Backed out changeset 8a9bae22cf24 (bug 1771150) for causing failures in browser_fullscreen_warning.js and test_pointerlock-api.html CLOSED TREE

This commit is contained in:
Noemi Erli 2022-06-27 17:27:11 +03:00
parent 68d72e655c
commit 5003eb07b7
6 changed files with 24 additions and 21 deletions

View File

@ -14574,7 +14574,7 @@ bool Document::PopFullscreenElement(UpdateViewport aUpdateViewport) {
}
MOZ_ASSERT(removedElement->State().HasState(ElementState::FULLSCREEN));
removedElement->RemoveStates(ElementState::FULLSCREEN | ElementState::MODAL);
removedElement->RemoveStates(ElementState::FULLSCREEN);
NotifyFullScreenChangedForMediaElement(*removedElement);
// Reset iframe fullscreen flag.
if (auto* iframe = HTMLIFrameElement::FromNode(removedElement)) {
@ -14587,18 +14587,23 @@ bool Document::PopFullscreenElement(UpdateViewport aUpdateViewport) {
}
void Document::SetFullscreenElement(Element& aElement) {
ElementState statesToAdd = ElementState::FULLSCREEN;
if (StaticPrefs::dom_fullscreen_modal()) {
statesToAdd |= ElementState::MODAL;
}
aElement.AddStates(statesToAdd);
aElement.AddStates(ElementState::FULLSCREEN);
TopLayerPush(aElement);
NotifyFullScreenChangedForMediaElement(aElement);
UpdateViewportScrollbarOverrideForFullscreen(this);
}
static ElementState TopLayerModalStates() {
ElementState modalStates = ElementState::MODAL_DIALOG;
if (StaticPrefs::dom_fullscreen_modal()) {
modalStates |= ElementState::FULLSCREEN;
}
return modalStates;
}
void Document::TopLayerPush(Element& aElement) {
const bool modal = aElement.State().HasState(ElementState::MODAL);
const bool modal =
aElement.State().HasAtLeastOneOfStates(TopLayerModalStates());
auto predictFunc = [&aElement](Element* element) {
return element == &aElement;
@ -14635,7 +14640,7 @@ void Document::TopLayerPush(Element& aElement) {
}
void Document::AddModalDialog(HTMLDialogElement& aDialogElement) {
aDialogElement.AddStates(ElementState::MODAL);
aDialogElement.AddStates(ElementState::MODAL_DIALOG);
TopLayerPush(aDialogElement);
}
@ -14645,7 +14650,7 @@ void Document::RemoveModalDialog(HTMLDialogElement& aDialogElement) {
};
DebugOnly<Element*> removedElement = TopLayerPop(predicate);
MOZ_ASSERT(removedElement == &aDialogElement);
aDialogElement.RemoveStates(ElementState::MODAL);
aDialogElement.RemoveStates(ElementState::MODAL_DIALOG);
}
Element* Document::TopLayerPop(FunctionRef<bool(Element*)> aPredicate) {
@ -14686,14 +14691,15 @@ Element* Document::TopLayerPop(FunctionRef<bool(Element*)> aPredicate) {
return nullptr;
}
const bool modal = removedElement->State().HasState(ElementState::MODAL);
const ElementState modalStates = TopLayerModalStates();
const bool modal = removedElement->State().HasAtLeastOneOfStates(modalStates);
if (modal) {
removedElement->RemoveStates(ElementState::TOPMOST_MODAL);
bool foundExistingModalElement = false;
for (const nsWeakPtr& weakPtr : Reversed(mTopLayer)) {
nsCOMPtr<Element> element(do_QueryReferent(weakPtr));
if (element && element->State().HasState(ElementState::MODAL)) {
if (element && element->State().HasAtLeastOneOfStates(modalStates)) {
element->AddStates(ElementState::TOPMOST_MODAL);
foundExistingModalElement = true;
break;

View File

@ -107,9 +107,9 @@ bitflags! {
const AUTOFILL = 1u64 << 40;
/// Non-standard & undocumented.
const AUTOFILL_PREVIEW = 1u64 << 41;
/// State for modal elements:
/// <https://drafts.csswg.org/selectors-4/#modal-state>
const MODAL = 1u64 << 42;
/// State that dialog element is modal, for centered alignment
/// <https://html.spec.whatwg.org/multipage/#centered-alignment>
const MODAL_DIALOG = 1u64 << 42;
/// <https://html.spec.whatwg.org/multipage/#inert-subtrees>
const INERT = 1u64 << 43;
/// State for the topmost modal element in top layer
@ -164,7 +164,7 @@ bitflags! {
Self::FULLSCREEN.bits |
Self::HOVER.bits |
Self::URLTARGET.bits |
Self::MODAL.bits |
Self::MODAL_DIALOG.bits |
Self::INERT.bits |
Self::TOPMOST_MODAL.bits |
Self::REVEALED.bits;

View File

@ -51,9 +51,6 @@ async function testFullscreenIsModal(modal) {
clickButton(/* expectEvent = */ !modal);
ok(document.fullscreenElement.matches(":fullscreen"), "Fullscreen element matches :fullscreen");
is(document.fullscreenElement.matches(":modal"), modal, "Fullscreen element matches :modal");
await document.exitFullscreen();
clickButton(/* expectEvent = */ true);
}

View File

@ -81,7 +81,7 @@ void HTMLDialogElement::Show() {
}
bool HTMLDialogElement::IsInTopLayer() const {
return State().HasState(ElementState::MODAL);
return State().HasState(ElementState::MODAL_DIALOG);
}
void HTMLDialogElement::AddToTopLayerIfNeeded() {

View File

@ -2384,7 +2384,7 @@
# This matches other browsers but historically not Gecko.
- name: dom.fullscreen.modal
type: bool
value: true
value: false
mirror: always
# Whether the Gamepad API is enabled

View File

@ -53,7 +53,7 @@ macro_rules! apply_non_ts_list {
("-moz-devtools-highlighted", MozDevtoolsHighlighted, DEVTOOLS_HIGHLIGHTED, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
("-moz-styleeditor-transitioning", MozStyleeditorTransitioning, STYLEEDITOR_TRANSITIONING, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
("fullscreen", Fullscreen, FULLSCREEN, _),
("modal", Modal, MODAL, _),
("modal", Modal, MODAL_DIALOG, _),
("-moz-topmost-modal", MozTopmostModal, TOPMOST_MODAL, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
("-moz-broken", MozBroken, BROKEN, _),
("-moz-loading", MozLoading, LOADING, _),