Changeset 234187 in webkit


Ignore:
Timestamp:
Jul 24, 2018 9:09:47 PM (6 years ago)
Author:
Simon Fraser
Message:

Animation stops with object-fit:contain on an animated 2d canvas
https://bugs.webkit.org/show_bug.cgi?id=187840

Reviewed by Zalan Bujtas.
Source/WebCore:

If a canvas has object-fit: cover or contain, repaints need to mapped through
the rect that is used to position the canvas in the element bounds, which is replacedContentRect().

Add a version of replacedContentRect() that doesn't require passing the intrinsicSize() since
all but RenderVideo just pass the RenderReplaced's intrinsicSize.

Test: fast/repaint/canvas-object-fit.html

  • html/HTMLCanvasElement.cpp:

(WebCore::HTMLCanvasElement::didDraw):

  • rendering/RenderHTMLCanvas.cpp:

(WebCore::RenderHTMLCanvas::paintReplaced):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::updateInnerContentRect):
(WebCore::RenderImage::paintReplaced):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::contentsBox const):

  • rendering/RenderReplaced.h:

(WebCore::RenderReplaced::replacedContentRect const):

  • rendering/shapes/ShapeOutsideInfo.cpp:

(WebCore::ShapeOutsideInfo::createShapeForImage const):

LayoutTests:

  • fast/repaint/canvas-object-fit-expected.txt: Added.
  • fast/repaint/canvas-object-fit.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r234186 r234187  
     12018-07-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Animation stops with object-fit:contain on an animated 2d canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=187840
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * fast/repaint/canvas-object-fit-expected.txt: Added.
     9        * fast/repaint/canvas-object-fit.html: Added.
     10
    1112018-07-24  Basuke Suzuki  <Basuke.Suzuki@sony.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r234186 r234187  
     12018-07-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Animation stops with object-fit:contain on an animated 2d canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=187840
     5
     6        Reviewed by Zalan Bujtas.
     7       
     8        If a canvas has object-fit: cover or contain, repaints need to mapped through
     9        the rect that is used to position the canvas in the element bounds, which is replacedContentRect().
     10       
     11        Add a version of replacedContentRect() that doesn't require passing the intrinsicSize() since
     12        all but RenderVideo just pass the RenderReplaced's intrinsicSize.
     13
     14        Test: fast/repaint/canvas-object-fit.html
     15
     16        * html/HTMLCanvasElement.cpp:
     17        (WebCore::HTMLCanvasElement::didDraw):
     18        * rendering/RenderHTMLCanvas.cpp:
     19        (WebCore::RenderHTMLCanvas::paintReplaced):
     20        * rendering/RenderImage.cpp:
     21        (WebCore::RenderImage::updateInnerContentRect):
     22        (WebCore::RenderImage::paintReplaced):
     23        * rendering/RenderLayerBacking.cpp:
     24        (WebCore::RenderLayerBacking::contentsBox const):
     25        * rendering/RenderReplaced.h:
     26        (WebCore::RenderReplaced::replacedContentRect const):
     27        * rendering/shapes/ShapeOutsideInfo.cpp:
     28        (WebCore::ShapeOutsideInfo::createShapeForImage const):
     29
    1302018-07-24  Basuke Suzuki  <Basuke.Suzuki@sony.com>
    231
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r233827 r234187  
    509509
    510510    FloatRect dirtyRect = rect;
    511     if (RenderBox* ro = renderBox()) {
    512         FloatRect destRect = ro->contentBoxRect();
     511    if (auto* renderer = renderBox()) {
     512        FloatRect destRect;
     513        if (is<RenderReplaced>(renderer))
     514            destRect = downcast<RenderReplaced>(renderer)->replacedContentRect();
     515        else
     516            destRect = renderer->contentBoxRect();
     517
    513518        // Inflate dirty rect to cover antialiasing on image buffers.
    514519        if (drawingContext() && drawingContext()->shouldAntialias())
    515520            dirtyRect.inflate(1);
     521
    516522        FloatRect r = mapRect(dirtyRect, FloatRect(0, 0, size().width(), size().height()), destRect);
    517523        r.intersect(destRect);
     524
    518525        if (!r.isEmpty() && !m_dirtyRect.contains(r)) {
    519526            m_dirtyRect.unite(r);
    520             ro->repaintRectangle(enclosingIntRect(m_dirtyRect));
     527            renderer->repaintRectangle(enclosingIntRect(m_dirtyRect));
    521528        }
    522529    }
  • trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp

    r224537 r234187  
    7575    LayoutRect contentBoxRect = this->contentBoxRect();
    7676    contentBoxRect.moveBy(paintOffset);
    77     LayoutRect replacedContentRect = this->replacedContentRect(intrinsicSize());
     77    LayoutRect replacedContentRect = this->replacedContentRect();
    7878    replacedContentRect.moveBy(paintOffset);
    7979
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r233872 r234187  
    286286{
    287287    // Propagate container size to image resource.
    288     IntSize containerSize(replacedContentRect(intrinsicSize()).size());
     288    IntSize containerSize(replacedContentRect().size());
    289289    if (!containerSize.isEmpty()) {
    290290        URL imageSourceURL;
     
    498498    LayoutRect contentBoxRect = this->contentBoxRect();
    499499    contentBoxRect.moveBy(paintOffset);
    500     LayoutRect replacedContentRect = this->replacedContentRect(intrinsicSize());
     500    LayoutRect replacedContentRect = this->replacedContentRect();
    501501    replacedContentRect.moveBy(paintOffset);
    502502    bool clip = !contentBoxRect.contains(replacedContentRect);
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r233552 r234187  
    23452345    if (is<RenderReplaced>(renderBox)) {
    23462346        RenderReplaced& renderReplaced = downcast<RenderReplaced>(renderBox);
    2347         contentsRect = renderReplaced.replacedContentRect(renderBox.intrinsicSize());
     2347        contentsRect = renderReplaced.replacedContentRect();
    23482348    } else
    23492349        contentsRect = renderBox.contentBoxRect();
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r228908 r234187  
    3535
    3636    LayoutRect replacedContentRect(const LayoutSize& intrinsicSize) const;
     37    LayoutRect replacedContentRect() const { return replacedContentRect(intrinsicSize()); }
    3738
    3839    bool hasReplacedLogicalWidth() const;
  • trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp

    r233302 r234187  
    152152    const LayoutRect& marginRect = getShapeImageMarginRect(m_renderer, m_referenceBoxLogicalSize);
    153153    const LayoutRect& imageRect = is<RenderImage>(m_renderer)
    154         ? downcast<RenderImage>(m_renderer).replacedContentRect(m_renderer.intrinsicSize())
     154        ? downcast<RenderImage>(m_renderer).replacedContentRect()
    155155        : LayoutRect(LayoutPoint(), imageSize);
    156156
Note: See TracChangeset for help on using the changeset viewer.