Changeset 197618 in webkit


Ignore:
Timestamp:
Mar 5, 2016 4:01:17 PM (8 years ago)
Author:
Simon Fraser
Message:

Add support for the object-position CSS property
https://bugs.webkit.org/show_bug.cgi?id=122811
rdar://problem/15836338

Reviewed by Sam Weinig.

Source/WebCore:

Take object-position into account when rendering replaced elements.
RenderReplaced::replacedContentRect() is the one place where we compute
the content rect for replaced elements.

Also return false from foregroundIsKnownToBeOpaqueInRect() if we have
any non-default object-position, as the foreground may no longer fill the box.

Tests: compositing/video/video-object-position.html

fast/css/object-position/object-position-canvas.html
fast/css/object-position/object-position-embed.html
fast/css/object-position/object-position-img-svg.html
fast/css/object-position/object-position-img.html
fast/css/object-position/object-position-input-image.html
fast/css/object-position/object-position-object.html
fast/css/object-position/object-position-video-poster.html

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::foregroundIsKnownToBeOpaqueInRect):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::replacedContentRect):

LayoutTests:

Various object-position tests.

  • compositing/video/video-object-position-expected.txt: Added.
  • compositing/video/video-object-position.html: Added.
  • fast/css/object-position/object-position-embed-expected.html: Added.
  • fast/css/object-position/object-position-embed.html: Added.
  • fast/css/object-position/object-position-img-expected.html: Added.
  • fast/css/object-position/object-position-img-svg-expected.html: Added.
  • fast/css/object-position/object-position-img-svg.html: Added.
  • fast/css/object-position/object-position-img.html: Added.
  • fast/css/object-position/object-position-input-image-expected.html: Added.
  • fast/css/object-position/object-position-input-image.html: Added.
  • fast/css/object-position/object-position-object-expected.html: Added.
  • fast/css/object-position/object-position-object.html: Added.
  • fast/css/object-position/object-position-video-poster-expected.html: Added.
  • fast/css/object-position/object-position-video-poster.html: Added.
  • fast/css/object-position/resources/expected.css: Added.
  • fast/css/object-position/resources/test.css: Added.
Location:
trunk
Files:
17 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r197617 r197618  
     12016-03-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Add support for the object-position CSS property
     4        https://bugs.webkit.org/show_bug.cgi?id=122811
     5        rdar://problem/15836338
     6
     7        Reviewed by Sam Weinig.
     8
     9        Various object-position tests.
     10
     11        * compositing/video/video-object-position-expected.txt: Added.
     12        * compositing/video/video-object-position.html: Added.
     13        * fast/css/object-position/object-position-embed-expected.html: Added.
     14        * fast/css/object-position/object-position-embed.html: Added.
     15        * fast/css/object-position/object-position-img-expected.html: Added.
     16        * fast/css/object-position/object-position-img-svg-expected.html: Added.
     17        * fast/css/object-position/object-position-img-svg.html: Added.
     18        * fast/css/object-position/object-position-img.html: Added.
     19        * fast/css/object-position/object-position-input-image-expected.html: Added.
     20        * fast/css/object-position/object-position-input-image.html: Added.
     21        * fast/css/object-position/object-position-object-expected.html: Added.
     22        * fast/css/object-position/object-position-object.html: Added.
     23        * fast/css/object-position/object-position-video-poster-expected.html: Added.
     24        * fast/css/object-position/object-position-video-poster.html: Added.
     25        * fast/css/object-position/resources/expected.css: Added.
     26        * fast/css/object-position/resources/test.css: Added.
     27
    1282016-03-05  Simon Fraser  <simon.fraser@apple.com>
    229
  • trunk/Source/WebCore/ChangeLog

    r197617 r197618  
     12016-03-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Add support for the object-position CSS property
     4        https://bugs.webkit.org/show_bug.cgi?id=122811
     5        rdar://problem/15836338
     6
     7        Reviewed by Sam Weinig.
     8
     9        Take object-position into account when rendering replaced elements.
     10        RenderReplaced::replacedContentRect() is the one place where we compute
     11        the content rect for replaced elements.
     12
     13        Also return false from foregroundIsKnownToBeOpaqueInRect() if we have
     14        any non-default object-position, as the foreground may no longer fill the box.
     15
     16        Tests: compositing/video/video-object-position.html
     17               fast/css/object-position/object-position-canvas.html
     18               fast/css/object-position/object-position-embed.html
     19               fast/css/object-position/object-position-img-svg.html
     20               fast/css/object-position/object-position-img.html
     21               fast/css/object-position/object-position-input-image.html
     22               fast/css/object-position/object-position-object.html
     23               fast/css/object-position/object-position-video-poster.html
     24
     25        * rendering/RenderImage.cpp:
     26        (WebCore::RenderImage::foregroundIsKnownToBeOpaqueInRect):
     27        * rendering/RenderReplaced.cpp:
     28        (WebCore::RenderReplaced::replacedContentRect):
     29
    1302016-03-05  Simon Fraser  <simon.fraser@apple.com>
    231
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r195848 r197618  
    585585    if (objectFit != ObjectFitFill && objectFit != ObjectFitCover)
    586586        return false;
     587
     588    LengthPoint objectPosition = style().objectPosition();
     589    if (objectPosition != RenderStyle::initialObjectPosition())
     590        return false;
     591
    587592    // Check for image with alpha.
    588593    return imageResource().cachedImage() && imageResource().cachedImage()->currentFrameKnownToBeOpaque(this);
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r196222 r197618  
    339339
    340340    ObjectFit objectFit = style().objectFit();
    341     if (objectFit == ObjectFitFill)
    342         return contentRect;
    343341
    344342    LayoutRect finalRect = contentRect;
     
    355353        break;
    356354    case ObjectFitFill:
    357         ASSERT_NOT_REACHED();
    358     }
    359 
    360     // FIXME: This is where object-position should be taken into account, but since it's not
    361     // implemented yet, assume the initial value of "50% 50%".
    362     LayoutUnit xOffset = (contentRect.width() - finalRect.width()) / 2;
    363     LayoutUnit yOffset = (contentRect.height() - finalRect.height()) / 2;
     355        break;
     356    }
     357
     358    LengthPoint objectPosition = style().objectPosition();
     359
     360    LayoutUnit xOffset = minimumValueForLength(objectPosition.x(), contentRect.width() - finalRect.width());
     361    LayoutUnit yOffset = minimumValueForLength(objectPosition.y(), contentRect.height() - finalRect.height());
     362
    364363    finalRect.move(xOffset, yOffset);
    365364
Note: See TracChangeset for help on using the changeset viewer.