Changeset 106882 in webkit


Ignore:
Timestamp:
Feb 6, 2012 5:30:50 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

RenderSVGShape::strokeContains will fail for some strokes
https://bugs.webkit.org/show_bug.cgi?id=76931

Patch by Stephen Chenney <schenney@chromium.org> on 2012-02-06
Reviewed by Darin Adler.

Source/WebCore:

Adding support for rounded zero-length endcaps for SVG path hit
testing.

Tests: svg/hittest/zero-length-butt-cap-path.xhtml

svg/hittest/zero-length-round-cap-path.xhtml
svg/hittest/zero-length-square-cap-path.xhtml

  • rendering/svg/RenderSVGShape.cpp:

(WebCore::RenderSVGShape::strokeContains):

LayoutTests:

New tests for hit testing against an SVG path of zero length with
endcaps.

  • svg/hittest/zero-length-butt-cap-path-expected.txt: Added.
  • svg/hittest/zero-length-butt-cap-path.xhtml: Added.
  • svg/hittest/zero-length-round-cap-path-expected.txt: Added.
  • svg/hittest/zero-length-round-cap-path.xhtml: Added.
  • svg/hittest/zero-length-square-cap-path-expected.txt: Added.
  • svg/hittest/zero-length-square-cap-path.xhtml: Added.
Location:
trunk
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r106878 r106882  
     12012-02-06  Stephen Chenney  <schenney@chromium.org>
     2
     3        RenderSVGShape::strokeContains will fail for some strokes
     4        https://bugs.webkit.org/show_bug.cgi?id=76931
     5
     6        Reviewed by Darin Adler.
     7
     8        New tests for hit testing against an SVG path of zero length with
     9        endcaps.
     10
     11        * svg/hittest/zero-length-butt-cap-path-expected.txt: Added.
     12        * svg/hittest/zero-length-butt-cap-path.xhtml: Added.
     13        * svg/hittest/zero-length-round-cap-path-expected.txt: Added.
     14        * svg/hittest/zero-length-round-cap-path.xhtml: Added.
     15        * svg/hittest/zero-length-square-cap-path-expected.txt: Added.
     16        * svg/hittest/zero-length-square-cap-path.xhtml: Added.
     17
    1182012-02-06  Philip Rogers  <pdr@google.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r106881 r106882  
     12012-02-06  Stephen Chenney  <schenney@chromium.org>
     2
     3        RenderSVGShape::strokeContains will fail for some strokes
     4        https://bugs.webkit.org/show_bug.cgi?id=76931
     5
     6        Reviewed by Darin Adler.
     7
     8        Adding support for rounded zero-length endcaps for SVG path hit
     9        testing.
     10
     11        Tests: svg/hittest/zero-length-butt-cap-path.xhtml
     12               svg/hittest/zero-length-round-cap-path.xhtml
     13               svg/hittest/zero-length-square-cap-path.xhtml
     14
     15        * rendering/svg/RenderSVGShape.cpp:
     16        (WebCore::RenderSVGShape::strokeContains):
     17
    1182012-02-06  Gregg Tavares  <gman@google.com>
    219
  • trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp

    r105878 r106882  
    137137        return false;
    138138
    139     // FIXME: This is not correct for round linecaps. https://bugs.webkit.org/show_bug.cgi?id=76931
     139    const SVGRenderStyle* svgStyle = style()->svgStyle();
    140140    for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) {
    141         if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], this->strokeWidth()).contains(point))
    142             return true;
    143     }
    144 
    145     const SVGRenderStyle* svgStyle = style()->svgStyle();
     141        ASSERT(style()->svgStyle()->hasStroke());
     142        float strokeWidth = this->strokeWidth();
     143        if (style()->svgStyle()->capStyle() == SquareCap) {
     144            if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWidth).contains(point))
     145                return true;
     146        } else {
     147            ASSERT(style()->svgStyle()->capStyle() == RoundCap);
     148            FloatPoint radiusVector(point.x() - m_zeroLengthLinecapLocations[i].x(), point.y() -  m_zeroLengthLinecapLocations[i].y());
     149            if (radiusVector.lengthSquared() < strokeWidth * strokeWidth * .25f)
     150                return true;
     151        }
     152    }
     153
    146154    if (!svgStyle->strokeDashArray().isEmpty() || svgStyle->strokeMiterLimit() != svgStyle->initialStrokeMiterLimit()
    147155        || svgStyle->joinStyle() != svgStyle->initialJoinStyle() || svgStyle->capStyle() != svgStyle->initialCapStyle() || static_cast<SVGElement*>(node())->isStyled()) {
Note: See TracChangeset for help on using the changeset viewer.