1/*
2 * This file is part of the WebKit project.
3 *
4 * Copyright (C) 2006 Apple Computer, Inc.
5 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
6 * Copyright (C) 2007 Holger Hans Peter Freyther
7 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
8 * Copyright (C) 2008, 2009 Google, Inc.
9 * All rights reserved.
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB.  If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25 *
26 */
27
28#ifndef RenderThemeChromiumSkia_h
29#define RenderThemeChromiumSkia_h
30
31#include "RenderTheme.h"
32
33namespace WebCore {
34
35class RenderProgress;
36
37class RenderThemeChromiumSkia : public RenderTheme {
38    public:
39        RenderThemeChromiumSkia();
40        virtual ~RenderThemeChromiumSkia();
41
42        virtual String extraDefaultStyleSheet();
43        virtual String extraQuirksStyleSheet();
44#if ENABLE(VIDEO)
45        virtual String extraMediaControlsStyleSheet();
46#endif
47
48        // A method asking if the theme's controls actually care about redrawing when hovered.
49        virtual bool supportsHover(const RenderStyle*) const;
50
51        // A method asking if the theme is able to draw the focus ring.
52        virtual bool supportsFocusRing(const RenderStyle*) const;
53
54        // The platform selection color.
55        virtual Color platformActiveSelectionBackgroundColor() const;
56        virtual Color platformInactiveSelectionBackgroundColor() const;
57        virtual Color platformActiveSelectionForegroundColor() const;
58        virtual Color platformInactiveSelectionForegroundColor() const;
59        virtual Color platformFocusRingColor() const;
60
61        // To change the blink interval, override caretBlinkIntervalInternal instead of this one so that we may share layout test code an intercepts.
62        virtual double caretBlinkInterval() const;
63
64        // System fonts.
65        virtual void systemFont(int propId, FontDescription&) const;
66
67        virtual int minimumMenuListSize(RenderStyle*) const;
68
69        virtual void setCheckboxSize(RenderStyle*) const;
70
71        virtual void setRadioSize(RenderStyle*) const;
72
73        virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
74
75        virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&);
76
77        virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
78        virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
79
80        virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
81        virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
82
83        virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
84
85        virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
86        virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
87
88        virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
89        virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
90
91        virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&);
92        virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
93        virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
94        virtual void adjustSliderThumbSize(RenderObject*) const;
95        virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
96        virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
97        virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
98        virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
99
100        // MenuList refers to an unstyled menulist (meaning a menulist without
101        // background-color or border set) and MenuListButton refers to a styled
102        // menulist (a menulist with background-color or border set). They have
103        // this distinction to support showing aqua style themes whenever they
104        // possibly can, which is something we don't want to replicate.
105        //
106        // In short, we either go down the MenuList code path or the MenuListButton
107        // codepath. We never go down both. And in both cases, they render the
108        // entire menulist.
109        virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
110        virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
111        virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
112
113#if ENABLE(PROGRESS_TAG)
114        virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const;
115        virtual double animationDurationForProgressBar(RenderProgress*) const;
116#endif
117
118        // These methods define the padding for the MenuList's inner block.
119        virtual int popupInternalPaddingLeft(RenderStyle*) const;
120        virtual int popupInternalPaddingRight(RenderStyle*) const;
121        virtual int popupInternalPaddingTop(RenderStyle*) const;
122        virtual int popupInternalPaddingBottom(RenderStyle*) const;
123
124#if ENABLE(VIDEO)
125        // Media controls
126        virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const { return true; }
127#endif
128
129        // Provide a way to pass the default font size from the Settings object
130        // to the render theme.  FIXME: http://b/1129186 A cleaner way would be
131        // to remove the default font size from this object and have callers
132        // that need the value to get it directly from the appropriate Settings
133        // object.
134        static void setDefaultFontSize(int);
135
136    protected:
137        static const String& defaultGUIFont();
138
139        // The default variable-width font size.  We use this as the default font
140        // size for the "system font", and as a base size (which we then shrink) for
141        // form control fonts.
142        static float defaultFontSize;
143
144        virtual double caretBlinkIntervalInternal() const;
145
146        static void setSizeIfAuto(RenderStyle*, const IntSize&);
147
148#if ENABLE(PROGRESS_TAG)
149        IntRect determinateProgressValueRectFor(RenderProgress*, const IntRect&) const;
150        IntRect indeterminateProgressValueRectFor(RenderProgress*, const IntRect&) const;
151        IntRect progressValueRectFor(RenderProgress*, const IntRect&) const;
152#endif
153
154    private:
155        int menuListInternalPadding(RenderStyle*, int paddingType) const;
156        bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*);
157        IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const;
158    };
159
160} // namespace WebCore
161
162#endif // RenderThemeChromiumSkia_h
163