Changeset 167825 in webkit
- Timestamp:
- Apr 25, 2014 2:42:48 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r167821 r167825 1 2014-04-25 Dean Jackson <dino@apple.com> 2 3 Allow a platform-specific size enumeration to be passed into popup-menu display 4 https://bugs.webkit.org/show_bug.cgi?id=132195 5 6 Reviewed by Brent Fulgham. With some in-person review comments from Sam Weinig. 7 8 Platforms like OS X use a set of predefined sizes for built-in controls 9 used for <select>: normal, small and mini. Expose that information to 10 the PopupMenuClient via the PopupMenuStyle, allowing it to be passed 11 into the platform code in WebKitSystemInterface. 12 13 * platform/PopupMenuStyle.h: Add a menu size enum. 14 (WebCore::PopupMenuStyle::PopupMenuStyle): 15 (WebCore::PopupMenuStyle::menuSize): 16 * platform/mac/WebCoreSystemInterface.h: Pass in NSControlSize as a parameter 17 to WKPopupMenu. 18 * platform/mac/WebCoreSystemInterface.mm: Ditto. 19 * rendering/RenderMenuList.cpp: 20 (RenderMenuList::menuStyle): Ask the RenderTheme to calculate the size 21 of the menu button, so that it can be added to the PopupMenuStyle. 22 * rendering/RenderTheme.h: New method to retrieve the menu size. 23 (WebCore::RenderTheme::popupMenuSize): Convert an NSControlSize into a PopupMenuSize. 24 * rendering/RenderThemeMac.h: Override the base function, and add a 25 controlSizeForCell helper. 26 * rendering/RenderThemeMac.mm: 27 (WebCore::RenderThemeMac::controlSizeForCell): Used by this new 28 code and the old setControlSizeForCell to calculate the NSControlSize 29 that would be used for the button. 30 (WebCore::RenderThemeMac::setControlSize): Call the new helper. 31 (WebCore::RenderThemeMac::popupMenuSize): Return the value from the helper. 32 1 33 2014-04-25 Javier Fernandez <jfernandez@igalia.com> 2 34 -
trunk/Source/WebCore/WebCore.exp.in
r167793 r167825 2314 2314 _wkMeasureMediaUIPart 2315 2315 _wkPopupMenu 2316 _wkPopupMenuWithSize 2316 2317 _wkQTClearMediaDownloadCache 2317 2318 _wkQTClearMediaDownloadCacheForSite -
trunk/Source/WebCore/platform/PopupMenuStyle.h
r145406 r167825 38 38 enum PopupMenuType { SelectPopup, AutofillPopup }; 39 39 enum BackgroundColorType { DefaultBackgroundColor, CustomBackgroundColor }; 40 PopupMenuStyle(const Color& foreground, const Color& background, const Font& font, bool visible, bool isDisplayNone, Length textIndent, TextDirection textDirection, bool hasTextDirectionOverride, BackgroundColorType backgroundColorType = DefaultBackgroundColor, PopupMenuType menuType = SelectPopup) 40 enum PopupMenuSize { 41 PopupMenuSizeNormal, 42 PopupMenuSizeSmall, 43 PopupMenuSizeMini 44 }; 45 46 PopupMenuStyle(const Color& foreground, const Color& background, const Font& font, bool visible, bool isDisplayNone, Length textIndent, TextDirection textDirection, bool hasTextDirectionOverride, BackgroundColorType backgroundColorType = DefaultBackgroundColor, PopupMenuType menuType = SelectPopup, PopupMenuSize menuSize = PopupMenuSizeNormal) 41 47 : m_foregroundColor(foreground) 42 48 , m_backgroundColor(background) … … 49 55 , m_backgroundColorType(backgroundColorType) 50 56 , m_menuType(menuType) 57 , m_menuSize(menuSize) 51 58 { 52 59 } … … 62 69 BackgroundColorType backgroundColorType() const { return m_backgroundColorType; } 63 70 PopupMenuType menuType() const { return m_menuType; } 71 PopupMenuSize menuSize() const { return m_menuSize; } 72 64 73 private: 65 74 Color m_foregroundColor; … … 73 82 BackgroundColorType m_backgroundColorType; 74 83 PopupMenuType m_menuType; 84 PopupMenuSize m_menuSize; 75 85 }; 76 86 -
trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h
r167609 r167825 197 197 extern void (*wkWindowSetAlpha)(NSWindow *, float); 198 198 extern void (*wkWindowSetScaledFrame)(NSWindow *, NSRect, NSRect); 199 199 200 extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*); 201 #if defined(__OBJC__) 202 extern void (*wkPopupMenuWithSize)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*, NSControlSize controlSize); 203 #endif 204 200 205 extern unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void); 201 206 extern int (*wkQTMovieDataRate)(QTMovie*); -
trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm
r167609 r167825 68 68 UInt8 (*wkGetNSEventKeyChar)(NSEvent *); 69 69 void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*); 70 void (*wkPopupMenuWithSize)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*, NSControlSize controlSize); 70 71 unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void); 71 72 int (*wkQTMovieDataRate)(QTMovie*); -
trunk/Source/WebCore/rendering/RenderMenuList.cpp
r164441 r167825 561 561 { 562 562 const RenderStyle& styleToUse = m_innerBlock ? m_innerBlock->style() : style(); 563 return PopupMenuStyle(styleToUse.visitedDependentColor(CSSPropertyColor), styleToUse.visitedDependentColor(CSSPropertyBackgroundColor), styleToUse.font(), styleToUse.visibility() == VISIBLE, 564 styleToUse.display() == NONE, styleToUse.textIndent(), style().direction(), isOverride(style().unicodeBidi())); 563 IntRect absBounds = absoluteBoundingBoxRectIgnoringTransforms(); 564 return PopupMenuStyle(styleToUse.visitedDependentColor(CSSPropertyColor), styleToUse.visitedDependentColor(CSSPropertyBackgroundColor), 565 styleToUse.font(), styleToUse.visibility() == VISIBLE, styleToUse.display() == NONE, styleToUse.textIndent(), 566 style().direction(), isOverride(style().unicodeBidi()), PopupMenuStyle::DefaultBackgroundColor, 567 PopupMenuStyle::SelectPopup, theme().popupMenuSize(&styleToUse, absBounds)); 565 568 } 566 569 -
trunk/Source/WebCore/rendering/RenderTheme.h
r167786 r167825 30 30 #include "ThemeTypes.h" 31 31 #endif 32 #include "PopupMenuStyle.h" 32 33 #include "RenderObject.h" 33 34 #include "ScrollTypes.h" … … 185 186 virtual int popupInternalPaddingBottom(RenderStyle*) const { return 0; } 186 187 virtual bool popupOptionSupportsTextIndent() const { return false; } 188 virtual PopupMenuStyle::PopupMenuSize popupMenuSize(const RenderStyle*, IntRect&) const { return PopupMenuStyle::PopupMenuSizeNormal; } 187 189 188 190 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return RegularScrollbar; } -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r167786 r167825 82 82 virtual int popupInternalPaddingTop(RenderStyle*) const; 83 83 virtual int popupInternalPaddingBottom(RenderStyle*) const; 84 virtual PopupMenuStyle::PopupMenuSize popupMenuSize(const RenderStyle*, IntRect&) const; 84 85 85 86 virtual bool paintCapsLockIndicator(const RenderObject&, const PaintInfo&, const IntRect&) override; … … 180 181 NSControlSize controlSizeForFont(RenderStyle*) const; 181 182 NSControlSize controlSizeForSystemFont(RenderStyle*) const; 183 NSControlSize controlSizeForCell(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f) const; 182 184 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f); 183 185 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const; -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r167786 r167825 741 741 } 742 742 743 NSControlSize RenderThemeMac::controlSizeForCell(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel) const 744 { 745 if (minSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomLevel) 746 && minSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomLevel)) 747 return NSRegularControlSize; 748 749 if (minSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomLevel) 750 && minSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomLevel)) 751 return NSSmallControlSize; 752 753 return NSMiniControlSize; 754 } 755 743 756 void RenderThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minSize, float zoomLevel) 744 757 { 745 NSControlSize size; 746 if (minSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomLevel) && 747 minSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomLevel)) 748 size = NSRegularControlSize; 749 else if (minSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomLevel) && 750 minSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomLevel)) 751 size = NSSmallControlSize; 752 else 753 size = NSMiniControlSize; 758 NSControlSize size = controlSizeForCell(cell, sizes, minSize, zoomLevel); 754 759 if (size != [cell controlSize]) // Only update if we have to, since AppKit does work even if the size is the same. 755 760 [cell setControlSize:size]; … … 1384 1389 } 1385 1390 1391 PopupMenuStyle::PopupMenuSize RenderThemeMac::popupMenuSize(const RenderStyle* style, IntRect& rect) const 1392 { 1393 NSPopUpButtonCell* popupButton = this->popupButton(); 1394 NSControlSize size = controlSizeForCell(popupButton, popupButtonSizes(), rect.size(), style->effectiveZoom()); 1395 switch (size) { 1396 case NSRegularControlSize: 1397 return PopupMenuStyle::PopupMenuSizeNormal; 1398 case NSSmallControlSize: 1399 return PopupMenuStyle::PopupMenuSizeSmall; 1400 case NSMiniControlSize: 1401 return PopupMenuStyle::PopupMenuSizeMini; 1402 default: 1403 return PopupMenuStyle::PopupMenuSizeNormal; 1404 } 1405 } 1406 1386 1407 void RenderThemeMac::adjustMenuListButtonStyle(StyleResolver*, RenderStyle* style, Element*) const 1387 1408 { -
trunk/Source/WebKit/mac/ChangeLog
r167788 r167825 1 2014-04-25 Dean Jackson <dino@apple.com> 2 3 Allow a platform-specific size enumeration to be passed into popup-menu display 4 https://bugs.webkit.org/show_bug.cgi?id=132195 5 6 Reviewed by Brent Fulgham. With some in-person review comments from Sam Weinig. 7 8 Platforms like OS X use a set of predefined sizes for built-in controls 9 used for <select>: normal, small and mini. Expose that information to 10 the PopupMenuClient via the PopupMenuStyle, allowing it to be passed 11 into the platform code in WebKitSystemInterface. 12 13 * WebCoreSupport/PopupMenuMac.mm: 14 (PopupMenuMac::show): Convert the WebCore menu size type into the 15 WebCoreSystemInterface type. 16 1 17 2014-04-24 Commit Queue <commit-queue@webkit.org> 2 18 -
trunk/Source/WebKit/mac/WebCoreSupport/PopupMenuMac.mm
r162929 r167825 192 192 } 193 193 194 wkPopupMenu(menu, location, roundf(NSWidth(r)), dummyView.get(), index, font); 194 NSControlSize controlSize; 195 switch (m_client->menuStyle().menuSize()) { 196 case PopupMenuStyle::PopupMenuSizeNormal: 197 controlSize = NSRegularControlSize; 198 break; 199 case PopupMenuStyle::PopupMenuSizeSmall: 200 controlSize = NSSmallControlSize; 201 break; 202 case PopupMenuStyle::PopupMenuSizeMini: 203 controlSize = NSMiniControlSize; 204 break; 205 } 206 207 wkPopupMenuWithSize(menu, location, roundf(NSWidth(r)), dummyView.get(), index, font, controlSize); 195 208 196 209 [m_popup dismissPopUp]; -
trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
r167609 r167825 94 94 INIT(WindowSetScaledFrame); 95 95 INIT(PopupMenu); 96 INIT(PopupMenuWithSize); 96 97 INIT(SetCGFontRenderingMode); 97 98 #endif -
trunk/Source/WebKit2/ChangeLog
r167822 r167825 1 2014-04-25 Dean Jackson <dino@apple.com> 2 3 Allow a platform-specific size enumeration to be passed into popup-menu display 4 https://bugs.webkit.org/show_bug.cgi?id=132195 5 6 Reviewed by Brent Fulgham. With some in-person review comments from Sam Weinig. 7 8 Platforms like OS X use a set of predefined sizes for built-in controls 9 used for <select>: normal, small and mini. Expose that information to 10 the PopupMenuClient via the PopupMenuStyle, allowing it to be passed 11 into the platform code in WebKitSystemInterface. 12 13 * Shared/PlatformPopupMenuData.cpp: Encode and decode the PopupMenuSize enum. 14 (WebKit::PlatformPopupMenuData::encode): 15 (WebKit::PlatformPopupMenuData::decode): 16 * Shared/PlatformPopupMenuData.h: Add PopupMenuSize member variable. 17 * UIProcess/mac/WebPopupMenuProxyMac.mm: 18 (WebKit::WebPopupMenuProxyMac::showPopupMenu): Convert the PopupMenuSize 19 into a WKControlSize, and pass that into WKPopupMenu. 20 * WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm: 21 (WebKit::WebPopupMenu::setUpPlatformData): Add the PopupMenuSize to 22 the PlatformPopupMenuData. 23 1 24 2014-04-25 Tim Horton <timothy_horton@apple.com> 2 25 -
trunk/Source/WebKit2/Shared/PlatformPopupMenuData.cpp
r163886 r167825 40 40 encoder << fontInfo; 41 41 encoder << shouldPopOver; 42 encoder.encodeEnum(menuSize); 42 43 #else 43 44 UNUSED_PARAM(encoder); … … 52 53 if (!decoder.decode(data.shouldPopOver)) 53 54 return false; 55 if (!decoder.decodeEnum(data.menuSize)) 56 return false; 54 57 #else 55 58 UNUSED_PARAM(decoder); -
trunk/Source/WebKit2/Shared/PlatformPopupMenuData.h
r163886 r167825 29 29 #include "FontInfo.h" 30 30 #include "ShareableBitmap.h" 31 #include <WebCore/PopupMenuStyle.h> 31 32 #include <wtf/text/WTFString.h> 32 33 … … 47 48 FontInfo fontInfo; 48 49 bool shouldPopOver; 50 WebCore::PopupMenuStyle::PopupMenuSize menuSize; 49 51 #endif 50 52 }; -
trunk/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
r162505 r167825 135 135 location = [dummyView convertPoint:location fromView:m_webView]; 136 136 137 WKPopupMenu(menu, location, roundf(NSWidth(rect)), dummyView.get(), selectedIndex, font); 137 NSControlSize controlSize; 138 switch (data.menuSize) { 139 case WebCore::PopupMenuStyle::PopupMenuSizeNormal: 140 controlSize = NSRegularControlSize; 141 break; 142 case WebCore::PopupMenuStyle::PopupMenuSizeSmall: 143 controlSize = NSSmallControlSize; 144 break; 145 case WebCore::PopupMenuStyle::PopupMenuSizeMini: 146 controlSize = NSMiniControlSize; 147 break; 148 } 149 150 WKPopupMenuWithSize(menu, location, roundf(NSWidth(rect)), dummyView.get(), selectedIndex, font, controlSize); 138 151 139 152 [m_popup dismissPopUp]; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm
r117085 r167825 50 50 data.fontInfo.fontAttributeDictionary = fontDescriptorAttributes; 51 51 data.shouldPopOver = m_popupClient->shouldPopOver(); 52 data.menuSize = m_popupClient->menuStyle().menuSize(); 52 53 #else 53 54 UNUSED_PARAM(data); -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
r167609 r167825 90 90 INIT(MeasureMediaUIPart); 91 91 INIT(PopupMenu); 92 INIT(PopupMenuWithSize); 92 93 INIT(QTIncludeOnlyModernMediaFileTypes); 93 94 INIT(QTMovieDataRate);
Note: See TracChangeset
for help on using the changeset viewer.