| Differences between
and this patch
- a/Source/WebCore/ChangeLog +30 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-03-14  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 NOBODY (OOPS!).
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. Also tested by SelectPopupMenuTest.*
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
1
2012-03-14  Dana Jansens  <danakj@chromium.org>
31
2012-03-14  Dana Jansens  <danakj@chromium.org>
2
32
3
        Region can acquire an empty span by subtracting an empty Region
33
        Region can acquire an empty span by subtracting an empty Region
- a/Source/WebKit/chromium/ChangeLog +16 lines
Lines 1-3 a/Source/WebKit/chromium/ChangeLog_sec1
1
2012-03-14  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 NOBODY (OOPS!).
7
8
        * src/WebViewImpl.cpp:
9
        (WebKit::WebViewImpl::gestureEvent):
10
        (WebKit::WebViewImpl::applyAutofillSuggestions):
11
        * tests/PopupMenuTest.cpp:
12
        (WebKit::TestWebViewClient::screenInfo):
13
        (WebKit::SelectPopupMenuTest::SetUp):
14
        (WebKit::SelectPopupMenuTest::TearDown):
15
        (SelectPopupMenuTest):
16
1
2012-03-14  Dana Jansens  <danakj@chromium.org>
17
2012-03-14  Dana Jansens  <danakj@chromium.org>
2
18
3
        Region can acquire an empty span by subtracting an empty Region
19
        Region can acquire an empty span by subtracting an empty Region
- a/Source/WebCore/platform/chromium/PopupListBox.cpp -7 / +25 lines
Lines 44-49 a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec1
44
#include "PopupMenuChromium.h"
44
#include "PopupMenuChromium.h"
45
#include "PopupMenuClient.h"
45
#include "PopupMenuClient.h"
46
#include "RenderTheme.h"
46
#include "RenderTheme.h"
47
#include "RuntimeEnabledFeatures.h"
47
#include "ScrollbarTheme.h"
48
#include "ScrollbarTheme.h"
48
#include "StringTruncator.h"
49
#include "StringTruncator.h"
49
#include "TextRun.h"
50
#include "TextRun.h"
Lines 352-357 void PopupListBox::typeAheadFind(const PlatformKeyboardEvent& event) a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec2
352
353
353
void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect)
354
void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect)
354
{
355
{
356
    int scale = m_settings.defaultDeviceScaleFactor;
355
    // adjust coords for scrolled frame
357
    // adjust coords for scrolled frame
356
    IntRect r = intersection(rect, frameRect());
358
    IntRect r = intersection(rect, frameRect());
357
    int tx = x() - scrollX();
359
    int tx = x() - scrollX();
Lines 366-371 void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec3
366
368
367
    // FIXME: Can we optimize scrolling to not require repainting the entire
369
    // FIXME: Can we optimize scrolling to not require repainting the entire
368
    // window? Should we?
370
    // window? Should we?
371
    if (scale != 1)
372
        gc->scale(FloatSize(scale, scale));
369
    for (int i = 0; i < numItems(); ++i)
373
    for (int i = 0; i < numItems(); ++i)
370
        paintRow(gc, r, i);
374
        paintRow(gc, r, i);
371
375
Lines 389-394 void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec4
389
    if (!rowRect.intersects(rect))
393
    if (!rowRect.intersects(rect))
390
        return;
394
        return;
391
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
    }
408
392
    PopupMenuStyle style = m_popupClient->itemStyle(rowIndex);
409
    PopupMenuStyle style = m_popupClient->itemStyle(rowIndex);
393
410
394
    // Paint background
411
    // Paint background
Lines 613-627 void PopupListBox::setOriginalIndex(int index) a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec5
613
630
614
int PopupListBox::getRowHeight(int index)
631
int PopupListBox::getRowHeight(int index)
615
{
632
{
616
    if (index < 0)
633
    int scale = m_settings.defaultDeviceScaleFactor;
617
        return PopupMenuChromium::minimumRowHeight();
634
    int paddingForTouch = 0;
618
635
    if (RuntimeEnabledFeatures::touchEnabled())
619
    if (m_popupClient->itemStyle(index).isDisplayNone())
636
        paddingForTouch = PopupMenuChromium::optionPaddingForTouch();
620
        return PopupMenuChromium::minimumRowHeight();
637
    if (index < 0 || m_popupClient->itemStyle(index).isDisplayNone())
638
        return PopupMenuChromium::minimumRowHeight() * scale;
621
639
622
    // Separator row height is the same size as itself.
640
    // Separator row height is the same size as itself.
623
    if (m_popupClient->itemIsSeparator(index))
641
    if (m_popupClient->itemIsSeparator(index))
624
        return max(separatorHeight, PopupMenuChromium::minimumRowHeight());
642
        return max(separatorHeight, (PopupMenuChromium::minimumRowHeight())) * scale;
625
643
626
    String icon = m_popupClient->itemIcon(index);
644
    String icon = m_popupClient->itemIcon(index);
627
    RefPtr<Image> image(Image::loadPlatformResource(icon.utf8().data()));
645
    RefPtr<Image> image(Image::loadPlatformResource(icon.utf8().data()));
Lines 631-637 int PopupListBox::getRowHeight(int index) a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec6
631
649
632
    int linePaddingHeight = m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup ? kLinePaddingHeight : 0;
650
    int linePaddingHeight = m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup ? kLinePaddingHeight : 0;
633
    int calculatedRowHeight = max(fontHeight, iconHeight) + linePaddingHeight * 2;
651
    int calculatedRowHeight = max(fontHeight, iconHeight) + linePaddingHeight * 2;
634
    return max(calculatedRowHeight, PopupMenuChromium::minimumRowHeight());
652
    return (max(calculatedRowHeight, PopupMenuChromium::minimumRowHeight()) + paddingForTouch) * scale;
635
}
653
}
636
654
637
IntRect PopupListBox::getRowBounds(int index)
655
IntRect PopupListBox::getRowBounds(int index)
- a/Source/WebCore/platform/chromium/PopupListBox.h +2 lines
Lines 79-84 struct PopupContainerSettings { a/Source/WebCore/platform/chromium/PopupListBox.h_sec1
79
    // Whether we should restrict the width of the PopupListBox or not.
79
    // Whether we should restrict the width of the PopupListBox or not.
80
    // Autocomplete popups are restricted, combo-boxes (select tags) aren't.
80
    // Autocomplete popups are restricted, combo-boxes (select tags) aren't.
81
    bool restrictWidthOfListBox;
81
    bool restrictWidthOfListBox;
82
83
    int defaultDeviceScaleFactor;
82
};
84
};
83
85
84
// A container for the data for each menu item (e.g. represented by <option>
86
// A container for the data for each menu item (e.g. represented by <option>
- a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp -2 / +14 lines
Lines 31-41 a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp_sec1
31
31
32
#include "config.h"
32
#include "config.h"
33
#include "PopupMenuChromium.h"
33
#include "PopupMenuChromium.h"
34
35
#include "Frame.h"
36
#include "FrameView.h"
37
#include "Page.h"
34
#include "PopupContainer.h"
38
#include "PopupContainer.h"
39
#include "Settings.h"
35
40
36
namespace WebCore {
41
namespace WebCore {
37
42
38
int PopupMenuChromium::s_minimumRowHeight = 0;
43
int PopupMenuChromium::s_minimumRowHeight = 0;
44
int PopupMenuChromium::s_optionPaddingForTouch = 30;
39
45
40
// The settings used for the drop down menu.
46
// The settings used for the drop down menu.
41
// This is the delegate used if none is provided.
47
// This is the delegate used if none is provided.
Lines 62-69 PopupMenuChromium::~PopupMenuChromium() a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp_sec2
62
68
63
void PopupMenuChromium::show(const IntRect& r, FrameView* v, int index)
69
void PopupMenuChromium::show(const IntRect& r, FrameView* v, int index)
64
{
70
{
65
    if (!p.popup)
71
    if (!p.popup) {
66
        p.popup = PopupContainer::create(client(), PopupContainer::Select, dropDownSettings);
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
    }
67
    p.popup->showInRect(r, v, index);
79
    p.popup->showInRect(r, v, index);
68
}
80
}
69
81
- a/Source/WebCore/platform/chromium/PopupMenuChromium.h +4 lines
Lines 57-62 public: a/Source/WebCore/platform/chromium/PopupMenuChromium.h_sec1
57
    static int minimumRowHeight() { return s_minimumRowHeight; }
57
    static int minimumRowHeight() { return s_minimumRowHeight; }
58
    static void setMinimumRowHeight(int minimumRowHeight) { s_minimumRowHeight = minimumRowHeight; }
58
    static void setMinimumRowHeight(int minimumRowHeight) { s_minimumRowHeight = minimumRowHeight; }
59
59
60
    static int optionPaddingForTouch() { return s_optionPaddingForTouch; }
61
    static void setOptionPaddingForTouch(int optionPaddingForTouch) { s_optionPaddingForTouch = optionPaddingForTouch; }
62
60
private:
63
private:
61
    PopupMenuClient* client() const { return m_popupClient; }
64
    PopupMenuClient* client() const { return m_popupClient; }
62
65
Lines 64-69 private: a/Source/WebCore/platform/chromium/PopupMenuChromium.h_sec2
64
    PopupMenuPrivate p;
67
    PopupMenuPrivate p;
65
68
66
    static int s_minimumRowHeight;
69
    static int s_minimumRowHeight;
70
    static int s_optionPaddingForTouch;
67
};
71
};
68
72
69
} // namespace WebCore
73
} // namespace WebCore
- a/Source/WebCore/rendering/RenderMenuList.cpp +4 lines
Lines 43-48 a/Source/WebCore/rendering/RenderMenuList.cpp_sec1
43
#include "RenderBR.h"
43
#include "RenderBR.h"
44
#include "RenderScrollbar.h"
44
#include "RenderScrollbar.h"
45
#include "RenderTheme.h"
45
#include "RenderTheme.h"
46
#include "Settings.h"
46
#include "TextRun.h"
47
#include "TextRun.h"
47
#include <math.h>
48
#include <math.h>
48
49
Lines 308-313 void RenderMenuList::showPopup() a/Source/WebCore/rendering/RenderMenuList.cpp_sec2
308
    // the actual width of the element to size the popup.
309
    // the actual width of the element to size the popup.
309
    FloatPoint absTopLeft = localToAbsolute(FloatPoint(), false, true);
310
    FloatPoint absTopLeft = localToAbsolute(FloatPoint(), false, true);
310
    LayoutRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
311
    LayoutRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
312
    int scale = document()->page()->settings()->defaultDeviceScaleFactor();
313
    if (scale && scale != 1)
314
        absBounds.scale(scale);
311
    absBounds.setLocation(roundedLayoutPoint(absTopLeft));
315
    absBounds.setLocation(roundedLayoutPoint(absTopLeft));
312
    HTMLSelectElement* select = toHTMLSelectElement(node());
316
    HTMLSelectElement* select = toHTMLSelectElement(node());
313
    m_popup->show(absBounds, document()->view(), select->optionToListIndex(select->selectedIndex()));
317
    m_popup->show(absBounds, document()->view(), select->optionToListIndex(select->selectedIndex()));
- a/Source/WebKit/chromium/src/WebViewImpl.cpp -2 / +24 lines
Lines 602-609 bool WebViewImpl::mouseWheel(const WebMouseWheelEvent& event) a/Source/WebKit/chromium/src/WebViewImpl.cpp_sec1
602
#if ENABLE(GESTURE_EVENTS)
602
#if ENABLE(GESTURE_EVENTS)
603
bool WebViewImpl::gestureEvent(const WebGestureEvent& event)
603
bool WebViewImpl::gestureEvent(const WebGestureEvent& event)
604
{
604
{
605
    RefPtr<WebCore::PopupContainer> selectPopup;
605
    PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
606
    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;
607
}
624
}
608
625
609
void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec)
626
void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec)
Lines 2691-2699 void WebViewImpl::applyAutofillSuggestions( a/Source/WebKit/chromium/src/WebViewImpl.cpp_sec2
2691
        inputElem, names, labels, icons, uniqueIDs, separatorIndex);
2708
        inputElem, names, labels, icons, uniqueIDs, separatorIndex);
2692
2709
2693
    if (!m_autofillPopup) {
2710
    if (!m_autofillPopup) {
2711
        PopupContainerSettings popupSettings = autofillPopupSettings;
2712
        popupSettings.defaultDeviceScaleFactor =
2713
            m_page->settings()->defaultDeviceScaleFactor();
2714
        if (!popupSettings.defaultDeviceScaleFactor)
2715
            popupSettings.defaultDeviceScaleFactor = 1;
2694
        m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(),
2716
        m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(),
2695
                                                 PopupContainer::Suggestion,
2717
                                                 PopupContainer::Suggestion,
2696
                                                 autofillPopupSettings);
2718
                                                 popupSettings);
2697
    }
2719
    }
2698
2720
2699
    if (m_autofillPopupShowing) {
2721
    if (m_autofillPopupShowing) {
- a/Source/WebKit/chromium/tests/PopupMenuTest.cpp -1 / +8 lines
Lines 42-47 a/Source/WebKit/chromium/tests/PopupMenuTest.cpp_sec1
42
#include "PopupMenu.h"
42
#include "PopupMenu.h"
43
#include "PopupMenuClient.h"
43
#include "PopupMenuClient.h"
44
#include "PopupMenuChromium.h"
44
#include "PopupMenuChromium.h"
45
#include "RuntimeEnabledFeatures.h"
45
#include "WebDocument.h"
46
#include "WebDocument.h"
46
#include "WebElement.h"
47
#include "WebElement.h"
47
#include "WebFrame.h"
48
#include "WebFrame.h"
Lines 154-160 public: a/Source/WebKit/chromium/tests/PopupMenuTest.cpp_sec2
154
    // We need to override this so that the popup menu size is not 0
155
    // We need to override this so that the popup menu size is not 0
155
    // (the layout code checks to see if the popup fits on the screen).
156
    // (the layout code checks to see if the popup fits on the screen).
156
    virtual WebScreenInfo screenInfo()
157
    virtual WebScreenInfo screenInfo()
157
    { 
158
    {
158
        WebScreenInfo screenInfo;
159
        WebScreenInfo screenInfo;
159
        screenInfo.availableRect.height = 2000;
160
        screenInfo.availableRect.height = 2000;
160
        screenInfo.availableRect.width = 2000;
161
        screenInfo.availableRect.width = 2000;
Lines 181-186 public: a/Source/WebKit/chromium/tests/PopupMenuTest.cpp_sec3
181
protected:
182
protected:
182
    virtual void SetUp()
183
    virtual void SetUp()
183
    {
184
    {
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);
184
        m_webView = static_cast<WebViewImpl*>(WebView::create(&m_webviewClient));
189
        m_webView = static_cast<WebViewImpl*>(WebView::create(&m_webviewClient));
185
        m_webView->initializeMainFrame(&m_webFrameClient);
190
        m_webView->initializeMainFrame(&m_webFrameClient);
186
        m_popupMenu = adoptRef(new PopupMenuChromium(&m_popupMenuClient));
191
        m_popupMenu = adoptRef(new PopupMenuChromium(&m_popupMenuClient));
Lines 191-196 protected: a/Source/WebKit/chromium/tests/PopupMenuTest.cpp_sec4
191
        m_popupMenu = 0;
196
        m_popupMenu = 0;
192
        m_webView->close();
197
        m_webView->close();
193
        webkit_support::UnregisterAllMockedURLs();
198
        webkit_support::UnregisterAllMockedURLs();
199
        RuntimeEnabledFeatures::setTouchEnabled(m_touchWasEnabled);
194
    }
200
    }
195
201
196
    // Returns true if there currently is a select popup in the WebView.
202
    // Returns true if there currently is a select popup in the WebView.
Lines 278-283 protected: a/Source/WebKit/chromium/tests/PopupMenuTest.cpp_sec5
278
    TestWebFrameClient m_webFrameClient;
284
    TestWebFrameClient m_webFrameClient;
279
    TestPopupMenuClient m_popupMenuClient;
285
    TestPopupMenuClient m_popupMenuClient;
280
    RefPtr<PopupMenu> m_popupMenu;
286
    RefPtr<PopupMenu> m_popupMenu;
287
    bool m_touchWasEnabled;
281
    std::string baseURL;
288
    std::string baseURL;
282
};
289
};
283
290

Return to Bug 80027