Changeset 223801 in webkit


Ignore:
Timestamp:
Oct 20, 2017 5:03:18 PM (7 years ago)
Author:
rniwa@webkit.org
Message:

Fix conditions in HTMLSourceElement and HTMLTrackElement's insertedInto and removedFrom
https://bugs.webkit.org/show_bug.cgi?id=178607

Reviewed by Eric Carlson.

Fixed the conditions in insertedInto and removedFrom of HTMLSourceElement and HTMLTrackElement to be
semantically sensisble. Since these elements are only functional when their immediate parents are
HTMLMediaElement and HTMLPictureElement, we have to check that its immediate parent changed, not when
some of its ancestor had changed by insertion or removal.

  • html/HTMLSourceElement.cpp:

(WebCore::HTMLSourceElement::insertedInto):
(WebCore::HTMLSourceElement::removedFrom):

  • html/HTMLTrackElement.cpp:

(WebCore::HTMLTrackElement::insertedInto):
(WebCore::HTMLTrackElement::removedFrom):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r223795 r223801  
     12017-10-20  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Fix conditions in HTMLSourceElement and HTMLTrackElement's insertedInto and removedFrom
     4        https://bugs.webkit.org/show_bug.cgi?id=178607
     5
     6        Reviewed by Eric Carlson.
     7
     8        Fixed the conditions in insertedInto and removedFrom of HTMLSourceElement and HTMLTrackElement to be
     9        semantically sensisble. Since these elements are only functional when their immediate parents are
     10        HTMLMediaElement and HTMLPictureElement, we have to check that its immediate parent changed, not when
     11        some of its ancestor had changed by insertion or removal.
     12
     13        * html/HTMLSourceElement.cpp:
     14        (WebCore::HTMLSourceElement::insertedInto):
     15        (WebCore::HTMLSourceElement::removedFrom):
     16        * html/HTMLTrackElement.cpp:
     17        (WebCore::HTMLTrackElement::insertedInto):
     18        (WebCore::HTMLTrackElement::removedFrom):
     19
    1202017-10-20  Keith Miller  <keith_miller@apple.com>
    221
  • trunk/Source/WebCore/html/HTMLSourceElement.cpp

    r223685 r223801  
    6767{
    6868    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
    69     // FIXME: This code is wrong if an ancestor of the parent had been inserted.
    70     if (auto* parent = parentElement()) {
     69    RefPtr<Element> parent = parentElement();
     70    if (parent == &parentOfInsertedTree) {
    7171#if ENABLE(VIDEO)
    7272        if (is<HTMLMediaElement>(*parent))
     
    8181
    8282void HTMLSourceElement::removedFrom(RemovalType removalType, ContainerNode& parentOfRemovedTree)
    83 {
    84     // FIXME: This code is wrong if an ancestor of the parent had been removed.
    85     RefPtr<Element> parent = parentElement();
    86     if (!parent && is<Element>(parentOfRemovedTree))
    87         parent = &downcast<Element>(parentOfRemovedTree);
    88     if (parent) {
     83{       
     84    HTMLElement::removedFrom(removalType, parentOfRemovedTree);
     85    if (!parentNode() && is<Element>(parentOfRemovedTree)) {
    8986#if ENABLE(VIDEO)
    90         if (is<HTMLMediaElement>(*parent))
    91             downcast<HTMLMediaElement>(*parent).sourceWasRemoved(*this);
     87        if (is<HTMLMediaElement>(parentOfRemovedTree))
     88            downcast<HTMLMediaElement>(parentOfRemovedTree).sourceWasRemoved(*this);
    9289        else
    9390#endif
    94         if (is<HTMLPictureElement>(*parent))
    95             downcast<HTMLPictureElement>(*parent).sourcesChanged();
     91        if (is<HTMLPictureElement>(parentOfRemovedTree))
     92            downcast<HTMLPictureElement>(parentOfRemovedTree).sourcesChanged();
    9693    }
    97     HTMLElement::removedFrom(removalType, parentOfRemovedTree);
    9894}
    9995
  • trunk/Source/WebCore/html/HTMLTrackElement.cpp

    r223685 r223801  
    8181    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
    8282
    83     // FIXME: This code is wrong. If HTMLTrackElement can be any descendent of HTMLMediaElement, then check ancestors of parentOfInsertedTree.
    84     // If HTMLMediaElement only supports HTMLTrackElement which is an immediate child, then check parentNode() instead.
    85     if (is<HTMLMediaElement>(parentOfInsertedTree))
     83    if (parentNode() == &parentOfInsertedTree && is<HTMLMediaElement>(parentOfInsertedTree)) {
    8684        downcast<HTMLMediaElement>(parentOfInsertedTree).didAddTextTrack(*this);
    87 
    88     // Since we've moved to a new parent, we may now be able to load.
    89     scheduleLoad();
     85        scheduleLoad();
     86    }
    9087
    9188    return InsertedIntoResult::Done;
     
    9693    HTMLElement::removedFrom(removalType, parentOfRemovedTree);
    9794
    98     // FIXME: This code is wrong. If HTMLTrackElement can be any descendent of HTMLMediaElement, then check ancestors of parentOfInsertedTree.
    99     // If HTMLMediaElement only supports HTMLTrackElement which is an immediate child, then check parentNode() instead.
    100     if (is<HTMLMediaElement>(parentOfRemovedTree))
     95    if (!parentNode() && is<HTMLMediaElement>(parentOfRemovedTree))
    10196        downcast<HTMLMediaElement>(parentOfRemovedTree).didRemoveTextTrack(*this);
    10297}
Note: See TracChangeset for help on using the changeset viewer.