Title: [105253] trunk/Source/WebCore
Revision
105253
Author
commit-qu...@webkit.org
Date
2012-01-18 02:39:31 -0800 (Wed, 18 Jan 2012)

Log Message

Use RenderTheme in HTMLSelectElement instead of #defines.
<http://webkit.org/b/76519>

Patch by Jun Mukai <mu...@chromium.org> on 2012-01-18
Reviewed by Kent Tamura.

Tests: no new tests because of no behavioral changes.

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::platformHandleKeydownEvent):
(WebCore::HTMLSelectElement::menuListDefaultEventHandler):
* platform/gtk/RenderThemeGtk.h:
(WebCore::RenderThemeGtk::popsMenuByArrowKeys):
* rendering/RenderTheme.h:
(WebCore::RenderTheme::popsMenuByArrowKeys):
(WebCore::RenderTheme::popsMenuBySpaceOrReturn):
* rendering/RenderThemeChromiumLinux.h:
(WebCore::RenderThemeChromiumLinux::popsMenuBySpaceOrReturn):
* rendering/RenderThemeMac.h:
(WebCore::RenderThemeMac::popsMenuByArrowKeys):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (105252 => 105253)


--- trunk/Source/WebCore/ChangeLog	2012-01-18 10:15:26 UTC (rev 105252)
+++ trunk/Source/WebCore/ChangeLog	2012-01-18 10:39:31 UTC (rev 105253)
@@ -1,3 +1,25 @@
+2012-01-18  Jun Mukai  <mu...@chromium.org>
+
+        Use RenderTheme in HTMLSelectElement instead of #defines.
+        <http://webkit.org/b/76519>
+
+        Reviewed by Kent Tamura.
+
+        Tests: no new tests because of no behavioral changes.
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::platformHandleKeydownEvent):
+        (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
+        * platform/gtk/RenderThemeGtk.h:
+        (WebCore::RenderThemeGtk::popsMenuByArrowKeys):
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::popsMenuByArrowKeys):
+        (WebCore::RenderTheme::popsMenuBySpaceOrReturn):
+        * rendering/RenderThemeChromiumLinux.h:
+        (WebCore::RenderThemeChromiumLinux::popsMenuBySpaceOrReturn):
+        * rendering/RenderThemeMac.h:
+        (WebCore::RenderThemeMac::popsMenuByArrowKeys):
+
 2012-01-18  Abhishek Arya  <infe...@chromium.org>
 
         Crash in FrameView::forceLayoutParentViewIfNeeded.        

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (105252 => 105253)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2012-01-18 10:15:26 UTC (rev 105252)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2012-01-18 10:39:31 UTC (rev 105253)
@@ -61,19 +61,6 @@
 // Upper limit agreed upon with representatives of Opera and Mozilla.
 static const unsigned maxSelectItems = 10000;
 
-// Configure platform-specific behavior when focused pop-up receives arrow/space/return keystroke.
-// (PLATFORM(MAC) and PLATFORM(GTK) are always false in Chromium, hence the extra tests.)
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
-#define ARROW_KEYS_POP_MENU 1
-#define SPACE_OR_RETURN_POP_MENU 0
-#elif PLATFORM(GTK) || (PLATFORM(CHROMIUM) && OS(UNIX))
-#define ARROW_KEYS_POP_MENU 0
-#define SPACE_OR_RETURN_POP_MENU 1
-#else
-#define ARROW_KEYS_POP_MENU 0
-#define SPACE_OR_RETURN_POP_MENU 0
-#endif
-
 static const DOMTimeStamp typeAheadTimeout = 1000;
 
 HTMLSelectElement::HTMLSelectElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
@@ -991,7 +978,12 @@
 #if !PLATFORM(WIN) || OS(WINCE)
 bool HTMLSelectElement::platformHandleKeydownEvent(KeyboardEvent* event)
 {
-#if ARROW_KEYS_POP_MENU
+    const Page* page = document()->page();
+    RefPtr<RenderTheme> renderTheme = page ? page->theme() : RenderTheme::defaultTheme();
+
+    if (!renderTheme->popsMenuByArrowKeys())
+        return false;
+
     if (!isSpatialNavigationEnabled(document()->frame())) {
         if (event->keyIdentifier() == "Down" || event->keyIdentifier() == "Up") {
             focus();
@@ -1012,15 +1004,16 @@
         }
         return true;
     }
-#else
-    UNUSED_PARAM(event);
-#endif
+
     return false;
 }
 #endif
 
 void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
 {
+    const Page* page = document()->page();
+    RefPtr<RenderTheme> renderTheme = page ? page->theme() : RenderTheme::defaultTheme();
+
     if (event->type() == eventNames().keydownEvent) {
         if (!renderer() || !event->isKeyboardEvent())
             return;
@@ -1079,48 +1072,49 @@
             return;
         }
 
-#if SPACE_OR_RETURN_POP_MENU
-        if (keyCode == ' ' || keyCode == '\r') {
-            focus();
+        if (renderTheme->popsMenuBySpaceOrReturn()) {
+            if (keyCode == ' ' || keyCode == '\r') {
+                focus();
 
-            // Calling focus() may cause us to lose our renderer, in which case
-            // do not want to handle the event.
-            if (!renderer())
-                return;
+                // Calling focus() may cause us to lose our renderer, in which case
+                // do not want to handle the event.
+                if (!renderer())
+                    return;
 
-            // Save the selection so it can be compared to the new selection
-            // when dispatching change events during selectOption, which
-            // gets called from RenderMenuList::valueChanged, which gets called
-            // after the user makes a selection from the menu.
-            saveLastSelection();
-            if (RenderMenuList* menuList = toRenderMenuList(renderer()))
-                menuList->showPopup();
-            handled = true;
-        }
-#elif ARROW_KEYS_POP_MENU
-        if (keyCode == ' ') {
-            focus();
+                // Save the selection so it can be compared to the new selection
+                // when dispatching change events during selectOption, which
+                // gets called from RenderMenuList::valueChanged, which gets called
+                // after the user makes a selection from the menu.
+                saveLastSelection();
+                if (RenderMenuList* menuList = toRenderMenuList(renderer()))
+                    menuList->showPopup();
+                handled = true;
+            }
+        } else if (renderTheme->popsMenuByArrowKeys()) {
+            if (keyCode == ' ') {
+                focus();
 
-            // Calling focus() may cause us to lose our renderer, in which case
-            // do not want to handle the event.
-            if (!renderer())
-                return;
+                // Calling focus() may cause us to lose our renderer, in which case
+                // do not want to handle the event.
+                if (!renderer())
+                    return;
 
-            // Save the selection so it can be compared to the new selection
-            // when dispatching change events during selectOption, which
-            // gets called from RenderMenuList::valueChanged, which gets called
-            // after the user makes a selection from the menu.
-            saveLastSelection();
-            if (RenderMenuList* menuList = toRenderMenuList(renderer()))
-                menuList->showPopup();
-            handled = true;
-        } else if (keyCode == '\r') {
-            if (form())
-                form()->submitImplicitly(event, false);
-            dispatchChangeEventForMenuList();
-            handled = true;
+                // Save the selection so it can be compared to the new selection
+                // when dispatching change events during selectOption, which
+                // gets called from RenderMenuList::valueChanged, which gets called
+                // after the user makes a selection from the menu.
+                saveLastSelection();
+                if (RenderMenuList* menuList = toRenderMenuList(renderer()))
+                    menuList->showPopup();
+                handled = true;
+            } else if (keyCode == '\r') {
+                if (form())
+                    form()->submitImplicitly(event, false);
+                dispatchChangeEventForMenuList();
+                handled = true;
+            }
         }
-#endif
+
         if (handled)
             event->setDefaultHandled();
     }

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h (105252 => 105253)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h	2012-01-18 10:15:26 UTC (rev 105252)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h	2012-01-18 10:39:31 UTC (rev 105253)
@@ -82,6 +82,8 @@
     virtual void systemFont(int propId, FontDescription&) const;
     virtual Color systemColor(int cssValueId) const;
 
+    virtual bool popsMenuByArrowKeys() const OVERRIDE { return true; }
+
 #if ENABLE(VIDEO)
     virtual String extraMediaControlsStyleSheet();
     virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (105252 => 105253)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2012-01-18 10:15:26 UTC (rev 105252)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2012-01-18 10:39:31 UTC (rev 105253)
@@ -209,7 +209,10 @@
     virtual bool shouldShowPlaceholderWhenFocused() const { return false; }
     virtual bool shouldHaveSpinButton(HTMLInputElement*) const;
 
+    // Functions for <select> elements.
     virtual bool delegatesMenuListRendering() const { return false; }
+    virtual bool popsMenuByArrowKeys() const { return false; }
+    virtual bool popsMenuBySpaceOrReturn() const { return false; }
 
     virtual String fileListNameForWidth(const Vector<String>& filenames, const Font&, int width, bool multipleFilesAllowed);
 

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumLinux.h (105252 => 105253)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumLinux.h	2012-01-18 10:15:26 UTC (rev 105252)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumLinux.h	2012-01-18 10:39:31 UTC (rev 105253)
@@ -74,6 +74,8 @@
         virtual void adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
         virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
 
+        virtual bool popsMenuBySpaceOrReturn() const OVERRIDE { return true; }
+
 #if ENABLE(PROGRESS_TAG)
         virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
 #endif

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (105252 => 105253)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2012-01-18 10:15:26 UTC (rev 105252)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2012-01-18 10:39:31 UTC (rev 105253)
@@ -76,6 +76,8 @@
     
     virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&);
 
+    virtual bool popsMenuByArrowKeys() const OVERRIDE { return true; }
+
 #if ENABLE(METER_TAG)
     virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const;
     virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to