[Webkit-unassigned] [Bug 141776] New: Horizontal and vertical lines are clipped completely if clip-path is included in the tag but the referenced element is defined later

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Feb 18 16:04:27 PST 2015


            Bug ID: 141776
           Summary: Horizontal and vertical lines are clipped completely
                    if clip-path is included in the tag but the referenced
                    element is defined later
    Classification: Unclassified
           Product: WebKit
           Version: 528+ (Nightly build)
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: SVG
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: sabouhallawa at apple.com
                CC: zimmermann at kde.org

Created attachment 246854
  --> https://bugs.webkit.org/attachment.cgi?id=246854&action=review
test case

Open the attached test case. It has different lines which are drawn using <line> and <path> elements. All the lines are clipped to a circle <clipPath> which is defined later.

Results: Only the horizontal and vertical lines which are defined before defining the clipPath elements are clipped completely. If the page is repainted (through zooming for example), these missing lines are drawn as expected.

The reason for this bug is the following.

-- RenderSVGResourceClipper::resourceBoundingBox() returns the clipping box of the <clipPath> element for the referencing element. (the <line> or the <path> in the test case)
-- If the <clipPath> is defined after it is referenced, RenderSVGResourceClipper::resourceBoundingBox() will see that selfNeedsLayout() is true so it will return object.objectBoundingBox().
-- For the case of horizontal and vertical line, the object.objectBoundingBox() height and width is zero. This means the clipping rectangle is just empty rectangle in this case.
-- Later when the base class RenderSVGResourceContainer::layout() runs the layout for the <clipPath>, it figures out it might need to notify its clients.
-- But it checks (everHadLayout() && selfNeedsLayout()) before doing so.
-- Because it is the first time we run the layout for this <clipPath>, everHadLayout() returns false and end up not calling RenderSVGRoot::addResourceForClientInvalidation()
-- Therefore the horizontal and vertical lines are completely clipped since their last clipping boxes were empty rectangles.

One interesting thing to notice is if the line is neither horizontal nor vertical, its bonding box is not an empty rectangle. In this case, no clipping is applied to this line not even the <clipPath>. The same thing can happen if more than a line is put a group such that their bounding box is not empty rectangle.

The fix can be the following:
-- We can keep track of the <clipPath> which is referenced before it is defined by adding the RendererObject to the m_clipper in RenderSVGResourceClipper::resourceBoundingBox().
-- In RenderSVGResourceClipper::applyClippingToContext() we need to ensure the RendererElement is in m_clipper if it does not exist.
-- In RenderSVGResourceContainer::layout() we need to use a new virtual function: selfNeedsClientInvalidation() which controls when we need to add the <clipPath> object for clientInvalidation.
-- In the base class we implement selfNeedsClientInvalidation() as it was before: (everHadLayout() && selfNeedsLayout())
-- In the derived class we implement selfNeedsClientInvalidation() the same as the base but we add the clause: ((m_clipper.size() && selfNeedsLayout())

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150219/6ea4f247/attachment-0002.html>

More information about the webkit-unassigned mailing list