2010-08-03 Leandro Pereira <leandro@profusion.mobi>
authorleandro@webkit.org <leandro@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Aug 2010 18:18:35 +0000 (18:18 +0000)
committerleandro@webkit.org <leandro@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Aug 2010 18:18:35 +0000 (18:18 +0000)
        Reviewed by Kenneth Rohde Christiansen.

        Implement HTML5 slider theme (using the scrollbar theme as base).
        https://bugs.webkit.org/show_bug.cgi?id=43430

        * DefaultTheme/default.edc: Include slider.edc.
        * DefaultTheme/widget/slider/slider.edc: Added.
        * DefaultTheme/widget/slider/slider_h.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_h.png.
        * DefaultTheme/widget/slider/slider_hilight.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_hilight.png.
        * DefaultTheme/widget/slider/slider_knob_h.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_knob_h.png.
        * DefaultTheme/widget/slider/slider_knob_v.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_knob_v.png.
        * DefaultTheme/widget/slider/slider_v.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_v.png.
2010-08-03  Leandro Pereira  <leandro@profusion.mobi>

        Reviewed by Kenneth Rohde Christiansen.

        [EFL] Implement HTML5 slider theme (using the scrollbar theme as base).
        https://bugs.webkit.org/show_bug.cgi?id=43430

        EFL port does not yet support automated tests.

        * platform/efl/RenderThemeEfl.cpp:
        (WebCore::RenderThemeEfl::paintThemePart):
        (WebCore::RenderThemeEfl::edjeGroupFromFormType): Add Edje groups
        for both vertical and horizontal sliders.
        (WebCore::supportsFocus): Add sliders as focusable elements.
        (WebCore::RenderThemeEfl::paintSliderTrack): Implement.
        (WebCore::RenderThemeEfl::adjustSliderTrackStyle): Implement.
        (WebCore::RenderThemeEfl::adjustSliderThumbStyle): Use
        adjustSliderTrackStyle() implementation.
        (WebCore::RenderThemeEfl::paintSliderThumb): Use paintSliderTrack()
        implementation().
        * platform/efl/RenderThemeEfl.h: Add SliderVertical and
        * SliderHorizontal.
        (WebCore::): Added prototypes for adjustSlider*/paintSlider*.

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

WebCore/ChangeLog
WebCore/platform/efl/RenderThemeEfl.cpp
WebCore/platform/efl/RenderThemeEfl.h
WebKit/efl/ChangeLog
WebKit/efl/DefaultTheme/default.edc
WebKit/efl/DefaultTheme/widget/slider/slider.edc [new file with mode: 0644]
WebKit/efl/DefaultTheme/widget/slider/slider_h.png [new file with mode: 0644]
WebKit/efl/DefaultTheme/widget/slider/slider_hilight.png [new file with mode: 0644]
WebKit/efl/DefaultTheme/widget/slider/slider_knob_h.png [new file with mode: 0644]
WebKit/efl/DefaultTheme/widget/slider/slider_knob_v.png [new file with mode: 0644]
WebKit/efl/DefaultTheme/widget/slider/slider_v.png [new file with mode: 0644]

index 3daa0fc47a0df825dcbdb9f2a9a2ff625200bbb6..4180fa146b93f1c75f6f92418c402b57306f6b12 100644 (file)
@@ -1,3 +1,27 @@
+2010-08-03  Leandro Pereira  <leandro@profusion.mobi>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [EFL] Implement HTML5 slider theme (using the scrollbar theme as base).
+        https://bugs.webkit.org/show_bug.cgi?id=43430
+
+        EFL port does not yet support automated tests.
+
+        * platform/efl/RenderThemeEfl.cpp:
+        (WebCore::RenderThemeEfl::paintThemePart):
+        (WebCore::RenderThemeEfl::edjeGroupFromFormType): Add Edje groups
+        for both vertical and horizontal sliders.
+        (WebCore::supportsFocus): Add sliders as focusable elements.
+        (WebCore::RenderThemeEfl::paintSliderTrack): Implement.
+        (WebCore::RenderThemeEfl::adjustSliderTrackStyle): Implement.
+        (WebCore::RenderThemeEfl::adjustSliderThumbStyle): Use
+        adjustSliderTrackStyle() implementation.
+        (WebCore::RenderThemeEfl::paintSliderThumb): Use paintSliderTrack()
+        implementation().
+        * platform/efl/RenderThemeEfl.h: Add SliderVertical and
+        * SliderHorizontal.
+        (WebCore::): Added prototypes for adjustSlider*/paintSlider*.
+
 2010-08-03  Alexander Pavlov  <apavlov@chromium.org>
 
         Reviewed by Joseph Pecoraro.
index d5a5365419007f4345068f42684fe19a8bcd2f27..36600a9f53d48b788ee8908b077a223ad7c867a5 100644 (file)
@@ -34,6 +34,7 @@
 #include "Page.h"
 #include "RenderBox.h"
 #include "RenderObject.h"
+#include "RenderSlider.h"
 #include <wtf/text/CString.h>
 
 #include <Ecore_Evas.h>
@@ -256,7 +257,7 @@ void RenderThemeEfl::applyEdjeStateFromForm(Evas_Object* o, ControlStates states
 
 bool RenderThemeEfl::paintThemePart(RenderObject* o, FormType type, const PaintInfo& i, const IntRect& rect)
 {
-    struct ThemePartCacheEntry* ce;
+    ThemePartCacheEntry* ce;
     Eina_List* updates;
     cairo_t* cairo;
 
@@ -273,6 +274,29 @@ bool RenderThemeEfl::paintThemePart(RenderObject* o, FormType type, const PaintI
     cairo = i.context->platformContext();
     ASSERT(cairo);
 
+    // Currently, only sliders needs this message; if other widget ever needs special
+    // treatment, move them to special functions.
+    if (type == SliderVertical || type == SliderHorizontal) {
+        RenderSlider* renderSlider = toRenderSlider(o);
+        Edje_Message_Float_Set* msg;
+        int max, value;
+
+        if (type == SliderVertical) {
+            max = rect.height() - renderSlider->thumbRect().height();
+            value = renderSlider->thumbRect().y();
+        } else {
+            max = rect.width() - renderSlider->thumbRect().width();
+            value = renderSlider->thumbRect().x();
+        }
+
+        msg = static_cast<Edje_Message_Float_Set*>(alloca(sizeof(Edje_Message_Float_Set) + sizeof(float)));
+
+        msg->count = 2;
+        msg->val[0] = static_cast<float>(value) / static_cast<float>(max);
+        msg->val[1] = 0.1;
+        edje_object_message_send(ce->o, EDJE_MESSAGE_FLOAT_SET, 0, msg);
+    }
+
     edje_object_calc_force(ce->o);
     edje_object_message_signal_process(ce->o);
     updates = evas_render_updates(ecore_evas_get(ce->ee));
@@ -542,6 +566,8 @@ const char* RenderThemeEfl::edjeGroupFromFormType(FormType type) const
         W("search/results_button"),
         W("search/results_decoration"),
         W("search/cancel_button"),
+        W("slider/vertical"),
+        W("slider/horizontal"),
 #undef W
         0
     };
@@ -702,6 +728,8 @@ static bool supportsFocus(ControlPart appearance)
     case MenulistPart:
     case RadioPart:
     case CheckboxPart:
+    case SliderVerticalPart:
+    case SliderHorizontalPart:
         return true;
     default:
         return false;
@@ -730,6 +758,40 @@ int RenderThemeEfl::baselinePosition(const RenderObject* o) const
     return RenderTheme::baselinePosition(o);
 }
 
+bool RenderThemeEfl::paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& rect)
+{
+    if (o->style()->appearance() == SliderHorizontalPart)
+        return paintThemePart(o, SliderHorizontal, i, rect);
+    return paintThemePart(o, SliderVertical, i, rect);
+}
+
+void RenderThemeEfl::adjustSliderTrackStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+    if (!m_page && e && e->document()->page()) {
+        static_cast<RenderThemeEfl*>(e->document()->page()->theme())->adjustSliderTrackStyle(selector, style, e);
+        return;
+    }
+
+    adjustSizeConstraints(style, SliderHorizontal);
+    style->resetBorder();
+
+    const struct ThemePartDesc *desc = m_partDescs + (size_t)SliderHorizontal;
+    if (style->width().value() < desc->min.width().value())
+        style->setWidth(desc->min.width());
+    if (style->height().value() < desc->min.height().value())
+        style->setHeight(desc->min.height());
+}
+
+void RenderThemeEfl::adjustSliderThumbStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+    adjustSliderTrackStyle(selector, style, e);
+}
+
+bool RenderThemeEfl::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& rect)
+{
+    return paintSliderTrack(o, i, rect);
+}
+
 void RenderThemeEfl::adjustCheckboxStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
 {
     if (!m_page && e && e->document()->page()) {
index 9753a76ab31322fb02a91f2e6a2cab5a24630fa9..8e5650d629189cc741bb01ae81737f5aaf68c364 100644 (file)
@@ -50,6 +50,8 @@ enum FormType { // KEEP IN SYNC WITH edjeGroupFromFormType()
     SearchFieldResultsButton,
     SearchFieldResultsDecoration,
     SearchFieldCancelButton,
+    SliderVertical,
+    SliderHorizontal,
     FormTypeLast
 };
 
@@ -135,6 +137,11 @@ public:
     virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
 
+    virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+    virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
+
+    virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+    virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
 private:
     void createCanvas();
     void createEdje();
index 0632ff11267d8173451cb87b80c762564691e7d7..e7e209fe3253e8593f59caaea4cc8c6e06c85180 100644 (file)
@@ -1,3 +1,18 @@
+2010-08-03  Leandro Pereira  <leandro@profusion.mobi>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Implement HTML5 slider theme (using the scrollbar theme as base).
+        https://bugs.webkit.org/show_bug.cgi?id=43430
+
+        * DefaultTheme/default.edc: Include slider.edc.
+        * DefaultTheme/widget/slider/slider.edc: Added.
+        * DefaultTheme/widget/slider/slider_h.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_h.png.
+        * DefaultTheme/widget/slider/slider_hilight.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_hilight.png.
+        * DefaultTheme/widget/slider/slider_knob_h.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_knob_h.png.
+        * DefaultTheme/widget/slider/slider_knob_v.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_knob_v.png.
+        * DefaultTheme/widget/slider/slider_v.png: Copied from WebKit/efl/DefaultTheme/widget/scrollbar/scrollbar_v.png.
+
 2010-08-03  ryuan choi  <ryuan.choi@samsung.com>
 
         Reviewed by Darin Adler.
index 7e0fe488df8850179ff3243ab4dad0728c87c857..82b688206e092857173369ab2c72e2a3f82c064d 100644 (file)
@@ -73,4 +73,5 @@ collections {
 #include "widget/search/field/search_field.edc"
 #include "widget/search/cancel/search_cancel.edc"
 #include "widget/search/decoration/search_decoration.edc"
+#include "widget/slider/slider.edc"
 }
diff --git a/WebKit/efl/DefaultTheme/widget/slider/slider.edc b/WebKit/efl/DefaultTheme/widget/slider/slider.edc
new file mode 100644 (file)
index 0000000..6c1f6a5
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+    Copyright (C) 2008,2009 INdT - Instituto Nokia de Tecnologia
+    Copyright (C) 2009,2010 ProFUSION embedded systems
+    Copyright (C) 2009,2010 Samsung Electronics
+
+    This file is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This file is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+group {
+    name: "webkit/widget/slider/vertical";
+
+    min: 10 0; /* if > 0, this is the minimum size that will be allocated.
+                * If wants to draw on top, just overflow usign edje's rel1/rel2
+                */
+
+    images {
+        image: "widget/slider/slider_v.png" COMP;
+        image: "widget/slider/slider_knob_v.png" COMP;
+    }
+
+    script {
+        public message(Msg_Type:type, id, ...) {
+            if ((id == 0) && (type == MSG_FLOAT_SET)) {
+                new Float:vy, Float:sy;
+
+                vy = getfarg(2);
+                sy = getfarg(3);
+
+                if (vy >= 0.0) {
+                    set_drag_size(PART:"img.knob", 1.0, sy);
+                    set_drag(PART:"img.knob", 0.0, vy);
+                }
+            }
+        }
+
+        public update_drag_pos() {
+            new Float:x, Float:y;
+            get_drag(PART:"img.knob", x, y);
+            send_message(MSG_FLOAT, 1, y);
+        }
+    }
+
+    parts {
+         part {
+            name: "rect.base";
+            type: RECT;
+            description {
+               min: 10 0;
+               max: 10 999999;
+               state: "default" 0.0;
+               color: 255 255 255 0;
+            }
+         }
+         part {
+            name: "rect.clipper";
+            type: RECT;
+            description {
+               state: "default" 0.0;
+               color: 255 255 255 255;
+            }
+         }
+
+         part {
+            name: "img.slider";
+            type: IMAGE;
+            mouse_events: 0;
+            clip_to: "rect.clipper";
+            description {
+               state: "default" 0.0;
+               image {
+                  normal: "widget/slider/slider_v.png";
+                  border: 0 0 6 6;
+               }
+           }
+         }
+
+         part {
+            name: "img.knob";
+            type: IMAGE;
+            mouse_events: 1;
+            clip_to: "rect.clipper";
+            dragable {
+                x: 0 0 0;
+                y: 1 1 0;
+                confine: "rect.base";
+            }
+            description {
+               state: "default" 0.0;
+               min: 10 10;
+               max: 10 999999;
+               image {
+                  normal: "widget/slider/slider_knob_v.png";
+                  border: 0 0 6 6;
+               }
+            }
+         }
+    }
+    programs {
+        program {
+           name: "dragged";
+           signal: "drag";
+           source: "img.knob";
+           script {
+              update_drag_pos();
+           }
+        }
+    }
+}
+
+group {
+    name: "webkit/widget/slider/horizontal";
+
+    min: 0 10; /* if > 0, this is the minimum size that will be allocated.
+                * If wants to draw on top, just overflow usign edje's rel1/rel2
+                */
+
+    images {
+        image: "widget/slider/slider_h.png" COMP;
+        image: "widget/slider/slider_knob_h.png" COMP;
+    }
+
+    script {
+        public message(Msg_Type:type, id, ...) {
+            if ((id == 0) && (type == MSG_FLOAT_SET)) {
+                new Float:vx, Float:sx;
+
+                vx = getfarg(2);
+                sx = getfarg(3);
+
+                if (vx >= 0.0) {
+                    set_drag_size(PART:"img.knob", sx, 1.0);
+                    set_drag(PART:"img.knob", vx, 0.0);
+                }
+            }
+        }
+
+        public update_drag_pos() {
+            new Float:x, Float:y;
+            get_drag(PART:"img.knob", x, y);
+            send_message(MSG_FLOAT, 1, x);
+        }
+    }
+
+    parts {
+         part {
+            name: "rect.base";
+            type: RECT;
+            description {
+               state: "default" 0.0;
+               min: 0 10;
+               max: 999999 10;
+               color: 255 255 255 0;
+            }
+         }
+         part {
+            name: "rect.clipper";
+            type: RECT;
+            description {
+               state: "default" 0.0;
+               color: 255 255 255 255;
+            }
+         }
+
+         part {
+            name: "img.slider";
+            type: IMAGE;
+            mouse_events: 0;
+            clip_to: "rect.clipper";
+            description {
+               state: "default" 0.0;
+               image {
+                  normal: "widget/slider/slider_h.png";
+                  border: 6 6 0 0;
+               }
+           }
+         }
+
+         part {
+            name: "img.knob";
+            type: IMAGE;
+            mouse_events: 1;
+            clip_to: "rect.clipper";
+            dragable {
+                x: 1 1 0;
+                y: 0 0 0;
+                confine: "rect.base";
+            }
+            description {
+               state: "default" 0.0;
+               min: 10 10;
+               image {
+                  normal: "widget/slider/slider_knob_h.png";
+                  border: 6 6 0 0;
+               }
+            }
+         }
+    }
+    programs {
+        program {
+           name: "dragged";
+           signal: "drag";
+           source: "img.knob";
+           script {
+              update_drag_pos();
+           }
+        }
+    }
+}
diff --git a/WebKit/efl/DefaultTheme/widget/slider/slider_h.png b/WebKit/efl/DefaultTheme/widget/slider/slider_h.png
new file mode 100644 (file)
index 0000000..6e55557
Binary files /dev/null and b/WebKit/efl/DefaultTheme/widget/slider/slider_h.png differ
diff --git a/WebKit/efl/DefaultTheme/widget/slider/slider_hilight.png b/WebKit/efl/DefaultTheme/widget/slider/slider_hilight.png
new file mode 100644 (file)
index 0000000..1116f4e
Binary files /dev/null and b/WebKit/efl/DefaultTheme/widget/slider/slider_hilight.png differ
diff --git a/WebKit/efl/DefaultTheme/widget/slider/slider_knob_h.png b/WebKit/efl/DefaultTheme/widget/slider/slider_knob_h.png
new file mode 100644 (file)
index 0000000..bc65102
Binary files /dev/null and b/WebKit/efl/DefaultTheme/widget/slider/slider_knob_h.png differ
diff --git a/WebKit/efl/DefaultTheme/widget/slider/slider_knob_v.png b/WebKit/efl/DefaultTheme/widget/slider/slider_knob_v.png
new file mode 100644 (file)
index 0000000..db3c685
Binary files /dev/null and b/WebKit/efl/DefaultTheme/widget/slider/slider_knob_v.png differ
diff --git a/WebKit/efl/DefaultTheme/widget/slider/slider_v.png b/WebKit/efl/DefaultTheme/widget/slider/slider_v.png
new file mode 100644 (file)
index 0000000..9ebdac2
Binary files /dev/null and b/WebKit/efl/DefaultTheme/widget/slider/slider_v.png differ