⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 136131 in webkit


Ignore:
Timestamp:
Nov 29, 2012, 7:33:03 AM (14 years ago)
Author:
morrita@google.com
Message:

Source/WebCore: HTMLMediaElement's .textTracks property does not reflect <track> element
​https://bugs.webkit.org/show_bug.cgi?id=103420

Reviewed by Eric Carlson.

There were some assumptions that <track> elements are valid only
if the parent <media> is in document. This change relaxes this
assumption so that <track> is valid when it has <media> as a
parent regardless whether the <media> is in the document or not.

HTMLMediaElement::didAddTrack and didRemoveTrack are now called
when the <track> is inserted to or removed from the parent <media>
element.

Test: media/track/track-node-add-remove.html

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::didRemoveTrack):
Renamed from willRemoveTrack() to reflect the timing. This was once called from
Node::willRemove(), which was removed a while ago.

  • html/HTMLMediaElement.h:

(HTMLMediaElement):

  • html/HTMLTrackElement.cpp:

(WebCore::HTMLTrackElement::insertedInto):
The old code notified parent <media> only if the subtree became a part of the document.
Now it notifies the <media> when this <track> becomes a child of that <media>.

(WebCore::HTMLTrackElement::removedFrom):
The old code notifies the parent <media> every time as long as the parent is available.
Now it notifies the <media> only if this <track> is removed from the parent <media>.
This matches how corresponding notification is done in insertedInto().

  • html/track/LoadableTextTrack.cpp:

(WebCore::LoadableTextTrack::trackElementIndex):

LayoutTests: HTMLMediaElement's .textTracks property does not reflect <track> element
​https://bugs.webkit.org/show_bug.cgi?id=103420

Reviewed by Eric Carlson.

  • media/track/track-node-add-remove-expected.txt: Added.
  • media/track/track-node-add-remove.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r136130 r136131  
     12012-11-29  Hajime Morrita  <morrita@google.com>
     2
     3        HTMLMediaElement's .textTracks property does not reflect <track> element
     4        https://bugs.webkit.org/show_bug.cgi?id=103420
     5       
     6        Reviewed by Eric Carlson.
     7
     8        * media/track/track-node-add-remove-expected.txt: Added.
     9        * media/track/track-node-add-remove.html: Added.
     10
    1112012-11-29  Alexander Pavlov  <apavlov@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r136125 r136131  
     12012-11-29  Hajime Morrita  <morrita@google.com>
     2
     3        HTMLMediaElement's .textTracks property does not reflect <track> element
     4        https://bugs.webkit.org/show_bug.cgi?id=103420
     5
     6        Reviewed by Eric Carlson.
     7
     8        There were some assumptions that <track> elements are valid only
     9        if the parent <media> is in document. This change relaxes this
     10        assumption so that <track> is valid when it has <media> as a
     11        parent regardless whether the <media> is in the document or not.
     12
     13        HTMLMediaElement::didAddTrack and didRemoveTrack are now called
     14        when the <track> is inserted to or removed from the parent <media>
     15        element.
     16
     17        Test: media/track/track-node-add-remove.html
     18
     19        * html/HTMLMediaElement.cpp:
     20        (WebCore::HTMLMediaElement::didRemoveTrack):
     21        Renamed from willRemoveTrack() to reflect the timing. This was once called from
     22        Node::willRemove(), which was removed a while ago.
     23        * html/HTMLMediaElement.h:
     24        (HTMLMediaElement):
     25        * html/HTMLTrackElement.cpp:
     26        (WebCore::HTMLTrackElement::insertedInto):
     27        The old code notified parent <media> only if the subtree became a part of the document.
     28        Now it notifies the <media> when this <track> becomes a child of that <media>.
     29
     30        (WebCore::HTMLTrackElement::removedFrom):
     31        The old code notifies the parent <media> every time as long as the parent is available.
     32        Now it notifies the <media> only if this <track> is removed from the parent <media>.
     33        This matches how corresponding notification is done in insertedInto().
     34
     35        * html/track/LoadableTextTrack.cpp:
     36        (WebCore::LoadableTextTrack::trackElementIndex):
     37
    1382012-11-29  Florin Malita  <fmalita@chromium.org>
    239
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r135934 r136131  
    28422842}
    28432843
    2844 void HTMLMediaElement::willRemoveTrack(HTMLTrackElement* trackElement)
     2844void HTMLMediaElement::didRemoveTrack(HTMLTrackElement* trackElement)
    28452845{
    28462846    ASSERT(trackElement->hasTagName(trackTag));
    … …  
    28522852    if (trackElement->hasTagName(trackTag)) {
    28532853        KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
    2854         LOG(Media, "HTMLMediaElement::willRemoveTrack - 'src' is %s", urlForLogging(url).utf8().data());
     2854        LOG(Media, "HTMLMediaElement::didRemoveTrack - 'src' is %s", urlForLogging(url).utf8().data());
    28552855    }
    28562856#endif
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r135934 r136131  
    222222
    223223    virtual void didAddTrack(HTMLTrackElement*);
    224     virtual void willRemoveTrack(HTMLTrackElement*);
     224    virtual void didRemoveTrack(HTMLTrackElement*);
    225225
    226226    struct TrackGroup {
  • trunk/Source/WebCore/html/HTMLTrackElement.cpp

    r135202 r136131  
    7676{
    7777    HTMLElement::insertedInto(insertionPoint);
    78     if (insertionPoint->inDocument()) {
    79         if (HTMLMediaElement* parent = mediaElement())
    80             parent->didAddTrack(this);
    81     }
    82 
     78    HTMLMediaElement* parent = mediaElement();
     79    if (insertionPoint == parent)
     80        parent->didAddTrack(this);
    8381    return InsertionDone;
    8482}
    … …  
    8684void HTMLTrackElement::removedFrom(ContainerNode* insertionPoint)
    8785{
    88     HTMLMediaElement* parent = mediaElement();
    89     if (!parent && WebCore::isMediaElement(insertionPoint))
    90         parent = toMediaElement(insertionPoint);
    91     if (parent)
    92         parent->willRemoveTrack(this);
    93 
     86    if (!parentNode() && WebCore::isMediaElement(insertionPoint))
     87        toMediaElement(insertionPoint)->didRemoveTrack(this);
    9488    HTMLElement::removedFrom(insertionPoint);
    9589}
  • trunk/Source/WebCore/html/track/LoadableTextTrack.cpp

    r135202 r136131  
    131131    size_t index = 0;
    132132    for (Node* node = m_trackElement->parentNode()->firstChild(); node; node = node->nextSibling()) {
    133         if (!node->hasTagName(trackTag) || !node->inDocument())
     133        if (!node->hasTagName(trackTag) || !node->parentNode())
    134134            continue;
    135135        if (node == m_trackElement)
Note: See TracChangeset for help on using the changeset viewer.