<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191617] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191617">191617</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2015-10-26 21:03:38 -0700 (Mon, 26 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove redundant GraphicsContext::clip(const Path&amp;, WindRule)
https://bugs.webkit.org/show_bug.cgi?id=150584

Reviewed by Tim Horton.

GraphicsContext had both clipPath(const Path&amp;, WindRule) and clip(const Path&amp;, WindRule),
which were mostly the same other than GraphicsContext::clipPath() not clipping if the path
was empty (added, I think by mistake, in <a href="http://trac.webkit.org/projects/webkit/changeset/72926">r72926</a>), and not calling m_data-&gt;clip().

Make clipPath() be the winner, and have it behave like clip() with empty paths, and call m_data-&gt;clip().

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::clipRoundedRect):
* platform/graphics/GraphicsContext.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::clip): Deleted.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::canvasClip):
(WebCore::GraphicsContext::clip): Deleted.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBoxShadow): Making a path, calling addRoundedRect() and then clipping
to the path is the same as context.clipRoundedRect().
* rendering/mathml/RenderMathMLRadicalOperator.cpp:
(WebCore::RenderMathMLRadicalOperator::paint):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContextcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContexth">trunk/Source/WebCore/platform/graphics/GraphicsContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp">trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp">trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLRadicalOperatorcpp">trunk/Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191616 => 191617)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/ChangeLog        2015-10-27 04:03:38 UTC (rev 191617)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2015-10-26  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Remove redundant GraphicsContext::clip(const Path&amp;, WindRule)
+        https://bugs.webkit.org/show_bug.cgi?id=150584
+
+        Reviewed by Tim Horton.
+
+        GraphicsContext had both clipPath(const Path&amp;, WindRule) and clip(const Path&amp;, WindRule),
+        which were mostly the same other than GraphicsContext::clipPath() not clipping if the path
+        was empty (added, I think by mistake, in r72926), and not calling m_data-&gt;clip().
+
+        Make clipPath() be the winner, and have it behave like clip() with empty paths, and call m_data-&gt;clip().
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::clipRoundedRect):
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::clipPath):
+        (WebCore::GraphicsContext::clip): Deleted.
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::clipPath):
+        (WebCore::GraphicsContext::canvasClip):
+        (WebCore::GraphicsContext::clip): Deleted.
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintBoxShadow): Making a path, calling addRoundedRect() and then clipping
+        to the path is the same as context.clipRoundedRect().
+        * rendering/mathml/RenderMathMLRadicalOperator.cpp:
+        (WebCore::RenderMathMLRadicalOperator::paint):
+
</ins><span class="cx"> 2015-10-26  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Floating box is misplaced after content change.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (191616 => 191617)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2015-10-27 04:03:38 UTC (rev 191617)
</span><span class="lines">@@ -461,7 +461,7 @@
</span><span class="cx"> 
</span><span class="cx">     Path path;
</span><span class="cx">     path.addRoundedRect(rect);
</span><del>-    clip(path);
</del><ins>+    clipPath(path);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::clipOutRoundedRect(const FloatRoundedRect&amp; rect)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (191616 => 191617)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2015-10-27 04:03:38 UTC (rev 191617)
</span><span class="lines">@@ -331,7 +331,7 @@
</span><span class="cx"> 
</span><span class="cx">     void clipOut(const FloatRect&amp;);
</span><span class="cx">     void clipOutRoundedRect(const FloatRoundedRect&amp;);
</span><del>-    void clipPath(const Path&amp;, WindRule);
</del><ins>+    void clipPath(const Path&amp;, WindRule = RULE_EVENODD);
</ins><span class="cx">     void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
</span><span class="cx">     void clipToImageBuffer(ImageBuffer&amp;, const FloatRect&amp;);
</span><span class="cx">     
</span><span class="lines">@@ -413,8 +413,6 @@
</span><span class="cx">     void setDrawLuminanceMask(bool drawLuminanceMask) { m_state.drawLuminanceMask = drawLuminanceMask; }
</span><span class="cx">     bool drawLuminanceMask() const { return m_state.drawLuminanceMask; }
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void clip(const Path&amp;, WindRule = RULE_EVENODD);
-
</del><span class="cx">     // This clip function is used only by &lt;canvas&gt; code. It allows
</span><span class="cx">     // implementations to handle clipping on the canvas differently since
</span><span class="cx">     // the discipline is different.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (191616 => 191617)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2015-10-27 04:03:38 UTC (rev 191617)
</span><span class="lines">@@ -494,8 +494,13 @@
</span><span class="cx">     cairo_t* cr = platformContext()-&gt;cr();
</span><span class="cx">     if (!path.isNull())
</span><span class="cx">         setPathOnCairoContext(cr, path.platformPath()-&gt;context());
</span><ins>+
+    cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
</ins><span class="cx">     cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
</span><span class="cx">     cairo_clip(cr);
</span><ins>+    cairo_set_fill_rule(cr, savedFillRule);
+
+    m_data-&gt;clip(path);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntRect GraphicsContext::clipBounds() const
</span><span class="lines">@@ -960,30 +965,9 @@
</span><span class="cx">     cairo_set_operator(platformContext()-&gt;cr(), cairo_op);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::clip(const Path&amp; path, WindRule windRule)
-{
-    if (paintingDisabled())
-        return;
-
-    cairo_t* cr = platformContext()-&gt;cr();
-    if (!path.isNull()) {
-        cairo_path_t* pathCopy = cairo_copy_path(path.platformPath()-&gt;context());
-        cairo_append_path(cr, pathCopy);
-        cairo_path_destroy(pathCopy);
-    }
-    cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
-    if (windRule == RULE_NONZERO)
-        cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
-    else
-        cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
-    cairo_clip(cr);
-    cairo_set_fill_rule(cr, savedFillRule);
-    m_data-&gt;clip(path);
-}
-
</del><span class="cx"> void GraphicsContext::canvasClip(const Path&amp; path, WindRule windRule)
</span><span class="cx"> {
</span><del>-    clip(path, windRule);
</del><ins>+    clipPath(path, windRule);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::clipOut(const Path&amp; path)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (191616 => 191617)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2015-10-27 04:03:38 UTC (rev 191617)
</span><span class="lines">@@ -982,20 +982,20 @@
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // Why does clipping to an empty path do nothing?
-    // Why is this different from GraphicsContext::clip(const Path&amp;).
</del><ins>+    CGContextRef context = platformContext();
</ins><span class="cx">     if (path.isEmpty())
</span><del>-        return;
</del><ins>+        CGContextClipToRect(context, CGRectZero);
+    else {
+        CGContextBeginPath(platformContext());
+        CGContextAddPath(platformContext(), path.platformPath());
</ins><span class="cx"> 
</span><del>-    CGContextRef context = platformContext();
-
-    CGContextBeginPath(platformContext());
-    CGContextAddPath(platformContext(), path.platformPath());
-
-    if (clipRule == RULE_EVENODD)
-        CGContextEOClip(context);
-    else
-        CGContextClip(context);
</del><ins>+        if (clipRule == RULE_EVENODD)
+            CGContextEOClip(context);
+        else
+            CGContextClip(context);
+    }
+    
+    m_data-&gt;clip(path);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntRect GraphicsContext::clipBounds() const
</span><span class="lines">@@ -1234,31 +1234,9 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::clip(const Path&amp; path, WindRule fillRule)
-{
-    if (paintingDisabled())
-        return;
-    CGContextRef context = platformContext();
-
-    // CGContextClip does nothing if the path is empty, so in this case, we
-    // instead clip against a zero rect to reduce the clipping region to
-    // nothing - which is the intended behavior of clip() if the path is empty.    
-    if (path.isEmpty())
-        CGContextClipToRect(context, CGRectZero);
-    else {
-        CGContextBeginPath(context);
-        CGContextAddPath(context, path.platformPath());
-        if (fillRule == RULE_NONZERO)
-            CGContextClip(context);
-        else
-            CGContextEOClip(context);
-    }
-    m_data-&gt;clip(path);
-}
-
</del><span class="cx"> void GraphicsContext::canvasClip(const Path&amp; path, WindRule fillRule)
</span><span class="cx"> {
</span><del>-    clip(path, fillRule);
</del><ins>+    clipPath(path, fillRule);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::clipOut(const Path&amp; path)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (191616 => 191617)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2015-10-27 04:03:38 UTC (rev 191617)
</span><span class="lines">@@ -2346,9 +2346,7 @@
</span><span class="cx"> 
</span><span class="cx">             GraphicsContextStateSaver stateSaver(context);
</span><span class="cx">             if (hasBorderRadius) {
</span><del>-                Path path;
-                path.addRoundedRect(pixelSnappedBorderRect);
-                context.clip(path);
</del><ins>+                context.clipRoundedRect(pixelSnappedBorderRect);
</ins><span class="cx">                 pixelSnappedRoundedHole.shrinkRadii(shadowSpread);
</span><span class="cx">             } else
</span><span class="cx">                 context.clip(pixelSnappedBorderRect.rect());
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLRadicalOperatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.cpp (191616 => 191617)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.cpp        2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.cpp        2015-10-27 04:03:38 UTC (rev 191617)
</span><span class="lines">@@ -152,14 +152,14 @@
</span><span class="cx">     GraphicsContextStateSaver maskStateSaver(info.context());
</span><span class="cx"> 
</span><span class="cx">     // Build a mask to draw the thick part of the root.
</span><del>-    Path mask;
</del><ins>+    Path maskPath;
</ins><span class="cx"> 
</span><del>-    mask.moveTo(overbarLeftPoint);
-    mask.addLineTo(bottomPoint);
-    mask.addLineTo(dipLeftPoint);
-    mask.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
</del><ins>+    maskPath.moveTo(overbarLeftPoint);
+    maskPath.addLineTo(bottomPoint);
+    maskPath.addLineTo(dipLeftPoint);
+    maskPath.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
</ins><span class="cx"> 
</span><del>-    info.context().clip(mask);
</del><ins>+    info.context().clipPath(maskPath);
</ins><span class="cx"> 
</span><span class="cx">     // Draw the thick part of the root.
</span><span class="cx">     info.context().setStrokeThickness(gRadicalThickLineThicknessEms * style().fontSize());
</span></span></pre>
</div>
</div>

</body>
</html>