| Differences between
and this patch
- a/Source/WebCore/ChangeLog +30 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-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
1
2012-03-09  Patrick Gansterer  <paroga@webkit.org>
31
2012-03-09  Patrick Gansterer  <paroga@webkit.org>
2
32
3
        Build fix for !ENABLE(FILTERS) after r110285.
33
        Build fix for !ENABLE(FILTERS) after r110285.
- a/Source/WebKit/chromium/ChangeLog +11 lines
Lines 1-3 a/Source/WebKit/chromium/ChangeLog_sec1
1
2012-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
1
2012-03-09  Dana Jansens  <danakj@chromium.org>
12
2012-03-09  Dana Jansens  <danakj@chromium.org>
2
13
3
        [chromium] Use opaque paints in CCOcclusionTracker
14
        [chromium] Use opaque paints in CCOcclusionTracker
- 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 601-608 bool WebViewImpl::mouseWheel(const WebMouseWheelEvent& event) a/Source/WebKit/chromium/src/WebViewImpl.cpp_sec1
601
#if ENABLE(GESTURE_EVENTS)
601
#if ENABLE(GESTURE_EVENTS)
602
bool WebViewImpl::gestureEvent(const WebGestureEvent& event)
602
bool WebViewImpl::gestureEvent(const WebGestureEvent& event)
603
{
603
{
604
    RefPtr<WebCore::PopupContainer> selectPopup;
604
    PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
605
    PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
605
    return mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
606
    if (event.type == WebInputEvent::GestureTap) {
607
        selectPopup = m_selectPopup;
608
        hideSelectPopup();
609
        ASSERT(!m_selectPopup);
610
    }
611
612
    bool gestureHandled = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
613
614
    if (m_selectPopup && m_selectPopup == selectPopup) {
615
        // That tap triggered a select popup which is the same as the one that
616
        // was showing before the tap. It means the user tapped the select
617
        // while the popup was showing, and as a result we first closed then
618
        // immediately reopened the select popup. It needs to be closed.
619
        hideSelectPopup();
620
    }
621
622
    return gestureHandled;
606
}
623
}
607
624
608
void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec)
625
void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec)
Lines 2690-2698 void WebViewImpl::applyAutofillSuggestions( a/Source/WebKit/chromium/src/WebViewImpl.cpp_sec2
2690
        inputElem, names, labels, icons, uniqueIDs, separatorIndex);
2707
        inputElem, names, labels, icons, uniqueIDs, separatorIndex);
2691
2708
2692
    if (!m_autofillPopup) {
2709
    if (!m_autofillPopup) {
2710
        PopupContainerSettings popupSettings = autofillPopupSettings;
2711
        popupSettings.defaultDeviceScaleFactor =
2712
            m_page->settings()->defaultDeviceScaleFactor();
2713
        if (!popupSettings.defaultDeviceScaleFactor)
2714
            popupSettings.defaultDeviceScaleFactor = 1;
2693
        m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(),
2715
        m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(),
2694
                                                 PopupContainer::Suggestion,
2716
                                                 PopupContainer::Suggestion,
2695
                                                 autofillPopupSettings);
2717
                                                 popupSettings);
2696
    }
2718
    }
2697
2719
2698
    if (m_autofillPopupShowing) {
2720
    if (m_autofillPopupShowing) {

Return to Bug 80027