Title: [207692] trunk
Revision
207692
Author
d...@apple.com
Date
2016-10-21 12:10:41 -0700 (Fri, 21 Oct 2016)

Log Message

SVG should not paint selection within a mask
https://bugs.webkit.org/show_bug.cgi?id=163772
<rdar://problem/28705129>

Reviewed by Simon Fraser.

Source/WebCore:

When masking content, we shouldn't paint the text
selection as we are rendering into the masking
offscreen buffer.

Test: svg/masking/mask-should-not-paint-selection.html

* rendering/PaintPhase.h: Add a new behavior - PaintBehaviorSkipSelectionHighlight.
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paint): Don't update the selectionStyle if
PaintBehaviorSkipSelectionHighlight is true.
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::renderSubtreeToImageBuffer): Add PaintBehaviorSkipSelectionHighlight
to the PaintInfo.

LayoutTests:

* svg/masking/mask-should-not-paint-selection-expected.html: Added.
* svg/masking/mask-should-not-paint-selection.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207691 => 207692)


--- trunk/LayoutTests/ChangeLog	2016-10-21 18:58:44 UTC (rev 207691)
+++ trunk/LayoutTests/ChangeLog	2016-10-21 19:10:41 UTC (rev 207692)
@@ -1,3 +1,14 @@
+2016-10-20  Dean Jackson  <d...@apple.com>
+
+        SVG should not paint selection within a mask
+        https://bugs.webkit.org/show_bug.cgi?id=163772
+        <rdar://problem/28705129>
+
+        Reviewed by Simon Fraser.
+
+        * svg/masking/mask-should-not-paint-selection-expected.html: Added.
+        * svg/masking/mask-should-not-paint-selection.html: Added.
+
 2016-10-21  Zalan Bujtas  <za...@apple.com>
 
         Do not mutate the render tree while collecting selection repaint rects.

Added: trunk/LayoutTests/svg/masking/mask-should-not-paint-selection-expected.html (0 => 207692)


--- trunk/LayoutTests/svg/masking/mask-should-not-paint-selection-expected.html	                        (rev 0)
+++ trunk/LayoutTests/svg/masking/mask-should-not-paint-selection-expected.html	2016-10-21 19:10:41 UTC (rev 207692)
@@ -0,0 +1,12 @@
+<body>
+<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs>
+  <mask id="m1" x="0" y="0" width="200" height="200">
+   <circle cx="100" cy="100" r="20" fill="white"/>
+   <text y="100" fill="white" font-size="50">
+    Text
+   </text>
+  </mask>
+ </defs>
+ <rect id="id1" mask="url(#m1)" x="10" y="10" width="180" height="180"/>
+</svg>
Property changes on: trunk/LayoutTests/svg/masking/mask-should-not-paint-selection-expected.html
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Revision \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Added: trunk/LayoutTests/svg/masking/mask-should-not-paint-selection.html (0 => 207692)


--- trunk/LayoutTests/svg/masking/mask-should-not-paint-selection.html	                        (rev 0)
+++ trunk/LayoutTests/svg/masking/mask-should-not-paint-selection.html	2016-10-21 19:10:41 UTC (rev 207692)
@@ -0,0 +1,26 @@
+<style>
+text::selection{
+    color: blue;
+}
+</style>
+<script>
+window.addEventListener("load", function () {
+    var range = document.createRange();
+    var selection = document.getSelection()
+    range.setStart(m1, 0);
+    range.setEnd(id1, id1.childNodes.length);
+    selection.addRange(range);
+}, false);
+</script>
+<body>
+<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs>
+  <mask id="m1" x="0" y="0" width="200" height="200">
+   <circle cx="100" cy="100" r="20" fill="white"/>
+   <text y="100" fill="white" font-size="50">
+    Text
+   </text>
+  </mask>
+ </defs>
+ <rect id="id1" mask="url(#m1)" x="10" y="10" width="180" height="180"/>
+</svg>
Property changes on: trunk/LayoutTests/svg/masking/mask-should-not-paint-selection.html
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Revision \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Modified: trunk/Source/WebCore/ChangeLog (207691 => 207692)


--- trunk/Source/WebCore/ChangeLog	2016-10-21 18:58:44 UTC (rev 207691)
+++ trunk/Source/WebCore/ChangeLog	2016-10-21 19:10:41 UTC (rev 207692)
@@ -1,3 +1,25 @@
+2016-10-20  Dean Jackson  <d...@apple.com>
+
+        SVG should not paint selection within a mask
+        https://bugs.webkit.org/show_bug.cgi?id=163772
+        <rdar://problem/28705129>
+
+        Reviewed by Simon Fraser.
+
+        When masking content, we shouldn't paint the text
+        selection as we are rendering into the masking
+        offscreen buffer.
+
+        Test: svg/masking/mask-should-not-paint-selection.html
+
+        * rendering/PaintPhase.h: Add a new behavior - PaintBehaviorSkipSelectionHighlight.
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paint): Don't update the selectionStyle if
+        PaintBehaviorSkipSelectionHighlight is true.
+        * rendering/svg/SVGRenderingContext.cpp:
+        (WebCore::SVGRenderingContext::renderSubtreeToImageBuffer): Add PaintBehaviorSkipSelectionHighlight
+        to the PaintInfo.
+
 2016-10-21  Chris Dumez  <cdu...@apple.com>
 
         [Web IDL] MediaControlsHost has invalid operation overloads

Modified: trunk/Source/WebCore/rendering/PaintPhase.h (207691 => 207692)


--- trunk/Source/WebCore/rendering/PaintPhase.h	2016-10-21 18:58:44 UTC (rev 207691)
+++ trunk/Source/WebCore/rendering/PaintPhase.h	2016-10-21 19:10:41 UTC (rev 207692)
@@ -54,15 +54,16 @@
 };
 
 enum PaintBehaviorFlags {
-    PaintBehaviorNormal = 0,
-    PaintBehaviorSelectionOnly = 1 << 0,
-    PaintBehaviorForceBlackText = 1 << 1,
-    PaintBehaviorForceWhiteText = 1 << 2,
-    PaintBehaviorFlattenCompositingLayers = 1 << 3,
-    PaintBehaviorRenderingSVGMask = 1 << 4,
-    PaintBehaviorSkipRootBackground = 1 << 5,
-    PaintBehaviorRootBackgroundOnly = 1 << 6,
-    PaintBehaviorSelectionAndBackgroundsOnly = 1 << 7,
+    PaintBehaviorNormal                      = 0,
+    PaintBehaviorSelectionOnly               = 1 << 0,
+    PaintBehaviorSkipSelectionHighlight      = 1 << 1,
+    PaintBehaviorForceBlackText              = 1 << 2,
+    PaintBehaviorForceWhiteText              = 1 << 3,
+    PaintBehaviorFlattenCompositingLayers    = 1 << 4,
+    PaintBehaviorRenderingSVGMask            = 1 << 5,
+    PaintBehaviorSkipRootBackground          = 1 << 6,
+    PaintBehaviorRootBackgroundOnly          = 1 << 7,
+    PaintBehaviorSelectionAndBackgroundsOnly = 1 << 8,
 };
 
 typedef unsigned PaintBehavior;

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (207691 => 207692)


--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2016-10-21 18:58:44 UTC (rev 207691)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2016-10-21 19:10:41 UTC (rev 207692)
@@ -247,6 +247,7 @@
     auto& parentRenderer = parent()->renderer();
 
     bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
+    bool shouldPaintSelectionHighlight = !(paintInfo.paintBehavior & PaintBehaviorSkipSelectionHighlight);
     bool hasSelection = !parentRenderer.document().printing() && selectionState() != RenderObject::SelectionNone;
     if (!hasSelection && paintSelectedTextOnly)
         return;
@@ -262,7 +263,7 @@
     bool hasVisibleStroke = svgStyle.hasVisibleStroke();
 
     const RenderStyle* selectionStyle = &style;
-    if (hasSelection) {
+    if (hasSelection && shouldPaintSelectionHighlight) {
         selectionStyle = parentRenderer.getCachedPseudoStyle(SELECTION);
         if (selectionStyle) {
             const SVGRenderStyle& svgSelectionStyle = selectionStyle->svgStyle();

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp (207691 => 207692)


--- trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp	2016-10-21 18:58:44 UTC (rev 207691)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp	2016-10-21 19:10:41 UTC (rev 207692)
@@ -295,7 +295,9 @@
 {
     ASSERT(image);
 
-    PaintInfo info(image->context(), LayoutRect::infiniteRect(), PaintPhaseForeground, PaintBehaviorNormal);
+    // Rendering into a buffer implies we're being used for masking, clipping, patterns or filters. In each of these
+    // cases we don't want to paint the selection.
+    PaintInfo info(image->context(), LayoutRect::infiniteRect(), PaintPhaseForeground, PaintBehaviorSkipSelectionHighlight);
 
     AffineTransform& contentTransformation = currentContentTransformation();
     AffineTransform savedContentTransformation = contentTransformation;

Modified: trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp (207691 => 207692)


--- trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp	2016-10-21 18:58:44 UTC (rev 207691)
+++ trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp	2016-10-21 19:10:41 UTC (rev 207692)
@@ -53,9 +53,10 @@
 
     bool isPrinting = renderSVGText().document().printing();
     bool hasSelection = !isPrinting && selectionState() != RenderObject::SelectionNone;
+    bool shouldPaintSelectionHighlight = !(paintInfo.paintBehavior & PaintBehaviorSkipSelectionHighlight);
 
     PaintInfo childPaintInfo(paintInfo);
-    if (hasSelection) {
+    if (hasSelection && shouldPaintSelectionHighlight) {
         for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
             if (is<SVGInlineTextBox>(*child))
                 downcast<SVGInlineTextBox>(*child).paintSelectionBackground(childPaintInfo);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to