Bug 1137009 - Do not persist attributes of xul window if the window is in fullscreen. r=janv

This commit is contained in:
Xidorn Quan 2015-09-09 10:45:39 +10:00
parent d7d49993cb
commit 0ade7a7b49
2 changed files with 39 additions and 11 deletions

View File

@ -924,6 +924,23 @@ XULDocument::AttributeWillChange(nsIDocument* aDocument,
}
}
static bool
ShouldPersistAttribute(nsIDocument* aDocument, Element* aElement)
{
if (aElement->IsXULElement(nsGkAtoms::window)) {
if (nsCOMPtr<nsPIDOMWindow> window = aDocument->GetWindow()) {
bool isFullscreen;
window->GetFullScreen(&isFullscreen);
if (isFullscreen) {
// Don't persist attributes if it is window element and
// we are in fullscreen state.
return false;
}
}
}
return true;
}
void
XULDocument::AttributeChanged(nsIDocument* aDocument,
Element* aElement, int32_t aNameSpaceID,
@ -999,18 +1016,19 @@ XULDocument::AttributeChanged(nsIDocument* aDocument,
bool listener, resolved;
CheckBroadcasterHookup(aElement, &listener, &resolved);
// See if there is anything we need to persist in the localstore.
//
// XXX Namespace handling broken :-(
nsAutoString persist;
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::persist, persist);
if (!persist.IsEmpty()) {
// XXXldb This should check that it's a token, not just a substring.
if (persist.Find(nsDependentAtomString(aAttribute)) >= 0) {
if (ShouldPersistAttribute(aDocument, aElement)) {
// See if there is anything we need to persist in the localstore.
//
// XXX Namespace handling broken :-(
nsString persist;
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::persist, persist);
if (!persist.IsEmpty() &&
// XXXldb This should check that it's a token, not just a substring.
persist.Find(nsDependentAtomString(aAttribute)) >= 0) {
nsContentUtils::AddScriptRunner(NS_NewRunnableMethodWithArgs
<nsIContent*, int32_t, nsIAtom*>
(this, &XULDocument::DoPersist, aElement, kNameSpaceID_None,
aAttribute));
<nsIContent*, int32_t, nsIAtom*>
(this, &XULDocument::DoPersist, aElement,
kNameSpaceID_None, aAttribute));
}
}
}

View File

@ -1436,6 +1436,16 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
if (!mDocShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMWindow> domWindow;
GetWindowDOMWindow(getter_AddRefs(domWindow));
if (domWindow) {
bool isFullscreen;
domWindow->GetFullScreen(&isFullscreen);
if (isFullscreen) {
return NS_OK;
}
}
nsCOMPtr<dom::Element> docShellElement = GetWindowDOMElement();
if (!docShellElement)
return NS_ERROR_FAILURE;