- Revision
- 122816
- Author
- [email protected]
- Date
- 2012-07-17 00:26:52 -0700 (Tue, 17 Jul 2012)
Log Message
HTMLMediaElement should not use Element::ensureShadowRoot()
https://bugs.webkit.org/show_bug.cgi?id=77936
Reviewed by Hajime Morita.
Source/WebCore:
a video element and an audio element add UserAgentShadowRoot dynamically, and they assume that it's the oldest ShadowRoot.
However an AuthorShadowRoot could be added by a user before a video element and an audio element add UserAgentShadowRoot.
It breaks the assumption that the UserAgentShadowRoot is the oldest.
If the UserAgentShadowRoot is not the oldest, the AuthorShadowRoot a page author added might be ignored.
Since the timing to add UserAgentShadowRoot is not known by a user, the fact that UserAgentShadorRoot is
not the oldest will cause inconsistent behavior.
Adding AuthorShadowRoot to a video element and an audio element is allowed by this patch.
Test: fast/dom/shadow/shadowdom-for-media.html
* dom/ShadowRoot.cpp:
(WebCore::allowsAuthorShadowRoot):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::createShadowSubtree):
(WebCore):
(WebCore::HTMLMediaElement::willAddAuthorShadowRoot):
(WebCore::HTMLMediaElement::createMediaControls):
* html/HTMLMediaElement.h:
(HTMLMediaElement):
LayoutTests:
Adding Shadow DOM to a video element and an audio element is allowed now.
* fast/dom/shadow/shadow-disable-expected.txt:
* fast/dom/shadow/shadow-disable.html:
* fast/dom/shadow/shadowdom-for-media-expected.txt: Added.
* fast/dom/shadow/shadowdom-for-media.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (122815 => 122816)
--- trunk/LayoutTests/ChangeLog 2012-07-17 07:23:18 UTC (rev 122815)
+++ trunk/LayoutTests/ChangeLog 2012-07-17 07:26:52 UTC (rev 122816)
@@ -1,3 +1,17 @@
+2012-07-17 Shinya Kawanaka <[email protected]>
+
+ HTMLMediaElement should not use Element::ensureShadowRoot()
+ https://bugs.webkit.org/show_bug.cgi?id=77936
+
+ Reviewed by Hajime Morita.
+
+ Adding Shadow DOM to a video element and an audio element is allowed now.
+
+ * fast/dom/shadow/shadow-disable-expected.txt:
+ * fast/dom/shadow/shadow-disable.html:
+ * fast/dom/shadow/shadowdom-for-media-expected.txt: Added.
+ * fast/dom/shadow/shadowdom-for-media.html: Added.
+
2012-07-17 Yoshifumi Inoue <[email protected]>
[Forms] Test expectations of datetime/datetime-local/time should not contain milliseconds when they aren't expected
Modified: trunk/LayoutTests/fast/dom/shadow/shadow-disable-expected.txt (122815 => 122816)
--- trunk/LayoutTests/fast/dom/shadow/shadow-disable-expected.txt 2012-07-17 07:23:18 UTC (rev 122815)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-disable-expected.txt 2012-07-17 07:26:52 UTC (rev 122816)
@@ -11,16 +11,16 @@
PASS new WebKitShadowRoot(element) is not null
SECTION
PASS new WebKitShadowRoot(element) is not null
+AUDIO
+PASS new WebKitShadowRoot(element) is not null
+VIDEO
+PASS new WebKitShadowRoot(element) is not null
INPUT
PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
TEXTAREA
PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
SELECT
PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
-AUDIO
-PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
-VIDEO
-PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
tref
PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
PASS successfullyParsed is true
Modified: trunk/LayoutTests/fast/dom/shadow/shadow-disable.html (122815 => 122816)
--- trunk/LayoutTests/fast/dom/shadow/shadow-disable.html 2012-07-17 07:23:18 UTC (rev 122815)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-disable.html 2012-07-17 07:26:52 UTC (rev 122816)
@@ -23,15 +23,15 @@
document.createElement('div'),
document.createElement('span'),
document.createElement('a'),
- document.createElement('section')
+ document.createElement('section'),
+ document.createElement('audio'),
+ document.createElement('video')
];
var elementsToFail = [
document.createElement('input'),
document.createElement('textarea'),
document.createElement('select'),
- document.createElement('audio'),
- document.createElement('video'),
document.getElementById('tref')
];
Added: trunk/LayoutTests/fast/dom/shadow/shadowdom-for-media-expected.txt (0 => 122816)
--- trunk/LayoutTests/fast/dom/shadow/shadowdom-for-media-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadowdom-for-media-expected.txt 2012-07-17 07:26:52 UTC (rev 122816)
@@ -0,0 +1,9 @@
+
+PASS shadowRootForVideoWithControls is youngerShadowRootForVideoWithControls
+PASS shadowRootForVideoWithControls is not oldestShadowRootForVideoWithControls
+PASS shadowRootForVideoWithoutControls is youngerShadowRootForVideoWithoutControls
+PASS shadowRootForVideoWithoutControls is not oldestShadowRootForVideoWithoutControls
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/shadow/shadowdom-for-media.html (0 => 122816)
--- trunk/LayoutTests/fast/dom/shadow/shadowdom-for-media.html (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadowdom-for-media.html 2012-07-17 07:26:52 UTC (rev 122816)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+
+<div id="container">
+<video id='videoWithControls' controls width="320" height="240"></video>
+<video id='videoWithoutControls' width="320" height="240"></video>
+</div>
+<pre id="console"></pre>
+
+<script>
+function addShadowDOM(host) {
+ var shadowRoot = new WebKitShadowRoot(host);
+ shadowRoot.innerHTML = "<div style='margin: 10px'><shadow></shadow></div>"
+ return shadowRoot;
+}
+
+var shadowRootForVideoWithControls = addShadowDOM(videoWithControls);
+var oldestShadowRootForVideoWithControls = internals.oldestShadowRoot(videoWithControls);
+var youngerShadowRootForVideoWithControls = internals.youngerShadowRoot(oldestShadowRootForVideoWithControls);
+
+var shadowRootForVideoWithoutControls = addShadowDOM(videoWithoutControls);
+var oldestShadowRootForVideoWithoutControls = internals.oldestShadowRoot(videoWithoutControls);
+var youngerShadowRootForVideoWithoutControls = internals.youngerShadowRoot(oldestShadowRootForVideoWithoutControls);
+
+
+shouldBe("shadowRootForVideoWithControls", "youngerShadowRootForVideoWithControls");
+shouldNotBe("shadowRootForVideoWithControls", "oldestShadowRootForVideoWithControls");
+shouldBe("shadowRootForVideoWithoutControls", "youngerShadowRootForVideoWithoutControls");
+shouldNotBe("shadowRootForVideoWithoutControls", "oldestShadowRootForVideoWithoutControls");
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
+
Modified: trunk/Source/WebCore/ChangeLog (122815 => 122816)
--- trunk/Source/WebCore/ChangeLog 2012-07-17 07:23:18 UTC (rev 122815)
+++ trunk/Source/WebCore/ChangeLog 2012-07-17 07:26:52 UTC (rev 122816)
@@ -1,3 +1,32 @@
+2012-07-17 Shinya Kawanaka <[email protected]>
+
+ HTMLMediaElement should not use Element::ensureShadowRoot()
+ https://bugs.webkit.org/show_bug.cgi?id=77936
+
+ Reviewed by Hajime Morita.
+
+ a video element and an audio element add UserAgentShadowRoot dynamically, and they assume that it's the oldest ShadowRoot.
+ However an AuthorShadowRoot could be added by a user before a video element and an audio element add UserAgentShadowRoot.
+ It breaks the assumption that the UserAgentShadowRoot is the oldest.
+
+ If the UserAgentShadowRoot is not the oldest, the AuthorShadowRoot a page author added might be ignored.
+ Since the timing to add UserAgentShadowRoot is not known by a user, the fact that UserAgentShadorRoot is
+ not the oldest will cause inconsistent behavior.
+
+ Adding AuthorShadowRoot to a video element and an audio element is allowed by this patch.
+
+ Test: fast/dom/shadow/shadowdom-for-media.html
+
+ * dom/ShadowRoot.cpp:
+ (WebCore::allowsAuthorShadowRoot):
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::createShadowSubtree):
+ (WebCore):
+ (WebCore::HTMLMediaElement::willAddAuthorShadowRoot):
+ (WebCore::HTMLMediaElement::createMediaControls):
+ * html/HTMLMediaElement.h:
+ (HTMLMediaElement):
+
2012-07-16 Daniel Bates <[email protected]>
Attempt to fix the Chromium Mac build after <http://trac.webkit.org/changeset/122802>
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (122815 => 122816)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2012-07-17 07:23:18 UTC (rev 122815)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2012-07-17 07:26:52 UTC (rev 122816)
@@ -75,11 +75,6 @@
static bool allowsAuthorShadowRoot(Element* element)
{
- // FIXME: MEDIA recreates shadow root dynamically.
- // https://bugs.webkit.org/show_bug.cgi?id=77936
- if (element->hasTagName(HTMLNames::videoTag) || element->hasTagName(HTMLNames::audioTag))
- return false;
-
// FIXME: ValidationMessage recreates shadow root dynamically.
// https://bugs.webkit.org/show_bug.cgi?id=77937
// Especially, INPUT recreates shadow root dynamically.
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (122815 => 122816)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2012-07-17 07:23:18 UTC (rev 122815)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2012-07-17 07:26:52 UTC (rev 122816)
@@ -1860,6 +1860,24 @@
}
}
+void HTMLMediaElement::createShadowSubtree()
+{
+ ASSERT(!shadow() || !shadow()->oldestShadowRoot());
+
+ ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
+}
+
+void HTMLMediaElement::willAddAuthorShadowRoot()
+{
+ ASSERT(shadow());
+ if (shadow()->oldestShadowRoot()) {
+ ASSERT(shadow()->oldestShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot);
+ return;
+ }
+
+ createShadowSubtree();
+}
+
void HTMLMediaElement::rewind(float timeDelta)
{
LOG(Media, "HTMLMediaElement::rewind(%f)", timeDelta);
@@ -4190,7 +4208,11 @@
if (isFullscreen())
controls->enteredFullscreen();
- ensureShadowRoot()->appendChild(controls, ec);
+ if (!shadow())
+ createShadowSubtree();
+
+ ASSERT(shadow()->oldestShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot);
+ shadow()->oldestShadowRoot()->appendChild(controls, ec);
return true;
}
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (122815 => 122816)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2012-07-17 07:23:18 UTC (rev 122815)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2012-07-17 07:26:52 UTC (rev 122816)
@@ -83,7 +83,10 @@
{
public:
MediaPlayer* player() const { return m_player.get(); }
-
+
+ void createShadowSubtree();
+ virtual void willAddAuthorShadowRoot() OVERRIDE;
+
virtual bool isVideo() const = 0;
virtual bool hasVideo() const { return false; }
virtual bool hasAudio() const;