Changeset 110359 in webkit


Ignore:
Timestamp:
Mar 9, 2012 6:40:26 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Increase size of Combo Box Options for touch and high DPI devices
https://bugs.webkit.org/show_bug.cgi?id=80027

Patch by Tim Dresser <tdresser@chromium.org> on 2012-03-09
Reviewed by Darin Fisher.

Source/WebCore:

Scale Combo box popups by defaultDeviceScaleFactor, and add padding to
<option> elements when touch is enabled.

Manually tested with --default-device-scale-factor=1,2 and unset.
Each of these were tested with RuntimeEnabledFeatures::touchEnabled
set to true and false.

  • platform/chromium/PopupListBox.cpp:

(WebCore::PopupListBox::paint):
(WebCore::PopupListBox::paintRow):
(WebCore::PopupListBox::getRowHeight):

  • platform/chromium/PopupListBox.h:

(PopupContainerSettings):

  • platform/chromium/PopupMenuChromium.cpp:

(WebCore):
(WebCore::PopupMenuChromium::show):

  • platform/chromium/PopupMenuChromium.h:

(WebCore::PopupMenuChromium::optionPaddingForTouch):
(WebCore::PopupMenuChromium::setOptionPaddingForTouch):
(PopupMenuChromium):

  • rendering/RenderMenuList.cpp:

(WebCore::RenderMenuList::showPopup):

Source/WebKit/chromium:

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::gestureEvent):
(WebKit::WebViewImpl::applyAutofillSuggestions):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r110358 r110359  
     12012-03-09  Tim Dresser  <tdresser@chromium.org>
     2
     3        [chromium] Increase size of Combo Box Options for touch and high DPI devices
     4        https://bugs.webkit.org/show_bug.cgi?id=80027
     5
     6        Reviewed by Darin Fisher.
     7
     8        Scale Combo box popups by defaultDeviceScaleFactor, and add padding to
     9        <option> elements when touch is enabled.
     10
     11        Manually tested with --default-device-scale-factor=1,2 and unset.
     12        Each of these were tested with RuntimeEnabledFeatures::touchEnabled
     13        set to true and false.
     14
     15        * platform/chromium/PopupListBox.cpp:
     16        (WebCore::PopupListBox::paint):
     17        (WebCore::PopupListBox::paintRow):
     18        (WebCore::PopupListBox::getRowHeight):
     19        * platform/chromium/PopupListBox.h:
     20        (PopupContainerSettings):
     21        * platform/chromium/PopupMenuChromium.cpp:
     22        (WebCore):
     23        (WebCore::PopupMenuChromium::show):
     24        * platform/chromium/PopupMenuChromium.h:
     25        (WebCore::PopupMenuChromium::optionPaddingForTouch):
     26        (WebCore::PopupMenuChromium::setOptionPaddingForTouch):
     27        (PopupMenuChromium):
     28        * rendering/RenderMenuList.cpp:
     29        (WebCore::RenderMenuList::showPopup):
     30
    1312012-03-09  Stephen White  <senorblanco@chromium.org>
    232
  • trunk/Source/WebCore/platform/chromium/PopupListBox.cpp

    r107842 r110359  
    4545#include "PopupMenuClient.h"
    4646#include "RenderTheme.h"
     47#include "RuntimeEnabledFeatures.h"
    4748#include "ScrollbarTheme.h"
    4849#include "StringTruncator.h"
     
    353354void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect)
    354355{
     356    int scale = m_settings.defaultDeviceScaleFactor;
    355357    // adjust coords for scrolled frame
    356358    IntRect r = intersection(rect, frameRect());
     
    367369    // FIXME: Can we optimize scrolling to not require repainting the entire
    368370    // window? Should we?
     371    if (scale != 1)
     372        gc->scale(FloatSize(scale, scale));
    369373    for (int i = 0; i < numItems(); ++i)
    370374        paintRow(gc, r, i);
     
    389393    if (!rowRect.intersects(rect))
    390394        return;
     395
     396    int scale = m_settings.defaultDeviceScaleFactor;
     397    // RowRect has already been scaled by the defaultDeviceScaleFactor.
     398    // To avoid scaling it twice, we have to unscale it before drawing.
     399    if (scale != 1) {
     400        // Height and y should both be evenly divisible by scale.
     401        ASSERT(!(rowRect.y() % scale));
     402        rowRect.setY(rowRect.y() / scale);
     403        ASSERT(!(rowRect.height() % scale));
     404        rowRect.setHeight(rowRect.height() / scale);
     405        rowRect.setWidth(ceilf(static_cast<float>(rowRect.width()) / scale));
     406        // rowRect.x is always 0.
     407    }
    391408
    392409    PopupMenuStyle style = m_popupClient->itemStyle(rowIndex);
     
    614631int PopupListBox::getRowHeight(int index)
    615632{
    616     if (index < 0)
    617         return PopupMenuChromium::minimumRowHeight();
    618 
    619     if (m_popupClient->itemStyle(index).isDisplayNone())
    620         return PopupMenuChromium::minimumRowHeight();
     633    int scale = m_settings.defaultDeviceScaleFactor;
     634    int paddingForTouch = 0;
     635    if (RuntimeEnabledFeatures::touchEnabled())
     636        paddingForTouch = PopupMenuChromium::optionPaddingForTouch();
     637    if (index < 0 || m_popupClient->itemStyle(index).isDisplayNone())
     638        return PopupMenuChromium::minimumRowHeight() * scale;
    621639
    622640    // Separator row height is the same size as itself.
    623641    if (m_popupClient->itemIsSeparator(index))
    624         return max(separatorHeight, PopupMenuChromium::minimumRowHeight());
     642        return max(separatorHeight, (PopupMenuChromium::minimumRowHeight())) * scale;
    625643
    626644    String icon = m_popupClient->itemIcon(index);
     
    632650    int linePaddingHeight = m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup ? kLinePaddingHeight : 0;
    633651    int calculatedRowHeight = max(fontHeight, iconHeight) + linePaddingHeight * 2;
    634     return max(calculatedRowHeight, PopupMenuChromium::minimumRowHeight());
     652    return (max(calculatedRowHeight, PopupMenuChromium::minimumRowHeight()) + paddingForTouch) * scale;
    635653}
    636654
  • trunk/Source/WebCore/platform/chromium/PopupListBox.h

    r107036 r110359  
    8080    // Autocomplete popups are restricted, combo-boxes (select tags) aren't.
    8181    bool restrictWidthOfListBox;
     82
     83    int defaultDeviceScaleFactor;
    8284};
    8385
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp

    r95901 r110359  
    3232#include "config.h"
    3333#include "PopupMenuChromium.h"
     34
     35#include "Frame.h"
     36#include "FrameView.h"
     37#include "Page.h"
    3438#include "PopupContainer.h"
     39#include "Settings.h"
    3540
    3641namespace WebCore {
    3742
    3843int PopupMenuChromium::s_minimumRowHeight = 0;
     44int PopupMenuChromium::s_optionPaddingForTouch = 30;
    3945
    4046// The settings used for the drop down menu.
     
    6369void PopupMenuChromium::show(const IntRect& r, FrameView* v, int index)
    6470{
    65     if (!p.popup)
    66         p.popup = PopupContainer::create(client(), PopupContainer::Select, dropDownSettings);
     71    if (!p.popup) {
     72        PopupContainerSettings popupSettings = dropDownSettings;
     73        popupSettings.defaultDeviceScaleFactor =
     74            v->frame()->page()->settings()->defaultDeviceScaleFactor();
     75        if (!popupSettings.defaultDeviceScaleFactor)
     76            popupSettings.defaultDeviceScaleFactor = 1;
     77        p.popup = PopupContainer::create(client(), PopupContainer::Select, popupSettings);
     78    }
    6779    p.popup->showInRect(r, v, index);
    6880}
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.h

    r95901 r110359  
    5858    static void setMinimumRowHeight(int minimumRowHeight) { s_minimumRowHeight = minimumRowHeight; }
    5959
     60    static int optionPaddingForTouch() { return s_optionPaddingForTouch; }
     61    static void setOptionPaddingForTouch(int optionPaddingForTouch) { s_optionPaddingForTouch = optionPaddingForTouch; }
     62
    6063private:
    6164    PopupMenuClient* client() const { return m_popupClient; }
     
    6568
    6669    static int s_minimumRowHeight;
     70    static int s_optionPaddingForTouch;
    6771};
    6872
  • trunk/Source/WebCore/rendering/RenderMenuList.cpp

    r109806 r110359  
    4444#include "RenderScrollbar.h"
    4545#include "RenderTheme.h"
     46#include "Settings.h"
    4647#include "TextRun.h"
    4748#include <math.h>
     
    309310    FloatPoint absTopLeft = localToAbsolute(FloatPoint(), false, true);
    310311    LayoutRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
     312    int scale = document()->page()->settings()->defaultDeviceScaleFactor();
     313    if (scale && scale != 1)
     314        absBounds.scale(scale);
    311315    absBounds.setLocation(roundedLayoutPoint(absTopLeft));
    312316    HTMLSelectElement* select = toHTMLSelectElement(node());
  • trunk/Source/WebKit/chromium/ChangeLog

    r110357 r110359  
     12012-03-09  Tim Dresser  <tdresser@chromium.org>
     2
     3        [chromium] Increase size of Combo Box Options for touch and high DPI devices
     4        https://bugs.webkit.org/show_bug.cgi?id=80027
     5
     6        Reviewed by Darin Fisher.
     7
     8        * src/WebViewImpl.cpp:
     9        (WebKit::WebViewImpl::gestureEvent):
     10        (WebKit::WebViewImpl::applyAutofillSuggestions):
     11
    1122012-03-09  James Robinson  <jamesr@chromium.org>
    213
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r110325 r110359  
    603603bool WebViewImpl::gestureEvent(const WebGestureEvent& event)
    604604{
     605    RefPtr<WebCore::PopupContainer> selectPopup;
    605606    PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
    606     return mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
     607    if (event.type == WebInputEvent::GestureTap) {
     608        selectPopup = m_selectPopup;
     609        hideSelectPopup();
     610        ASSERT(!m_selectPopup);
     611    }
     612
     613    bool gestureHandled = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
     614
     615    if (m_selectPopup && m_selectPopup == selectPopup) {
     616        // That tap triggered a select popup which is the same as the one that
     617        // was showing before the tap. It means the user tapped the select
     618        // while the popup was showing, and as a result we first closed then
     619        // immediately reopened the select popup. It needs to be closed.
     620        hideSelectPopup();
     621    }
     622
     623    return gestureHandled;
    607624}
    608625
     
    26922709
    26932710    if (!m_autofillPopup) {
     2711        PopupContainerSettings popupSettings = autofillPopupSettings;
     2712        popupSettings.defaultDeviceScaleFactor =
     2713            m_page->settings()->defaultDeviceScaleFactor();
     2714        if (!popupSettings.defaultDeviceScaleFactor)
     2715            popupSettings.defaultDeviceScaleFactor = 1;
    26942716        m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(),
    26952717                                                 PopupContainer::Suggestion,
    2696                                                  autofillPopupSettings);
     2718                                                 popupSettings);
    26972719    }
    26982720
Note: See TracChangeset for help on using the changeset viewer.