Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h

Issue 2086293004: Document/ShadowRoot split of pointerLockElement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update UseCounters Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h
diff --git a/third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h b/third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h
index 11fbf32b7b9da7d7754da24cd0ee2058703e0a52..c4aed37e515d900221b7b3252bddce2a944c4195 100644
--- a/third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h
+++ b/third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h
@@ -7,6 +7,7 @@
#include "core/dom/Document.h"
#include "core/dom/shadow/ShadowRoot.h"
+#include "core/frame/UseCounter.h"
namespace blink {
@@ -46,6 +47,38 @@ public:
{
return treeScope.elementsFromPoint(x, y);
}
+
+ static Element* retargetPointerLockElement(TreeScope& scope, const Element* target)
hayato 2016/06/27 06:43:13 Make a target a reference: const Element& target
kochi 2016/06/27 07:11:36 Done.
+ {
hayato 2016/06/27 06:43:13 This is not a spec compliant. Please see the defi
kochi 2016/06/27 07:11:36 This was intentional because if Shadow V1 hosts V0
kochi 2016/06/28 06:34:06 This function moved to TreeScope's method.
+ const Element* elementToReturn = target;
+ for (const Element* ancestor = target; ancestor; ancestor = ancestor->shadowHost()) {
+ if (ancestor->shadowRootIfV1())
+ elementToReturn = ancestor;
+ if (scope == ancestor->treeScope())
+ return const_cast<Element*>(elementToReturn);
+ }
+ return nullptr;
+ }
+
+ static Element* pointerLockElement(Document& document)
+ {
+ UseCounter::count(document, UseCounter::DocumentPointerLockElement);
+ const Element* target = document.pointerLockElement();
hayato 2016/06/27 06:43:13 Return early if target is null.
kochi 2016/06/27 07:11:36 Done.
+ if (target && target->isInV0ShadowTree()) {
+ UseCounter::count(document, UseCounter::DocumentPointerLockElementInV0Shadow);
+ return const_cast<Element*>(target);
hayato 2016/06/27 06:43:13 Could you add a comment here so that we can remove
kochi 2016/06/28 06:34:06 Done.
+ }
+ return retargetPointerLockElement(document, target);
+ }
+
+ static Element* pointerLockElement(ShadowRoot& shadowRoot)
+ {
+ if (!shadowRoot.isV1())
hayato 2016/06/27 06:43:13 Could you add a comment here so that we can remove
kochi 2016/06/27 07:11:36 Done.
kochi 2016/06/27 07:11:36 Done.
+ return nullptr;
+ UseCounter::count(shadowRoot.document(), UseCounter::ShadowRootPointerLockElement);
+ const Element* target = shadowRoot.document().pointerLockElement();
hayato 2016/06/27 06:43:13 Return early if target is null.
kochi 2016/06/27 07:11:36 Done.
+ return retargetPointerLockElement(shadowRoot, target);
+ }
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698