mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 888615 - [Australis] Add a drawtitle attribute for XUL root elements. When drawtitle="true" is set, even drawintitlebar windows will have a window title. r=roc, r=smichaud
This commit is contained in:
parent
ba2db93ae9
commit
3b7de5fbc9
@ -311,6 +311,7 @@ GK_ATOM(dragover, "dragover")
|
||||
GK_ATOM(dragSession, "dragSession")
|
||||
GK_ATOM(dragstart, "dragstart")
|
||||
GK_ATOM(drawintitlebar, "drawintitlebar")
|
||||
GK_ATOM(drawtitle, "drawtitle")
|
||||
GK_ATOM(drop, "drop")
|
||||
GK_ATOM(dropAfter, "dropAfter")
|
||||
GK_ATOM(dropBefore, "dropBefore")
|
||||
|
@ -1003,6 +1003,10 @@ nsXULElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
SetDrawsInTitlebar(
|
||||
aValue->Equals(NS_LITERAL_STRING("true"), eCaseMatters));
|
||||
}
|
||||
else if (aName == nsGkAtoms::drawtitle) {
|
||||
SetDrawsTitle(
|
||||
aValue->Equals(NS_LITERAL_STRING("true"), eCaseMatters));
|
||||
}
|
||||
else if (aName == nsGkAtoms::localedir) {
|
||||
// if the localedir changed on the root element, reset the document direction
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(document);
|
||||
@ -1058,6 +1062,9 @@ nsXULElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
else if (aName == nsGkAtoms::drawintitlebar) {
|
||||
SetDrawsInTitlebar(false);
|
||||
}
|
||||
else if (aName == nsGkAtoms::drawtitle) {
|
||||
SetDrawsTitle(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1829,6 +1836,17 @@ nsXULElement::SetDrawsInTitlebar(bool aState)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::SetDrawsTitle(bool aState)
|
||||
{
|
||||
nsIWidget* mainWidget = GetWindowWidget();
|
||||
if (mainWidget) {
|
||||
// We can do this synchronously because SetDrawsTitle doesn't have any
|
||||
// synchronous effects apart from a harmless invalidation.
|
||||
mainWidget->SetDrawsTitle(aState);
|
||||
}
|
||||
}
|
||||
|
||||
class MarginSetter : public nsRunnable
|
||||
{
|
||||
public:
|
||||
|
@ -680,6 +680,7 @@ protected:
|
||||
void SetTitlebarColor(nscolor aColor, bool aActive);
|
||||
|
||||
void SetDrawsInTitlebar(bool aState);
|
||||
void SetDrawsTitle(bool aState);
|
||||
|
||||
void RemoveBroadcaster(const nsAString & broadcasterId);
|
||||
|
||||
|
@ -78,6 +78,7 @@ typedef struct _nsCocoaWindowList {
|
||||
NSTrackingArea* mTrackingArea;
|
||||
|
||||
BOOL mBeingShown;
|
||||
BOOL mDrawTitle;
|
||||
}
|
||||
|
||||
- (void)importState:(NSDictionary*)aState;
|
||||
@ -104,6 +105,9 @@ typedef struct _nsCocoaWindowList {
|
||||
|
||||
- (NSArray*)titlebarControls;
|
||||
|
||||
- (void)setWantsTitleDrawn:(BOOL)aDrawTitle;
|
||||
- (BOOL)wantsTitleDrawn;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSWindow (Undocumented)
|
||||
@ -294,6 +298,7 @@ public:
|
||||
virtual void SetShowsToolbarButton(bool aShow);
|
||||
virtual void SetShowsFullScreenButton(bool aShow);
|
||||
virtual void SetWindowAnimationType(WindowAnimationType aType);
|
||||
virtual void SetDrawsTitle(bool aDrawTitle);
|
||||
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins);
|
||||
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive);
|
||||
virtual void SetDrawsInTitlebar(bool aState);
|
||||
|
@ -1995,6 +1995,16 @@ void nsCocoaWindow::SetWindowAnimationType(nsIWidget::WindowAnimationType aType)
|
||||
mAnimationType = aType;
|
||||
}
|
||||
|
||||
void
|
||||
nsCocoaWindow::SetDrawsTitle(bool aDrawTitle)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
[mWindow setWantsTitleDrawn:aDrawTitle];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::SetNonClientMargins(nsIntMargin &margins)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
@ -2630,6 +2640,7 @@ static NSMutableSet *gSwizzledFrameViewClasses = nil;
|
||||
mDPI = GetDPI(self);
|
||||
mTrackingArea = nil;
|
||||
mBeingShown = NO;
|
||||
mDrawTitle = NO;
|
||||
[self updateTrackingArea];
|
||||
|
||||
return self;
|
||||
@ -2703,6 +2714,16 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
|
||||
return mDrawsIntoWindowFrame;
|
||||
}
|
||||
|
||||
- (void)setWantsTitleDrawn:(BOOL)aDrawTitle
|
||||
{
|
||||
mDrawTitle = aDrawTitle;
|
||||
}
|
||||
|
||||
- (BOOL)wantsTitleDrawn
|
||||
{
|
||||
return mDrawTitle;
|
||||
}
|
||||
|
||||
// Pass nil here to get the default appearance.
|
||||
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive
|
||||
{
|
||||
@ -3090,8 +3111,9 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
|
||||
|
||||
- (NSRect)titlebarRect
|
||||
{
|
||||
return NSMakeRect(0, [[self contentView] bounds].size.height,
|
||||
[self frame].size.width, [self titlebarHeight]);
|
||||
CGFloat titlebarHeight = [self titlebarHeight];
|
||||
return NSMakeRect(0, [self frame].size.height - titlebarHeight,
|
||||
[self frame].size.width, titlebarHeight);
|
||||
}
|
||||
|
||||
// Returns the unified height of titlebar + toolbar.
|
||||
@ -3155,6 +3177,12 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setWantsTitleDrawn:(BOOL)aDrawTitle
|
||||
{
|
||||
[super setWantsTitleDrawn:aDrawTitle];
|
||||
[self setTitlebarNeedsDisplayInRect:[self titlebarRect]];
|
||||
}
|
||||
|
||||
- (void)placeWindowButtons:(NSRect)aRect
|
||||
{
|
||||
if (!NSEqualRects(mWindowButtonsRect, aRect)) {
|
||||
|
@ -1152,6 +1152,13 @@ class nsIWidget : public nsISupports {
|
||||
*/
|
||||
virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
|
||||
|
||||
/**
|
||||
* Specifies whether the window title should be drawn even if the window
|
||||
* contents extend into the titlebar. Ignored on windows that don't draw
|
||||
* in the titlebar. Only implemented on OS X.
|
||||
*/
|
||||
virtual void SetDrawsTitle(bool aDrawTitle) {}
|
||||
|
||||
/**
|
||||
* Hide window chrome (borders, buttons) for this widget.
|
||||
*
|
||||
|
@ -1410,6 +1410,10 @@ void nsXULWindow::SyncAttributesToWidget()
|
||||
}
|
||||
mWindow->SetIcon(attr);
|
||||
|
||||
// "drawtitle" attribute
|
||||
windowElement->GetAttribute(NS_LITERAL_STRING("drawtitle"), attr);
|
||||
mWindow->SetDrawsTitle(attr.LowerCaseEqualsLiteral("true"));
|
||||
|
||||
// "toggletoolbar" attribute
|
||||
windowElement->GetAttribute(NS_LITERAL_STRING("toggletoolbar"), attr);
|
||||
mWindow->SetShowsToolbarButton(attr.LowerCaseEqualsLiteral("true"));
|
||||
|
Loading…
Reference in New Issue
Block a user