[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

zimmermann at webkit.org zimmermann at webkit.org
Wed Dec 22 12:28:08 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 650c061a9e91e25a408833b1aefe901d105dda4b
Author: zimmermann at webkit.org <zimmermann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 24 09:25:11 2010 +0000

    2010-08-24  Nikolas Zimmermann  <nzimmermann at rim.com>
    
            Reviewed by Dirk Schulze
    
            clip-path does not work inside mask element
            https://bugs.webkit.org/show_bug.cgi?id=41428
    
            Add new tests covering nesting of clippers and maskers, with different unitTypes for the content coordinate system.
            Scale all ImageBuffer content to take into account that ImageBuffers use integer based sizes, where the content
            is floating-point sized. This compensates rounded errors, when scaling the document.
    
            Tests: svg/clip-path/clip-in-mask-objectBoundingBox.svg
                   svg/clip-path/clip-in-mask-userSpaceOnUse.svg
                   svg/clip-path/clip-in-mask.svg
                   svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg
                   svg/clip-path/deep-nested-clip-in-mask-panning.svg
                   svg/clip-path/deep-nested-clip-in-mask.svg
                   svg/clip-path/nested-clip-in-mask-image-based-clipping.svg
                   svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg
                   svg/clip-path/nested-clip-in-mask-path-based-clipping.svg
    
            * rendering/RenderSVGResourceClipper.cpp:
            (WebCore::RenderSVGResourceClipper::applyResource): Return the value of applyClippingToContext, instead of always true.
            (WebCore::RenderSVGResourceClipper::applyClippingToContext): Moved some code from createClipData, to avoid having to pass 5 arguments to createClipData.
            (WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage): Renamed from createClipData.
            * rendering/RenderSVGResourceClipper.h:
            * rendering/RenderSVGResourceGradient.cpp:
            (WebCore::createMaskAndSwapContextForTextGradient): Pass absoluteTargetRect to createImageBuffer.
            (WebCore::clipToTextMask): Ditto.
            * rendering/RenderSVGResourceMasker.cpp:
            (WebCore::RenderSVGResourceMasker::applyResource): Ditto.
            (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage): Pass content transformation to renderSubtreeToImageBuffer, to support nesting objectBoundingBox resources.
            * rendering/RenderSVGResourcePattern.cpp:
            (WebCore::RenderSVGResourcePattern::applyResource): Adapt to calculateTransformationToOutermostSVGCoordinateSystem changes. AffineTransform is now passed as reference.
            (WebCore::RenderSVGResourcePattern::createTileImage): ImageBuffer content scaling is now handled by createImageBuffer.
            * rendering/SVGImageBufferTools.cpp:
            (WebCore::SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem): Renamed. Don't return an AffineTransform copy, but instead pass it as reference.
            (WebCore::SVGImageBufferTools::createImageBuffer): Always scale the ImageBuffer content, to compensate rounding effects (code was only present in patterns so far).
                                                               Now also needs the 'absoluteTargetRect' parameter, not only 'clampedAbsoluteTargetRect'.
            (WebCore::SVGImageBufferTools::renderSubtreeToImageBuffer): Moved from SVGRenderSupport.
            (WebCore::SVGImageBufferTools::clipToImageBuffer): Pass ImageBuffer as OwnPtr reference, to allow to clear it under certain circumstances (see comment).
            (WebCore::SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer): Remove AffineTransform parameter, absoluteTargetRect is calculated before passing into this function.
            * rendering/SVGImageBufferTools.h:
            * rendering/SVGRenderSupport.cpp:
            (WebCore::SVGRenderSupport::prepareToRenderSVGContent): Important change, respect the RenderSVGResourceClipper::applyResource() return value!
            * rendering/SVGRenderSupport.h:
            * svg/SVGFEImageElement.cpp:
            (WebCore::SVGFEImageElement::build): renderSubtreeToImage now lives in SVGImageBufferTools, adapt code.
    
    2010-08-24  Nikolas Zimmermann  <nzimmermann at rim.com>
    
            Reviewed by Dirk Schulze.
    
            clip-path does not work inside mask element
            https://bugs.webkit.org/show_bug.cgi?id=41428
    
            Update results of all tests containing <mask> / <pattern> and/or gradient on text (using CG).
            The ImageBuffer content is now scaled to account for rounding differences, when zooming.
    
            * platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.checksum:
            * platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.png:
            * platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.checksum:
            * platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.png:
            * platform/mac/svg/clip-path/clip-in-mask-expected.checksum: Added.
            * platform/mac/svg/clip-path/clip-in-mask-expected.png: Added.
            * platform/mac/svg/clip-path/clip-in-mask-expected.txt: Added.
            * platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.checksum: Added.
            * platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.png: Added.
            * platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.txt: Added.
            * platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.checksum: Added.
            * platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.png: Added.
            * platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.txt: Added.
            * platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.checksum: Added.
            * platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.png: Added.
            * platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.txt: Added.
            * platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.checksum: Added.
            * platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.png: Added.
            * platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.txt: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.checksum: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.png: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.txt: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.checksum: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.png: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.txt: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.checksum: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.png: Added.
            * platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.txt: Added.
            * platform/mac/svg/custom/absolute-sized-content-with-resources-expected.checksum:
            * platform/mac/svg/custom/absolute-sized-content-with-resources-expected.png:
            * platform/mac/svg/custom/grayscale-gradient-mask-expected.checksum:
            * platform/mac/svg/custom/grayscale-gradient-mask-expected.png:
            * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.checksum:
            * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png:
            * platform/mac/svg/custom/text-rotated-gradient-expected.checksum:
            * platform/mac/svg/custom/text-rotated-gradient-expected.png:
            * platform/mac/svg/text/selection-background-color-expected.checksum:
            * platform/mac/svg/text/selection-background-color-expected.png:
            * platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.checksum:
            * platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.png:
            * platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.checksum:
            * platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.png:
            * svg/clip-path/clip-in-mask-objectBoundingBox.svg: Added.
            * svg/clip-path/clip-in-mask-userSpaceOnUse.svg: Added.
            * svg/clip-path/clip-in-mask.svg: Added.
            * svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg: Added.
            * svg/clip-path/deep-nested-clip-in-mask.svg: Added.
            * svg/clip-path/nested-clip-in-mask-image-based-clipping.svg: Added.
            * svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg: Added.
            * svg/clip-path/nested-clip-in-mask-path-based-clipping.svg: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65880 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index c5340d0..238afdb 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,64 @@
+2010-08-24  Nikolas Zimmermann  <nzimmermann at rim.com>
+
+        Reviewed by Dirk Schulze.
+
+        clip-path does not work inside mask element
+        https://bugs.webkit.org/show_bug.cgi?id=41428
+
+        Update results of all tests containing <mask> / <pattern> and/or gradient on text (using CG).
+        The ImageBuffer content is now scaled to account for rounding differences, when zooming.
+
+        * platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.checksum:
+        * platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.png:
+        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.checksum:
+        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.png:
+        * platform/mac/svg/clip-path/clip-in-mask-expected.checksum: Added.
+        * platform/mac/svg/clip-path/clip-in-mask-expected.png: Added.
+        * platform/mac/svg/clip-path/clip-in-mask-expected.txt: Added.
+        * platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.checksum: Added.
+        * platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.png: Added.
+        * platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.txt: Added.
+        * platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.checksum: Added.
+        * platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.png: Added.
+        * platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.txt: Added.
+        * platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.checksum: Added.
+        * platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.png: Added.
+        * platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.txt: Added.
+        * platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.checksum: Added.
+        * platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.png: Added.
+        * platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.txt: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.checksum: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.png: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.txt: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.checksum: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.png: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.txt: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.checksum: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.png: Added.
+        * platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.txt: Added.
+        * platform/mac/svg/custom/absolute-sized-content-with-resources-expected.checksum:
+        * platform/mac/svg/custom/absolute-sized-content-with-resources-expected.png:
+        * platform/mac/svg/custom/grayscale-gradient-mask-expected.checksum:
+        * platform/mac/svg/custom/grayscale-gradient-mask-expected.png:
+        * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.checksum:
+        * platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png:
+        * platform/mac/svg/custom/text-rotated-gradient-expected.checksum:
+        * platform/mac/svg/custom/text-rotated-gradient-expected.png:
+        * platform/mac/svg/text/selection-background-color-expected.checksum:
+        * platform/mac/svg/text/selection-background-color-expected.png:
+        * platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.checksum:
+        * platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.png:
+        * platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.checksum:
+        * platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.png:
+        * svg/clip-path/clip-in-mask-objectBoundingBox.svg: Added.
+        * svg/clip-path/clip-in-mask-userSpaceOnUse.svg: Added.
+        * svg/clip-path/clip-in-mask.svg: Added.
+        * svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg: Added.
+        * svg/clip-path/deep-nested-clip-in-mask.svg: Added.
+        * svg/clip-path/nested-clip-in-mask-image-based-clipping.svg: Added.
+        * svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg: Added.
+        * svg/clip-path/nested-clip-in-mask-path-based-clipping.svg: Added.
+
 2010-08-24  Andrei Popescu  <andreip at dhcp-172-16-14-12.lon.corp.google.com>
 
         Reviewed by Jeremy Orlow.
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.checksum b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.checksum
index 0e79e38..1193ec6 100644
--- a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.checksum
+++ b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.checksum
@@ -1 +1 @@
-62a68fa8de7ea652f54ced5930397a1e
\ No newline at end of file
+c9143af98632ecc250a30eb1902e35dc
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.png b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.png
index d6bb9cd..1072d0c 100644
Binary files a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.png and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-intro-01-f-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.checksum b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.checksum
index 16a443d..c736b99 100644
--- a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.checksum
@@ -1 +1 @@
-effebeceed60e2edcd5795281c16f129
\ No newline at end of file
+b4d10b39924990573785324a4e3813da
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.png b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.png
index 2ee597c..0b1fc60 100644
Binary files a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.png and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.checksum
new file mode 100644
index 0000000..33068d5
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.checksum
@@ -0,0 +1 @@
+5d7c3dc8fa03aac52cece76b059e9eb2
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.png b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.png
new file mode 100644
index 0000000..677448b
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.txt b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.txt
new file mode 100644
index 0000000..142526c
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-expected.txt
@@ -0,0 +1,21 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 200x200
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,0.00 L0.50,0.03 L0.50,0.06 L0.49,0.09 L0.48,0.12 L0.48,0.15 L0.46,0.18 L0.45,0.21 L0.44,0.24 L0.42,0.27 L0.40,0.29 L0.39,0.32 L0.36,0.34 L0.34,0.36 L0.32,0.39 L0.29,0.40 L0.27,0.42 L0.24,0.44 L0.21,0.45 L0.18,0.46 L0.15,0.48 L0.12,0.48 L0.09,0.49 L0.06,0.50 L0.03,0.50 L-0.00,0.50 L-0.03,0.50 L-0.06,0.50 L-0.09,0.49 L-0.12,0.48 L-0.15,0.48 L-0.18,0.46 L-0.21,0.45 L-0.24,0.44 L-0.27,0.42 L-0.29,0.40 L-0.32,0.39 L-0.34,0.36 L-0.36,0.34 L-0.39,0.32 L-0.40,0.29 L-0.42,0.27 L-0.44,0.24 L-0.45,0.21 L-0.46,0.18 L-0.48,0.15 L-0.48,0.12 L-0.49,0.09 L-0.50,0.06 L-0.50,0.03 L-0.50,-0.00 L-0.50,-0.03 L-0.50,-0.06 L-0.49,-0.09 L-0.48,-0.12 L-0.48,-0.15 L-0.46,-0.18 L-0.45,-0.21 L-0.44,-0.24 L-0.42,-0.27 L-0.40,-0.29 L-0.39,-0.32 L-0.36,-0.34 L-0.34,-0.36 L-0.32,-0.39 L-0.29,-0.40 L-0.27,-0.42 L-0.24,-0.44 L-0.21,-0.45 L-0.18,-0.46 L-0.15,-0.48 L-0.12,-0.48 L-0.09,-0.49 L-0.06,-0.50 L-0.03,-0.50 L0.00,-0.50 L0.03,-0.50 L0.06,-0.50 L0.09,-0.49 L0.12,-0.48 L0.15,-0.48 L0.18,-0.46 L0.21,-0.45 L0.24,-0.44 L0.27,-0.42 L0.29,-0.40 L0.32,-0.39 L0.34,-0.36 L0.36,-0.34 L0.39,-0.32 L0.40,-0.29 L0.42,-0.27 L0.44,-0.24 L0.45,-0.21 L0.46,-0.18 L0.48,-0.15 L0.48,-0.12 L0.49,-0.09 L0.50,-0.06 L0.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 1x2 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,1.00 L0.50,1.03 L0.50,1.06 L0.49,1.09 L0.48,1.12 L0.48,1.15 L0.46,1.18 L0.45,1.21 L0.44,1.24 L0.42,1.27 L0.40,1.29 L0.39,1.32 L0.36,1.34 L0.34,1.36 L0.32,1.39 L0.29,1.40 L0.27,1.42 L0.24,1.44 L0.21,1.45 L0.18,1.46 L0.15,1.48 L0.12,1.48 L0.09,1.49 L0.06,1.50 L0.03,1.50 L-0.00,1.50 L-0.03,1.50 L-0.06,1.50 L-0.09,1.49 L-0.12,1.48 L-0.15,1.48 L-0.18,1.46 L-0.21,1.45 L-0.24,1.44 L-0.27,1.42 L-0.29,1.40 L-0.32,1.39 L-0.34,1.36 L-0.36,1.34 L-0.39,1.32 L-0.40,1.29 L-0.42,1.27 L-0.44,1.24 L-0.45,1.21 L-0.46,1.18 L-0.48,1.15 L-0.48,1.12 L-0.49,1.09 L-0.50,1.06 L-0.50,1.03 L-0.50,1.00 L-0.50,0.97 L-0.50,0.94 L-0.49,0.91 L-0.48,0.88 L-0.48,0.85 L-0.46,0.82 L-0.45,0.79 L-0.44,0.76 L-0.42,0.73 L-0.40,0.71 L-0.39,0.68 L-0.36,0.66 L-0.34,0.64 L-0.32,0.61 L-0.29,0.60 L-0.27,0.58 L-0.24,0.56 L-0.21,0.55 L-0.18,0.54 L-0.15,0.52 L-0.12,0.52 L-0.09,0.51 L-0.06,0.50 L-0.03,0.50 L0.00,0.50 L0.03,0.50 L0.06,0.50 L0.09,0.51 L0.12,0.52 L0.15,0.52 L0.18,0.54 L0.21,0.55 L0.24,0.56 L0.27,0.58 L0.29,0.60 L0.32,0.61 L0.34,0.64 L0.36,0.66 L0.39,0.68 L0.40,0.71 L0.42,0.73 L0.44,0.76 L0.45,0.79 L0.46,0.82 L0.48,0.85 L0.48,0.88 L0.49,0.91 L0.50,0.94 L0.50,0.97 Z"]
+        RenderPath {circle} at (0,0) size 2x1 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,0.00 L1.50,0.03 L1.50,0.06 L1.49,0.09 L1.48,0.12 L1.48,0.15 L1.46,0.18 L1.45,0.21 L1.44,0.24 L1.42,0.27 L1.40,0.29 L1.39,0.32 L1.36,0.34 L1.34,0.36 L1.32,0.39 L1.29,0.40 L1.27,0.42 L1.24,0.44 L1.21,0.45 L1.18,0.46 L1.15,0.48 L1.12,0.48 L1.09,0.49 L1.06,0.50 L1.03,0.50 L1.00,0.50 L0.97,0.50 L0.94,0.50 L0.91,0.49 L0.88,0.48 L0.85,0.48 L0.82,0.46 L0.79,0.45 L0.76,0.44 L0.73,0.42 L0.71,0.40 L0.68,0.39 L0.66,0.36 L0.64,0.34 L0.61,0.32 L0.60,0.29 L0.58,0.27 L0.56,0.24 L0.55,0.21 L0.54,0.18 L0.52,0.15 L0.52,0.12 L0.51,0.09 L0.50,0.06 L0.50,0.03 L0.50,-0.00 L0.50,-0.03 L0.50,-0.06 L0.51,-0.09 L0.52,-0.12 L0.52,-0.15 L0.54,-0.18 L0.55,-0.21 L0.56,-0.24 L0.58,-0.27 L0.60,-0.29 L0.61,-0.32 L0.64,-0.34 L0.66,-0.36 L0.68,-0.39 L0.71,-0.40 L0.73,-0.42 L0.76,-0.44 L0.79,-0.45 L0.82,-0.46 L0.85,-0.48 L0.88,-0.48 L0.91,-0.49 L0.94,-0.50 L0.97,-0.50 L1.00,-0.50 L1.03,-0.50 L1.06,-0.50 L1.09,-0.49 L1.12,-0.48 L1.15,-0.48 L1.18,-0.46 L1.21,-0.45 L1.24,-0.44 L1.27,-0.42 L1.29,-0.40 L1.32,-0.39 L1.34,-0.36 L1.36,-0.34 L1.39,-0.32 L1.40,-0.29 L1.42,-0.27 L1.44,-0.24 L1.45,-0.21 L1.46,-0.18 L1.48,-0.15 L1.48,-0.12 L1.49,-0.09 L1.50,-0.06 L1.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 2x2 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,1.00 L1.50,1.03 L1.50,1.06 L1.49,1.09 L1.48,1.12 L1.48,1.15 L1.46,1.18 L1.45,1.21 L1.44,1.24 L1.42,1.27 L1.40,1.29 L1.39,1.32 L1.36,1.34 L1.34,1.36 L1.32,1.39 L1.29,1.40 L1.27,1.42 L1.24,1.44 L1.21,1.45 L1.18,1.46 L1.15,1.48 L1.12,1.48 L1.09,1.49 L1.06,1.50 L1.03,1.50 L1.00,1.50 L0.97,1.50 L0.94,1.50 L0.91,1.49 L0.88,1.48 L0.85,1.48 L0.82,1.46 L0.79,1.45 L0.76,1.44 L0.73,1.42 L0.71,1.40 L0.68,1.39 L0.66,1.36 L0.64,1.34 L0.61,1.32 L0.60,1.29 L0.58,1.27 L0.56,1.24 L0.55,1.21 L0.54,1.18 L0.52,1.15 L0.52,1.12 L0.51,1.09 L0.50,1.06 L0.50,1.03 L0.50,1.00 L0.50,0.97 L0.50,0.94 L0.51,0.91 L0.52,0.88 L0.52,0.85 L0.54,0.82 L0.55,0.79 L0.56,0.76 L0.58,0.73 L0.60,0.71 L0.61,0.68 L0.64,0.66 L0.66,0.64 L0.68,0.61 L0.71,0.60 L0.73,0.58 L0.76,0.56 L0.79,0.55 L0.82,0.54 L0.85,0.52 L0.88,0.52 L0.91,0.51 L0.94,0.50 L0.97,0.50 L1.00,0.50 L1.03,0.50 L1.06,0.50 L1.09,0.51 L1.12,0.52 L1.15,0.52 L1.18,0.54 L1.21,0.55 L1.24,0.56 L1.27,0.58 L1.29,0.60 L1.32,0.61 L1.34,0.64 L1.36,0.66 L1.39,0.68 L1.40,0.71 L1.42,0.73 L1.44,0.76 L1.45,0.79 L1.46,0.82 L1.48,0.85 L1.48,0.88 L1.49,0.91 L1.50,0.94 L1.50,0.97 Z"]
+      RenderSVGResourceMasker {mask} [id="mask1"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 2x2
+      RenderSVGResourceMasker {mask} [id="mask2"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 2x2
+    RenderPath {circle} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M100.00,50.00 L99.90,53.14 L99.61,56.27 L99.11,59.37 L98.43,62.43 L97.55,65.45 L96.49,68.41 L95.24,71.29 L93.82,74.09 L92.22,76.79 L90.45,79.39 L88.53,81.87 L86.45,84.23 L84.23,86.45 L81.87,88.53 L79.39,90.45 L76.79,92.22 L74.09,93.82 L71.29,95.24 L68.41,96.49 L65.45,97.55 L62.43,98.43 L59.37,99.11 L56.27,99.61 L53.14,99.90 L50.00,100.00 L46.86,99.90 L43.73,99.61 L40.63,99.11 L37.57,98.43 L34.55,97.55 L31.59,96.49 L28.71,95.24 L25.91,93.82 L23.21,92.22 L20.61,90.45 L18.13,88.53 L15.77,86.45 L13.55,84.23 L11.47,81.87 L9.55,79.39 L7.78,76.79 L6.18,74.09 L4.76,71.29 L3.51,68.41 L2.45,65.45 L1.57,62.43 L0.89,59.37 L0.39,56.27 L0.10,53.14 L0.00,50.00 L0.10,46.86 L0.39,43.73 L0.89,40.63 L1.57,37.57 L2.45,34.55 L3.51,31.59 L4.76,28.71 L6.18,25.91 L7.78,23.21 L9.55,20.61 L11.47,18.13 L13.55,15.77 L15.77,13.55 L18.13,11.47 L20.61,9.55 L23.21,7.78 L25.91,6.18 L28.71,4.76 L31.59,3.51 L34.55,2.45 L37.57,1.57 L40.63,0.89 L43.73,0.39 L46.86,0.10 L50.00,0.00 L53.14,0.10 L56.27,0.39 L59.37,0.89 L62.43,1.57 L65.45,2.45 L68.41,3.51 L71.29,4.76 L74.09,6.18 L76.79,7.78 L79.39,9.55 L81.87,11.47 L84.23,13.55 L86.45,15.77 L88.53,18.13 L90.45,20.61 L92.22,23.21 L93.82,25.91 L95.24,28.71 L96.49,31.59 L97.55,34.55 L98.43,37.57 L99.11,40.63 L99.61,43.73 L99.90,46.86 Z"]
+      [masker="mask1"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+    RenderPath {circle} at (100,100) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M200.00,150.00 L199.90,153.14 L199.61,156.27 L199.11,159.37 L198.43,162.43 L197.55,165.45 L196.49,168.41 L195.24,171.29 L193.82,174.09 L192.22,176.79 L190.45,179.39 L188.53,181.87 L186.45,184.23 L184.23,186.45 L181.87,188.53 L179.39,190.45 L176.79,192.22 L174.09,193.82 L171.29,195.24 L168.41,196.49 L165.45,197.55 L162.43,198.43 L159.37,199.11 L156.27,199.61 L153.14,199.90 L150.00,200.00 L146.86,199.90 L143.73,199.61 L140.63,199.11 L137.57,198.43 L134.55,197.55 L131.59,196.49 L128.71,195.24 L125.91,193.82 L123.21,192.22 L120.61,190.45 L118.13,188.53 L115.77,186.45 L113.55,184.23 L111.47,181.87 L109.55,179.39 L107.78,176.79 L106.18,174.09 L104.76,171.29 L103.51,168.41 L102.45,165.45 L101.57,162.43 L100.89,159.37 L100.39,156.27 L100.10,153.14 L100.00,150.00 L100.10,146.86 L100.39,143.73 L100.89,140.63 L101.57,137.57 L102.45,134.55 L103.51,131.59 L104.76,128.71 L106.18,125.91 L107.78,123.21 L109.55,120.61 L111.47,118.13 L113.55,115.77 L115.77,113.55 L118.13,111.47 L120.61,109.55 L123.21,107.78 L125.91,106.18 L128.71,104.76 L131.59,103.51 L134.55,102.45 L137.57,101.57 L140.63,100.89 L143.73,100.39 L146.86,100.10 L150.00,100.00 L153.14,100.10 L156.27,100.39 L159.37,100.89 L162.43,101.57 L165.45,102.45 L168.41,103.51 L171.29,104.76 L174.09,106.18 L176.79,107.78 L179.39,109.55 L181.87,111.47 L184.23,113.55 L186.45,115.77 L188.53,118.13 L190.45,120.61 L192.22,123.21 L193.82,125.91 L195.24,128.71 L196.49,131.59 L197.55,134.55 L198.43,137.57 L199.11,140.63 L199.61,143.73 L199.90,146.86 Z"]
+      [masker="mask2"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.checksum
new file mode 100644
index 0000000..8a9a00e
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.checksum
@@ -0,0 +1 @@
+e67d3921a9232fb509bd2c3992ac3d3a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.png b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.png
new file mode 100644
index 0000000..0b2c608
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.txt b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.txt
new file mode 100644
index 0000000..2b482f0
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-objectBoundingBox-expected.txt
@@ -0,0 +1,12 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (60,60) size 80x80
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=userSpaceOnUse]
+        RenderPath {circle} at (0,0) size 1x1 [transform={m=((0.01,0.00)(0.00,0.01)) t=(0.00,0.00)}] [fill={[type=SOLID] [color=#000000]}] [data="M90.00,50.00 L89.92,52.51 L89.68,55.01 L89.29,57.50 L88.74,59.95 L88.04,62.36 L87.19,64.72 L86.19,67.03 L85.05,69.27 L83.77,71.43 L82.36,73.51 L80.82,75.50 L79.16,77.38 L77.38,79.16 L75.50,80.82 L73.51,82.36 L71.43,83.77 L69.27,85.05 L67.03,86.19 L64.72,87.19 L62.36,88.04 L59.95,88.74 L57.50,89.29 L55.01,89.68 L52.51,89.92 L50.00,90.00 L47.49,89.92 L44.99,89.68 L42.50,89.29 L40.05,88.74 L37.64,88.04 L35.28,87.19 L32.97,86.19 L30.73,85.05 L28.57,83.77 L26.49,82.36 L24.50,80.82 L22.62,79.16 L20.84,77.38 L19.18,75.50 L17.64,73.51 L16.23,71.43 L14.95,69.27 L13.81,67.03 L12.81,64.72 L11.96,62.36 L11.26,59.95 L10.71,57.50 L10.32,55.01 L10.08,52.51 L10.00,50.00 L10.08,47.49 L10.32,44.99 L10.71,42.50 L11.26,40.05 L11.96,37.64 L12.81,35.28 L13.81,32.97 L14.95,30.73 L16.23,28.57 L17.64,26.49 L19.18,24.50 L20.84,22.62 L22.62,20.84 L24.50,19.18 L26.49,17.64 L28.57,16.23 L30.73,14.95 L32.97,13.81 L35.28,12.81 L37.64,11.96 L40.05,11.26 L42.50,10.71 L44.99,10.32 L47.49,10.08 L50.00,10.00 L52.51,10.08 L55.01,10.32 L57.50,10.71 L59.95,11.26 L62.36,11.96 L64.72,12.81 L67.03,13.81 L69.27,14.95 L71.43,16.23 L73.51,17.64 L75.50,19.18 L77.38,20.84 L79.16,22.62 L80.82,24.50 L82.36,26.49 L83.77,28.57 L85.05,30.73 L86.19,32.97 L87.19,35.28 L88.04,37.64 L88.74,40.05 L89.29,42.50 L89.68,44.99 L89.92,47.49 Z"]
+      RenderSVGResourceMasker {mask} [id="mask"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0.10,0.10) size 0.80x0.80
+    RenderPath {rect} at (60,60) size 80x80 [fill={[type=SOLID] [color=#008000]}] [data="M50.00,50.00 L150.00,50.00 L150.00,150.00 L50.00,150.00 Z"]
+      [masker="mask"] RenderSVGResourceMasker {mask} at (60,60) size 80x80
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.checksum
new file mode 100644
index 0000000..8a9a00e
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.checksum
@@ -0,0 +1 @@
+e67d3921a9232fb509bd2c3992ac3d3a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.png b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.png
new file mode 100644
index 0000000..0b2c608
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.txt b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.txt
new file mode 100644
index 0000000..55a6a19
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/clip-in-mask-userSpaceOnUse-expected.txt
@@ -0,0 +1,12 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (60,60) size 80x80
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=userSpaceOnUse]
+        RenderPath {circle} at (0,0) size 1x1 [transform={m=((0.01,0.00)(0.00,0.01)) t=(0.00,0.00)}] [fill={[type=SOLID] [color=#000000]}] [data="M90.00,50.00 L89.92,52.51 L89.68,55.01 L89.29,57.50 L88.74,59.95 L88.04,62.36 L87.19,64.72 L86.19,67.03 L85.05,69.27 L83.77,71.43 L82.36,73.51 L80.82,75.50 L79.16,77.38 L77.38,79.16 L75.50,80.82 L73.51,82.36 L71.43,83.77 L69.27,85.05 L67.03,86.19 L64.72,87.19 L62.36,88.04 L59.95,88.74 L57.50,89.29 L55.01,89.68 L52.51,89.92 L50.00,90.00 L47.49,89.92 L44.99,89.68 L42.50,89.29 L40.05,88.74 L37.64,88.04 L35.28,87.19 L32.97,86.19 L30.73,85.05 L28.57,83.77 L26.49,82.36 L24.50,80.82 L22.62,79.16 L20.84,77.38 L19.18,75.50 L17.64,73.51 L16.23,71.43 L14.95,69.27 L13.81,67.03 L12.81,64.72 L11.96,62.36 L11.26,59.95 L10.71,57.50 L10.32,55.01 L10.08,52.51 L10.00,50.00 L10.08,47.49 L10.32,44.99 L10.71,42.50 L11.26,40.05 L11.96,37.64 L12.81,35.28 L13.81,32.97 L14.95,30.73 L16.23,28.57 L17.64,26.49 L19.18,24.50 L20.84,22.62 L22.62,20.84 L24.50,19.18 L26.49,17.64 L28.57,16.23 L30.73,14.95 L32.97,13.81 L35.28,12.81 L37.64,11.96 L40.05,11.26 L42.50,10.71 L44.99,10.32 L47.49,10.08 L50.00,10.00 L52.51,10.08 L55.01,10.32 L57.50,10.71 L59.95,11.26 L62.36,11.96 L64.72,12.81 L67.03,13.81 L69.27,14.95 L71.43,16.23 L73.51,17.64 L75.50,19.18 L77.38,20.84 L79.16,22.62 L80.82,24.50 L82.36,26.49 L83.77,28.57 L85.05,30.73 L86.19,32.97 L87.19,35.28 L88.04,37.64 L88.74,40.05 L89.29,42.50 L89.68,44.99 L89.92,47.49 Z"]
+      RenderSVGResourceMasker {mask} [id="mask"] [maskUnits=userSpaceOnUse] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0.10,0.10) size 0.80x0.80
+    RenderPath {rect} at (60,60) size 80x80 [fill={[type=SOLID] [color=#008000]}] [data="M50.00,50.00 L150.00,50.00 L150.00,150.00 L50.00,150.00 Z"]
+      [masker="mask"] RenderSVGResourceMasker {mask} at (60,60) size 80x80
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.checksum
new file mode 100644
index 0000000..8243270
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.checksum
@@ -0,0 +1 @@
+6a43664f477e8c0aaaa73801b621e5e0
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.png b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.png
new file mode 100644
index 0000000..6552e70
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.txt b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.txt
new file mode 100644
index 0000000..72bcb71
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes-expected.txt
@@ -0,0 +1,30 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 231x229
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip0"] [clipPathUnits=userSpaceOnUse]
+        RenderPath {circle} at (50,50) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M150.00,100.00 L149.90,103.14 L149.61,106.27 L149.11,109.37 L148.43,112.43 L147.55,115.45 L146.49,118.41 L145.24,121.29 L143.82,124.09 L142.22,126.79 L140.45,129.39 L138.53,131.87 L136.45,134.23 L134.23,136.45 L131.87,138.53 L129.39,140.45 L126.79,142.22 L124.09,143.82 L121.29,145.24 L118.41,146.49 L115.45,147.55 L112.43,148.43 L109.37,149.11 L106.27,149.61 L103.14,149.90 L100.00,150.00 L96.86,149.90 L93.73,149.61 L90.63,149.11 L87.57,148.43 L84.55,147.55 L81.59,146.49 L78.71,145.24 L75.91,143.82 L73.21,142.22 L70.61,140.45 L68.13,138.53 L65.77,136.45 L63.55,134.23 L61.47,131.87 L59.55,129.39 L57.78,126.79 L56.18,124.09 L54.76,121.29 L53.51,118.41 L52.45,115.45 L51.57,112.43 L50.89,109.37 L50.39,106.27 L50.10,103.14 L50.00,100.00 L50.10,96.86 L50.39,93.73 L50.89,90.63 L51.57,87.57 L52.45,84.55 L53.51,81.59 L54.76,78.71 L56.18,75.91 L57.78,73.21 L59.55,70.61 L61.47,68.13 L63.55,65.77 L65.77,63.55 L68.13,61.47 L70.61,59.55 L73.21,57.78 L75.91,56.18 L78.71,54.76 L81.59,53.51 L84.55,52.45 L87.57,51.57 L90.63,50.89 L93.73,50.39 L96.86,50.10 L100.00,50.00 L103.14,50.10 L106.27,50.39 L109.37,50.89 L112.43,51.57 L115.45,52.45 L118.41,53.51 L121.29,54.76 L124.09,56.18 L126.79,57.78 L129.39,59.55 L131.87,61.47 L134.23,63.55 L136.45,65.77 L138.53,68.13 L140.45,70.61 L142.22,73.21 L143.82,75.91 L145.24,78.71 L146.49,81.59 L147.55,84.55 L148.43,87.57 L149.11,90.63 L149.61,93.73 L149.90,96.86 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip1"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,0.00 L0.50,0.03 L0.50,0.06 L0.49,0.09 L0.48,0.12 L0.48,0.15 L0.46,0.18 L0.45,0.21 L0.44,0.24 L0.42,0.27 L0.40,0.29 L0.39,0.32 L0.36,0.34 L0.34,0.36 L0.32,0.39 L0.29,0.40 L0.27,0.42 L0.24,0.44 L0.21,0.45 L0.18,0.46 L0.15,0.48 L0.12,0.48 L0.09,0.49 L0.06,0.50 L0.03,0.50 L-0.00,0.50 L-0.03,0.50 L-0.06,0.50 L-0.09,0.49 L-0.12,0.48 L-0.15,0.48 L-0.18,0.46 L-0.21,0.45 L-0.24,0.44 L-0.27,0.42 L-0.29,0.40 L-0.32,0.39 L-0.34,0.36 L-0.36,0.34 L-0.39,0.32 L-0.40,0.29 L-0.42,0.27 L-0.44,0.24 L-0.45,0.21 L-0.46,0.18 L-0.48,0.15 L-0.48,0.12 L-0.49,0.09 L-0.50,0.06 L-0.50,0.03 L-0.50,-0.00 L-0.50,-0.03 L-0.50,-0.06 L-0.49,-0.09 L-0.48,-0.12 L-0.48,-0.15 L-0.46,-0.18 L-0.45,-0.21 L-0.44,-0.24 L-0.42,-0.27 L-0.40,-0.29 L-0.39,-0.32 L-0.36,-0.34 L-0.34,-0.36 L-0.32,-0.39 L-0.29,-0.40 L-0.27,-0.42 L-0.24,-0.44 L-0.21,-0.45 L-0.18,-0.46 L-0.15,-0.48 L-0.12,-0.48 L-0.09,-0.49 L-0.06,-0.50 L-0.03,-0.50 L0.00,-0.50 L0.03,-0.50 L0.06,-0.50 L0.09,-0.49 L0.12,-0.48 L0.15,-0.48 L0.18,-0.46 L0.21,-0.45 L0.24,-0.44 L0.27,-0.42 L0.29,-0.40 L0.32,-0.39 L0.34,-0.36 L0.36,-0.34 L0.39,-0.32 L0.40,-0.29 L0.42,-0.27 L0.44,-0.24 L0.45,-0.21 L0.46,-0.18 L0.48,-0.15 L0.48,-0.12 L0.49,-0.09 L0.50,-0.06 L0.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 1x2 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,1.00 L0.50,1.03 L0.50,1.06 L0.49,1.09 L0.48,1.12 L0.48,1.15 L0.46,1.18 L0.45,1.21 L0.44,1.24 L0.42,1.27 L0.40,1.29 L0.39,1.32 L0.36,1.34 L0.34,1.36 L0.32,1.39 L0.29,1.40 L0.27,1.42 L0.24,1.44 L0.21,1.45 L0.18,1.46 L0.15,1.48 L0.12,1.48 L0.09,1.49 L0.06,1.50 L0.03,1.50 L-0.00,1.50 L-0.03,1.50 L-0.06,1.50 L-0.09,1.49 L-0.12,1.48 L-0.15,1.48 L-0.18,1.46 L-0.21,1.45 L-0.24,1.44 L-0.27,1.42 L-0.29,1.40 L-0.32,1.39 L-0.34,1.36 L-0.36,1.34 L-0.39,1.32 L-0.40,1.29 L-0.42,1.27 L-0.44,1.24 L-0.45,1.21 L-0.46,1.18 L-0.48,1.15 L-0.48,1.12 L-0.49,1.09 L-0.50,1.06 L-0.50,1.03 L-0.50,1.00 L-0.50,0.97 L-0.50,0.94 L-0.49,0.91 L-0.48,0.88 L-0.48,0.85 L-0.46,0.82 L-0.45,0.79 L-0.44,0.76 L-0.42,0.73 L-0.40,0.71 L-0.39,0.68 L-0.36,0.66 L-0.34,0.64 L-0.32,0.61 L-0.29,0.60 L-0.27,0.58 L-0.24,0.56 L-0.21,0.55 L-0.18,0.54 L-0.15,0.52 L-0.12,0.52 L-0.09,0.51 L-0.06,0.50 L-0.03,0.50 L0.00,0.50 L0.03,0.50 L0.06,0.50 L0.09,0.51 L0.12,0.52 L0.15,0.52 L0.18,0.54 L0.21,0.55 L0.24,0.56 L0.27,0.58 L0.29,0.60 L0.32,0.61 L0.34,0.64 L0.36,0.66 L0.39,0.68 L0.40,0.71 L0.42,0.73 L0.44,0.76 L0.45,0.79 L0.46,0.82 L0.48,0.85 L0.48,0.88 L0.49,0.91 L0.50,0.94 L0.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip2"] [clipPathUnits=userSpaceOnUse]
+        RenderPath {circle} at (0,0) size 2x1 [transform={m=((0.01,0.00)(0.00,0.01)) t=(0.00,0.00)}] [fill={[type=SOLID] [color=#000000]}] [data="M150.00,0.00 L149.90,3.14 L149.61,6.27 L149.11,9.37 L148.43,12.43 L147.55,15.45 L146.49,18.41 L145.24,21.29 L143.82,24.09 L142.22,26.79 L140.45,29.39 L138.53,31.87 L136.45,34.23 L134.23,36.45 L131.87,38.53 L129.39,40.45 L126.79,42.22 L124.09,43.82 L121.29,45.24 L118.41,46.49 L115.45,47.55 L112.43,48.43 L109.37,49.11 L106.27,49.61 L103.14,49.90 L100.00,50.00 L96.86,49.90 L93.73,49.61 L90.63,49.11 L87.57,48.43 L84.55,47.55 L81.59,46.49 L78.71,45.24 L75.91,43.82 L73.21,42.22 L70.61,40.45 L68.13,38.53 L65.77,36.45 L63.55,34.23 L61.47,31.87 L59.55,29.39 L57.78,26.79 L56.18,24.09 L54.76,21.29 L53.51,18.41 L52.45,15.45 L51.57,12.43 L50.89,9.37 L50.39,6.27 L50.10,3.14 L50.00,-0.00 L50.10,-3.14 L50.39,-6.27 L50.89,-9.37 L51.57,-12.43 L52.45,-15.45 L53.51,-18.41 L54.76,-21.29 L56.18,-24.09 L57.78,-26.79 L59.55,-29.39 L61.47,-31.87 L63.55,-34.23 L65.77,-36.45 L68.13,-38.53 L70.61,-40.45 L73.21,-42.22 L75.91,-43.82 L78.71,-45.24 L81.59,-46.49 L84.55,-47.55 L87.57,-48.43 L90.63,-49.11 L93.73,-49.61 L96.86,-49.90 L100.00,-50.00 L103.14,-49.90 L106.27,-49.61 L109.37,-49.11 L112.43,-48.43 L115.45,-47.55 L118.41,-46.49 L121.29,-45.24 L124.09,-43.82 L126.79,-42.22 L129.39,-40.45 L131.87,-38.53 L134.23,-36.45 L136.45,-34.23 L138.53,-31.87 L140.45,-29.39 L142.22,-26.79 L143.82,-24.09 L145.24,-21.29 L146.49,-18.41 L147.55,-15.45 L148.43,-12.43 L149.11,-9.37 L149.61,-6.27 L149.90,-3.14 Z"]
+        RenderPath {rect} at (0,0) size 2x2 [transform={m=((0.01,0.00)(0.00,0.01)) t=(0.00,0.00)}] [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]
+          [clipPath="clip0"] RenderSVGResourceClipper {clipPath} at (50,50) size 100x100
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip1"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 1x2
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip2"] RenderSVGResourceClipper {clipPath} at (0.50,-0.50) size 1.00x1.50
+      RenderSVGResourceMasker {mask} [id="mask1"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0,0) size 1x1
+    RenderSVGText {text} at (19,211) size 212x18 contains 1 chunk(s)
+      RenderSVGInlineText {#text} at (0,0) size 212x18
+        chunk 1 (middle anchor) text run 1 at (19.00,225.00) startOffset 0 endOffset 33 width 212.00: "Both shapes should look identical"
+    RenderPath {circle} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M100.00,50.00 L99.90,53.14 L99.61,56.27 L99.11,59.37 L98.43,62.43 L97.55,65.45 L96.49,68.41 L95.24,71.29 L93.82,74.09 L92.22,76.79 L90.45,79.39 L88.53,81.87 L86.45,84.23 L84.23,86.45 L81.87,88.53 L79.39,90.45 L76.79,92.22 L74.09,93.82 L71.29,95.24 L68.41,96.49 L65.45,97.55 L62.43,98.43 L59.37,99.11 L56.27,99.61 L53.14,99.90 L50.00,100.00 L46.86,99.90 L43.73,99.61 L40.63,99.11 L37.57,98.43 L34.55,97.55 L31.59,96.49 L28.71,95.24 L25.91,93.82 L23.21,92.22 L20.61,90.45 L18.13,88.53 L15.77,86.45 L13.55,84.23 L11.47,81.87 L9.55,79.39 L7.78,76.79 L6.18,74.09 L4.76,71.29 L3.51,68.41 L2.45,65.45 L1.57,62.43 L0.89,59.37 L0.39,56.27 L0.10,53.14 L0.00,50.00 L0.10,46.86 L0.39,43.73 L0.89,40.63 L1.57,37.57 L2.45,34.55 L3.51,31.59 L4.76,28.71 L6.18,25.91 L7.78,23.21 L9.55,20.61 L11.47,18.13 L13.55,15.77 L15.77,13.55 L18.13,11.47 L20.61,9.55 L23.21,7.78 L25.91,6.18 L28.71,4.76 L31.59,3.51 L34.55,2.45 L37.57,1.57 L40.63,0.89 L43.73,0.39 L46.86,0.10 L50.00,0.00 L53.14,0.10 L56.27,0.39 L59.37,0.89 L62.43,1.57 L65.45,2.45 L68.41,3.51 L71.29,4.76 L74.09,6.18 L76.79,7.78 L79.39,9.55 L81.87,11.47 L84.23,13.55 L86.45,15.77 L88.53,18.13 L90.45,20.61 L92.22,23.21 L93.82,25.91 L95.24,28.71 L96.49,31.59 L97.55,34.55 L98.43,37.57 L99.11,40.63 L99.61,43.73 L99.90,46.86 Z"]
+      [masker="mask1"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+    RenderPath {circle} at (100,100) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M200.00,150.00 L199.90,153.14 L199.61,156.27 L199.11,159.37 L198.43,162.43 L197.55,165.45 L196.49,168.41 L195.24,171.29 L193.82,174.09 L192.22,176.79 L190.45,179.39 L188.53,181.87 L186.45,184.23 L184.23,186.45 L181.87,188.53 L179.39,190.45 L176.79,192.22 L174.09,193.82 L171.29,195.24 L168.41,196.49 L165.45,197.55 L162.43,198.43 L159.37,199.11 L156.27,199.61 L153.14,199.90 L150.00,200.00 L146.86,199.90 L143.73,199.61 L140.63,199.11 L137.57,198.43 L134.55,197.55 L131.59,196.49 L128.71,195.24 L125.91,193.82 L123.21,192.22 L120.61,190.45 L118.13,188.53 L115.77,186.45 L113.55,184.23 L111.47,181.87 L109.55,179.39 L107.78,176.79 L106.18,174.09 L104.76,171.29 L103.51,168.41 L102.45,165.45 L101.57,162.43 L100.89,159.37 L100.39,156.27 L100.10,153.14 L100.00,150.00 L100.10,146.86 L100.39,143.73 L100.89,140.63 L101.57,137.57 L102.45,134.55 L103.51,131.59 L104.76,128.71 L106.18,125.91 L107.78,123.21 L109.55,120.61 L111.47,118.13 L113.55,115.77 L115.77,113.55 L118.13,111.47 L120.61,109.55 L123.21,107.78 L125.91,106.18 L128.71,104.76 L131.59,103.51 L134.55,102.45 L137.57,101.57 L140.63,100.89 L143.73,100.39 L146.86,100.10 L150.00,100.00 L153.14,100.10 L156.27,100.39 L159.37,100.89 L162.43,101.57 L165.45,102.45 L168.41,103.51 L171.29,104.76 L174.09,106.18 L176.79,107.78 L179.39,109.55 L181.87,111.47 L184.23,113.55 L186.45,115.77 L188.53,118.13 L190.45,120.61 L192.22,123.21 L193.82,125.91 L195.24,128.71 L196.49,131.59 L197.55,134.55 L198.43,137.57 L199.11,140.63 L199.61,143.73 L199.90,146.86 Z"]
+      [masker="mask1"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.checksum
new file mode 100644
index 0000000..0fc73db
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.checksum
@@ -0,0 +1 @@
+d86f3de7ffdf3bfcf567dafe1bec515a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.png b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.png
new file mode 100644
index 0000000..70ef9a1
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.txt b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.txt
new file mode 100644
index 0000000..947c7f9
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-expected.txt
@@ -0,0 +1,41 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 231x229
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip1"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,0.00 L0.50,0.03 L0.50,0.06 L0.49,0.09 L0.48,0.12 L0.48,0.15 L0.46,0.18 L0.45,0.21 L0.44,0.24 L0.42,0.27 L0.40,0.29 L0.39,0.32 L0.36,0.34 L0.34,0.36 L0.32,0.39 L0.29,0.40 L0.27,0.42 L0.24,0.44 L0.21,0.45 L0.18,0.46 L0.15,0.48 L0.12,0.48 L0.09,0.49 L0.06,0.50 L0.03,0.50 L-0.00,0.50 L-0.03,0.50 L-0.06,0.50 L-0.09,0.49 L-0.12,0.48 L-0.15,0.48 L-0.18,0.46 L-0.21,0.45 L-0.24,0.44 L-0.27,0.42 L-0.29,0.40 L-0.32,0.39 L-0.34,0.36 L-0.36,0.34 L-0.39,0.32 L-0.40,0.29 L-0.42,0.27 L-0.44,0.24 L-0.45,0.21 L-0.46,0.18 L-0.48,0.15 L-0.48,0.12 L-0.49,0.09 L-0.50,0.06 L-0.50,0.03 L-0.50,-0.00 L-0.50,-0.03 L-0.50,-0.06 L-0.49,-0.09 L-0.48,-0.12 L-0.48,-0.15 L-0.46,-0.18 L-0.45,-0.21 L-0.44,-0.24 L-0.42,-0.27 L-0.40,-0.29 L-0.39,-0.32 L-0.36,-0.34 L-0.34,-0.36 L-0.32,-0.39 L-0.29,-0.40 L-0.27,-0.42 L-0.24,-0.44 L-0.21,-0.45 L-0.18,-0.46 L-0.15,-0.48 L-0.12,-0.48 L-0.09,-0.49 L-0.06,-0.50 L-0.03,-0.50 L0.00,-0.50 L0.03,-0.50 L0.06,-0.50 L0.09,-0.49 L0.12,-0.48 L0.15,-0.48 L0.18,-0.46 L0.21,-0.45 L0.24,-0.44 L0.27,-0.42 L0.29,-0.40 L0.32,-0.39 L0.34,-0.36 L0.36,-0.34 L0.39,-0.32 L0.40,-0.29 L0.42,-0.27 L0.44,-0.24 L0.45,-0.21 L0.46,-0.18 L0.48,-0.15 L0.48,-0.12 L0.49,-0.09 L0.50,-0.06 L0.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 1x2 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,1.00 L0.50,1.03 L0.50,1.06 L0.49,1.09 L0.48,1.12 L0.48,1.15 L0.46,1.18 L0.45,1.21 L0.44,1.24 L0.42,1.27 L0.40,1.29 L0.39,1.32 L0.36,1.34 L0.34,1.36 L0.32,1.39 L0.29,1.40 L0.27,1.42 L0.24,1.44 L0.21,1.45 L0.18,1.46 L0.15,1.48 L0.12,1.48 L0.09,1.49 L0.06,1.50 L0.03,1.50 L-0.00,1.50 L-0.03,1.50 L-0.06,1.50 L-0.09,1.49 L-0.12,1.48 L-0.15,1.48 L-0.18,1.46 L-0.21,1.45 L-0.24,1.44 L-0.27,1.42 L-0.29,1.40 L-0.32,1.39 L-0.34,1.36 L-0.36,1.34 L-0.39,1.32 L-0.40,1.29 L-0.42,1.27 L-0.44,1.24 L-0.45,1.21 L-0.46,1.18 L-0.48,1.15 L-0.48,1.12 L-0.49,1.09 L-0.50,1.06 L-0.50,1.03 L-0.50,1.00 L-0.50,0.97 L-0.50,0.94 L-0.49,0.91 L-0.48,0.88 L-0.48,0.85 L-0.46,0.82 L-0.45,0.79 L-0.44,0.76 L-0.42,0.73 L-0.40,0.71 L-0.39,0.68 L-0.36,0.66 L-0.34,0.64 L-0.32,0.61 L-0.29,0.60 L-0.27,0.58 L-0.24,0.56 L-0.21,0.55 L-0.18,0.54 L-0.15,0.52 L-0.12,0.52 L-0.09,0.51 L-0.06,0.50 L-0.03,0.50 L0.00,0.50 L0.03,0.50 L0.06,0.50 L0.09,0.51 L0.12,0.52 L0.15,0.52 L0.18,0.54 L0.21,0.55 L0.24,0.56 L0.27,0.58 L0.29,0.60 L0.32,0.61 L0.34,0.64 L0.36,0.66 L0.39,0.68 L0.40,0.71 L0.42,0.73 L0.44,0.76 L0.45,0.79 L0.46,0.82 L0.48,0.85 L0.48,0.88 L0.49,0.91 L0.50,0.94 L0.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip2"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 2x1 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,0.00 L1.50,0.03 L1.50,0.06 L1.49,0.09 L1.48,0.12 L1.48,0.15 L1.46,0.18 L1.45,0.21 L1.44,0.24 L1.42,0.27 L1.40,0.29 L1.39,0.32 L1.36,0.34 L1.34,0.36 L1.32,0.39 L1.29,0.40 L1.27,0.42 L1.24,0.44 L1.21,0.45 L1.18,0.46 L1.15,0.48 L1.12,0.48 L1.09,0.49 L1.06,0.50 L1.03,0.50 L1.00,0.50 L0.97,0.50 L0.94,0.50 L0.91,0.49 L0.88,0.48 L0.85,0.48 L0.82,0.46 L0.79,0.45 L0.76,0.44 L0.73,0.42 L0.71,0.40 L0.68,0.39 L0.66,0.36 L0.64,0.34 L0.61,0.32 L0.60,0.29 L0.58,0.27 L0.56,0.24 L0.55,0.21 L0.54,0.18 L0.52,0.15 L0.52,0.12 L0.51,0.09 L0.50,0.06 L0.50,0.03 L0.50,-0.00 L0.50,-0.03 L0.50,-0.06 L0.51,-0.09 L0.52,-0.12 L0.52,-0.15 L0.54,-0.18 L0.55,-0.21 L0.56,-0.24 L0.58,-0.27 L0.60,-0.29 L0.61,-0.32 L0.64,-0.34 L0.66,-0.36 L0.68,-0.39 L0.71,-0.40 L0.73,-0.42 L0.76,-0.44 L0.79,-0.45 L0.82,-0.46 L0.85,-0.48 L0.88,-0.48 L0.91,-0.49 L0.94,-0.50 L0.97,-0.50 L1.00,-0.50 L1.03,-0.50 L1.06,-0.50 L1.09,-0.49 L1.12,-0.48 L1.15,-0.48 L1.18,-0.46 L1.21,-0.45 L1.24,-0.44 L1.27,-0.42 L1.29,-0.40 L1.32,-0.39 L1.34,-0.36 L1.36,-0.34 L1.39,-0.32 L1.40,-0.29 L1.42,-0.27 L1.44,-0.24 L1.45,-0.21 L1.46,-0.18 L1.48,-0.15 L1.48,-0.12 L1.49,-0.09 L1.50,-0.06 L1.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 2x2 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,1.00 L1.50,1.03 L1.50,1.06 L1.49,1.09 L1.48,1.12 L1.48,1.15 L1.46,1.18 L1.45,1.21 L1.44,1.24 L1.42,1.27 L1.40,1.29 L1.39,1.32 L1.36,1.34 L1.34,1.36 L1.32,1.39 L1.29,1.40 L1.27,1.42 L1.24,1.44 L1.21,1.45 L1.18,1.46 L1.15,1.48 L1.12,1.48 L1.09,1.49 L1.06,1.50 L1.03,1.50 L1.00,1.50 L0.97,1.50 L0.94,1.50 L0.91,1.49 L0.88,1.48 L0.85,1.48 L0.82,1.46 L0.79,1.45 L0.76,1.44 L0.73,1.42 L0.71,1.40 L0.68,1.39 L0.66,1.36 L0.64,1.34 L0.61,1.32 L0.60,1.29 L0.58,1.27 L0.56,1.24 L0.55,1.21 L0.54,1.18 L0.52,1.15 L0.52,1.12 L0.51,1.09 L0.50,1.06 L0.50,1.03 L0.50,1.00 L0.50,0.97 L0.50,0.94 L0.51,0.91 L0.52,0.88 L0.52,0.85 L0.54,0.82 L0.55,0.79 L0.56,0.76 L0.58,0.73 L0.60,0.71 L0.61,0.68 L0.64,0.66 L0.66,0.64 L0.68,0.61 L0.71,0.60 L0.73,0.58 L0.76,0.56 L0.79,0.55 L0.82,0.54 L0.85,0.52 L0.88,0.52 L0.91,0.51 L0.94,0.50 L0.97,0.50 L1.00,0.50 L1.03,0.50 L1.06,0.50 L1.09,0.51 L1.12,0.52 L1.15,0.52 L1.18,0.54 L1.21,0.55 L1.24,0.56 L1.27,0.58 L1.29,0.60 L1.32,0.61 L1.34,0.64 L1.36,0.66 L1.39,0.68 L1.40,0.71 L1.42,0.73 L1.44,0.76 L1.45,0.79 L1.46,0.82 L1.48,0.85 L1.48,0.88 L1.49,0.91 L1.50,0.94 L1.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip1"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 1x2
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip2"] RenderSVGResourceClipper {clipPath} at (0.50,-0.50) size 1x2
+      RenderSVGResourceMasker {mask} [id="mask1a"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip1"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 1x2
+      RenderSVGResourceMasker {mask} [id="mask1b"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip2"] RenderSVGResourceClipper {clipPath} at (0.50,-0.50) size 1x2
+      RenderSVGResourceMasker {mask} [id="mask2"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [masker="mask1a"] RenderSVGResourceMasker {mask} at (0,0) size 1x1
+      RenderSVGResourceMasker {mask} [id="mask3"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [masker="mask1b"] RenderSVGResourceMasker {mask} at (0,0) size 1x1
+    RenderSVGText {text} at (19,211) size 212x18 contains 1 chunk(s)
+      RenderSVGInlineText {#text} at (0,0) size 212x18
+        chunk 1 (middle anchor) text run 1 at (19.00,225.00) startOffset 0 endOffset 33 width 212.00: "Both shapes should look identical"
+    RenderSVGContainer {g} at (0,0) size 100x100
+      [masker="mask1a"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+      RenderPath {circle} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M100.00,50.00 L99.90,53.14 L99.61,56.27 L99.11,59.37 L98.43,62.43 L97.55,65.45 L96.49,68.41 L95.24,71.29 L93.82,74.09 L92.22,76.79 L90.45,79.39 L88.53,81.87 L86.45,84.23 L84.23,86.45 L81.87,88.53 L79.39,90.45 L76.79,92.22 L74.09,93.82 L71.29,95.24 L68.41,96.49 L65.45,97.55 L62.43,98.43 L59.37,99.11 L56.27,99.61 L53.14,99.90 L50.00,100.00 L46.86,99.90 L43.73,99.61 L40.63,99.11 L37.57,98.43 L34.55,97.55 L31.59,96.49 L28.71,95.24 L25.91,93.82 L23.21,92.22 L20.61,90.45 L18.13,88.53 L15.77,86.45 L13.55,84.23 L11.47,81.87 L9.55,79.39 L7.78,76.79 L6.18,74.09 L4.76,71.29 L3.51,68.41 L2.45,65.45 L1.57,62.43 L0.89,59.37 L0.39,56.27 L0.10,53.14 L0.00,50.00 L0.10,46.86 L0.39,43.73 L0.89,40.63 L1.57,37.57 L2.45,34.55 L3.51,31.59 L4.76,28.71 L6.18,25.91 L7.78,23.21 L9.55,20.61 L11.47,18.13 L13.55,15.77 L15.77,13.55 L18.13,11.47 L20.61,9.55 L23.21,7.78 L25.91,6.18 L28.71,4.76 L31.59,3.51 L34.55,2.45 L37.57,1.57 L40.63,0.89 L43.73,0.39 L46.86,0.10 L50.00,0.00 L53.14,0.10 L56.27,0.39 L59.37,0.89 L62.43,1.57 L65.45,2.45 L68.41,3.51 L71.29,4.76 L74.09,6.18 L76.79,7.78 L79.39,9.55 L81.87,11.47 L84.23,13.55 L86.45,15.77 L88.53,18.13 L90.45,20.61 L92.22,23.21 L93.82,25.91 L95.24,28.71 L96.49,31.59 L97.55,34.55 L98.43,37.57 L99.11,40.63 L99.61,43.73 L99.90,46.86 Z"]
+        [masker="mask1b"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+    RenderSVGContainer {g} at (100,100) size 100x100
+      [masker="mask3"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
+      RenderPath {circle} at (100,100) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M200.00,150.00 L199.90,153.14 L199.61,156.27 L199.11,159.37 L198.43,162.43 L197.55,165.45 L196.49,168.41 L195.24,171.29 L193.82,174.09 L192.22,176.79 L190.45,179.39 L188.53,181.87 L186.45,184.23 L184.23,186.45 L181.87,188.53 L179.39,190.45 L176.79,192.22 L174.09,193.82 L171.29,195.24 L168.41,196.49 L165.45,197.55 L162.43,198.43 L159.37,199.11 L156.27,199.61 L153.14,199.90 L150.00,200.00 L146.86,199.90 L143.73,199.61 L140.63,199.11 L137.57,198.43 L134.55,197.55 L131.59,196.49 L128.71,195.24 L125.91,193.82 L123.21,192.22 L120.61,190.45 L118.13,188.53 L115.77,186.45 L113.55,184.23 L111.47,181.87 L109.55,179.39 L107.78,176.79 L106.18,174.09 L104.76,171.29 L103.51,168.41 L102.45,165.45 L101.57,162.43 L100.89,159.37 L100.39,156.27 L100.10,153.14 L100.00,150.00 L100.10,146.86 L100.39,143.73 L100.89,140.63 L101.57,137.57 L102.45,134.55 L103.51,131.59 L104.76,128.71 L106.18,125.91 L107.78,123.21 L109.55,120.61 L111.47,118.13 L113.55,115.77 L115.77,113.55 L118.13,111.47 L120.61,109.55 L123.21,107.78 L125.91,106.18 L128.71,104.76 L131.59,103.51 L134.55,102.45 L137.57,101.57 L140.63,100.89 L143.73,100.39 L146.86,100.10 L150.00,100.00 L153.14,100.10 L156.27,100.39 L159.37,100.89 L162.43,101.57 L165.45,102.45 L168.41,103.51 L171.29,104.76 L174.09,106.18 L176.79,107.78 L179.39,109.55 L181.87,111.47 L184.23,113.55 L186.45,115.77 L188.53,118.13 L190.45,120.61 L192.22,123.21 L193.82,125.91 L195.24,128.71 L196.49,131.59 L197.55,134.55 L198.43,137.57 L199.11,140.63 L199.61,143.73 L199.90,146.86 Z"]
+        [masker="mask2"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.checksum
new file mode 100644
index 0000000..ff17fe5
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.checksum
@@ -0,0 +1 @@
+4da35a54a651a2d7f7ad45624b29ff16
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.png b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.png
new file mode 100644
index 0000000..994e26e
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.txt b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.txt
new file mode 100644
index 0000000..7cb7a3a
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/deep-nested-clip-in-mask-panning-expected.txt
@@ -0,0 +1,44 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 331x279
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip1"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,0.00 L0.50,0.03 L0.50,0.06 L0.49,0.09 L0.48,0.12 L0.48,0.15 L0.46,0.18 L0.45,0.21 L0.44,0.24 L0.42,0.27 L0.40,0.29 L0.39,0.32 L0.36,0.34 L0.34,0.36 L0.32,0.39 L0.29,0.40 L0.27,0.42 L0.24,0.44 L0.21,0.45 L0.18,0.46 L0.15,0.48 L0.12,0.48 L0.09,0.49 L0.06,0.50 L0.03,0.50 L-0.00,0.50 L-0.03,0.50 L-0.06,0.50 L-0.09,0.49 L-0.12,0.48 L-0.15,0.48 L-0.18,0.46 L-0.21,0.45 L-0.24,0.44 L-0.27,0.42 L-0.29,0.40 L-0.32,0.39 L-0.34,0.36 L-0.36,0.34 L-0.39,0.32 L-0.40,0.29 L-0.42,0.27 L-0.44,0.24 L-0.45,0.21 L-0.46,0.18 L-0.48,0.15 L-0.48,0.12 L-0.49,0.09 L-0.50,0.06 L-0.50,0.03 L-0.50,-0.00 L-0.50,-0.03 L-0.50,-0.06 L-0.49,-0.09 L-0.48,-0.12 L-0.48,-0.15 L-0.46,-0.18 L-0.45,-0.21 L-0.44,-0.24 L-0.42,-0.27 L-0.40,-0.29 L-0.39,-0.32 L-0.36,-0.34 L-0.34,-0.36 L-0.32,-0.39 L-0.29,-0.40 L-0.27,-0.42 L-0.24,-0.44 L-0.21,-0.45 L-0.18,-0.46 L-0.15,-0.48 L-0.12,-0.48 L-0.09,-0.49 L-0.06,-0.50 L-0.03,-0.50 L0.00,-0.50 L0.03,-0.50 L0.06,-0.50 L0.09,-0.49 L0.12,-0.48 L0.15,-0.48 L0.18,-0.46 L0.21,-0.45 L0.24,-0.44 L0.27,-0.42 L0.29,-0.40 L0.32,-0.39 L0.34,-0.36 L0.36,-0.34 L0.39,-0.32 L0.40,-0.29 L0.42,-0.27 L0.44,-0.24 L0.45,-0.21 L0.46,-0.18 L0.48,-0.15 L0.48,-0.12 L0.49,-0.09 L0.50,-0.06 L0.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,1.00 L0.50,1.03 L0.50,1.06 L0.49,1.09 L0.48,1.12 L0.48,1.15 L0.46,1.18 L0.45,1.21 L0.44,1.24 L0.42,1.27 L0.40,1.29 L0.39,1.32 L0.36,1.34 L0.34,1.36 L0.32,1.39 L0.29,1.40 L0.27,1.42 L0.24,1.44 L0.21,1.45 L0.18,1.46 L0.15,1.48 L0.12,1.48 L0.09,1.49 L0.06,1.50 L0.03,1.50 L-0.00,1.50 L-0.03,1.50 L-0.06,1.50 L-0.09,1.49 L-0.12,1.48 L-0.15,1.48 L-0.18,1.46 L-0.21,1.45 L-0.24,1.44 L-0.27,1.42 L-0.29,1.40 L-0.32,1.39 L-0.34,1.36 L-0.36,1.34 L-0.39,1.32 L-0.40,1.29 L-0.42,1.27 L-0.44,1.24 L-0.45,1.21 L-0.46,1.18 L-0.48,1.15 L-0.48,1.12 L-0.49,1.09 L-0.50,1.06 L-0.50,1.03 L-0.50,1.00 L-0.50,0.97 L-0.50,0.94 L-0.49,0.91 L-0.48,0.88 L-0.48,0.85 L-0.46,0.82 L-0.45,0.79 L-0.44,0.76 L-0.42,0.73 L-0.40,0.71 L-0.39,0.68 L-0.36,0.66 L-0.34,0.64 L-0.32,0.61 L-0.29,0.60 L-0.27,0.58 L-0.24,0.56 L-0.21,0.55 L-0.18,0.54 L-0.15,0.52 L-0.12,0.52 L-0.09,0.51 L-0.06,0.50 L-0.03,0.50 L0.00,0.50 L0.03,0.50 L0.06,0.50 L0.09,0.51 L0.12,0.52 L0.15,0.52 L0.18,0.54 L0.21,0.55 L0.24,0.56 L0.27,0.58 L0.29,0.60 L0.32,0.61 L0.34,0.64 L0.36,0.66 L0.39,0.68 L0.40,0.71 L0.42,0.73 L0.44,0.76 L0.45,0.79 L0.46,0.82 L0.48,0.85 L0.48,0.88 L0.49,0.91 L0.50,0.94 L0.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip2"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,0.00 L1.50,0.03 L1.50,0.06 L1.49,0.09 L1.48,0.12 L1.48,0.15 L1.46,0.18 L1.45,0.21 L1.44,0.24 L1.42,0.27 L1.40,0.29 L1.39,0.32 L1.36,0.34 L1.34,0.36 L1.32,0.39 L1.29,0.40 L1.27,0.42 L1.24,0.44 L1.21,0.45 L1.18,0.46 L1.15,0.48 L1.12,0.48 L1.09,0.49 L1.06,0.50 L1.03,0.50 L1.00,0.50 L0.97,0.50 L0.94,0.50 L0.91,0.49 L0.88,0.48 L0.85,0.48 L0.82,0.46 L0.79,0.45 L0.76,0.44 L0.73,0.42 L0.71,0.40 L0.68,0.39 L0.66,0.36 L0.64,0.34 L0.61,0.32 L0.60,0.29 L0.58,0.27 L0.56,0.24 L0.55,0.21 L0.54,0.18 L0.52,0.15 L0.52,0.12 L0.51,0.09 L0.50,0.06 L0.50,0.03 L0.50,-0.00 L0.50,-0.03 L0.50,-0.06 L0.51,-0.09 L0.52,-0.12 L0.52,-0.15 L0.54,-0.18 L0.55,-0.21 L0.56,-0.24 L0.58,-0.27 L0.60,-0.29 L0.61,-0.32 L0.64,-0.34 L0.66,-0.36 L0.68,-0.39 L0.71,-0.40 L0.73,-0.42 L0.76,-0.44 L0.79,-0.45 L0.82,-0.46 L0.85,-0.48 L0.88,-0.48 L0.91,-0.49 L0.94,-0.50 L0.97,-0.50 L1.00,-0.50 L1.03,-0.50 L1.06,-0.50 L1.09,-0.49 L1.12,-0.48 L1.15,-0.48 L1.18,-0.46 L1.21,-0.45 L1.24,-0.44 L1.27,-0.42 L1.29,-0.40 L1.32,-0.39 L1.34,-0.36 L1.36,-0.34 L1.39,-0.32 L1.40,-0.29 L1.42,-0.27 L1.44,-0.24 L1.45,-0.21 L1.46,-0.18 L1.48,-0.15 L1.48,-0.12 L1.49,-0.09 L1.50,-0.06 L1.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,1.00 L1.50,1.03 L1.50,1.06 L1.49,1.09 L1.48,1.12 L1.48,1.15 L1.46,1.18 L1.45,1.21 L1.44,1.24 L1.42,1.27 L1.40,1.29 L1.39,1.32 L1.36,1.34 L1.34,1.36 L1.32,1.39 L1.29,1.40 L1.27,1.42 L1.24,1.44 L1.21,1.45 L1.18,1.46 L1.15,1.48 L1.12,1.48 L1.09,1.49 L1.06,1.50 L1.03,1.50 L1.00,1.50 L0.97,1.50 L0.94,1.50 L0.91,1.49 L0.88,1.48 L0.85,1.48 L0.82,1.46 L0.79,1.45 L0.76,1.44 L0.73,1.42 L0.71,1.40 L0.68,1.39 L0.66,1.36 L0.64,1.34 L0.61,1.32 L0.60,1.29 L0.58,1.27 L0.56,1.24 L0.55,1.21 L0.54,1.18 L0.52,1.15 L0.52,1.12 L0.51,1.09 L0.50,1.06 L0.50,1.03 L0.50,1.00 L0.50,0.97 L0.50,0.94 L0.51,0.91 L0.52,0.88 L0.52,0.85 L0.54,0.82 L0.55,0.79 L0.56,0.76 L0.58,0.73 L0.60,0.71 L0.61,0.68 L0.64,0.66 L0.66,0.64 L0.68,0.61 L0.71,0.60 L0.73,0.58 L0.76,0.56 L0.79,0.55 L0.82,0.54 L0.85,0.52 L0.88,0.52 L0.91,0.51 L0.94,0.50 L0.97,0.50 L1.00,0.50 L1.03,0.50 L1.06,0.50 L1.09,0.51 L1.12,0.52 L1.15,0.52 L1.18,0.54 L1.21,0.55 L1.24,0.56 L1.27,0.58 L1.29,0.60 L1.32,0.61 L1.34,0.64 L1.36,0.66 L1.39,0.68 L1.40,0.71 L1.42,0.73 L1.44,0.76 L1.45,0.79 L1.46,0.82 L1.48,0.85 L1.48,0.88 L1.49,0.91 L1.50,0.94 L1.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip1"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 1x2
+        RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip2"] RenderSVGResourceClipper {clipPath} at (0.50,-0.50) size 1x2
+      RenderSVGResourceMasker {mask} [id="mask1a"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip1"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 1x2
+      RenderSVGResourceMasker {mask} [id="mask1b"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip2"] RenderSVGResourceClipper {clipPath} at (0.50,-0.50) size 1x2
+      RenderSVGResourceMasker {mask} [id="mask2"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [masker="mask1a"] RenderSVGResourceMasker {mask} at (0,0) size 1x1
+      RenderSVGResourceMasker {mask} [id="mask3"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [masker="mask1b"] RenderSVGResourceMasker {mask} at (0,0) size 1x1
+    RenderSVGContainer {g} at (0,0) size 25x100
+      [masker="mask1a"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+      RenderPath {circle} at (0,0) size 25x100 [fill={[type=SOLID] [color=#000000]}] [data="M100.00,50.00 L99.90,53.14 L99.61,56.27 L99.11,59.37 L98.43,62.43 L97.55,65.45 L96.49,68.41 L95.24,71.29 L93.82,74.09 L92.22,76.79 L90.45,79.39 L88.53,81.87 L86.45,84.23 L84.23,86.45 L81.87,88.53 L79.39,90.45 L76.79,92.22 L74.09,93.82 L71.29,95.24 L68.41,96.49 L65.45,97.55 L62.43,98.43 L59.37,99.11 L56.27,99.61 L53.14,99.90 L50.00,100.00 L46.86,99.90 L43.73,99.61 L40.63,99.11 L37.57,98.43 L34.55,97.55 L31.59,96.49 L28.71,95.24 L25.91,93.82 L23.21,92.22 L20.61,90.45 L18.13,88.53 L15.77,86.45 L13.55,84.23 L11.47,81.87 L9.55,79.39 L7.78,76.79 L6.18,74.09 L4.76,71.29 L3.51,68.41 L2.45,65.45 L1.57,62.43 L0.89,59.37 L0.39,56.27 L0.10,53.14 L0.00,50.00 L0.10,46.86 L0.39,43.73 L0.89,40.63 L1.57,37.57 L2.45,34.55 L3.51,31.59 L4.76,28.71 L6.18,25.91 L7.78,23.21 L9.55,20.61 L11.47,18.13 L13.55,15.77 L15.77,13.55 L18.13,11.47 L20.61,9.55 L23.21,7.78 L25.91,6.18 L28.71,4.76 L31.59,3.51 L34.55,2.45 L37.57,1.57 L40.63,0.89 L43.73,0.39 L46.86,0.10 L50.00,0.00 L53.14,0.10 L56.27,0.39 L59.37,0.89 L62.43,1.57 L65.45,2.45 L68.41,3.51 L71.29,4.76 L74.09,6.18 L76.79,7.78 L79.39,9.55 L81.87,11.47 L84.23,13.55 L86.45,15.77 L88.53,18.13 L90.45,20.61 L92.22,23.21 L93.82,25.91 L95.24,28.71 L96.49,31.59 L97.55,34.55 L98.43,37.57 L99.11,40.63 L99.61,43.73 L99.90,46.86 Z"]
+        [masker="mask1b"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+    RenderSVGContainer {g} at (25,100) size 100x100
+      [masker="mask3"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
+      RenderPath {circle} at (25,100) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M200.00,150.00 L199.90,153.14 L199.61,156.27 L199.11,159.37 L198.43,162.43 L197.55,165.45 L196.49,168.41 L195.24,171.29 L193.82,174.09 L192.22,176.79 L190.45,179.39 L188.53,181.87 L186.45,184.23 L184.23,186.45 L181.87,188.53 L179.39,190.45 L176.79,192.22 L174.09,193.82 L171.29,195.24 L168.41,196.49 L165.45,197.55 L162.43,198.43 L159.37,199.11 L156.27,199.61 L153.14,199.90 L150.00,200.00 L146.86,199.90 L143.73,199.61 L140.63,199.11 L137.57,198.43 L134.55,197.55 L131.59,196.49 L128.71,195.24 L125.91,193.82 L123.21,192.22 L120.61,190.45 L118.13,188.53 L115.77,186.45 L113.55,184.23 L111.47,181.87 L109.55,179.39 L107.78,176.79 L106.18,174.09 L104.76,171.29 L103.51,168.41 L102.45,165.45 L101.57,162.43 L100.89,159.37 L100.39,156.27 L100.10,153.14 L100.00,150.00 L100.10,146.86 L100.39,143.73 L100.89,140.63 L101.57,137.57 L102.45,134.55 L103.51,131.59 L104.76,128.71 L106.18,125.91 L107.78,123.21 L109.55,120.61 L111.47,118.13 L113.55,115.77 L115.77,113.55 L118.13,111.47 L120.61,109.55 L123.21,107.78 L125.91,106.18 L128.71,104.76 L131.59,103.51 L134.55,102.45 L137.57,101.57 L140.63,100.89 L143.73,100.39 L146.86,100.10 L150.00,100.00 L153.14,100.10 L156.27,100.39 L159.37,100.89 L162.43,101.57 L165.45,102.45 L168.41,103.51 L171.29,104.76 L174.09,106.18 L176.79,107.78 L179.39,109.55 L181.87,111.47 L184.23,113.55 L186.45,115.77 L188.53,118.13 L190.45,120.61 L192.22,123.21 L193.82,125.91 L195.24,128.71 L196.49,131.59 L197.55,134.55 L198.43,137.57 L199.11,140.63 L199.61,143.73 L199.90,146.86 Z"]
+        [masker="mask2"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
+    RenderSVGText {text} at (94,236) size 312x43 contains 2 chunk(s)
+      RenderSVGInlineText {#text} at (0,0) size 312x18
+        chunk 1 (middle anchor) text run 1 at (94.00,250.00) startOffset 0 endOffset 52 width 312.00: "The left shape should still be visible after panning"
+      RenderSVGTSpan {tspan} at (0,0) size 276x18
+        RenderSVGInlineText {#text} at (18,25) size 276x18
+          chunk 2 (middle anchor) text run 1 at (112.50,275.00) startOffset 0 endOffset 44 width 275.00: "And the right shape shouldn't look distorted"
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.checksum
new file mode 100644
index 0000000..33068d5
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.checksum
@@ -0,0 +1 @@
+5d7c3dc8fa03aac52cece76b059e9eb2
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.png b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.png
new file mode 100644
index 0000000..677448b
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.txt b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.txt
new file mode 100644
index 0000000..7646d49
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-image-based-clipping-expected.txt
@@ -0,0 +1,27 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 200x200
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip1"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,0.00 L0.50,0.03 L0.50,0.06 L0.49,0.09 L0.48,0.12 L0.48,0.15 L0.46,0.18 L0.45,0.21 L0.44,0.24 L0.42,0.27 L0.40,0.29 L0.39,0.32 L0.36,0.34 L0.34,0.36 L0.32,0.39 L0.29,0.40 L0.27,0.42 L0.24,0.44 L0.21,0.45 L0.18,0.46 L0.15,0.48 L0.12,0.48 L0.09,0.49 L0.06,0.50 L0.03,0.50 L-0.00,0.50 L-0.03,0.50 L-0.06,0.50 L-0.09,0.49 L-0.12,0.48 L-0.15,0.48 L-0.18,0.46 L-0.21,0.45 L-0.24,0.44 L-0.27,0.42 L-0.29,0.40 L-0.32,0.39 L-0.34,0.36 L-0.36,0.34 L-0.39,0.32 L-0.40,0.29 L-0.42,0.27 L-0.44,0.24 L-0.45,0.21 L-0.46,0.18 L-0.48,0.15 L-0.48,0.12 L-0.49,0.09 L-0.50,0.06 L-0.50,0.03 L-0.50,-0.00 L-0.50,-0.03 L-0.50,-0.06 L-0.49,-0.09 L-0.48,-0.12 L-0.48,-0.15 L-0.46,-0.18 L-0.45,-0.21 L-0.44,-0.24 L-0.42,-0.27 L-0.40,-0.29 L-0.39,-0.32 L-0.36,-0.34 L-0.34,-0.36 L-0.32,-0.39 L-0.29,-0.40 L-0.27,-0.42 L-0.24,-0.44 L-0.21,-0.45 L-0.18,-0.46 L-0.15,-0.48 L-0.12,-0.48 L-0.09,-0.49 L-0.06,-0.50 L-0.03,-0.50 L0.00,-0.50 L0.03,-0.50 L0.06,-0.50 L0.09,-0.49 L0.12,-0.48 L0.15,-0.48 L0.18,-0.46 L0.21,-0.45 L0.24,-0.44 L0.27,-0.42 L0.29,-0.40 L0.32,-0.39 L0.34,-0.36 L0.36,-0.34 L0.39,-0.32 L0.40,-0.29 L0.42,-0.27 L0.44,-0.24 L0.45,-0.21 L0.46,-0.18 L0.48,-0.15 L0.48,-0.12 L0.49,-0.09 L0.50,-0.06 L0.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 1x2 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,1.00 L0.50,1.03 L0.50,1.06 L0.49,1.09 L0.48,1.12 L0.48,1.15 L0.46,1.18 L0.45,1.21 L0.44,1.24 L0.42,1.27 L0.40,1.29 L0.39,1.32 L0.36,1.34 L0.34,1.36 L0.32,1.39 L0.29,1.40 L0.27,1.42 L0.24,1.44 L0.21,1.45 L0.18,1.46 L0.15,1.48 L0.12,1.48 L0.09,1.49 L0.06,1.50 L0.03,1.50 L-0.00,1.50 L-0.03,1.50 L-0.06,1.50 L-0.09,1.49 L-0.12,1.48 L-0.15,1.48 L-0.18,1.46 L-0.21,1.45 L-0.24,1.44 L-0.27,1.42 L-0.29,1.40 L-0.32,1.39 L-0.34,1.36 L-0.36,1.34 L-0.39,1.32 L-0.40,1.29 L-0.42,1.27 L-0.44,1.24 L-0.45,1.21 L-0.46,1.18 L-0.48,1.15 L-0.48,1.12 L-0.49,1.09 L-0.50,1.06 L-0.50,1.03 L-0.50,1.00 L-0.50,0.97 L-0.50,0.94 L-0.49,0.91 L-0.48,0.88 L-0.48,0.85 L-0.46,0.82 L-0.45,0.79 L-0.44,0.76 L-0.42,0.73 L-0.40,0.71 L-0.39,0.68 L-0.36,0.66 L-0.34,0.64 L-0.32,0.61 L-0.29,0.60 L-0.27,0.58 L-0.24,0.56 L-0.21,0.55 L-0.18,0.54 L-0.15,0.52 L-0.12,0.52 L-0.09,0.51 L-0.06,0.50 L-0.03,0.50 L0.00,0.50 L0.03,0.50 L0.06,0.50 L0.09,0.51 L0.12,0.52 L0.15,0.52 L0.18,0.54 L0.21,0.55 L0.24,0.56 L0.27,0.58 L0.29,0.60 L0.32,0.61 L0.34,0.64 L0.36,0.66 L0.39,0.68 L0.40,0.71 L0.42,0.73 L0.44,0.76 L0.45,0.79 L0.46,0.82 L0.48,0.85 L0.48,0.88 L0.49,0.91 L0.50,0.94 L0.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip2"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 2x1 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,0.00 L1.50,0.03 L1.50,0.06 L1.49,0.09 L1.48,0.12 L1.48,0.15 L1.46,0.18 L1.45,0.21 L1.44,0.24 L1.42,0.27 L1.40,0.29 L1.39,0.32 L1.36,0.34 L1.34,0.36 L1.32,0.39 L1.29,0.40 L1.27,0.42 L1.24,0.44 L1.21,0.45 L1.18,0.46 L1.15,0.48 L1.12,0.48 L1.09,0.49 L1.06,0.50 L1.03,0.50 L1.00,0.50 L0.97,0.50 L0.94,0.50 L0.91,0.49 L0.88,0.48 L0.85,0.48 L0.82,0.46 L0.79,0.45 L0.76,0.44 L0.73,0.42 L0.71,0.40 L0.68,0.39 L0.66,0.36 L0.64,0.34 L0.61,0.32 L0.60,0.29 L0.58,0.27 L0.56,0.24 L0.55,0.21 L0.54,0.18 L0.52,0.15 L0.52,0.12 L0.51,0.09 L0.50,0.06 L0.50,0.03 L0.50,-0.00 L0.50,-0.03 L0.50,-0.06 L0.51,-0.09 L0.52,-0.12 L0.52,-0.15 L0.54,-0.18 L0.55,-0.21 L0.56,-0.24 L0.58,-0.27 L0.60,-0.29 L0.61,-0.32 L0.64,-0.34 L0.66,-0.36 L0.68,-0.39 L0.71,-0.40 L0.73,-0.42 L0.76,-0.44 L0.79,-0.45 L0.82,-0.46 L0.85,-0.48 L0.88,-0.48 L0.91,-0.49 L0.94,-0.50 L0.97,-0.50 L1.00,-0.50 L1.03,-0.50 L1.06,-0.50 L1.09,-0.49 L1.12,-0.48 L1.15,-0.48 L1.18,-0.46 L1.21,-0.45 L1.24,-0.44 L1.27,-0.42 L1.29,-0.40 L1.32,-0.39 L1.34,-0.36 L1.36,-0.34 L1.39,-0.32 L1.40,-0.29 L1.42,-0.27 L1.44,-0.24 L1.45,-0.21 L1.46,-0.18 L1.48,-0.15 L1.48,-0.12 L1.49,-0.09 L1.50,-0.06 L1.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 2x2 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,1.00 L1.50,1.03 L1.50,1.06 L1.49,1.09 L1.48,1.12 L1.48,1.15 L1.46,1.18 L1.45,1.21 L1.44,1.24 L1.42,1.27 L1.40,1.29 L1.39,1.32 L1.36,1.34 L1.34,1.36 L1.32,1.39 L1.29,1.40 L1.27,1.42 L1.24,1.44 L1.21,1.45 L1.18,1.46 L1.15,1.48 L1.12,1.48 L1.09,1.49 L1.06,1.50 L1.03,1.50 L1.00,1.50 L0.97,1.50 L0.94,1.50 L0.91,1.49 L0.88,1.48 L0.85,1.48 L0.82,1.46 L0.79,1.45 L0.76,1.44 L0.73,1.42 L0.71,1.40 L0.68,1.39 L0.66,1.36 L0.64,1.34 L0.61,1.32 L0.60,1.29 L0.58,1.27 L0.56,1.24 L0.55,1.21 L0.54,1.18 L0.52,1.15 L0.52,1.12 L0.51,1.09 L0.50,1.06 L0.50,1.03 L0.50,1.00 L0.50,0.97 L0.50,0.94 L0.51,0.91 L0.52,0.88 L0.52,0.85 L0.54,0.82 L0.55,0.79 L0.56,0.76 L0.58,0.73 L0.60,0.71 L0.61,0.68 L0.64,0.66 L0.66,0.64 L0.68,0.61 L0.71,0.60 L0.73,0.58 L0.76,0.56 L0.79,0.55 L0.82,0.54 L0.85,0.52 L0.88,0.52 L0.91,0.51 L0.94,0.50 L0.97,0.50 L1.00,0.50 L1.03,0.50 L1.06,0.50 L1.09,0.51 L1.12,0.52 L1.15,0.52 L1.18,0.54 L1.21,0.55 L1.24,0.56 L1.27,0.58 L1.29,0.60 L1.32,0.61 L1.34,0.64 L1.36,0.66 L1.39,0.68 L1.40,0.71 L1.42,0.73 L1.44,0.76 L1.45,0.79 L1.46,0.82 L1.48,0.85 L1.48,0.88 L1.49,0.91 L1.50,0.94 L1.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip1"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 1x2
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip2"] RenderSVGResourceClipper {clipPath} at (0.50,-0.50) size 1x2
+      RenderSVGResourceMasker {mask} [id="mask1"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0,0) size 1x1
+      RenderSVGResourceMasker {mask} [id="mask2"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0,0) size 1x1
+    RenderPath {circle} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M100.00,50.00 L99.90,53.14 L99.61,56.27 L99.11,59.37 L98.43,62.43 L97.55,65.45 L96.49,68.41 L95.24,71.29 L93.82,74.09 L92.22,76.79 L90.45,79.39 L88.53,81.87 L86.45,84.23 L84.23,86.45 L81.87,88.53 L79.39,90.45 L76.79,92.22 L74.09,93.82 L71.29,95.24 L68.41,96.49 L65.45,97.55 L62.43,98.43 L59.37,99.11 L56.27,99.61 L53.14,99.90 L50.00,100.00 L46.86,99.90 L43.73,99.61 L40.63,99.11 L37.57,98.43 L34.55,97.55 L31.59,96.49 L28.71,95.24 L25.91,93.82 L23.21,92.22 L20.61,90.45 L18.13,88.53 L15.77,86.45 L13.55,84.23 L11.47,81.87 L9.55,79.39 L7.78,76.79 L6.18,74.09 L4.76,71.29 L3.51,68.41 L2.45,65.45 L1.57,62.43 L0.89,59.37 L0.39,56.27 L0.10,53.14 L0.00,50.00 L0.10,46.86 L0.39,43.73 L0.89,40.63 L1.57,37.57 L2.45,34.55 L3.51,31.59 L4.76,28.71 L6.18,25.91 L7.78,23.21 L9.55,20.61 L11.47,18.13 L13.55,15.77 L15.77,13.55 L18.13,11.47 L20.61,9.55 L23.21,7.78 L25.91,6.18 L28.71,4.76 L31.59,3.51 L34.55,2.45 L37.57,1.57 L40.63,0.89 L43.73,0.39 L46.86,0.10 L50.00,0.00 L53.14,0.10 L56.27,0.39 L59.37,0.89 L62.43,1.57 L65.45,2.45 L68.41,3.51 L71.29,4.76 L74.09,6.18 L76.79,7.78 L79.39,9.55 L81.87,11.47 L84.23,13.55 L86.45,15.77 L88.53,18.13 L90.45,20.61 L92.22,23.21 L93.82,25.91 L95.24,28.71 L96.49,31.59 L97.55,34.55 L98.43,37.57 L99.11,40.63 L99.61,43.73 L99.90,46.86 Z"]
+      [masker="mask1"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+    RenderPath {circle} at (100,100) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M200.00,150.00 L199.90,153.14 L199.61,156.27 L199.11,159.37 L198.43,162.43 L197.55,165.45 L196.49,168.41 L195.24,171.29 L193.82,174.09 L192.22,176.79 L190.45,179.39 L188.53,181.87 L186.45,184.23 L184.23,186.45 L181.87,188.53 L179.39,190.45 L176.79,192.22 L174.09,193.82 L171.29,195.24 L168.41,196.49 L165.45,197.55 L162.43,198.43 L159.37,199.11 L156.27,199.61 L153.14,199.90 L150.00,200.00 L146.86,199.90 L143.73,199.61 L140.63,199.11 L137.57,198.43 L134.55,197.55 L131.59,196.49 L128.71,195.24 L125.91,193.82 L123.21,192.22 L120.61,190.45 L118.13,188.53 L115.77,186.45 L113.55,184.23 L111.47,181.87 L109.55,179.39 L107.78,176.79 L106.18,174.09 L104.76,171.29 L103.51,168.41 L102.45,165.45 L101.57,162.43 L100.89,159.37 L100.39,156.27 L100.10,153.14 L100.00,150.00 L100.10,146.86 L100.39,143.73 L100.89,140.63 L101.57,137.57 L102.45,134.55 L103.51,131.59 L104.76,128.71 L106.18,125.91 L107.78,123.21 L109.55,120.61 L111.47,118.13 L113.55,115.77 L115.77,113.55 L118.13,111.47 L120.61,109.55 L123.21,107.78 L125.91,106.18 L128.71,104.76 L131.59,103.51 L134.55,102.45 L137.57,101.57 L140.63,100.89 L143.73,100.39 L146.86,100.10 L150.00,100.00 L153.14,100.10 L156.27,100.39 L159.37,100.89 L162.43,101.57 L165.45,102.45 L168.41,103.51 L171.29,104.76 L174.09,106.18 L176.79,107.78 L179.39,109.55 L181.87,111.47 L184.23,113.55 L186.45,115.77 L188.53,118.13 L190.45,120.61 L192.22,123.21 L193.82,125.91 L195.24,128.71 L196.49,131.59 L197.55,134.55 L198.43,137.57 L199.11,140.63 L199.61,143.73 L199.90,146.86 Z"]
+      [masker="mask2"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.checksum
new file mode 100644
index 0000000..33068d5
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.checksum
@@ -0,0 +1 @@
+5d7c3dc8fa03aac52cece76b059e9eb2
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.png b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.png
new file mode 100644
index 0000000..677448b
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.txt b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.txt
new file mode 100644
index 0000000..b2b5547
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping-expected.txt
@@ -0,0 +1,27 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 200x200
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip1"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,0.00 L0.50,0.03 L0.50,0.06 L0.49,0.09 L0.48,0.12 L0.48,0.15 L0.46,0.18 L0.45,0.21 L0.44,0.24 L0.42,0.27 L0.40,0.29 L0.39,0.32 L0.36,0.34 L0.34,0.36 L0.32,0.39 L0.29,0.40 L0.27,0.42 L0.24,0.44 L0.21,0.45 L0.18,0.46 L0.15,0.48 L0.12,0.48 L0.09,0.49 L0.06,0.50 L0.03,0.50 L-0.00,0.50 L-0.03,0.50 L-0.06,0.50 L-0.09,0.49 L-0.12,0.48 L-0.15,0.48 L-0.18,0.46 L-0.21,0.45 L-0.24,0.44 L-0.27,0.42 L-0.29,0.40 L-0.32,0.39 L-0.34,0.36 L-0.36,0.34 L-0.39,0.32 L-0.40,0.29 L-0.42,0.27 L-0.44,0.24 L-0.45,0.21 L-0.46,0.18 L-0.48,0.15 L-0.48,0.12 L-0.49,0.09 L-0.50,0.06 L-0.50,0.03 L-0.50,-0.00 L-0.50,-0.03 L-0.50,-0.06 L-0.49,-0.09 L-0.48,-0.12 L-0.48,-0.15 L-0.46,-0.18 L-0.45,-0.21 L-0.44,-0.24 L-0.42,-0.27 L-0.40,-0.29 L-0.39,-0.32 L-0.36,-0.34 L-0.34,-0.36 L-0.32,-0.39 L-0.29,-0.40 L-0.27,-0.42 L-0.24,-0.44 L-0.21,-0.45 L-0.18,-0.46 L-0.15,-0.48 L-0.12,-0.48 L-0.09,-0.49 L-0.06,-0.50 L-0.03,-0.50 L0.00,-0.50 L0.03,-0.50 L0.06,-0.50 L0.09,-0.49 L0.12,-0.48 L0.15,-0.48 L0.18,-0.46 L0.21,-0.45 L0.24,-0.44 L0.27,-0.42 L0.29,-0.40 L0.32,-0.39 L0.34,-0.36 L0.36,-0.34 L0.39,-0.32 L0.40,-0.29 L0.42,-0.27 L0.44,-0.24 L0.45,-0.21 L0.46,-0.18 L0.48,-0.15 L0.48,-0.12 L0.49,-0.09 L0.50,-0.06 L0.50,-0.03 Z"]
+        RenderPath {circle} at (0,0) size 1x2 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,1.00 L0.50,1.03 L0.50,1.06 L0.49,1.09 L0.48,1.12 L0.48,1.15 L0.46,1.18 L0.45,1.21 L0.44,1.24 L0.42,1.27 L0.40,1.29 L0.39,1.32 L0.36,1.34 L0.34,1.36 L0.32,1.39 L0.29,1.40 L0.27,1.42 L0.24,1.44 L0.21,1.45 L0.18,1.46 L0.15,1.48 L0.12,1.48 L0.09,1.49 L0.06,1.50 L0.03,1.50 L-0.00,1.50 L-0.03,1.50 L-0.06,1.50 L-0.09,1.49 L-0.12,1.48 L-0.15,1.48 L-0.18,1.46 L-0.21,1.45 L-0.24,1.44 L-0.27,1.42 L-0.29,1.40 L-0.32,1.39 L-0.34,1.36 L-0.36,1.34 L-0.39,1.32 L-0.40,1.29 L-0.42,1.27 L-0.44,1.24 L-0.45,1.21 L-0.46,1.18 L-0.48,1.15 L-0.48,1.12 L-0.49,1.09 L-0.50,1.06 L-0.50,1.03 L-0.50,1.00 L-0.50,0.97 L-0.50,0.94 L-0.49,0.91 L-0.48,0.88 L-0.48,0.85 L-0.46,0.82 L-0.45,0.79 L-0.44,0.76 L-0.42,0.73 L-0.40,0.71 L-0.39,0.68 L-0.36,0.66 L-0.34,0.64 L-0.32,0.61 L-0.29,0.60 L-0.27,0.58 L-0.24,0.56 L-0.21,0.55 L-0.18,0.54 L-0.15,0.52 L-0.12,0.52 L-0.09,0.51 L-0.06,0.50 L-0.03,0.50 L0.00,0.50 L0.03,0.50 L0.06,0.50 L0.09,0.51 L0.12,0.52 L0.15,0.52 L0.18,0.54 L0.21,0.55 L0.24,0.56 L0.27,0.58 L0.29,0.60 L0.32,0.61 L0.34,0.64 L0.36,0.66 L0.39,0.68 L0.40,0.71 L0.42,0.73 L0.44,0.76 L0.45,0.79 L0.46,0.82 L0.48,0.85 L0.48,0.88 L0.49,0.91 L0.50,0.94 L0.50,0.97 Z"]
+        RenderPath {circle} at (0,0) size 2x1 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,0.00 L1.50,0.03 L1.50,0.06 L1.49,0.09 L1.48,0.12 L1.48,0.15 L1.46,0.18 L1.45,0.21 L1.44,0.24 L1.42,0.27 L1.40,0.29 L1.39,0.32 L1.36,0.34 L1.34,0.36 L1.32,0.39 L1.29,0.40 L1.27,0.42 L1.24,0.44 L1.21,0.45 L1.18,0.46 L1.15,0.48 L1.12,0.48 L1.09,0.49 L1.06,0.50 L1.03,0.50 L1.00,0.50 L0.97,0.50 L0.94,0.50 L0.91,0.49 L0.88,0.48 L0.85,0.48 L0.82,0.46 L0.79,0.45 L0.76,0.44 L0.73,0.42 L0.71,0.40 L0.68,0.39 L0.66,0.36 L0.64,0.34 L0.61,0.32 L0.60,0.29 L0.58,0.27 L0.56,0.24 L0.55,0.21 L0.54,0.18 L0.52,0.15 L0.52,0.12 L0.51,0.09 L0.50,0.06 L0.50,0.03 L0.50,-0.00 L0.50,-0.03 L0.50,-0.06 L0.51,-0.09 L0.52,-0.12 L0.52,-0.15 L0.54,-0.18 L0.55,-0.21 L0.56,-0.24 L0.58,-0.27 L0.60,-0.29 L0.61,-0.32 L0.64,-0.34 L0.66,-0.36 L0.68,-0.39 L0.71,-0.40 L0.73,-0.42 L0.76,-0.44 L0.79,-0.45 L0.82,-0.46 L0.85,-0.48 L0.88,-0.48 L0.91,-0.49 L0.94,-0.50 L0.97,-0.50 L1.00,-0.50 L1.03,-0.50 L1.06,-0.50 L1.09,-0.49 L1.12,-0.48 L1.15,-0.48 L1.18,-0.46 L1.21,-0.45 L1.24,-0.44 L1.27,-0.42 L1.29,-0.40 L1.32,-0.39 L1.34,-0.36 L1.36,-0.34 L1.39,-0.32 L1.40,-0.29 L1.42,-0.27 L1.44,-0.24 L1.45,-0.21 L1.46,-0.18 L1.48,-0.15 L1.48,-0.12 L1.49,-0.09 L1.50,-0.06 L1.50,-0.03 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip2"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 2x2 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,1.00 L1.50,1.03 L1.50,1.06 L1.49,1.09 L1.48,1.12 L1.48,1.15 L1.46,1.18 L1.45,1.21 L1.44,1.24 L1.42,1.27 L1.40,1.29 L1.39,1.32 L1.36,1.34 L1.34,1.36 L1.32,1.39 L1.29,1.40 L1.27,1.42 L1.24,1.44 L1.21,1.45 L1.18,1.46 L1.15,1.48 L1.12,1.48 L1.09,1.49 L1.06,1.50 L1.03,1.50 L1.00,1.50 L0.97,1.50 L0.94,1.50 L0.91,1.49 L0.88,1.48 L0.85,1.48 L0.82,1.46 L0.79,1.45 L0.76,1.44 L0.73,1.42 L0.71,1.40 L0.68,1.39 L0.66,1.36 L0.64,1.34 L0.61,1.32 L0.60,1.29 L0.58,1.27 L0.56,1.24 L0.55,1.21 L0.54,1.18 L0.52,1.15 L0.52,1.12 L0.51,1.09 L0.50,1.06 L0.50,1.03 L0.50,1.00 L0.50,0.97 L0.50,0.94 L0.51,0.91 L0.52,0.88 L0.52,0.85 L0.54,0.82 L0.55,0.79 L0.56,0.76 L0.58,0.73 L0.60,0.71 L0.61,0.68 L0.64,0.66 L0.66,0.64 L0.68,0.61 L0.71,0.60 L0.73,0.58 L0.76,0.56 L0.79,0.55 L0.82,0.54 L0.85,0.52 L0.88,0.52 L0.91,0.51 L0.94,0.50 L0.97,0.50 L1.00,0.50 L1.03,0.50 L1.06,0.50 L1.09,0.51 L1.12,0.52 L1.15,0.52 L1.18,0.54 L1.21,0.55 L1.24,0.56 L1.27,0.58 L1.29,0.60 L1.32,0.61 L1.34,0.64 L1.36,0.66 L1.39,0.68 L1.40,0.71 L1.42,0.73 L1.44,0.76 L1.45,0.79 L1.46,0.82 L1.48,0.85 L1.48,0.88 L1.49,0.91 L1.50,0.94 L1.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip1"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 2x2
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip2"] RenderSVGResourceClipper {clipPath} at (0.50,0.50) size 1x1
+      RenderSVGResourceMasker {mask} [id="mask1"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0,0) size 1x1
+      RenderSVGResourceMasker {mask} [id="mask2"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0,0) size 1x1
+    RenderPath {circle} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M100.00,50.00 L99.90,53.14 L99.61,56.27 L99.11,59.37 L98.43,62.43 L97.55,65.45 L96.49,68.41 L95.24,71.29 L93.82,74.09 L92.22,76.79 L90.45,79.39 L88.53,81.87 L86.45,84.23 L84.23,86.45 L81.87,88.53 L79.39,90.45 L76.79,92.22 L74.09,93.82 L71.29,95.24 L68.41,96.49 L65.45,97.55 L62.43,98.43 L59.37,99.11 L56.27,99.61 L53.14,99.90 L50.00,100.00 L46.86,99.90 L43.73,99.61 L40.63,99.11 L37.57,98.43 L34.55,97.55 L31.59,96.49 L28.71,95.24 L25.91,93.82 L23.21,92.22 L20.61,90.45 L18.13,88.53 L15.77,86.45 L13.55,84.23 L11.47,81.87 L9.55,79.39 L7.78,76.79 L6.18,74.09 L4.76,71.29 L3.51,68.41 L2.45,65.45 L1.57,62.43 L0.89,59.37 L0.39,56.27 L0.10,53.14 L0.00,50.00 L0.10,46.86 L0.39,43.73 L0.89,40.63 L1.57,37.57 L2.45,34.55 L3.51,31.59 L4.76,28.71 L6.18,25.91 L7.78,23.21 L9.55,20.61 L11.47,18.13 L13.55,15.77 L15.77,13.55 L18.13,11.47 L20.61,9.55 L23.21,7.78 L25.91,6.18 L28.71,4.76 L31.59,3.51 L34.55,2.45 L37.57,1.57 L40.63,0.89 L43.73,0.39 L46.86,0.10 L50.00,0.00 L53.14,0.10 L56.27,0.39 L59.37,0.89 L62.43,1.57 L65.45,2.45 L68.41,3.51 L71.29,4.76 L74.09,6.18 L76.79,7.78 L79.39,9.55 L81.87,11.47 L84.23,13.55 L86.45,15.77 L88.53,18.13 L90.45,20.61 L92.22,23.21 L93.82,25.91 L95.24,28.71 L96.49,31.59 L97.55,34.55 L98.43,37.57 L99.11,40.63 L99.61,43.73 L99.90,46.86 Z"]
+      [masker="mask1"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+    RenderPath {circle} at (100,100) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M200.00,150.00 L199.90,153.14 L199.61,156.27 L199.11,159.37 L198.43,162.43 L197.55,165.45 L196.49,168.41 L195.24,171.29 L193.82,174.09 L192.22,176.79 L190.45,179.39 L188.53,181.87 L186.45,184.23 L184.23,186.45 L181.87,188.53 L179.39,190.45 L176.79,192.22 L174.09,193.82 L171.29,195.24 L168.41,196.49 L165.45,197.55 L162.43,198.43 L159.37,199.11 L156.27,199.61 L153.14,199.90 L150.00,200.00 L146.86,199.90 L143.73,199.61 L140.63,199.11 L137.57,198.43 L134.55,197.55 L131.59,196.49 L128.71,195.24 L125.91,193.82 L123.21,192.22 L120.61,190.45 L118.13,188.53 L115.77,186.45 L113.55,184.23 L111.47,181.87 L109.55,179.39 L107.78,176.79 L106.18,174.09 L104.76,171.29 L103.51,168.41 L102.45,165.45 L101.57,162.43 L100.89,159.37 L100.39,156.27 L100.10,153.14 L100.00,150.00 L100.10,146.86 L100.39,143.73 L100.89,140.63 L101.57,137.57 L102.45,134.55 L103.51,131.59 L104.76,128.71 L106.18,125.91 L107.78,123.21 L109.55,120.61 L111.47,118.13 L113.55,115.77 L115.77,113.55 L118.13,111.47 L120.61,109.55 L123.21,107.78 L125.91,106.18 L128.71,104.76 L131.59,103.51 L134.55,102.45 L137.57,101.57 L140.63,100.89 L143.73,100.39 L146.86,100.10 L150.00,100.00 L153.14,100.10 L156.27,100.39 L159.37,100.89 L162.43,101.57 L165.45,102.45 L168.41,103.51 L171.29,104.76 L174.09,106.18 L176.79,107.78 L179.39,109.55 L181.87,111.47 L184.23,113.55 L186.45,115.77 L188.53,118.13 L190.45,120.61 L192.22,123.21 L193.82,125.91 L195.24,128.71 L196.49,131.59 L197.55,134.55 L198.43,137.57 L199.11,140.63 L199.61,143.73 L199.90,146.86 Z"]
+      [masker="mask2"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.checksum b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.checksum
new file mode 100644
index 0000000..33068d5
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.checksum
@@ -0,0 +1 @@
+5d7c3dc8fa03aac52cece76b059e9eb2
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.png b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.png
new file mode 100644
index 0000000..677448b
Binary files /dev/null and b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.txt b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.txt
new file mode 100644
index 0000000..0181bbe
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/clip-path/nested-clip-in-mask-path-based-clipping-expected.txt
@@ -0,0 +1,33 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 200x200
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceClipper {clipPath} [id="clip1"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,0.00 L0.50,0.03 L0.50,0.06 L0.49,0.09 L0.48,0.12 L0.48,0.15 L0.46,0.18 L0.45,0.21 L0.44,0.24 L0.42,0.27 L0.40,0.29 L0.39,0.32 L0.36,0.34 L0.34,0.36 L0.32,0.39 L0.29,0.40 L0.27,0.42 L0.24,0.44 L0.21,0.45 L0.18,0.46 L0.15,0.48 L0.12,0.48 L0.09,0.49 L0.06,0.50 L0.03,0.50 L-0.00,0.50 L-0.03,0.50 L-0.06,0.50 L-0.09,0.49 L-0.12,0.48 L-0.15,0.48 L-0.18,0.46 L-0.21,0.45 L-0.24,0.44 L-0.27,0.42 L-0.29,0.40 L-0.32,0.39 L-0.34,0.36 L-0.36,0.34 L-0.39,0.32 L-0.40,0.29 L-0.42,0.27 L-0.44,0.24 L-0.45,0.21 L-0.46,0.18 L-0.48,0.15 L-0.48,0.12 L-0.49,0.09 L-0.50,0.06 L-0.50,0.03 L-0.50,-0.00 L-0.50,-0.03 L-0.50,-0.06 L-0.49,-0.09 L-0.48,-0.12 L-0.48,-0.15 L-0.46,-0.18 L-0.45,-0.21 L-0.44,-0.24 L-0.42,-0.27 L-0.40,-0.29 L-0.39,-0.32 L-0.36,-0.34 L-0.34,-0.36 L-0.32,-0.39 L-0.29,-0.40 L-0.27,-0.42 L-0.24,-0.44 L-0.21,-0.45 L-0.18,-0.46 L-0.15,-0.48 L-0.12,-0.48 L-0.09,-0.49 L-0.06,-0.50 L-0.03,-0.50 L0.00,-0.50 L0.03,-0.50 L0.06,-0.50 L0.09,-0.49 L0.12,-0.48 L0.15,-0.48 L0.18,-0.46 L0.21,-0.45 L0.24,-0.44 L0.27,-0.42 L0.29,-0.40 L0.32,-0.39 L0.34,-0.36 L0.36,-0.34 L0.39,-0.32 L0.40,-0.29 L0.42,-0.27 L0.44,-0.24 L0.45,-0.21 L0.46,-0.18 L0.48,-0.15 L0.48,-0.12 L0.49,-0.09 L0.50,-0.06 L0.50,-0.03 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip2"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 1x2 [fill={[type=SOLID] [color=#000000]}] [data="M0.50,1.00 L0.50,1.03 L0.50,1.06 L0.49,1.09 L0.48,1.12 L0.48,1.15 L0.46,1.18 L0.45,1.21 L0.44,1.24 L0.42,1.27 L0.40,1.29 L0.39,1.32 L0.36,1.34 L0.34,1.36 L0.32,1.39 L0.29,1.40 L0.27,1.42 L0.24,1.44 L0.21,1.45 L0.18,1.46 L0.15,1.48 L0.12,1.48 L0.09,1.49 L0.06,1.50 L0.03,1.50 L-0.00,1.50 L-0.03,1.50 L-0.06,1.50 L-0.09,1.49 L-0.12,1.48 L-0.15,1.48 L-0.18,1.46 L-0.21,1.45 L-0.24,1.44 L-0.27,1.42 L-0.29,1.40 L-0.32,1.39 L-0.34,1.36 L-0.36,1.34 L-0.39,1.32 L-0.40,1.29 L-0.42,1.27 L-0.44,1.24 L-0.45,1.21 L-0.46,1.18 L-0.48,1.15 L-0.48,1.12 L-0.49,1.09 L-0.50,1.06 L-0.50,1.03 L-0.50,1.00 L-0.50,0.97 L-0.50,0.94 L-0.49,0.91 L-0.48,0.88 L-0.48,0.85 L-0.46,0.82 L-0.45,0.79 L-0.44,0.76 L-0.42,0.73 L-0.40,0.71 L-0.39,0.68 L-0.36,0.66 L-0.34,0.64 L-0.32,0.61 L-0.29,0.60 L-0.27,0.58 L-0.24,0.56 L-0.21,0.55 L-0.18,0.54 L-0.15,0.52 L-0.12,0.52 L-0.09,0.51 L-0.06,0.50 L-0.03,0.50 L0.00,0.50 L0.03,0.50 L0.06,0.50 L0.09,0.51 L0.12,0.52 L0.15,0.52 L0.18,0.54 L0.21,0.55 L0.24,0.56 L0.27,0.58 L0.29,0.60 L0.32,0.61 L0.34,0.64 L0.36,0.66 L0.39,0.68 L0.40,0.71 L0.42,0.73 L0.44,0.76 L0.45,0.79 L0.46,0.82 L0.48,0.85 L0.48,0.88 L0.49,0.91 L0.50,0.94 L0.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip3"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 2x1 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,0.00 L1.50,0.03 L1.50,0.06 L1.49,0.09 L1.48,0.12 L1.48,0.15 L1.46,0.18 L1.45,0.21 L1.44,0.24 L1.42,0.27 L1.40,0.29 L1.39,0.32 L1.36,0.34 L1.34,0.36 L1.32,0.39 L1.29,0.40 L1.27,0.42 L1.24,0.44 L1.21,0.45 L1.18,0.46 L1.15,0.48 L1.12,0.48 L1.09,0.49 L1.06,0.50 L1.03,0.50 L1.00,0.50 L0.97,0.50 L0.94,0.50 L0.91,0.49 L0.88,0.48 L0.85,0.48 L0.82,0.46 L0.79,0.45 L0.76,0.44 L0.73,0.42 L0.71,0.40 L0.68,0.39 L0.66,0.36 L0.64,0.34 L0.61,0.32 L0.60,0.29 L0.58,0.27 L0.56,0.24 L0.55,0.21 L0.54,0.18 L0.52,0.15 L0.52,0.12 L0.51,0.09 L0.50,0.06 L0.50,0.03 L0.50,-0.00 L0.50,-0.03 L0.50,-0.06 L0.51,-0.09 L0.52,-0.12 L0.52,-0.15 L0.54,-0.18 L0.55,-0.21 L0.56,-0.24 L0.58,-0.27 L0.60,-0.29 L0.61,-0.32 L0.64,-0.34 L0.66,-0.36 L0.68,-0.39 L0.71,-0.40 L0.73,-0.42 L0.76,-0.44 L0.79,-0.45 L0.82,-0.46 L0.85,-0.48 L0.88,-0.48 L0.91,-0.49 L0.94,-0.50 L0.97,-0.50 L1.00,-0.50 L1.03,-0.50 L1.06,-0.50 L1.09,-0.49 L1.12,-0.48 L1.15,-0.48 L1.18,-0.46 L1.21,-0.45 L1.24,-0.44 L1.27,-0.42 L1.29,-0.40 L1.32,-0.39 L1.34,-0.36 L1.36,-0.34 L1.39,-0.32 L1.40,-0.29 L1.42,-0.27 L1.44,-0.24 L1.45,-0.21 L1.46,-0.18 L1.48,-0.15 L1.48,-0.12 L1.49,-0.09 L1.50,-0.06 L1.50,-0.03 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip4"] [clipPathUnits=objectBoundingBox]
+        RenderPath {circle} at (0,0) size 2x2 [fill={[type=SOLID] [color=#000000]}] [data="M1.50,1.00 L1.50,1.03 L1.50,1.06 L1.49,1.09 L1.48,1.12 L1.48,1.15 L1.46,1.18 L1.45,1.21 L1.44,1.24 L1.42,1.27 L1.40,1.29 L1.39,1.32 L1.36,1.34 L1.34,1.36 L1.32,1.39 L1.29,1.40 L1.27,1.42 L1.24,1.44 L1.21,1.45 L1.18,1.46 L1.15,1.48 L1.12,1.48 L1.09,1.49 L1.06,1.50 L1.03,1.50 L1.00,1.50 L0.97,1.50 L0.94,1.50 L0.91,1.49 L0.88,1.48 L0.85,1.48 L0.82,1.46 L0.79,1.45 L0.76,1.44 L0.73,1.42 L0.71,1.40 L0.68,1.39 L0.66,1.36 L0.64,1.34 L0.61,1.32 L0.60,1.29 L0.58,1.27 L0.56,1.24 L0.55,1.21 L0.54,1.18 L0.52,1.15 L0.52,1.12 L0.51,1.09 L0.50,1.06 L0.50,1.03 L0.50,1.00 L0.50,0.97 L0.50,0.94 L0.51,0.91 L0.52,0.88 L0.52,0.85 L0.54,0.82 L0.55,0.79 L0.56,0.76 L0.58,0.73 L0.60,0.71 L0.61,0.68 L0.64,0.66 L0.66,0.64 L0.68,0.61 L0.71,0.60 L0.73,0.58 L0.76,0.56 L0.79,0.55 L0.82,0.54 L0.85,0.52 L0.88,0.52 L0.91,0.51 L0.94,0.50 L0.97,0.50 L1.00,0.50 L1.03,0.50 L1.06,0.50 L1.09,0.51 L1.12,0.52 L1.15,0.52 L1.18,0.54 L1.21,0.55 L1.24,0.56 L1.27,0.58 L1.29,0.60 L1.32,0.61 L1.34,0.64 L1.36,0.66 L1.39,0.68 L1.40,0.71 L1.42,0.73 L1.44,0.76 L1.45,0.79 L1.46,0.82 L1.48,0.85 L1.48,0.88 L1.49,0.91 L1.50,0.94 L1.50,0.97 Z"]
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip1"] RenderSVGResourceClipper {clipPath} at (-0.50,-0.50) size 1x1
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip2"] RenderSVGResourceClipper {clipPath} at (-0.50,0.50) size 1x1
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip3"] RenderSVGResourceClipper {clipPath} at (0.50,-0.50) size 1x1
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip4"] RenderSVGResourceClipper {clipPath} at (0.50,0.50) size 1x1
+      RenderSVGResourceMasker {mask} [id="mask1"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0,0) size 1x1
+      RenderSVGResourceMasker {mask} [id="mask2"] [maskUnits=objectBoundingBox] [maskContentUnits=objectBoundingBox]
+        RenderPath {rect} at (0,0) size 1x1 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L1.00,0.00 L1.00,1.00 L0.00,1.00 Z"]
+          [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (0,0) size 1x1
+    RenderPath {circle} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M100.00,50.00 L99.90,53.14 L99.61,56.27 L99.11,59.37 L98.43,62.43 L97.55,65.45 L96.49,68.41 L95.24,71.29 L93.82,74.09 L92.22,76.79 L90.45,79.39 L88.53,81.87 L86.45,84.23 L84.23,86.45 L81.87,88.53 L79.39,90.45 L76.79,92.22 L74.09,93.82 L71.29,95.24 L68.41,96.49 L65.45,97.55 L62.43,98.43 L59.37,99.11 L56.27,99.61 L53.14,99.90 L50.00,100.00 L46.86,99.90 L43.73,99.61 L40.63,99.11 L37.57,98.43 L34.55,97.55 L31.59,96.49 L28.71,95.24 L25.91,93.82 L23.21,92.22 L20.61,90.45 L18.13,88.53 L15.77,86.45 L13.55,84.23 L11.47,81.87 L9.55,79.39 L7.78,76.79 L6.18,74.09 L4.76,71.29 L3.51,68.41 L2.45,65.45 L1.57,62.43 L0.89,59.37 L0.39,56.27 L0.10,53.14 L0.00,50.00 L0.10,46.86 L0.39,43.73 L0.89,40.63 L1.57,37.57 L2.45,34.55 L3.51,31.59 L4.76,28.71 L6.18,25.91 L7.78,23.21 L9.55,20.61 L11.47,18.13 L13.55,15.77 L15.77,13.55 L18.13,11.47 L20.61,9.55 L23.21,7.78 L25.91,6.18 L28.71,4.76 L31.59,3.51 L34.55,2.45 L37.57,1.57 L40.63,0.89 L43.73,0.39 L46.86,0.10 L50.00,0.00 L53.14,0.10 L56.27,0.39 L59.37,0.89 L62.43,1.57 L65.45,2.45 L68.41,3.51 L71.29,4.76 L74.09,6.18 L76.79,7.78 L79.39,9.55 L81.87,11.47 L84.23,13.55 L86.45,15.77 L88.53,18.13 L90.45,20.61 L92.22,23.21 L93.82,25.91 L95.24,28.71 L96.49,31.59 L97.55,34.55 L98.43,37.57 L99.11,40.63 L99.61,43.73 L99.90,46.86 Z"]
+      [masker="mask1"] RenderSVGResourceMasker {mask} at (0,0) size 100x100
+    RenderPath {circle} at (100,100) size 100x100 [fill={[type=SOLID] [color=#000000]}] [data="M200.00,150.00 L199.90,153.14 L199.61,156.27 L199.11,159.37 L198.43,162.43 L197.55,165.45 L196.49,168.41 L195.24,171.29 L193.82,174.09 L192.22,176.79 L190.45,179.39 L188.53,181.87 L186.45,184.23 L184.23,186.45 L181.87,188.53 L179.39,190.45 L176.79,192.22 L174.09,193.82 L171.29,195.24 L168.41,196.49 L165.45,197.55 L162.43,198.43 L159.37,199.11 L156.27,199.61 L153.14,199.90 L150.00,200.00 L146.86,199.90 L143.73,199.61 L140.63,199.11 L137.57,198.43 L134.55,197.55 L131.59,196.49 L128.71,195.24 L125.91,193.82 L123.21,192.22 L120.61,190.45 L118.13,188.53 L115.77,186.45 L113.55,184.23 L111.47,181.87 L109.55,179.39 L107.78,176.79 L106.18,174.09 L104.76,171.29 L103.51,168.41 L102.45,165.45 L101.57,162.43 L100.89,159.37 L100.39,156.27 L100.10,153.14 L100.00,150.00 L100.10,146.86 L100.39,143.73 L100.89,140.63 L101.57,137.57 L102.45,134.55 L103.51,131.59 L104.76,128.71 L106.18,125.91 L107.78,123.21 L109.55,120.61 L111.47,118.13 L113.55,115.77 L115.77,113.55 L118.13,111.47 L120.61,109.55 L123.21,107.78 L125.91,106.18 L128.71,104.76 L131.59,103.51 L134.55,102.45 L137.57,101.57 L140.63,100.89 L143.73,100.39 L146.86,100.10 L150.00,100.00 L153.14,100.10 L156.27,100.39 L159.37,100.89 L162.43,101.57 L165.45,102.45 L168.41,103.51 L171.29,104.76 L174.09,106.18 L176.79,107.78 L179.39,109.55 L181.87,111.47 L184.23,113.55 L186.45,115.77 L188.53,118.13 L190.45,120.61 L192.22,123.21 L193.82,125.91 L195.24,128.71 L196.49,131.59 L197.55,134.55 L198.43,137.57 L199.11,140.63 L199.61,143.73 L199.90,146.86 Z"]
+      [masker="mask2"] RenderSVGResourceMasker {mask} at (100,100) size 100x100
diff --git a/LayoutTests/platform/mac/svg/custom/absolute-sized-content-with-resources-expected.checksum b/LayoutTests/platform/mac/svg/custom/absolute-sized-content-with-resources-expected.checksum
index b5c5faf..331da4d 100644
--- a/LayoutTests/platform/mac/svg/custom/absolute-sized-content-with-resources-expected.checksum
+++ b/LayoutTests/platform/mac/svg/custom/absolute-sized-content-with-resources-expected.checksum
@@ -1 +1 @@
-f482ede9c5fc18f3f09a70545af6ba67
\ No newline at end of file
+70e709058a071d7207192c403ee1deb2
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/absolute-sized-content-with-resources-expected.png b/LayoutTests/platform/mac/svg/custom/absolute-sized-content-with-resources-expected.png
index 13f6fe3..df6b166 100644
Binary files a/LayoutTests/platform/mac/svg/custom/absolute-sized-content-with-resources-expected.png and b/LayoutTests/platform/mac/svg/custom/absolute-sized-content-with-resources-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.checksum b/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.checksum
index 7d9698c..9b53595 100644
--- a/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.checksum
+++ b/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.checksum
@@ -1 +1 @@
-c9fa987aacc7c5064491999daceb0d4f
\ No newline at end of file
+791d8651a70b39d17fac23e5ccafca53
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.png b/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.png
index f234cad..d537121 100644
Binary files a/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.png and b/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.checksum b/LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.checksum
index 3497fbe..0830b5e 100644
--- a/LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.checksum
+++ b/LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.checksum
@@ -1 +1 @@
-79c35c1f034795088b8a008729997baa
\ No newline at end of file
+3cdac160082fd7d24f5e65d83ddf7958
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png b/LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png
index 4ca098e..c8264c3 100644
Binary files a/LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png and b/LayoutTests/platform/mac/svg/custom/js-late-gradient-and-object-creation-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/text-rotated-gradient-expected.checksum b/LayoutTests/platform/mac/svg/custom/text-rotated-gradient-expected.checksum
index 6cf5c52..c2b7fa3 100644
--- a/LayoutTests/platform/mac/svg/custom/text-rotated-gradient-expected.checksum
+++ b/LayoutTests/platform/mac/svg/custom/text-rotated-gradient-expected.checksum
@@ -1 +1 @@
-7c0fe736cb4ed2a2a51eb2458251e610
\ No newline at end of file
+ce7c2f3d28648885b0045fc74eaaf8f4
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/text-rotated-gradient-expected.png b/LayoutTests/platform/mac/svg/custom/text-rotated-gradient-expected.png
index 227be6c..8982d4e 100644
Binary files a/LayoutTests/platform/mac/svg/custom/text-rotated-gradient-expected.png and b/LayoutTests/platform/mac/svg/custom/text-rotated-gradient-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/text/selection-background-color-expected.checksum b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.checksum
index 404cfa6..9b19cbd 100644
--- a/LayoutTests/platform/mac/svg/text/selection-background-color-expected.checksum
+++ b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.checksum
@@ -1 +1 @@
-1ad4cec1470600775011aa727d7a5c94
\ No newline at end of file
+3165f6d9b00829dfa0119222f11e2585
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/selection-background-color-expected.png b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.png
index 3bf04ec..a76ec61 100644
Binary files a/LayoutTests/platform/mac/svg/text/selection-background-color-expected.png and b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.checksum b/LayoutTests/platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.checksum
index b5317b4..a0065d9 100644
--- a/LayoutTests/platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.checksum
+++ b/LayoutTests/platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.checksum
@@ -1 +1 @@
-ab99a5d800d7ea930b1151158e14be69
\ No newline at end of file
+34ebee33d4d97a2e82a75241afcfe9eb
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.png b/LayoutTests/platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.png
index 7d4cff9..2f97683 100644
Binary files a/LayoutTests/platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.png and b/LayoutTests/platform/mac/svg/transforms/text-with-mask-with-svg-transform-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.checksum b/LayoutTests/platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.checksum
index 6695306..f5aaa40 100644
--- a/LayoutTests/platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.checksum
+++ b/LayoutTests/platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.checksum
@@ -1 +1 @@
-28befae5e6709c12c60fd2e448dff271
\ No newline at end of file
+c9f4cbaab8844bc7b6bf998831f89a3e
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.png b/LayoutTests/platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.png
index 90935bd..362b736 100644
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.png differ
diff --git a/LayoutTests/svg/clip-path/clip-in-mask-objectBoundingBox.svg b/LayoutTests/svg/clip-path/clip-in-mask-objectBoundingBox.svg
new file mode 100644
index 0000000..2370ee6
--- /dev/null
+++ b/LayoutTests/svg/clip-path/clip-in-mask-objectBoundingBox.svg
@@ -0,0 +1,13 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+    <clipPath id="clip" clipPathUnits="userSpaceOnUse">
+        <circle cx="50" cy="50" r="40" transform="scale(0.01 0.01)"/>
+    </clipPath>
+
+    <mask id="mask" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" clip-path="url(#clip)"/>
+    </mask>
+</defs>
+
+<rect x="50" y="50" height="100" width="100" style="fill:green;mask:url(#mask);"/>
+</svg>
diff --git a/LayoutTests/svg/clip-path/clip-in-mask-userSpaceOnUse.svg b/LayoutTests/svg/clip-path/clip-in-mask-userSpaceOnUse.svg
new file mode 100644
index 0000000..4e9eaa7
--- /dev/null
+++ b/LayoutTests/svg/clip-path/clip-in-mask-userSpaceOnUse.svg
@@ -0,0 +1,13 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+    <clipPath id="clip" clipPathUnits="userSpaceOnUse">
+        <circle cx="50" cy="50" r="40" transform="scale(0.01 0.01)"/>
+    </clipPath>
+
+    <mask id="mask" x="50" y="50" width="100" height="100" maskUnits="userSpaceOnUse" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" clip-path="url(#clip)"/>
+    </mask>
+</defs>
+
+<rect x="50" y="50" height="100" width="100" style="fill:green;mask:url(#mask);"/>
+</svg>
diff --git a/LayoutTests/svg/clip-path/clip-in-mask.svg b/LayoutTests/svg/clip-path/clip-in-mask.svg
new file mode 100644
index 0000000..6f9a755
--- /dev/null
+++ b/LayoutTests/svg/clip-path/clip-in-mask.svg
@@ -0,0 +1,22 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip" clipPathUnits="objectBoundingBox">
+        <circle cx="0" cy="0" r="0.5" />
+        <circle cx="0" cy="1" r="0.5" />
+        <circle cx="1" cy="0" r="0.5" />
+        <circle cx="1" cy="1" r="0.5" />
+    </clipPath>
+
+    <mask id="mask1" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip)" />
+    </mask>
+
+    <mask id="mask2" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" clip-path="url(#clip)" />
+    </mask>
+</defs>
+
+<circle cx="50" cy="50" r="50" fill="black" mask="url(#mask1)" />
+<circle cx="150" cy="150" r="50" fill="black" mask="url(#mask2)" />
+</svg>
diff --git a/LayoutTests/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg b/LayoutTests/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg
new file mode 100644
index 0000000..46f2fed
--- /dev/null
+++ b/LayoutTests/svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg
@@ -0,0 +1,33 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip0" clipPathUnits="userSpaceOnUse">
+        <circle cx="100" cy="100" r="50"/>
+    </clipPath>
+
+    <clipPath id="clip1" clipPathUnits="objectBoundingBox">
+        <circle cx="0" cy="0" r="0.5" />
+        <circle cx="0" cy="1" r="0.5" />
+    </clipPath>
+
+    <clipPath id="clip2" clipPathUnits="userSpaceOnUse">
+        <circle cx="100" cy="0" r="50" transform="scale(0.01 0.01)"/>
+        <rect x="0" y="0" width="100" height="100" transform="scale(0.01 0.01)" clip-path="url(#clip0)"/>
+    </clipPath>
+
+    <clipPath id="clip" clipPathUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip1)"/>
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip2)"/>
+    </clipPath>
+
+    <mask id="mask1" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip)" />
+    </mask>
+</defs>
+
+<text x="125" y="225" text-anchor="middle">Both shapes should look identical</text>
+
+<circle cx="50" cy="50" r="50" fill="black" mask="url(#mask1)"/>
+<circle cx="150" cy="150" r="50" fill="black" mask="url(#mask1)"/>
+
+</svg>
diff --git a/LayoutTests/svg/clip-path/deep-nested-clip-in-mask-panning.svg b/LayoutTests/svg/clip-path/deep-nested-clip-in-mask-panning.svg
new file mode 100644
index 0000000..fca1ec2
--- /dev/null
+++ b/LayoutTests/svg/clip-path/deep-nested-clip-in-mask-panning.svg
@@ -0,0 +1,52 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip1" clipPathUnits="objectBoundingBox">
+        <circle cx="0" cy="0" r="0.5" />
+        <circle cx="0" cy="1" r="0.5" />
+    </clipPath>
+
+    <clipPath id="clip2" clipPathUnits="objectBoundingBox">
+        <circle cx="1" cy="0" r="0.5" />
+        <circle cx="1" cy="1" r="0.5" />
+    </clipPath>
+
+    <clipPath id="clip" clipPathUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip1)"/>
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip2)"/>
+    </clipPath>
+
+    <mask id="mask1a" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip1)" />
+    </mask>
+
+    <mask id="mask1b" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip2)" />
+    </mask>
+
+    <mask id="mask2" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" mask="url(#mask1a)"/>
+    </mask>
+
+    <mask id="mask3" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" mask="url(#mask1b)"/>
+    </mask>
+</defs>
+
+<!-- The mask on the <g> causes nothing to be renderer with Opera, clearly a bug -->
+<g mask="url(#mask1a)">
+    <circle cx="50" cy="50" r="50" fill="black" mask="url(#mask1b)"/>
+</g>
+
+<!-- The mask on the <g> causes nothing to be renderer with Opera, clearly a bug -->
+<g mask="url(#mask3)">
+    <circle cx="150" cy="150" r="50" fill="black" mask="url(#mask2)"/>
+</g>
+
+<text x="250" y="250" text-anchor="middle">The left shape should still be visible after panning<tspan x="250" dy="25">And the right shape shouldn't look distorted</tspan></text>
+<script>
+var translate = document.getElementsByTagName('svg')[0].currentTranslate;
+translate.x = -75;
+</script>
+</svg>
diff --git a/LayoutTests/svg/clip-path/deep-nested-clip-in-mask.svg b/LayoutTests/svg/clip-path/deep-nested-clip-in-mask.svg
new file mode 100644
index 0000000..cb66ac7
--- /dev/null
+++ b/LayoutTests/svg/clip-path/deep-nested-clip-in-mask.svg
@@ -0,0 +1,49 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip1" clipPathUnits="objectBoundingBox">
+        <circle cx="0" cy="0" r="0.5" />
+        <circle cx="0" cy="1" r="0.5" />
+    </clipPath>
+
+    <clipPath id="clip2" clipPathUnits="objectBoundingBox">
+        <circle cx="1" cy="0" r="0.5" />
+        <circle cx="1" cy="1" r="0.5" />
+    </clipPath>
+
+    <clipPath id="clip" clipPathUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip1)"/>
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip2)"/>
+    </clipPath>
+
+    <mask id="mask1a" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip1)" />
+    </mask>
+
+    <mask id="mask1b" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip2)" />
+    </mask>
+
+    <mask id="mask2" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" mask="url(#mask1a)"/>
+    </mask>
+
+    <mask id="mask3" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" mask="url(#mask1b)"/>
+    </mask>
+</defs>
+
+<text x="125" y="225" text-anchor="middle">Both shapes should look identical</text>
+
+<!-- The mask on the <g> causes nothing to be renderer with Opera, clearly a bug -->
+<g mask="url(#mask1a)">
+    <circle cx="50" cy="50" r="50" fill="black" mask="url(#mask1b)"/>
+</g>
+
+<!-- The mask on the <g> causes nothing to be renderer with Opera, clearly a bug -->
+<g mask="url(#mask3)">
+    <circle cx="150" cy="150" r="50" fill="black" mask="url(#mask2)"/>
+</g>
+
+</svg>
diff --git a/LayoutTests/svg/clip-path/nested-clip-in-mask-image-based-clipping.svg b/LayoutTests/svg/clip-path/nested-clip-in-mask-image-based-clipping.svg
new file mode 100644
index 0000000..548aa58
--- /dev/null
+++ b/LayoutTests/svg/clip-path/nested-clip-in-mask-image-based-clipping.svg
@@ -0,0 +1,30 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip1" clipPathUnits="objectBoundingBox">
+        <circle cx="0" cy="0" r="0.5" />
+        <circle cx="0" cy="1" r="0.5" />
+    </clipPath>
+
+    <clipPath id="clip2" clipPathUnits="objectBoundingBox">
+        <circle cx="1" cy="0" r="0.5" />
+        <circle cx="1" cy="1" r="0.5" />
+    </clipPath>
+
+    <clipPath id="clip" clipPathUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip1)"/>
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip2)"/>
+    </clipPath>
+
+    <mask id="mask1" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip)" />
+    </mask>
+
+    <mask id="mask2" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" clip-path="url(#clip)" />
+    </mask>
+</defs>
+
+<circle cx="50" cy="50" r="50" fill="black" mask="url(#mask1)" />
+<circle cx="150" cy="150" r="50" fill="black" mask="url(#mask2)" />
+</svg>
diff --git a/LayoutTests/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg b/LayoutTests/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg
new file mode 100644
index 0000000..2964e8b
--- /dev/null
+++ b/LayoutTests/svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg
@@ -0,0 +1,30 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip1" clipPathUnits="objectBoundingBox">
+        <circle cx="0" cy="0" r="0.5"/>
+        <circle cx="0" cy="1" r="0.5"/>
+        <circle cx="1" cy="0" r="0.5"/>
+    </clipPath>
+
+    <clipPath id="clip2" clipPathUnits="objectBoundingBox">
+        <circle cx="1" cy="1" r="0.5"/>
+    </clipPath>
+
+    <clipPath id="clip" clipPathUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip1)"/>
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip2)"/>
+    </clipPath>
+
+    <mask id="mask1" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip)" />
+    </mask>
+
+    <mask id="mask2" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" clip-path="url(#clip)" />
+    </mask>
+</defs>
+
+<circle cx="50" cy="50" r="50" fill="black" mask="url(#mask1)" />
+<circle cx="150" cy="150" r="50" fill="black" mask="url(#mask2)" />
+</svg>
diff --git a/LayoutTests/svg/clip-path/nested-clip-in-mask-path-based-clipping.svg b/LayoutTests/svg/clip-path/nested-clip-in-mask-path-based-clipping.svg
new file mode 100644
index 0000000..320a7e8
--- /dev/null
+++ b/LayoutTests/svg/clip-path/nested-clip-in-mask-path-based-clipping.svg
@@ -0,0 +1,38 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip1" clipPathUnits="objectBoundingBox">
+        <circle cx="0" cy="0" r="0.5"/>
+    </clipPath>
+
+    <clipPath id="clip2" clipPathUnits="objectBoundingBox">
+        <circle cx="0" cy="1" r="0.5"/>
+    </clipPath>
+
+    <clipPath id="clip3" clipPathUnits="objectBoundingBox">
+        <circle cx="1" cy="0" r="0.5"/>
+    </clipPath>
+
+    <clipPath id="clip4" clipPathUnits="objectBoundingBox">
+        <circle cx="1" cy="1" r="0.5"/>
+    </clipPath>
+
+    <clipPath id="clip" clipPathUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip1)"/>
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip2)"/>
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip3)"/>
+        <rect x="0" y="0" width="1" height="1" clip-path="url(#clip4)"/>
+    </clipPath>
+
+    <mask id="mask1" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white"/>
+        <rect x="0" y="0" width="1" height="1" fill="black" clip-path="url(#clip)" />
+    </mask>
+
+    <mask id="mask2" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect x="0" y="0" width="1" height="1" fill="white" clip-path="url(#clip)" />
+    </mask>
+</defs>
+
+<circle cx="50" cy="50" r="50" fill="black" mask="url(#mask1)" />
+<circle cx="150" cy="150" r="50" fill="black" mask="url(#mask2)" />
+</svg>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7fe9fcb..9ce8e7c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,52 @@
+2010-08-24  Nikolas Zimmermann  <nzimmermann at rim.com>
+
+        Reviewed by Dirk Schulze
+
+        clip-path does not work inside mask element
+        https://bugs.webkit.org/show_bug.cgi?id=41428
+
+        Add new tests covering nesting of clippers and maskers, with different unitTypes for the content coordinate system.
+        Scale all ImageBuffer content to take into account that ImageBuffers use integer based sizes, where the content
+        is floating-point sized. This compensates rounded errors, when scaling the document.
+
+        Tests: svg/clip-path/clip-in-mask-objectBoundingBox.svg
+               svg/clip-path/clip-in-mask-userSpaceOnUse.svg
+               svg/clip-path/clip-in-mask.svg
+               svg/clip-path/deep-nested-clip-in-mask-different-unitTypes.svg
+               svg/clip-path/deep-nested-clip-in-mask-panning.svg
+               svg/clip-path/deep-nested-clip-in-mask.svg
+               svg/clip-path/nested-clip-in-mask-image-based-clipping.svg
+               svg/clip-path/nested-clip-in-mask-path-and-image-based-clipping.svg
+               svg/clip-path/nested-clip-in-mask-path-based-clipping.svg
+
+        * rendering/RenderSVGResourceClipper.cpp:
+        (WebCore::RenderSVGResourceClipper::applyResource): Return the value of applyClippingToContext, instead of always true.
+        (WebCore::RenderSVGResourceClipper::applyClippingToContext): Moved some code from createClipData, to avoid having to pass 5 arguments to createClipData.
+        (WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage): Renamed from createClipData.
+        * rendering/RenderSVGResourceClipper.h:
+        * rendering/RenderSVGResourceGradient.cpp:
+        (WebCore::createMaskAndSwapContextForTextGradient): Pass absoluteTargetRect to createImageBuffer.
+        (WebCore::clipToTextMask): Ditto.
+        * rendering/RenderSVGResourceMasker.cpp:
+        (WebCore::RenderSVGResourceMasker::applyResource): Ditto.
+        (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage): Pass content transformation to renderSubtreeToImageBuffer, to support nesting objectBoundingBox resources.
+        * rendering/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::applyResource): Adapt to calculateTransformationToOutermostSVGCoordinateSystem changes. AffineTransform is now passed as reference.
+        (WebCore::RenderSVGResourcePattern::createTileImage): ImageBuffer content scaling is now handled by createImageBuffer.
+        * rendering/SVGImageBufferTools.cpp:
+        (WebCore::SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem): Renamed. Don't return an AffineTransform copy, but instead pass it as reference.
+        (WebCore::SVGImageBufferTools::createImageBuffer): Always scale the ImageBuffer content, to compensate rounding effects (code was only present in patterns so far).
+                                                           Now also needs the 'absoluteTargetRect' parameter, not only 'clampedAbsoluteTargetRect'.
+        (WebCore::SVGImageBufferTools::renderSubtreeToImageBuffer): Moved from SVGRenderSupport.
+        (WebCore::SVGImageBufferTools::clipToImageBuffer): Pass ImageBuffer as OwnPtr reference, to allow to clear it under certain circumstances (see comment).
+        (WebCore::SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer): Remove AffineTransform parameter, absoluteTargetRect is calculated before passing into this function.
+        * rendering/SVGImageBufferTools.h:
+        * rendering/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderSupport::prepareToRenderSVGContent): Important change, respect the RenderSVGResourceClipper::applyResource() return value!
+        * rendering/SVGRenderSupport.h:
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::SVGFEImageElement::build): renderSubtreeToImage now lives in SVGImageBufferTools, adapt code.
+
 2010-08-24  Andrei Popescu  <andreip at dhcp-172-16-14-12.lon.corp.google.com>
 
         Reviewed by Jeremy Orlow.
diff --git a/WebCore/rendering/RenderSVGResourceClipper.cpp b/WebCore/rendering/RenderSVGResourceClipper.cpp
index e8aa65e..ef44a79 100644
--- a/WebCore/rendering/RenderSVGResourceClipper.cpp
+++ b/WebCore/rendering/RenderSVGResourceClipper.cpp
@@ -101,8 +101,7 @@ bool RenderSVGResourceClipper::applyResource(RenderObject* object, RenderStyle*,
     UNUSED_PARAM(resourceMode);
 #endif
 
-    applyClippingToContext(object, object->objectBoundingBox(), object->repaintRectInLocalCoordinates(), context);
-    return true;
+    return applyClippingToContext(object, object->objectBoundingBox(), object->repaintRectInLocalCoordinates(), context);
 }
 
 bool RenderSVGResourceClipper::pathOnlyClipping(GraphicsContext* context, const FloatRect& objectBoundingBox)
@@ -172,49 +171,59 @@ bool RenderSVGResourceClipper::applyClippingToContext(RenderObject* object, cons
         shouldCreateClipData = true;
     }
 
-    AffineTransform absoluteTransform = SVGImageBufferTools::transformationToOutermostSVGCoordinateSystem(object);
-    FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(object, absoluteTransform, repaintRect);
+    AffineTransform absoluteTransform;
+    SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(object, absoluteTransform);
+
+    FloatRect absoluteTargetRect = absoluteTransform.mapRect(repaintRect);
+    FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(object, absoluteTargetRect);
+
+    if (shouldCreateClipData && !clampedAbsoluteTargetRect.isEmpty()) {
+        if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, clipperData->clipMaskImage, DeviceRGB))
+            return false;
+
+        GraphicsContext* maskContext = clipperData->clipMaskImage->context();
+        ASSERT(maskContext);
+
+        // The save/restore pair is needed for clipToImageBuffer - it doesn't work without it on non-Cg platforms.
+        maskContext->save();
+        maskContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());
+        maskContext->concatCTM(absoluteTransform);
+
+        // clipPath can also be clipped by another clipPath.
+        if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this)) {
+            if (RenderSVGResourceClipper* clipper = resources->clipper()) {
+                if (!clipper->applyClippingToContext(this, objectBoundingBox, repaintRect, maskContext)) {
+                    maskContext->restore();
+                    return false;
+                }
+            }
+        }
 
-    if (shouldCreateClipData)
-        createClipData(clipperData, objectBoundingBox, repaintRect, clampedAbsoluteTargetRect, absoluteTransform);
+        drawContentIntoMaskImage(clipperData, objectBoundingBox);
+        maskContext->restore();
+    }
 
     if (!clipperData->clipMaskImage)
         return false;
 
-    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, clipperData->clipMaskImage.get());
+    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, clipperData->clipMaskImage);
     return true;
 }
 
-bool RenderSVGResourceClipper::createClipData(ClipperData* clipperData,
-                                              const FloatRect& objectBoundingBox,
-                                              const FloatRect& repaintRect,
-                                              const FloatRect& clampedAbsoluteTargetRect,
-                                              const AffineTransform& absoluteTransform)
+bool RenderSVGResourceClipper::drawContentIntoMaskImage(ClipperData* clipperData, const FloatRect& objectBoundingBox)
 {
-    if (!SVGImageBufferTools::createImageBuffer(clampedAbsoluteTargetRect, clipperData->clipMaskImage, DeviceRGB))
-        return false;
+    ASSERT(clipperData);
+    ASSERT(clipperData->clipMaskImage);
 
     GraphicsContext* maskContext = clipperData->clipMaskImage->context();
     ASSERT(maskContext);
 
-    maskContext->save();
-    maskContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());
-    maskContext->concatCTM(absoluteTransform);
-
-    // clipPath can also be clipped by another clipPath.
-    if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this)) {
-        if (RenderSVGResourceClipper* clipper = resources->clipper()) {
-            if (!clipper->applyClippingToContext(this, objectBoundingBox, repaintRect, maskContext)) {
-                maskContext->restore();
-                return false;
-            }
-        }
-    }
-
+    AffineTransform maskContentTransformation;
     SVGClipPathElement* clipPath = static_cast<SVGClipPathElement*>(node());
     if (clipPath->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
-        maskContext->translate(objectBoundingBox.x(), objectBoundingBox.y());
-        maskContext->scale(objectBoundingBox.size());
+        maskContentTransformation.translate(objectBoundingBox.x(), objectBoundingBox.y());
+        maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
+        maskContext->concatCTM(maskContentTransformation);
     }
 
     // Draw all clipPath children into a global mask.
@@ -262,16 +271,14 @@ bool RenderSVGResourceClipper::createClipData(ClipperData* clipperData,
         renderer->setStyle(newRenderStyle.release());
 
         // In the case of a <use> element, we obtained its renderere above, to retrieve its clipRule.
-        // We hsve to pass the <use> renderer itself to renderSubtreeToImage() to apply it's x/y/transform/etc. values when rendering.
+        // We have to pass the <use> renderer itself to renderSubtreeToImageBuffer() to apply it's x/y/transform/etc. values when rendering.
         // So if isUseElement is true, refetch the childNode->renderer(), as renderer got overriden above.
-        SVGRenderSupport::renderSubtreeToImage(clipperData->clipMaskImage.get(), isUseElement ? childNode->renderer() : renderer);
+        SVGImageBufferTools::renderSubtreeToImageBuffer(clipperData->clipMaskImage.get(), isUseElement ? childNode->renderer() : renderer, maskContentTransformation);
 
         renderer->setStyle(oldRenderStyle.release());
         m_invalidationBlocked = false;
     }
 
-    maskContext->restore();
-
     return true;
 }
 
diff --git a/WebCore/rendering/RenderSVGResourceClipper.h b/WebCore/rendering/RenderSVGResourceClipper.h
index 6ea1563..20153e9 100644
--- a/WebCore/rendering/RenderSVGResourceClipper.h
+++ b/WebCore/rendering/RenderSVGResourceClipper.h
@@ -65,8 +65,7 @@ private:
     // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources
     bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect&, GraphicsContext*);
     bool pathOnlyClipping(GraphicsContext*, const FloatRect&);
-    bool createClipData(ClipperData*, const FloatRect& objectBoundingBox, const FloatRect& repaintRect, const FloatRect& clampedAbsoluteTargetRect, const AffineTransform& absoluteTransform);
-
+    bool drawContentIntoMaskImage(ClipperData*, const FloatRect& objectBoundingBox);
     void calculateClipContentRepaintRect();
 
     bool m_invalidationBlocked;
diff --git a/WebCore/rendering/RenderSVGResourceGradient.cpp b/WebCore/rendering/RenderSVGResourceGradient.cpp
index b8c4e77..1c33de4 100644
--- a/WebCore/rendering/RenderSVGResourceGradient.cpp
+++ b/WebCore/rendering/RenderSVGResourceGradient.cpp
@@ -80,13 +80,16 @@ static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& con
     const RenderObject* textRootBlock = SVGRenderSupport::findTextRootObject(object);
     ASSERT(textRootBlock);
 
-    AffineTransform absoluteTransform(SVGImageBufferTools::transformationToOutermostSVGCoordinateSystem(textRootBlock));
-    FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(textRootBlock, absoluteTransform, textRootBlock->repaintRectInLocalCoordinates());
+    AffineTransform absoluteTransform;
+    SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(textRootBlock, absoluteTransform);
+
+    FloatRect absoluteTargetRect = absoluteTransform.mapRect(textRootBlock->repaintRectInLocalCoordinates());
+    FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(textRootBlock, absoluteTargetRect);
     if (clampedAbsoluteTargetRect.isEmpty())
         return false;
 
     OwnPtr<ImageBuffer> maskImage;
-    if (!SVGImageBufferTools::createImageBuffer(clampedAbsoluteTargetRect, maskImage, DeviceRGB))
+    if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, maskImage, DeviceRGB))
         return false;
 
     GraphicsContext* maskImageContext = maskImage->context();
@@ -113,10 +116,13 @@ static inline AffineTransform clipToTextMask(GraphicsContext* context,
 
     targetRect = textRootBlock->repaintRectInLocalCoordinates();
 
-    AffineTransform absoluteTransform(SVGImageBufferTools::transformationToOutermostSVGCoordinateSystem(textRootBlock));
-    FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(textRootBlock, absoluteTransform, targetRect);
+    AffineTransform absoluteTransform;
+    SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(textRootBlock, absoluteTransform);
+
+    FloatRect absoluteTargetRect = absoluteTransform.mapRect(targetRect);
+    FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(textRootBlock, absoluteTargetRect);
 
-    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, imageBuffer.get());
+    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, imageBuffer);
 
     AffineTransform matrix;
     if (gradientData->boundingBoxMode) {
diff --git a/WebCore/rendering/RenderSVGResourceMasker.cpp b/WebCore/rendering/RenderSVGResourceMasker.cpp
index 39ad951..3e81929 100644
--- a/WebCore/rendering/RenderSVGResourceMasker.cpp
+++ b/WebCore/rendering/RenderSVGResourceMasker.cpp
@@ -96,20 +96,25 @@ bool RenderSVGResourceMasker::applyResource(RenderObject* object, RenderStyle*,
 
     MaskerData* maskerData = m_masker.get(object);
 
-    AffineTransform absoluteTransform(SVGImageBufferTools::transformationToOutermostSVGCoordinateSystem(object));
-    FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(object, absoluteTransform, object->repaintRectInLocalCoordinates());
+    AffineTransform absoluteTransform;
+    SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(object, absoluteTransform);
+
+    FloatRect absoluteTargetRect = absoluteTransform.mapRect(object->repaintRectInLocalCoordinates());
+    FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(object, absoluteTargetRect);
 
     if (!maskerData->maskImage && !clampedAbsoluteTargetRect.isEmpty()) {
         SVGMaskElement* maskElement = static_cast<SVGMaskElement*>(node());
         if (!maskElement)
             return false;
 
-        if (!SVGImageBufferTools::createImageBuffer(clampedAbsoluteTargetRect, maskerData->maskImage, LinearRGB))
+        if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, maskerData->maskImage, LinearRGB))
             return false;
 
         GraphicsContext* maskImageContext = maskerData->maskImage->context();
         ASSERT(maskImageContext);
 
+        // The save/restore pair is needed for clipToImageBuffer - it doesn't work without it on non-Cg platforms.
+        maskImageContext->save();
         maskImageContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());
         maskImageContext->concatCTM(absoluteTransform);
 
@@ -119,20 +124,22 @@ bool RenderSVGResourceMasker::applyResource(RenderObject* object, RenderStyle*,
     if (!maskerData->maskImage)
         return false;
 
-    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, maskerData->maskImage.get());
+    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAbsoluteTargetRect, maskerData->maskImage);
     return true;
 }
 
 void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, const SVGMaskElement* maskElement, RenderObject* object)
 {
+    GraphicsContext* maskImageContext = maskerData->maskImage->context();
+    ASSERT(maskImageContext);
+
     // Eventually adjust the mask image context according to the target objectBoundingBox.
+    AffineTransform maskContentTransformation;
     if (maskElement->maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
-        GraphicsContext* maskImageContext = maskerData->maskImage->context();
-        ASSERT(maskImageContext);
-
         FloatRect objectBoundingBox = object->objectBoundingBox();
-        maskImageContext->translate(objectBoundingBox.x(), objectBoundingBox.y());
-        maskImageContext->scale(FloatSize(objectBoundingBox.width(), objectBoundingBox.height()));
+        maskContentTransformation.translate(objectBoundingBox.x(), objectBoundingBox.y());
+        maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
+        maskImageContext->concatCTM(maskContentTransformation);
     }
 
     // Draw the content into the ImageBuffer.
@@ -143,9 +150,11 @@ void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, c
         RenderStyle* style = renderer->style();
         if (!style || style->display() == NONE || style->visibility() != VISIBLE)
             continue;
-        SVGRenderSupport::renderSubtreeToImage(maskerData->maskImage.get(), renderer);
+        SVGImageBufferTools::renderSubtreeToImageBuffer(maskerData->maskImage.get(), renderer, maskContentTransformation);
     }
 
+    maskImageContext->restore();
+
 #if !PLATFORM(CG)
     maskerData->maskImage->transformColorSpace(DeviceRGB, LinearRGB);
 #endif
diff --git a/WebCore/rendering/RenderSVGResourcePattern.cpp b/WebCore/rendering/RenderSVGResourcePattern.cpp
index f87fcb7..ccbdaca 100644
--- a/WebCore/rendering/RenderSVGResourcePattern.cpp
+++ b/WebCore/rendering/RenderSVGResourcePattern.cpp
@@ -101,7 +101,9 @@ bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle*
         FloatRect tileBoundaries;
         AffineTransform tileImageTransform = buildTileImageTransform(object, attributes, patternElement, tileBoundaries);
 
-        AffineTransform absoluteTransform(SVGImageBufferTools::transformationToOutermostSVGCoordinateSystem(object));
+        AffineTransform absoluteTransform;
+        SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(object, absoluteTransform);
+
         FloatRect absoluteTileBoundaries = absoluteTransform.mapRect(tileBoundaries);
 
         // Build tile image.
@@ -244,17 +246,12 @@ PassOwnPtr<ImageBuffer> RenderSVGResourcePattern::createTileImage(RenderObject*
 
     OwnPtr<ImageBuffer> tileImage;
 
-    if (!SVGImageBufferTools::createImageBuffer(clampedAbsoluteTileBoundaries, tileImage, DeviceRGB))
+    if (!SVGImageBufferTools::createImageBuffer(absoluteTileBoundaries, clampedAbsoluteTileBoundaries, tileImage, DeviceRGB))
         return PassOwnPtr<ImageBuffer>();
 
     GraphicsContext* tileImageContext = tileImage->context();
     ASSERT(tileImageContext);
 
-    // Compensate rounding effects, as the absolute target rect is using floating-point numbers and the image buffer size is integer.
-    IntSize unclampedImageSize(SVGImageBufferTools::roundedImageBufferSize(absoluteTileBoundaries.size()));
-    tileImageContext->scale(FloatSize(unclampedImageSize.width() / absoluteTileBoundaries.width(),
-                                      unclampedImageSize.height() / absoluteTileBoundaries.height()));
-
     // The image buffer represents the final rendered size, so the content has to be scaled (to avoid pixelation).
     tileImageContext->scale(FloatSize(absoluteTileBoundaries.width() / tileBoundaries.width(),
                                       absoluteTileBoundaries.height() / tileBoundaries.height()));
@@ -263,11 +260,13 @@ PassOwnPtr<ImageBuffer> RenderSVGResourcePattern::createTileImage(RenderObject*
     if (!tileImageTransform.isIdentity())
         tileImageContext->concatCTM(tileImageTransform);
 
+    AffineTransform contentTransformation;
+
     // Draw the content into the ImageBuffer.
     for (Node* node = attributes.patternContentElement()->firstChild(); node; node = node->nextSibling()) {
         if (!node->isSVGElement() || !static_cast<SVGElement*>(node)->isStyled() || !node->renderer())
             continue;
-        SVGRenderSupport::renderSubtreeToImage(tileImage.get(), node->renderer());
+        SVGImageBufferTools::renderSubtreeToImageBuffer(tileImage.get(), node->renderer(), contentTransformation);
     }
 
     return tileImage.release();
diff --git a/WebCore/rendering/SVGImageBufferTools.cpp b/WebCore/rendering/SVGImageBufferTools.cpp
index fd522a5..709bf10 100644
--- a/WebCore/rendering/SVGImageBufferTools.cpp
+++ b/WebCore/rendering/SVGImageBufferTools.cpp
@@ -25,32 +25,35 @@
 #include "FrameView.h"
 #include "GraphicsContext.h"
 #include "RenderObject.h"
+#include "RenderSVGContainer.h"
 #include "RenderSVGRoot.h"
 
 namespace WebCore {
 
-AffineTransform SVGImageBufferTools::transformationToOutermostSVGCoordinateSystem(const RenderObject* renderer)
+static AffineTransform& currentContentTransformation()
 {
-    ASSERT(renderer);
+    DEFINE_STATIC_LOCAL(AffineTransform, s_currentContentTransformation, ());
+    return s_currentContentTransformation;
+}
 
+void SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(const RenderObject* renderer, AffineTransform& absoluteTransform)
+{
     const RenderObject* current = renderer;
     ASSERT(current);
 
-    AffineTransform ctm;
+    absoluteTransform = currentContentTransformation();
     while (current) {
-        ctm.multiply(current->localToParentTransform());
+        absoluteTransform.multiply(current->localToParentTransform());
         if (current->isSVGRoot())
             break;
-
         current = current->parent();
     }
-
-    return ctm;
 }
 
-bool SVGImageBufferTools::createImageBuffer(const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imageBuffer, ImageColorSpace colorSpace)
+bool SVGImageBufferTools::createImageBuffer(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imageBuffer, ImageColorSpace colorSpace)
 {
     IntSize imageSize(roundedImageBufferSize(clampedAbsoluteTargetRect.size()));
+    IntSize unclampedImageSize(SVGImageBufferTools::roundedImageBufferSize(absoluteTargetRect.size()));
 
     // Don't create empty ImageBuffers.
     if (imageSize.isEmpty())
@@ -60,20 +63,62 @@ bool SVGImageBufferTools::createImageBuffer(const FloatRect& clampedAbsoluteTarg
     if (!image)
         return false;
 
+    GraphicsContext* imageContext = image->context();
+    ASSERT(imageContext);
+
+    // Compensate rounding effects, as the absolute target rect is using floating-point numbers and the image buffer size is integer.
+    imageContext->scale(FloatSize(unclampedImageSize.width() / absoluteTargetRect.width(), unclampedImageSize.height() / absoluteTargetRect.height()));
+
     imageBuffer = image.release();
     return true;
 }
 
-void SVGImageBufferTools::clipToImageBuffer(GraphicsContext* context, const AffineTransform& absoluteTransform, const FloatRect& clampedAbsoluteTargetRect, ImageBuffer* imageBuffer)
+void SVGImageBufferTools::renderSubtreeToImageBuffer(ImageBuffer* image, RenderObject* item, const AffineTransform& subtreeContentTransformation)
+{
+    ASSERT(item);
+    ASSERT(image);
+    ASSERT(image->context());
+
+    PaintInfo info(image->context(), PaintInfo::infiniteRect(), PaintPhaseForeground, 0, 0, 0);
+
+    // FIXME: isSVGContainer returns true for RenderSVGViewportContainer, so if this is ever
+    // called with one of those, we will read from the wrong offset in an object due to a bad cast.
+    RenderSVGContainer* svgContainer = 0;
+    if (item && item->isSVGContainer())
+        svgContainer = toRenderSVGContainer(item);
+
+    bool drawsContents = svgContainer ? svgContainer->drawsContents() : false;
+    if (svgContainer && !drawsContents)
+        svgContainer->setDrawsContents(true);
+
+    AffineTransform& contentTransformation = currentContentTransformation();
+    AffineTransform savedContentTransformation = contentTransformation;
+    contentTransformation.multiply(subtreeContentTransformation);
+
+    item->layoutIfNeeded();
+    item->paint(info, 0, 0);
+
+    contentTransformation = savedContentTransformation;
+
+    if (svgContainer && !drawsContents)
+        svgContainer->setDrawsContents(false);
+}
+
+void SVGImageBufferTools::clipToImageBuffer(GraphicsContext* context, const AffineTransform& absoluteTransform, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imageBuffer)
 {
     ASSERT(context);
     ASSERT(imageBuffer);
 
-    // The mask image has been created in the device coordinate space, as the image should not be scaled.
-    // So the actual masking process has to be done in the device coordinate space as well.
+    // The mask image has been created in the absolute coordinate space, as the image should not be scaled.
+    // So the actual masking process has to be done in the absolute coordinate space as well.
     context->concatCTM(absoluteTransform.inverse());
-    context->clipToImageBuffer(imageBuffer, clampedAbsoluteTargetRect);
+    context->clipToImageBuffer(imageBuffer.get(), clampedAbsoluteTargetRect);
     context->concatCTM(absoluteTransform);
+
+    // When nesting resources, with objectBoundingBox as content unit types, there's no use in caching the
+    // resulting image buffer as the parent resource already caches the result.
+    if (!currentContentTransformation().isIdentity())
+        imageBuffer.clear();
 }
 
 IntSize SVGImageBufferTools::roundedImageBufferSize(const FloatSize& size)
@@ -81,12 +126,12 @@ IntSize SVGImageBufferTools::roundedImageBufferSize(const FloatSize& size)
     return IntSize(static_cast<int>(lroundf(size.width())), static_cast<int>(lroundf(size.height())));
 }
 
-FloatRect SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(const RenderObject* renderer, const AffineTransform& absoluteTransform, const FloatRect& targetRect)
+FloatRect SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(const RenderObject* renderer, const FloatRect& absoluteTargetRect)
 {
     ASSERT(renderer);
 
     const RenderSVGRoot* svgRoot = SVGRenderSupport::findTreeRootObject(renderer);
-    FloatRect clampedAbsoluteTargetRect = absoluteTransform.mapRect(targetRect);
+    FloatRect clampedAbsoluteTargetRect = absoluteTargetRect;
     clampedAbsoluteTargetRect.intersect(svgRoot->contentBoxRect());
     return clampedAbsoluteTargetRect;
 }
diff --git a/WebCore/rendering/SVGImageBufferTools.h b/WebCore/rendering/SVGImageBufferTools.h
index 7535042..8894aae 100644
--- a/WebCore/rendering/SVGImageBufferTools.h
+++ b/WebCore/rendering/SVGImageBufferTools.h
@@ -34,11 +34,12 @@ class RenderObject;
 
 class SVGImageBufferTools : public Noncopyable {
 public:
-    static bool createImageBuffer(const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, ImageColorSpace);
-    static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absoluteTransform, const FloatRect& clampedAbsoluteTargetRect, ImageBuffer*);
+    static bool createImageBuffer(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, ImageColorSpace);
+    static void renderSubtreeToImageBuffer(ImageBuffer*, RenderObject*, const AffineTransform&);
+    static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absoluteTransform, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&);
 
-    static AffineTransform transformationToOutermostSVGCoordinateSystem(const RenderObject*);
-    static FloatRect clampedAbsoluteTargetRectForRenderer(const RenderObject*, const AffineTransform& absouteTransform, const FloatRect& targetRect);
+    static void calculateTransformationToOutermostSVGCoordinateSystem(const RenderObject*, AffineTransform& absoluteTransform);
+    static FloatRect clampedAbsoluteTargetRectForRenderer(const RenderObject*, const FloatRect& absoluteTargetRect);
     static IntSize roundedImageBufferSize(const FloatSize&);
 
 private:
diff --git a/WebCore/rendering/SVGRenderSupport.cpp b/WebCore/rendering/SVGRenderSupport.cpp
index 90fed6a..12d6d77 100644
--- a/WebCore/rendering/SVGRenderSupport.cpp
+++ b/WebCore/rendering/SVGRenderSupport.cpp
@@ -33,7 +33,6 @@
 #include "NodeRenderStyle.h"
 #include "RenderLayer.h"
 #include "RenderPath.h"
-#include "RenderSVGContainer.h"
 #include "RenderSVGResource.h"
 #include "RenderSVGResourceClipper.h"
 #include "RenderSVGResourceFilter.h"
@@ -116,8 +115,10 @@ bool SVGRenderSupport::prepareToRenderSVGContent(RenderObject* object, PaintInfo
             return false;
     }
 
-    if (RenderSVGResourceClipper* clipper = resources->clipper())
-        clipper->applyResource(object, style, paintInfo.context, ApplyToDefaultMode);
+    if (RenderSVGResourceClipper* clipper = resources->clipper()) {
+        if (!clipper->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
+            return false;
+    }
 
 #if ENABLE(FILTERS)
     if (RenderSVGResourceFilter* filter = resources->filter()) {
@@ -163,31 +164,6 @@ void SVGRenderSupport::finishRenderSVGContent(RenderObject* object, PaintInfo& p
         paintInfo.context->endTransparencyLayer();
 }
 
-void SVGRenderSupport::renderSubtreeToImage(ImageBuffer* image, RenderObject* item)
-{
-    ASSERT(item);
-    ASSERT(image);
-    ASSERT(image->context());
-
-    PaintInfo info(image->context(), PaintInfo::infiniteRect(), PaintPhaseForeground, 0, 0, 0);
-
-    // FIXME: isSVGContainer returns true for RenderSVGViewportContainer, so if this is ever
-    // called with one of those, we will read from the wrong offset in an object due to a bad cast.
-    RenderSVGContainer* svgContainer = 0;
-    if (item && item->isSVGContainer())
-        svgContainer = toRenderSVGContainer(item);
-
-    bool drawsContents = svgContainer ? svgContainer->drawsContents() : false;
-    if (svgContainer && !drawsContents)
-        svgContainer->setDrawsContents(true);
-
-    item->layoutIfNeeded();
-    item->paint(info, 0, 0);
-
-    if (svgContainer && !drawsContents)
-        svgContainer->setDrawsContents(false);
-}
-
 FloatRect SVGRenderSupport::computeContainerBoundingBox(const RenderObject* container, ContainerBoundingBoxMode mode)
 {
     FloatRect boundingBox;
diff --git a/WebCore/rendering/SVGRenderSupport.h b/WebCore/rendering/SVGRenderSupport.h
index 715fb55..2de1e99 100644
--- a/WebCore/rendering/SVGRenderSupport.h
+++ b/WebCore/rendering/SVGRenderSupport.h
@@ -73,9 +73,6 @@ public:
     static void computeRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer, IntRect&, bool fixed);
     static void mapLocalToContainer(const RenderObject*, RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&);
 
-    // This offers a way to render parts of a WebKit rendering tree into a ImageBuffer.
-    static void renderSubtreeToImage(ImageBuffer*, RenderObject*);
-
     // Shared between SVG renderers and resources.
     static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
 
diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp
index 92534e8..eb024f6 100644
--- a/WebCore/svg/SVGFEImageElement.cpp
+++ b/WebCore/svg/SVGFEImageElement.cpp
@@ -30,10 +30,10 @@
 #include "Document.h"
 #include "RenderObject.h"
 #include "RenderSVGResource.h"
+#include "SVGImageBufferTools.h"
 #include "SVGLength.h"
 #include "SVGNames.h"
 #include "SVGPreserveAspectRatio.h"
-#include "SVGRenderSupport.h"
 
 namespace WebCore {
 
@@ -134,7 +134,8 @@ PassRefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*)
         IntRect targetRect = enclosingIntRect(renderer->objectBoundingBox());
         m_targetImage = ImageBuffer::create(targetRect.size(), LinearRGB);
 
-        SVGRenderSupport::renderSubtreeToImage(m_targetImage.get(), renderer);
+        AffineTransform contentTransformation;
+        SVGImageBufferTools::renderSubtreeToImageBuffer(m_targetImage.get(), renderer, contentTransformation);
     }
 
     return FEImage::create(m_targetImage ? m_targetImage->copyImage() : m_cachedImage->image(), preserveAspectRatio());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list