Index: third_party/WebKit/Source/core/dom/Fullscreen.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Fullscreen.cpp b/third_party/WebKit/Source/core/dom/Fullscreen.cpp |
index f30793ebf893232c84067a756b252a75473c91a3..e75d853d744c37555a2ba3a42a12fd70c8c74e20 100644 |
--- a/third_party/WebKit/Source/core/dom/Fullscreen.cpp |
+++ b/third_party/WebKit/Source/core/dom/Fullscreen.cpp |
@@ -218,6 +218,39 @@ Element* Fullscreen::currentFullScreenElementFrom(Document& document) { |
return nullptr; |
} |
+Element* Fullscreen::fullscreenElementForBindingFrom(Document& document) { |
+ Element* element = nullptr; |
+ if (Fullscreen* found = fromIfExists(document)) |
+ element = found->fullscreenElement(); |
+ 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); |
+} |
+ |
+Element* Fullscreen::fullscreenElementForBindingFrom(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; |
+ |
+ if (Fullscreen* found = fromIfExists(shadowRoot.document())) { |
+ if (Element* element = found->fullscreenElement()) |
+ return shadowRoot.adjustedElement(*element); |
+ } |
+ return nullptr; |
+} |
+ |
Fullscreen::Fullscreen(Document& document) |
: ContextLifecycleObserver(&document), |
m_fullScreenLayoutObject(nullptr), |