f9e8ea9aea183a945ed16beb5398ad7e118e2c92
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderThemeChromiumSkia.h
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 "core/rendering/RenderTheme.h"
32
33 namespace blink {
34
35 class RenderProgress;
36
37 class RenderThemeChromiumSkia : public RenderTheme {
38 public:
39     RenderThemeChromiumSkia();
40     virtual ~RenderThemeChromiumSkia();
41
42     virtual String extraDefaultStyleSheet() OVERRIDE;
43     virtual String extraQuirksStyleSheet() OVERRIDE;
44
45     virtual Color platformTapHighlightColor() const OVERRIDE
46     {
47         return Color(defaultTapHighlightColor);
48     }
49
50     // A method asking if the theme's controls actually care about redrawing when hovered.
51     virtual bool supportsHover(const RenderStyle*) const OVERRIDE FINAL;
52
53     // A method asking if the theme is able to draw the focus ring.
54     virtual bool supportsFocusRing(const RenderStyle*) const OVERRIDE;
55
56     // The platform selection color.
57     virtual Color platformActiveSelectionBackgroundColor() const OVERRIDE;
58     virtual Color platformInactiveSelectionBackgroundColor() const OVERRIDE;
59     virtual Color platformActiveSelectionForegroundColor() const OVERRIDE;
60     virtual Color platformInactiveSelectionForegroundColor() const OVERRIDE;
61     virtual Color platformFocusRingColor() const OVERRIDE;
62
63     // To change the blink interval, override caretBlinkIntervalInternal instead of this one so that we may share layout test code an intercepts.
64     virtual double caretBlinkInterval() const OVERRIDE;
65
66     // System fonts.
67     virtual void systemFont(CSSValueID, FontDescription&) const OVERRIDE;
68
69     virtual int minimumMenuListSize(RenderStyle*) const OVERRIDE;
70
71     virtual void setCheckboxSize(RenderStyle*) const OVERRIDE;
72
73     virtual void setRadioSize(RenderStyle*) const OVERRIDE;
74
75     virtual void adjustButtonStyle(RenderStyle*, Element*) const OVERRIDE;
76
77     virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
78
79     virtual void adjustSearchFieldStyle(RenderStyle*, Element*) const OVERRIDE;
80     virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
81
82     virtual void adjustSearchFieldCancelButtonStyle(RenderStyle*, Element*) const OVERRIDE;
83     virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
84
85     virtual void adjustSearchFieldDecorationStyle(RenderStyle*, Element*) const OVERRIDE;
86
87     virtual void adjustSearchFieldResultsDecorationStyle(RenderStyle*, Element*) const OVERRIDE;
88     virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
89
90     virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
91     virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
92     virtual void adjustSliderThumbSize(RenderStyle*, Element*) const OVERRIDE;
93     virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
94     virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
95     virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
96     virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
97     virtual bool paintMediaOverlayPlayButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
98     virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
99     virtual String formatMediaControlsTime(float time) const OVERRIDE;
100     virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const OVERRIDE;
101     virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
102
103     // MenuList refers to an unstyled menulist (meaning a menulist without
104     // background-color or border set) and MenuListButton refers to a styled
105     // menulist (a menulist with background-color or border set). They have
106     // this distinction to support showing aqua style themes whenever they
107     // possibly can, which is something we don't want to replicate.
108     //
109     // In short, we either go down the MenuList code path or the MenuListButton
110     // codepath. We never go down both. And in both cases, they render the
111     // entire menulist.
112     virtual void adjustMenuListStyle(RenderStyle*, Element*) const OVERRIDE;
113     virtual void adjustMenuListButtonStyle(RenderStyle*, Element*) const OVERRIDE;
114     virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
115
116     virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const OVERRIDE;
117     virtual double animationDurationForProgressBar(RenderProgress*) const OVERRIDE;
118
119     // These methods define the padding for the MenuList's inner block.
120     virtual int popupInternalPaddingLeft(RenderStyle*) const OVERRIDE;
121     virtual int popupInternalPaddingRight(RenderStyle*) const OVERRIDE;
122     virtual int popupInternalPaddingTop(RenderStyle*) const OVERRIDE;
123     virtual int popupInternalPaddingBottom(RenderStyle*) const OVERRIDE;
124
125     // Provide a way to pass the default font size from the Settings object
126     // to the render theme. FIXME: http://b/1129186 A cleaner way would be
127     // to remove the default font size from this object and have callers
128     // that need the value to get it directly from the appropriate Settings
129     // object.
130     static void setDefaultFontSize(int);
131
132 protected:
133     virtual double caretBlinkIntervalInternal() const;
134
135     virtual int menuListArrowPadding() const;
136
137     IntRect determinateProgressValueRectFor(RenderProgress*, const IntRect&) const;
138     IntRect indeterminateProgressValueRectFor(RenderProgress*, const IntRect&) const;
139     IntRect progressValueRectFor(RenderProgress*, const IntRect&) const;
140
141     class DirectionFlippingScope {
142     public:
143         DirectionFlippingScope(RenderObject*, const PaintInfo&, const IntRect&);
144         ~DirectionFlippingScope();
145
146     private:
147         bool m_needsFlipping;
148         const PaintInfo& m_paintInfo;
149     };
150
151 private:
152     virtual bool shouldShowPlaceholderWhenFocused() const OVERRIDE;
153
154     int menuListInternalPadding(RenderStyle*, int paddingType) const;
155     bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*);
156     IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const;
157
158     static const RGBA32 defaultTapHighlightColor = 0x2e000000; // 18% black.
159 };
160
161 } // namespace blink
162
163 #endif // RenderThemeChromiumSkia_h