Title: [136005] trunk/Source
Revision
136005
Author
[email protected]
Date
2012-11-28 06:23:18 -0800 (Wed, 28 Nov 2012)

Log Message

[EFL] Refactor theme to choose whether to support foreground color of selection
https://bugs.webkit.org/show_bug.cgi?id=102037

Patch by Ryuan Choi <[email protected]> on 2012-11-28
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

If foreground selection color is supported, selected text is painted to
SelectionForegroundColor instead of text color. If not, text can be painted
to text color.

However, EFL port does not have a way to disable support of foreground
selection color. So this patch refactors color classes of theme from
active and inactive to foreground and background in order to disable support
of foreground selection color when foreground color class is not specified.

* platform/efl/RenderThemeEfl.cpp:
(WebCore::fillColorsFromEdjeClass):
Returned false without error message when colorClass is not specified.
(WebCore::RenderThemeEfl::setColorFromThemeClass):
(WebCore::RenderThemeEfl::loadTheme):
(WebCore::RenderThemeEfl::RenderThemeEfl):
(WebCore::RenderThemeEfl::supportsSelectionForegroundColors):
(WebCore):
* platform/efl/RenderThemeEfl.h:
(RenderThemeEfl):

Source/WebKit/efl:

* DefaultTheme/default.edc:
Refactored color classes from active/inactive to foreground/background.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (136004 => 136005)


--- trunk/Source/WebCore/ChangeLog	2012-11-28 14:12:30 UTC (rev 136004)
+++ trunk/Source/WebCore/ChangeLog	2012-11-28 14:23:18 UTC (rev 136005)
@@ -1,3 +1,30 @@
+2012-11-28  Ryuan Choi  <[email protected]>
+
+        [EFL] Refactor theme to choose whether to support foreground color of selection
+        https://bugs.webkit.org/show_bug.cgi?id=102037
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        If foreground selection color is supported, selected text is painted to
+        SelectionForegroundColor instead of text color. If not, text can be painted
+        to text color.
+
+        However, EFL port does not have a way to disable support of foreground
+        selection color. So this patch refactors color classes of theme from
+        active and inactive to foreground and background in order to disable support
+        of foreground selection color when foreground color class is not specified.
+
+        * platform/efl/RenderThemeEfl.cpp:
+        (WebCore::fillColorsFromEdjeClass):
+        Returned false without error message when colorClass is not specified.
+        (WebCore::RenderThemeEfl::setColorFromThemeClass):
+        (WebCore::RenderThemeEfl::loadTheme):
+        (WebCore::RenderThemeEfl::RenderThemeEfl):
+        (WebCore::RenderThemeEfl::supportsSelectionForegroundColors):
+        (WebCore):
+        * platform/efl/RenderThemeEfl.h:
+        (RenderThemeEfl):
+
 2012-11-28  Allan Sandfeld Jensen  <[email protected]>
 
         Move childrenAffectedBy bits from RenderStyle to Element

Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp (136004 => 136005)


--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp	2012-11-28 14:12:30 UTC (rev 136004)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp	2012-11-28 14:23:18 UTC (rev 136005)
@@ -406,14 +406,14 @@
     that->platformColorsDidChange(); // Triggers relayout.
 }
 
-static void fillColorsFromEdjeClass(Evas_Object* o, const char* colorClass, Color* color1, Color* color2 = 0, Color* color3 = 0)
+static bool fillColorsFromEdjeClass(Evas_Object* o, const char* colorClass, Color* color1, Color* color2 = 0, Color* color3 = 0)
 {
     int r1, g1, b1, a1;
     int r2, g2, b2, a2;
     int r3, g3, b3, a3;
 
-    bool ok = edje_object_color_class_get(o, colorClass, &r1, &g1, &b1, &a1, &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3);
-    _ASSERT_ON_RELEASE_RETURN(ok, "Could not get color class '%s'\n", colorClass);
+    if (!edje_object_color_class_get(o, colorClass, &r1, &g1, &b1, &a1, &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3))
+        return false;
 
     if (color1)
         color1->setRGB(makeRGBA(r1, g1, b1, a1));
@@ -421,18 +421,22 @@
         color2->setRGB(makeRGBA(r2, g2, b2, a2));
     if (color3)
         color3->setRGB(makeRGBA(r3, g3, b3, a3));
+
+    return true;
 }
 
 void RenderThemeEfl::setColorFromThemeClass(const char* colorClass)
 {
     ASSERT(edje());
 
-    if (!strcmp("webkit/selection/active", colorClass))
-        fillColorsFromEdjeClass(edje(), colorClass, &m_activeSelectionForegroundColor, &m_activeSelectionBackgroundColor);
-    else if (!strcmp("webkit/selection/inactive", colorClass))
-        fillColorsFromEdjeClass(edje(), colorClass, &m_inactiveSelectionForegroundColor, &m_inactiveSelectionBackgroundColor);
+    if (!strcmp("webkit/selection/foreground", colorClass))
+        m_supportsSelectionForegroundColor = fillColorsFromEdjeClass(edje(), colorClass, &m_activeSelectionForegroundColor, &m_inactiveSelectionForegroundColor);
+    else if (!strcmp("webkit/selection/background", colorClass))
+        fillColorsFromEdjeClass(edje(), colorClass, &m_activeSelectionBackgroundColor, &m_inactiveSelectionBackgroundColor);
     else if (!strcmp("webkit/focus_ring", colorClass)) {
-        fillColorsFromEdjeClass(edje(), colorClass, &m_focusRingColor);
+        if (!fillColorsFromEdjeClass(edje(), colorClass, &m_focusRingColor))
+            return;
+
         // platformFocusRingColor() is only used for the default theme (without page)
         // The following is ugly, but no other way to do it unless we change it to use page themes as much as possible.
         RenderTheme::setCustomFocusRingColor(m_focusRingColor);
@@ -493,14 +497,14 @@
     // Set new loaded theme, and apply it.
     m_edje = o;
 
-    edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/active", applyColorCallback, this);
-    edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/inactive", applyColorCallback, this);
+    edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/foreground", applyColorCallback, this);
+    edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/background", applyColorCallback, this);
     edje_object_signal_callback_add(edje(), "color_class,set", "webkit/focus_ring", applyColorCallback, this);
 
     applyPartDescriptionsFrom(m_themePath);
 
-    setColorFromThemeClass("webkit/selection/active");
-    setColorFromThemeClass("webkit/selection/inactive");
+    setColorFromThemeClass("webkit/selection/foreground");
+    setColorFromThemeClass("webkit/selection/background");
     setColorFromThemeClass("webkit/focus_ring");
 
     platformColorsDidChange(); // Schedules a relayout, do last.
@@ -598,6 +602,7 @@
     , m_mediaPanelColor(220, 220, 195) // light tannish color.
     , m_mediaSliderColor(Color::white)
 #endif
+    , m_supportsSelectionForegroundColor(false)
     , m_partCache(0)
 {
 }
@@ -678,6 +683,12 @@
     return m_focusRingColor;
 }
 
+bool RenderThemeEfl::supportsSelectionForegroundColors() const
+{
+    loadThemeIfNeeded();
+    return m_supportsSelectionForegroundColor;
+}
+
 bool RenderThemeEfl::paintSliderTrack(RenderObject* object, const PaintInfo& info, const IntRect& rect)
 {
     if (object->style()->appearance() == SliderHorizontalPart)

Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.h (136004 => 136005)


--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.h	2012-11-28 14:12:30 UTC (rev 136004)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.h	2012-11-28 14:23:18 UTC (rev 136005)
@@ -96,6 +96,9 @@
     // A general method asking if any control tinting is supported at all.
     virtual bool supportsControlTints() const { return true; }
 
+    // A general method asking if foreground colors of selection are supported.
+    virtual bool supportsSelectionForegroundColors() const;
+
     // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
     // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
     // controls that need to do this.
@@ -255,6 +258,8 @@
     OwnPtr<Ecore_Evas> m_canvas;
     RefPtr<Evas_Object> m_edje;
 
+    bool m_supportsSelectionForegroundColor;
+
     struct ThemePartDesc {
         FormType type;
         LengthSize min;

Modified: trunk/Source/WebKit/efl/ChangeLog (136004 => 136005)


--- trunk/Source/WebKit/efl/ChangeLog	2012-11-28 14:12:30 UTC (rev 136004)
+++ trunk/Source/WebKit/efl/ChangeLog	2012-11-28 14:23:18 UTC (rev 136005)
@@ -1,3 +1,13 @@
+2012-11-28  Ryuan Choi  <[email protected]>
+
+        [EFL] Refactor theme to choose whether to support foreground color of selection
+        https://bugs.webkit.org/show_bug.cgi?id=102037
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * DefaultTheme/default.edc:
+        Refactored color classes from active/inactive to foreground/background.
+
 2012-11-27  James Simonsen  <[email protected]>
 
         Consolidate FrameLoader::load() into one function taking a FrameLoadRequest

Modified: trunk/Source/WebKit/efl/DefaultTheme/default.edc (136004 => 136005)


--- trunk/Source/WebKit/efl/DefaultTheme/default.edc	2012-11-28 14:12:30 UTC (rev 136004)
+++ trunk/Source/WebKit/efl/DefaultTheme/default.edc	2012-11-28 14:23:18 UTC (rev 136005)
@@ -21,14 +21,14 @@
 
 color_classes {
    color_class {
-      name: "webkit/selection/active";
-      color: 255 255 255 255; /* foreground */
-      color2: 86 86 209 255; /* background */
+      name: "webkit/selection/foreground";
+      color: 255 255 255 255; /* active */
+      color2: 255 255 255 255; /* inactive */
    }
    color_class {
-      name: "webkit/selection/inactive";
-      color: 255 255 255 255; /* foreground */
-      color2: 0 0 128 128; /* background */
+      name: "webkit/selection/background";
+      color: 86 86 209 255; /* active */
+      color2: 0 0 128 128; /* inactive */
    }
    color_class {
       name: "webkit/focus_ring";
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to