Changeset 171046 in webkit


Ignore:
Timestamp:
Jul 12, 2014 11:35:21 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Elements with rendering disabled due to dimensions should not contribute to parent bounding box
https://bugs.webkit.org/show_bug.cgi?id=134184

Patch by Nikos Andronikos <nikos.andronikos-webkit@cisra.canon.com.au> on 2014-07-12
Reviewed by Dirk Schulze.

Source/WebCore:
SVG elements that have rendering disabled should not contribute to any ancestor elements bounding box.
Examples of elements with rendering disabled:

  • basic shape with width <= 0 or height <= 0
  • path with no path data (d attribute missing or empty)
  • polyline or polygon element with no point data (points attribute missing or empty)

To achieve this a method (isRenderingDisabled) was added to RenderSVGShape and it's derived classes.
This is used to determine if an element is included when creating the union of child bounding boxes
in a container element.

Tests: svg/custom/GetBBox-path-nodata.html

svg/custom/GetBBox-polygon-nodata.html
svg/custom/GetBBox-polyline-nodata.html
svg/custom/getBBox-container-hiddenchild.html

  • rendering/svg/RenderSVGEllipse.cpp:

(WebCore::RenderSVGEllipse::isRenderingDisabled):
New method added. Checks bounding box to determine if rendering is disabled.

  • rendering/svg/RenderSVGEllipse.h:
  • rendering/svg/RenderSVGPath.cpp:

(WebCore::RenderSVGPath::isRenderingDisabled):
New method added. Checks bounding box to determine if rendering is disabled.

  • rendering/svg/RenderSVGPath.h:
  • rendering/svg/RenderSVGRect.cpp:

(WebCore::RenderSVGRect::isRenderingDisabled):
New method added. Checks bounding box to determine if rendering is disabled.

  • rendering/svg/RenderSVGRect.h:
  • rendering/svg/RenderSVGShape.h:

(WebCore::RenderSVGShape::isRenderingDisabled):
New method added. Always returns false so that derived classes that do not
implement this method retain the existing behaviour.

  • rendering/svg/SVGRenderSupport.cpp:

(WebCore::SVGRenderSupport::computeContainerBoundingBoxes):
For each element potentially being included in the unioned bounding box of
a container, check isRenderingDisabled and skip that element if true.

  • rendering/svg/RenderSVGEllipse.cpp:

(WebCore::RenderSVGEllipse::isRenderingDisabled):

  • rendering/svg/RenderSVGEllipse.h:
  • rendering/svg/RenderSVGPath.cpp:

(WebCore::RenderSVGPath::isRenderingDisabled):

  • rendering/svg/RenderSVGPath.h:
  • rendering/svg/RenderSVGRect.cpp:

(WebCore::RenderSVGRect::isRenderingDisabled):

  • rendering/svg/RenderSVGRect.h:
  • rendering/svg/RenderSVGShape.h:
  • rendering/svg/SVGRenderSupport.cpp:

(WebCore::SVGRenderSupport::computeContainerBoundingBoxes):

LayoutTests:
Test, for each element type, that when rendering is disabled, that element does not contribute
to the bounding box for an ancestor element.

Added test to ensure zero width/height polyline and polygon do contribute to ancestor bounding box.

Updated expected results for 1 existing test (shapes-rect-02-t) as this test included zero
width and zero height rects and these were previously included in the repaint rect.

  • platform/mac/svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt:
  • svg/custom/GetBBox-path-nodata-expected.txt: Added.
  • svg/custom/GetBBox-path-nodata.html: Added.
  • svg/custom/GetBBox-polygon-nodata-expected.txt: Added.
  • svg/custom/GetBBox-polygon-nodata.html: Added.
  • svg/custom/GetBBox-polyline-nodata-expected.txt: Added.
  • svg/custom/GetBBox-polyline-nodata.html: Added.
  • svg/custom/getBBox-container-hiddenchild-expected.txt: Added.
  • svg/custom/getBBox-container-hiddenchild.html: Added.
  • svg/custom/getBBox-perpendicular-polygon-expected.txt: Added.
  • svg/custom/getBBox-perpendicular-polygon.svg: Added.
  • svg/custom/getBBox-perpendicular-polyline-expected.txt: Added.
  • svg/custom/getBBox-perpendicular-polyline.svg: Added.
Location:
trunk
Files:
12 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r171033 r171046  
     12014-07-12  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
     2
     3        Elements with rendering disabled due to dimensions should not contribute to parent bounding box
     4        https://bugs.webkit.org/show_bug.cgi?id=134184
     5
     6        Reviewed by Dirk Schulze.
     7
     8        Test, for each element type, that when rendering is disabled, that element does not contribute
     9        to the bounding box for an ancestor element.
     10
     11        Added test to ensure zero width/height polyline and polygon do contribute to ancestor bounding box.
     12
     13        Updated expected results for 1 existing test (shapes-rect-02-t) as this test included zero
     14        width and zero height rects and these were previously included in the repaint rect.
     15
     16        * platform/mac/svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt:
     17        * svg/custom/GetBBox-path-nodata-expected.txt: Added.
     18        * svg/custom/GetBBox-path-nodata.html: Added.
     19        * svg/custom/GetBBox-polygon-nodata-expected.txt: Added.
     20        * svg/custom/GetBBox-polygon-nodata.html: Added.
     21        * svg/custom/GetBBox-polyline-nodata-expected.txt: Added.
     22        * svg/custom/GetBBox-polyline-nodata.html: Added.
     23        * svg/custom/getBBox-container-hiddenchild-expected.txt: Added.
     24        * svg/custom/getBBox-container-hiddenchild.html: Added.
     25        * svg/custom/getBBox-perpendicular-polygon-expected.txt: Added.
     26        * svg/custom/getBBox-perpendicular-polygon.svg: Added.
     27        * svg/custom/getBBox-perpendicular-polyline-expected.txt: Added.
     28        * svg/custom/getBBox-perpendicular-polyline.svg: Added.
     29
    1302014-07-11  Jer Noble  <jer.noble@apple.com>
    231
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt

    r169522 r171046  
    33layer at (0,0) size 480x360
    44  RenderSVGRoot {svg} at (0,0) size 480x360
    5     RenderSVGContainer {g} at (0,0) size 401x277
     5    RenderSVGContainer {g} at (0,0) size 181x277
    66      RenderSVGRect {rect} at (0,45) size 51x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=46.00] [width=50.00] [height=80.00]
    77      RenderSVGRect {rect} at (129,0) size 52x81 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=130.00] [y=0.00] [width=50.00] [height=80.00]
  • trunk/Source/WebCore/ChangeLog

    r171043 r171046  
     12014-07-12  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
     2
     3        Elements with rendering disabled due to dimensions should not contribute to parent bounding box
     4        https://bugs.webkit.org/show_bug.cgi?id=134184
     5
     6        Reviewed by Dirk Schulze.
     7
     8        SVG elements that have rendering disabled should not contribute to any ancestor elements bounding box.
     9        Examples of elements with rendering disabled:
     10        - basic shape with width <= 0 or height <= 0
     11        - path with no path data (d attribute missing or empty)
     12        - polyline or polygon element with no point data (points attribute missing or empty)
     13
     14        To achieve this a method (isRenderingDisabled) was added to RenderSVGShape and it's derived classes.
     15        This is used to determine if an element is included when creating the union of child bounding boxes
     16        in a container element.
     17
     18        Tests: svg/custom/GetBBox-path-nodata.html
     19               svg/custom/GetBBox-polygon-nodata.html
     20               svg/custom/GetBBox-polyline-nodata.html
     21               svg/custom/getBBox-container-hiddenchild.html
     22
     23        * rendering/svg/RenderSVGEllipse.cpp:
     24        (WebCore::RenderSVGEllipse::isRenderingDisabled):
     25        New method added. Checks bounding box to determine if rendering is disabled.
     26        * rendering/svg/RenderSVGEllipse.h:
     27        * rendering/svg/RenderSVGPath.cpp:
     28        (WebCore::RenderSVGPath::isRenderingDisabled):
     29        New method added. Checks bounding box to determine if rendering is disabled.
     30        * rendering/svg/RenderSVGPath.h:
     31        * rendering/svg/RenderSVGRect.cpp:
     32        (WebCore::RenderSVGRect::isRenderingDisabled):
     33        New method added. Checks bounding box to determine if rendering is disabled.
     34        * rendering/svg/RenderSVGRect.h:
     35        * rendering/svg/RenderSVGShape.h:
     36        (WebCore::RenderSVGShape::isRenderingDisabled):
     37        New method added. Always returns false so that derived classes that do not
     38        implement this method retain the existing behaviour.
     39        * rendering/svg/SVGRenderSupport.cpp:
     40        (WebCore::SVGRenderSupport::computeContainerBoundingBoxes):
     41        For each element potentially being included in the unioned bounding box of
     42        a container, check isRenderingDisabled and skip that element if true.
     43
     44        * rendering/svg/RenderSVGEllipse.cpp:
     45        (WebCore::RenderSVGEllipse::isRenderingDisabled):
     46        * rendering/svg/RenderSVGEllipse.h:
     47        * rendering/svg/RenderSVGPath.cpp:
     48        (WebCore::RenderSVGPath::isRenderingDisabled):
     49        * rendering/svg/RenderSVGPath.h:
     50        * rendering/svg/RenderSVGRect.cpp:
     51        (WebCore::RenderSVGRect::isRenderingDisabled):
     52        * rendering/svg/RenderSVGRect.h:
     53        * rendering/svg/RenderSVGShape.h:
     54        * rendering/svg/SVGRenderSupport.cpp:
     55        (WebCore::SVGRenderSupport::computeContainerBoundingBoxes):
     56
    1572014-07-12  Benjamin Poulain  <benjamin@webkit.org>
    258
  • trunk/Source/WebCore/rendering/svg/RenderSVGEllipse.cpp

    r170774 r171046  
    154154}
    155155
     156bool RenderSVGEllipse::isRenderingDisabled() const
     157{
     158    // A radius of zero disables rendering of the element, and results in an empty bounding box.
     159    return m_fillBoundingBox.isEmpty();
    156160}
     161
     162}
  • trunk/Source/WebCore/rendering/svg/RenderSVGEllipse.h

    r163440 r171046  
    4242    virtual void updateShapeFromElement();
    4343    virtual bool isEmpty() const { return m_usePathFallback ? RenderSVGShape::isEmpty() : m_fillBoundingBox.isEmpty(); };
     44    virtual bool isRenderingDisabled() const override;
    4445    virtual void fillShape(GraphicsContext*) const;
    4546    virtual void strokeShape(GraphicsContext*) const;
  • trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp

    r170774 r171046  
    160160}
    161161
     162bool RenderSVGPath::isRenderingDisabled() const
     163{
     164    // For a polygon, polyline or path, rendering is disabled if there is no path data.
     165    // No path data is possible in the case of a missing or empty 'd' or 'points' attribute.
     166    return path().isEmpty();
    162167}
     168
     169}
  • trunk/Source/WebCore/rendering/svg/RenderSVGPath.h

    r165676 r171046  
    5151    void updateZeroLengthSubpaths();
    5252
     53    virtual bool isRenderingDisabled() const override;
     54
    5355    Vector<FloatPoint> m_zeroLengthLinecapLocations;
    5456};
  • trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp

    r170774 r171046  
    152152}
    153153
     154bool RenderSVGRect::isRenderingDisabled() const
     155{
     156    // A width or height of zero disables rendering for the element, and results in an empty bounding box.
     157    return m_fillBoundingBox.isEmpty();
    154158}
     159
     160}
  • trunk/Source/WebCore/rendering/svg/RenderSVGRect.h

    r163440 r171046  
    4848    virtual void updateShapeFromElement();
    4949    virtual bool isEmpty() const { return m_usePathFallback ? RenderSVGShape::isEmpty() : m_fillBoundingBox.isEmpty(); };
     50    virtual bool isRenderingDisabled() const override;
    5051    virtual void fillShape(GraphicsContext*) const;
    5152    virtual void strokeShape(GraphicsContext*) const;
  • trunk/Source/WebCore/rendering/svg/RenderSVGShape.h

    r166489 r171046  
    5858    virtual void fillShape(GraphicsContext*) const;
    5959    virtual void strokeShape(GraphicsContext*) const;
     60    virtual bool isRenderingDisabled() const = 0;
    6061
    6162    bool hasPath() const { return m_path.get(); }
  • trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp

    r168543 r171046  
    158158            continue;
    159159
     160        // Don't include elements in the union that do not render.
     161        if (current->isSVGShape() && toRenderSVGShape(current)->isRenderingDisabled())
     162            continue;
     163
    160164        const AffineTransform& transform = current->localToParentTransform();
    161165        if (transform.isIdentity()) {
Note: See TracChangeset for help on using the changeset viewer.