From 5a05ec18d8a4333dbba3d758c5e8376fefc48b44 Mon Sep 17 00:00:00 2001 From: "dino@apple.com" Date: Tue, 27 Sep 2011 19:49:09 +0000 Subject: [PATCH] Add 'filter' value to RenderStyle https://bugs.webkit.org/show_bug.cgi?id=68471 Reviewed by Simon Fraser. Add a filter property to RenderStyle when ENABLE(CSS_FILTERS) is turned on. Similar to -webkit-transform, -webkit-filter is a list of FilterOperations, each identifying what type of operation it is. This change simply adds the basic objects, it does not parse the property to generate the list. * CMakeLists.txt: * GNUmakefile.list.am: * WebCore.gypi: * WebCore.pro: * WebCore.vcproj/WebCore.vcproj: * WebCore.xcodeproj/project.pbxproj: * platform/graphics/filters/FilterOperation.h: Added. (WebCore::FilterOperation::~FilterOperation): (WebCore::FilterOperation::operator!=): (WebCore::FilterOperation::getOperationType): (WebCore::FilterOperation::isSameType): (WebCore::FilterOperation::FilterOperation): (WebCore::ReferenceFilterOperation::create): (WebCore::ReferenceFilterOperation::reference): (WebCore::ReferenceFilterOperation::operator==): (WebCore::ReferenceFilterOperation::ReferenceFilterOperation): (WebCore::BasicColorMatrixFilterOperation::create): (WebCore::BasicColorMatrixFilterOperation::amount): (WebCore::BasicColorMatrixFilterOperation::operator==): (WebCore::BasicColorMatrixFilterOperation::BasicColorMatrixFilterOperation): (WebCore::BasicComponentTransferFilterOperation::create): (WebCore::BasicComponentTransferFilterOperation::amount): (WebCore::BasicComponentTransferFilterOperation::operator==): (WebCore::BasicComponentTransferFilterOperation::BasicComponentTransferFilterOperation): (WebCore::GammaFilterOperation::create): (WebCore::GammaFilterOperation::amplitude): (WebCore::GammaFilterOperation::exponent): (WebCore::GammaFilterOperation::offset): (WebCore::GammaFilterOperation::operator==): (WebCore::GammaFilterOperation::GammaFilterOperation): (WebCore::BlurFilterOperation::create): (WebCore::BlurFilterOperation::stdDeviationX): (WebCore::BlurFilterOperation::stdDeviationY): (WebCore::BlurFilterOperation::operator==): (WebCore::BlurFilterOperation::BlurFilterOperation): (WebCore::SharpenFilterOperation::create): (WebCore::SharpenFilterOperation::radius): (WebCore::SharpenFilterOperation::threshold): (WebCore::SharpenFilterOperation::amount): (WebCore::SharpenFilterOperation::operator==): (WebCore::SharpenFilterOperation::SharpenFilterOperation): (WebCore::DropShadowFilterOperation::create): (WebCore::DropShadowFilterOperation::shadow): (WebCore::DropShadowFilterOperation::operator==): (WebCore::DropShadowFilterOperation::DropShadowFilterOperation): * platform/graphics/filters/FilterOperations.cpp: Added. (WebCore::FilterOperations::FilterOperations): (WebCore::FilterOperations::operator==): * platform/graphics/filters/FilterOperations.h: Added. (WebCore::FilterOperations::operator!=): (WebCore::FilterOperations::clear): (WebCore::FilterOperations::operations): (WebCore::FilterOperations::size): (WebCore::FilterOperations::at): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::RenderStyle): * rendering/style/RenderStyle.h: (WebCore::InheritedFlags::filter): (WebCore::InheritedFlags::hasFilter): (WebCore::InheritedFlags::setFilter): (WebCore::InheritedFlags::initialFilter): * rendering/style/StyleAllInOne.cpp: Added include of new StyleFilterData. * rendering/style/StyleFilterData.cpp: Added. (WebCore::StyleFilterData::StyleFilterData): (WebCore::StyleFilterData::operator==): * rendering/style/StyleFilterData.h: Added. (WebCore::StyleFilterData::create): (WebCore::StyleFilterData::copy): (WebCore::StyleFilterData::operator!=): * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: New filter DataRef. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96142 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/CMakeLists.txt | 2 + Source/WebCore/ChangeLog | 87 ++++++ Source/WebCore/GNUmakefile.list.am | 7 +- Source/WebCore/WebCore.gypi | 5 + Source/WebCore/WebCore.pro | 5 + Source/WebCore/WebCore.vcproj/WebCore.vcproj | 68 +++++ Source/WebCore/WebCore.xcodeproj/project.pbxproj | 24 ++ .../platform/graphics/filters/FilterOperation.h | 299 +++++++++++++++++++++ .../platform/graphics/filters/FilterOperations.cpp | 53 ++++ .../platform/graphics/filters/FilterOperations.h | 67 +++++ Source/WebCore/rendering/style/RenderStyle.cpp | 3 + Source/WebCore/rendering/style/RenderStyle.h | 20 +- Source/WebCore/rendering/style/StyleAllInOne.cpp | 1 + Source/WebCore/rendering/style/StyleFilterData.cpp | 53 ++++ Source/WebCore/rendering/style/StyleFilterData.h | 59 ++++ .../rendering/style/StyleRareNonInheritedData.cpp | 8 + .../rendering/style/StyleRareNonInheritedData.h | 8 +- 17 files changed, 766 insertions(+), 3 deletions(-) create mode 100644 Source/WebCore/platform/graphics/filters/FilterOperation.h create mode 100644 Source/WebCore/platform/graphics/filters/FilterOperations.cpp create mode 100644 Source/WebCore/platform/graphics/filters/FilterOperations.h create mode 100644 Source/WebCore/rendering/style/StyleFilterData.cpp create mode 100644 Source/WebCore/rendering/style/StyleFilterData.h diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index dcf6e41..e1eee73 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -1103,6 +1103,7 @@ SET(WebCore_SOURCES platform/graphics/filters/FETile.cpp platform/graphics/filters/FETurbulence.cpp platform/graphics/filters/FilterEffect.cpp + platform/graphics/filters/FilterOperations.cpp platform/graphics/filters/LightSource.cpp platform/graphics/filters/PointLightSource.cpp platform/graphics/filters/SpotLightSource.cpp @@ -1282,6 +1283,7 @@ SET(WebCore_SOURCES rendering/style/StyleBoxData.cpp rendering/style/StyleCachedImage.cpp rendering/style/StyleDeprecatedFlexibleBoxData.cpp + rendering/style/StyleFilterData.cpp rendering/style/StyleFlexibleBoxData.cpp rendering/style/StyleGeneratedImage.cpp rendering/style/StyleInheritedData.cpp diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 600ebbd..9238adf 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,90 @@ +2011-09-27 Dean Jackson + + Add 'filter' value to RenderStyle + https://bugs.webkit.org/show_bug.cgi?id=68471 + + Reviewed by Simon Fraser. + + Add a filter property to RenderStyle when ENABLE(CSS_FILTERS) + is turned on. Similar to -webkit-transform, -webkit-filter is a + list of FilterOperations, each identifying what type of operation + it is. This change simply adds the basic objects, it does not + parse the property to generate the list. + + * CMakeLists.txt: + * GNUmakefile.list.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * platform/graphics/filters/FilterOperation.h: Added. + (WebCore::FilterOperation::~FilterOperation): + (WebCore::FilterOperation::operator!=): + (WebCore::FilterOperation::getOperationType): + (WebCore::FilterOperation::isSameType): + (WebCore::FilterOperation::FilterOperation): + (WebCore::ReferenceFilterOperation::create): + (WebCore::ReferenceFilterOperation::reference): + (WebCore::ReferenceFilterOperation::operator==): + (WebCore::ReferenceFilterOperation::ReferenceFilterOperation): + (WebCore::BasicColorMatrixFilterOperation::create): + (WebCore::BasicColorMatrixFilterOperation::amount): + (WebCore::BasicColorMatrixFilterOperation::operator==): + (WebCore::BasicColorMatrixFilterOperation::BasicColorMatrixFilterOperation): + (WebCore::BasicComponentTransferFilterOperation::create): + (WebCore::BasicComponentTransferFilterOperation::amount): + (WebCore::BasicComponentTransferFilterOperation::operator==): + (WebCore::BasicComponentTransferFilterOperation::BasicComponentTransferFilterOperation): + (WebCore::GammaFilterOperation::create): + (WebCore::GammaFilterOperation::amplitude): + (WebCore::GammaFilterOperation::exponent): + (WebCore::GammaFilterOperation::offset): + (WebCore::GammaFilterOperation::operator==): + (WebCore::GammaFilterOperation::GammaFilterOperation): + (WebCore::BlurFilterOperation::create): + (WebCore::BlurFilterOperation::stdDeviationX): + (WebCore::BlurFilterOperation::stdDeviationY): + (WebCore::BlurFilterOperation::operator==): + (WebCore::BlurFilterOperation::BlurFilterOperation): + (WebCore::SharpenFilterOperation::create): + (WebCore::SharpenFilterOperation::radius): + (WebCore::SharpenFilterOperation::threshold): + (WebCore::SharpenFilterOperation::amount): + (WebCore::SharpenFilterOperation::operator==): + (WebCore::SharpenFilterOperation::SharpenFilterOperation): + (WebCore::DropShadowFilterOperation::create): + (WebCore::DropShadowFilterOperation::shadow): + (WebCore::DropShadowFilterOperation::operator==): + (WebCore::DropShadowFilterOperation::DropShadowFilterOperation): + * platform/graphics/filters/FilterOperations.cpp: Added. + (WebCore::FilterOperations::FilterOperations): + (WebCore::FilterOperations::operator==): + * platform/graphics/filters/FilterOperations.h: Added. + (WebCore::FilterOperations::operator!=): + (WebCore::FilterOperations::clear): + (WebCore::FilterOperations::operations): + (WebCore::FilterOperations::size): + (WebCore::FilterOperations::at): + * rendering/style/RenderStyle.cpp: + (WebCore::RenderStyle::RenderStyle): + * rendering/style/RenderStyle.h: + (WebCore::InheritedFlags::filter): + (WebCore::InheritedFlags::hasFilter): + (WebCore::InheritedFlags::setFilter): + (WebCore::InheritedFlags::initialFilter): + * rendering/style/StyleAllInOne.cpp: Added include of new StyleFilterData. + * rendering/style/StyleFilterData.cpp: Added. + (WebCore::StyleFilterData::StyleFilterData): + (WebCore::StyleFilterData::operator==): + * rendering/style/StyleFilterData.h: Added. + (WebCore::StyleFilterData::create): + (WebCore::StyleFilterData::copy): + (WebCore::StyleFilterData::operator!=): + * rendering/style/StyleRareNonInheritedData.cpp: + (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): + (WebCore::StyleRareNonInheritedData::operator==): + * rendering/style/StyleRareNonInheritedData.h: New filter DataRef. + 2011-09-27 James Robinson [chromium] LayerRenderChromium asserts about leaking textures. diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am index 03b97b7..7436ecf 100644 --- a/Source/WebCore/GNUmakefile.list.am +++ b/Source/WebCore/GNUmakefile.list.am @@ -2482,9 +2482,12 @@ webcore_sources += \ Source/WebCore/platform/graphics/filters/FETile.h \ Source/WebCore/platform/graphics/filters/FETurbulence.cpp \ Source/WebCore/platform/graphics/filters/FETurbulence.h \ + Source/WebCore/platform/graphics/filters/Filter.h \ Source/WebCore/platform/graphics/filters/FilterEffect.cpp \ Source/WebCore/platform/graphics/filters/FilterEffect.h \ - Source/WebCore/platform/graphics/filters/Filter.h \ + Source/WebCore/platform/graphics/filters/FilterOperation.h \ + Source/WebCore/platform/graphics/filters/FilterOperations.cpp \ + Source/WebCore/platform/graphics/filters/FilterOperations.h \ Source/WebCore/platform/graphics/filters/LightSource.cpp \ Source/WebCore/platform/graphics/filters/LightSource.h \ Source/WebCore/platform/graphics/filters/PointLightSource.cpp \ @@ -3169,6 +3172,8 @@ webcore_sources += \ Source/WebCore/rendering/style/StyleDashboardRegion.h \ Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp \ Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h \ + Source/WebCore/rendering/style/StyleFilterData.cpp \ + Source/WebCore/rendering/style/StyleFilterData.h \ Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp \ Source/WebCore/rendering/style/StyleFlexibleBoxData.h \ Source/WebCore/rendering/style/StyleGeneratedImage.cpp \ diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index be0a943..bee98c3 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -936,6 +936,7 @@ 'rendering/style/StyleCachedImage.h', 'rendering/style/StyleDashboardRegion.h', 'rendering/style/StyleDeprecatedFlexibleBoxData.h', + 'rendering/style/StyleFilterData.h', 'rendering/style/StyleFlexibleBoxData.h', 'rendering/style/StyleGeneratedImage.h', 'rendering/style/StyleImage.h', @@ -3570,6 +3571,9 @@ 'platform/graphics/filters/Filter.h', 'platform/graphics/filters/FilterEffect.cpp', 'platform/graphics/filters/FilterEffect.h', + 'platform/graphics/filters/FilterOperation.h', + 'platform/graphics/filters/FilterOperations.cpp', + 'platform/graphics/filters/FilterOperations.h', 'platform/graphics/filters/LightSource.cpp', 'platform/graphics/filters/LightSource.h', 'platform/graphics/filters/PointLightSource.cpp', @@ -4677,6 +4681,7 @@ 'rendering/style/StyleBoxData.cpp', 'rendering/style/StyleCachedImage.cpp', 'rendering/style/StyleDeprecatedFlexibleBoxData.cpp', + 'rendering/style/StyleFilterData.cpp', 'rendering/style/StyleFlexibleBoxData.cpp', 'rendering/style/StyleGeneratedImage.cpp', 'rendering/style/StyleInheritedData.cpp', diff --git a/Source/WebCore/WebCore.pro b/Source/WebCore/WebCore.pro index dfd1afa..79ae403 100644 --- a/Source/WebCore/WebCore.pro +++ b/Source/WebCore/WebCore.pro @@ -1199,6 +1199,7 @@ SOURCES += \ rendering/style/StyleBoxData.cpp \ rendering/style/StyleCachedImage.cpp \ rendering/style/StyleDeprecatedFlexibleBoxData.cpp \ + rendering/style/StyleFilterData.cpp \ rendering/style/StyleFlexibleBoxData.cpp \ rendering/style/StyleGeneratedImage.cpp \ rendering/style/StyleInheritedData.cpp \ @@ -1991,6 +1992,8 @@ HEADERS += \ platform/graphics/filters/FETile.h \ platform/graphics/filters/FETurbulence.h \ platform/graphics/filters/FilterEffect.h \ + platform/graphics/filters/FilterOperation.h \ + platform/graphics/filters/FilterOperations.h \ platform/graphics/filters/LightSource.h \ platform/graphics/filters/SourceAlpha.h \ platform/graphics/filters/SourceGraphic.h \ @@ -2269,6 +2272,7 @@ HEADERS += \ rendering/style/StyleBoxData.h \ rendering/style/StyleCachedImage.h \ rendering/style/StyleDeprecatedFlexibleBoxData.h \ + rendering/style/StyleFilterData.h \ rendering/style/StyleFlexibleBoxData.h \ rendering/style/StyleGeneratedImage.h \ rendering/style/StyleInheritedData.h \ @@ -3208,6 +3212,7 @@ contains(DEFINES, ENABLE_FILTERS=1) { platform/graphics/filters/FETile.cpp \ platform/graphics/filters/FETurbulence.cpp \ platform/graphics/filters/FilterEffect.cpp \ + platform/graphics/filters/FilterOperations.cpp \ platform/graphics/filters/LightSource.cpp \ platform/graphics/filters/PointLightSource.cpp \ platform/graphics/filters/SpotLightSource.cpp \ diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj index e09ab3f..a11b47e 100755 --- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj @@ -30168,6 +30168,18 @@ > + + + + + + @@ -40915,6 +40927,62 @@ > + + + + + + + + + + + + + + + + + + + + + + +#include +#include +#include + +namespace WebCore { + +// CSS Filters + +class FilterOperation : public RefCounted { +public: + enum OperationType { + REFERENCE, // url(#somefilter) + GRAYSCALE, + SEPIA, + SATURATE, + HUE_ROTATE, + INVERT, + OPACITY, + GAMMA, + BLUR, + SHARPEN, + DROP_SHADOW, + NONE + }; + + virtual ~FilterOperation() { } + + virtual bool operator==(const FilterOperation&) const = 0; + bool operator!=(const FilterOperation& o) const { return !(*this == o); } + + virtual OperationType getOperationType() const { return m_type; } + virtual bool isSameType(const FilterOperation& o) const { return o.getOperationType() == m_type; } + +protected: + FilterOperation(OperationType type) + : m_type(type) + { + } + + OperationType m_type; +}; + +// Each of the individual operations are provided here. Once they actually +// have code to apply their effect they'll move to separate files. +// At the moment we're just storing the data for roundtripping. + +class ReferenceFilterOperation : public FilterOperation { +public: + static PassRefPtr create(const AtomicString& reference, OperationType type) + { + return adoptRef(new ReferenceFilterOperation(reference, type)); + } + + const AtomicString& reference() const { return m_reference; } + +private: + + virtual bool operator==(const FilterOperation& o) const + { + if (!isSameType(o)) + return false; + const ReferenceFilterOperation* other = static_cast(&o); + return m_reference == other->m_reference; + } + + ReferenceFilterOperation(const AtomicString& reference, OperationType type) + : FilterOperation(type) + , m_reference(reference) + { + } + + AtomicString m_reference; +}; + +// GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color matrix effect. +// For HUE_ROTATE, the angle of rotation is stored in m_amount. + +class BasicColorMatrixFilterOperation : public FilterOperation { +public: + static PassRefPtr create(double amount, OperationType type) + { + return adoptRef(new BasicColorMatrixFilterOperation(amount, type)); + } + + double amount() const { return m_amount; } + +private: + + virtual bool operator==(const FilterOperation& o) const + { + if (!isSameType(o)) + return false; + const BasicColorMatrixFilterOperation* other = static_cast(&o); + return m_amount == other->m_amount; + } + + BasicColorMatrixFilterOperation(double amount, OperationType type) + : FilterOperation(type) + , m_amount(amount) + { + } + + double m_amount; +}; + +// INVERT and OPACITY are variations on a basic component transfer effect. + +class BasicComponentTransferFilterOperation : public FilterOperation { +public: + static PassRefPtr create(double amount, OperationType type) + { + return adoptRef(new BasicComponentTransferFilterOperation(amount, type)); + } + + double amount() const { return m_amount; } + +private: + + virtual bool operator==(const FilterOperation& o) const + { + if (!isSameType(o)) + return false; + const BasicComponentTransferFilterOperation* other = static_cast(&o); + return m_amount == other->m_amount; + } + + BasicComponentTransferFilterOperation(double amount, OperationType type) + : FilterOperation(type) + , m_amount(amount) + { + } + + double m_amount; +}; + +class GammaFilterOperation : public FilterOperation { +public: + static PassRefPtr create(double amplitude, double exponent, double offset, OperationType type) + { + return adoptRef(new GammaFilterOperation(amplitude, exponent, offset, type)); + } + + double amplitude() const { return m_amplitude; } + double exponent() const { return m_exponent; } + double offset() const { return m_offset; } + +private: + + virtual bool operator==(const FilterOperation& o) const + { + if (!isSameType(o)) + return false; + const GammaFilterOperation* other = static_cast(&o); + return m_amplitude == other->m_amplitude && m_exponent == other->m_exponent && m_offset == other->m_offset; + } + + GammaFilterOperation(double amplitude, double exponent, double offset, OperationType type) + : FilterOperation(type) + , m_amplitude(amplitude) + , m_exponent(exponent) + , m_offset(offset) + { + } + + double m_amplitude; + double m_exponent; + double m_offset; +}; + +class BlurFilterOperation : public FilterOperation { +public: + static PassRefPtr create(double stdDeviationX, double stdDeviationY, OperationType type) + { + return adoptRef(new BlurFilterOperation(stdDeviationX, stdDeviationY, type)); + } + + double stdDeviationX() const { return m_stdDeviationX; } + double stdDeviationY() const { return m_stdDeviationY; } + +private: + + virtual bool operator==(const FilterOperation& o) const + { + if (!isSameType(o)) + return false; + const BlurFilterOperation* other = static_cast(&o); + return m_stdDeviationX == other->m_stdDeviationX && m_stdDeviationY == other->m_stdDeviationY; + } + + BlurFilterOperation(double stdDeviationX, double stdDeviationY, OperationType type) + : FilterOperation(type) + , m_stdDeviationX(stdDeviationX) + , m_stdDeviationY(stdDeviationY) + { + } + + double m_stdDeviationX; + double m_stdDeviationY; +}; + +class SharpenFilterOperation : public FilterOperation { +public: + static PassRefPtr create(double radius, double threshold, double amount, OperationType type) + { + return adoptRef(new SharpenFilterOperation(radius, threshold, amount, type)); + } + + double radius() const { return m_radius; } + double threshold() const { return m_threshold; } + double amount() const { return m_amount; } + +private: + + virtual bool operator==(const FilterOperation& o) const + { + if (!isSameType(o)) + return false; + const SharpenFilterOperation* other = static_cast(&o); + return m_radius == other->m_radius && m_threshold == other->m_threshold && m_amount == other->m_amount; + } + + SharpenFilterOperation(double radius, double threshold, double amount, OperationType type) + : FilterOperation(type) + , m_radius(radius) + , m_threshold(threshold) + , m_amount(amount) + { + } + + double m_radius; + double m_threshold; + double m_amount; +}; + +class DropShadowFilterOperation : public FilterOperation { +public: + static PassRefPtr create(PassOwnPtr shadow, OperationType type) + { + return adoptRef(new DropShadowFilterOperation(shadow, type)); + } + + const ShadowData* shadow() const { return m_shadow.get(); } + +private: + + virtual bool operator==(const FilterOperation& o) const + { + if (!isSameType(o)) + return false; + const DropShadowFilterOperation* other = static_cast(&o); + return *m_shadow == *(other->m_shadow); + } + + DropShadowFilterOperation(PassOwnPtr shadow, OperationType type) + : FilterOperation(type) + , m_shadow(shadow) + { + } + + OwnPtr m_shadow; +}; + +} // namespace WebCore + +#endif // ENABLE(CSS_FILTERS) + +#endif // FilterOperation_h diff --git a/Source/WebCore/platform/graphics/filters/FilterOperations.cpp b/Source/WebCore/platform/graphics/filters/FilterOperations.cpp new file mode 100644 index 0000000..727852b --- /dev/null +++ b/Source/WebCore/platform/graphics/filters/FilterOperations.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011 Apple 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 COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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 "FilterOperations.h" + +#if ENABLE(CSS_FILTERS) + +namespace WebCore { + +FilterOperations::FilterOperations() +{ +} + +bool FilterOperations::operator==(const FilterOperations& o) const +{ + if (m_operations.size() != o.m_operations.size()) + return false; + + unsigned s = m_operations.size(); + for (unsigned i = 0; i < s; i++) { + if (*m_operations[i] != *o.m_operations[i]) + return false; + } + + return true; +} + +} // namespace WebCore + +#endif // ENABLE(CSS_FILTERS) diff --git a/Source/WebCore/platform/graphics/filters/FilterOperations.h b/Source/WebCore/platform/graphics/filters/FilterOperations.h new file mode 100644 index 0000000..2eba829 --- /dev/null +++ b/Source/WebCore/platform/graphics/filters/FilterOperations.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2011 Apple 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 COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#ifndef FilterOperations_h +#define FilterOperations_h + +#if ENABLE(CSS_FILTERS) + +#include "FilterOperation.h" +#include +#include + +namespace WebCore { + +class FilterOperations { + WTF_MAKE_FAST_ALLOCATED; +public: + FilterOperations(); + + bool operator==(const FilterOperations&) const; + bool operator!=(const FilterOperations& o) const + { + return !(*this == o); + } + + void clear() + { + m_operations.clear(); + } + + Vector >& operations() { return m_operations; } + const Vector >& operations() const { return m_operations; } + + size_t size() const { return m_operations.size(); } + const FilterOperation* at(size_t index) const { return index < m_operations.size() ? m_operations.at(index).get() : 0; } + +private: + Vector > m_operations; +}; + +} // namespace WebCore + +#endif // ENABLE(CSS_FILTERS) + +#endif // FilterOperations_h diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp index 4050766..6c0d385 100644 --- a/Source/WebCore/rendering/style/RenderStyle.cpp +++ b/Source/WebCore/rendering/style/RenderStyle.cpp @@ -125,6 +125,9 @@ ALWAYS_INLINE RenderStyle::RenderStyle(bool) rareNonInheritedData.access()->m_marquee.init(); rareNonInheritedData.access()->m_multiCol.init(); rareNonInheritedData.access()->m_transform.init(); +#if ENABLE(CSS_FILTERS) + rareNonInheritedData.access()->m_filter.init(); +#endif rareInheritedData.init(); inherited.init(); diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index 05d19ac..d15a3e2 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -35,6 +35,9 @@ #include "CounterDirectives.h" #include "DataRef.h" #include "FillLayer.h" +#if ENABLE(CSS_FILTERS) +#include "FilterOperations.h" +#endif #include "Font.h" #include "GraphicsTypes.h" #include "Length.h" @@ -49,6 +52,9 @@ #include "StyleBackgroundData.h" #include "StyleBoxData.h" #include "StyleDeprecatedFlexibleBoxData.h" +#if ENABLE(CSS_FILTERS) +#include "StyleFilterData.h" +#endif #include "StyleFlexibleBoxData.h" #include "StyleInheritedData.h" #include "StyleMarqueeData.h" @@ -841,6 +847,11 @@ public: EImageRendering imageRendering() const { return static_cast(rareInheritedData->m_imageRendering); } ESpeak speak() { return static_cast(rareInheritedData->speak); } + +#if ENABLE(CSS_FILTERS) + const FilterOperations& filter() const { return rareNonInheritedData->m_filter->m_operations; } + bool hasFilter() const { return !rareNonInheritedData->m_filter->m_operations.operations().isEmpty(); } +#endif // attribute setter methods @@ -1161,6 +1172,11 @@ public: void setTextEmphasisMark(TextEmphasisMark mark) { SET_VAR(rareInheritedData, textEmphasisMark, mark); } void setTextEmphasisCustomMark(const AtomicString& mark) { SET_VAR(rareInheritedData, textEmphasisCustomMark, mark); } void setTextEmphasisPosition(TextEmphasisPosition position) { SET_VAR(rareInheritedData, textEmphasisPosition, position); } + +#if ENABLE(CSS_FILTERS) + void setFilter(const FilterOperations& ops) { SET_VAR(rareNonInheritedData.access()->m_filter, m_operations, ops); } +#endif + // End CSS3 Setters void setFlowThread(const AtomicString& flowThread) { SET_VAR(rareNonInheritedData, m_flowThread, flowThread); } @@ -1454,7 +1470,9 @@ public: static const Vector& initialDashboardRegions(); static const Vector& noneDashboardRegions(); #endif - +#if ENABLE(CSS_FILTERS) + static const FilterOperations& initialFilter() { DEFINE_STATIC_LOCAL(FilterOperations, ops, ()); return ops; } +#endif private: void inheritUnicodeBidiFrom(const RenderStyle* parent) { noninherited_flags._unicodeBidi = parent->noninherited_flags._unicodeBidi; } void getShadowExtent(const ShadowData*, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const; diff --git a/Source/WebCore/rendering/style/StyleAllInOne.cpp b/Source/WebCore/rendering/style/StyleAllInOne.cpp index 4db420c..2238a6b 100644 --- a/Source/WebCore/rendering/style/StyleAllInOne.cpp +++ b/Source/WebCore/rendering/style/StyleAllInOne.cpp @@ -39,6 +39,7 @@ #include "StyleBoxData.cpp" #include "StyleCachedImage.cpp" #include "StyleDeprecatedFlexibleBoxData.cpp" +#include "StyleFilterData.cpp" #include "StyleFlexibleBoxData.cpp" #include "StyleGeneratedImage.cpp" #include "StyleInheritedData.cpp" diff --git a/Source/WebCore/rendering/style/StyleFilterData.cpp b/Source/WebCore/rendering/style/StyleFilterData.cpp new file mode 100644 index 0000000..edc7cfd --- /dev/null +++ b/Source/WebCore/rendering/style/StyleFilterData.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011 Apple 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 COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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 "StyleFilterData.h" + +#if ENABLE(CSS_FILTERS) + +#include "RenderStyle.h" + +namespace WebCore { + +StyleFilterData::StyleFilterData() + : m_operations() +{ +} + +StyleFilterData::StyleFilterData(const StyleFilterData& o) + : RefCounted() + , m_operations(o.m_operations) +{ +} + +bool StyleFilterData::operator==(const StyleFilterData& o) const +{ + return m_operations == o.m_operations; +} + +} // namespace WebCore + +#endif // ENABLE(CSS_FILTERS) diff --git a/Source/WebCore/rendering/style/StyleFilterData.h b/Source/WebCore/rendering/style/StyleFilterData.h new file mode 100644 index 0000000..16b102e --- /dev/null +++ b/Source/WebCore/rendering/style/StyleFilterData.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2011 Apple 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 COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#ifndef StyleFilterData_h +#define StyleFilterData_h + +#if ENABLE(CSS_FILTERS) + +#include "FilterOperations.h" +#include +#include + +namespace WebCore { + +class StyleFilterData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleFilterData); } + PassRefPtr copy() const { return adoptRef(new StyleFilterData(*this)); } + + bool operator==(const StyleFilterData&) const; + bool operator!=(const StyleFilterData& o) const + { + return !(*this == o); + } + + FilterOperations m_operations; + +private: + StyleFilterData(); + StyleFilterData(const StyleFilterData&); +}; + +} // namespace WebCore + +#endif // ENABLE(CSS_FILTERS) + +#endif // StyleFilterData_h diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp index f3b8017..7bc6681 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp @@ -27,6 +27,8 @@ #include "RenderCounter.h" #include "RenderStyle.h" #include "ShadowData.h" +#include "StyleFilterData.h" +#include "StyleTransformData.h" #include "StyleImage.h" namespace WebCore { @@ -78,6 +80,9 @@ StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInherited , m_marquee(o.m_marquee) , m_multiCol(o.m_multiCol) , m_transform(o.m_transform) +#if ENABLE(CSS_FILTERS) + , m_filter(o.m_filter) +#endif , m_content(o.m_content ? o.m_content->clone() : nullptr) , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr) , userDrag(o.userDrag) @@ -135,6 +140,9 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c && m_marquee == o.m_marquee && m_multiCol == o.m_multiCol && m_transform == o.m_transform +#if ENABLE(CSS_FILTERS) + && m_filter == o.m_filter +#endif && contentDataEquivalent(o) && counterDataEquivalent(o) && userDrag == o.userDrag diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h index 21a4207..d938e0d 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h @@ -32,7 +32,6 @@ #include "FillLayer.h" #include "LineClampValue.h" #include "NinePieceImage.h" -#include "StyleTransformData.h" #include #include #include @@ -43,6 +42,9 @@ class AnimationList; class CSSStyleSelector; class ShadowData; class StyleDeprecatedFlexibleBoxData; +#if ENABLE(CSS_FILTERS) +class StyleFilterData; +#endif class StyleFlexibleBoxData; class StyleMarqueeData; class StyleMultiColData; @@ -99,6 +101,10 @@ public: DataRef m_multiCol; // CSS3 multicol properties DataRef m_transform; // Transform properties (rotate, scale, skew, etc.) +#if ENABLE(CSS_FILTERS) + DataRef m_filter; // Filter operations (url, sepia, blur, etc.) +#endif + OwnPtr m_content; OwnPtr m_counterDirectives; -- 2.7.4