- Revision
- 180643
- Author
- s...@apple.com
- Date
- 2015-02-25 15:05:20 -0800 (Wed, 25 Feb 2015)
Log 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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (180642 => 180643)
--- trunk/LayoutTests/ChangeLog 2015-02-25 22:37:17 UTC (rev 180642)
+++ trunk/LayoutTests/ChangeLog 2015-02-25 23:05:20 UTC (rev 180643)
@@ -1,3 +1,16 @@
+2015-02-25 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ 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.
+
+ 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.
+
2015-02-25 Myles C. Maxfield <mmaxfi...@apple.com>
Test gardening
Added: trunk/LayoutTests/svg/clip-path/clip-path-line-use-before-defined-expected.svg (0 => 180643)
--- trunk/LayoutTests/svg/clip-path/clip-path-line-use-before-defined-expected.svg (rev 0)
+++ trunk/LayoutTests/svg/clip-path/clip-path-line-use-before-defined-expected.svg 2015-02-25 23:05:20 UTC (rev 180643)
@@ -0,0 +1,33 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
+ <defs>
+ <style>
+ line, path {
+ stroke: black;
+ }
+ </style>
+ <clipPath id="clip-circle">
+ <circle cx="50%" cy="50%" r="25%"/>
+ </clipPath>
+ </defs>
+
+ <rect x="0" y="0" width="100%" height="100%" fill="lime"/>
+ <rect x="0" y="0" width="100%" height="100%" fill="white" clip-path="url(#clip-circle)"/>
+
+ <!-- diagonal -->
+ <line x1="170" y1="30" x2="30" y2="170" clip-path="url(#clip-circle)"/>
+
+ <!-- top and left lines -->
+ <path d="M30 75 L170 75" clip-path="url(#clip-circle)"/>
+ <line x1="75" y1="30" x2="75" y2="170" clip-path="url(#clip-circle)"/>
+
+ <!-- right and bottom lines -->
+ <g clip-path="url(#clip-circle)">
+ <path d="M30 125 L170 125"/>
+ <line x1="125" y1="30" x2="125" y2="170"/>
+ </g>
+
+ <!-- center lines -->
+ <path d="M30 100 L170 100" clip-path="url(#clip-circle)"/>
+ <line x1="100" y1="30" x2="100" y2="170" clip-path="url(#clip-circle)"/>
+
+</svg>
Added: trunk/LayoutTests/svg/clip-path/clip-path-line-use-before-defined.svg (0 => 180643)
--- trunk/LayoutTests/svg/clip-path/clip-path-line-use-before-defined.svg (rev 0)
+++ trunk/LayoutTests/svg/clip-path/clip-path-line-use-before-defined.svg 2015-02-25 23:05:20 UTC (rev 180643)
@@ -0,0 +1,38 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
+ <defs>
+ <style>
+ line, path {
+ stroke: black;
+ }
+ </style>
+ </defs>
+
+ <rect x="0" y="0" width="100%" height="100%" fill="lime"/>
+ <rect x="0" y="0" width="100%" height="100%" fill="white" clip-path="url(#clip-circle)"/>
+
+ <!-- diagonal -->
+ <line x1="170" y1="30" x2="30" y2="170" clip-path="url(#clip-circle)"/>
+
+ <!-- top and left lines -->
+ <path d="M30 75 L170 75" clip-path="url(#clip-circle)"/>
+ <line x1="75" y1="30" x2="75" y2="170" clip-path="url(#clip-circle)"/>
+
+ <!-- bottom and right lines -->
+ <g clip-path="url(#clip-circle)">
+ <path d="M30 125 L170 125"/>
+ <line x1="125" y1="30" x2="125" y2="170"/>
+ </g>
+
+ <defs>
+ <clipPath id="clip-circle">
+ <circle cx="50%" cy="50%" r="50%" clip-path="url(#clip-small-circle)"/>
+ </clipPath>
+ <clipPath id="clip-small-circle">
+ <circle cx="50%" cy="50%" r="25%"/>
+ </clipPath>
+ </defs>
+
+ <!-- center lines -->
+ <path d="M30 100 L170 100" clip-path="url(#clip-circle)"/>
+ <line x1="100" y1="30" x2="100" y2="170" clip-path="url(#clip-circle)"/>
+</svg>
Modified: trunk/Source/WebCore/ChangeLog (180642 => 180643)
--- trunk/Source/WebCore/ChangeLog 2015-02-25 22:37:17 UTC (rev 180642)
+++ trunk/Source/WebCore/ChangeLog 2015-02-25 23:05:20 UTC (rev 180643)
@@ -1,3 +1,42 @@
+2015-02-25 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ 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.
+
+ 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.
+
2015-02-25 pe...@outlook.com <pe...@outlook.com>
[WinCairo] WinLauncher is not starting on Vista.
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp (180642 => 180643)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp 2015-02-25 22:37:17 UTC (rev 180642)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp 2015-02-25 23:05:20 UTC (rev 180643)
@@ -130,19 +130,15 @@
bool RenderSVGResourceClipper::applyClippingToContext(RenderElement& renderer, const FloatRect& objectBoundingBox,
const FloatRect& repaintRect, GraphicsContext* context)
{
- bool missingClipperData = !m_clipper.contains(&renderer);
- if (missingClipperData)
- m_clipper.set(&renderer, std::make_unique<ClipperData>());
+ ClipperData* clipperData = addRendererToClipper(renderer);
+ ASSERT(clipperData);
+ bool shouldCreateClipData = !clipperData->clipMaskImage;
- bool shouldCreateClipData = false;
AffineTransform animatedLocalTransform = clipPathElement().animatedLocalTransform();
- ClipperData* clipperData = m_clipper.get(&renderer);
- if (!clipperData->clipMaskImage) {
- if (pathOnlyClipping(context, animatedLocalTransform, objectBoundingBox))
- return true;
- shouldCreateClipData = true;
- }
+ if (shouldCreateClipData && pathOnlyClipping(context, animatedLocalTransform, objectBoundingBox))
+ return true;
+
AffineTransform absoluteTransform;
SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(renderer, absoluteTransform);
@@ -177,7 +173,7 @@
if (!clipperData->clipMaskImage)
return false;
- SVGRenderingContext::clipToImageBuffer(context, absoluteTransform, repaintRect, clipperData->clipMaskImage, missingClipperData);
+ SVGRenderingContext::clipToImageBuffer(context, absoluteTransform, repaintRect, clipperData->clipMaskImage, shouldCreateClipData);
return true;
}
@@ -261,6 +257,13 @@
m_clipBoundaries = clipPathElement().animatedLocalTransform().mapRect(m_clipBoundaries);
}
+ClipperData* RenderSVGResourceClipper::addRendererToClipper(const RenderObject& object)
+{
+ if (!m_clipper.contains(&object))
+ m_clipper.set(&object, std::make_unique<ClipperData>());
+ return m_clipper.get(&object);
+}
+
bool RenderSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundingBox, const FloatPoint& nodeAtPoint)
{
FloatPoint point = nodeAtPoint;
@@ -294,8 +297,10 @@
FloatRect RenderSVGResourceClipper::resourceBoundingBox(const RenderObject& object)
{
// Resource was not layouted yet. Give back the boundingBox of the object.
- if (selfNeedsLayout())
+ if (selfNeedsLayout()) {
+ addRendererToClipper(object);
return object.objectBoundingBox();
+ }
if (m_clipBoundaries.isEmpty())
calculateClipContentRepaintRect();
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h (180642 => 180643)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h 2015-02-25 22:37:17 UTC (rev 180642)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h 2015-02-25 23:05:20 UTC (rev 180643)
@@ -60,6 +60,9 @@
SVGUnitTypes::SVGUnitType clipPathUnits() const { return clipPathElement().clipPathUnits(); }
+protected:
+ virtual bool selfNeedsClientInvalidation() const override { return (everHadLayout() || m_clipper.size()) && selfNeedsLayout(); }
+
private:
void element() const = delete;
@@ -68,9 +71,10 @@
bool pathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatRect&);
bool drawContentIntoMaskImage(ClipperData*, const FloatRect& objectBoundingBox);
void calculateClipContentRepaintRect();
+ ClipperData* addRendererToClipper(const RenderObject&);
FloatRect m_clipBoundaries;
- HashMap<RenderObject*, std::unique_ptr<ClipperData>> m_clipper;
+ HashMap<const RenderObject*, std::unique_ptr<ClipperData>> m_clipper;
};
}
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp (180642 => 180643)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp 2015-02-25 22:37:17 UTC (rev 180642)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp 2015-02-25 23:05:20 UTC (rev 180643)
@@ -52,7 +52,7 @@
{
StackStats::LayoutCheckPoint layoutCheckPoint;
// Invalidate all resources if our layout changed.
- if (everHadLayout() && selfNeedsLayout())
+ if (selfNeedsClientInvalidation())
RenderSVGRoot::addResourceForClientInvalidation(this);
RenderSVGHiddenContainer::layout();
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.h (180642 => 180643)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.h 2015-02-25 22:37:17 UTC (rev 180642)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.h 2015-02-25 23:05:20 UTC (rev 180643)
@@ -55,6 +55,8 @@
};
// Used from the invalidateClient/invalidateClients methods from classes, inheriting from us.
+ virtual bool selfNeedsClientInvalidation() const { return everHadLayout() && selfNeedsLayout(); }
+
void markAllClientsForInvalidation(InvalidationMode);
void markAllClientLayersForInvalidation();
void markClientForInvalidation(RenderObject&, InvalidationMode);
Modified: trunk/Source/WebCore/svg/SVGElement.cpp (180642 => 180643)
--- trunk/Source/WebCore/svg/SVGElement.cpp 2015-02-25 22:37:17 UTC (rev 180642)
+++ trunk/Source/WebCore/svg/SVGElement.cpp 2015-02-25 23:05:20 UTC (rev 180643)
@@ -39,7 +39,6 @@
#include "HTMLParserIdioms.h"
#include "RenderObject.h"
#include "RenderSVGResource.h"
-#include "RenderSVGResourceClipper.h"
#include "RenderSVGResourceFilter.h"
#include "RenderSVGResourceMasker.h"
#include "SVGCursorElement.h"