| Differences between
and this patch
- a/Source/WebCore/ChangeLog +22 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2016-10-20  Dean Jackson  <dino@apple.com>
2
3
        SVG should not paint selection within a mask
4
        https://bugs.webkit.org/show_bug.cgi?id=163772
5
        <rdar://problem/28705129>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        When masking content, we shouldn't paint the text
10
        selection as we are rendering into the masking
11
        offscreen buffer.
12
13
        Test: svg/masking/mask-should-not-paint-selection.html
14
15
        * rendering/PaintPhase.h: Add a new behavior - PaintBehaviorSkipSelectionHighlight.
16
        * rendering/svg/SVGInlineTextBox.cpp:
17
        (WebCore::SVGInlineTextBox::paint): Don't update the selectionStyle if
18
        PaintBehaviorSkipSelectionHighlight is true.
19
        * rendering/svg/SVGRenderingContext.cpp:
20
        (WebCore::SVGRenderingContext::renderSubtreeToImageBuffer): Add PaintBehaviorSkipSelectionHighlight
21
        to the PaintInfo.
22
1
2016-10-20  Dave Hyatt  <hyatt@apple.com>
23
2016-10-20  Dave Hyatt  <hyatt@apple.com>
2
24
3
        [CSS Parser] Fix crash when parsing -webkit-margin-collapse
25
        [CSS Parser] Fix crash when parsing -webkit-margin-collapse
- a/Source/WebCore/rendering/PaintPhase.h -7 / +8 lines
Lines 56-68 enum PaintPhase { a/Source/WebCore/rendering/PaintPhase.h_sec1
56
enum PaintBehaviorFlags {
56
enum PaintBehaviorFlags {
57
    PaintBehaviorNormal = 0,
57
    PaintBehaviorNormal = 0,
58
    PaintBehaviorSelectionOnly = 1 << 0,
58
    PaintBehaviorSelectionOnly = 1 << 0,
59
    PaintBehaviorForceBlackText = 1 << 1,
59
    PaintBehaviorSkipSelectionHighlight = 1 << 1,
60
    PaintBehaviorForceWhiteText = 1 << 2,
60
    PaintBehaviorForceBlackText = 1 << 2,
61
    PaintBehaviorFlattenCompositingLayers = 1 << 3,
61
    PaintBehaviorForceWhiteText = 1 << 3,
62
    PaintBehaviorRenderingSVGMask = 1 << 4,
62
    PaintBehaviorFlattenCompositingLayers = 1 << 4,
63
    PaintBehaviorSkipRootBackground = 1 << 5,
63
    PaintBehaviorRenderingSVGMask = 1 << 5,
64
    PaintBehaviorRootBackgroundOnly = 1 << 6,
64
    PaintBehaviorSkipRootBackground = 1 << 6,
65
    PaintBehaviorSelectionAndBackgroundsOnly = 1 << 7,
65
    PaintBehaviorRootBackgroundOnly = 1 << 7,
66
    PaintBehaviorSelectionAndBackgroundsOnly = 1 << 8,
66
};
67
};
67
68
68
typedef unsigned PaintBehavior;
69
typedef unsigned PaintBehavior;
- a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp -1 / +2 lines
Lines 247-252 void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp_sec1
247
    auto& parentRenderer = parent()->renderer();
247
    auto& parentRenderer = parent()->renderer();
248
248
249
    bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
249
    bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
250
    bool shouldPaintSelectionHighlight = !(paintInfo.paintBehavior & PaintBehaviorSkipSelectionHighlight);
250
    bool hasSelection = !parentRenderer.document().printing() && selectionState() != RenderObject::SelectionNone;
251
    bool hasSelection = !parentRenderer.document().printing() && selectionState() != RenderObject::SelectionNone;
251
    if (!hasSelection && paintSelectedTextOnly)
252
    if (!hasSelection && paintSelectedTextOnly)
252
        return;
253
        return;
Lines 262-268 void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp_sec2
262
    bool hasVisibleStroke = svgStyle.hasVisibleStroke();
263
    bool hasVisibleStroke = svgStyle.hasVisibleStroke();
263
264
264
    const RenderStyle* selectionStyle = &style;
265
    const RenderStyle* selectionStyle = &style;
265
    if (hasSelection) {
266
    if (hasSelection && shouldPaintSelectionHighlight) {
266
        selectionStyle = parentRenderer.getCachedPseudoStyle(SELECTION);
267
        selectionStyle = parentRenderer.getCachedPseudoStyle(SELECTION);
267
        if (selectionStyle) {
268
        if (selectionStyle) {
268
            const SVGRenderStyle& svgSelectionStyle = selectionStyle->svgStyle();
269
            const SVGRenderStyle& svgSelectionStyle = selectionStyle->svgStyle();
- a/Source/WebCore/rendering/svg/SVGRenderingContext.cpp -1 / +3 lines
Lines 295-301 void SVGRenderingContext::renderSubtreeToImageBuffer(ImageBuffer* image, RenderE a/Source/WebCore/rendering/svg/SVGRenderingContext.cpp_sec1
295
{
295
{
296
    ASSERT(image);
296
    ASSERT(image);
297
297
298
    PaintInfo info(image->context(), LayoutRect::infiniteRect(), PaintPhaseForeground, PaintBehaviorNormal);
298
    // Rendering into a buffer implies we're being used for masking, clipping, patterns or filters. In each of these
299
    // cases we don't want to paint the selection.
300
    PaintInfo info(image->context(), LayoutRect::infiniteRect(), PaintPhaseForeground, PaintBehaviorSkipSelectionHighlight);
299
301
300
    AffineTransform& contentTransformation = currentContentTransformation();
302
    AffineTransform& contentTransformation = currentContentTransformation();
301
    AffineTransform savedContentTransformation = contentTransformation;
303
    AffineTransform savedContentTransformation = contentTransformation;
- a/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp -1 / +2 lines
Lines 53-61 void SVGRootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse a/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp_sec1
53
53
54
    bool isPrinting = renderSVGText().document().printing();
54
    bool isPrinting = renderSVGText().document().printing();
55
    bool hasSelection = !isPrinting && selectionState() != RenderObject::SelectionNone;
55
    bool hasSelection = !isPrinting && selectionState() != RenderObject::SelectionNone;
56
    bool shouldPaintSelectionHighlight = !(paintInfo.paintBehavior & PaintBehaviorSkipSelectionHighlight);
56
57
57
    PaintInfo childPaintInfo(paintInfo);
58
    PaintInfo childPaintInfo(paintInfo);
58
    if (hasSelection) {
59
    if (hasSelection && shouldPaintSelectionHighlight) {
59
        for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
60
        for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
60
            if (is<SVGInlineTextBox>(*child))
61
            if (is<SVGInlineTextBox>(*child))
61
                downcast<SVGInlineTextBox>(*child).paintSelectionBackground(childPaintInfo);
62
                downcast<SVGInlineTextBox>(*child).paintSelectionBackground(childPaintInfo);
- a/LayoutTests/ChangeLog +11 lines
Lines 1-5 a/LayoutTests/ChangeLog_sec1
1
2016-10-20  Dean Jackson  <dino@apple.com>
1
2016-10-20  Dean Jackson  <dino@apple.com>
2
2
3
        SVG should not paint selection within a mask
4
        https://bugs.webkit.org/show_bug.cgi?id=163772
5
        <rdar://problem/28705129>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        * svg/masking/mask-should-not-paint-selection-expected.html: Added.
10
        * svg/masking/mask-should-not-paint-selection.html: Added.
11
12
2016-10-20  Dean Jackson  <dino@apple.com>
13
3
        Shapes tests failing on iOS
14
        Shapes tests failing on iOS
4
        https://bugs.webkit.org/show_bug.cgi?id=163755
15
        https://bugs.webkit.org/show_bug.cgi?id=163755
5
        <rdar://problem/28875780>
16
        <rdar://problem/28875780>
- a/LayoutTests/svg/masking/mask-should-not-paint-selection-expected.html +12 lines
Line 0 a/LayoutTests/svg/masking/mask-should-not-paint-selection-expected.html_sec1
1
<body>
2
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
 <defs>
4
  <mask id="m1" x="0" y="0" width="200" height="200">
5
   <circle cx="100" cy="100" r="20" fill="white"/>
6
   <text y="100" fill="white" font-size="50">
7
    Text
8
   </text>
9
  </mask>
10
 </defs>
11
 <rect id="id1" mask="url(#m1)" x="10" y="10" width="180" height="180"/>
12
</svg>
- a/LayoutTests/svg/masking/mask-should-not-paint-selection.html +26 lines
Line 0 a/LayoutTests/svg/masking/mask-should-not-paint-selection.html_sec1
1
<style>
2
text::selection{
3
    color: blue;
4
}
5
</style>
6
<script>
7
window.addEventListener("load", function () {
8
    var range = document.createRange();
9
    var selection = document.getSelection()
10
    range.setStart(m1, 0);
11
    range.setEnd(id1, id1.childNodes.length);
12
    selection.addRange(range);
13
}, false);
14
</script>
15
<body>
16
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
17
 <defs>
18
  <mask id="m1" x="0" y="0" width="200" height="200">
19
   <circle cx="100" cy="100" r="20" fill="white"/>
20
   <text y="100" fill="white" font-size="50">
21
    Text
22
   </text>
23
  </mask>
24
 </defs>
25
 <rect id="id1" mask="url(#m1)" x="10" y="10" width="180" height="180"/>
26
</svg>

Return to Bug 163772