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

--HG--
extra : source : 19c3f7b23f53ae04f51458de6df339f3166fe3dc
extra : histedit_source : 4bad4820bca43ebf1cd30228c52b4126a35a25a5
This commit is contained in:
Xidorn Quan 2015-09-24 11:39:22 +10:00
Родитель 1fa3dc1199
Коммит e122198562
1 изменённых файлов: 29 добавлений и 11 удалений

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

@ -918,6 +918,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,
@ -992,18 +1009,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));
}
}
}