Bug 1173617. Don't cache titlebar caption sizes unless the widget has a titlebar. r=jimm

This commit is contained in:
Mason Chang 2015-06-15 08:53:20 -07:00
parent db4b1d63c9
commit 98faa4494b
2 changed files with 23 additions and 5 deletions

View File

@ -30,7 +30,8 @@ nsUXThemeData::sFlatMenus = false;
bool nsUXThemeData::sTitlebarInfoPopulatedAero = false;
bool nsUXThemeData::sTitlebarInfoPopulatedThemed = false;
SIZE nsUXThemeData::sCommandButtons[4];
const int NUM_COMMAND_BUTTONS = 4;
SIZE nsUXThemeData::sCommandButtons[NUM_COMMAND_BUTTONS];
void
nsUXThemeData::Teardown() {
@ -221,6 +222,15 @@ nsUXThemeData::UpdateTitlebarInfo(HWND aWnd)
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(sCommandButtons[i].cx > 0);
MOZ_ASSERT(sCommandButtons[i].cy > 0);
}
#endif
sTitlebarInfoPopulatedThemed = true;
}

View File

@ -458,6 +458,16 @@ int32_t nsWindow::GetHeight(int32_t aProposedHeight)
return aProposedHeight;
}
static bool
ShouldCacheTitleBarInfo(nsWindowType aWindowType, nsBorderStyle aBorderStyle)
{
return (aWindowType == eWindowType_toplevel) &&
(aBorderStyle == eBorderStyle_default ||
aBorderStyle == eBorderStyle_all) &&
(!nsUXThemeData::sTitlebarInfoPopulatedThemed ||
!nsUXThemeData::sTitlebarInfoPopulatedAero);
}
// Create the proper widget
nsresult
nsWindow::Create(nsIWidget *aParent,
@ -645,10 +655,8 @@ nsWindow::Create(nsIWidget *aParent,
}
// Query for command button metric data for rendering the titlebar. We
// only do this once on the first window.
if (mWindowType == eWindowType_toplevel &&
(!nsUXThemeData::sTitlebarInfoPopulatedThemed ||
!nsUXThemeData::sTitlebarInfoPopulatedAero)) {
// only do this once on the first window that has an actual titlebar
if (ShouldCacheTitleBarInfo(mWindowType, mBorderStyle)) {
nsUXThemeData::UpdateTitlebarInfo(mWnd);
}