Changeset 122816 in webkit


Ignore:
Timestamp:
Jul 17, 2012 12:26:52 AM (12 years ago)
Author:
shinyak@chromium.org
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.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r122815 r122816  
     12012-07-17  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        HTMLMediaElement should not use Element::ensureShadowRoot()
     4        https://bugs.webkit.org/show_bug.cgi?id=77936
     5
     6        Reviewed by Hajime Morita.
     7
     8        Adding Shadow DOM to a video element and an audio element is allowed now.
     9
     10        * fast/dom/shadow/shadow-disable-expected.txt:
     11        * fast/dom/shadow/shadow-disable.html:
     12        * fast/dom/shadow/shadowdom-for-media-expected.txt: Added.
     13        * fast/dom/shadow/shadowdom-for-media.html: Added.
     14
    1152012-07-17  Yoshifumi Inoue  <yosin@chromium.org>
    216
  • trunk/LayoutTests/fast/dom/shadow/shadow-disable-expected.txt

    r107202 r122816  
    1212SECTION
    1313PASS new WebKitShadowRoot(element) is not null
     14AUDIO
     15PASS new WebKitShadowRoot(element) is not null
     16VIDEO
     17PASS new WebKitShadowRoot(element) is not null
    1418INPUT
    1519PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
     
    1721PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
    1822SELECT
    19 PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
    20 AUDIO
    21 PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
    22 VIDEO
    2323PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
    2424tref
  • trunk/LayoutTests/fast/dom/shadow/shadow-disable.html

    r107202 r122816  
    2424    document.createElement('span'),
    2525    document.createElement('a'),
    26     document.createElement('section')
     26    document.createElement('section'),
     27    document.createElement('audio'),
     28    document.createElement('video')
    2729];
    2830
     
    3133    document.createElement('textarea'),
    3234    document.createElement('select'),
    33     document.createElement('audio'),
    34     document.createElement('video'),
    3535    document.getElementById('tref')
    3636];
  • trunk/Source/WebCore/ChangeLog

    r122812 r122816  
     12012-07-17  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        HTMLMediaElement should not use Element::ensureShadowRoot()
     4        https://bugs.webkit.org/show_bug.cgi?id=77936
     5
     6        Reviewed by Hajime Morita.
     7
     8        a video element and an audio element add UserAgentShadowRoot dynamically, and they assume that it's the oldest ShadowRoot.
     9        However an AuthorShadowRoot could be added by a user before a video element and an audio element add UserAgentShadowRoot.
     10        It breaks the assumption that the UserAgentShadowRoot is the oldest.
     11
     12        If the UserAgentShadowRoot is not the oldest, the AuthorShadowRoot a page author added might be ignored.
     13        Since the timing to add UserAgentShadowRoot is not known by a user, the fact that UserAgentShadorRoot is
     14        not the oldest will cause inconsistent behavior.
     15
     16        Adding AuthorShadowRoot to a video element and an audio element is allowed by this patch.
     17
     18        Test: fast/dom/shadow/shadowdom-for-media.html
     19
     20        * dom/ShadowRoot.cpp:
     21        (WebCore::allowsAuthorShadowRoot):
     22        * html/HTMLMediaElement.cpp:
     23        (WebCore::HTMLMediaElement::createShadowSubtree):
     24        (WebCore):
     25        (WebCore::HTMLMediaElement::willAddAuthorShadowRoot):
     26        (WebCore::HTMLMediaElement::createMediaControls):
     27        * html/HTMLMediaElement.h:
     28        (HTMLMediaElement):
     29
    1302012-07-16  Daniel Bates  <dbates@webkit.org>
    231
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r122530 r122816  
    7676static bool allowsAuthorShadowRoot(Element* element)
    7777{
    78     // FIXME: MEDIA recreates shadow root dynamically.
    79     // https://bugs.webkit.org/show_bug.cgi?id=77936
    80     if (element->hasTagName(HTMLNames::videoTag) || element->hasTagName(HTMLNames::audioTag))
    81         return false;
    82 
    8378    // FIXME: ValidationMessage recreates shadow root dynamically.
    8479    // https://bugs.webkit.org/show_bug.cgi?id=77937
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r122787 r122816  
    18611861}
    18621862
     1863void HTMLMediaElement::createShadowSubtree()
     1864{
     1865    ASSERT(!shadow() || !shadow()->oldestShadowRoot());
     1866
     1867    ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
     1868}
     1869
     1870void HTMLMediaElement::willAddAuthorShadowRoot()
     1871{
     1872    ASSERT(shadow());
     1873    if (shadow()->oldestShadowRoot()) {
     1874        ASSERT(shadow()->oldestShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot);
     1875        return;
     1876    }
     1877
     1878    createShadowSubtree();
     1879}
     1880
    18631881void HTMLMediaElement::rewind(float timeDelta)
    18641882{
     
    41914209        controls->enteredFullscreen();
    41924210
    4193     ensureShadowRoot()->appendChild(controls, ec);
     4211    if (!shadow())
     4212        createShadowSubtree();
     4213
     4214    ASSERT(shadow()->oldestShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot);
     4215    shadow()->oldestShadowRoot()->appendChild(controls, ec);
    41944216    return true;
    41954217}
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r122676 r122816  
    8484public:
    8585    MediaPlayer* player() const { return m_player.get(); }
    86    
     86
     87    void createShadowSubtree();
     88    virtual void willAddAuthorShadowRoot() OVERRIDE;
     89
    8790    virtual bool isVideo() const = 0;
    8891    virtual bool hasVideo() const { return false; }
Note: See TracChangeset for help on using the changeset viewer.