Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1389)

Unified Diff: Source/core/rendering/RenderTheme.cpp

Issue 20061003: Move isValid/isCurrentColor from Color to StyleColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderTheme.cpp
diff --git a/Source/core/rendering/RenderTheme.cpp b/Source/core/rendering/RenderTheme.cpp
index 790b9ed634e69448d728dae88c2a6074372d430c..e182a4d71d046a6d43aa77478d885ed2c3e55dd6 100644
--- a/Source/core/rendering/RenderTheme.cpp
+++ b/Source/core/rendering/RenderTheme.cpp
@@ -68,9 +68,9 @@ namespace WebCore {
using namespace HTMLNames;
-static Color& customFocusRingColor()
+static StyleColor& customFocusRingColor()
{
- DEFINE_STATIC_LOCAL(Color, color, ());
+ DEFINE_STATIC_LOCAL(StyleColor, color, ());
return color;
}
@@ -91,6 +91,7 @@ RenderTheme::RenderTheme()
: m_theme(platformTheme())
#endif
{
+ m_selectionColorsValid = 0;
}
void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyle& uaStyle)
@@ -525,59 +526,88 @@ String RenderTheme::formatMediaControlsCurrentTime(float currentTime, float /*du
return formatMediaControlsTime(currentTime);
}
+namespace SelectionColors {
+enum {
+ ActiveBackground = 1,
+ InactiveBackground = 2,
+ ActiveForeground = 4,
+ InactiveForeground = 8,
+ ActiveListBoxBackground = 16,
+ InactiveListBoxBackground = 32,
+ ActiveListBoxForeground = 64,
+ InactiveListBoxForeground = 128
+};
+};
+
Color RenderTheme::activeSelectionBackgroundColor() const
{
- if (!m_activeSelectionBackgroundColor.isValid())
+ if (!(m_selectionColorsValid & SelectionColors::ActiveBackground)) {
m_activeSelectionBackgroundColor = platformActiveSelectionBackgroundColor().blendWithWhite();
+ m_selectionColorsValid |= SelectionColors::ActiveBackground;
+ }
return m_activeSelectionBackgroundColor;
}
Color RenderTheme::inactiveSelectionBackgroundColor() const
{
- if (!m_inactiveSelectionBackgroundColor.isValid())
+ if (!(m_selectionColorsValid & SelectionColors::InactiveBackground)) {
m_inactiveSelectionBackgroundColor = platformInactiveSelectionBackgroundColor().blendWithWhite();
+ m_selectionColorsValid |= SelectionColors::InactiveBackground;
+ }
return m_inactiveSelectionBackgroundColor;
}
Color RenderTheme::activeSelectionForegroundColor() const
{
- if (!m_activeSelectionForegroundColor.isValid() && supportsSelectionForegroundColors())
+ if (!(m_selectionColorsValid & SelectionColors::ActiveForeground) && supportsSelectionForegroundColors()) {
m_activeSelectionForegroundColor = platformActiveSelectionForegroundColor();
+ m_selectionColorsValid |= SelectionColors::ActiveForeground;
+ }
return m_activeSelectionForegroundColor;
}
Color RenderTheme::inactiveSelectionForegroundColor() const
{
- if (!m_inactiveSelectionForegroundColor.isValid() && supportsSelectionForegroundColors())
+ if (!(m_selectionColorsValid & SelectionColors::InactiveForeground) && supportsSelectionForegroundColors()) {
m_inactiveSelectionForegroundColor = platformInactiveSelectionForegroundColor();
+ m_selectionColorsValid |= SelectionColors::InactiveForeground;
+ }
return m_inactiveSelectionForegroundColor;
}
Color RenderTheme::activeListBoxSelectionBackgroundColor() const
{
- if (!m_activeListBoxSelectionBackgroundColor.isValid())
+ if (!(m_selectionColorsValid & SelectionColors::ActiveListBoxBackground)) {
m_activeListBoxSelectionBackgroundColor = platformActiveListBoxSelectionBackgroundColor();
+ m_selectionColorsValid |= SelectionColors::ActiveListBoxBackground;
+ }
return m_activeListBoxSelectionBackgroundColor;
}
Color RenderTheme::inactiveListBoxSelectionBackgroundColor() const
{
- if (!m_inactiveListBoxSelectionBackgroundColor.isValid())
+ if (!(m_selectionColorsValid & SelectionColors::InactiveListBoxBackground)) {
m_inactiveListBoxSelectionBackgroundColor = platformInactiveListBoxSelectionBackgroundColor();
+ m_selectionColorsValid |= SelectionColors::InactiveListBoxBackground;
+ }
return m_inactiveListBoxSelectionBackgroundColor;
}
Color RenderTheme::activeListBoxSelectionForegroundColor() const
{
- if (!m_activeListBoxSelectionForegroundColor.isValid() && supportsListBoxSelectionForegroundColors())
+ if (!(m_selectionColorsValid & SelectionColors::ActiveListBoxForeground) && supportsListBoxSelectionForegroundColors()) {
m_activeListBoxSelectionForegroundColor = platformActiveListBoxSelectionForegroundColor();
+ m_selectionColorsValid |= SelectionColors::ActiveListBoxForeground;
+ }
return m_activeListBoxSelectionForegroundColor;
}
Color RenderTheme::inactiveListBoxSelectionForegroundColor() const
{
- if (!m_inactiveListBoxSelectionForegroundColor.isValid() && supportsListBoxSelectionForegroundColors())
+ if (!(m_selectionColorsValid & SelectionColors::InactiveListBoxForeground) && supportsListBoxSelectionForegroundColors()) {
m_inactiveListBoxSelectionForegroundColor = platformInactiveListBoxSelectionForegroundColor();
+ m_selectionColorsValid |= SelectionColors::InactiveListBoxForeground;
+ }
return m_inactiveListBoxSelectionForegroundColor;
}
@@ -659,7 +689,7 @@ static bool isBackgroundOrBorderStyled(const RenderStyle& style, const CachedUAS
// Test the style to see if the UA border and background match.
return style.border() != uaStyle.border
|| backgroundLayersCopy != backgroundCopy
- || style.visitedDependentColor(CSSPropertyBackgroundColor) != uaStyle.backgroundColor;
+ || style.visitedDependentColor(CSSPropertyBackgroundColor).color() != uaStyle.backgroundColor;
}
bool RenderTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle& uaStyle) const
@@ -1092,16 +1122,7 @@ void RenderTheme::adjustSearchFieldResultsDecorationStyle(RenderStyle*, Element*
void RenderTheme::platformColorsDidChange()
{
- m_activeSelectionForegroundColor = Color();
- m_inactiveSelectionForegroundColor = Color();
- m_activeSelectionBackgroundColor = Color();
- m_inactiveSelectionBackgroundColor = Color();
-
- m_activeListBoxSelectionForegroundColor = Color();
- m_inactiveListBoxSelectionForegroundColor = Color();
- m_activeListBoxSelectionBackgroundColor = Color();
- m_inactiveListBoxSelectionForegroundColor = Color();
-
+ m_selectionColorsValid = 0;
Page::scheduleForcedStyleRecalcForAllPages();
}
@@ -1206,7 +1227,7 @@ void RenderTheme::setCustomFocusRingColor(const Color& c)
Color RenderTheme::focusRingColor()
{
- return customFocusRingColor().isValid() ? customFocusRingColor() : defaultTheme()->platformFocusRingColor();
+ return customFocusRingColor().isValid() ? customFocusRingColor().color() : defaultTheme()->platformFocusRingColor();
}
String RenderTheme::fileListDefaultLabel(bool multipleFilesAllowed) const

Powered by Google App Engine
This is Rietveld 408576698