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 f3ff270b36ce7161ed35f1d6b5320a6b6704d8ff..166cf1153250af122975e3e0f9a80ddc9bfc8f50 100644 |
--- a/third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h |
+++ b/third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h |
@@ -6,6 +6,7 @@ |
#define DocumentOrShadowRoot_h |
#include "core/dom/Document.h" |
+#include "core/dom/Fullscreen.h" |
#include "core/dom/shadow/ShadowRoot.h" |
#include "core/frame/UseCounter.h" |
@@ -76,6 +77,60 @@ public: |
return nullptr; |
return shadowRoot.adjustedElement(*target); |
} |
+ |
+ static Element* currentFullScreenElement(Document& document) |
+ { |
+ Element* element = Fullscreen::currentFullScreenElementFrom(document); |
+ if (!element) |
+ 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 (element->isInV0ShadowTree()) { |
+ UseCounter::count(document, UseCounter::DocumentFullscreenElementInV0Shadow); |
+ return element; |
+ } |
+ return document.adjustedElement(*element); |
+ } |
+ |
+ static Element* currentFullScreenElement(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; |
+ |
+ Element* element = Fullscreen::currentFullScreenElementFrom(shadowRoot.document()); |
+ return element ? shadowRoot.adjustedElement(*element) : nullptr; |
+ } |
+ |
+ static Element* fullscreenElement(Document& document) |
+ { |
+ Element* element = Fullscreen::fullscreenElementFrom(document); |
+ if (!element) |
+ 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 (element->isInV0ShadowTree()) { |
+ UseCounter::count(document, UseCounter::DocumentFullscreenElementInV0Shadow); |
+ return element; |
+ } |
+ return document.adjustedElement(*element); |
+ } |
+ |
+ static Element* fullscreenElement(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; |
+ |
+ Element* element = Fullscreen::fullscreenElementFrom(shadowRoot.document()); |
+ return element ? shadowRoot.adjustedElement(*element) : nullptr; |
+ } |
}; |
} // namespace blink |