Title: [123005] trunk
Revision
123005
Author
[email protected]
Date
2012-07-18 13:06:12 -0700 (Wed, 18 Jul 2012)

Log Message

Unify allowfullscreen logic in Document::webkitFullScreenEnabled and fullScreenIsAllowedForElement.
https://bugs.webkit.org/show_bug.cgi?id=91448

Reviewed by Adrienne Walker.

Unifies redundant traversal logic and static cast previously used
to determine if an element or document can be made fullscreen.
This clean up prepares for pointer lock, which will use the same logic.

Added a test to detect an edge case of an owning document with
fullscreen permision moving an iframe to fullscreen, while that iframe
does not have permision for its contents to be made fullscreen.

Source/WebCore:

Test: fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent.html

* dom/Document.cpp:
(WebCore::isAttributeOnAllOwners):
(WebCore::Document::fullScreenIsAllowedForElement):
(WebCore::Document::webkitFullscreenEnabled):

LayoutTests:

* fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent-expected.txt: Added.
* fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123004 => 123005)


--- trunk/LayoutTests/ChangeLog	2012-07-18 20:01:46 UTC (rev 123004)
+++ trunk/LayoutTests/ChangeLog	2012-07-18 20:06:12 UTC (rev 123005)
@@ -1,3 +1,21 @@
+2012-07-18  Vincent Scheib  <[email protected]>
+
+        Unify allowfullscreen logic in Document::webkitFullScreenEnabled and fullScreenIsAllowedForElement.
+        https://bugs.webkit.org/show_bug.cgi?id=91448
+
+        Reviewed by Adrienne Walker.
+
+        Unifies redundant traversal logic and static cast previously used
+        to determine if an element or document can be made fullscreen.
+        This clean up prepares for pointer lock, which will use the same logic.
+
+        Added a test to detect an edge case of an owning document with
+        fullscreen permision moving an iframe to fullscreen, while that iframe
+        does not have permision for its contents to be made fullscreen.
+
+        * fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent-expected.txt: Added.
+        * fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent.html: Added.
+
 2012-07-18  Tony Chang  <[email protected]>
 
         [chromium] Unreviewed gardening. Rebaseline 2 tests due to minor changes from r122980.

Added: trunk/LayoutTests/fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent-expected.txt (0 => 123005)


--- trunk/LayoutTests/fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent-expected.txt	2012-07-18 20:06:12 UTC (rev 123005)
@@ -0,0 +1,11 @@
+Test entering full screen security restrictions. An iframe without an allow attribute is still permitted to fullscreen if the request comes from the containing document.
+
+To test manually, press any key - the page should enter full screen mode.
+
+TEST(document.webkitFullscreenEnabled) OK
+iframe's webkitFullscreenEnabled should be false:
+TEST(iframeMessage == 'document.webkitFullscreenEnabled == false') OK
+EVENT(webkitfullscreenchange)
+SUCCEED - entered full screen!
+END OF TEST
+

Added: trunk/LayoutTests/fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent.html (0 => 123005)


--- trunk/LayoutTests/fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent.html	                        (rev 0)
+++ trunk/LayoutTests/fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent.html	2012-07-18 20:06:12 UTC (rev 123005)
@@ -0,0 +1,35 @@
+<p>Test entering full screen security restrictions. An iframe without an allow attribute
+is still permitted to fullscreen if the request comes from the containing document.</p>
+<p>To test manually, press any key - the page should enter full screen mode.</p>
+<script src=""
+<script>
+window._onmessage_ = function (e) {
+    frame = document.getElementById('frame');
+
+    test("document.webkitFullscreenEnabled");
+    consoleWrite("iframe's webkitFullscreenEnabled should be false:");
+    iframeMessage = e.data;
+    test("iframeMessage == 'document.webkitFullscreenEnabled == false'");
+
+    waitForEvent(document, 'webkitfullscreenchange', function() {
+            consoleWrite("SUCCEED - entered full screen!");
+            endTest();
+    });
+
+    runWithKeyDown(function() {
+        setTimeout(function() {
+            consoleWrite("FAIL - did not enter full screen!");
+            endTest();
+        }, 50);
+        frame.webkitRequestFullScreen();
+    });
+}
+</script>
+<iframe id="frame" src=''>
+</iframe>
+

Modified: trunk/Source/WebCore/ChangeLog (123004 => 123005)


--- trunk/Source/WebCore/ChangeLog	2012-07-18 20:01:46 UTC (rev 123004)
+++ trunk/Source/WebCore/ChangeLog	2012-07-18 20:06:12 UTC (rev 123005)
@@ -1,3 +1,25 @@
+2012-07-18  Vincent Scheib  <[email protected]>
+
+        Unify allowfullscreen logic in Document::webkitFullScreenEnabled and fullScreenIsAllowedForElement.
+        https://bugs.webkit.org/show_bug.cgi?id=91448
+
+        Reviewed by Adrienne Walker.
+
+        Unifies redundant traversal logic and static cast previously used
+        to determine if an element or document can be made fullscreen.
+        This clean up prepares for pointer lock, which will use the same logic.
+
+        Added a test to detect an edge case of an owning document with
+        fullscreen permision moving an iframe to fullscreen, while that iframe
+        does not have permision for its contents to be made fullscreen.
+
+        Test: fullscreen/full-screen-iframe-without-allow-attribute-allowed-from-parent.html
+
+        * dom/Document.cpp:
+        (WebCore::isAttributeOnAllOwners):
+        (WebCore::Document::fullScreenIsAllowedForElement):
+        (WebCore::Document::webkitFullscreenEnabled):
+
 2012-07-18  Christophe Dumez  <[email protected]>
 
         [EFL] Add central error management to EFL port

Modified: trunk/Source/WebCore/dom/Document.cpp (123004 => 123005)


--- trunk/Source/WebCore/dom/Document.cpp	2012-07-18 20:01:46 UTC (rev 123004)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-07-18 20:06:12 UTC (rev 123005)
@@ -585,6 +585,19 @@
     HistogramSupport::histogramEnumeration("DOMAPI.PerDocumentMutationEventUsage.DOMCharacterDataModified", static_cast<bool>(listenerTypes & Document::DOMCHARACTERDATAMODIFIED_LISTENER), 2);
 }
 
+#if ENABLE(FULLSCREEN_API)
+static bool isAttributeOnAllOwners(const WebCore::QualifiedName& attribute, const HTMLFrameOwnerElement* owner)
+{
+    if (!owner)
+        return true;
+    do {
+        if (!owner->hasAttribute(attribute))
+            return false;
+    } while ((owner = owner->document()->ownerElement()));
+    return true;
+}
+#endif
+
 Document::~Document()
 {
     ASSERT(!renderer());
@@ -5365,15 +5378,7 @@
 bool Document::fullScreenIsAllowedForElement(Element* element) const
 {
     ASSERT(element);
-    while (HTMLFrameOwnerElement* ownerElement = element->document()->ownerElement()) {
-        if (!ownerElement->isFrameElementBase())
-            continue;
-
-        if (!static_cast<HTMLFrameElementBase*>(ownerElement)->allowFullScreen())
-            return false;
-        element = ownerElement;
-    }
-    return true;
+    return isAttributeOnAllOwners(webkitallowfullscreenAttr, element->document()->ownerElement());
 }
 
 void Document::requestFullScreenForElement(Element* element, unsigned short flags, FullScreenCheckType checkType)
@@ -5582,19 +5587,7 @@
     // browsing context's documents have their fullscreen enabled flag set, or false otherwise.
 
     // Top-level browsing contexts are implied to have their allowFullScreen attribute set.
-    HTMLFrameOwnerElement* owner = ownerElement();
-    if (!owner)
-        return true;
-
-    do {
-        if (!owner->isFrameElementBase())
-            continue;
-
-        if (!static_cast<HTMLFrameElementBase*>(owner)->allowFullScreen())
-            return false;
-    } while ((owner = owner->document()->ownerElement()));
-
-    return true;        
+    return isAttributeOnAllOwners(webkitallowfullscreenAttr, ownerElement());
 }
 
 void Document::webkitWillEnterFullScreenForElement(Element* element)

Modified: trunk/Source/WebCore/html/HTMLFrameElementBase.cpp (123004 => 123005)


--- trunk/Source/WebCore/html/HTMLFrameElementBase.cpp	2012-07-18 20:01:46 UTC (rev 123004)
+++ trunk/Source/WebCore/html/HTMLFrameElementBase.cpp	2012-07-18 20:06:12 UTC (rev 123005)
@@ -246,11 +246,4 @@
     return renderBox()->height();
 }
 
-#if ENABLE(FULLSCREEN_API)
-bool HTMLFrameElementBase::allowFullScreen() const
-{
-    return hasAttribute(webkitallowfullscreenAttr);
-}
-#endif
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLFrameElementBase.h (123004 => 123005)


--- trunk/Source/WebCore/html/HTMLFrameElementBase.h	2012-07-18 20:01:46 UTC (rev 123004)
+++ trunk/Source/WebCore/html/HTMLFrameElementBase.h	2012-07-18 20:06:12 UTC (rev 123005)
@@ -42,10 +42,6 @@
     int width();
     int height();
 
-#if ENABLE(FULLSCREEN_API)
-    virtual bool allowFullScreen() const;
-#endif
-
     virtual bool canContainRangeEndPoint() const { return false; }
 
 protected:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to