mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 515880 - Add drawintitlebar attribute to XUL root elements and sync it to the window widget. r=neil, sr=roc
This commit is contained in:
parent
a6b3fbf7e9
commit
1b0f10ebf2
@ -326,6 +326,7 @@ GK_ATOM(dragleave, "dragleave")
|
||||
GK_ATOM(dragover, "dragover")
|
||||
GK_ATOM(dragSession, "dragSession")
|
||||
GK_ATOM(dragstart, "dragstart")
|
||||
GK_ATOM(drawintitlebar, "drawintitlebar")
|
||||
GK_ATOM(drop, "drop")
|
||||
GK_ATOM(dropAfter, "dropAfter")
|
||||
GK_ATOM(dropBefore, "dropBefore")
|
||||
|
@ -1097,44 +1097,41 @@ nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||
if (aName == nsGkAtoms::hidechrome &&
|
||||
mNodeInfo->Equals(nsGkAtoms::window) &&
|
||||
aValue) {
|
||||
HideWindowChrome(aValue && NS_LITERAL_STRING("true").Equals(*aValue));
|
||||
HideWindowChrome(aValue->EqualsLiteral("true"));
|
||||
}
|
||||
|
||||
|
||||
// title, (in)activetitlebarcolor and drawintitlebar are settable on
|
||||
// any root node (windows, dialogs, etc)
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (aName == nsGkAtoms::title &&
|
||||
document && document->GetRootContent() == this) {
|
||||
document->NotifyPossibleTitleChange(PR_FALSE);
|
||||
}
|
||||
|
||||
// (in)activetitlebarcolor is settable on any root node (windows, dialogs, etc)
|
||||
if ((aName == nsGkAtoms::activetitlebarcolor ||
|
||||
aName == nsGkAtoms::inactivetitlebarcolor) &&
|
||||
document && document->GetRootContent() == this) {
|
||||
|
||||
nscolor color = NS_RGBA(0, 0, 0, 0);
|
||||
nsAttrValue attrValue;
|
||||
attrValue.ParseColor(*aValue, document);
|
||||
attrValue.GetColorValue(color);
|
||||
|
||||
SetTitlebarColor(color, aName == nsGkAtoms::activetitlebarcolor);
|
||||
}
|
||||
|
||||
// if the localedir changed on the root element, reset the document direction
|
||||
if (aName == nsGkAtoms::localedir &&
|
||||
document && document->GetRootContent() == this) {
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(document);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentDirection();
|
||||
if (document && document->GetRootContent() == this) {
|
||||
if (aName == nsGkAtoms::title) {
|
||||
document->NotifyPossibleTitleChange(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
// if the lwtheme changed, make sure to reset the document lwtheme cache
|
||||
if ((aName == nsGkAtoms::lwtheme ||
|
||||
aName == nsGkAtoms::lwthemetextcolor) &&
|
||||
document && document->GetRootContent() == this) {
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(document);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentLWTheme();
|
||||
else if ((aName == nsGkAtoms::activetitlebarcolor ||
|
||||
aName == nsGkAtoms::inactivetitlebarcolor)) {
|
||||
nscolor color = NS_RGBA(0, 0, 0, 0);
|
||||
nsAttrValue attrValue;
|
||||
attrValue.ParseColor(*aValue, document);
|
||||
attrValue.GetColorValue(color);
|
||||
SetTitlebarColor(color, aName == nsGkAtoms::activetitlebarcolor);
|
||||
}
|
||||
else if (aName == nsGkAtoms::drawintitlebar) {
|
||||
SetDrawsInTitlebar(aValue && aValue->EqualsLiteral("true"));
|
||||
}
|
||||
else if (aName == nsGkAtoms::localedir) {
|
||||
// if the localedir changed on the root element, reset the document direction
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(document);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentDirection();
|
||||
}
|
||||
}
|
||||
else if (aName == nsGkAtoms::lwtheme ||
|
||||
aName == nsGkAtoms::lwthemetextcolor) {
|
||||
// if the lwtheme changed, make sure to reset the document lwtheme cache
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(document);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentLWTheme();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1377,29 +1374,29 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
|
||||
HideWindowChrome(PR_FALSE);
|
||||
}
|
||||
|
||||
if ((aName == nsGkAtoms::activetitlebarcolor ||
|
||||
aName == nsGkAtoms::inactivetitlebarcolor) &&
|
||||
doc && doc->GetRootContent() == this) {
|
||||
// Use 0, 0, 0, 0 as the "none" color.
|
||||
SetTitlebarColor(NS_RGBA(0, 0, 0, 0), aName == nsGkAtoms::activetitlebarcolor);
|
||||
}
|
||||
|
||||
// if the localedir changed on the root element, reset the document direction
|
||||
if (aName == nsGkAtoms::localedir &&
|
||||
doc && doc->GetRootContent() == this) {
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentDirection();
|
||||
if (doc && doc->GetRootContent() == this) {
|
||||
if ((aName == nsGkAtoms::activetitlebarcolor ||
|
||||
aName == nsGkAtoms::inactivetitlebarcolor)) {
|
||||
// Use 0, 0, 0, 0 as the "none" color.
|
||||
SetTitlebarColor(NS_RGBA(0, 0, 0, 0), aName == nsGkAtoms::activetitlebarcolor);
|
||||
}
|
||||
}
|
||||
|
||||
// if the lwtheme changed, make sure to restyle appropriately
|
||||
if ((aName == nsGkAtoms::lwtheme ||
|
||||
aName == nsGkAtoms::lwthemetextcolor) &&
|
||||
doc && doc->GetRootContent() == this) {
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentLWTheme();
|
||||
else if (aName == nsGkAtoms::localedir) {
|
||||
// if the localedir changed on the root element, reset the document direction
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentDirection();
|
||||
}
|
||||
}
|
||||
else if ((aName == nsGkAtoms::lwtheme ||
|
||||
aName == nsGkAtoms::lwthemetextcolor)) {
|
||||
// if the lwtheme changed, make sure to restyle appropriately
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentLWTheme();
|
||||
}
|
||||
}
|
||||
else if (aName == nsGkAtoms::drawintitlebar) {
|
||||
SetDrawsInTitlebar(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2398,13 +2395,10 @@ nsXULElement::HideWindowChrome(PRBool aShouldHide)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::SetTitlebarColor(nscolor aColor, PRBool aActive)
|
||||
nsIWidget*
|
||||
nsXULElement::GetWindowWidget()
|
||||
{
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
if (!doc || doc->GetRootContent() != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only top level chrome documents can set the titlebar color
|
||||
if (doc->IsRootDisplayDocument()) {
|
||||
@ -2413,11 +2407,28 @@ nsXULElement::SetTitlebarColor(nscolor aColor, PRBool aActive)
|
||||
if (baseWindow) {
|
||||
nsCOMPtr<nsIWidget> mainWidget;
|
||||
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
|
||||
if (mainWidget) {
|
||||
mainWidget->SetWindowTitlebarColor(aColor, aActive);
|
||||
}
|
||||
return mainWidget;
|
||||
}
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::SetTitlebarColor(nscolor aColor, PRBool aActive)
|
||||
{
|
||||
nsIWidget* mainWidget = GetWindowWidget();
|
||||
if (mainWidget) {
|
||||
mainWidget->SetWindowTitlebarColor(aColor, aActive);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::SetDrawsInTitlebar(PRBool aState)
|
||||
{
|
||||
nsIWidget* mainWidget = GetWindowWidget();
|
||||
if (mainWidget) {
|
||||
mainWidget->SetDrawsInTitlebar(aState);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -682,11 +682,14 @@ protected:
|
||||
PRBool aCompileEventHandlers);
|
||||
void MaybeAddPopupListener(nsIAtom* aLocalName);
|
||||
|
||||
nsIWidget* GetWindowWidget();
|
||||
|
||||
nsresult HideWindowChrome(PRBool aShouldHide);
|
||||
|
||||
void SetTitlebarColor(nscolor aColor, PRBool aActive);
|
||||
|
||||
void SetDrawsInTitlebar(PRBool aState);
|
||||
|
||||
const nsAttrName* InternalGetExistingAttrNameFromQName(const nsAString& aStr) const;
|
||||
|
||||
void RemoveBroadcaster(const nsAString & broadcasterId);
|
||||
|
@ -823,7 +823,20 @@ class nsIWidget : public nsISupports {
|
||||
* windows.
|
||||
*/
|
||||
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, PRBool aActive) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* If set to true, the window will draw its contents into the titlebar
|
||||
* instead of below it.
|
||||
*
|
||||
* Ignored on any platform that does not support it. Ignored by widgets that
|
||||
* do not represent windows.
|
||||
* May result in a resize event, so should only be called from places where
|
||||
* reflow and painting is allowed.
|
||||
*
|
||||
* @param aState Whether drawing into the titlebar should be activated.
|
||||
*/
|
||||
virtual void SetDrawsInTitlebar(PRBool aState) = 0;
|
||||
|
||||
/*
|
||||
* Determine whether the widget shows a resize widget. If it does,
|
||||
* aResizerRect returns the resizer's rect.
|
||||
|
@ -122,6 +122,7 @@ public:
|
||||
NS_IMETHOD BeginSecureKeyboardInput();
|
||||
NS_IMETHOD EndSecureKeyboardInput();
|
||||
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, PRBool aActive);
|
||||
virtual void SetDrawsInTitlebar(PRBool aState) {}
|
||||
virtual PRBool ShowsResizeIndicator(nsIntRect* aResizerRect);
|
||||
virtual void FreeNativeData(void * data, PRUint32 aDataType) {}
|
||||
NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical);
|
||||
|
Loading…
Reference in New Issue
Block a user