Changeset 110359 in webkit
- Timestamp:
- Mar 9, 2012 6:40:26 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r110358 r110359 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 31 2012-03-09 Stephen White <senorblanco@chromium.org> 2 32 -
trunk/Source/WebCore/platform/chromium/PopupListBox.cpp
r107842 r110359 45 45 #include "PopupMenuClient.h" 46 46 #include "RenderTheme.h" 47 #include "RuntimeEnabledFeatures.h" 47 48 #include "ScrollbarTheme.h" 48 49 #include "StringTruncator.h" … … 353 354 void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) 354 355 { 356 int scale = m_settings.defaultDeviceScaleFactor; 355 357 // adjust coords for scrolled frame 356 358 IntRect r = intersection(rect, frameRect()); … … 367 369 // FIXME: Can we optimize scrolling to not require repainting the entire 368 370 // window? Should we? 371 if (scale != 1) 372 gc->scale(FloatSize(scale, scale)); 369 373 for (int i = 0; i < numItems(); ++i) 370 374 paintRow(gc, r, i); … … 389 393 if (!rowRect.intersects(rect)) 390 394 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 } 391 408 392 409 PopupMenuStyle style = m_popupClient->itemStyle(rowIndex); … … 614 631 int PopupListBox::getRowHeight(int index) 615 632 { 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; 621 639 622 640 // Separator row height is the same size as itself. 623 641 if (m_popupClient->itemIsSeparator(index)) 624 return max(separatorHeight, PopupMenuChromium::minimumRowHeight());642 return max(separatorHeight, (PopupMenuChromium::minimumRowHeight())) * scale; 625 643 626 644 String icon = m_popupClient->itemIcon(index); … … 632 650 int linePaddingHeight = m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup ? kLinePaddingHeight : 0; 633 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 -
trunk/Source/WebCore/platform/chromium/PopupListBox.h
r107036 r110359 80 80 // Autocomplete popups are restricted, combo-boxes (select tags) aren't. 81 81 bool restrictWidthOfListBox; 82 83 int defaultDeviceScaleFactor; 82 84 }; 83 85 -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp
r95901 r110359 32 32 #include "config.h" 33 33 #include "PopupMenuChromium.h" 34 35 #include "Frame.h" 36 #include "FrameView.h" 37 #include "Page.h" 34 38 #include "PopupContainer.h" 39 #include "Settings.h" 35 40 36 41 namespace WebCore { 37 42 38 43 int PopupMenuChromium::s_minimumRowHeight = 0; 44 int PopupMenuChromium::s_optionPaddingForTouch = 30; 39 45 40 46 // The settings used for the drop down menu. … … 63 69 void PopupMenuChromium::show(const IntRect& r, FrameView* v, int index) 64 70 { 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 } 67 79 p.popup->showInRect(r, v, index); 68 80 } -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.h
r95901 r110359 58 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 63 private: 61 64 PopupMenuClient* client() const { return m_popupClient; } … … 65 68 66 69 static int s_minimumRowHeight; 70 static int s_optionPaddingForTouch; 67 71 }; 68 72 -
trunk/Source/WebCore/rendering/RenderMenuList.cpp
r109806 r110359 44 44 #include "RenderScrollbar.h" 45 45 #include "RenderTheme.h" 46 #include "Settings.h" 46 47 #include "TextRun.h" 47 48 #include <math.h> … … 309 310 FloatPoint absTopLeft = localToAbsolute(FloatPoint(), false, true); 310 311 LayoutRect absBounds = absoluteBoundingBoxRectIgnoringTransforms(); 312 int scale = document()->page()->settings()->defaultDeviceScaleFactor(); 313 if (scale && scale != 1) 314 absBounds.scale(scale); 311 315 absBounds.setLocation(roundedLayoutPoint(absTopLeft)); 312 316 HTMLSelectElement* select = toHTMLSelectElement(node()); -
trunk/Source/WebKit/chromium/ChangeLog
r110357 r110359 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 12 2012-03-09 James Robinson <jamesr@chromium.org> 2 13 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r110325 r110359 603 603 bool WebViewImpl::gestureEvent(const WebGestureEvent& event) 604 604 { 605 RefPtr<WebCore::PopupContainer> selectPopup; 605 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 … … 2692 2709 2693 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 2716 m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(), 2695 2717 PopupContainer::Suggestion, 2696 autofillPopupSettings);2718 popupSettings); 2697 2719 } 2698 2720
Note: See TracChangeset
for help on using the changeset viewer.