Changeset 105253 in webkit


Ignore:
Timestamp:
Jan 18, 2012 2:39:31 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Jun Mukai <mukai@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):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r105250 r105253  
     12012-01-18  Jun Mukai  <mukai@chromium.org>
     2
     3        Use RenderTheme in HTMLSelectElement instead of #defines.
     4        <http://webkit.org/b/76519>
     5
     6        Reviewed by Kent Tamura.
     7
     8        Tests: no new tests because of no behavioral changes.
     9
     10        * html/HTMLSelectElement.cpp:
     11        (WebCore::HTMLSelectElement::platformHandleKeydownEvent):
     12        (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
     13        * platform/gtk/RenderThemeGtk.h:
     14        (WebCore::RenderThemeGtk::popsMenuByArrowKeys):
     15        * rendering/RenderTheme.h:
     16        (WebCore::RenderTheme::popsMenuByArrowKeys):
     17        (WebCore::RenderTheme::popsMenuBySpaceOrReturn):
     18        * rendering/RenderThemeChromiumLinux.h:
     19        (WebCore::RenderThemeChromiumLinux::popsMenuBySpaceOrReturn):
     20        * rendering/RenderThemeMac.h:
     21        (WebCore::RenderThemeMac::popsMenuByArrowKeys):
     22
    1232012-01-18  Abhishek Arya  <inferno@chromium.org>
    224
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r104864 r105253  
    6262static const unsigned maxSelectItems = 10000;
    6363
    64 // Configure platform-specific behavior when focused pop-up receives arrow/space/return keystroke.
    65 // (PLATFORM(MAC) and PLATFORM(GTK) are always false in Chromium, hence the extra tests.)
    66 #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
    67 #define ARROW_KEYS_POP_MENU 1
    68 #define SPACE_OR_RETURN_POP_MENU 0
    69 #elif PLATFORM(GTK) || (PLATFORM(CHROMIUM) && OS(UNIX))
    70 #define ARROW_KEYS_POP_MENU 0
    71 #define SPACE_OR_RETURN_POP_MENU 1
    72 #else
    73 #define ARROW_KEYS_POP_MENU 0
    74 #define SPACE_OR_RETURN_POP_MENU 0
    75 #endif
    76 
    7764static const DOMTimeStamp typeAheadTimeout = 1000;
    7865
     
    992979bool HTMLSelectElement::platformHandleKeydownEvent(KeyboardEvent* event)
    993980{
    994 #if ARROW_KEYS_POP_MENU
     981    const Page* page = document()->page();
     982    RefPtr<RenderTheme> renderTheme = page ? page->theme() : RenderTheme::defaultTheme();
     983
     984    if (!renderTheme->popsMenuByArrowKeys())
     985        return false;
     986
    995987    if (!isSpatialNavigationEnabled(document()->frame())) {
    996988        if (event->keyIdentifier() == "Down" || event->keyIdentifier() == "Up") {
     
    10131005        return true;
    10141006    }
    1015 #else
    1016     UNUSED_PARAM(event);
     1007
     1008    return false;
     1009}
    10171010#endif
    1018     return false;
    1019 }
    1020 #endif
    10211011
    10221012void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
    10231013{
     1014    const Page* page = document()->page();
     1015    RefPtr<RenderTheme> renderTheme = page ? page->theme() : RenderTheme::defaultTheme();
     1016
    10241017    if (event->type() == eventNames().keydownEvent) {
    10251018        if (!renderer() || !event->isKeyboardEvent())
     
    10801073        }
    10811074
    1082 #if SPACE_OR_RETURN_POP_MENU
    1083         if (keyCode == ' ' || keyCode == '\r') {
    1084             focus();
    1085 
    1086             // Calling focus() may cause us to lose our renderer, in which case
    1087             // do not want to handle the event.
    1088             if (!renderer())
    1089                 return;
    1090 
    1091             // Save the selection so it can be compared to the new selection
    1092             // when dispatching change events during selectOption, which
    1093             // gets called from RenderMenuList::valueChanged, which gets called
    1094             // after the user makes a selection from the menu.
    1095             saveLastSelection();
    1096             if (RenderMenuList* menuList = toRenderMenuList(renderer()))
    1097                 menuList->showPopup();
    1098             handled = true;
    1099         }
    1100 #elif ARROW_KEYS_POP_MENU
    1101         if (keyCode == ' ') {
    1102             focus();
    1103 
    1104             // Calling focus() may cause us to lose our renderer, in which case
    1105             // do not want to handle the event.
    1106             if (!renderer())
    1107                 return;
    1108 
    1109             // Save the selection so it can be compared to the new selection
    1110             // when dispatching change events during selectOption, which
    1111             // gets called from RenderMenuList::valueChanged, which gets called
    1112             // after the user makes a selection from the menu.
    1113             saveLastSelection();
    1114             if (RenderMenuList* menuList = toRenderMenuList(renderer()))
    1115                 menuList->showPopup();
    1116             handled = true;
    1117         } else if (keyCode == '\r') {
    1118             if (form())
    1119                 form()->submitImplicitly(event, false);
    1120             dispatchChangeEventForMenuList();
    1121             handled = true;
    1122         }
    1123 #endif
     1075        if (renderTheme->popsMenuBySpaceOrReturn()) {
     1076            if (keyCode == ' ' || keyCode == '\r') {
     1077                focus();
     1078
     1079                // Calling focus() may cause us to lose our renderer, in which case
     1080                // do not want to handle the event.
     1081                if (!renderer())
     1082                    return;
     1083
     1084                // Save the selection so it can be compared to the new selection
     1085                // when dispatching change events during selectOption, which
     1086                // gets called from RenderMenuList::valueChanged, which gets called
     1087                // after the user makes a selection from the menu.
     1088                saveLastSelection();
     1089                if (RenderMenuList* menuList = toRenderMenuList(renderer()))
     1090                    menuList->showPopup();
     1091                handled = true;
     1092            }
     1093        } else if (renderTheme->popsMenuByArrowKeys()) {
     1094            if (keyCode == ' ') {
     1095                focus();
     1096
     1097                // Calling focus() may cause us to lose our renderer, in which case
     1098                // do not want to handle the event.
     1099                if (!renderer())
     1100                    return;
     1101
     1102                // Save the selection so it can be compared to the new selection
     1103                // when dispatching change events during selectOption, which
     1104                // gets called from RenderMenuList::valueChanged, which gets called
     1105                // after the user makes a selection from the menu.
     1106                saveLastSelection();
     1107                if (RenderMenuList* menuList = toRenderMenuList(renderer()))
     1108                    menuList->showPopup();
     1109                handled = true;
     1110            } else if (keyCode == '\r') {
     1111                if (form())
     1112                    form()->submitImplicitly(event, false);
     1113                dispatchChangeEventForMenuList();
     1114                handled = true;
     1115            }
     1116        }
     1117
    11241118        if (handled)
    11251119            event->setDefaultHandled();
  • trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h

    r99083 r105253  
    8282    virtual void systemFont(int propId, FontDescription&) const;
    8383    virtual Color systemColor(int cssValueId) const;
     84
     85    virtual bool popsMenuByArrowKeys() const OVERRIDE { return true; }
    8486
    8587#if ENABLE(VIDEO)
  • trunk/Source/WebCore/rendering/RenderTheme.h

    r102655 r105253  
    210210    virtual bool shouldHaveSpinButton(HTMLInputElement*) const;
    211211
     212    // Functions for <select> elements.
    212213    virtual bool delegatesMenuListRendering() const { return false; }
     214    virtual bool popsMenuByArrowKeys() const { return false; }
     215    virtual bool popsMenuBySpaceOrReturn() const { return false; }
    213216
    214217    virtual String fileListNameForWidth(const Vector<String>& filenames, const Font&, int width, bool multipleFilesAllowed);
  • trunk/Source/WebCore/rendering/RenderThemeChromiumLinux.h

    r104139 r105253  
    7575        virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
    7676
     77        virtual bool popsMenuBySpaceOrReturn() const OVERRIDE { return true; }
     78
    7779#if ENABLE(PROGRESS_TAG)
    7880        virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
  • trunk/Source/WebCore/rendering/RenderThemeMac.h

    r105203 r105253  
    7676   
    7777    virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&);
     78
     79    virtual bool popsMenuByArrowKeys() const OVERRIDE { return true; }
    7880
    7981#if ENABLE(METER_TAG)
Note: See TracChangeset for help on using the changeset viewer.