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

Changeset 268249 in webkit


Ignore:
Timestamp:
Oct 9, 2020, 1:19:01 AM (6 years ago)
Author:
Noam Rosenthal
Message:

CSS image-orientation: none should be ignored for cross-origin images
https://bugs.webkit.org/show_bug.cgi?id=217294

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-images/image-orientation/image-orientation-none-cross-origin-expected.html: Added.
  • web-platform-tests/css/css-images/image-orientation/image-orientation-none-cross-origin.html: Added.

Imported a new W3C test for remote image with image-orientation.

Source/WebCore:

Per the new spec in https://github.com/w3c/csswg-drafts/issues/5165,
the orientation should be baked into the image if the image is cross origin, to avoid
exposing remote image orientation to embedders.

The meaning of it in practice is that image-orientation: none would have no effect on remote,
image as it's the only web-facing feature exposing image-orientation.

This change disables image-orientation override for remote images.

Tests: http/wpt/css/css-images/image-orientation/image-orientation-none-cross-origin-canvas.html
imported/w3c/web-platform-tests/css/css-images/image-orientation/image-orientation-none-cross-origin.html

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::allowsOrientationOverride const):

  • html/HTMLImageElement.h:

Add a check whether an element is allowed to override/expose orientation.

  • html/canvas/CanvasRenderingContext2DBase.cpp:

(WebCore::CanvasRenderingContext2DBase::drawImage):

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::imageOrientation const):
Only apply orientation for eligible images.

LayoutTests:

  • http/wpt/css/css-images/image-orientation/image-orientation-none-cross-origin-canvas.html: Added.
  • http/wpt/css/css-images/image-orientation/image-orientation-none-cross-origin-canvas-expected.html: Added.
Location:
trunk
Files:
9 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r268244 r268249  
     12020-10-09  Noam Rosenthal  <noam@webkit.org>
     2
     3        CSS image-orientation: none should be ignored for cross-origin images
     4        https://bugs.webkit.org/show_bug.cgi?id=217294
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * http/wpt/css/css-images/image-orientation/image-orientation-none-cross-origin-canvas.html: Added.
     9        * http/wpt/css/css-images/image-orientation/image-orientation-none-cross-origin-canvas-expected.html: Added.
     10
    1112020-10-08  Myles C. Maxfield  <mmaxfield@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r268232 r268249  
     12020-10-09  Noam Rosenthal  <noam@webkit.org>
     2
     3        CSS image-orientation: none should be ignored for cross-origin images
     4        https://bugs.webkit.org/show_bug.cgi?id=217294
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * web-platform-tests/css/css-images/image-orientation/image-orientation-none-cross-origin-expected.html: Added.
     9        * web-platform-tests/css/css-images/image-orientation/image-orientation-none-cross-origin.html: Added.
     10                Imported a new W3C test for remote image with image-orientation.
     11
    1122020-10-08  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r268245 r268249  
     12020-10-09  Noam Rosenthal  <noam@webkit.org>
     2
     3        CSS image-orientation: none should be ignored for cross-origin images
     4        https://bugs.webkit.org/show_bug.cgi?id=217294
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Per the new spec in https://github.com/w3c/csswg-drafts/issues/5165,
     9        the orientation should be baked into the image if the image is cross origin, to avoid
     10        exposing remote image orientation to embedders.
     11
     12        The meaning of it in practice is that image-orientation: none would have no effect on remote,
     13        image as it's the only web-facing feature exposing image-orientation.
     14
     15        This change disables image-orientation override for remote images.       
     16
     17        Tests: http/wpt/css/css-images/image-orientation/image-orientation-none-cross-origin-canvas.html
     18        imported/w3c/web-platform-tests/css/css-images/image-orientation/image-orientation-none-cross-origin.html
     19
     20        * html/HTMLImageElement.cpp:
     21        (WebCore::HTMLImageElement::allowsOrientationOverride const):
     22        * html/HTMLImageElement.h:
     23        Add a check whether an element is allowed to override/expose orientation.
     24
     25        * html/canvas/CanvasRenderingContext2DBase.cpp:
     26        (WebCore::CanvasRenderingContext2DBase::drawImage):
     27        * rendering/RenderElement.cpp:
     28        (WebCore::RenderElement::imageOrientation const):
     29        Only apply orientation for eligible images.
     30
    1312020-10-08  Eric Carlson  <eric.carlson@apple.com>
    232
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r267007 r268249  
    682682}
    683683
     684bool HTMLImageElement::allowsOrientationOverride() const
     685{
     686    auto* image = cachedImage();
     687    return !image || image->isOriginClean(&(document().securityOrigin()));
     688}
     689
    684690#if ENABLE(ATTACHMENT_ELEMENT)
    685691
  • trunk/Source/WebCore/html/HTMLImageElement.h

    r267007 r268249  
    140140    String referrerPolicyForBindings() const;
    141141    ReferrerPolicy referrerPolicy() const;
     142
     143    bool allowsOrientationOverride() const;
    142144
    143145protected:
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp

    r267645 r268249  
    14511451
    14521452    auto orientation = ImageOrientation::FromImage;
    1453     if (auto* renderer = imageElement.renderer())
    1454         orientation = renderer->style().imageOrientation();
    1455     else if (auto* computedStyle = imageElement.computedStyle())
    1456         orientation = computedStyle->imageOrientation();
     1453    if (imageElement.allowsOrientationOverride()) {
     1454        if (auto* renderer = imageElement.renderer())
     1455            orientation = renderer->style().imageOrientation();
     1456        else if (auto* computedStyle = imageElement.computedStyle())
     1457            orientation = computedStyle->imageOrientation();
     1458    }
    14571459
    14581460    auto result = drawImage(imageElement.document(), imageElement.cachedImage(), imageElement.renderer(), imageRect, srcRect, dstRect, op, blendMode, orientation);
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r268075 r268249  
    21412141ImageOrientation RenderElement::imageOrientation() const
    21422142{
    2143     return style().imageOrientation();
     2143    auto* imageElement = is<HTMLImageElement>(element()) ? downcast<HTMLImageElement>(element()) : nullptr;
     2144    return (imageElement && !imageElement->allowsOrientationOverride()) ? ImageOrientation(ImageOrientation::FromImage) : style().imageOrientation();
    21442145}
    21452146
Note: See TracChangeset for help on using the changeset viewer.