Backed out changeset 71444e81ac24 (bug 1369508)

This commit is contained in:
Carsten "Tomcat" Book 2017-06-21 14:59:28 +02:00
Родитель 7177a36cde
Коммит 413311adfc
4 изменённых файлов: 36 добавлений и 89 удалений

Просмотреть файл

@ -2251,22 +2251,22 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF
// The only way to get accurate titlebar button info is to query a
// window w/buttons when it's visible. nsWindow takes care of this and
// stores that info in nsUXThemeData.
aResult->width = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_RESTORE).cx;
aResult->height = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_RESTORE).cy;
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cy;
AddPaddingRect(aResult, CAPTIONBUTTON_RESTORE);
*aIsOverridable = false;
return rv;
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
aResult->width = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_MINIMIZE).cx;
aResult->height = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_MINIMIZE).cy;
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cy;
AddPaddingRect(aResult, CAPTIONBUTTON_MINIMIZE);
*aIsOverridable = false;
return rv;
case NS_THEME_WINDOW_BUTTON_CLOSE:
aResult->width = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_CLOSE).cx;
aResult->height = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_CLOSE).cy;
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cy;
AddPaddingRect(aResult, CAPTIONBUTTON_CLOSE);
*aIsOverridable = false;
return rv;
@ -2291,8 +2291,8 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF
case NS_THEME_WINDOW_BUTTON_BOX:
case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
if (nsUXThemeData::CheckForCompositor()) {
aResult->width = nsUXThemeData::GetCommandButtonBoxMetrics().cx;
aResult->height = nsUXThemeData::GetCommandButtonBoxMetrics().cy
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy
- GetSystemMetrics(SM_CYFRAME)
- GetSystemMetrics(SM_CXPADDEDBORDER);
if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED) {

Просмотреть файл

@ -25,17 +25,13 @@ nsUXThemeData::sThemes[eUXNumClasses];
HMODULE
nsUXThemeData::sThemeDLL = nullptr;
const int NUM_COMMAND_BUTTONS = 3;
SIZE nsUXThemeData::sCommandButtonMetrics[NUM_COMMAND_BUTTONS];
bool nsUXThemeData::sCommandButtonMetricsInitialized = false;
SIZE nsUXThemeData::sCommandButtonBoxMetrics;
bool nsUXThemeData::sCommandButtonBoxMetricsInitialized = false;
bool
nsUXThemeData::sFlatMenus = false;
bool nsUXThemeData::sTitlebarInfoPopulatedAero = false;
bool nsUXThemeData::sTitlebarInfoPopulatedThemed = false;
const int NUM_COMMAND_BUTTONS = 4;
SIZE nsUXThemeData::sCommandButtons[NUM_COMMAND_BUTTONS];
void
nsUXThemeData::Teardown() {
@ -136,47 +132,16 @@ const wchar_t *nsUXThemeData::GetClassName(nsUXThemeClass cls) {
// static
void
nsUXThemeData::EnsureCommandButtonMetrics()
nsUXThemeData::InitTitlebarInfo()
{
if (sCommandButtonMetricsInitialized) {
return;
}
sCommandButtonMetricsInitialized = true;
// This code should never need to be evaluated since we should
// obtain the metrics we need when nsWindow::Create() is called.
// The generic metrics that we set here likley will not match the
// current theme, but they insure the buttons at least show up if
// there is some combination of theme settings that we aren't
// handling in nsWindow::Create().
MOZ_ASSERT_UNREACHABLE("We should avoid expensive GetSystemMetrics calls");
sCommandButtonMetrics[0].cx = GetSystemMetrics(SM_CXSIZE);
sCommandButtonMetrics[0].cy = GetSystemMetrics(SM_CYSIZE);
sCommandButtonMetrics[1].cx = sCommandButtonMetrics[2].cx = sCommandButtonMetrics[0].cx;
sCommandButtonMetrics[1].cy = sCommandButtonMetrics[2].cy = sCommandButtonMetrics[0].cy;
// Trigger a refresh on the next layout.
sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed = false;
}
// static
void
nsUXThemeData::EnsureCommandButtonBoxMetrics()
{
if (sCommandButtonBoxMetricsInitialized) {
return;
}
sCommandButtonBoxMetricsInitialized = true;
EnsureCommandButtonMetrics();
sCommandButtonBoxMetrics.cx = sCommandButtonMetrics[0].cx
+ sCommandButtonMetrics[1].cx
+ sCommandButtonMetrics[2].cx;
sCommandButtonBoxMetrics.cy = sCommandButtonMetrics[0].cy
+ sCommandButtonMetrics[1].cy
+ sCommandButtonMetrics[2].cy;
// Pre-populate with generic metrics. These likley will not match
// the current theme, but they insure the buttons at least show up.
sCommandButtons[0].cx = GetSystemMetrics(SM_CXSIZE);
sCommandButtons[0].cy = GetSystemMetrics(SM_CYSIZE);
sCommandButtons[1].cx = sCommandButtons[2].cx = sCommandButtons[0].cx;
sCommandButtons[1].cy = sCommandButtons[2].cy = sCommandButtons[0].cy;
sCommandButtons[3].cx = sCommandButtons[0].cx * 3;
sCommandButtons[3].cy = sCommandButtons[0].cy;
// Trigger a refresh on the next layout.
sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed = false;
@ -195,12 +160,8 @@ nsUXThemeData::UpdateTitlebarInfo(HWND aWnd)
DWMWA_CAPTION_BUTTON_BOUNDS,
&captionButtons,
sizeof(captionButtons)))) {
sCommandButtonBoxMetrics.cx = captionButtons.right - captionButtons.left - 3;
sCommandButtonBoxMetrics.cy = (captionButtons.bottom - captionButtons.top) - 1;
sCommandButtonBoxMetricsInitialized = true;
MOZ_ASSERT(sCommandButtonBoxMetrics.cx > 0 &&
sCommandButtonBoxMetrics.cy > 0,
"We must not cache bad command button box dimensions");
sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cx = captionButtons.right - captionButtons.left - 3;
sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy = (captionButtons.bottom - captionButtons.top) - 1;
sTitlebarInfoPopulatedAero = true;
}
}
@ -257,22 +218,21 @@ nsUXThemeData::UpdateTitlebarInfo(HWND aWnd)
return;
}
// minimize
sCommandButtonMetrics[0].cx = info.rgrect[2].right - info.rgrect[2].left;
sCommandButtonMetrics[0].cy = info.rgrect[2].bottom - info.rgrect[2].top;
sCommandButtons[0].cx = info.rgrect[2].right - info.rgrect[2].left;
sCommandButtons[0].cy = info.rgrect[2].bottom - info.rgrect[2].top;
// maximize/restore
sCommandButtonMetrics[1].cx = info.rgrect[3].right - info.rgrect[3].left;
sCommandButtonMetrics[1].cy = info.rgrect[3].bottom - info.rgrect[3].top;
sCommandButtons[1].cx = info.rgrect[3].right - info.rgrect[3].left;
sCommandButtons[1].cy = info.rgrect[3].bottom - info.rgrect[3].top;
// close
sCommandButtonMetrics[2].cx = info.rgrect[5].right - info.rgrect[5].left;
sCommandButtonMetrics[2].cy = info.rgrect[5].bottom - info.rgrect[5].top;
sCommandButtonMetricsInitialized = true;
sCommandButtons[2].cx = info.rgrect[5].right - info.rgrect[5].left;
sCommandButtons[2].cy = info.rgrect[5].bottom - info.rgrect[5].top;
#ifdef DEBUG
// Verify that all values for the command buttons are positive values
// otherwise we have cached bad values for the caption buttons
for (int i = 0; i < NUM_COMMAND_BUTTONS; i++) {
MOZ_ASSERT(sCommandButtonMetrics[i].cx > 0);
MOZ_ASSERT(sCommandButtonMetrics[i].cy > 0);
MOZ_ASSERT(sCommandButtons[i].cx > 0);
MOZ_ASSERT(sCommandButtons[i].cy > 0);
}
#endif

Просмотреть файл

@ -81,24 +81,15 @@ enum WindowsThemeColor {
class nsUXThemeData {
static HMODULE sThemeDLL;
static HANDLE sThemes[eUXNumClasses];
// We initialize sCommandButtonBoxMetrics separately as a performance
// optimization to avoid fetching dummy values for sCommandButtonMetrics
// when we don't need those.
static SIZE sCommandButtonMetrics[3];
static bool sCommandButtonMetricsInitialized;
static SIZE sCommandButtonBoxMetrics;
static bool sCommandButtonBoxMetricsInitialized;
static const wchar_t *GetClassName(nsUXThemeClass);
static void EnsureCommandButtonMetrics();
static void EnsureCommandButtonBoxMetrics();
public:
static const wchar_t kThemeLibraryName[];
static bool sFlatMenus;
static bool sTitlebarInfoPopulatedAero;
static bool sTitlebarInfoPopulatedThemed;
static SIZE sCommandButtons[4];
static mozilla::LookAndFeel::WindowsTheme sThemeId;
static bool sIsDefaultWindowsTheme;
static bool sIsHighContrastOn;
@ -110,16 +101,9 @@ public:
static HMODULE GetThemeDLL();
// nsWindow calls this to update desktop settings info
static void InitTitlebarInfo();
static void UpdateTitlebarInfo(HWND aWnd);
static SIZE GetCommandButtonMetrics(int aMetric) {
EnsureCommandButtonMetrics();
return sCommandButtonMetrics[aMetric];
}
static SIZE GetCommandButtonBoxMetrics() {
EnsureCommandButtonBoxMetrics();
return sCommandButtonBoxMetrics;
}
static void UpdateNativeThemeInfo();
static mozilla::LookAndFeel::WindowsTheme GetNativeThemeId();
static bool IsDefaultWindowTheme();

Просмотреть файл

@ -663,6 +663,8 @@ nsWindow::nsWindow()
}
NS_ASSERTION(sIsOleInitialized, "***** OLE is not initialized!\n");
MouseScrollHandler::Initialize();
// Init titlebar button info for custom frames.
nsUXThemeData::InitTitlebarInfo();
// Init theme data
nsUXThemeData::UpdateNativeThemeInfo();
RedirectedKeyDownMessageManager::Forget();
@ -3100,7 +3102,7 @@ void nsWindow::UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion)
// The minimum glass height must be the caption buttons height,
// otherwise the buttons are drawn incorrectly.
largest.y = std::max<uint32_t>(largest.y,
nsUXThemeData::GetCommandButtonBoxMetrics().cy);
nsUXThemeData::sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy);
}
margins.cyTopHeight = largest.y;
}
@ -5146,6 +5148,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
{
// Update non-client margin offsets
UpdateNonClientMargins();
nsUXThemeData::InitTitlebarInfo();
nsUXThemeData::UpdateNativeThemeInfo();
NotifyThemeChanged();