- Revision
- 102655
- Author
- commit-qu...@webkit.org
- Date
- 2011-12-12 19:48:54 -0800 (Mon, 12 Dec 2011)
Log Message
RenderTheme should have a function for disabled text color adjustment
https://bugs.webkit.org/show_bug.cgi?id=74143
Patch by Yosifumi Inoue <yo...@chromium.org> on 2011-12-12
Reviewed by Kent Tamura.
No new tests / existing tests cover this change.
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::adjustInnerTextStyle): Use RenderTheme::disabledTextColor instead of PLATFORM wraped static function.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::disabledTextColor): Moved from RenderTextControl.cpp. This method implements for non-Chromium color.
* rendering/RenderTheme.h: Add new virtual method disabledTextColor.
* rendering/RenderThemeChromiumMac.h: Implementation of RenderTheme::disabledTextColor for Chrimium Mac.
* rendering/RenderThemeChromiumSkia.h: Implementation of RenderTheme::disabledTextColor for Chrimium.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (102654 => 102655)
--- trunk/Source/WebCore/ChangeLog 2011-12-13 03:28:19 UTC (rev 102654)
+++ trunk/Source/WebCore/ChangeLog 2011-12-13 03:48:54 UTC (rev 102655)
@@ -1,3 +1,20 @@
+2011-12-12 Yosifumi Inoue <yo...@chromium.org>
+
+ RenderTheme should have a function for disabled text color adjustment
+ https://bugs.webkit.org/show_bug.cgi?id=74143
+
+ Reviewed by Kent Tamura.
+
+ No new tests / existing tests cover this change.
+
+ * rendering/RenderTextControl.cpp:
+ (WebCore::RenderTextControl::adjustInnerTextStyle): Use RenderTheme::disabledTextColor instead of PLATFORM wraped static function.
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::disabledTextColor): Moved from RenderTextControl.cpp. This method implements for non-Chromium color.
+ * rendering/RenderTheme.h: Add new virtual method disabledTextColor.
+ * rendering/RenderThemeChromiumMac.h: Implementation of RenderTheme::disabledTextColor for Chrimium Mac.
+ * rendering/RenderThemeChromiumSkia.h: Implementation of RenderTheme::disabledTextColor for Chrimium.
+
2011-12-12 Kenneth Russell <k...@google.com>
Unreviewed, rolling out r102648.
Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (102654 => 102655)
--- trunk/Source/WebCore/rendering/RenderTextControl.cpp 2011-12-13 03:28:19 UTC (rev 102654)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp 2011-12-13 03:48:54 UTC (rev 102655)
@@ -25,6 +25,7 @@
#include "HTMLTextFormControlElement.h"
#include "HitTestResult.h"
#include "RenderText.h"
+#include "RenderTheme.h"
#include "ScrollbarTheme.h"
#include "TextIterator.h"
#include "VisiblePosition.h"
@@ -34,32 +35,6 @@
namespace WebCore {
-#if !PLATFORM(CHROMIUM)
-// Value chosen by observation. This can be tweaked.
-static const int minColorContrastValue = 1300;
-// For transparent or translucent background color, use lightening.
-static const int minDisabledColorAlphaValue = 128;
-
-static Color disabledTextColor(const Color& textColor, const Color& backgroundColor)
-{
- // The explicit check for black is an optimization for the 99% case (black on white).
- // This also means that black on black will turn into grey on black when disabled.
- Color disabledColor;
- if (textColor.rgb() == Color::black || backgroundColor.alpha() < minDisabledColorAlphaValue || differenceSquared(textColor, Color::white) > differenceSquared(backgroundColor, Color::white))
- disabledColor = textColor.light();
- else
- disabledColor = textColor.dark();
-
- // If there's not very much contrast between the disabled color and the background color,
- // just leave the text color alone. We don't want to change a good contrast color scheme so that it has really bad contrast.
- // If the the contrast was already poor, then it doesn't do any good to change it to a different poor contrast color scheme.
- if (differenceSquared(disabledColor, backgroundColor) < minColorContrastValue)
- return textColor;
-
- return disabledColor;
-}
-#endif
-
RenderTextControl::RenderTextControl(Node* node)
: RenderBlock(node)
{
@@ -121,13 +96,8 @@
textBlockStyle->setUnicodeBidi(style()->unicodeBidi());
bool disabled = updateUserModifyProperty(node(), textBlockStyle);
- if (disabled) {
-#if PLATFORM(CHROMIUM)
- textBlockStyle->setColor(textBlockStyle->visitedDependentColor(CSSPropertyColor));
-#else
- textBlockStyle->setColor(disabledTextColor(textBlockStyle->visitedDependentColor(CSSPropertyColor), startStyle->visitedDependentColor(CSSPropertyBackgroundColor)));
-#endif
- }
+ if (disabled)
+ textBlockStyle->setColor(theme()->disabledTextColor(textBlockStyle->visitedDependentColor(CSSPropertyColor), startStyle->visitedDependentColor(CSSPropertyBackgroundColor)));
}
int RenderTextControl::textBlockHeight() const
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (102654 => 102655)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2011-12-13 03:28:19 UTC (rev 102654)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2011-12-13 03:48:54 UTC (rev 102655)
@@ -1091,6 +1091,30 @@
}
#endif
+// Value chosen by observation. This can be tweaked.
+static const int minColorContrastValue = 1300;
+// For transparent or translucent background color, use lightening.
+static const int minDisabledColorAlphaValue = 128;
+
+Color RenderTheme::disabledTextColor(const Color& textColor, const Color& backgroundColor) const
+{
+ // The explicit check for black is an optimization for the 99% case (black on white).
+ // This also means that black on black will turn into grey on black when disabled.
+ Color disabledColor;
+ if (textColor.rgb() == Color::black || backgroundColor.alpha() < minDisabledColorAlphaValue || differenceSquared(textColor, Color::white) > differenceSquared(backgroundColor, Color::white))
+ disabledColor = textColor.light();
+ else
+ disabledColor = textColor.dark();
+
+ // If there's not very much contrast between the disabled color and the background color,
+ // just leave the text color alone. We don't want to change a good contrast color scheme so that it has really bad contrast.
+ // If the the contrast was already poor, then it doesn't do any good to change it to a different poor contrast color scheme.
+ if (differenceSquared(disabledColor, backgroundColor) < minColorContrastValue)
+ return textColor;
+
+ return disabledColor;
+}
+
void RenderTheme::setCustomFocusRingColor(const Color& c)
{
customFocusRingColor() = c;
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (102654 => 102655)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2011-12-13 03:28:19 UTC (rev 102654)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2011-12-13 03:48:54 UTC (rev 102655)
@@ -146,6 +146,8 @@
virtual Color platformActiveTextSearchHighlightColor() const;
virtual Color platformInactiveTextSearchHighlightColor() const;
+ virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const;
+
static Color focusRingColor();
virtual Color platformFocusRingColor() const { return Color(0, 0, 0); }
static void setCustomFocusRingColor(const Color&);
Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h (102654 => 102655)
--- trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h 2011-12-13 03:28:19 UTC (rev 102654)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h 2011-12-13 03:48:54 UTC (rev 102655)
@@ -31,6 +31,9 @@
class RenderThemeChromiumMac : public RenderThemeMac {
public:
static PassRefPtr<RenderTheme> create();
+
+ virtual Color disabledTextColor(const Color& textColor, const Color&) const OVERRIDE { return textColor; }
+
protected:
#if ENABLE(VIDEO)
virtual void adjustMediaSliderThumbSize(RenderStyle*) const;
Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h (102654 => 102655)
--- trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h 2011-12-13 03:28:19 UTC (rev 102654)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h 2011-12-13 03:48:54 UTC (rev 102655)
@@ -58,6 +58,8 @@
virtual Color platformInactiveSelectionForegroundColor() const;
virtual Color platformFocusRingColor() const;
+ virtual Color disabledTextColor(const Color& textColor, const Color&) const OVERRIDE { return textColor; }
+
// To change the blink interval, override caretBlinkIntervalInternal instead of this one so that we may share layout test code an intercepts.
virtual double caretBlinkInterval() const;