Chromium Code Reviews| 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 |