Changeset 109104 in webkit


Ignore:
Timestamp:
Feb 28, 2012 8:01:19 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Percent width/height SVG not always scaled on window resize
https://bugs.webkit.org/show_bug.cgi?id=79490

Patch by Florin Malita <fmalita@google.com> on 2012-02-28
Reviewed by Nikolas Zimmermann.

Source/WebCore:

Tests: fast/repaint/percent-minheight-resize-expected.html

fast/repaint/percent-minheight-resize.html
svg/custom/svg-percent-scale-expected.html
svg/custom/svg-percent-scale-vonly-expected.html
svg/custom/svg-percent-scale-vonly.html
svg/custom/svg-percent-scale.html

Fix a couple of problems preventing correct SVG scaling on window resize:

  • RenderReplaced::computePreferredLogicalWidths is not SVG attribute aware and computes

a non-zero m_minPreferredLogicalWidth even when the SVG widh/height are percentages.

  • RenderBlock::layoutInlineChildren is also not SVG attribute aware and does not trigger

percent height child layouts on vertical-only resizes.

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::layoutInlineChildren):
Use hasRelativeDimensions() instead of direct width/height->isPercent tests. This also fixes
an HTML issue where percent {min,max}Height inline elements are not updated on vertical-only resizes.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::hasRelativeDimensions):
(WebCore):

  • rendering/RenderBox.h:

(RenderBox):
Add virtual hasRelativeDimensions() method.

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computePreferredLogicalWidths):
Use hasRelativeDimensions() instead of direct width/height->isPercent tests.

  • rendering/svg/RenderSVGRoot.cpp:

(WebCore::RenderSVGRoot::computeReplacedLogicalHeight):
(WebCore::RenderSVGRoot::willBeDestroyed):
Register percent-height SVG elements with the gPercentHeightDescendantsMap, and clean-up on destruction
or height unit change.

(WebCore::RenderSVGRoot::hasRelativeDimensions):
(WebCore):

  • rendering/svg/RenderSVGRoot.h:

(RenderSVGRoot):
SVG-aware hasRelativeDimensions() override.

LayoutTests:

  • fast/repaint/percent-minheight-resize-expected.html: Added.
  • fast/repaint/percent-minheight-resize.html: Added.
  • svg/custom/svg-percent-scale-expected.html: Added.
  • svg/custom/svg-percent-scale-vonly-expected.html: Added.
  • svg/custom/svg-percent-scale-vonly.html: Added.
  • svg/custom/svg-percent-scale.html: Added.
Location:
trunk
Files:
6 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109100 r109104  
     12012-02-28  Florin Malita  <fmalita@google.com>
     2
     3        Percent width/height SVG not always scaled on window resize
     4        https://bugs.webkit.org/show_bug.cgi?id=79490
     5
     6        Reviewed by Nikolas Zimmermann.
     7
     8        * fast/repaint/percent-minheight-resize-expected.html: Added.
     9        * fast/repaint/percent-minheight-resize.html: Added.
     10        * svg/custom/svg-percent-scale-expected.html: Added.
     11        * svg/custom/svg-percent-scale-vonly-expected.html: Added.
     12        * svg/custom/svg-percent-scale-vonly.html: Added.
     13        * svg/custom/svg-percent-scale.html: Added.
     14
    1152012-02-28  Nikolas Zimmermann  <nzimmermann@rim.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r109102 r109104  
     12012-02-28  Florin Malita  <fmalita@google.com>
     2
     3        Percent width/height SVG not always scaled on window resize
     4        https://bugs.webkit.org/show_bug.cgi?id=79490
     5
     6        Reviewed by Nikolas Zimmermann.
     7
     8        Tests: fast/repaint/percent-minheight-resize-expected.html
     9               fast/repaint/percent-minheight-resize.html
     10               svg/custom/svg-percent-scale-expected.html
     11               svg/custom/svg-percent-scale-vonly-expected.html
     12               svg/custom/svg-percent-scale-vonly.html
     13               svg/custom/svg-percent-scale.html
     14
     15        Fix a couple of problems preventing correct SVG scaling on window resize:
     16
     17        - RenderReplaced::computePreferredLogicalWidths is not SVG attribute aware and computes
     18        a non-zero m_minPreferredLogicalWidth even when the SVG widh/height are percentages.
     19
     20        - RenderBlock::layoutInlineChildren is also not SVG attribute aware and does not trigger
     21        percent height child layouts on vertical-only resizes.
     22
     23        * rendering/RenderBlockLineLayout.cpp:
     24        (WebCore::RenderBlock::layoutInlineChildren):
     25        Use hasRelativeDimensions() instead of direct width/height->isPercent tests. This also fixes
     26        an HTML issue where percent {min,max}Height inline elements are not updated on vertical-only resizes.
     27
     28        * rendering/RenderBox.cpp:
     29        (WebCore::RenderBox::hasRelativeDimensions):
     30        (WebCore):
     31        * rendering/RenderBox.h:
     32        (RenderBox):
     33        Add virtual hasRelativeDimensions() method.
     34
     35        * rendering/RenderReplaced.cpp:
     36        (WebCore::RenderReplaced::computePreferredLogicalWidths):
     37        Use hasRelativeDimensions() instead of direct width/height->isPercent tests.
     38
     39        * rendering/svg/RenderSVGRoot.cpp:
     40        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight):
     41        (WebCore::RenderSVGRoot::willBeDestroyed):
     42        Register percent-height SVG elements with the gPercentHeightDescendantsMap, and clean-up on destruction
     43        or height unit change.
     44
     45        (WebCore::RenderSVGRoot::hasRelativeDimensions):
     46        (WebCore):
     47        * rendering/svg/RenderSVGRoot.h:
     48        (RenderSVGRoot):
     49        SVG-aware hasRelativeDimensions() override.
     50
    1512012-02-28  Yury Semikhatsky  <yurys@chromium.org>
    252
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r108933 r109104  
    14871487                RenderBox* box = toRenderBox(o);
    14881488
    1489                 if (relayoutChildren || o->style()->width().isPercent() || o->style()->height().isPercent())
     1489                if (relayoutChildren || box->hasRelativeDimensions())
    14901490                    o->setChildNeedsLayout(true, false);
    14911491
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r109028 r109104  
    39613961}
    39623962
     3963bool RenderBox::hasRelativeDimensions() const
     3964{
     3965    return style()->height().isPercent() || style()->width().isPercent()
     3966            || style()->maxHeight().isPercent() || style()->maxWidth().isPercent()
     3967            || style()->minHeight().isPercent() || style()->minWidth().isPercent();
     3968}
     3969
    39633970} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderBox.h

    r108382 r109104  
    450450    IntSize scrolledContentOffset() const;
    451451
     452    virtual bool hasRelativeDimensions() const;
     453
    452454protected:
    453455    virtual void willBeDestroyed();
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r107880 r109104  
    441441        m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : zeroLayoutUnit));
    442442
    443     if (style()->width().isPercent() || style()->height().isPercent()
    444         || style()->maxWidth().isPercent() || style()->maxHeight().isPercent()
    445         || style()->minWidth().isPercent() || style()->minHeight().isPercent())
     443    if (hasRelativeDimensions())
    446444        m_minPreferredLogicalWidth = 0;
    447445    else
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r108857 r109104  
    189189        return RenderReplaced::computeReplacedLogicalHeight();
    190190
    191     if (svg->heightAttributeEstablishesViewport())
    192         return resolveLengthAttributeForSVG(svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalHeight());
     191    if (svg->heightAttributeEstablishesViewport()) {
     192        Length height = svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties);
     193        if (height.isPercent()) {
     194            RenderBlock* cb = containingBlock();
     195            ASSERT(cb);
     196            while (cb->isAnonymous()) {
     197                cb = cb->containingBlock();
     198                cb->addPercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
     199            }
     200        } else
     201            RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
     202
     203        return resolveLengthAttributeForSVG(height, style()->effectiveZoom(), containingBlock()->availableLogicalHeight());
     204    }
    193205
    194206    // Only SVGs embedded in <object> reach this point.
     
    276288void RenderSVGRoot::willBeDestroyed()
    277289{
     290    RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
     291
    278292    SVGResourcesCache::clientDestroyed(this);
    279293    RenderReplaced::willBeDestroyed();
     
    402416}
    403417
     418bool RenderSVGRoot::hasRelativeDimensions() const
     419{
     420    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     421    ASSERT(svg);
     422
     423    return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent() || svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties).isPercent();
     424}
     425
    404426}
    405427
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h

    r108758 r109104  
    5353    IntSize containerSize() const { return m_containerSize; }
    5454    void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; }
     55
     56    virtual bool hasRelativeDimensions() const;
    5557
    5658private:
Note: See TracChangeset for help on using the changeset viewer.