Merge inbound to mozilla-central. a=merge
authorCsoregi Natalia <ncsoregi@mozilla.com>
Sun, 04 Feb 2018 12:15:21 +0200
changeset 457369 cac3a4e6000d7079f8cf0118a5c509b2527b3289
parent 457365 bcebc8274aea0f411fbca45e387e84e475d1c9c8 (current diff)
parent 457368 ef621baf72e3d1ab67fd06593d8b4992d0a34472 (diff)
child 457370 88e2ca4007fddda4a7879354cfabf92c35bd7514
child 457379 635377b5ce2ac4f198b8a9fb04d648abe233bed8
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone60.0a1
first release with
nightly linux32
cac3a4e6000d / 60.0a1 / 20180204102054 / files
nightly linux64
cac3a4e6000d / 60.0a1 / 20180204102054 / files
nightly mac
cac3a4e6000d / 60.0a1 / 20180204102054 / files
nightly win32
cac3a4e6000d / 60.0a1 / 20180204102054 / files
nightly win64
cac3a4e6000d / 60.0a1 / 20180204102054 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to mozilla-central. a=merge
--- a/dom/base/DocumentOrShadowRoot.cpp
+++ b/dom/base/DocumentOrShadowRoot.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DocumentOrShadowRoot.h"
+#include "mozilla/EventStateManager.h"
 #include "mozilla/dom/StyleSheetList.h"
 #include "nsDocument.h"
 #include "nsFocusManager.h"
 
 namespace mozilla {
 namespace dom {
 
 DocumentOrShadowRoot::DocumentOrShadowRoot(mozilla::dom::ShadowRoot& aShadowRoot)
@@ -125,10 +126,25 @@ DocumentOrShadowRoot::GetRetargetedFocus
         }
       }
     }
   }
 
   return nullptr;
 }
 
+Element*
+DocumentOrShadowRoot::GetPointerLockElement()
+{
+  nsCOMPtr<Element> pointerLockedElement =
+    do_QueryReferent(EventStateManager::sPointerLockedElement);
+  if (!pointerLockedElement) {
+    return nullptr;
+  }
+
+  nsIContent* retargetedPointerLockedElement = Retarget(pointerLockedElement);
+  return
+    retargetedPointerLockedElement && retargetedPointerLockedElement->IsElement() ?
+      retargetedPointerLockedElement->AsElement() : nullptr;
+}
+
 }
 }
--- a/dom/base/DocumentOrShadowRoot.h
+++ b/dom/base/DocumentOrShadowRoot.h
@@ -108,16 +108,17 @@ public:
                          const nsAString& aLocalName,
                          mozilla::ErrorResult&);
 
   already_AddRefed<nsContentList>
   GetElementsByClassName(const nsAString& aClasses);
 
   ~DocumentOrShadowRoot() = default;
 
+  Element* GetPointerLockElement();
 protected:
   nsIContent* Retarget(nsIContent* aContent) const;
 
   /**
    * If focused element's subtree root is this document or shadow root, return
    * focused element, otherwise, get the shadow host recursively until the
    * shadow host's subtree root is this document or shadow root.
    */
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -11635,17 +11635,17 @@ GetPointerLockError(Element* aElement, E
     return "PointerLockDeniedDisabled";
   }
 
   nsCOMPtr<nsIDocument> ownerDoc = aElement->OwnerDoc();
   if (aCurrentLock && aCurrentLock->OwnerDoc() != ownerDoc) {
     return "PointerLockDeniedInUse";
   }
 
-  if (!aElement->IsInUncomposedDoc()) {
+  if (!aElement->IsInComposedDoc()) {
     return "PointerLockDeniedNotInDocument";
   }
 
   if (ownerDoc->GetSandboxFlags() & SANDBOXED_POINTER_LOCK) {
     return "PointerLockDeniedSandboxed";
   }
 
   // Check if the element is in a document with a docshell.
@@ -11686,21 +11686,21 @@ ChangePointerLockedElement(Element* aEle
   // aDocument here is not really necessary, as it is the uncomposed
   // document of both aElement and aPointerLockedElement as far as one
   // is not nullptr, and they wouldn't both be nullptr in any case.
   // But since the caller of this function should have known what the
   // document is, we just don't try to figure out what it should be.
   MOZ_ASSERT(aDocument);
   MOZ_ASSERT(aElement != aPointerLockedElement);
   if (aPointerLockedElement) {
-    MOZ_ASSERT(aPointerLockedElement->GetUncomposedDoc() == aDocument);
+    MOZ_ASSERT(aPointerLockedElement->GetComposedDoc() == aDocument);
     aPointerLockedElement->ClearPointerLock();
   }
   if (aElement) {
-    MOZ_ASSERT(aElement->GetUncomposedDoc() == aDocument);
+    MOZ_ASSERT(aElement->GetComposedDoc() == aDocument);
     aElement->SetPointerLock();
     EventStateManager::sPointerLockedElement = do_GetWeakReference(aElement);
     EventStateManager::sPointerLockedDoc = do_GetWeakReference(aDocument);
     NS_ASSERTION(EventStateManager::sPointerLockedElement &&
                  EventStateManager::sPointerLockedDoc,
                  "aElement and this should support weak references!");
   } else {
     EventStateManager::sPointerLockedElement = nullptr;
@@ -11714,19 +11714,19 @@ ChangePointerLockedElement(Element* aEle
 
 NS_IMETHODIMP
 PointerLockRequest::Run()
 {
   nsCOMPtr<Element> e = do_QueryReferent(mElement);
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
   nsDocument* d = static_cast<nsDocument*>(doc.get());
   const char* error = nullptr;
-  if (!e || !d || !e->GetUncomposedDoc()) {
+  if (!e || !d || !e->GetComposedDoc()) {
     error = "PointerLockDeniedNotInDocument";
-  } else if (e->GetUncomposedDoc() != d) {
+  } else if (e->GetComposedDoc() != d) {
     error = "PointerLockDeniedMovedDocument";
   }
   if (!error) {
     nsCOMPtr<Element> pointerLockedElement =
       do_QueryReferent(EventStateManager::sPointerLockedElement);
     if (e == pointerLockedElement) {
       DispatchPointerLockChange(d);
       return NS_OK;
@@ -11867,35 +11867,16 @@ nsDocument::UnlockPointer(nsIDocument* a
 }
 
 void
 nsIDocument::UnlockPointer(nsIDocument* aDoc)
 {
   nsDocument::UnlockPointer(aDoc);
 }
 
-Element*
-nsIDocument::GetPointerLockElement()
-{
-  nsCOMPtr<Element> pointerLockedElement =
-    do_QueryReferent(EventStateManager::sPointerLockedElement);
-  if (!pointerLockedElement) {
-    return nullptr;
-  }
-
-  // Make sure pointer locked element is in the same document.
-  nsCOMPtr<nsIDocument> pointerLockedDoc =
-    do_QueryReferent(EventStateManager::sPointerLockedDoc);
-  if (pointerLockedDoc != this) {
-    return nullptr;
-  }
-
-  return pointerLockedElement;
-}
-
 void
 nsDocument::UpdateVisibilityState()
 {
   dom::VisibilityState oldState = mVisibilityState;
   mVisibilityState = GetVisibilityState();
   if (oldState != mVisibilityState) {
     nsContentUtils::DispatchTrustedEvent(this, static_cast<nsIDocument*>(this),
                                          NS_LITERAL_STRING("visibilitychange"),
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -2927,17 +2927,16 @@ public:
   // Not const because all the full-screen goop is not const
   virtual bool FullscreenEnabled(mozilla::dom::CallerType aCallerType) = 0;
   virtual Element* GetFullscreenElement() = 0;
   bool Fullscreen()
   {
     return !!GetFullscreenElement();
   }
   void ExitFullscreen();
-  Element* GetPointerLockElement();
   void ExitPointerLock()
   {
     UnlockPointer(this);
   }
 #ifdef MOZILLA_INTERNAL_API
   bool Hidden() const
   {
     return mVisibilityState != mozilla::dom::VisibilityState::Visible;
copy from dom/tests/mochitest/pointerlock/file_pointerlock-api.html
copy to dom/tests/mochitest/pointerlock/file_pointerlock-api-with-shadow.html
--- a/dom/tests/mochitest/pointerlock/file_pointerlock-api.html
+++ b/dom/tests/mochitest/pointerlock/file_pointerlock-api-with-shadow.html
@@ -10,27 +10,28 @@
   <script type="application/javascript" src="pointerlock_utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
   <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
     Mozilla Bug 633602
   </a>
-  <div id="div"></div>
+  <div id="host"></div>
   <pre id="test">
     <script type="text/javascript">
       /*
-       * Test for Bug 633602
+       * Test for Bug 1430303
        * Make sure DOM API is correct.
        */
 
       SimpleTest.waitForExplicitFinish();
 
       var div,
+        host,
         hasRequestPointerLock = false,
         pointerLockChangeEventFired = false,
         pointerUnlocked = false,
         pointerLocked = false,
         hasExitPointerLock = false,
         pointerLockElement = false,
         hasMovementX = false,
         hasMovementY = false;
@@ -60,45 +61,50 @@
       }
 
       document.addEventListener("pointerlockchange", function (e) {
         pointerLockChangeEventFired = true;
 
         if (document.pointerLockElement) {
           info("Got pointerlockchange for entering");
           pointerLocked = true;
-          pointerLockElement = document.pointerLockElement === div;
+          pointerLockElement = document.pointerLockElement === host;
+          is(host.shadowRoot.firstChild, host.shadowRoot.pointerLockElement,
+             "ShadowRoot's pointerLockElement shouldn't be retargeted.");
  
           window.addEventListener("contextmenu",
                                   function() { gotContextMenuEvent = true; },
                                   true);
           synthesizeMouse(document.body, 4, 4,
                           { type: "contextmenu", button: 2 },
                           window);
 
           document.addEventListener("mousemove", mouseMoveHandler);
-          synthesizeMouseAtCenter(div, {type: "mousemove"}, window);
+          synthesizeMouseAtCenter(host, {type: "mousemove"}, window);
         } else {
           info("Got pointerlockchange for exiting");
           pointerUnlocked = true;
           addFullscreenChangeContinuation("exit", function() {
             info("Got fullscreenchange for exiting");
             runTests();
             SimpleTest.finish();
           });
           document.exitFullscreen();
         }
       });
 
       function start() {
-        div = document.getElementById("div");
+        host = document.getElementById("host");
+        var sr = host.attachShadow({mode: "open"});
+        sr.innerHTML = "<div><div>";
+        div = sr.firstChild;
         info("Requesting fullscreen on parent");
         addFullscreenChangeContinuation("enter", function() {
           info("Got fullscreenchange for entering");
           hasRequestPointerLock = "requestPointerLock" in div;
           div.requestPointerLock();
         });
-        div.requestFullscreen();
+        host.requestFullscreen();
       }
     </script>
   </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/mochitest.ini
+++ b/dom/tests/mochitest/pointerlock/mochitest.ini
@@ -4,16 +4,17 @@ skip-if = toolkit == 'android'
 [test_closewindow-with-pointerlock.html]
 
 [test_pointerlock-api.html]
 skip-if = os == "linux" || os == "win" # Bug 1357082
 tags = fullscreen
 support-files =
   pointerlock_utils.js
   file_pointerlock-api.html
+  file_pointerlock-api-with-shadow.html
   file_pointerlockerror.html
   file_escapeKey.html
   file_withoutDOM.html
   file_removedFromDOM.html
   file_pointerLockPref.html
   file_nestedFullScreen.html
   file_doubleLock.html
   file_childIframe.html
--- a/dom/tests/mochitest/pointerlock/test_pointerlock-api.html
+++ b/dom/tests/mochitest/pointerlock/test_pointerlock-api.html
@@ -28,32 +28,34 @@ https://bugzilla.mozilla.org/show_bug.cg
 
         SimpleTest.waitForExplicitFinish();
 
         SpecialPowers.pushPrefEnv({"set": [
           ["full-screen-api.enabled", true],
           ["full-screen-api.unprefix.enabled", true],
           ["full-screen-api.allow-trusted-requests-only", false],
           ["full-screen-api.transition-duration.enter", "0 0"],
-          ["full-screen-api.transition-duration.leave", "0 0"]
+          ["full-screen-api.transition-duration.leave", "0 0"],
+          ["dom.webcomponents.shadowdom.enabled", true]
         ]}, nextTest);
 
         // Run the tests which go full-screen in new window, as Mochitests
         // normally run in an iframe, which by default will not have the
         // allowfullscreen attribute set, so full-screen won't work.
         var gTestFiles = [
           "file_screenClientXYConst.html",
           "file_childIframe.html",
           "file_doubleLock.html",
           "file_escapeKey.html",
           "file_infiniteMovement.html",
           "file_locksvgelement.html",
           "file_movementXY.html",
           "file_nestedFullScreen.html",
           "file_pointerlock-api.html",
+          "file_pointerlock-api-with-shadow.html",
           "file_pointerlockerror.html",
           "file_pointerLockPref.html",
           "file_removedFromDOM.html",
           "file_retargetMouseEvents.html",
           "file_suppressSomeMouseEvents.html",
           "file_targetOutOfFocus.html",
           "file_withoutDOM.html",
           "file_allowPointerLockSandboxFlag.html",
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -257,17 +257,16 @@ partial interface Document {
   attribute EventHandler onfullscreenchange;
   [Func="nsDocument::IsUnprefixedFullscreenEnabled"]
   attribute EventHandler onfullscreenerror;
 };
 
 // https://w3c.github.io/pointerlock/#extensions-to-the-document-interface
 // https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin
 partial interface Document {
-  readonly attribute Element? pointerLockElement;
   void exitPointerLock();
 
   // Event handlers
   attribute EventHandler onpointerlockchange;
   attribute EventHandler onpointerlockerror;
 };
 
 // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#sec-document-interface
--- a/dom/webidl/DocumentOrShadowRoot.webidl
+++ b/dom/webidl/DocumentOrShadowRoot.webidl
@@ -17,13 +17,12 @@ interface DocumentOrShadowRoot {
   // Not implemented yet: bug 1430301.
   // sequence<Element> elementsFromPoint (float x, float y);
   // Not implemented yet: bug 1430307.
   // CaretPosition? caretPositionFromPoint (float x, float y);
 
   readonly attribute Element? activeElement;
   readonly attribute StyleSheetList styleSheets;
 
-  // Not implemented yet: bug 1430303.
-  // readonly attribute Element? pointerLockElement;
+  readonly attribute Element? pointerLockElement;
   // Not implemented yet: bug 1430305.
   // readonly attribute Element? fullscreenElement;
 };