Changeset 201889 in webkit


Ignore:
Timestamp:
Jun 9, 2016 3:34:41 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Changing canvas height immediately after page load does not relayout canvas
https://bugs.webkit.org/show_bug.cgi?id=156097

Patch by Antoine Quint <Antoine Quint> on 2016-06-09
Reviewed by Zalan Bujtas.

Source/WebCore:

Promote the logic use to identify whether we should perform a layout after a change of
intrinsic size from RenderImage to RenderReplaced such that RenderCanvas may use it
in canvasSizeChanged() and correctly update its layout in the case where the width
or height attribute is updated and there are no explicit sizing performed with CSS.
Additionally, this will also account for the object-fix property to only perform
a layout if necessary.

Test: fast/canvas/canvas-css-size-after-height-change-with-display-flex.html

  • rendering/RenderHTMLCanvas.cpp:

(WebCore::RenderHTMLCanvas::canvasSizeChanged):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::repaintOrMarkForLayout):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::setNeedsLayoutIfNeededAfterIntrinsicSizeChange):

  • rendering/RenderReplaced.h:

LayoutTests:

  • fast/canvas/canvas-css-size-after-height-change-with-display-flex-expected.html: Added.
  • fast/canvas/canvas-css-size-after-height-change-with-display-flex.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r201887 r201889  
     12016-06-09  Antoine Quint  <graouts@apple.com>
     2
     3        Changing canvas height immediately after page load does not relayout canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=156097
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * fast/canvas/canvas-css-size-after-height-change-with-display-flex-expected.html: Added.
     9        * fast/canvas/canvas-css-size-after-height-change-with-display-flex.html: Added.
     10
    1112016-06-09  Myles C. Maxfield  <mmaxfield@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r201887 r201889  
     12016-06-09  Antoine Quint  <graouts@apple.com>
     2
     3        Changing canvas height immediately after page load does not relayout canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=156097
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Promote the logic use to identify whether we should perform a layout after a change of
     9        intrinsic size from RenderImage to RenderReplaced such that RenderCanvas may use it
     10        in canvasSizeChanged() and correctly update its layout in the case where the width
     11        or height attribute is updated and there are no explicit sizing performed with CSS.
     12        Additionally, this will also account for the object-fix property to only perform
     13        a layout if necessary.
     14
     15        Test: fast/canvas/canvas-css-size-after-height-change-with-display-flex.html
     16
     17        * rendering/RenderHTMLCanvas.cpp:
     18        (WebCore::RenderHTMLCanvas::canvasSizeChanged):
     19        * rendering/RenderImage.cpp:
     20        (WebCore::RenderImage::repaintOrMarkForLayout):
     21        * rendering/RenderReplaced.cpp:
     22        (WebCore::RenderReplaced::setNeedsLayoutIfNeededAfterIntrinsicSizeChange):
     23        * rendering/RenderReplaced.h:
     24
    1252016-06-09  Myles C. Maxfield  <mmaxfield@apple.com>
    226
  • trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp

    r200041 r201889  
    102102    if (!parent())
    103103        return;
    104 
    105     if (!preferredLogicalWidthsDirty())
    106         setPreferredLogicalWidthsDirty(true);
    107 
    108     LayoutSize oldSize = size();
    109     updateLogicalWidth();
    110     updateLogicalHeight();
    111     if (oldSize == size())
    112         return;
    113 
    114     if (!selfNeedsLayout())
    115         setNeedsLayout();
     104    setNeedsLayoutIfNeededAfterIntrinsicSizeChange();
    116105}
    117106
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r201040 r201889  
    296296    bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize || imageSizeChange != ImageSizeChangeNone;
    297297
    298     if (imageSourceHasChangedSize) {
    299         setPreferredLogicalWidthsDirty(true);
    300 
    301         // If the actual area occupied by the image has changed and it is not constrained by style then a layout is required.
    302         bool imageSizeIsConstrained = style().logicalWidth().isSpecified() && style().logicalHeight().isSpecified();
    303 
    304         // FIXME: We only need to recompute the containing block's preferred size
    305         // if the containing block's size depends on the image's size (i.e., the container uses shrink-to-fit sizing).
    306         // There's no easy way to detect that shrink-to-fit is needed, always force a layout.
    307         bool containingBlockNeedsToRecomputePreferredSize =
    308             style().logicalWidth().isPercentOrCalculated()
    309             || style().logicalMaxWidth().isPercentOrCalculated()
    310             || style().logicalMinWidth().isPercentOrCalculated();
    311 
    312         bool layoutSizeDependsOnIntrinsicSize = style().aspectRatioType() == AspectRatioFromIntrinsic;
    313 
    314         if (!imageSizeIsConstrained || containingBlockNeedsToRecomputePreferredSize || layoutSizeDependsOnIntrinsicSize) {
    315             // FIXME: It's not clear that triggering a layout guarantees a repaint in all cases.
    316             // But many callers do depend on this code causing a layout.
    317             setNeedsLayout();
    318             return;
    319         }
    320     }
     298    if (imageSourceHasChangedSize && setNeedsLayoutIfNeededAfterIntrinsicSizeChange())
     299        return;
    321300
    322301    if (everHadLayout() && !selfNeedsLayout()) {
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r201752 r201889  
    291291}
    292292
     293bool RenderReplaced::setNeedsLayoutIfNeededAfterIntrinsicSizeChange()
     294{
     295    setPreferredLogicalWidthsDirty(true);
     296   
     297    // If the actual area occupied by the image has changed and it is not constrained by style then a layout is required.
     298    bool imageSizeIsConstrained = style().logicalWidth().isSpecified() && style().logicalHeight().isSpecified();
     299   
     300    // FIXME: We only need to recompute the containing block's preferred size
     301    // if the containing block's size depends on the image's size (i.e., the container uses shrink-to-fit sizing).
     302    // There's no easy way to detect that shrink-to-fit is needed, always force a layout.
     303    bool containingBlockNeedsToRecomputePreferredSize =
     304        style().logicalWidth().isPercentOrCalculated()
     305        || style().logicalMaxWidth().isPercentOrCalculated()
     306        || style().logicalMinWidth().isPercentOrCalculated();
     307   
     308    bool layoutSizeDependsOnIntrinsicSize = style().aspectRatioType() == AspectRatioFromIntrinsic;
     309   
     310    if (!imageSizeIsConstrained || containingBlockNeedsToRecomputePreferredSize || layoutSizeDependsOnIntrinsicSize) {
     311        setNeedsLayout();
     312        return true;
     313    }
     314
     315    return false;
     316}
     317   
    293318void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* contentRenderer, FloatSize& constrainedSize, double& intrinsicRatio) const
    294319{
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r200041 r201889  
    3838    bool hasReplacedLogicalWidth() const;
    3939    bool hasReplacedLogicalHeight() const;
     40    bool setNeedsLayoutIfNeededAfterIntrinsicSizeChange();
    4041
    4142protected:
Note: See TracChangeset for help on using the changeset viewer.