Commit 9fbc18ca authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1733384 - Make inert not modify the computed style. r=sefeng,layout-reviewers,jfkthame

parent 9dd0c68d
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
@@ -39,11 +39,6 @@ add_task(async function test_check_window_modal_prompt_service() {
    dialogWin?.docShell?.chromeEventHandler,
    "Should have embedded the dialog."
  );
  is(
    window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
    "none",
    "Browser window should be inert."
  );
  for (let menu of document.querySelectorAll("menubar > menu")) {
    ok(menu.disabled, `Menu ${menu.id} should be disabled.`);
  }
@@ -65,11 +60,6 @@ add_task(async function test_check_window_modal_prompt_service() {
  );

  // Check we cleaned up:
  is(
    window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
    "auto",
    "Browser window should no longer be inert."
  );
  for (let menu of document.querySelectorAll("menubar > menu")) {
    ok(!menu.disabled, `Menu ${menu.id} should not be disabled anymore.`);
  }
@@ -95,11 +85,6 @@ add_task(async function test_check_window_modal_prompt_service() {
    dialogWin?.docShell?.chromeEventHandler,
    "Should have embedded the dialog."
  );
  is(
    window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
    "none",
    "Browser window should be inert."
  );

  let container = dialogWin.docShell.chromeEventHandler.closest("dialog");
  let closedPromise = BrowserTestUtils.waitForMutationCondition(
@@ -114,11 +99,6 @@ add_task(async function test_check_window_modal_prompt_service() {
  await closedPromise;

  // Check we cleaned up:
  is(
    window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
    "auto",
    "Browser window should no longer be inert."
  );
  for (let menu of document.querySelectorAll("menubar > menu")) {
    ok(!menu.disabled, `Menu ${menu.id} should not be disabled anymore.`);
  }
@@ -145,11 +125,6 @@ add_task(async function test_check_multiple_prompts() {
    dialogWin?.docShell?.chromeEventHandler,
    "Should have embedded the dialog."
  );
  is(
    window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
    "none",
    "Browser window should be inert."
  );
  is(container.childElementCount, 1, "Should only have 1 dialog in the DOM.");

  let secondDialogClosedPromise = new Promise(resolve => {
@@ -173,12 +148,6 @@ add_task(async function test_check_multiple_prompts() {
  isnot(oldWin, dialogWin, "Opened a new dialog.");
  ok(container.open, "Dialog should be open.");

  is(
    window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
    "none",
    "Browser window should be inert again."
  );

  info("Now close the second dialog.");
  dialogWin.document.querySelector("dialog").acceptDialog();

@@ -191,11 +160,6 @@ add_task(async function test_check_multiple_prompts() {
    () => !container.hasChildNodes() && !container.open
  );
  // Check we cleaned up:
  is(
    window.getComputedStyle(document.body).getPropertyValue("-moz-user-input"),
    "auto",
    "Browser window should no longer be inert."
  );
  for (let menu of document.querySelectorAll("menubar > menu")) {
    ok(!menu.disabled, `Menu ${menu.id} should not be disabled anymore.`);
  }
+6 −8
Original line number Diff line number Diff line
@@ -3371,7 +3371,6 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
        bool suppressBlur = false;
        if (mCurrentTarget) {
          mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(newFocus));
          const nsStyleUI* ui = mCurrentTarget->StyleUI();
          activeContent = mCurrentTarget->GetContent();

          // In some cases, we do not want to even blur the current focused
@@ -3385,7 +3384,8 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
          // we click on a non-focusable element like a <div>.
          // We have to use |aEvent->mTarget| to not make sure we do not check
          // an anonymous node of the targeted element.
          suppressBlur = (ui->mUserFocus == StyleUserFocus::Ignore);
          suppressBlur =
              mCurrentTarget->StyleUI()->UserFocus() == StyleUserFocus::Ignore;

          nsCOMPtr<Element> element = do_QueryInterface(aEvent->mTarget);
          if (!suppressBlur && element) {
@@ -4071,7 +4071,7 @@ static CursorImage ComputeCustomCursor(nsPresContext* aPresContext,
  // If we are falling back because any cursor before us is loading, let the
  // consumer know.
  bool loading = false;
  for (const auto& image : style.StyleUI()->mCursor.images.AsSpan()) {
  for (const auto& image : style.StyleUI()->Cursor().images.AsSpan()) {
    MOZ_ASSERT(image.image.IsImageRequestType(),
               "Cursor image should only parse url() types");
    uint32_t status;
@@ -5606,12 +5606,10 @@ bool EventStateManager::SetContentState(nsIContent* aContent,

    // check to see that this state is allowed by style. Check dragover too?
    // XXX Is this even what we want?
    if (mCurrentTarget) {
      const nsStyleUI* ui = mCurrentTarget->StyleUI();
      if (ui->mUserInput == StyleUserInput::None) {
    if (mCurrentTarget &&
        mCurrentTarget->StyleUI()->UserInput() == StyleUserInput::None) {
      return false;
    }
    }

    if (aState == NS_EVENT_STATE_ACTIVE) {
      if (aContent && !CanContentHaveActiveState(*aContent)) {
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ void HTMLOptGroupElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
  if (nsIFrame* frame = GetPrimaryFrame()) {
    // FIXME(emilio): This poking at the style of the frame is broken unless we
    // flush before every event handling, which we don't really want to.
    if (frame->StyleUI()->mUserInput == StyleUserInput::None) {
    if (frame->StyleUI()->UserInput() == StyleUserInput::None) {
      return;
    }
  }
+1 −1
Original line number Diff line number Diff line
@@ -1948,7 +1948,7 @@ bool nsGenericHTMLFormElement::IsElementDisabledForEvents(WidgetEvent* aEvent,

  // FIXME(emilio): This poking at the style of the frame is slightly bogus
  // unless we flush before every event, which we don't really want to do.
  if (aFrame && aFrame->StyleUI()->mUserInput == StyleUserInput::None) {
  if (aFrame && aFrame->StyleUI()->UserInput() == StyleUserInput::None) {
    return true;
  }

+2 −2
Original line number Diff line number Diff line
@@ -185,8 +185,8 @@ nsresult nsXULPopupListener::FireFocusOnTargetContent(
  nsIFrame* targetFrame = aTargetContent->GetPrimaryFrame();
  if (!targetFrame) return NS_ERROR_FAILURE;

  const nsStyleUI* ui = targetFrame->StyleUI();
  bool suppressBlur = (ui->mUserFocus == StyleUserFocus::Ignore);
  const bool suppressBlur =
      targetFrame->StyleUI()->UserFocus() == StyleUserFocus::Ignore;

  RefPtr<Element> newFocusElement;

Loading