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

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 comments 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..8749667a832bfa4e58b3c8ee7ed71cc8b7981691 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,35 @@ public:
{
return treeScope.elementsFromPoint(x, y);
}
+
+ static Element* pointerLockElement(Document& document)
+ {
+ UseCounter::count(document, UseCounter::DocumentPointerLockElement);
+ const Element* target = document.pointerLockElement();
+ if (!target)
+ return nullptr;
+ // For Shadow DOM V0 compatibility: We allow returning an element in V0 shadow tree,
+ // even though it leaks the Shadow DOM.
+ // TODO(kochi): Once V0 code is removed, the following V0 check is unnecessary.
+ if (target && target->isInV0ShadowTree()) {
+ UseCounter::count(document, UseCounter::DocumentPointerLockElementInV0Shadow);
+ return const_cast<Element*>(target);
+ }
+ return document.adjustedPointerLockElement(*target);
+ }
+
+ static Element* pointerLockElement(ShadowRoot& shadowRoot)
+ {
+ // TODO(kochi): Once V0 code is removed, the following non-V1 check is unnecessary.
+ // After V0 code is removed, we can use the same logic for Document and ShadowRoot.
+ if (!shadowRoot.isV1())
+ return nullptr;
+ UseCounter::count(shadowRoot.document(), UseCounter::ShadowRootPointerLockElement);
+ const Element* target = shadowRoot.document().pointerLockElement();
+ if (!target)
+ return nullptr;
+ return shadowRoot.adjustedPointerLockElement(*target);
+ }
};
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.idl ('k') | third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698