[EFL] Refactor theme to choose whether to support foreground color of selection
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 14:23:18 +0000 (14:23 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 14:23:18 +0000 (14:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102037

Patch by Ryuan Choi <ryuan.choi@gmail.com> 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136005 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/efl/RenderThemeEfl.cpp
Source/WebCore/platform/efl/RenderThemeEfl.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/DefaultTheme/default.edc

index 34044a7..a5ab206 100644 (file)
@@ -1,3 +1,30 @@
+2012-11-28  Ryuan Choi  <ryuan.choi@gmail.com>
+
+        [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  <allan.jensen@digia.com>
 
         Move childrenAffectedBy bits from RenderStyle to Element
index 67d8483..936f983 100644 (file)
@@ -406,14 +406,14 @@ static void applyColorCallback(void* data, Evas_Object*, const char* /* signal *
     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 @@ static void fillColorsFromEdjeClass(Evas_Object* o, const char* colorClass, Colo
         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 @@ bool RenderThemeEfl::loadTheme()
     // 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 @@ RenderThemeEfl::RenderThemeEfl(Page* page)
     , m_mediaPanelColor(220, 220, 195) // light tannish color.
     , m_mediaSliderColor(Color::white)
 #endif
+    , m_supportsSelectionForegroundColor(false)
     , m_partCache(0)
 {
 }
@@ -678,6 +683,12 @@ Color RenderThemeEfl::platformFocusRingColor() const
     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)
index 34999f1..622213c 100644 (file)
@@ -96,6 +96,9 @@ public:
     // 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 @@ private:
     OwnPtr<Ecore_Evas> m_canvas;
     RefPtr<Evas_Object> m_edje;
 
+    bool m_supportsSelectionForegroundColor;
+
     struct ThemePartDesc {
         FormType type;
         LengthSize min;
index 0b933ce..14b3744 100644 (file)
@@ -1,3 +1,13 @@
+2012-11-28  Ryuan Choi  <ryuan.choi@gmail.com>
+
+        [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  <simonjam@chromium.org>
 
         Consolidate FrameLoader::load() into one function taking a FrameLoadRequest
index e234839..2ac69c5 100644 (file)
 
 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";