Skip to content
Permalink
Browse files
[Mac] Allow popup menus to override default appearance
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.

Canonical link: https://commits.webkit.org/151157@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169134 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
grorg committed May 20, 2014
1 parent 4572dbb commit e6e95ef40830bcb3cf74fb5ae90f00e7c94e2f73
Showing 13 changed files with 76 additions and 8 deletions.
@@ -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
@@ -43,12 +43,13 @@ class PopupMenuStyle {
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 @@ class PopupMenuStyle {
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 @@ class PopupMenuStyle {
Font m_font;
bool m_visible;
bool m_isDisplayNone;
bool m_hasDefaultAppearance;
Length m_textIndent;
TextDirection m_textDirection;
bool m_hasTextDirectionOverride;
@@ -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

@@ -68,7 +68,7 @@
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*);
@@ -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));
}
@@ -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
@@ -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
@@ -204,7 +204,7 @@
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];
@@ -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
@@ -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
@@ -47,6 +47,7 @@ struct PlatformPopupMenuData {
#if PLATFORM(COCOA)
FontInfo fontInfo;
bool shouldPopOver;
bool hideArrows;
WebCore::PopupMenuStyle::PopupMenuSize menuSize;
#endif
};
@@ -147,7 +147,7 @@
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];
@@ -49,6 +49,7 @@

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);

0 comments on commit e6e95ef

Please sign in to comment.