зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1192053 - Implement NS_THEME_MAC_SOURCE_LIST_SELECTION and NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION. r=mstange.
This commit is contained in:
Родитель
246a2ff0f8
Коммит
3a689f8b9a
|
@ -292,3 +292,5 @@
|
|||
|
||||
#define NS_THEME_GTK_INFO_BAR 247
|
||||
#define NS_THEME_MAC_SOURCE_LIST 248
|
||||
#define NS_THEME_MAC_SOURCE_LIST_SELECTION 249
|
||||
#define NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION 250
|
||||
|
|
|
@ -2430,9 +2430,11 @@ static void
|
|||
RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
||||
nsITheme::ThemeGeometryType aType)
|
||||
{
|
||||
if (aBuilder->IsInRootChromeDocumentOrPopup() && !aBuilder->IsInTransform()) {
|
||||
if (aBuilder->IsInChromeDocumentOrPopup() && !aBuilder->IsInTransform()) {
|
||||
nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(aFrame);
|
||||
nsRect borderBox(aFrame->GetOffsetTo(displayRoot), aFrame->GetSize());
|
||||
nsPoint offset = aBuilder->IsInSubdocument() ? aBuilder->ToReferenceFrame(aFrame)
|
||||
: aFrame->GetOffsetTo(displayRoot);
|
||||
nsRect borderBox = nsRect(offset, aFrame->GetSize());
|
||||
aBuilder->RegisterThemeGeometry(aType,
|
||||
LayoutDeviceIntRect::FromUnknownRect(
|
||||
borderBox.ToNearestPixels(
|
||||
|
@ -2662,7 +2664,7 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
|
|||
if (isThemed) {
|
||||
nsITheme* theme = presContext->GetTheme();
|
||||
if (theme->NeedToClearBackgroundBehindWidget(aFrame, aFrame->StyleDisplay()->mAppearance) &&
|
||||
aBuilder->IsInRootChromeDocumentOrPopup() && !aBuilder->IsInTransform()) {
|
||||
aBuilder->IsInChromeDocumentOrPopup() && !aBuilder->IsInTransform()) {
|
||||
bgItemList.AppendNewToTop(
|
||||
new (aBuilder) nsDisplayClearBackground(aBuilder, aFrame));
|
||||
}
|
||||
|
|
|
@ -556,13 +556,11 @@ public:
|
|||
bool IsInSubdocument() { return mPresShellStates.Length() > 1; }
|
||||
|
||||
/**
|
||||
* Return true if we're currently building a display list for the root
|
||||
* presshell which is the presshell of a chrome document, or if we're
|
||||
* building the display list for a popup and have not entered a subdocument
|
||||
* inside that popup.
|
||||
* Return true if we're currently building a display list for the presshell
|
||||
* of a chrome document, or if we're building the display list for a popup.
|
||||
*/
|
||||
bool IsInRootChromeDocumentOrPopup() {
|
||||
return (mIsInChromePresContext || mIsBuildingForPopup) && !IsInSubdocument();
|
||||
bool IsInChromeDocumentOrPopup() {
|
||||
return mIsInChromePresContext || mIsBuildingForPopup;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -762,6 +762,8 @@ CSS_KEY(-moz-mac-vibrancy-dark, _moz_mac_vibrancy_dark)
|
|||
CSS_KEY(-moz-mac-disclosure-button-closed, _moz_mac_disclosure_button_closed)
|
||||
CSS_KEY(-moz-mac-disclosure-button-open, _moz_mac_disclosure_button_open)
|
||||
CSS_KEY(-moz-mac-source-list, _moz_mac_source_list)
|
||||
CSS_KEY(-moz-mac-source-list-selection, _moz_mac_source_list_selection)
|
||||
CSS_KEY(-moz-mac-active-source-list-selection, _moz_mac_active_source_list_selection)
|
||||
CSS_KEY(alphabetic, alphabetic)
|
||||
CSS_KEY(bevel, bevel)
|
||||
CSS_KEY(butt, butt)
|
||||
|
|
|
@ -864,6 +864,8 @@ const KTableEntry nsCSSProps::kAppearanceKTable[] = {
|
|||
{ eCSSKeyword__moz_mac_disclosure_button_closed, NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED },
|
||||
{ eCSSKeyword__moz_gtk_info_bar, NS_THEME_GTK_INFO_BAR },
|
||||
{ eCSSKeyword__moz_mac_source_list, NS_THEME_MAC_SOURCE_LIST },
|
||||
{ eCSSKeyword__moz_mac_source_list_selection, NS_THEME_MAC_SOURCE_LIST_SELECTION },
|
||||
{ eCSSKeyword__moz_mac_active_source_list_selection, NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,9 @@ enum class VibrancyType {
|
|||
MENU,
|
||||
HIGHLIGHTED_MENUITEM,
|
||||
SHEET,
|
||||
SOURCE_LIST
|
||||
SOURCE_LIST,
|
||||
SOURCE_LIST_SELECTION,
|
||||
ACTIVE_SOURCE_LIST_SELECTION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -147,6 +147,8 @@ AppearanceForVibrancyType(VibrancyType aType)
|
|||
case VibrancyType::HIGHLIGHTED_MENUITEM:
|
||||
case VibrancyType::SHEET:
|
||||
case VibrancyType::SOURCE_LIST:
|
||||
case VibrancyType::SOURCE_LIST_SELECTION:
|
||||
case VibrancyType::ACTIVE_SOURCE_LIST_SELECTION:
|
||||
return [NSAppearanceClass performSelector:@selector(appearanceNamed:)
|
||||
withObject:@"NSAppearanceNameVibrantLight"];
|
||||
case VibrancyType::DARK:
|
||||
|
@ -234,9 +236,12 @@ VibrancyManager::CreateEffectView(VibrancyType aType)
|
|||
: NSVisualEffectMaterialTitlebar];
|
||||
} else if (aType == VibrancyType::SOURCE_LIST && canUseElCapitanMaterials) {
|
||||
[effectView setMaterial:NSVisualEffectMaterialSidebar];
|
||||
} else if (aType == VibrancyType::HIGHLIGHTED_MENUITEM) {
|
||||
} else if (aType == VibrancyType::HIGHLIGHTED_MENUITEM ||
|
||||
aType == VibrancyType::SOURCE_LIST_SELECTION ||
|
||||
aType == VibrancyType::ACTIVE_SOURCE_LIST_SELECTION) {
|
||||
[effectView setMaterial:NSVisualEffectMaterialMenuItem];
|
||||
if ([effectView respondsToSelector:@selector(setEmphasized:)]) {
|
||||
if ([effectView respondsToSelector:@selector(setEmphasized:)] &&
|
||||
aType != VibrancyType::SOURCE_LIST_SELECTION) {
|
||||
[effectView setEmphasized:YES];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2543,10 +2543,15 @@ nsChildView::UpdateVibrancy(const nsTArray<ThemeGeometry>& aThemeGeometries)
|
|||
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeHighlightedMenuItem);
|
||||
LayoutDeviceIntRegion sourceListRegion =
|
||||
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeSourceList);
|
||||
LayoutDeviceIntRegion sourceListSelectionRegion =
|
||||
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeSourceListSelection);
|
||||
LayoutDeviceIntRegion activeSourceListSelectionRegion =
|
||||
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeActiveSourceListSelection);
|
||||
|
||||
MakeRegionsNonOverlapping(sheetRegion, vibrantLightRegion, vibrantDarkRegion,
|
||||
menuRegion, tooltipRegion, highlightedMenuItemRegion,
|
||||
sourceListRegion);
|
||||
sourceListRegion, sourceListSelectionRegion,
|
||||
activeSourceListSelectionRegion);
|
||||
|
||||
auto& vm = EnsureVibrancyManager();
|
||||
vm.UpdateVibrantRegion(VibrancyType::LIGHT, vibrantLightRegion);
|
||||
|
@ -2555,6 +2560,8 @@ nsChildView::UpdateVibrancy(const nsTArray<ThemeGeometry>& aThemeGeometries)
|
|||
vm.UpdateVibrantRegion(VibrancyType::HIGHLIGHTED_MENUITEM, highlightedMenuItemRegion);
|
||||
vm.UpdateVibrantRegion(VibrancyType::SHEET, sheetRegion);
|
||||
vm.UpdateVibrantRegion(VibrancyType::SOURCE_LIST, sourceListRegion);
|
||||
vm.UpdateVibrantRegion(VibrancyType::SOURCE_LIST_SELECTION, sourceListSelectionRegion);
|
||||
vm.UpdateVibrantRegion(VibrancyType::ACTIVE_SOURCE_LIST_SELECTION, activeSourceListSelectionRegion);
|
||||
vm.UpdateVibrantRegion(VibrancyType::DARK, vibrantDarkRegion);
|
||||
}
|
||||
|
||||
|
@ -2584,6 +2591,10 @@ ThemeGeometryTypeToVibrancyType(nsITheme::ThemeGeometryType aThemeGeometryType)
|
|||
return VibrancyType::SHEET;
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeSourceList:
|
||||
return VibrancyType::SOURCE_LIST;
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeSourceListSelection:
|
||||
return VibrancyType::SOURCE_LIST_SELECTION;
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeActiveSourceListSelection:
|
||||
return VibrancyType::ACTIVE_SOURCE_LIST_SELECTION;
|
||||
default:
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
eThemeGeometryTypeTooltip,
|
||||
eThemeGeometryTypeSheet,
|
||||
eThemeGeometryTypeSourceList,
|
||||
eThemeGeometryTypeSourceListSelection,
|
||||
eThemeGeometryTypeActiveSourceListSelection
|
||||
};
|
||||
|
||||
nsNativeThemeCocoa();
|
||||
|
|
|
@ -514,6 +514,15 @@ static BOOL IsActive(nsIFrame* aFrame, BOOL aIsToolbarControl)
|
|||
return FrameIsInActiveWindow(aFrame);
|
||||
}
|
||||
|
||||
static bool IsInSourceList(nsIFrame* aFrame) {
|
||||
for (nsIFrame* frame = aFrame->GetParent(); frame; frame = frame->GetParent()) {
|
||||
if (frame->StyleDisplay()->mAppearance == NS_THEME_MAC_SOURCE_LIST) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsNativeThemeCocoa, nsNativeTheme, nsITheme)
|
||||
|
||||
nsNativeThemeCocoa::nsNativeThemeCocoa()
|
||||
|
@ -2890,6 +2899,31 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_THEME_MAC_SOURCE_LIST_SELECTION:
|
||||
case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION: {
|
||||
// If we're in XUL tree, we need to rely on the source list's clear
|
||||
// background display item. If we cleared the background behind the
|
||||
// selections, the source list would not pick up the right font
|
||||
// smoothing background. So, to simplify a bit, we only support vibrancy
|
||||
// if we're in a source list.
|
||||
if (VibrancyManager::SystemSupportsVibrancy() && IsInSourceList(aFrame)) {
|
||||
ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType);
|
||||
DrawVibrancyBackground(cgContext, macRect, aFrame, type);
|
||||
} else {
|
||||
BOOL isActiveSelection =
|
||||
aWidgetType == NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION;
|
||||
RenderWithCoreUI(macRect, cgContext,
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:isActiveSelection], @"focus",
|
||||
[NSNumber numberWithBool:YES], @"is.flipped",
|
||||
@"kCUIVariantGradientSideBarSelection", @"kCUIVariantKey",
|
||||
(FrameIsInActiveWindow(aFrame) ? @"normal" : @"inactive"), @"state",
|
||||
@"gradient", @"widget",
|
||||
nil]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_THEME_TAB:
|
||||
DrawSegment(cgContext, macRect, eventState, aFrame, tabRenderSettings);
|
||||
|
@ -3615,6 +3649,8 @@ nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* a
|
|||
case NS_THEME_TREEITEM:
|
||||
case NS_THEME_TREELINE:
|
||||
case NS_THEME_MAC_SOURCE_LIST:
|
||||
case NS_THEME_MAC_SOURCE_LIST_SELECTION:
|
||||
case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION:
|
||||
|
||||
case NS_THEME_RANGE:
|
||||
|
||||
|
@ -3756,6 +3792,12 @@ nsNativeThemeCocoa::NeedToClearBackgroundBehindWidget(nsIFrame* aFrame,
|
|||
{
|
||||
switch (aWidgetType) {
|
||||
case NS_THEME_MAC_SOURCE_LIST:
|
||||
// If we're in a XUL tree, we don't want to clear the background behind the
|
||||
// selections below, since that would make our source list to not pick up
|
||||
// the right font smoothing background. But since we don't call this method
|
||||
// in nsTreeBodyFrame::BuildDisplayList, we never get here.
|
||||
case NS_THEME_MAC_SOURCE_LIST_SELECTION:
|
||||
case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION:
|
||||
case NS_THEME_MAC_VIBRANCY_LIGHT:
|
||||
case NS_THEME_MAC_VIBRANCY_DARK:
|
||||
case NS_THEME_TOOLTIP:
|
||||
|
@ -3786,6 +3828,8 @@ nsNativeThemeCocoa::WidgetProvidesFontSmoothingBackgroundColor(nsIFrame* aFrame,
|
|||
{
|
||||
switch (aWidgetType) {
|
||||
case NS_THEME_MAC_SOURCE_LIST:
|
||||
case NS_THEME_MAC_SOURCE_LIST_SELECTION:
|
||||
case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION:
|
||||
case NS_THEME_MAC_VIBRANCY_LIGHT:
|
||||
case NS_THEME_MAC_VIBRANCY_DARK:
|
||||
case NS_THEME_TOOLTIP:
|
||||
|
@ -3794,7 +3838,10 @@ nsNativeThemeCocoa::WidgetProvidesFontSmoothingBackgroundColor(nsIFrame* aFrame,
|
|||
case NS_THEME_CHECKMENUITEM:
|
||||
case NS_THEME_DIALOG:
|
||||
{
|
||||
if (aWidgetType == NS_THEME_DIALOG && !IsWindowSheet(aFrame)) {
|
||||
if ((aWidgetType == NS_THEME_DIALOG && !IsWindowSheet(aFrame)) ||
|
||||
((aWidgetType == NS_THEME_MAC_SOURCE_LIST_SELECTION ||
|
||||
aWidgetType == NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION) &&
|
||||
!IsInSourceList(aFrame))) {
|
||||
return false;
|
||||
}
|
||||
ChildView* childView = ChildViewForFrame(aFrame);
|
||||
|
@ -3844,6 +3891,12 @@ nsNativeThemeCocoa::ThemeGeometryTypeForWidget(nsIFrame* aFrame, uint8_t aWidget
|
|||
return IsWindowSheet(aFrame) ? eThemeGeometryTypeSheet : eThemeGeometryTypeUnknown;
|
||||
case NS_THEME_MAC_SOURCE_LIST:
|
||||
return eThemeGeometryTypeSourceList;
|
||||
case NS_THEME_MAC_SOURCE_LIST_SELECTION:
|
||||
return IsInSourceList(aFrame) ? eThemeGeometryTypeSourceListSelection
|
||||
: eThemeGeometryTypeUnknown;
|
||||
case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION:
|
||||
return IsInSourceList(aFrame) ? eThemeGeometryTypeActiveSourceListSelection
|
||||
: eThemeGeometryTypeUnknown;
|
||||
default:
|
||||
return eThemeGeometryTypeUnknown;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче