[Mac] Allow popup menus to override default appearance
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 May 2014 21:03:54 +0000 (21:03 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 May 2014 21:03:54 +0000 (21:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133129

Reviewed by Tim Horton.

Source/WebCore:
WebKitSystemInterface's WKPopupMenu has a flag to hide
the arrows at the end of a popup-menu (e.g. <select>).
Expose that via adding a hasDefaultAppearance flag to
PopupMenuStyle, which then passes it on to WKSI.

* platform/PopupMenuStyle.h:
(WebCore::PopupMenuStyle::PopupMenuStyle): New flag in constructor.
(WebCore::PopupMenuStyle::hasDefaultAppearance): New flag.
* platform/mac/WebCoreSystemInterface.h: wkPopupMenu signature has changed to accept
the new flag.
* platform/mac/WebCoreSystemInterface.mm: Ditto.
* rendering/RenderMenuList.cpp:
(RenderMenuList::itemStyle): Pass in true as default appearance when creating
the PopupMenuStyle. We don't need it.
(RenderMenuList::menuStyle): In this case we pass in the negated value of
style().hasAppearance(), which indicates if we are overriding the built-in drawing.
* rendering/RenderSearchField.cpp:
(WebCore::RenderSearchField::menuStyle): Use true as the default value.

Source/WebKit/mac:
Replace the call to wkPopupMenuWithSize with wkPopupMenu, now
with extra parameters to indicate the control size and whether
or not to draw the arrows at the end.

* WebCoreSupport/PopupMenuMac.mm:
(PopupMenuMac::show):

Source/WebKit2:
Add an extra "hideArrows" flag to PlatformPopupMenuData
and replace the call to WKPopupMenuWithSize with WKPopupMenu.

* Shared/PlatformPopupMenuData.cpp: Encode and decode the new data value.
(WebKit::PlatformPopupMenuData::encode):
(WebKit::PlatformPopupMenuData::decode):
* Shared/PlatformPopupMenuData.h: Add hideArrows boolean.
* UIProcess/mac/WebPopupMenuProxyMac.mm:
(WebKit::WebPopupMenuProxyMac::showPopupMenu):
* WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm:
(WebKit::WebPopupMenu::setUpPlatformData): The hideArrows flag is
true if we don't have the default appearance.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169134 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/PopupMenuStyle.h
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/rendering/RenderMenuList.cpp
Source/WebCore/rendering/RenderSearchField.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/PopupMenuMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/PlatformPopupMenuData.cpp
Source/WebKit2/Shared/PlatformPopupMenuData.h
Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm

index 6076083..78be7b0 100644 (file)
@@ -1,3 +1,29 @@
+2014-05-20  Dean Jackson  <dino@apple.com>
+
+        [Mac] Allow popup menus to override default appearance
+        https://bugs.webkit.org/show_bug.cgi?id=133129
+
+        Reviewed by Tim Horton.
+
+        WebKitSystemInterface's WKPopupMenu has a flag to hide
+        the arrows at the end of a popup-menu (e.g. <select>).
+        Expose that via adding a hasDefaultAppearance flag to
+        PopupMenuStyle, which then passes it on to WKSI.
+
+        * platform/PopupMenuStyle.h:
+        (WebCore::PopupMenuStyle::PopupMenuStyle): New flag in constructor.
+        (WebCore::PopupMenuStyle::hasDefaultAppearance): New flag.
+        * platform/mac/WebCoreSystemInterface.h: wkPopupMenu signature has changed to accept
+        the new flag.
+        * platform/mac/WebCoreSystemInterface.mm: Ditto.
+        * rendering/RenderMenuList.cpp:
+        (RenderMenuList::itemStyle): Pass in true as default appearance when creating
+        the PopupMenuStyle. We don't need it.
+        (RenderMenuList::menuStyle): In this case we pass in the negated value of
+        style().hasAppearance(), which indicates if we are overriding the built-in drawing.
+        * rendering/RenderSearchField.cpp:
+        (WebCore::RenderSearchField::menuStyle): Use true as the default value.
+
 2014-05-20  Eric Carlson  <eric.carlson@apple.com>
 
         [Mac] do not deactivate an audio session that has running I/O
index c7aaac5..94b8a72 100644 (file)
@@ -43,12 +43,13 @@ public:
         PopupMenuSizeMini
     };
 
-    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)
+    PopupMenuStyle(const Color& foreground, const Color& background, const Font& font, bool visible, bool isDisplayNone, bool hasDefaultAppearance, Length textIndent, TextDirection textDirection, bool hasTextDirectionOverride, BackgroundColorType backgroundColorType = DefaultBackgroundColor, PopupMenuType menuType = SelectPopup, PopupMenuSize menuSize = PopupMenuSizeNormal)
         : m_foregroundColor(foreground)
         , m_backgroundColor(background)
         , m_font(font)
         , m_visible(visible)
         , m_isDisplayNone(isDisplayNone)
+        , m_hasDefaultAppearance(hasDefaultAppearance)
         , m_textIndent(textIndent)
         , m_textDirection(textDirection)
         , m_hasTextDirectionOverride(hasTextDirectionOverride)
@@ -63,6 +64,7 @@ public:
     const Font& font() const { return m_font; }
     bool isVisible() const { return m_visible; }
     bool isDisplayNone() const { return m_isDisplayNone; }
+    bool hasDefaultAppearance() const { return m_hasDefaultAppearance; }
     Length textIndent() const { return m_textIndent; }
     TextDirection textDirection() const { return m_textDirection; }
     bool hasTextDirectionOverride() const { return m_hasTextDirectionOverride; }
@@ -76,6 +78,7 @@ private:
     Font m_font;
     bool m_visible;
     bool m_isDisplayNone;
+    bool m_hasDefaultAppearance;
     Length m_textIndent;
     TextDirection m_textDirection;
     bool m_hasTextDirectionOverride;
index 48b1f25..2c13d1b 100644 (file)
@@ -202,8 +202,8 @@ extern NSControl *(*wkCreateMediaUIControl)(int);
 extern void (*wkWindowSetAlpha)(NSWindow *, float);
 extern void (*wkWindowSetScaledFrame)(NSWindow *, NSRect, NSRect);
 
-extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
 #if defined(__OBJC__)
+extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*, NSControlSize controlSize, bool hideArrows);
 extern void (*wkPopupMenuWithSize)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*, NSControlSize controlSize);
 #endif
 
index a841703..97466f1 100644 (file)
@@ -68,7 +68,7 @@ NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
 BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
 void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
 UInt8 (*wkGetNSEventKeyChar)(NSEvent *);
-void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
+void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*, NSControlSize controlSize, bool hideArrows);
 void (*wkPopupMenuWithSize)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*, NSControlSize controlSize);
 unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void);
 int (*wkQTMovieDataRate)(QTMovie*);
index 9ef7113..863f1cf 100644 (file)
@@ -522,7 +522,7 @@ PopupMenuStyle RenderMenuList::itemStyle(unsigned listIndex) const
 
     RenderStyle* style = element->renderStyle() ? element->renderStyle() : element->computedStyle();
     return style ? PopupMenuStyle(style->visitedDependentColor(CSSPropertyColor), itemBackgroundColor, style->font(), style->visibility() == VISIBLE,
-        style->display() == NONE, style->textIndent(), style->direction(), isOverride(style->unicodeBidi()),
+        style->display() == NONE, true, style->textIndent(), style->direction(), isOverride(style->unicodeBidi()),
         itemHasCustomBackgroundColor ? PopupMenuStyle::CustomBackgroundColor : PopupMenuStyle::DefaultBackgroundColor) : menuStyle();
 }
 
@@ -562,7 +562,7 @@ PopupMenuStyle RenderMenuList::menuStyle() const
     const RenderStyle& styleToUse = m_innerBlock ? m_innerBlock->style() : style();
     IntRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
     return PopupMenuStyle(styleToUse.visitedDependentColor(CSSPropertyColor), styleToUse.visitedDependentColor(CSSPropertyBackgroundColor),
-        styleToUse.font(), styleToUse.visibility() == VISIBLE, styleToUse.display() == NONE, styleToUse.textIndent(),
+        styleToUse.font(), styleToUse.visibility() == VISIBLE, styleToUse.display() == NONE, style().hasAppearance(), styleToUse.textIndent(),
         style().direction(), isOverride(style().unicodeBidi()), PopupMenuStyle::DefaultBackgroundColor,
         PopupMenuStyle::SelectPopup, theme().popupMenuSize(&styleToUse, absBounds));
 }
index 4541b8b..23ac5a0 100644 (file)
@@ -261,7 +261,7 @@ PopupMenuStyle RenderSearchField::itemStyle(unsigned) const
 PopupMenuStyle RenderSearchField::menuStyle() const
 {
     return PopupMenuStyle(style().visitedDependentColor(CSSPropertyColor), style().visitedDependentColor(CSSPropertyBackgroundColor), style().font(), style().visibility() == VISIBLE,
-        style().display() == NONE, style().textIndent(), style().direction(), isOverride(style().unicodeBidi()), PopupMenuStyle::CustomBackgroundColor);
+        style().display() == NONE, true, style().textIndent(), style().direction(), isOverride(style().unicodeBidi()), PopupMenuStyle::CustomBackgroundColor);
 }
 
 int RenderSearchField::clientInsetLeft() const
index e565176..099396d 100644 (file)
@@ -1,3 +1,17 @@
+2014-05-20  Dean Jackson  <dino@apple.com>
+
+        [Mac] Allow popup menus to override default appearance
+        https://bugs.webkit.org/show_bug.cgi?id=133129
+
+        Reviewed by Tim Horton.
+
+        Replace the call to wkPopupMenuWithSize with wkPopupMenu, now
+        with extra parameters to indicate the control size and whether
+        or not to draw the arrows at the end.
+
+        * WebCoreSupport/PopupMenuMac.mm:
+        (PopupMenuMac::show):
+
 2014-05-20  Eric Carlson  <eric.carlson@apple.com>
 
         [Mac] do not deactivate an audio session that has running I/O
index 5290293..9238810 100644 (file)
@@ -204,7 +204,7 @@ void PopupMenuMac::show(const IntRect& r, FrameView* v, int index)
         break;
     }
 
-    wkPopupMenuWithSize(menu, location, roundf(NSWidth(r)), dummyView.get(), index, font, controlSize);
+    wkPopupMenu(menu, location, roundf(NSWidth(r)), dummyView.get(), index, font, controlSize, !m_client->menuStyle().hasDefaultAppearance());
 
     [m_popup dismissPopUp];
     [dummyView removeFromSuperview];
index cfdec81..e2c0629 100644 (file)
@@ -1,3 +1,23 @@
+2014-05-20  Dean Jackson  <dino@apple.com>
+
+        [Mac] Allow popup menus to override default appearance
+        https://bugs.webkit.org/show_bug.cgi?id=133129
+
+        Reviewed by Tim Horton.
+
+        Add an extra "hideArrows" flag to PlatformPopupMenuData
+        and replace the call to WKPopupMenuWithSize with WKPopupMenu.
+
+        * Shared/PlatformPopupMenuData.cpp: Encode and decode the new data value.
+        (WebKit::PlatformPopupMenuData::encode):
+        (WebKit::PlatformPopupMenuData::decode):
+        * Shared/PlatformPopupMenuData.h: Add hideArrows boolean.
+        * UIProcess/mac/WebPopupMenuProxyMac.mm:
+        (WebKit::WebPopupMenuProxyMac::showPopupMenu):
+        * WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm:
+        (WebKit::WebPopupMenu::setUpPlatformData): The hideArrows flag is
+        true if we don't have the default appearance.
+
 2014-05-20  Eric Carlson  <eric.carlson@apple.com>
 
         [Mac] do not deactivate an audio session that has running I/O
index 5eebfe1..3ad06a3 100644 (file)
@@ -39,6 +39,7 @@ void PlatformPopupMenuData::encode(IPC::ArgumentEncoder& encoder) const
 #if PLATFORM(COCOA)
     encoder << fontInfo;
     encoder << shouldPopOver;
+    encoder << hideArrows;
     encoder.encodeEnum(menuSize);
 #else
     UNUSED_PARAM(encoder);
@@ -52,6 +53,8 @@ bool PlatformPopupMenuData::decode(IPC::ArgumentDecoder& decoder, PlatformPopupM
         return false;
     if (!decoder.decode(data.shouldPopOver))
         return false;
+    if (!decoder.decode(data.hideArrows))
+        return false;
     if (!decoder.decodeEnum(data.menuSize))
         return false;
 #else
index 400edcd..31a9d1b 100644 (file)
@@ -47,6 +47,7 @@ struct PlatformPopupMenuData {
 #if PLATFORM(COCOA)
     FontInfo fontInfo;
     bool shouldPopOver;
+    bool hideArrows;
     WebCore::PopupMenuStyle::PopupMenuSize menuSize;
 #endif
 };
index cb45d5b..637fff3 100644 (file)
@@ -147,7 +147,7 @@ void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection text
         break;
     }
 
-    WKPopupMenuWithSize(menu, location, roundf(NSWidth(rect)), dummyView.get(), selectedIndex, font, controlSize);
+    WKPopupMenu(menu, location, roundf(NSWidth(rect)), dummyView.get(), selectedIndex, font, controlSize, data.hideArrows);
 
     [m_popup dismissPopUp];
     [dummyView removeFromSuperview];
index 8141ac2..dfcb58a 100644 (file)
@@ -49,6 +49,7 @@ void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData& data
     
     data.fontInfo.fontAttributeDictionary = fontDescriptorAttributes;
     data.shouldPopOver = m_popupClient->shouldPopOver();
+    data.hideArrows = !m_popupClient->menuStyle().hasDefaultAppearance();
     data.menuSize = m_popupClient->menuStyle().menuSize();
 #else
     UNUSED_PARAM(data);