| 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
|
|
|