Changeset 284667 in webkit


Ignore:
Timestamp:
Oct 21, 2021 10:05:42 PM (9 months ago)
Author:
cathiechen
Message:

The intrisic size of picture image inside a template is always zero
https://bugs.webkit.org/show_bug.cgi?id=227682

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

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

Source/WebCore:

When the picture element is inside a template element, it belongs to a template document which does not
have frame or RenderView, this would affect the source selection and size calculation. Though it calls
sourcesChanged to adjust the source in HTMLPictureElement::didMoveToNewDocument, but at this point
the image element is still inside the template document, so it does not help with this scenario. To
fix it, call sourcesChanged in HTMLImageElement::didMoveToNewDocument instead.

Test: fast/picture/picture-inside-template.html

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::didMoveToNewDocument):

  • html/HTMLPictureElement.cpp:

(WebCore::HTMLPictureElement::didMoveToNewDocument): Deleted.

  • html/HTMLPictureElement.h:

LayoutTests:

  • fast/picture/picture-inside-template-expected.txt: Added.
  • fast/picture/picture-inside-template.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r284665 r284667  
     12021-10-21  Cathie Chen  <cathiechen@igalia.com>
     2
     3        The intrisic size of picture image inside a template is always zero
     4        https://bugs.webkit.org/show_bug.cgi?id=227682
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/picture/picture-inside-template-expected.txt: Added.
     9        * fast/picture/picture-inside-template.html: Added.
     10
    1112021-10-21  Gabriel Nava Marino  <gnavamarino@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r284652 r284667  
     12021-10-21  Cathie Chen  <cathiechen@igalia.com>
     2
     3        The intrisic size of picture image inside a template is always zero
     4        https://bugs.webkit.org/show_bug.cgi?id=227682
     5
     6        Reviewed by Darin Adler.
     7
     8        * web-platform-tests/html/semantics/embedded-content/the-img-element/adoption-expected.txt:
     9
    1102021-10-21  Sihui Liu  <sihui_liu@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/adoption-expected.txt

    r267646 r284667  
    33
    44TIMEOUT img (src only) Test timed out
    5 TIMEOUT img (src only), parent is picture Test timed out
    6 TIMEOUT img (src only), previous sibling is source Test timed out
     5PASS img (src only), parent is picture
     6PASS img (src only), previous sibling is source
    77TIMEOUT img (srcset 1 cand) Test timed out
    8 TIMEOUT img (srcset 1 cand), parent is picture Test timed out
    9 TIMEOUT img (srcset 1 cand), previous sibling is source Test timed out
     8PASS img (srcset 1 cand), parent is picture
     9PASS img (srcset 1 cand), previous sibling is source
    1010FAIL adopt a cloned img in template assert_equals: expected "http://localhost:8800/images/green-1x1.png" but got "/images/green-1x1.png"
    1111PASS adoption is from appendChild
  • trunk/Source/WebCore/ChangeLog

    r284665 r284667  
     12021-10-21  Cathie Chen  <cathiechen@igalia.com>
     2
     3        The intrisic size of picture image inside a template is always zero
     4        https://bugs.webkit.org/show_bug.cgi?id=227682
     5
     6        Reviewed by Darin Adler.
     7
     8        When the picture element is inside a template element, it belongs to a template document which does not
     9        have frame or RenderView, this would affect the source selection and size calculation. Though it calls
     10        sourcesChanged to adjust the source in HTMLPictureElement::didMoveToNewDocument, but at this point
     11        the image element is still inside the template document, so it does not help with this scenario. To
     12        fix it, call sourcesChanged in HTMLImageElement::didMoveToNewDocument instead.
     13
     14        Test: fast/picture/picture-inside-template.html
     15
     16        * html/HTMLImageElement.cpp:
     17        (WebCore::HTMLImageElement::didMoveToNewDocument):
     18        * html/HTMLPictureElement.cpp:
     19        (WebCore::HTMLPictureElement::didMoveToNewDocument): Deleted.
     20        * html/HTMLPictureElement.h:
     21
    1222021-10-21  Gabriel Nava Marino  <gnavamarino@apple.com>
    223
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r284093 r284667  
    682682    m_imageLoader->elementDidMoveToNewDocument(oldDocument);
    683683    HTMLElement::didMoveToNewDocument(oldDocument, newDocument);
     684    if (RefPtr element = pictureElement())
     685        element->sourcesChanged();
    684686}
    685687
  • trunk/Source/WebCore/html/HTMLPictureElement.cpp

    r279108 r284667  
    4848}
    4949
    50 void HTMLPictureElement::didMoveToNewDocument(Document& oldDocument, Document& newDocument)
    51 {
    52     HTMLElement::didMoveToNewDocument(oldDocument, newDocument);
    53     sourcesChanged();
    54 }
    55 
    5650Ref<HTMLPictureElement> HTMLPictureElement::create(const QualifiedName& tagName, Document& document)
    5751{
  • trunk/Source/WebCore/html/HTMLPictureElement.h

    r279108 r284667  
    4545private:
    4646    HTMLPictureElement(const QualifiedName&, Document&);
    47 
    48     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
    4947};
    5048
Note: See TracChangeset for help on using the changeset viewer.