OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DocumentOrShadowRoot_h | 5 #ifndef DocumentOrShadowRoot_h |
6 #define DocumentOrShadowRoot_h | 6 #define DocumentOrShadowRoot_h |
7 | 7 |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/shadow/ShadowRoot.h" | 9 #include "core/dom/shadow/ShadowRoot.h" |
10 #include "core/frame/UseCounter.h" | 10 #include "core/frame/UseCounter.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 int x, | 41 int x, |
42 int y) { | 42 int y) { |
43 return treeScope.elementsFromPoint(x, y); | 43 return treeScope.elementsFromPoint(x, y); |
44 } | 44 } |
45 | 45 |
46 static Element* pointerLockElement(Document& document) { | 46 static Element* pointerLockElement(Document& document) { |
47 UseCounter::count(document, UseCounter::DocumentPointerLockElement); | 47 UseCounter::count(document, UseCounter::DocumentPointerLockElement); |
48 const Element* target = document.pointerLockElement(); | 48 const Element* target = document.pointerLockElement(); |
49 if (!target) | 49 if (!target) |
50 return nullptr; | 50 return nullptr; |
51 // For Shadow DOM V0 compatibility: We allow returning an element in V0 shad
ow tree, | 51 // For Shadow DOM V0 compatibility: We allow returning an element in V0 |
52 // even though it leaks the Shadow DOM. | 52 // shadow tree, even though it leaks the Shadow DOM. |
53 // TODO(kochi): Once V0 code is removed, the following V0 check is unnecessa
ry. | 53 // TODO(kochi): Once V0 code is removed, the following V0 check is |
| 54 // unnecessary. |
54 if (target && target->isInV0ShadowTree()) { | 55 if (target && target->isInV0ShadowTree()) { |
55 UseCounter::count(document, | 56 UseCounter::count(document, |
56 UseCounter::DocumentPointerLockElementInV0Shadow); | 57 UseCounter::DocumentPointerLockElementInV0Shadow); |
57 return const_cast<Element*>(target); | 58 return const_cast<Element*>(target); |
58 } | 59 } |
59 return document.adjustedElement(*target); | 60 return document.adjustedElement(*target); |
60 } | 61 } |
61 | 62 |
62 static Element* pointerLockElement(ShadowRoot& shadowRoot) { | 63 static Element* pointerLockElement(ShadowRoot& shadowRoot) { |
63 // TODO(kochi): Once V0 code is removed, the following non-V1 check is unnec
essary. | 64 // TODO(kochi): Once V0 code is removed, the following non-V1 check is |
64 // After V0 code is removed, we can use the same logic for Document and Shad
owRoot. | 65 // unnecessary. After V0 code is removed, we can use the same logic for |
| 66 // Document and ShadowRoot. |
65 if (!shadowRoot.isV1()) | 67 if (!shadowRoot.isV1()) |
66 return nullptr; | 68 return nullptr; |
67 UseCounter::count(shadowRoot.document(), | 69 UseCounter::count(shadowRoot.document(), |
68 UseCounter::ShadowRootPointerLockElement); | 70 UseCounter::ShadowRootPointerLockElement); |
69 const Element* target = shadowRoot.document().pointerLockElement(); | 71 const Element* target = shadowRoot.document().pointerLockElement(); |
70 if (!target) | 72 if (!target) |
71 return nullptr; | 73 return nullptr; |
72 return shadowRoot.adjustedElement(*target); | 74 return shadowRoot.adjustedElement(*target); |
73 } | 75 } |
74 }; | 76 }; |
75 | 77 |
76 } // namespace blink | 78 } // namespace blink |
77 | 79 |
78 #endif // DocumentOrShadowRoot_h | 80 #endif // DocumentOrShadowRoot_h |
OLD | NEW |