Changeset 118707 in webkit


Ignore:
Timestamp:
May 28, 2012 2:55:20 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Only increase size of Combo Box Options when displayed on touch screen
https://bugs.webkit.org/show_bug.cgi?id=85921

Patch by Rob Flack <flackr@chromium.org> on 2012-05-28
Reviewed by Adam Barth.

Adds a flag to set whether the current device is a touch screen, independent of whether touch events are supported and use this for the combo box sizing.

Source/WebCore:

No new tests as this is a flag change and covered by existing tests: WebKit/chromium/tests/PopupMenuTest.cpp

  • page/Settings.cpp:

(WebCore::Settings::Settings):

  • page/Settings.h:

(WebCore::Settings::setDeviceSupportsTouch):
(WebCore::Settings::deviceSupportsTouch):
(Settings):

  • platform/chromium/PopupListBox.cpp:

(WebCore::PopupListBox::getRowHeight):

  • platform/chromium/PopupListBox.h:

(PopupContainerSettings):

  • platform/chromium/PopupMenuChromium.cpp:

(WebCore::PopupMenuChromium::show):

Source/WebKit/chromium:

  • public/WebSettings.h:
  • src/WebSettingsImpl.cpp:

(WebKit::WebSettingsImpl::defaultDeviceScaleFactor):
(WebKit):
(WebKit::WebSettingsImpl::setDeviceSupportsTouch):
(WebKit::WebSettingsImpl::deviceSupportsTouch):

  • src/WebSettingsImpl.h:

(WebSettingsImpl):

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::applyAutofillSuggestions):

  • tests/PopupMenuTest.cpp:

(WebKit::SelectPopupMenuTest::SetUp):
(WebKit::SelectPopupMenuTest::TearDown):
(SelectPopupMenuTest):
(WebKit::TEST_F):

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118706 r118707  
     12012-05-28  Rob Flack  <flackr@chromium.org>
     2
     3        [chromium] Only increase size of Combo Box Options when displayed on touch screen
     4        https://bugs.webkit.org/show_bug.cgi?id=85921
     5
     6        Reviewed by Adam Barth.
     7
     8        Adds a flag to set whether the current device is a touch screen, independent of whether touch events are supported and use this for the combo box sizing.
     9
     10        No new tests as this is a flag change and covered by existing tests: WebKit/chromium/tests/PopupMenuTest.cpp
     11
     12        * page/Settings.cpp:
     13        (WebCore::Settings::Settings):
     14        * page/Settings.h:
     15        (WebCore::Settings::setDeviceSupportsTouch):
     16        (WebCore::Settings::deviceSupportsTouch):
     17        (Settings):
     18        * platform/chromium/PopupListBox.cpp:
     19        (WebCore::PopupListBox::getRowHeight):
     20        * platform/chromium/PopupListBox.h:
     21        (PopupContainerSettings):
     22        * platform/chromium/PopupMenuChromium.cpp:
     23        (WebCore::PopupMenuChromium::show):
     24
    1252012-05-28  Arvid Nilsson  <anilsson@rim.com>
    226
  • trunk/Source/WebCore/page/Settings.cpp

    r118599 r118707  
    271271    , m_wantsBalancedSetDefersLoadingBehavior(false)
    272272    , m_requestAnimationFrameEnabled(true)
     273    , m_deviceSupportsTouch(false)
    273274    , m_needsDidFinishLoadOrderQuirk(false)
    274275    , m_fixedPositionCreatesStackingContext(false)
  • trunk/Source/WebCore/page/Settings.h

    r118599 r118707  
    575575        void setRequestAnimationFrameEnabled(bool enabled) { m_requestAnimationFrameEnabled = enabled; }
    576576        bool requestAnimationFrameEnabled() const { return m_requestAnimationFrameEnabled; }
     577
     578        void setDeviceSupportsTouch(bool enabled) { m_deviceSupportsTouch = enabled; }
     579        bool deviceSupportsTouch() const { return m_deviceSupportsTouch; }
    577580
    578581        void setNeedsDidFinishLoadOrderQuirk(bool needsQuirk) { m_needsDidFinishLoadOrderQuirk = needsQuirk; }
     
    754757        bool m_wantsBalancedSetDefersLoadingBehavior : 1;
    755758        bool m_requestAnimationFrameEnabled : 1;
     759        bool m_deviceSupportsTouch : 1;
    756760        bool m_needsDidFinishLoadOrderQuirk : 1;
    757761
  • trunk/Source/WebCore/platform/chromium/PopupListBox.cpp

    r116723 r118707  
    633633    int scale = m_settings.defaultDeviceScaleFactor;
    634634    int paddingForTouch = 0;
    635     if (RuntimeEnabledFeatures::touchEnabled())
     635    if (m_settings.deviceSupportsTouch)
    636636        paddingForTouch = PopupMenuChromium::optionPaddingForTouch();
    637637    if (index < 0 || m_popupClient->itemStyle(index).isDisplayNone())
  • trunk/Source/WebCore/platform/chromium/PopupListBox.h

    r111539 r118707  
    8181    bool restrictWidthOfListBox;
    8282
     83    // The default device scale factor of the screen used to draw the menu
     84    // at this scale suitable for the device DPI.
    8385    int defaultDeviceScaleFactor;
     86
     87    // If the device is a touch screen we increase the height of menu items
     88    // to make it easier to unambiguously touch them.
     89    bool deviceSupportsTouch;
    8490};
    8591
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp

    r111539 r118707  
    6767}
    6868
    69 void PopupMenuChromium::show(const IntRect& r, FrameView* v, int index)
     69void PopupMenuChromium::show(const IntRect& rect, FrameView* frameView, int index)
    7070{
    7171    if (!p.popup) {
     72        Settings* settings = frameView->frame()->page()->settings();
    7273        PopupContainerSettings popupSettings = dropDownSettings;
    73         popupSettings.defaultDeviceScaleFactor =
    74             v->frame()->page()->settings()->defaultDeviceScaleFactor();
     74        popupSettings.defaultDeviceScaleFactor = settings->defaultDeviceScaleFactor();
    7575        if (!popupSettings.defaultDeviceScaleFactor)
    7676            popupSettings.defaultDeviceScaleFactor = 1;
     77        popupSettings.deviceSupportsTouch = settings->deviceSupportsTouch();
    7778        p.popup = PopupContainer::create(client(), PopupContainer::Select, popupSettings);
    7879    }
    79     p.popup->showInRect(r, v, index);
     80    p.popup->showInRect(rect, frameView, index);
    8081}
    8182
  • trunk/Source/WebKit/chromium/ChangeLog

    r118705 r118707  
     12012-05-28  Rob Flack  <flackr@chromium.org>
     2
     3        [chromium] Only increase size of Combo Box Options when displayed on touch screen
     4        https://bugs.webkit.org/show_bug.cgi?id=85921
     5
     6        Reviewed by Adam Barth.
     7
     8        Adds a flag to set whether the current device is a touch screen, independent of whether touch events are supported and use this for the combo box sizing.
     9
     10        * public/WebSettings.h:
     11        * src/WebSettingsImpl.cpp:
     12        (WebKit::WebSettingsImpl::defaultDeviceScaleFactor):
     13        (WebKit):
     14        (WebKit::WebSettingsImpl::setDeviceSupportsTouch):
     15        (WebKit::WebSettingsImpl::deviceSupportsTouch):
     16        * src/WebSettingsImpl.h:
     17        (WebSettingsImpl):
     18        * src/WebViewImpl.cpp:
     19        (WebKit::WebViewImpl::applyAutofillSuggestions):
     20        * tests/PopupMenuTest.cpp:
     21        (WebKit::SelectPopupMenuTest::SetUp):
     22        (WebKit::SelectPopupMenuTest::TearDown):
     23        (SelectPopupMenuTest):
     24        (WebKit::TEST_F):
     25
    1262012-05-25  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
    227
  • trunk/Source/WebKit/chromium/public/WebSettings.h

    r118599 r118707  
    6868    virtual void setFontBoostingEnabled(bool) = 0;
    6969    virtual void setDefaultTextEncodingName(const WebString&) = 0;
     70    virtual void setDeviceSupportsTouch(bool) = 0;
    7071    virtual void setJavaScriptEnabled(bool) = 0;
    7172    virtual void setWebSecurityEnabled(bool) = 0;
  • trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp

    r118599 r118707  
    119119}
    120120
     121int WebSettingsImpl::defaultDeviceScaleFactor()
     122{
     123    return m_settings->defaultDeviceScaleFactor();
     124}
     125
     126void WebSettingsImpl::setDeviceSupportsTouch(bool deviceSupportsTouch)
     127{
     128    m_settings->setDeviceSupportsTouch(deviceSupportsTouch);
     129}
     130
     131bool WebSettingsImpl::deviceSupportsTouch()
     132{
     133    return m_settings->deviceSupportsTouch();
     134}
     135
    121136void WebSettingsImpl::setApplyDefaultDeviceScaleFactorInCompositor(bool applyDefaultDeviceScaleFactorInCompositor)
    122137{
  • trunk/Source/WebKit/chromium/src/WebSettingsImpl.h

    r118599 r118707  
    5656    virtual void setMinimumLogicalFontSize(int);
    5757    virtual void setDefaultDeviceScaleFactor(int);
     58    virtual int defaultDeviceScaleFactor();
    5859    virtual void setApplyDefaultDeviceScaleFactorInCompositor(bool);
    5960    virtual void setFontBoostingEnabled(bool);
    6061    virtual void setDefaultTextEncodingName(const WebString&);
     62    virtual void setDeviceSupportsTouch(bool);
     63    virtual bool deviceSupportsTouch();
    6164    virtual void setJavaScriptEnabled(bool);
    6265    virtual void setWebSecurityEnabled(bool);
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r118513 r118707  
    29562956    if (!m_autofillPopup) {
    29572957        PopupContainerSettings popupSettings = autofillPopupSettings;
    2958         popupSettings.defaultDeviceScaleFactor =
    2959             m_page->settings()->defaultDeviceScaleFactor();
     2958        popupSettings.defaultDeviceScaleFactor = settingsImpl()->defaultDeviceScaleFactor();
    29602959        if (!popupSettings.defaultDeviceScaleFactor)
    29612960            popupSettings.defaultDeviceScaleFactor = 1;
     2961        popupSettings.deviceSupportsTouch = settingsImpl()->deviceSupportsTouch();
    29622962        m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(),
    29632963                                                 PopupContainer::Suggestion,
  • trunk/Source/WebKit/chromium/tests/PopupMenuTest.cpp

    r115441 r118707  
    183183    virtual void SetUp()
    184184    {
    185         // When touch is enabled, padding is added to option elements
    186         // In these tests, we'll assume touch is disabled.
    187         m_touchWasEnabled = RuntimeEnabledFeatures::touchEnabled();
    188         RuntimeEnabledFeatures::setTouchEnabled(false);
    189185        m_webView = static_cast<WebViewImpl*>(WebView::create(&m_webviewClient));
    190186        m_webView->initializeMainFrame(&m_webFrameClient);
     
    197193        m_webView->close();
    198194        webkit_support::UnregisterAllMockedURLs();
    199         RuntimeEnabledFeatures::setTouchEnabled(m_touchWasEnabled);
    200195    }
    201196
     
    285280    TestPopupMenuClient m_popupMenuClient;
    286281    RefPtr<PopupMenu> m_popupMenu;
    287     bool m_touchWasEnabled;
    288282    std::string baseURL;
    289283};
     
    361355    showPopup();
    362356
    363     // Y of 18 to be on the item at index 1 (12 font plus border and more to be safe).
    364     IntPoint row1Point(2, 18);
     357    int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
     358    // menuItemHeight * 1.5 means the Y position on the item at index 1.
     359    IntPoint row1Point(2, menuItemHeight * 1.5);
    365360    // Simulate a click down/up on the first item.
    366361    simulateLeftMouseDownEvent(row1Point);
     
    378373    showPopup();
    379374
    380     // Y of 18 to be on the item at index 1 (12 font plus border and more to be safe).
    381     IntPoint row1Point(2, 18);
     375    int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
     376    // menuItemHeight * 1.5 means the Y position on the item at index 1.
     377    IntPoint row1Point(2, menuItemHeight * 1.5);
    382378    // Simulate the mouse moving over the first item.
    383379    PlatformMouseEvent mouseEvent(row1Point, row1Point, NoButton, PlatformEvent::MouseMoved,
     
    422418    showPopup();
    423419
    424     int menuHeight = m_webView->selectPopup()->menuItemHeight();
    425     // menuHeight * 0.5 means the Y position on the item at index 0.
    426     IntPoint row1Point(2, menuHeight * 0.5);
     420    int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
     421    // menuItemHeight * 0.5 means the Y position on the item at index 0.
     422    IntPoint row1Point(2, menuItemHeight * 0.5);
    427423    simulateLeftMouseDownEvent(row1Point);
    428424    simulateLeftMouseUpEvent(row1Point);
     
    438434
    439435    showPopup();
    440     // menuHeight * 1.5 means the Y position on the item at index 1.
    441     row1Point.setY(menuHeight * 1.5);
     436    // menuItemHeight * 1.5 means the Y position on the item at index 1.
     437    row1Point.setY(menuItemHeight * 1.5);
    442438    simulateLeftMouseDownEvent(row1Point);
    443439    simulateLeftMouseUpEvent(row1Point);
     
    447443
    448444    showPopup();
    449     // menuHeight * 2.5 means the Y position on the item at index 2.
    450     row1Point.setY(menuHeight * 2.5);
     445    // menuItemHeight * 2.5 means the Y position on the item at index 2.
     446    row1Point.setY(menuItemHeight * 2.5);
    451447    simulateLeftMouseDownEvent(row1Point);
    452448    simulateLeftMouseUpEvent(row1Point);
     
    489485    showPopup();
    490486
    491     int menuHeight = m_webView->selectPopup()->menuItemHeight();
    492     // menuHeight * 1.5 means the Y position on the item at index 1.
    493     IntPoint row1Point(2, menuHeight * 1.5);
     487    int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
     488    // menuItemHeight * 1.5 means the Y position on the item at index 1.
     489    IntPoint row1Point(2, menuItemHeight * 1.5);
    494490    simulateLeftMouseDownEvent(row1Point);
    495491    simulateLeftMouseUpEvent(row1Point);
     
    511507    showPopup();
    512508
    513     int menuHeight = m_webView->selectPopup()->menuItemHeight();
    514     // menuHeight * 1.5 means the Y position on the item at index 1.
    515     IntPoint row1Point(2, menuHeight * 1.5);
     509    int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
     510    // menuItemHeight * 1.5 means the Y position on the item at index 1.
     511    IntPoint row1Point(2, menuItemHeight * 1.5);
    516512    simulateLeftMouseDownEvent(row1Point);
    517513    simulateLeftMouseUpEvent(row1Point);
Note: See TracChangeset for help on using the changeset viewer.