<!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>[166741] trunk/Source</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/166741">166741</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2014-04-03 13:57:48 -0700 (Thu, 03 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Harden FilterOperation type casting
https://bugs.webkit.org/show_bug.cgi?id=131142

Reviewed by Sam Weinig.

DefaultFilterOperation had an error-prone behavior where it set the base class
OperationType to the type of some other filter class, but overrode isDefault().
This made it very easy to write incorrect code that casted incorrectly based on type().

Fix by making adding a DEFAULT filter operation type, and storing the represented
type on DefaultFilterOperation().

Also remove the OperationType argument for constructors of FilterOperations that
can only be of one type, to avoid possible mistakes.

Make the type cast macros a bit more normal, and use them in a few places.

Fixed PlatformCAFiltersMac to handle the default filter case more cleanly.

Source/WebCore:

* WebCore.exp.in:
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForFilter):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::createFilterOperations):
* platform/graphics/ca/PlatformCAFilters.h:
* platform/graphics/ca/mac/PlatformCAFiltersMac.mm:
(PlatformCAFilters::filterValueForOperation):
(PlatformCAFilters::colorMatrixValueForFilter):
* platform/graphics/filters/FilterOperation.cpp:
(WebCore::DefaultFilterOperation::operator==):
(WebCore::ReferenceFilterOperation::ReferenceFilterOperation):
(WebCore::ReferenceFilterOperation::operator==):
(WebCore::BlurFilterOperation::operator==):
(WebCore::BlurFilterOperation::blend):
(WebCore::DropShadowFilterOperation::operator==):
(WebCore::DropShadowFilterOperation::blend):
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::blend):
(WebCore::FilterOperation::type):
(WebCore::FilterOperation::isBasicColorMatrixFilterOperation):
(WebCore::FilterOperation::isBasicComponentTransferFilterOperation):
(WebCore::FilterOperation::isSameType):
(WebCore::DefaultFilterOperation::create):
(WebCore::DefaultFilterOperation::representedType):
(WebCore::DefaultFilterOperation::DefaultFilterOperation):
(WebCore::ReferenceFilterOperation::create):
(WebCore::BlurFilterOperation::create):
(WebCore::BlurFilterOperation::BlurFilterOperation):
(WebCore::DropShadowFilterOperation::create):
(WebCore::DropShadowFilterOperation::DropShadowFilterOperation):
(WebCore::FilterOperation::isDefault): Deleted.
* platform/graphics/filters/FilterOperations.cpp:
(WebCore::FilterOperations::outsets):
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::build):
* rendering/RenderLayerFilterInfo.cpp:
(WebCore::RenderLayer::FilterInfo::updateReferenceFilterClients):

Source/WebKit2:

* Shared/WebCoreArgumentCoders.cpp:
(IPC::encodeFilterOperation):
(IPC::decodeFilterOperation):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTextStream::operator&lt;&lt;):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorecssCSSComputedStyleDeclarationcpp">trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaPlatformCAFiltersh">trunk/Source/WebCore/platform/graphics/ca/PlatformCAFilters.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacPlatformCAFiltersMacmm">trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterOperationcpp">trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterOperationh">trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterOperationscpp">trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingFilterEffectRenderercpp">trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerFilterInfocpp">trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebCoreArgumentCoderscpp">trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm">trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/ChangeLog        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -1,3 +1,63 @@
</span><ins>+2014-04-02  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Harden FilterOperation type casting
+        https://bugs.webkit.org/show_bug.cgi?id=131142
+
+        Reviewed by Sam Weinig.
+
+        DefaultFilterOperation had an error-prone behavior where it set the base class
+        OperationType to the type of some other filter class, but overrode isDefault(). 
+        This made it very easy to write incorrect code that casted incorrectly based on type().
+        
+        Fix by making adding a DEFAULT filter operation type, and storing the represented
+        type on DefaultFilterOperation().
+        
+        Also remove the OperationType argument for constructors of FilterOperations that
+        can only be of one type, to avoid possible mistakes.
+        
+        Make the type cast macros a bit more normal, and use them in a few places.
+        
+        Fixed PlatformCAFiltersMac to handle the default filter case more cleanly.
+
+        * WebCore.exp.in:
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::valueForFilter):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::createFilterOperations):
+        * platform/graphics/ca/PlatformCAFilters.h:
+        * platform/graphics/ca/mac/PlatformCAFiltersMac.mm:
+        (PlatformCAFilters::filterValueForOperation):
+        (PlatformCAFilters::colorMatrixValueForFilter):
+        * platform/graphics/filters/FilterOperation.cpp:
+        (WebCore::DefaultFilterOperation::operator==):
+        (WebCore::ReferenceFilterOperation::ReferenceFilterOperation):
+        (WebCore::ReferenceFilterOperation::operator==):
+        (WebCore::BlurFilterOperation::operator==):
+        (WebCore::BlurFilterOperation::blend):
+        (WebCore::DropShadowFilterOperation::operator==):
+        (WebCore::DropShadowFilterOperation::blend):
+        * platform/graphics/filters/FilterOperation.h:
+        (WebCore::FilterOperation::blend):
+        (WebCore::FilterOperation::type):
+        (WebCore::FilterOperation::isBasicColorMatrixFilterOperation):
+        (WebCore::FilterOperation::isBasicComponentTransferFilterOperation):
+        (WebCore::FilterOperation::isSameType):
+        (WebCore::DefaultFilterOperation::create):
+        (WebCore::DefaultFilterOperation::representedType):
+        (WebCore::DefaultFilterOperation::DefaultFilterOperation):
+        (WebCore::ReferenceFilterOperation::create):
+        (WebCore::BlurFilterOperation::create):
+        (WebCore::BlurFilterOperation::BlurFilterOperation):
+        (WebCore::DropShadowFilterOperation::create):
+        (WebCore::DropShadowFilterOperation::DropShadowFilterOperation):
+        (WebCore::FilterOperation::isDefault): Deleted.
+        * platform/graphics/filters/FilterOperations.cpp:
+        (WebCore::FilterOperations::outsets):
+        * rendering/FilterEffectRenderer.cpp:
+        (WebCore::FilterEffectRenderer::build):
+        * rendering/RenderLayerFilterInfo.cpp:
+        (WebCore::RenderLayer::FilterInfo::updateReferenceFilterClients):
+
</ins><span class="cx"> 2014-04-03  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Stop throwing away the Document's StyleResolver on a timer.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -953,7 +953,7 @@
</span><span class="cx"> __ZN7WebCore24FrameDestructionObserverC2EPNS_5FrameE
</span><span class="cx"> __ZN7WebCore24FrameDestructionObserverD2Ev
</span><span class="cx"> __ZN7WebCore24ImmutableStylePropertiesD1Ev
</span><del>-__ZN7WebCore24ReferenceFilterOperationC1ERKN3WTF6StringES4_NS_15FilterOperation13OperationTypeE
</del><ins>+__ZN7WebCore24ReferenceFilterOperationC1ERKN3WTF6StringES4_
</ins><span class="cx"> __ZN7WebCore24createFragmentFromMarkupERNS_8DocumentERKN3WTF6StringES5_NS_19ParserContentPolicyE
</span><span class="cx"> __ZN7WebCore24decodeURLEscapeSequencesERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore24deleteCookiesForHostnameERKNS_21NetworkStorageSessionERKN3WTF6StringE
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSComputedStyleDeclarationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -878,67 +878,67 @@
</span><span class="cx">         FilterOperation* filterOperation = (*it).get();
</span><span class="cx">         switch (filterOperation-&gt;type()) {
</span><span class="cx">         case FilterOperation::REFERENCE: {
</span><del>-            ReferenceFilterOperation* referenceOperation = static_cast&lt;ReferenceFilterOperation*&gt;(filterOperation);
</del><ins>+            ReferenceFilterOperation* referenceOperation = toReferenceFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(referenceOperation-&gt;url(), CSSPrimitiveValue::CSS_URI));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::GRAYSCALE: {
</span><del>-            BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast&lt;BasicColorMatrixFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicColorMatrixFilterOperation* colorMatrixOperation = toBasicColorMatrixFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::GrayscaleFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(colorMatrixOperation-&gt;amount(), CSSPrimitiveValue::CSS_NUMBER));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::SEPIA: {
</span><del>-            BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast&lt;BasicColorMatrixFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicColorMatrixFilterOperation* colorMatrixOperation = toBasicColorMatrixFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SepiaFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(colorMatrixOperation-&gt;amount(), CSSPrimitiveValue::CSS_NUMBER));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::SATURATE: {
</span><del>-            BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast&lt;BasicColorMatrixFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicColorMatrixFilterOperation* colorMatrixOperation = toBasicColorMatrixFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SaturateFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(colorMatrixOperation-&gt;amount(), CSSPrimitiveValue::CSS_NUMBER));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::HUE_ROTATE: {
</span><del>-            BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast&lt;BasicColorMatrixFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicColorMatrixFilterOperation* colorMatrixOperation = toBasicColorMatrixFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::HueRotateFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(colorMatrixOperation-&gt;amount(), CSSPrimitiveValue::CSS_DEG));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::INVERT: {
</span><del>-            BasicComponentTransferFilterOperation* componentTransferOperation = static_cast&lt;BasicComponentTransferFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicComponentTransferFilterOperation* componentTransferOperation = toBasicComponentTransferFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::InvertFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(componentTransferOperation-&gt;amount(), CSSPrimitiveValue::CSS_NUMBER));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::OPACITY: {
</span><del>-            BasicComponentTransferFilterOperation* componentTransferOperation = static_cast&lt;BasicComponentTransferFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicComponentTransferFilterOperation* componentTransferOperation = toBasicComponentTransferFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::OpacityFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(componentTransferOperation-&gt;amount(), CSSPrimitiveValue::CSS_NUMBER));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::BRIGHTNESS: {
</span><del>-            BasicComponentTransferFilterOperation* brightnessOperation = static_cast&lt;BasicComponentTransferFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicComponentTransferFilterOperation* brightnessOperation = toBasicComponentTransferFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BrightnessFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(brightnessOperation-&gt;amount(), CSSPrimitiveValue::CSS_NUMBER));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::CONTRAST: {
</span><del>-            BasicComponentTransferFilterOperation* contrastOperation = static_cast&lt;BasicComponentTransferFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicComponentTransferFilterOperation* contrastOperation = toBasicComponentTransferFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ContrastFilterOperation);
</span><span class="cx">             filterValue-&gt;append(cssValuePool().createValue(contrastOperation-&gt;amount(), CSSPrimitiveValue::CSS_NUMBER));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::BLUR: {
</span><del>-            BlurFilterOperation* blurOperation = static_cast&lt;BlurFilterOperation*&gt;(filterOperation);
</del><ins>+            BlurFilterOperation* blurOperation = toBlurFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BlurFilterOperation);
</span><span class="cx">             filterValue-&gt;append(adjustLengthForZoom(blurOperation-&gt;stdDeviation(), style, adjust));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::DROP_SHADOW: {
</span><del>-            DropShadowFilterOperation* dropShadowOperation = static_cast&lt;DropShadowFilterOperation*&gt;(filterOperation);
</del><ins>+            DropShadowFilterOperation* dropShadowOperation = toDropShadowFilterOperation(filterOperation);
</ins><span class="cx">             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
</span><span class="cx">             // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
</span><span class="cx">             ShadowData shadowData = ShadowData(dropShadowOperation-&gt;location(), dropShadowOperation-&gt;stdDeviation(), 0, Normal, false, dropShadowOperation-&gt;color());
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -3350,7 +3350,7 @@
</span><span class="cx">             String cssUrl = primitiveValue.getStringValue();
</span><span class="cx">             URL url = m_state.document().completeURL(cssUrl);
</span><span class="cx"> 
</span><del>-            RefPtr&lt;ReferenceFilterOperation&gt; operation = ReferenceFilterOperation::create(cssUrl, url.fragmentIdentifier(), operationType);
</del><ins>+            RefPtr&lt;ReferenceFilterOperation&gt; operation = ReferenceFilterOperation::create(cssUrl, url.fragmentIdentifier());
</ins><span class="cx">             if (SVGURIReference::isExternalURIReference(cssUrl, m_state.document()))
</span><span class="cx">                 state.filtersWithPendingSVGDocuments().append(operation);
</span><span class="cx"> 
</span><span class="lines">@@ -3418,7 +3418,7 @@
</span><span class="cx">             if (stdDeviation.isUndefined())
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-            operations.operations().append(BlurFilterOperation::create(stdDeviation, operationType));
</del><ins>+            operations.operations().append(BlurFilterOperation::create(stdDeviation));
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case WebKitCSSFilterValue::DropShadowFilterOperation: {
</span><span class="lines">@@ -3444,7 +3444,7 @@
</span><span class="cx">             if (item-&gt;color)
</span><span class="cx">                 color = colorFromPrimitiveValue(item-&gt;color.get());
</span><span class="cx"> 
</span><del>-            operations.operations().append(DropShadowFilterOperation::create(location, blur, color.isValid() ? color : Color::transparent, operationType));
</del><ins>+            operations.operations().append(DropShadowFilterOperation::create(location, blur, color.isValid() ? color : Color::transparent));
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case WebKitCSSFilterValue::UnknownFilterOperation:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaPlatformCAFiltersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCAFilters.h (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/PlatformCAFilters.h        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCAFilters.h        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -57,7 +57,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #ifdef USE_CA_FILTERS
</span><del>-    static RetainPtr&lt;NSValue&gt; colorMatrixValueForFilter(const FilterOperation&amp;);
</del><ins>+    // A null operation indicates that we should make a &quot;no-op&quot; filter of the given type.
+    static RetainPtr&lt;NSValue&gt; colorMatrixValueForFilter(FilterOperation::OperationType, const FilterOperation*);
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacPlatformCAFiltersMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -76,6 +76,9 @@
</span><span class="cx">         String filterName = String::format(&quot;filter_%d&quot;, i);
</span><span class="cx">         const FilterOperation* filterOperation = filters.at(i);
</span><span class="cx">         switch (filterOperation-&gt;type()) {
</span><ins>+        case FilterOperation::DEFAULT:
+            ASSERT_NOT_REACHED();
+            break;
</ins><span class="cx">         case FilterOperation::DROP_SHADOW: {
</span><span class="cx">             // FIXME: For now assume drop shadow is the last filter, put it on the layer.
</span><span class="cx">             // &lt;rdar://problem/10959969&gt; Handle case where drop-shadow is not the last filter.
</span><span class="lines">@@ -101,7 +104,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::SEPIA: {
</span><del>-            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*filterOperation);
</del><ins>+            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(filterOperation-&gt;type(), filterOperation);
</ins><span class="cx">             CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
</span><span class="cx">             [filter setValue:colorMatrixValue.get() forKey:@&quot;inputColorMatrix&quot;];
</span><span class="cx">             [filter setName:filterName];
</span><span class="lines">@@ -126,7 +129,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::INVERT: {
</span><del>-            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*filterOperation);
</del><ins>+            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(filterOperation-&gt;type(), filterOperation);
</ins><span class="cx">             CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
</span><span class="cx">             [filter setValue:colorMatrixValue.get() forKey:@&quot;inputColorMatrix&quot;];
</span><span class="cx">             [filter setName:filterName];
</span><span class="lines">@@ -134,7 +137,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::OPACITY: {
</span><del>-            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*filterOperation);
</del><ins>+            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(filterOperation-&gt;type(), filterOperation);
</ins><span class="cx">             CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
</span><span class="cx">             [filter setValue:colorMatrixValue.get() forKey:@&quot;inputColorMatrix&quot;];
</span><span class="cx">             [filter setName:filterName];
</span><span class="lines">@@ -142,7 +145,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::BRIGHTNESS: {
</span><del>-            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*filterOperation);
</del><ins>+            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(filterOperation-&gt;type(), filterOperation);
</ins><span class="cx">             CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
</span><span class="cx">             [filter setValue:colorMatrixValue.get() forKey:@&quot;inputColorMatrix&quot;];
</span><span class="cx">             [filter setName:filterName];
</span><span class="lines">@@ -150,7 +153,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::CONTRAST: {
</span><del>-            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*filterOperation);
</del><ins>+            RetainPtr&lt;NSValue&gt; colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(filterOperation-&gt;type(), filterOperation);
</ins><span class="cx">             CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
</span><span class="cx">             [filter setValue:colorMatrixValue.get() forKey:@&quot;inputColorMatrix&quot;];
</span><span class="cx">             [filter setName:filterName];
</span><span class="lines">@@ -302,26 +305,33 @@
</span><span class="cx">     FilterOperation::OperationType type = operation-&gt;type();
</span><span class="cx">     RetainPtr&lt;id&gt; value;
</span><span class="cx">     
</span><ins>+    if (type == FilterOperation::DEFAULT) {
+        type = toDefaultFilterOperation(operation)-&gt;representedType();
+        operation = nullptr;
+    }
+    
</ins><span class="cx">     switch (type) {
</span><ins>+    case FilterOperation::DEFAULT:
+        ASSERT_NOT_REACHED();
+        break;
</ins><span class="cx">     case FilterOperation::GRAYSCALE: {
</span><span class="cx">         // CIFilter: inputIntensity
</span><span class="cx">         // CAFilter: inputAmount
</span><span class="cx">         double amount = 0;
</span><del>-        if (!operation-&gt;isDefault()) {
-            const BasicColorMatrixFilterOperation* op = toBasicColorMatrixFilterOperation(operation);
-            amount = op-&gt;amount();
-        }
</del><ins>+        if (operation)
+            amount = toBasicColorMatrixFilterOperation(operation)-&gt;amount();
+        
</ins><span class="cx">         value = [NSNumber numberWithDouble:amount];
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case FilterOperation::SEPIA: {
</span><span class="cx"> #if USE_CA_FILTERS
</span><span class="cx">         // CAFilter: inputColorMatrix
</span><del>-        value = PlatformCAFilters::colorMatrixValueForFilter(*operation);
</del><ins>+        value = PlatformCAFilters::colorMatrixValueForFilter(type, operation);
</ins><span class="cx"> #else
</span><span class="cx">         // CIFilter: inputRVector, inputGVector, inputBVector
</span><span class="cx">         double amount = 0;
</span><del>-        if (!operation-&gt;isDefault()) {
</del><ins>+        if (operation) {
</ins><span class="cx">             const BasicColorMatrixFilterOperation* op = toBasicColorMatrixFilterOperation(operation);
</span><span class="cx">             amount = op-&gt;amount();
</span><span class="cx">         }
</span><span class="lines">@@ -346,10 +356,8 @@
</span><span class="cx">         // CIFilter: inputSaturation
</span><span class="cx">         // CAFilter: inputAmount
</span><span class="cx">         double amount = 1;
</span><del>-        if (!operation-&gt;isDefault()) {
-            const BasicColorMatrixFilterOperation* op = toBasicColorMatrixFilterOperation(operation);
-            amount = op-&gt;amount();
-        }
</del><ins>+        if (operation)
+            amount = toBasicColorMatrixFilterOperation(operation)-&gt;amount();
</ins><span class="cx">         
</span><span class="cx">         value = [NSNumber numberWithDouble:amount];
</span><span class="cx">         break;
</span><span class="lines">@@ -358,10 +366,9 @@
</span><span class="cx">         // Hue rotate CIFilter: inputAngle
</span><span class="cx">         // Hue rotate CAFilter: inputAngle
</span><span class="cx">         double amount = 0;
</span><del>-        if (!operation-&gt;isDefault()) {
-            const BasicColorMatrixFilterOperation* op = toBasicColorMatrixFilterOperation(operation);
-            amount = op-&gt;amount();
-        }
</del><ins>+        if (operation)
+            amount = toBasicColorMatrixFilterOperation(operation)-&gt;amount();
+        
</ins><span class="cx">         amount = deg2rad(amount);
</span><span class="cx">         value = [NSNumber numberWithDouble:amount];
</span><span class="cx">         break;
</span><span class="lines">@@ -369,15 +376,13 @@
</span><span class="cx">     case FilterOperation::INVERT: {
</span><span class="cx"> #if USE_CA_FILTERS
</span><span class="cx">         // CAFilter: inputColorMatrix
</span><del>-        value = PlatformCAFilters::colorMatrixValueForFilter(*operation);
</del><ins>+        value = PlatformCAFilters::colorMatrixValueForFilter(type, operation);
</ins><span class="cx"> #else
</span><span class="cx">         // CIFilter: inputRVector, inputGVector, inputBVector, inputBiasVector
</span><span class="cx">         double amount = 0;
</span><del>-        if (!operation-&gt;isDefault()) {
-            const BasicComponentTransferFilterOperation* op = toBasicComponentTransferFilterOperation(operation);
-            amount = op-&gt;amount();
-        }
-
</del><ins>+        if (operation)
+            amount = toBasicComponentTransferFilterOperation(operation)-&gt;amount();
+        
</ins><span class="cx">         double multiplier = 1 - amount * 2;
</span><span class="cx"> 
</span><span class="cx">         // The color matrix animation for invert does a scale of each color component by a value that goes from 
</span><span class="lines">@@ -397,14 +402,12 @@
</span><span class="cx">     case FilterOperation::OPACITY: {
</span><span class="cx"> #if USE_CA_FILTERS
</span><span class="cx">         // Opacity CAFilter: inputColorMatrix
</span><del>-        value = PlatformCAFilters::colorMatrixValueForFilter(*operation);
</del><ins>+        value = PlatformCAFilters::colorMatrixValueForFilter(type, operation);
</ins><span class="cx"> #else
</span><span class="cx">         // Opacity CIFilter: inputAVector
</span><span class="cx">         double amount = 1;
</span><del>-        if (!operation-&gt;isDefault()) {
-            const BasicComponentTransferFilterOperation* op = toBasicComponentTransferFilterOperation(operation);
-            amount = op-&gt;amount();
-        }
</del><ins>+        if (operation)
+            amount = toBasicComponentTransferFilterOperation(operation)-&gt;amount();
</ins><span class="cx">         
</span><span class="cx">         value = adoptNS([[CIVector alloc] initWithX:0 Y:0 Z:0 W:amount]);
</span><span class="cx"> #endif
</span><span class="lines">@@ -414,14 +417,12 @@
</span><span class="cx">     case FilterOperation::BRIGHTNESS: {
</span><span class="cx"> #if USE_CA_FILTERS
</span><span class="cx">         // Brightness CAFilter: inputColorMatrix
</span><del>-        value = PlatformCAFilters::colorMatrixValueForFilter(*operation);
</del><ins>+        value = PlatformCAFilters::colorMatrixValueForFilter(type, operation);
</ins><span class="cx"> #else
</span><span class="cx">         // Brightness CIFilter: inputColorMatrix
</span><span class="cx">         double amount = 1;
</span><del>-        if (!operation-&gt;isDefault()) {
-            const BasicComponentTransferFilterOperation* op = toBasicComponentTransferFilterOperation(operation);
-            amount = op-&gt;amount();
-        }
</del><ins>+        if (operation)
+            amount = toBasicComponentTransferFilterOperation(operation)-&gt;amount();
</ins><span class="cx">         
</span><span class="cx">         CIVector* rowVector = 0;
</span><span class="cx">         switch (internalFilterPropertyIndex) {
</span><span class="lines">@@ -437,15 +438,13 @@
</span><span class="cx">     case FilterOperation::CONTRAST: {
</span><span class="cx"> #if USE_CA_FILTERS
</span><span class="cx">         // Contrast CAFilter: inputColorMatrix
</span><del>-        value = PlatformCAFilters::colorMatrixValueForFilter(*operation);
</del><ins>+        value = PlatformCAFilters::colorMatrixValueForFilter(type, operation);
</ins><span class="cx"> #else
</span><span class="cx">         // Contrast CIFilter: inputContrast
</span><span class="cx">         double amount = 1;
</span><del>-        if (!operation-&gt;isDefault()) {
-            const BasicComponentTransferFilterOperation* op = toBasicComponentTransferFilterOperation(operation);
-            amount = op-&gt;amount();
-        }
-
</del><ins>+        if (operation)
+            amount = toBasicComponentTransferFilterOperation(operation)-&gt;amount();
+        
</ins><span class="cx">         value = [NSNumber numberWithDouble:amount];
</span><span class="cx"> #endif
</span><span class="cx">         break;
</span><span class="lines">@@ -454,11 +453,8 @@
</span><span class="cx">         // CIFilter: inputRadius
</span><span class="cx">         // CAFilter: inputRadius
</span><span class="cx">         double amount = 0;
</span><del>-
-        if (!operation-&gt;isDefault()) {
-            const BlurFilterOperation* op = toBlurFilterOperation(operation);
-            amount = floatValueForLength(op-&gt;stdDeviation(), 0);
-        }
</del><ins>+        if (operation)
+            amount = floatValueForLength(toBlurFilterOperation(operation)-&gt;stdDeviation(), 0);
</ins><span class="cx">         
</span><span class="cx">         value = [NSNumber numberWithDouble:amount];
</span><span class="cx">         break;
</span><span class="lines">@@ -471,12 +467,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE_CA_FILTERS
</span><del>-RetainPtr&lt;NSValue&gt; PlatformCAFilters::colorMatrixValueForFilter(const FilterOperation&amp; filterOperation)
</del><ins>+RetainPtr&lt;NSValue&gt; PlatformCAFilters::colorMatrixValueForFilter(FilterOperation::OperationType type, const FilterOperation* filterOperation)
</ins><span class="cx"> {
</span><del>-    switch (filterOperation.type()) {
</del><ins>+    switch (type) {
</ins><span class="cx">     case FilterOperation::SEPIA: {
</span><del>-        const BasicColorMatrixFilterOperation&amp; op = toBasicColorMatrixFilterOperation(filterOperation);
-        double t = op.amount();
</del><ins>+        double t = filterOperation ? toBasicColorMatrixFilterOperation(filterOperation)-&gt;amount() : 0;
</ins><span class="cx">         t = std::min(std::max(0.0, t), 1.0);
</span><span class="cx">         CAColorMatrix colorMatrix = {
</span><span class="cx">             static_cast&lt;float&gt;(WebCore::blend(sepiaNoneConstants[0][0], sepiaFullConstants[0][0], t)),
</span><span class="lines">@@ -495,11 +490,7 @@
</span><span class="cx">         return [NSValue valueWithCAColorMatrix:colorMatrix];
</span><span class="cx">     }
</span><span class="cx">     case FilterOperation::INVERT: {
</span><del>-        const BasicComponentTransferFilterOperation&amp; op = toBasicComponentTransferFilterOperation(filterOperation);
-        float amount = op.amount();
-        if (op.isDefault())
-            amount = 0;
-
</del><ins>+        float amount = filterOperation ? toBasicComponentTransferFilterOperation(filterOperation)-&gt;amount() : 0;
</ins><span class="cx">         float multiplier = 1 - amount * 2;
</span><span class="cx">         CAColorMatrix colorMatrix = {
</span><span class="cx">             multiplier, 0, 0, 0, amount,
</span><span class="lines">@@ -510,11 +501,7 @@
</span><span class="cx">         return [NSValue valueWithCAColorMatrix:colorMatrix];
</span><span class="cx">     }
</span><span class="cx">     case FilterOperation::OPACITY: {
</span><del>-        const BasicComponentTransferFilterOperation&amp; op = toBasicComponentTransferFilterOperation(filterOperation);
-        float amount = op.amount();
-        if (op.isDefault())
-            amount = 1;
-
</del><ins>+        float amount = filterOperation ? toBasicComponentTransferFilterOperation(filterOperation)-&gt;amount() : 1;
</ins><span class="cx">         CAColorMatrix colorMatrix = {
</span><span class="cx">             1, 0, 0, 0, 0,
</span><span class="cx">             0, 1, 0, 0, 0,
</span><span class="lines">@@ -524,11 +511,7 @@
</span><span class="cx">         return [NSValue valueWithCAColorMatrix:colorMatrix];
</span><span class="cx">     }
</span><span class="cx">     case FilterOperation::CONTRAST: {
</span><del>-        const BasicComponentTransferFilterOperation&amp; op = toBasicComponentTransferFilterOperation(filterOperation);
-        float amount = op.amount();
-        if (op.isDefault())
-            amount = 1;
-
</del><ins>+        float amount = filterOperation ? toBasicComponentTransferFilterOperation(filterOperation)-&gt;amount() : 1;
</ins><span class="cx">         float intercept = -0.5 * amount + 0.5;
</span><span class="cx">         CAColorMatrix colorMatrix = {
</span><span class="cx">             amount, 0, 0, 0, intercept,
</span><span class="lines">@@ -539,11 +522,7 @@
</span><span class="cx">         return [NSValue valueWithCAColorMatrix:colorMatrix];
</span><span class="cx">     }
</span><span class="cx">     case FilterOperation::BRIGHTNESS: {
</span><del>-        const BasicComponentTransferFilterOperation&amp; op = toBasicComponentTransferFilterOperation(filterOperation);
-        float amount = op.amount();
-        if (op.isDefault())
-            amount = 1;
-
</del><ins>+        float amount = filterOperation ? toBasicComponentTransferFilterOperation(filterOperation)-&gt;amount() : 1;
</ins><span class="cx">         CAColorMatrix colorMatrix = {
</span><span class="cx">             amount, 0, 0, 0, 0,
</span><span class="cx">             0, amount, 0, 0, 0,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterOperationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -32,9 +32,17 @@
</span><span class="cx"> #include &quot;CachedSVGDocumentReference.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+    
+bool DefaultFilterOperation::operator==(const FilterOperation&amp; o) const
+{
+    if (!isSameType(o))
+        return false;
+    
+    return representedType() == toDefaultFilterOperation(o).representedType();
+}
</ins><span class="cx"> 
</span><del>-ReferenceFilterOperation::ReferenceFilterOperation(const String&amp; url, const String&amp; fragment, OperationType type)
-    : FilterOperation(type)
</del><ins>+ReferenceFilterOperation::ReferenceFilterOperation(const String&amp; url, const String&amp; fragment)
+    : FilterOperation(REFERENCE)
</ins><span class="cx">     , m_url(url)
</span><span class="cx">     , m_fragment(fragment)
</span><span class="cx"> {
</span><span class="lines">@@ -43,7 +51,15 @@
</span><span class="cx"> ReferenceFilterOperation::~ReferenceFilterOperation()
</span><span class="cx"> {
</span><span class="cx"> }
</span><del>-
</del><ins>+    
+bool ReferenceFilterOperation::operator==(const FilterOperation&amp; o) const
+{
+    if (!isSameType(o))
+        return false;
+    
+    return m_url == toReferenceFilterOperation(o).m_url;
+}
+    
</ins><span class="cx"> CachedSVGDocumentReference* ReferenceFilterOperation::getOrCreateCachedSVGDocumentReference()
</span><span class="cx"> {
</span><span class="cx">     if (!m_cachedSVGDocumentReference)
</span><span class="lines">@@ -124,7 +140,15 @@
</span><span class="cx">         return 0;
</span><span class="cx">     }
</span><span class="cx"> }
</span><del>-
</del><ins>+    
+bool BlurFilterOperation::operator==(const FilterOperation&amp; o) const
+{
+    if (!isSameType(o))
+        return false;
+    
+    return m_stdDeviation == toBlurFilterOperation(o).stdDeviation();
+}
+    
</ins><span class="cx"> PassRefPtr&lt;FilterOperation&gt; BlurFilterOperation::blend(const FilterOperation* from, double progress, bool blendToPassthrough)
</span><span class="cx"> {
</span><span class="cx">     if (from &amp;&amp; !from-&gt;isSameType(*this))
</span><span class="lines">@@ -133,13 +157,21 @@
</span><span class="cx">     LengthType lengthType = m_stdDeviation.type();
</span><span class="cx"> 
</span><span class="cx">     if (blendToPassthrough)
</span><del>-        return BlurFilterOperation::create(Length(lengthType).blend(m_stdDeviation, progress), m_type);
</del><ins>+        return BlurFilterOperation::create(Length(lengthType).blend(m_stdDeviation, progress));
</ins><span class="cx"> 
</span><del>-    const BlurFilterOperation* fromOp = static_cast&lt;const BlurFilterOperation*&gt;(from);
</del><ins>+    const BlurFilterOperation* fromOp = toBlurFilterOperation(from);
</ins><span class="cx">     Length fromLength = fromOp ? fromOp-&gt;m_stdDeviation : Length(lengthType);
</span><del>-    return BlurFilterOperation::create(m_stdDeviation.blend(fromLength, progress), m_type);
</del><ins>+    return BlurFilterOperation::create(m_stdDeviation.blend(fromLength, progress));
</ins><span class="cx"> }
</span><del>-
</del><ins>+    
+bool DropShadowFilterOperation::operator==(const FilterOperation&amp; o) const
+{
+    if (!isSameType(o))
+        return false;
+    const DropShadowFilterOperation&amp; other = toDropShadowFilterOperation(o);
+    return m_location == other.m_location &amp;&amp; m_stdDeviation == other.m_stdDeviation &amp;&amp; m_color == other.m_color;
+}
+    
</ins><span class="cx"> PassRefPtr&lt;FilterOperation&gt; DropShadowFilterOperation::blend(const FilterOperation* from, double progress, bool blendToPassthrough)
</span><span class="cx"> {
</span><span class="cx">     if (from &amp;&amp; !from-&gt;isSameType(*this))
</span><span class="lines">@@ -149,10 +181,9 @@
</span><span class="cx">         return DropShadowFilterOperation::create(
</span><span class="cx">             WebCore::blend(m_location, IntPoint(), progress),
</span><span class="cx">             WebCore::blend(m_stdDeviation, 0, progress),
</span><del>-            WebCore::blend(m_color, Color(Color::transparent), progress),
-            m_type);
</del><ins>+            WebCore::blend(m_color, Color(Color::transparent), progress));
</ins><span class="cx"> 
</span><del>-    const DropShadowFilterOperation* fromOp = static_cast&lt;const DropShadowFilterOperation*&gt;(from);
</del><ins>+    const DropShadowFilterOperation* fromOp = toDropShadowFilterOperation(from);
</ins><span class="cx">     IntPoint fromLocation = fromOp ? fromOp-&gt;location() : IntPoint();
</span><span class="cx">     int fromStdDeviation = fromOp ? fromOp-&gt;stdDeviation() : 0;
</span><span class="cx">     Color fromColor = fromOp ? fromOp-&gt;color() : Color(Color::transparent);
</span><span class="lines">@@ -160,7 +191,7 @@
</span><span class="cx">     return DropShadowFilterOperation::create(
</span><span class="cx">         WebCore::blend(fromLocation, m_location, progress),
</span><span class="cx">         WebCore::blend(fromStdDeviation, m_stdDeviation, progress),
</span><del>-        WebCore::blend(fromColor, m_color, progress), m_type);
</del><ins>+        WebCore::blend(fromColor, m_color, progress));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterOperationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx">  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
</span><span class="cx">  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
</span><span class="cx">  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><del>- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
</del><ins>+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #ifndef FilterOperation_h
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">         BLUR,
</span><span class="cx">         DROP_SHADOW,
</span><span class="cx">         PASSTHROUGH,
</span><ins>+        DEFAULT,
</ins><span class="cx">         NONE
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -72,22 +73,31 @@
</span><span class="cx">     bool operator!=(const FilterOperation&amp; o) const { return !(*this == o); }
</span><span class="cx"> 
</span><span class="cx">     virtual PassRefPtr&lt;FilterOperation&gt; blend(const FilterOperation* /*from*/, double /*progress*/, bool /*blendToPassthrough*/ = false)
</span><del>-    { 
</del><ins>+    {
</ins><span class="cx">         ASSERT(!blendingNeedsRendererSize());
</span><del>-        return 0; 
</del><ins>+        return 0;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     virtual PassRefPtr&lt;FilterOperation&gt; blend(const FilterOperation* /*from*/, double /*progress*/, const LayoutSize&amp;, bool /*blendToPassthrough*/ = false)
</span><del>-    { 
</del><ins>+    {
</ins><span class="cx">         ASSERT(blendingNeedsRendererSize());
</span><del>-        return 0; 
</del><ins>+        return 0;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual OperationType type() const { return m_type; }
-    virtual bool isSameType(const FilterOperation&amp; o) const { return o.type() == m_type; }
-    
-    virtual bool isDefault() const { return false; }
</del><ins>+    OperationType type() const { return m_type; }
</ins><span class="cx"> 
</span><ins>+    bool isBasicColorMatrixFilterOperation() const
+    {
+        return m_type == GRAYSCALE || m_type == SEPIA || m_type == SATURATE || m_type == HUE_ROTATE;
+    }
+
+    bool isBasicComponentTransferFilterOperation() const
+    {
+        return m_type == INVERT || m_type == BRIGHTNESS || m_type == CONTRAST || m_type == OPACITY;
+    }
+
+    bool isSameType(const FilterOperation&amp; o) const { return o.type() == m_type; }
+
</ins><span class="cx">     // True if the alpha channel of any pixel can change under this operation.
</span><span class="cx">     virtual bool affectsOpacity() const { return false; }
</span><span class="cx">     // True if the the value of one pixel can affect the value of another pixel under this operation, such as blur.
</span><span class="lines">@@ -104,27 +114,33 @@
</span><span class="cx">     OperationType m_type;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+#define FILTEROPERATION_TYPE_CASTS(ToValueTypeName, predicate) \
+    TYPE_CASTS_BASE(ToValueTypeName, WebCore::FilterOperation, value, value-&gt;predicate, value.predicate)
+
</ins><span class="cx"> class DefaultFilterOperation : public FilterOperation {
</span><span class="cx"> public:
</span><del>-    static PassRefPtr&lt;DefaultFilterOperation&gt; create(OperationType type)
</del><ins>+    static PassRefPtr&lt;DefaultFilterOperation&gt; create(OperationType representedType)
</ins><span class="cx">     {
</span><del>-        return adoptRef(new DefaultFilterOperation(type));
</del><ins>+        return adoptRef(new DefaultFilterOperation(representedType));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    OperationType representedType() const { return m_representedType; }
+
</ins><span class="cx"> private:
</span><del>-    virtual bool operator==(const FilterOperation&amp; o) const override
</del><ins>+    virtual bool operator==(const FilterOperation&amp;) const override;
+
+    DefaultFilterOperation(OperationType representedType)
+        : FilterOperation(DEFAULT)
+        , m_representedType(representedType)
</ins><span class="cx">     {
</span><del>-        return isSameType(o);
</del><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual bool isDefault() const override { return true; }
-
-    DefaultFilterOperation(OperationType type)
-        : FilterOperation(type)
-    {
-    }
</del><ins>+    OperationType m_representedType;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+FILTEROPERATION_TYPE_CASTS(DefaultFilterOperation, type() == FilterOperation::DEFAULT);
+
+
</ins><span class="cx"> class PassthroughFilterOperation : public FilterOperation {
</span><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;PassthroughFilterOperation&gt; create()
</span><span class="lines">@@ -144,11 +160,13 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+FILTEROPERATION_TYPE_CASTS(PassthroughFilterOperation, type() == FilterOperation::PASSTHROUGH);
+
</ins><span class="cx"> class ReferenceFilterOperation : public FilterOperation {
</span><span class="cx"> public:
</span><del>-    static PassRefPtr&lt;ReferenceFilterOperation&gt; create(const String&amp; url, const String&amp; fragment, OperationType type)
</del><ins>+    static PassRefPtr&lt;ReferenceFilterOperation&gt; create(const String&amp; url, const String&amp; fragment)
</ins><span class="cx">     {
</span><del>-        return adoptRef(new ReferenceFilterOperation(url, fragment, type));
</del><ins>+        return adoptRef(new ReferenceFilterOperation(url, fragment));
</ins><span class="cx">     }
</span><span class="cx">     virtual ~ReferenceFilterOperation();
</span><span class="cx"> 
</span><span class="lines">@@ -165,15 +183,9 @@
</span><span class="cx">     void setFilterEffect(PassRefPtr&lt;FilterEffect&gt; filterEffect) { m_filterEffect = filterEffect; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    ReferenceFilterOperation(const String&amp; url, const String&amp; fragment, OperationType);
</del><ins>+    ReferenceFilterOperation(const String&amp; url, const String&amp; fragment);
</ins><span class="cx"> 
</span><del>-    virtual bool operator==(const FilterOperation&amp; o) const override
-    {
-        if (!isSameType(o))
-            return false;
-        const ReferenceFilterOperation* other = static_cast&lt;const ReferenceFilterOperation*&gt;(&amp;o);
-        return m_url == other-&gt;m_url;
-    }
</del><ins>+    virtual bool operator==(const FilterOperation&amp;) const override;
</ins><span class="cx"> 
</span><span class="cx">     String m_url;
</span><span class="cx">     String m_fragment;
</span><span class="lines">@@ -181,6 +193,8 @@
</span><span class="cx">     RefPtr&lt;FilterEffect&gt; m_filterEffect;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+FILTEROPERATION_TYPE_CASTS(ReferenceFilterOperation, type() == FilterOperation::REFERENCE);
+
</ins><span class="cx"> // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color matrix effect.
</span><span class="cx"> // For HUE_ROTATE, the angle of rotation is stored in m_amount.
</span><span class="cx"> class BasicColorMatrixFilterOperation : public FilterOperation {
</span><span class="lines">@@ -208,6 +222,8 @@
</span><span class="cx">     double m_amount;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+FILTEROPERATION_TYPE_CASTS(BasicColorMatrixFilterOperation, isBasicColorMatrixFilterOperation());
+
</ins><span class="cx"> // INVERT, BRIGHTNESS, CONTRAST and OPACITY are variations on a basic component transfer effect.
</span><span class="cx"> class BasicComponentTransferFilterOperation : public FilterOperation {
</span><span class="cx"> public:
</span><span class="lines">@@ -236,11 +252,13 @@
</span><span class="cx">     double m_amount;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+FILTEROPERATION_TYPE_CASTS(BasicComponentTransferFilterOperation, isBasicComponentTransferFilterOperation());
+
</ins><span class="cx"> class BlurFilterOperation : public FilterOperation {
</span><span class="cx"> public:
</span><del>-    static PassRefPtr&lt;BlurFilterOperation&gt; create(Length stdDeviation, OperationType type)
</del><ins>+    static PassRefPtr&lt;BlurFilterOperation&gt; create(Length stdDeviation)
</ins><span class="cx">     {
</span><del>-        return adoptRef(new BlurFilterOperation(std::move(stdDeviation), type));
</del><ins>+        return adoptRef(new BlurFilterOperation(std::move(stdDeviation)));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     const Length&amp; stdDeviation() const { return m_stdDeviation; }
</span><span class="lines">@@ -251,16 +269,10 @@
</span><span class="cx">     virtual PassRefPtr&lt;FilterOperation&gt; blend(const FilterOperation* from, double progress, bool blendToPassthrough = false) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    virtual bool operator==(const FilterOperation&amp; o) const override
-    {
-        if (!isSameType(o))
-            return false;
-        const BlurFilterOperation* other = static_cast&lt;const BlurFilterOperation*&gt;(&amp;o);
-        return m_stdDeviation == other-&gt;m_stdDeviation;
-    }
</del><ins>+    virtual bool operator==(const FilterOperation&amp;) const override;
</ins><span class="cx"> 
</span><del>-    BlurFilterOperation(Length stdDeviation, OperationType type)
-        : FilterOperation(type)
</del><ins>+    BlurFilterOperation(Length stdDeviation)
+        : FilterOperation(BLUR)
</ins><span class="cx">         , m_stdDeviation(std::move(stdDeviation))
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="lines">@@ -268,11 +280,13 @@
</span><span class="cx">     Length m_stdDeviation;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+FILTEROPERATION_TYPE_CASTS(BlurFilterOperation, type() == FilterOperation::BLUR);
+
</ins><span class="cx"> class DropShadowFilterOperation : public FilterOperation {
</span><span class="cx"> public:
</span><del>-    static PassRefPtr&lt;DropShadowFilterOperation&gt; create(const IntPoint&amp; location, int stdDeviation, Color color, OperationType type)
</del><ins>+    static PassRefPtr&lt;DropShadowFilterOperation&gt; create(const IntPoint&amp; location, int stdDeviation, Color color)
</ins><span class="cx">     {
</span><del>-        return adoptRef(new DropShadowFilterOperation(location, stdDeviation, color, type));
</del><ins>+        return adoptRef(new DropShadowFilterOperation(location, stdDeviation, color));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     int x() const { return m_location.x(); }
</span><span class="lines">@@ -287,16 +301,10 @@
</span><span class="cx">     virtual PassRefPtr&lt;FilterOperation&gt; blend(const FilterOperation* from, double progress, bool blendToPassthrough = false) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    virtual bool operator==(const FilterOperation&amp; o) const override
-    {
-        if (!isSameType(o))
-            return false;
-        const DropShadowFilterOperation* other = static_cast&lt;const DropShadowFilterOperation*&gt;(&amp;o);
-        return m_location == other-&gt;m_location &amp;&amp; m_stdDeviation == other-&gt;m_stdDeviation &amp;&amp; m_color == other-&gt;m_color;
-    }
</del><ins>+    virtual bool operator==(const FilterOperation&amp;) const override;
</ins><span class="cx"> 
</span><del>-    DropShadowFilterOperation(const IntPoint&amp; location, int stdDeviation, Color color, OperationType type)
-        : FilterOperation(type)
</del><ins>+    DropShadowFilterOperation(const IntPoint&amp; location, int stdDeviation, Color color)
+        : FilterOperation(DROP_SHADOW)
</ins><span class="cx">         , m_location(location)
</span><span class="cx">         , m_stdDeviation(stdDeviation)
</span><span class="cx">         , m_color(color)
</span><span class="lines">@@ -308,16 +316,8 @@
</span><span class="cx">     Color m_color;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-#define SIMPLE_FILTER_OPERATION_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, FilterOperation, operation, operation-&gt;type() == FilterOperation::predicate, operation.type() == FilterOperation::predicate)
</del><ins>+FILTEROPERATION_TYPE_CASTS(DropShadowFilterOperation, type() == FilterOperation::DROP_SHADOW);
</ins><span class="cx"> 
</span><del>-SIMPLE_FILTER_OPERATION_CASTS(ReferenceFilterOperation, REFERENCE)
-SIMPLE_FILTER_OPERATION_CASTS(BlurFilterOperation, BLUR)
-SIMPLE_FILTER_OPERATION_CASTS(DropShadowFilterOperation, DROP_SHADOW)
-
-TYPE_CASTS_BASE(BasicColorMatrixFilterOperation, FilterOperation, operation, operation-&gt;type() == FilterOperation::GRAYSCALE || operation-&gt;type() == FilterOperation::SEPIA || operation-&gt;type() == FilterOperation::SATURATE || operation-&gt;type() == FilterOperation::HUE_ROTATE, operation.type() == FilterOperation::GRAYSCALE || operation.type() == FilterOperation::SEPIA || operation.type() == FilterOperation::SATURATE || operation.type() == FilterOperation::HUE_ROTATE)
-TYPE_CASTS_BASE(BasicComponentTransferFilterOperation, FilterOperation, operation, operation-&gt;type() == FilterOperation::INVERT || operation-&gt;type() == FilterOperation::BRIGHTNESS || operation-&gt;type() == FilterOperation::CONTRAST || operation-&gt;type() == FilterOperation::OPACITY, operation.type() == FilterOperation::INVERT || operation.type() == FilterOperation::BRIGHTNESS || operation.type() == FilterOperation::CONTRAST || operation.type() == FilterOperation::OPACITY)
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(CSS_FILTERS)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -108,10 +108,10 @@
</span><span class="cx"> {
</span><span class="cx">     FilterOutsets totalOutsets;
</span><span class="cx">     for (size_t i = 0; i &lt; m_operations.size(); ++i) {
</span><del>-        FilterOperation* filterOperation = m_operations.at(i).get();
</del><ins>+        const FilterOperation* filterOperation = m_operations.at(i).get();
</ins><span class="cx">         switch (filterOperation-&gt;type()) {
</span><span class="cx">         case FilterOperation::BLUR: {
</span><del>-            BlurFilterOperation* blurOperation = static_cast&lt;BlurFilterOperation*&gt;(filterOperation);
</del><ins>+            const BlurFilterOperation* blurOperation = toBlurFilterOperation(filterOperation);
</ins><span class="cx">             float stdDeviation = floatValueForLength(blurOperation-&gt;stdDeviation(), 0);
</span><span class="cx">             IntSize outsetSize = outsetSizeForBlur(stdDeviation);
</span><span class="cx">             FilterOutsets outsets(outsetSize.height(), outsetSize.width(), outsetSize.height(), outsetSize.width());
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::DROP_SHADOW: {
</span><del>-            DropShadowFilterOperation* dropShadowOperation = static_cast&lt;DropShadowFilterOperation*&gt;(filterOperation);
</del><ins>+            const DropShadowFilterOperation* dropShadowOperation = toDropShadowFilterOperation(filterOperation);
</ins><span class="cx">             IntSize outsetSize = outsetSizeForBlur(dropShadowOperation-&gt;stdDeviation());
</span><span class="cx">             FilterOutsets outsets(
</span><span class="cx">                 std::max(0, outsetSize.height() - dropShadowOperation-&gt;y()),
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingFilterEffectRenderercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -146,13 +146,13 @@
</span><span class="cx">         FilterOperation* filterOperation = operations.operations().at(i).get();
</span><span class="cx">         switch (filterOperation-&gt;type()) {
</span><span class="cx">         case FilterOperation::REFERENCE: {
</span><del>-            ReferenceFilterOperation* referenceOperation = static_cast&lt;ReferenceFilterOperation*&gt;(filterOperation);
</del><ins>+            ReferenceFilterOperation* referenceOperation = toReferenceFilterOperation(filterOperation);
</ins><span class="cx">             effect = buildReferenceFilter(renderer, previousEffect, referenceOperation);
</span><span class="cx">             referenceOperation-&gt;setFilterEffect(effect);
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::GRAYSCALE: {
</span><del>-            BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast&lt;BasicColorMatrixFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicColorMatrixFilterOperation* colorMatrixOperation = toBasicColorMatrixFilterOperation(filterOperation);
</ins><span class="cx">             Vector&lt;float&gt; inputParameters;
</span><span class="cx">             double oneMinusAmount = clampTo(1 - colorMatrixOperation-&gt;amount(), 0.0, 1.0);
</span><span class="cx"> 
</span><span class="lines">@@ -180,7 +180,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::SEPIA: {
</span><del>-            BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast&lt;BasicColorMatrixFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicColorMatrixFilterOperation* colorMatrixOperation = toBasicColorMatrixFilterOperation(filterOperation);
</ins><span class="cx">             Vector&lt;float&gt; inputParameters;
</span><span class="cx">             double oneMinusAmount = clampTo(1 - colorMatrixOperation-&gt;amount(), 0.0, 1.0);
</span><span class="cx"> 
</span><span class="lines">@@ -208,21 +208,21 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::SATURATE: {
</span><del>-            BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast&lt;BasicColorMatrixFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicColorMatrixFilterOperation* colorMatrixOperation = toBasicColorMatrixFilterOperation(filterOperation);
</ins><span class="cx">             Vector&lt;float&gt; inputParameters;
</span><span class="cx">             inputParameters.append(narrowPrecisionToFloat(colorMatrixOperation-&gt;amount()));
</span><span class="cx">             effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_SATURATE, inputParameters);
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::HUE_ROTATE: {
</span><del>-            BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast&lt;BasicColorMatrixFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicColorMatrixFilterOperation* colorMatrixOperation = toBasicColorMatrixFilterOperation(filterOperation);
</ins><span class="cx">             Vector&lt;float&gt; inputParameters;
</span><span class="cx">             inputParameters.append(narrowPrecisionToFloat(colorMatrixOperation-&gt;amount()));
</span><span class="cx">             effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_HUEROTATE, inputParameters);
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::INVERT: {
</span><del>-            BasicComponentTransferFilterOperation* componentTransferOperation = static_cast&lt;BasicComponentTransferFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicComponentTransferFilterOperation* componentTransferOperation = toBasicComponentTransferFilterOperation(filterOperation);
</ins><span class="cx">             ComponentTransferFunction transferFunction;
</span><span class="cx">             transferFunction.type = FECOMPONENTTRANSFER_TYPE_TABLE;
</span><span class="cx">             Vector&lt;float&gt; transferParameters;
</span><span class="lines">@@ -235,7 +235,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::OPACITY: {
</span><del>-            BasicComponentTransferFilterOperation* componentTransferOperation = static_cast&lt;BasicComponentTransferFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicComponentTransferFilterOperation* componentTransferOperation = toBasicComponentTransferFilterOperation(filterOperation);
</ins><span class="cx">             ComponentTransferFunction transferFunction;
</span><span class="cx">             transferFunction.type = FECOMPONENTTRANSFER_TYPE_TABLE;
</span><span class="cx">             Vector&lt;float&gt; transferParameters;
</span><span class="lines">@@ -248,7 +248,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::BRIGHTNESS: {
</span><del>-            BasicComponentTransferFilterOperation* componentTransferOperation = static_cast&lt;BasicComponentTransferFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicComponentTransferFilterOperation* componentTransferOperation = toBasicComponentTransferFilterOperation(filterOperation);
</ins><span class="cx">             ComponentTransferFunction transferFunction;
</span><span class="cx">             transferFunction.type = FECOMPONENTTRANSFER_TYPE_LINEAR;
</span><span class="cx">             transferFunction.slope = narrowPrecisionToFloat(componentTransferOperation-&gt;amount());
</span><span class="lines">@@ -259,7 +259,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::CONTRAST: {
</span><del>-            BasicComponentTransferFilterOperation* componentTransferOperation = static_cast&lt;BasicComponentTransferFilterOperation*&gt;(filterOperation);
</del><ins>+            BasicComponentTransferFilterOperation* componentTransferOperation = toBasicComponentTransferFilterOperation(filterOperation);
</ins><span class="cx">             ComponentTransferFunction transferFunction;
</span><span class="cx">             transferFunction.type = FECOMPONENTTRANSFER_TYPE_LINEAR;
</span><span class="cx">             float amount = narrowPrecisionToFloat(componentTransferOperation-&gt;amount());
</span><span class="lines">@@ -271,13 +271,13 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::BLUR: {
</span><del>-            BlurFilterOperation* blurOperation = static_cast&lt;BlurFilterOperation*&gt;(filterOperation);
</del><ins>+            BlurFilterOperation* blurOperation = toBlurFilterOperation(filterOperation);
</ins><span class="cx">             float stdDeviation = floatValueForLength(blurOperation-&gt;stdDeviation(), 0);
</span><span class="cx">             effect = FEGaussianBlur::create(this, stdDeviation, stdDeviation, consumer == FilterProperty ? EDGEMODE_NONE : EDGEMODE_DUPLICATE);
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case FilterOperation::DROP_SHADOW: {
</span><del>-            DropShadowFilterOperation* dropShadowOperation = static_cast&lt;DropShadowFilterOperation*&gt;(filterOperation);
</del><ins>+            DropShadowFilterOperation* dropShadowOperation = toDropShadowFilterOperation(filterOperation);
</ins><span class="cx">             effect = FEDropShadow::create(this, dropShadowOperation-&gt;stdDeviation(), dropShadowOperation-&gt;stdDeviation(),
</span><span class="cx">                                                 dropShadowOperation-&gt;x(), dropShadowOperation-&gt;y(), dropShadowOperation-&gt;color(), 1);
</span><span class="cx">             break;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerFilterInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">         FilterOperation* filterOperation = operations.operations()[i].get();
</span><span class="cx">         if (filterOperation-&gt;type() != FilterOperation::REFERENCE)
</span><span class="cx">             continue;
</span><del>-        ReferenceFilterOperation* referenceFilterOperation = static_cast&lt;ReferenceFilterOperation*&gt;(filterOperation);
</del><ins>+        ReferenceFilterOperation* referenceFilterOperation = toReferenceFilterOperation(filterOperation);
</ins><span class="cx">         CachedSVGDocumentReference* documentReference = referenceFilterOperation-&gt;cachedSVGDocumentReference();
</span><span class="cx">         CachedSVGDocument* cachedSVGDocument = documentReference ? documentReference-&gt;document() : 0;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebKit2/ChangeLog        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2014-04-02  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Harden FilterOperation type casting
+        https://bugs.webkit.org/show_bug.cgi?id=131142
+
+        Reviewed by Sam Weinig.
+
+        DefaultFilterOperation had an error-prone behavior where it set the base class
+        OperationType to the type of some other filter class, but overrode isDefault(). 
+        This made it very easy to write incorrect code that casted incorrectly based on type().
+        
+        Fix by making adding a DEFAULT filter operation type, and storing the represented
+        type on DefaultFilterOperation().
+        
+        Also remove the OperationType argument for constructors of FilterOperations that
+        can only be of one type, to avoid possible mistakes.
+        
+        Make the type cast macros a bit more normal, and use them in a few places.
+        
+        Fixed PlatformCAFiltersMac to handle the default filter case more cleanly.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::encodeFilterOperation):
+        (IPC::decodeFilterOperation):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTextStream::operator&lt;&lt;):
+
</ins><span class="cx"> 2014-04-03  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (Async text input): Controls become unresponsive to mouse events
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebCoreArgumentCoderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -1608,6 +1608,7 @@
</span><span class="cx">         encoder &lt;&lt; dropShadowFilter.color();
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case FilterOperation::DEFAULT:
</ins><span class="cx">     case FilterOperation::PASSTHROUGH:
</span><span class="cx">     case FilterOperation::NONE:
</span><span class="cx">         break;
</span><span class="lines">@@ -1628,7 +1629,7 @@
</span><span class="cx">             return false;
</span><span class="cx">         if (!decoder.decode(fragment))
</span><span class="cx">             return false;
</span><del>-        filter = ReferenceFilterOperation::create(url, fragment, type);
</del><ins>+        filter = ReferenceFilterOperation::create(url, fragment);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case FilterOperation::GRAYSCALE:
</span><span class="lines">@@ -1655,7 +1656,7 @@
</span><span class="cx">         Length stdDeviation;
</span><span class="cx">         if (!decoder.decode(stdDeviation))
</span><span class="cx">             return false;
</span><del>-        filter = BlurFilterOperation::create(stdDeviation, type);
</del><ins>+        filter = BlurFilterOperation::create(stdDeviation);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case FilterOperation::DROP_SHADOW: {
</span><span class="lines">@@ -1668,9 +1669,10 @@
</span><span class="cx">             return false;
</span><span class="cx">         if (!decoder.decode(color))
</span><span class="cx">             return false;
</span><del>-        filter = DropShadowFilterOperation::create(location, stdDeviation, color, type);
</del><ins>+        filter = DropShadowFilterOperation::create(location, stdDeviation, color);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    case FilterOperation::DEFAULT:
</ins><span class="cx">     case FilterOperation::PASSTHROUGH:
</span><span class="cx">     case FilterOperation::NONE:
</span><span class="cx">         break;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (166740 => 166741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-04-03 20:56:33 UTC (rev 166740)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-04-03 20:57:48 UTC (rev 166741)
</span><span class="lines">@@ -632,6 +632,9 @@
</span><span class="cx">     for (size_t i = 0; i &lt; filters.size(); ++i) {
</span><span class="cx">         const auto filter = filters.at(i);
</span><span class="cx">         switch (filter-&gt;type()) {
</span><ins>+        case FilterOperation::DEFAULT:
+            ts &lt;&lt; &quot;default&quot;;
+            break;
</ins><span class="cx">         case FilterOperation::REFERENCE:
</span><span class="cx">             ts &lt;&lt; &quot;reference&quot;;
</span><span class="cx">             break;
</span></span></pre>
</div>
</div>

</body>
</html>