<!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>[174729] 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/174729">174729</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2014-10-15 10:13:41 -0700 (Wed, 15 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use is&lt;&gt;() / downcast&lt;&gt;() for ClipPathOperation subclasses
https://bugs.webkit.org/show_bug.cgi?id=137733

Reviewed by Mihnea Ovidenie.

Use is&lt;&gt;() / downcast&lt;&gt;() for ClipPathOperation subclasses.

No new tests, no behavior change.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyClipPath::applyValue):
* rendering/ClipPathOperation.h:
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::nodeAtPoint):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::setupClipPath):
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::prepareToRenderSVGContent):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSComputedStyleDeclarationcpp">trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp</a></li>
<li><a href="#trunkSourceWebCorecssDeprecatedStyleBuildercpp">trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingClipPathOperationh">trunk/Source/WebCore/rendering/ClipPathOperation.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGRenderingContextcpp">trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (174728 => 174729)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/ChangeLog        2014-10-15 17:13:41 UTC (rev 174729)
</span><span class="lines">@@ -1,5 +1,28 @@
</span><span class="cx"> 2014-10-15  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Use is&lt;&gt;() / downcast&lt;&gt;() for ClipPathOperation subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137733
+
+        Reviewed by Mihnea Ovidenie.
+
+        Use is&lt;&gt;() / downcast&lt;&gt;() for ClipPathOperation subclasses.
+
+        No new tests, no behavior change.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::ApplyPropertyClipPath::applyValue):
+        * rendering/ClipPathOperation.h:
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::nodeAtPoint):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::setupClipPath):
+        * rendering/svg/SVGRenderingContext.cpp:
+        (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
+
+2014-10-15  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         [Mac] Use CFDictionaryContainsKey() in ImageSource::isSizeAvailable()
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=137723
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSComputedStyleDeclarationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (174728 => 174729)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2014-10-15 17:13:41 UTC (rev 174729)
</span><span class="lines">@@ -2852,19 +2852,19 @@
</span><span class="cx">             ClipPathOperation* operation = style-&gt;clipPath();
</span><span class="cx">             if (!operation)
</span><span class="cx">                 return cssValuePool().createIdentifierValue(CSSValueNone);
</span><del>-            if (operation-&gt;type() == ClipPathOperation::Reference) {
-                ReferenceClipPathOperation&amp; referenceOperation = toReferenceClipPathOperation(*operation);
</del><ins>+            if (is&lt;ReferenceClipPathOperation&gt;(*operation)) {
+                const auto&amp; referenceOperation = downcast&lt;ReferenceClipPathOperation&gt;(*operation);
</ins><span class="cx">                 return CSSPrimitiveValue::create(referenceOperation.url(), CSSPrimitiveValue::CSS_URI);
</span><span class="cx">             }
</span><span class="cx">             RefPtr&lt;CSSValueList&gt; list = CSSValueList::createSpaceSeparated();
</span><del>-            if (operation-&gt;type() == ClipPathOperation::Shape) {
-                ShapeClipPathOperation&amp; shapeOperation = toShapeClipPathOperation(*operation);
</del><ins>+            if (is&lt;ShapeClipPathOperation&gt;(*operation)) {
+                const auto&amp; shapeOperation = downcast&lt;ShapeClipPathOperation&gt;(*operation);
</ins><span class="cx">                 list-&gt;append(valueForBasicShape(style.get(), shapeOperation.basicShape()));
</span><span class="cx">                 if (shapeOperation.referenceBox() != BoxMissing)
</span><span class="cx">                     list-&gt;append(cssValuePool().createValue(shapeOperation.referenceBox()));
</span><span class="cx">             }
</span><del>-            if (operation-&gt;type() == ClipPathOperation::Box) {
-                BoxClipPathOperation&amp; boxOperation = toBoxClipPathOperation(*operation);
</del><ins>+            if (is&lt;BoxClipPathOperation&gt;(*operation)) {
+                const auto&amp; boxOperation = downcast&lt;BoxClipPathOperation&gt;(*operation);
</ins><span class="cx">                 list-&gt;append(cssValuePool().createValue(boxOperation.referenceBox()));
</span><span class="cx">             }
</span><span class="cx">             return list.release();
</span></span></pre></div>
<a id="trunkSourceWebCorecssDeprecatedStyleBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (174728 => 174729)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp        2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp        2014-10-15 17:13:41 UTC (rev 174729)
</span><span class="lines">@@ -2163,7 +2163,7 @@
</span><span class="cx">                 return;
</span><span class="cx">             operation = BoxClipPathOperation::create(referenceBox);
</span><span class="cx">         } else
</span><del>-            toShapeClipPathOperation(operation.get())-&gt;setReferenceBox(referenceBox);
</del><ins>+            downcast&lt;ShapeClipPathOperation&gt;(*operation).setReferenceBox(referenceBox);
</ins><span class="cx">         setValue(styleResolver-&gt;style(), operation.release());
</span><span class="cx">     }
</span><span class="cx">     static PropertyHandler createHandler()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingClipPathOperationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/ClipPathOperation.h (174728 => 174729)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/ClipPathOperation.h        2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/rendering/ClipPathOperation.h        2014-10-15 17:13:41 UTC (rev 174729)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;Path.h&quot;
</span><span class="cx"> #include &quot;RenderStyleConstants.h&quot;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><ins>+#include &lt;wtf/TypeCasts.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -166,13 +167,15 @@
</span><span class="cx">     CSSBoxType m_referenceBox;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-#define CLIP_PATH_OPERATION_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, ClipPathOperation, operation, operation-&gt;type() == ClipPathOperation::predicate, operation.type() == ClipPathOperation::predicate)
</del><ins>+} // namespace WebCore
</ins><span class="cx"> 
</span><del>-CLIP_PATH_OPERATION_CASTS(ReferenceClipPathOperation, Reference)
-CLIP_PATH_OPERATION_CASTS(ShapeClipPathOperation, Shape)
-CLIP_PATH_OPERATION_CASTS(BoxClipPathOperation, Box)
</del><ins>+#define SPECIALIZE_TYPE_TRAITS_CLIP_PATH_OPERATION(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+    static bool isType(const WebCore::ClipPathOperation&amp; operation) { return operation.type() == WebCore::predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
</ins><span class="cx"> 
</span><del>-} // namespace WebCore
</del><ins>+SPECIALIZE_TYPE_TRAITS_CLIP_PATH_OPERATION(ReferenceClipPathOperation, ClipPathOperation::Reference)
+SPECIALIZE_TYPE_TRAITS_CLIP_PATH_OPERATION(ShapeClipPathOperation, ClipPathOperation::Shape)
+SPECIALIZE_TYPE_TRAITS_CLIP_PATH_OPERATION(BoxClipPathOperation, ClipPathOperation::Box)
</ins><span class="cx"> 
</span><span class="cx"> #endif // ClipPathOperation_h
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (174728 => 174729)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-10-15 17:13:41 UTC (rev 174729)
</span><span class="lines">@@ -2453,10 +2453,10 @@
</span><span class="cx">     if (style().clipPath()) {
</span><span class="cx">         switch (style().clipPath()-&gt;type()) {
</span><span class="cx">         case ClipPathOperation::Shape: {
</span><del>-            ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style().clipPath());
</del><ins>+            const auto&amp; clipPath = downcast&lt;ShapeClipPathOperation&gt;(*style().clipPath());
</ins><span class="cx"> 
</span><span class="cx">             LayoutRect referenceBoxRect;
</span><del>-            switch (clipPath-&gt;referenceBox()) {
</del><ins>+            switch (clipPath.referenceBox()) {
</ins><span class="cx">             case CSSBoxType::MarginBox:
</span><span class="cx">                 referenceBoxRect = marginBoxRect();
</span><span class="cx">                 break;
</span><span class="lines">@@ -2475,7 +2475,7 @@
</span><span class="cx">             case CSSBoxType::ViewBox:
</span><span class="cx">                 referenceBoxRect = borderBoxRect();
</span><span class="cx">             }
</span><del>-            if (!clipPath-&gt;pathForReferenceRect(referenceBoxRect).contains(locationInContainer.point() - localOffset, clipPath-&gt;windRule()))
</del><ins>+            if (!clipPath.pathForReferenceRect(referenceBoxRect).contains(locationInContainer.point() - localOffset, clipPath.windRule()))
</ins><span class="cx">                 return false;
</span><span class="cx">             break;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (174728 => 174729)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2014-10-15 17:13:41 UTC (rev 174729)
</span><span class="lines">@@ -3925,23 +3925,23 @@
</span><span class="cx"> 
</span><span class="cx">     RenderStyle&amp; style = renderer().style();
</span><span class="cx">     ASSERT(style.clipPath());
</span><del>-    if (style.clipPath()-&gt;type() == ClipPathOperation::Shape) {
-        ShapeClipPathOperation&amp; clippingPath = toShapeClipPathOperation(*(style.clipPath()));
</del><ins>+    if (is&lt;ShapeClipPathOperation&gt;(*style.clipPath())) {
+        const auto&amp; clipPath = downcast&lt;ShapeClipPathOperation&gt;(*style.clipPath());
</ins><span class="cx"> 
</span><del>-        LayoutRect referenceBox = computeReferenceBox(renderer(), clippingPath, offsetFromRoot, rootRelativeBounds);
</del><ins>+        LayoutRect referenceBox = computeReferenceBox(renderer(), clipPath, offsetFromRoot, rootRelativeBounds);
</ins><span class="cx">         context-&gt;save();
</span><del>-        context-&gt;clipPath(clippingPath.pathForReferenceRect(referenceBox), clippingPath.windRule());
</del><ins>+        context-&gt;clipPath(clipPath.pathForReferenceRect(referenceBox), clipPath.windRule());
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (style.clipPath()-&gt;type() == ClipPathOperation::Box &amp;&amp; renderer().isBox()) {
-        BoxClipPathOperation&amp; clippingPath = toBoxClipPathOperation(*(style.clipPath()));
</del><ins>+    if (is&lt;BoxClipPathOperation&gt;(*style.clipPath()) &amp;&amp; is&lt;RenderBox&gt;(renderer())) {
+        const auto&amp; clipPath = downcast&lt;BoxClipPathOperation&gt;(*style.clipPath());
</ins><span class="cx"> 
</span><del>-        RoundedRect shapeRect = computeRoundedRectForBoxShape(clippingPath.referenceBox(), toRenderBox(renderer()));
</del><ins>+        RoundedRect shapeRect = computeRoundedRectForBoxShape(clipPath.referenceBox(), downcast&lt;RenderBox&gt;(renderer()));
</ins><span class="cx">         shapeRect.move(offsetFromRoot);
</span><span class="cx"> 
</span><span class="cx">         context-&gt;save();
</span><del>-        context-&gt;clipPath(clippingPath.pathForReferenceRect(shapeRect), RULE_NONZERO);
</del><ins>+        context-&gt;clipPath(clipPath.pathForReferenceRect(shapeRect), RULE_NONZERO);
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGRenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp (174728 => 174729)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp        2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp        2014-10-15 17:13:41 UTC (rev 174729)
</span><span class="lines">@@ -136,8 +136,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ClipPathOperation* clipPathOperation = style.clipPath();
</span><del>-    if (clipPathOperation &amp;&amp; clipPathOperation-&gt;type() == ClipPathOperation::Shape) {
-        ShapeClipPathOperation&amp; clipPath = toShapeClipPathOperation(*clipPathOperation);
</del><ins>+    if (is&lt;ShapeClipPathOperation&gt;(clipPathOperation)) {
+        const auto&amp; clipPath = downcast&lt;ShapeClipPathOperation&gt;(*clipPathOperation);
</ins><span class="cx">         FloatRect referenceBox;
</span><span class="cx">         if (clipPath.referenceBox() == Stroke)
</span><span class="cx">             // FIXME: strokeBoundingBox() takes dasharray into account but shouldn't.
</span></span></pre>
</div>
</div>

</body>
</html>