mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1696988 - Support tooltips in nsNativeBasicThemeCocoa. r=mstange
Not sure if you prefer to go this way, your call. Depends on D107574 Differential Revision: https://phabricator.services.mozilla.com/D107575
This commit is contained in:
parent
085d087cf3
commit
0f8e07ccf7
26
widget/cocoa/MacThemeGeometryType.h
Normal file
26
widget/cocoa/MacThemeGeometryType.h
Normal file
@ -0,0 +1,26 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef mozilla_widget_ThemeGeometryType
|
||||
#define mozilla_widget_ThemeGeometryType
|
||||
|
||||
enum MacThemeGeometryType {
|
||||
eThemeGeometryTypeTitlebar = 1,
|
||||
eThemeGeometryTypeToolbar,
|
||||
eThemeGeometryTypeToolbox,
|
||||
eThemeGeometryTypeWindowButtons,
|
||||
eThemeGeometryTypeMenu,
|
||||
eThemeGeometryTypeHighlightedMenuItem,
|
||||
eThemeGeometryTypeVibrancyLight,
|
||||
eThemeGeometryTypeVibrancyDark,
|
||||
eThemeGeometryTypeVibrantTitlebarLight,
|
||||
eThemeGeometryTypeVibrantTitlebarDark,
|
||||
eThemeGeometryTypeTooltip,
|
||||
eThemeGeometryTypeSheet,
|
||||
eThemeGeometryTypeSourceList,
|
||||
eThemeGeometryTypeSourceListSelection,
|
||||
eThemeGeometryTypeActiveSourceListSelection
|
||||
};
|
||||
|
||||
#endif
|
@ -55,6 +55,7 @@
|
||||
#include "nsMenuUtilsX.h"
|
||||
#include "nsMenuBarX.h"
|
||||
#include "NativeKeyBindings.h"
|
||||
#include "MacThemeGeometryType.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxQuartzSurface.h"
|
||||
@ -1627,9 +1628,9 @@ static int32_t FindTitlebarBottom(const nsTArray<nsIWidget::ThemeGeometry>& aThe
|
||||
int32_t aWindowWidth) {
|
||||
int32_t titlebarBottom = 0;
|
||||
for (auto& g : aThemeGeometries) {
|
||||
if ((g.mType == nsNativeThemeCocoa::eThemeGeometryTypeTitlebar ||
|
||||
g.mType == nsNativeThemeCocoa::eThemeGeometryTypeVibrantTitlebarLight ||
|
||||
g.mType == nsNativeThemeCocoa::eThemeGeometryTypeVibrantTitlebarDark) &&
|
||||
if ((g.mType == eThemeGeometryTypeTitlebar ||
|
||||
g.mType == eThemeGeometryTypeVibrantTitlebarLight ||
|
||||
g.mType == eThemeGeometryTypeVibrantTitlebarDark) &&
|
||||
g.mRect.X() <= 0 && g.mRect.XMost() >= aWindowWidth && g.mRect.Y() <= 0) {
|
||||
titlebarBottom = std::max(titlebarBottom, g.mRect.YMost());
|
||||
}
|
||||
@ -1642,7 +1643,7 @@ static int32_t FindUnifiedToolbarBottom(const nsTArray<nsIWidget::ThemeGeometry>
|
||||
int32_t unifiedToolbarBottom = aTitlebarBottom;
|
||||
for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) {
|
||||
const nsIWidget::ThemeGeometry& g = aThemeGeometries[i];
|
||||
if ((g.mType == nsNativeThemeCocoa::eThemeGeometryTypeToolbar) && g.mRect.X() <= 0 &&
|
||||
if ((g.mType == eThemeGeometryTypeToolbar) && g.mRect.X() <= 0 &&
|
||||
g.mRect.XMost() >= aWindowWidth && g.mRect.Y() <= aTitlebarBottom) {
|
||||
unifiedToolbarBottom = std::max(unifiedToolbarBottom, g.mRect.YMost());
|
||||
}
|
||||
@ -1674,8 +1675,7 @@ void nsChildView::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeo
|
||||
int32_t titlebarBottom = FindTitlebarBottom(aThemeGeometries, windowWidth);
|
||||
int32_t unifiedToolbarBottom =
|
||||
FindUnifiedToolbarBottom(aThemeGeometries, windowWidth, titlebarBottom);
|
||||
int32_t toolboxBottom =
|
||||
FindFirstRectOfType(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeToolbox).YMost();
|
||||
int32_t toolboxBottom = FindFirstRectOfType(aThemeGeometries, eThemeGeometryTypeToolbox).YMost();
|
||||
|
||||
ToolbarWindow* win = (ToolbarWindow*)[mView window];
|
||||
int32_t titlebarHeight = CocoaPointsToDevPixels([win titlebarHeight]);
|
||||
@ -1689,32 +1689,32 @@ void nsChildView::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeo
|
||||
|
||||
// Update titlebar control offsets.
|
||||
LayoutDeviceIntRect windowButtonRect =
|
||||
FindFirstRectOfType(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeWindowButtons);
|
||||
FindFirstRectOfType(aThemeGeometries, eThemeGeometryTypeWindowButtons);
|
||||
[win placeWindowButtons:[mView convertRect:DevPixelsToCocoaPoints(windowButtonRect) toView:nil]];
|
||||
}
|
||||
|
||||
static Maybe<VibrancyType> ThemeGeometryTypeToVibrancyType(
|
||||
nsITheme::ThemeGeometryType aThemeGeometryType) {
|
||||
switch (aThemeGeometryType) {
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeVibrancyLight:
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeVibrantTitlebarLight:
|
||||
case eThemeGeometryTypeVibrancyLight:
|
||||
case eThemeGeometryTypeVibrantTitlebarLight:
|
||||
return Some(VibrancyType::LIGHT);
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeVibrancyDark:
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeVibrantTitlebarDark:
|
||||
case eThemeGeometryTypeVibrancyDark:
|
||||
case eThemeGeometryTypeVibrantTitlebarDark:
|
||||
return Some(VibrancyType::DARK);
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeSheet:
|
||||
case eThemeGeometryTypeSheet:
|
||||
return Some(VibrancyType::SHEET);
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeTooltip:
|
||||
case eThemeGeometryTypeTooltip:
|
||||
return Some(VibrancyType::TOOLTIP);
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeMenu:
|
||||
case eThemeGeometryTypeMenu:
|
||||
return Some(VibrancyType::MENU);
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeHighlightedMenuItem:
|
||||
case eThemeGeometryTypeHighlightedMenuItem:
|
||||
return Some(VibrancyType::HIGHLIGHTED_MENUITEM);
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeSourceList:
|
||||
case eThemeGeometryTypeSourceList:
|
||||
return Some(VibrancyType::SOURCE_LIST);
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeSourceListSelection:
|
||||
case eThemeGeometryTypeSourceListSelection:
|
||||
return Some(VibrancyType::SOURCE_LIST_SELECTION);
|
||||
case nsNativeThemeCocoa::eThemeGeometryTypeActiveSourceListSelection:
|
||||
case eThemeGeometryTypeActiveSourceListSelection:
|
||||
return Some(VibrancyType::ACTIVE_SOURCE_LIST_SELECTION);
|
||||
default:
|
||||
return Nothing();
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "mozilla/gfx/Helpers.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/ServoStyleConsts.h"
|
||||
#include "MacThemeGeometryType.h"
|
||||
|
||||
already_AddRefed<nsITheme> do_GetBasicNativeThemeDoNotUseDirectly() {
|
||||
static mozilla::StaticRefPtr<nsITheme> gInstance;
|
||||
@ -33,6 +35,29 @@ nsNativeBasicThemeCocoa::GetMinimumWidgetSize(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool nsNativeBasicThemeCocoa::ThemeSupportsWidget(nsPresContext* aPc,
|
||||
nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance) {
|
||||
switch (aAppearance) {
|
||||
case StyleAppearance::Tooltip:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return nsNativeBasicTheme::ThemeSupportsWidget(aPc, aFrame, aAppearance);
|
||||
}
|
||||
|
||||
nsITheme::ThemeGeometryType nsNativeBasicThemeCocoa::ThemeGeometryTypeForWidget(
|
||||
nsIFrame* aFrame, StyleAppearance aAppearance) {
|
||||
switch (aAppearance) {
|
||||
case StyleAppearance::Tooltip:
|
||||
return eThemeGeometryTypeTooltip;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return nsNativeBasicTheme::ThemeGeometryTypeForWidget(aFrame, aAppearance);
|
||||
}
|
||||
|
||||
auto nsNativeBasicThemeCocoa::GetScrollbarSizes(nsPresContext* aPresContext,
|
||||
StyleScrollbarWidth aWidth,
|
||||
Overlay aOverlay)
|
||||
|
@ -85,6 +85,10 @@ class nsNativeBasicThemeCocoa : public nsNativeBasicTheme {
|
||||
return false;
|
||||
}
|
||||
|
||||
ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame*,
|
||||
StyleAppearance) override;
|
||||
bool ThemeSupportsWidget(nsPresContext*, nsIFrame*, StyleAppearance) override;
|
||||
|
||||
protected:
|
||||
virtual ~nsNativeBasicThemeCocoa() = default;
|
||||
};
|
||||
|
@ -31,24 +31,6 @@ class DrawTarget;
|
||||
|
||||
class nsNativeThemeCocoa : private nsNativeTheme, public nsITheme {
|
||||
public:
|
||||
enum {
|
||||
eThemeGeometryTypeTitlebar = eThemeGeometryTypeUnknown + 1,
|
||||
eThemeGeometryTypeToolbar,
|
||||
eThemeGeometryTypeToolbox,
|
||||
eThemeGeometryTypeWindowButtons,
|
||||
eThemeGeometryTypeMenu,
|
||||
eThemeGeometryTypeHighlightedMenuItem,
|
||||
eThemeGeometryTypeVibrancyLight,
|
||||
eThemeGeometryTypeVibrancyDark,
|
||||
eThemeGeometryTypeVibrantTitlebarLight,
|
||||
eThemeGeometryTypeVibrantTitlebarDark,
|
||||
eThemeGeometryTypeTooltip,
|
||||
eThemeGeometryTypeSheet,
|
||||
eThemeGeometryTypeSourceList,
|
||||
eThemeGeometryTypeSourceListSelection,
|
||||
eThemeGeometryTypeActiveSourceListSelection
|
||||
};
|
||||
|
||||
enum class MenuIcon : uint8_t {
|
||||
eCheckmark,
|
||||
eMenuArrow,
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/StaticPrefs_widget.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
#include "MacThemeGeometryType.h"
|
||||
#include "VibrancyManager.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
|
@ -177,8 +177,7 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme {
|
||||
nsIFrame*, StyleAppearance) override;*/
|
||||
ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame*,
|
||||
StyleAppearance) override;
|
||||
bool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame*,
|
||||
StyleAppearance) override;
|
||||
bool ThemeSupportsWidget(nsPresContext*, nsIFrame*, StyleAppearance) override;
|
||||
bool WidgetIsContainer(StyleAppearance) override;
|
||||
bool ThemeDrawsFocusForWidget(StyleAppearance) override;
|
||||
bool ThemeNeedsComboboxDropmarker() override;
|
||||
|
Loading…
Reference in New Issue
Block a user