[chromium] Remove guarded virtual methods from WebFilterOperation API
authordanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Apr 2012 05:44:22 +0000 (05:44 +0000)
committerdanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Apr 2012 05:44:22 +0000 (05:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84926

Reviewed by James Robinson.

Source/Platform:

We remove the virtual methods from the WebFilterOperation class,
and use an enum in the base class to distinguish which subclass
the object is. Then WebFilterOperations can access the correct
subclass to get the filter operation's data and construct a
WebCore::FilterOperation to store internally.

* chromium/public/WebFilterOperation.h:
(WebKit::WebFilterOperation::WebFilterOperation):
(WebKit::WebBasicColorMatrixFilterOperation::WebBasicColorMatrixFilterOperation):
(WebBasicColorMatrixFilterOperation):
(WebKit::WebBasicComponentTransferFilterOperation::WebBasicComponentTransferFilterOperation):
(WebBasicComponentTransferFilterOperation):
(WebKit::WebBlurFilterOperation::WebBlurFilterOperation):
(WebKit::WebDropShadowFilterOperation::WebDropShadowFilterOperation):

Source/WebCore:

* WebCore.gypi:
* platform/chromium/support/WebFilterOperation.cpp: Removed.
* platform/chromium/support/WebFilterOperations.cpp:
(WebKit::WebFilterOperations::append):

Source/WebKit/chromium:

* src/AssertMatchingEnums.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115291 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/Platform/ChangeLog
Source/Platform/chromium/public/WebFilterOperation.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/chromium/support/WebFilterOperation.cpp [deleted file]
Source/WebCore/platform/chromium/support/WebFilterOperations.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/AssertMatchingEnums.cpp

index ecdb94a..f8b3fba 100644 (file)
@@ -1,3 +1,25 @@
+2012-04-25  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Remove guarded virtual methods from WebFilterOperation API
+        https://bugs.webkit.org/show_bug.cgi?id=84926
+
+        Reviewed by James Robinson.
+
+        We remove the virtual methods from the WebFilterOperation class,
+        and use an enum in the base class to distinguish which subclass
+        the object is. Then WebFilterOperations can access the correct
+        subclass to get the filter operation's data and construct a
+        WebCore::FilterOperation to store internally.
+
+        * chromium/public/WebFilterOperation.h:
+        (WebKit::WebFilterOperation::WebFilterOperation):
+        (WebKit::WebBasicColorMatrixFilterOperation::WebBasicColorMatrixFilterOperation):
+        (WebBasicColorMatrixFilterOperation):
+        (WebKit::WebBasicComponentTransferFilterOperation::WebBasicComponentTransferFilterOperation):
+        (WebBasicComponentTransferFilterOperation):
+        (WebKit::WebBlurFilterOperation::WebBlurFilterOperation):
+        (WebKit::WebDropShadowFilterOperation::WebDropShadowFilterOperation):
+
 2012-04-25  Gavin Peters  <gavinp@chromium.org>
 
         [Chromium] Fix some conditional compilation logic in Platform
index 561cad3..2b5940c 100644 (file)
 #include <wtf/PassRefPtr.h>
 #endif
 
-#if WEBKIT_IMPLEMENTATION
-namespace WebCore {
-class FilterOperation;
-}
-#endif
-
 namespace WebKit {
 
 struct WebFilterOperation {
-#if WEBKIT_IMPLEMENTATION
-    virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const = 0;
-#endif
+    enum FilterType {
+        FilterTypeBasicColorMatrix,
+        FilterTypeBasicComponentTransfer,
+        FilterTypeBlur,
+        FilterTypeDropShadow
+    };
+
+    FilterType type;
 
 protected:
-    WebFilterOperation() { }
+    WebFilterOperation(FilterType type)
+        : type(type)
+    { }
 };
 
 struct WebBasicColorMatrixFilterOperation : public WebFilterOperation {
-    enum FilterType {
-        FilterTypeGrayscale = 1,
-        FilterTypeSepia = 2,
-        FilterTypeSaturate = 3,
-        FilterTypeHueRotate = 4
+    enum BasicColorMatrixFilterType {
+        BasicColorMatrixFilterTypeGrayscale = 1,
+        BasicColorMatrixFilterTypeSepia = 2,
+        BasicColorMatrixFilterTypeSaturate = 3,
+        BasicColorMatrixFilterTypeHueRotate = 4
     };
 
-    WebBasicColorMatrixFilterOperation(FilterType type, float amount)
-        : type(type)
+    WebBasicColorMatrixFilterOperation(BasicColorMatrixFilterType type, float amount)
+        : WebFilterOperation(FilterTypeBasicColorMatrix)
+        , subtype(type)
         , amount(amount)
     { }
 
-#if WEBKIT_IMPLEMENTATION
-    virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const OVERRIDE;
-#endif
-
-    FilterType type;
+    BasicColorMatrixFilterType subtype;
     float amount;
 };
 
 struct WebBasicComponentTransferFilterOperation : public WebFilterOperation {
-    enum FilterType {
-        FilterTypeInvert = 5,
-        FilterTypeBrightness = 7,
-        FilterTypeContrast = 8
+    enum BasicComponentTransferFilterType {
+        BasicComponentTransferFilterTypeInvert = 5,
+        BasicComponentTransferFilterTypeBrightness = 7,
+        BasicComponentTransferFilterTypeContrast = 8
         // Opacity is missing because this is more expensive than just setting opacity on the layer.
     };
 
-    WebBasicComponentTransferFilterOperation(FilterType type, float amount)
-        : type(type)
+    WebBasicComponentTransferFilterOperation(BasicComponentTransferFilterType type, float amount)
+        : WebFilterOperation(FilterTypeBasicComponentTransfer)
+        , subtype(type)
         , amount(amount)
     { }
 
-#if WEBKIT_IMPLEMENTATION
-    virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const OVERRIDE;
-#endif
-
-    FilterType type;
+    BasicComponentTransferFilterType subtype;
     float amount;
 };
 
 struct WebBlurFilterOperation : public WebFilterOperation {
-    explicit WebBlurFilterOperation(int pixelRadius) : pixelRadius(pixelRadius) { }
-
-#if WEBKIT_IMPLEMENTATION
-    virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const OVERRIDE;
-#endif
+    explicit WebBlurFilterOperation(int pixelRadius)
+        : WebFilterOperation(FilterTypeBlur)
+        , pixelRadius(pixelRadius)
+    { }
 
     int pixelRadius;
 };
 
-class WebDropShadowFilterOperation : public WebFilterOperation {
-    WebDropShadowFilterOperation(int x, int y, int stdDeviation, WebColor color)
-        : x(x)
+struct WebDropShadowFilterOperation : public WebFilterOperation {
+    WebDropShadowFilterOperation(int x, int y, int stdDeviation, WebColor color) 
+        : WebFilterOperation(FilterTypeDropShadow)
+        , x(x)
         , y(y)
         , stdDeviation(stdDeviation)
         , color(color)
     { }
 
-#if WEBKIT_IMPLEMENTATION
-    virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const OVERRIDE;
-#endif
-
     int x;
     int y;
     int stdDeviation;
index 712821e..6f7b62a 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-25  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Remove guarded virtual methods from WebFilterOperation API
+        https://bugs.webkit.org/show_bug.cgi?id=84926
+
+        Reviewed by James Robinson.
+
+        * WebCore.gypi:
+        * platform/chromium/support/WebFilterOperation.cpp: Removed.
+        * platform/chromium/support/WebFilterOperations.cpp:
+        (WebKit::WebFilterOperations::append):
+
 2012-04-25  Benjamin Poulain  <benjamin@webkit.org>
 
         Add a version of StringImpl::find() without offset
index d8e7f00..e03dd17 100644 (file)
             'platform/chromium/support/WebData.cpp',
             'platform/chromium/support/WebHTTPBody.cpp',
             'platform/chromium/support/WebHTTPLoadInfo.cpp',
-            'platform/chromium/support/WebFilterOperation.cpp',
             'platform/chromium/support/WebFilterOperations.cpp',
             'platform/chromium/support/WebICECandidateDescriptor.cpp',
             'platform/chromium/support/WebICEOptions.cpp',
diff --git a/Source/WebCore/platform/chromium/support/WebFilterOperation.cpp b/Source/WebCore/platform/chromium/support/WebFilterOperation.cpp
deleted file mode 100644 (file)
index 536968d..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "FilterOperation.h"
-
-#include <public/WebFilterOperation.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-PassRefPtr<WebCore::FilterOperation> WebBasicColorMatrixFilterOperation::toFilterOperation() const
-{
-    return BasicColorMatrixFilterOperation::create(amount, static_cast<FilterOperation::OperationType>(type));
-}
-
-PassRefPtr<WebCore::FilterOperation> WebBasicComponentTransferFilterOperation::toFilterOperation() const
-{
-    return BasicComponentTransferFilterOperation::create(amount, static_cast<FilterOperation::OperationType>(type));
-}
-
-PassRefPtr<WebCore::FilterOperation> WebBlurFilterOperation::toFilterOperation() const
-{
-    return BlurFilterOperation::create(Length(pixelRadius, Fixed), FilterOperation::BLUR);
-}
-
-PassRefPtr<WebCore::FilterOperation> WebDropShadowFilterOperation::toFilterOperation() const
-{
-    return DropShadowFilterOperation::create(IntPoint(x, y), stdDeviation, color, FilterOperation::DROP_SHADOW);
-}
-
-} // namespace WebKit
index e8007d8..d60d928 100644 (file)
@@ -42,7 +42,28 @@ void WebFilterOperations::initialize()
 
 void WebFilterOperations::append(const WebFilterOperation& filter)
 {
-    m_private->operations().append(filter.toFilterOperation());
+    switch (filter.type) {
+    case WebFilterOperation::FilterTypeBasicColorMatrix: {
+        const WebBasicColorMatrixFilterOperation& colorFilter = static_cast<const WebBasicColorMatrixFilterOperation&>(filter);
+        m_private->operations().append(BasicColorMatrixFilterOperation::create(colorFilter.amount, static_cast<FilterOperation::OperationType>(colorFilter.subtype)));
+        break;
+    }
+    case WebFilterOperation::FilterTypeBasicComponentTransfer: {
+        const WebBasicComponentTransferFilterOperation& componentFilter = static_cast<const WebBasicComponentTransferFilterOperation&>(filter);
+        m_private->operations().append(BasicComponentTransferFilterOperation::create(componentFilter.amount, static_cast<FilterOperation::OperationType>(componentFilter.subtype)));
+        break;
+    }
+    case WebFilterOperation::FilterTypeBlur: {
+        const WebBlurFilterOperation& blurFilter = static_cast<const WebBlurFilterOperation&>(filter);
+        m_private->operations().append(BlurFilterOperation::create(Length(blurFilter.pixelRadius, Fixed), FilterOperation::BLUR));
+        break;
+    }
+    case WebFilterOperation::FilterTypeDropShadow: {
+        const WebDropShadowFilterOperation& shadowFilter = static_cast<const WebDropShadowFilterOperation&>(filter);
+        m_private->operations().append(DropShadowFilterOperation::create(IntPoint(shadowFilter.x, shadowFilter.y), shadowFilter.stdDeviation, shadowFilter.color, FilterOperation::DROP_SHADOW));
+        break;
+    }
+    }
 }
 
 void WebFilterOperations::clear()
index 6b7cccf..e651fd6 100644 (file)
@@ -1,3 +1,12 @@
+2012-04-25  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Remove guarded virtual methods from WebFilterOperation API
+        https://bugs.webkit.org/show_bug.cgi?id=84926
+
+        Reviewed by James Robinson.
+
+        * src/AssertMatchingEnums.cpp:
+
 2012-04-25  James Robinson  <jamesr@chromium.org>
 
         [chromium] REGRESSION(112286) Compositor initialization blocks for program compilation / linking
index f1fb229..69e5962 100644 (file)
@@ -319,14 +319,14 @@ COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionTyped, EditorInsertActionTyped);
 COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionPasted, EditorInsertActionPasted);
 COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionDropped, EditorInsertActionDropped);
 
-COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::FilterTypeGrayscale, FilterOperation::GRAYSCALE);
-COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::FilterTypeSepia, FilterOperation::SEPIA);
-COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::FilterTypeSaturate, FilterOperation::SATURATE);
-COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::FilterTypeHueRotate, FilterOperation::HUE_ROTATE);
-
-COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::FilterTypeInvert, FilterOperation::INVERT);
-COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::FilterTypeBrightness, FilterOperation::BRIGHTNESS);
-COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::FilterTypeContrast, FilterOperation::CONTRAST);
+COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::BasicColorMatrixFilterTypeGrayscale, FilterOperation::GRAYSCALE);
+COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::BasicColorMatrixFilterTypeSepia, FilterOperation::SEPIA);
+COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::BasicColorMatrixFilterTypeSaturate, FilterOperation::SATURATE);
+COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::BasicColorMatrixFilterTypeHueRotate, FilterOperation::HUE_ROTATE);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::BasicComponentTransferFilterTypeInvert, FilterOperation::INVERT);
+COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::BasicComponentTransferFilterTypeBrightness, FilterOperation::BRIGHTNESS);
+COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::BasicComponentTransferFilterTypeContrast, FilterOperation::CONTRAST);
 
 COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyNone, FontDescription::NoFamily);
 COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyStandard, FontDescription::StandardFamily);