Changeset 115291 in webkit


Ignore:
Timestamp:
Apr 25, 2012, 10:44:22 PM (13 years ago)
Author:
danakj@chromium.org
Message:

[chromium] Remove guarded virtual methods from WebFilterOperation API
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:
Location:
trunk/Source
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/Platform/ChangeLog

    r115206 r115291  
     12012-04-25  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Remove guarded virtual methods from WebFilterOperation API
     4        https://bugs.webkit.org/show_bug.cgi?id=84926
     5
     6        Reviewed by James Robinson.
     7
     8        We remove the virtual methods from the WebFilterOperation class,
     9        and use an enum in the base class to distinguish which subclass
     10        the object is. Then WebFilterOperations can access the correct
     11        subclass to get the filter operation's data and construct a
     12        WebCore::FilterOperation to store internally.
     13
     14        * chromium/public/WebFilterOperation.h:
     15        (WebKit::WebFilterOperation::WebFilterOperation):
     16        (WebKit::WebBasicColorMatrixFilterOperation::WebBasicColorMatrixFilterOperation):
     17        (WebBasicColorMatrixFilterOperation):
     18        (WebKit::WebBasicComponentTransferFilterOperation::WebBasicComponentTransferFilterOperation):
     19        (WebBasicComponentTransferFilterOperation):
     20        (WebKit::WebBlurFilterOperation::WebBlurFilterOperation):
     21        (WebKit::WebDropShadowFilterOperation::WebDropShadowFilterOperation):
     22
    1232012-04-25  Gavin Peters  <gavinp@chromium.org>
    224
  • trunk/Source/Platform/chromium/public/WebFilterOperation.h

    r114343 r115291  
    3535#endif
    3636
    37 #if WEBKIT_IMPLEMENTATION
    38 namespace WebCore {
    39 class FilterOperation;
    40 }
    41 #endif
    42 
    4337namespace WebKit {
    4438
    4539struct WebFilterOperation {
    46 #if WEBKIT_IMPLEMENTATION
    47     virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const = 0;
    48 #endif
     40    enum FilterType {
     41        FilterTypeBasicColorMatrix,
     42        FilterTypeBasicComponentTransfer,
     43        FilterTypeBlur,
     44        FilterTypeDropShadow
     45    };
     46
     47    FilterType type;
    4948
    5049protected:
    51     WebFilterOperation() { }
     50    WebFilterOperation(FilterType type)
     51        : type(type)
     52    { }
    5253};
    5354
    5455struct WebBasicColorMatrixFilterOperation : public WebFilterOperation {
    55     enum FilterType {
    56         FilterTypeGrayscale = 1,
    57         FilterTypeSepia = 2,
    58         FilterTypeSaturate = 3,
    59         FilterTypeHueRotate = 4
     56    enum BasicColorMatrixFilterType {
     57        BasicColorMatrixFilterTypeGrayscale = 1,
     58        BasicColorMatrixFilterTypeSepia = 2,
     59        BasicColorMatrixFilterTypeSaturate = 3,
     60        BasicColorMatrixFilterTypeHueRotate = 4
    6061    };
    6162
    62     WebBasicColorMatrixFilterOperation(FilterType type, float amount)
    63         : type(type)
     63    WebBasicColorMatrixFilterOperation(BasicColorMatrixFilterType type, float amount)
     64        : WebFilterOperation(FilterTypeBasicColorMatrix)
     65        , subtype(type)
    6466        , amount(amount)
    6567    { }
    6668
    67 #if WEBKIT_IMPLEMENTATION
    68     virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const OVERRIDE;
    69 #endif
    70 
    71     FilterType type;
     69    BasicColorMatrixFilterType subtype;
    7270    float amount;
    7371};
    7472
    7573struct WebBasicComponentTransferFilterOperation : public WebFilterOperation {
    76     enum FilterType {
    77         FilterTypeInvert = 5,
    78         FilterTypeBrightness = 7,
    79         FilterTypeContrast = 8
     74    enum BasicComponentTransferFilterType {
     75        BasicComponentTransferFilterTypeInvert = 5,
     76        BasicComponentTransferFilterTypeBrightness = 7,
     77        BasicComponentTransferFilterTypeContrast = 8
    8078        // Opacity is missing because this is more expensive than just setting opacity on the layer.
    8179    };
    8280
    83     WebBasicComponentTransferFilterOperation(FilterType type, float amount)
    84         : type(type)
     81    WebBasicComponentTransferFilterOperation(BasicComponentTransferFilterType type, float amount)
     82        : WebFilterOperation(FilterTypeBasicComponentTransfer)
     83        , subtype(type)
    8584        , amount(amount)
    8685    { }
    8786
    88 #if WEBKIT_IMPLEMENTATION
    89     virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const OVERRIDE;
    90 #endif
    91 
    92     FilterType type;
     87    BasicComponentTransferFilterType subtype;
    9388    float amount;
    9489};
    9590
    9691struct WebBlurFilterOperation : public WebFilterOperation {
    97     explicit WebBlurFilterOperation(int pixelRadius) : pixelRadius(pixelRadius) { }
    98 
    99 #if WEBKIT_IMPLEMENTATION
    100     virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const OVERRIDE;
    101 #endif
     92    explicit WebBlurFilterOperation(int pixelRadius)
     93        : WebFilterOperation(FilterTypeBlur)
     94        , pixelRadius(pixelRadius)
     95    { }
    10296
    10397    int pixelRadius;
    10498};
    10599
    106 class WebDropShadowFilterOperation : public WebFilterOperation {
    107     WebDropShadowFilterOperation(int x, int y, int stdDeviation, WebColor color)
    108         : x(x)
     100struct WebDropShadowFilterOperation : public WebFilterOperation {
     101    WebDropShadowFilterOperation(int x, int y, int stdDeviation, WebColor color)
     102        : WebFilterOperation(FilterTypeDropShadow)
     103        , x(x)
    109104        , y(y)
    110105        , stdDeviation(stdDeviation)
    111106        , color(color)
    112107    { }
    113 
    114 #if WEBKIT_IMPLEMENTATION
    115     virtual PassRefPtr<WebCore::FilterOperation> toFilterOperation() const OVERRIDE;
    116 #endif
    117108
    118109    int x;
  • trunk/Source/WebCore/ChangeLog

    r115290 r115291  
     12012-04-25  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Remove guarded virtual methods from WebFilterOperation API
     4        https://bugs.webkit.org/show_bug.cgi?id=84926
     5
     6        Reviewed by James Robinson.
     7
     8        * WebCore.gypi:
     9        * platform/chromium/support/WebFilterOperation.cpp: Removed.
     10        * platform/chromium/support/WebFilterOperations.cpp:
     11        (WebKit::WebFilterOperations::append):
     12
    1132012-04-25  Benjamin Poulain  <benjamin@webkit.org>
    214
  • trunk/Source/WebCore/WebCore.gypi

    r115274 r115291  
    82448244            'platform/chromium/support/WebHTTPBody.cpp',
    82458245            'platform/chromium/support/WebHTTPLoadInfo.cpp',
    8246             'platform/chromium/support/WebFilterOperation.cpp',
    82478246            'platform/chromium/support/WebFilterOperations.cpp',
    82488247            'platform/chromium/support/WebICECandidateDescriptor.cpp',
  • trunk/Source/WebCore/platform/chromium/support/WebFilterOperations.cpp

    r114807 r115291  
    4343void WebFilterOperations::append(const WebFilterOperation& filter)
    4444{
    45     m_private->operations().append(filter.toFilterOperation());
     45    switch (filter.type) {
     46    case WebFilterOperation::FilterTypeBasicColorMatrix: {
     47        const WebBasicColorMatrixFilterOperation& colorFilter = static_cast<const WebBasicColorMatrixFilterOperation&>(filter);
     48        m_private->operations().append(BasicColorMatrixFilterOperation::create(colorFilter.amount, static_cast<FilterOperation::OperationType>(colorFilter.subtype)));
     49        break;
     50    }
     51    case WebFilterOperation::FilterTypeBasicComponentTransfer: {
     52        const WebBasicComponentTransferFilterOperation& componentFilter = static_cast<const WebBasicComponentTransferFilterOperation&>(filter);
     53        m_private->operations().append(BasicComponentTransferFilterOperation::create(componentFilter.amount, static_cast<FilterOperation::OperationType>(componentFilter.subtype)));
     54        break;
     55    }
     56    case WebFilterOperation::FilterTypeBlur: {
     57        const WebBlurFilterOperation& blurFilter = static_cast<const WebBlurFilterOperation&>(filter);
     58        m_private->operations().append(BlurFilterOperation::create(Length(blurFilter.pixelRadius, Fixed), FilterOperation::BLUR));
     59        break;
     60    }
     61    case WebFilterOperation::FilterTypeDropShadow: {
     62        const WebDropShadowFilterOperation& shadowFilter = static_cast<const WebDropShadowFilterOperation&>(filter);
     63        m_private->operations().append(DropShadowFilterOperation::create(IntPoint(shadowFilter.x, shadowFilter.y), shadowFilter.stdDeviation, shadowFilter.color, FilterOperation::DROP_SHADOW));
     64        break;
     65    }
     66    }
    4667}
    4768
  • trunk/Source/WebKit/chromium/ChangeLog

    r115285 r115291  
     12012-04-25  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Remove guarded virtual methods from WebFilterOperation API
     4        https://bugs.webkit.org/show_bug.cgi?id=84926
     5
     6        Reviewed by James Robinson.
     7
     8        * src/AssertMatchingEnums.cpp:
     9
    1102012-04-25  James Robinson  <jamesr@chromium.org>
    211
  • trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp

    r115200 r115291  
    320320COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionDropped, EditorInsertActionDropped);
    321321
    322 COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::FilterTypeGrayscale, FilterOperation::GRAYSCALE);
    323 COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::FilterTypeSepia, FilterOperation::SEPIA);
    324 COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::FilterTypeSaturate, FilterOperation::SATURATE);
    325 COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::FilterTypeHueRotate, FilterOperation::HUE_ROTATE);
    326 
    327 COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::FilterTypeInvert, FilterOperation::INVERT);
    328 COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::FilterTypeBrightness, FilterOperation::BRIGHTNESS);
    329 COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::FilterTypeContrast, FilterOperation::CONTRAST);
     322COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::BasicColorMatrixFilterTypeGrayscale, FilterOperation::GRAYSCALE);
     323COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::BasicColorMatrixFilterTypeSepia, FilterOperation::SEPIA);
     324COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::BasicColorMatrixFilterTypeSaturate, FilterOperation::SATURATE);
     325COMPILE_ASSERT_MATCHING_ENUM(WebBasicColorMatrixFilterOperation::BasicColorMatrixFilterTypeHueRotate, FilterOperation::HUE_ROTATE);
     326
     327COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::BasicComponentTransferFilterTypeInvert, FilterOperation::INVERT);
     328COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::BasicComponentTransferFilterTypeBrightness, FilterOperation::BRIGHTNESS);
     329COMPILE_ASSERT_MATCHING_ENUM(WebBasicComponentTransferFilterOperation::BasicComponentTransferFilterTypeContrast, FilterOperation::CONTRAST);
    330330
    331331COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyNone, FontDescription::NoFamily);
Note: See TracChangeset for help on using the changeset viewer.