Bug 1428676 pt 5. Honor the webkit pref when handling 'menulist-button' on Mac. r=emilio

This commit is contained in:
Jonathan Watt 2018-07-16 14:46:19 +01:00
parent 071dc75f10
commit 665c7fd264
2 changed files with 33 additions and 1 deletions

View File

@ -35,6 +35,7 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLMeterElement.h"
#include "mozilla/layers/StackingContextHelper.h"
#include "mozilla/StaticPrefs.h"
#include "nsLookAndFeel.h"
#include "VibrancyManager.h"
@ -3069,6 +3070,11 @@ nsNativeThemeCocoa::ComputeWidgetInfo(nsIFrame* aFrame,
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
if (aWidgetType == StyleAppearance::MenulistButton &&
StaticPrefs::layout_css_webkit_appearance_enabled()) {
aWidgetType = StyleAppearance::Menulist;
}
// setup to draw into the correct port
int32_t p2a = aFrame->PresContext()->AppUnitsPerDevPixel();
@ -3866,6 +3872,8 @@ nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBui
case StyleAppearance::Toolbar:
case StyleAppearance::MozWindowTitlebar:
case StyleAppearance::Statusbar:
// NOTE: if you change Menulist and MenulistButton to behave differently,
// be sure to handle StaticPrefs::layout_css_webkit_appearance_enabled.
case StyleAppearance::Menulist:
case StyleAppearance::MenulistTextfield:
case StyleAppearance::MenulistButton:
@ -4033,6 +4041,8 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext,
break;
}
// NOTE: if you change Menulist and MenulistButton to behave differently,
// be sure to handle StaticPrefs::layout_css_webkit_appearance_enabled.
case StyleAppearance::Menulist:
case StyleAppearance::MenulistButton:
case StyleAppearance::MozMenulistButton:
@ -4161,6 +4171,8 @@ nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFram
case StyleAppearance::TextfieldMultiline:
case StyleAppearance::Searchfield:
case StyleAppearance::Listbox:
// NOTE: if you change Menulist and MenulistButton to behave differently,
// be sure to handle StaticPrefs::layout_css_webkit_appearance_enabled.
case StyleAppearance::Menulist:
case StyleAppearance::MenulistButton:
case StyleAppearance::MozMenulistButton:
@ -4292,6 +4304,8 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext,
break;
}
// NOTE: if you change Menulist and MenulistButton to behave differently,
// be sure to handle StaticPrefs::layout_css_webkit_appearance_enabled.
case StyleAppearance::Menulist:
case StyleAppearance::MenulistButton:
case StyleAppearance::MozMenulistButton:
@ -4620,6 +4634,11 @@ bool
nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame,
WidgetType aWidgetType)
{
if (aWidgetType == StyleAppearance::MenulistButton &&
StaticPrefs::layout_css_webkit_appearance_enabled()) {
aWidgetType = StyleAppearance::Menulist;
}
// if this is a dropdown button in a combobox the answer is always no
if (aWidgetType == StyleAppearance::MenulistButton ||
aWidgetType == StyleAppearance::MozMenulistButton) {
@ -4759,6 +4778,11 @@ nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* a
bool
nsNativeThemeCocoa::WidgetIsContainer(WidgetType aWidgetType)
{
if (aWidgetType == StyleAppearance::MenulistButton &&
StaticPrefs::layout_css_webkit_appearance_enabled()) {
aWidgetType = StyleAppearance::Menulist;
}
// flesh this out at some point
switch (aWidgetType) {
case StyleAppearance::MenulistButton:
@ -4781,6 +4805,11 @@ nsNativeThemeCocoa::WidgetIsContainer(WidgetType aWidgetType)
bool
nsNativeThemeCocoa::ThemeDrawsFocusForWidget(WidgetType aWidgetType)
{
if (aWidgetType == StyleAppearance::MenulistButton &&
StaticPrefs::layout_css_webkit_appearance_enabled()) {
aWidgetType = StyleAppearance::Menulist;
}
if (aWidgetType == StyleAppearance::Menulist ||
aWidgetType == StyleAppearance::MenulistTextfield ||
aWidgetType == StyleAppearance::Button ||

View File

@ -27,6 +27,7 @@
#include "mozilla/dom/HTMLBodyElement.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLProgressElement.h"
#include "mozilla/StaticPrefs.h"
#include "nsIDocumentInlines.h"
#include <algorithm>
@ -349,7 +350,9 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
aWidgetType == StyleAppearance::Textfield ||
aWidgetType == StyleAppearance::TextfieldMultiline ||
aWidgetType == StyleAppearance::Listbox ||
aWidgetType == StyleAppearance::Menulist) &&
aWidgetType == StyleAppearance::Menulist ||
(aWidgetType == StyleAppearance::MenulistButton &&
StaticPrefs::layout_css_webkit_appearance_enabled())) &&
aFrame->GetContent()->IsHTMLElement() &&
aPresContext->HasAuthorSpecifiedRules(aFrame,
NS_AUTHOR_SPECIFIED_BORDER |