Changeset 180643 in webkit


Ignore:
Timestamp:
Feb 25, 2015 3:05:20 PM (9 years ago)
Author:
Said Abou-Hallawa
Message:

Horizontal and vertical lines are clipped completely if clip-path is included in the tag but the referenced element is defined later.
https://bugs.webkit.org/show_bug.cgi?id=141776.

Reviewed by Dean Jackson.
Source/WebCore:

Tests: svg/clip-path/clip-path-line-use-before-defined-expected.svg

svg/clip-path/clip-path-line-use-before-defined.svg

  • rendering/svg/RenderSVGResourceClipper.cpp:

(WebCore::RenderSVGResourceClipper::applyClippingToContext): Ensure the renderer
is added to m_clipper if it does not exist. The same renderer might have been
added to m_clipper in resourceBoundingBox().

(WebCore::RenderSVGResourceClipper::addRendererToClipper): Add the renderer to
m_clipper if it does not exist. Return the associated ClipperData.

(WebCore::RenderSVGResourceClipper::resourceBoundingBox): If the clipper is
referenced before it is defined, add the renderer to m_clipper. While doing the
layout() for the clipper, we can check if m_clipper has values or not. If it does
have, we are going to mark the clipper for client invalidation which is done by
the SVG root.

  • rendering/svg/RenderSVGResourceClipper.h:
  • rendering/svg/RenderSVGResourceContainer.h:

(WebCore::RenderSVGResourceContainer::selfNeedsClientInvalidation): Define a
new function selfNeedsClientInvalidation() which controls marking the clipper
for client invalidation. In RenderSVGResourceClipper, override it so it checks
m_clipper to force clients validation even if it the first time we do layout
for this clipper.

  • rendering/svg/RenderSVGResourceContainer.cpp:

(WebCore::RenderSVGResourceContainer::layout): Call the virtual function
selfNeedsClientInvalidation() to check whether we need to mark the clipper for
client invalidation.

  • svg/SVGElement.cpp: Delete unneeded header file.

LayoutTests:


New test cases for SVG lines which are clipped to a <clipPath>. The <clipPath>
is referenced before it is defined.

  • svg/clip-path/clip-path-line-use-before-defined-expected.svg: Added.
  • svg/clip-path/clip-path-line-use-before-defined.svg: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r180638 r180643  
     12015-02-25  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Horizontal and vertical lines are clipped completely if clip-path is included in the tag but the referenced element is defined later.
     4        https://bugs.webkit.org/show_bug.cgi?id=141776.
     5
     6        Reviewed by Dean Jackson.
     7       
     8        New test cases for SVG lines which are clipped to a <clipPath>. The <clipPath>
     9        is referenced before it is defined.
     10
     11        * svg/clip-path/clip-path-line-use-before-defined-expected.svg: Added.
     12        * svg/clip-path/clip-path-line-use-before-defined.svg: Added.
     13
    1142015-02-25  Myles C. Maxfield  <mmaxfield@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r180641 r180643  
     12015-02-25  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Horizontal and vertical lines are clipped completely if clip-path is included in the tag but the referenced element is defined later.
     4        https://bugs.webkit.org/show_bug.cgi?id=141776.
     5
     6        Reviewed by Dean Jackson.
     7
     8        Tests: svg/clip-path/clip-path-line-use-before-defined-expected.svg
     9               svg/clip-path/clip-path-line-use-before-defined.svg
     10
     11        * rendering/svg/RenderSVGResourceClipper.cpp:
     12        (WebCore::RenderSVGResourceClipper::applyClippingToContext): Ensure the renderer
     13        is added to m_clipper if it does not exist. The same renderer might have been
     14        added to m_clipper in resourceBoundingBox().
     15       
     16        (WebCore::RenderSVGResourceClipper::addRendererToClipper): Add the renderer to
     17        m_clipper if it does not exist. Return the associated ClipperData.
     18       
     19        (WebCore::RenderSVGResourceClipper::resourceBoundingBox): If the clipper is
     20        referenced before it is defined, add the renderer to m_clipper. While doing the
     21        layout() for the clipper, we can check if m_clipper has values or not. If it does
     22        have, we are going to mark the clipper for client invalidation which is done by
     23        the SVG root.
     24       
     25        * rendering/svg/RenderSVGResourceClipper.h:
     26        * rendering/svg/RenderSVGResourceContainer.h:
     27        (WebCore::RenderSVGResourceContainer::selfNeedsClientInvalidation): Define a
     28        new function selfNeedsClientInvalidation() which controls marking the clipper
     29        for client invalidation. In RenderSVGResourceClipper, override it so it checks
     30        m_clipper to force clients validation even if it the first time we do layout
     31        for this clipper.
     32
     33        * rendering/svg/RenderSVGResourceContainer.cpp:
     34        (WebCore::RenderSVGResourceContainer::layout): Call the virtual function
     35        selfNeedsClientInvalidation() to check whether we need to mark the clipper for
     36        client invalidation.
     37       
     38        * svg/SVGElement.cpp: Delete unneeded header file.
     39
    1402015-02-25  peavo@outlook.com  <peavo@outlook.com>
    241
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp

    r177259 r180643  
    131131                                                      const FloatRect& repaintRect, GraphicsContext* context)
    132132{
    133     bool missingClipperData = !m_clipper.contains(&renderer);
    134     if (missingClipperData)
    135         m_clipper.set(&renderer, std::make_unique<ClipperData>());
    136 
    137     bool shouldCreateClipData = false;
     133    ClipperData* clipperData = addRendererToClipper(renderer);
     134    ASSERT(clipperData);
     135    bool shouldCreateClipData = !clipperData->clipMaskImage;
     136
    138137    AffineTransform animatedLocalTransform = clipPathElement().animatedLocalTransform();
    139     ClipperData* clipperData = m_clipper.get(&renderer);
    140     if (!clipperData->clipMaskImage) {
    141         if (pathOnlyClipping(context, animatedLocalTransform, objectBoundingBox))
    142             return true;
    143         shouldCreateClipData = true;
    144     }
     138
     139    if (shouldCreateClipData && pathOnlyClipping(context, animatedLocalTransform, objectBoundingBox))
     140        return true;
    145141
    146142    AffineTransform absoluteTransform;
     
    178174        return false;
    179175
    180     SVGRenderingContext::clipToImageBuffer(context, absoluteTransform, repaintRect, clipperData->clipMaskImage, missingClipperData);
     176    SVGRenderingContext::clipToImageBuffer(context, absoluteTransform, repaintRect, clipperData->clipMaskImage, shouldCreateClipData);
    181177    return true;
    182178}
     
    262258}
    263259
     260ClipperData* RenderSVGResourceClipper::addRendererToClipper(const RenderObject& object)
     261{
     262    if (!m_clipper.contains(&object))
     263        m_clipper.set(&object, std::make_unique<ClipperData>());
     264    return m_clipper.get(&object);
     265}
     266
    264267bool RenderSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundingBox, const FloatPoint& nodeAtPoint)
    265268{
     
    295298{
    296299    // Resource was not layouted yet. Give back the boundingBox of the object.
    297     if (selfNeedsLayout())
     300    if (selfNeedsLayout()) {
     301        addRendererToClipper(object);
    298302        return object.objectBoundingBox();
     303    }
    299304   
    300305    if (m_clipBoundaries.isEmpty())
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h

    r177259 r180643  
    6161    SVGUnitTypes::SVGUnitType clipPathUnits() const { return clipPathElement().clipPathUnits(); }
    6262
     63protected:
     64    virtual bool selfNeedsClientInvalidation() const override { return (everHadLayout() || m_clipper.size()) && selfNeedsLayout(); }
     65
    6366private:
    6467    void element() const = delete;
     
    6972    bool drawContentIntoMaskImage(ClipperData*, const FloatRect& objectBoundingBox);
    7073    void calculateClipContentRepaintRect();
     74    ClipperData* addRendererToClipper(const RenderObject&);
    7175
    7276    FloatRect m_clipBoundaries;
    73     HashMap<RenderObject*, std::unique_ptr<ClipperData>> m_clipper;
     77    HashMap<const RenderObject*, std::unique_ptr<ClipperData>> m_clipper;
    7478};
    7579
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp

    r177259 r180643  
    5353    StackStats::LayoutCheckPoint layoutCheckPoint;
    5454    // Invalidate all resources if our layout changed.
    55     if (everHadLayout() && selfNeedsLayout())
     55    if (selfNeedsClientInvalidation())
    5656        RenderSVGRoot::addResourceForClientInvalidation(this);
    5757
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.h

    r177259 r180643  
    5656
    5757    // Used from the invalidateClient/invalidateClients methods from classes, inheriting from us.
     58    virtual bool selfNeedsClientInvalidation() const { return everHadLayout() && selfNeedsLayout(); }
     59
    5860    void markAllClientsForInvalidation(InvalidationMode);
    5961    void markAllClientLayersForInvalidation();
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r179980 r180643  
    4040#include "RenderObject.h"
    4141#include "RenderSVGResource.h"
    42 #include "RenderSVGResourceClipper.h"
    4342#include "RenderSVGResourceFilter.h"
    4443#include "RenderSVGResourceMasker.h"
Note: See TracChangeset for help on using the changeset viewer.