Commit 35ba3e38 authored by philipj@opera.com's avatar philipj@opera.com

Remove the fullscreen element stack exemption for webkitRequestFullScreen()

This exemption allowed the fullscreen element stack to get into a state
not otherwise possible, namely with elements in any order as opposed to
in tree order. It also seemed possible to enter fullscreen in a sibling
iframe, leading to a (cross-document) set of fullscreen elements forming
a tree instead of a simple chain, a case without any test coverage.

Removing the exemption means that a webkitfullscreenerror event will be
fired if one is already in fullscreen and requests fullscreen for an
element other than a descendant of the current fullscreen element.

The use counter was intended to tell whether any content depends on this
or not, but data will not be available for a long time yet. In order to
be affected one needs to, in fullscreen, have a currently visible button
request fullscreen for an element currently not visible, which seems
far-fetched, so site compat is probably not a problem.

The use counter for webkitRequestFullScreen() provides an upper bound:
http://www.chromestatus.com/metrics/feature/timeline/popularity/177

BUG=383813

Review URL: https://codereview.chromium.org/458223003

git-svn-id: svn://svn.chromium.org/blink/trunk@180243 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 28226399
...@@ -2,14 +2,14 @@ EXPECTED (document.defaultView.getComputedStyle(span, null).getPropertyValue('ba ...@@ -2,14 +2,14 @@ EXPECTED (document.defaultView.getComputedStyle(span, null).getPropertyValue('ba
EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color') == 'rgba(0, 0, 0, 0)') OK EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color') == 'rgba(0, 0, 0, 0)') OK
EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color') == 'rgb(0, 0, 0)') OK EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color') == 'rgb(0, 0, 0)') OK
EVENT(webkitfullscreenchange) EVENT(webkitfullscreenchange)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLSpanElement]') OK
EXPECTED (document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color') == 'rgb(0, 255, 0)') OK
EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color') == 'rgb(255, 0, 0)') OK
EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color') == 'rgb(0, 0, 255)') OK
EVENT(webkitfullscreenchange)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLHtmlElement]') OK EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLHtmlElement]') OK
EXPECTED (document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color') == 'rgba(0, 0, 0, 0)') OK EXPECTED (document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color') == 'rgba(0, 0, 0, 0)') OK
EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color') == 'rgb(0, 255, 0)') OK EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color') == 'rgb(0, 255, 0)') OK
EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color') == 'rgb(0, 0, 255)') OK EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color') == 'rgb(0, 0, 255)') OK
EVENT(webkitfullscreenchange)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLSpanElement]') OK
EXPECTED (document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color') == 'rgb(0, 255, 0)') OK
EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color') == 'rgb(255, 0, 0)') OK
EXPECTED (document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color') == 'rgb(0, 0, 255)') OK
END OF TEST END OF TEST
...@@ -18,33 +18,32 @@ ...@@ -18,33 +18,32 @@
if (callback) if (callback)
callback(event) callback(event)
}; };
waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged); waitForEvent(document, "webkitfullscreenchange", fullscreenChanged);
var span = document.getElementsByTagName("span")[0];
var span = document.getElementsByTagName('span')[0];
testExpected("document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color')", "rgba(0, 0, 0, 0)"); testExpected("document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color')", "rgba(0, 0, 0, 0)");
testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color')", "rgba(0, 0, 0, 0)"); testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color')", "rgba(0, 0, 0, 0)");
testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color')", "rgb(0, 0, 0)"); testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color')", "rgb(0, 0, 0)");
var spanEnteredFullScreen = function(event) {
testExpected("document.webkitCurrentFullScreenElement", span);
testExpected("document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color')", "rgb(0, 255, 0)");
testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color')", "rgb(255, 0, 0)");
testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color')", "rgb(0, 0, 255)");
callback = documentEnteredFullScreen;
runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()});
};
var documentEnteredFullScreen = function(event) { var documentEnteredFullScreen = function(event) {
testExpected("document.webkitCurrentFullScreenElement", document.documentElement); testExpected("document.webkitCurrentFullScreenElement", document.documentElement);
testExpected("document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color')", "rgba(0, 0, 0, 0)"); testExpected("document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color')", "rgba(0, 0, 0, 0)");
testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color')", "rgb(0, 255, 0)"); testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color')", "rgb(0, 255, 0)");
testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color')", "rgb(0, 0, 255)"); testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color')", "rgb(0, 0, 255)");
callback = spanEnteredFullScreen;
runWithKeyDown(function(){span.webkitRequestFullScreen()});
};
var spanEnteredFullScreen = function(event) {
testExpected("document.webkitCurrentFullScreenElement", span);
testExpected("document.defaultView.getComputedStyle(span, null).getPropertyValue('background-color')", "rgb(0, 255, 0)");
testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('background-color')", "rgb(255, 0, 0)");
testExpected("document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue('color')", "rgb(0, 0, 255)");
endTest(); endTest();
}; };
callback = spanEnteredFullScreen; callback = documentEnteredFullScreen;
runWithKeyDown(function(){span.webkitRequestFullScreen()}); runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()});
} }
</script> </script>
EVENT(webkitfullscreenchange) EVENT(webkitfullscreenchange)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLSpanElement]') OK EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLSpanElement]') OK
EVENT(webkitfullscreenchange) EVENT(webkitfullscreenerror)
EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLHtmlElement]') OK
END OF TEST END OF TEST
...@@ -7,29 +7,15 @@ ...@@ -7,29 +7,15 @@
logResult(false, "Element.prototype.webkitRequestFullScreen == undefined"); logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
endTest(); endTest();
} else { } else {
var callback; var span = document.getElementsByTagName("span")[0];
var fullscreenChanged = function(event)
{
if (callback)
callback(event)
};
waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
var span = document.getElementsByTagName('span')[0];
var spanEnteredFullScreen = function() { var spanEnteredFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", span); testExpected("document.webkitCurrentFullScreenElement", span);
callback = documentEnteredFullScreen; waitForEventAndEnd(document, "webkitfullscreenerror");
runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()}); runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()});
}; };
var documentEnteredFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", document.documentElement);
callback = null;
endTest();
};
callback = spanEnteredFullScreen; waitForEvent(document, "webkitfullscreenchange", spanEnteredFullScreen);
runWithKeyDown(function(){span.webkitRequestFullScreen()}); runWithKeyDown(function(){span.webkitRequestFullScreen()});
} }
</script> </script>
...@@ -186,15 +186,11 @@ bool FullscreenElementStack::elementReady(Element& element, RequestType requestT ...@@ -186,15 +186,11 @@ bool FullscreenElementStack::elementReady(Element& element, RequestType requestT
return false; return false;
} }
// element's node document fullscreen element stack is either empty or its top element is an // element's node document's fullscreen element stack is either empty or its top element is an
// ancestor of element. // ancestor of element.
if (Element* lastElementOnStack = fullscreenElementFrom(element.document())) { if (Element* topElement = fullscreenElementFrom(element.document())) {
if (!element.isDescendantOf(lastElementOnStack)) { if (!element.isDescendantOf(topElement))
if (requestType == PrefixedMozillaRequest || requestType == PrefixedMozillaAllowKeyboardInputRequest) return false;
UseCounter::count(element.document(), UseCounter::LegacyFullScreenErrorExemption);
else
return false;
}
} }
// element has no ancestor element whose local name is iframe and namespace is the HTML // element has no ancestor element whose local name is iframe and namespace is the HTML
......
...@@ -453,7 +453,6 @@ public: ...@@ -453,7 +453,6 @@ public:
KeyEventNotAllowedInFullScreen = 474, KeyEventNotAllowedInFullScreen = 474,
DOMWindowOpen = 475, DOMWindowOpen = 475,
DOMWindowOpenFeatures = 476, DOMWindowOpenFeatures = 476,
LegacyFullScreenErrorExemption = 477,
MediaStreamTrackGetSources = 478, MediaStreamTrackGetSources = 478,
AspectRatioFlexItem = 479, AspectRatioFlexItem = 479,
DetailsElement = 480, DetailsElement = 480,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment