Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: third_party/WebKit/Source/core/dom/DocumentOrShadowRoot.h

Issue 2340263003: Move Document.fullscreenElement to DocumentOrShadowRoot (Closed)
Patch Set: Update test. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698