Changeset 276679 in webkit


Ignore:
Timestamp:
Apr 27, 2021 4:40:17 PM (15 months ago)
Author:
Cameron McCormack
Message:

Associate a picture element with an img only if the img is a direct child.
https://bugs.webkit.org/show_bug.cgi?id=225044

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/embedded-content/the-img-element/img-picture-ancestor-expected.txt: Added.
  • web-platform-tests/html/semantics/embedded-content/the-img-element/img-picture-ancestor.html: Added.

Source/WebCore:

Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/img-picture-ancestor.html

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::insertedIntoAncestor):
(WebCore::HTMLImageElement::removedFromAncestor):

  • html/parser/HTMLConstructionSite.cpp:

(WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface):

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r276656 r276679  
     12021-04-27  Cameron McCormack  <heycam@apple.com>
     2
     3        Associate a picture element with an img only if the img is a direct child.
     4        https://bugs.webkit.org/show_bug.cgi?id=225044
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * web-platform-tests/html/semantics/embedded-content/the-img-element/img-picture-ancestor-expected.txt: Added.
     9        * web-platform-tests/html/semantics/embedded-content/the-img-element/img-picture-ancestor.html: Added.
     10
    1112021-04-27  Alexey Shvayka  <shvaikalesh@gmail.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r276678 r276679  
     12021-04-27  Cameron McCormack  <heycam@apple.com>
     2
     3        Associate a picture element with an img only if the img is a direct child.
     4        https://bugs.webkit.org/show_bug.cgi?id=225044
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/img-picture-ancestor.html
     9
     10        * html/HTMLImageElement.cpp:
     11        (WebCore::HTMLImageElement::insertedIntoAncestor):
     12        (WebCore::HTMLImageElement::removedFromAncestor):
     13        * html/parser/HTMLConstructionSite.cpp:
     14        (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface):
     15
    1162021-04-27  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r275076 r276679  
    383383        treeScope().addImageElementByUsemap(*m_parsedUsemap.impl(), *this);
    384384
    385     if (is<HTMLPictureElement>(&parentOfInsertedTree)) {
     385    if (is<HTMLPictureElement>(&parentOfInsertedTree) && &parentOfInsertedTree == parentElement()) {
     386        // FIXME: When the hack in HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface to eagerly call setPictureElement is removed, we can just assert !pictureElement().
     387        ASSERT(!pictureElement() || pictureElement() == &parentOfInsertedTree);
    386388        setPictureElement(&downcast<HTMLPictureElement>(parentOfInsertedTree));
     389        // FIXME: We should unconditionally call selectImageSource so that source selection is performed even for <img> elements outside the document.
    387390        if (insertionType.connectedToDocument) {
    388391            selectImageSource(RelevantMutation::Yes);
     
    412415        oldParentOfRemovedTree.treeScope().removeImageElementByUsemap(*m_parsedUsemap.impl(), *this);
    413416
    414     if (is<HTMLPictureElement>(oldParentOfRemovedTree)) {
     417    if (is<HTMLPictureElement>(oldParentOfRemovedTree) && !parentElement()) {
     418        ASSERT(pictureElement() == &oldParentOfRemovedTree);
    415419        setPictureElement(nullptr);
     420        // FIXME: We should call selectImageSource so that source selection is performed, now that we no longer have a <picture> context.
    416421        m_imageLoader->updateFromElementIgnoringPreviousError(RelevantMutation::Yes);
    417422    }
  • trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp

    r259523 r276679  
    696696    // FIXME: This is a hack to connect images to pictures before the image has
    697697    // been inserted into the document. It can be removed once asynchronous image
    698     // loading is working.
     698    // loading is working. When this hack is removed, the assertion just before
     699    // the setPictureElement() call in HTMLImageElement::insertedIntoAncestor
     700    // can be simplified.
    699701    if (is<HTMLPictureElement>(currentNode()) && is<HTMLImageElement>(*element))
    700702        downcast<HTMLImageElement>(*element).setPictureElement(&downcast<HTMLPictureElement>(currentNode()));
Note: See TracChangeset for help on using the changeset viewer.