Diff
Modified: trunk/Source/WebCore/ChangeLog (210468 => 210469)
--- trunk/Source/WebCore/ChangeLog 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/ChangeLog 2017-01-07 05:23:54 UTC (rev 210469)
@@ -1,3 +1,87 @@
+2017-01-05 Darin Adler <[email protected]>
+
+ Remove PassRefPtr use from "rendering" directory, other improvements
+ https://bugs.webkit.org/show_bug.cgi?id=166717
+
+ Reviewed by Sam Weinig.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::shapePropertyValue): Use auto.
+ * css/CSSFilterImageValue.cpp:
+ (WebCore::CSSFilterImageValue::image): Use auto. Pass references.
+ (WebCore::CSSFilterImageValue::filterImageChanged): Use modern for loop.
+
+ * css/StyleBuilderConverter.h:
+ (WebCore::StyleBuilderConverter::convertShapeValue): Use overloaded
+ ShapeValue::create function instead of differently named functions.
+ * page/animation/CSSPropertyAnimation.cpp:
+ (WebCore::blendFunc): Ditto.
+
+ * platform/graphics/filters/Filter.h: Added a protected constructor that takes
+ a filter resolution.
+
+ * rendering/FilterEffectRenderer.cpp:
+ (WebCore::FilterEffectRenderer::FilterEffectRenderer): Use new constructor so
+ we don't have to call setFilterResolution and can initialize m_sourceGraphic.
+ (WebCore::FilterEffectRenderer::create): Moved here from the header.
+ (WebCore::FilterEffectRenderer::buildReferenceFilter): Take references and not
+ PssRefPtr. Use auto and references.
+ (WebCore::FilterEffectRenderer::build): Take a reference. Updated to work with
+ references rather than pointer. Use auto.
+ (WebCore::FilterEffectRenderer::allocateBackingStoreIfNeeded): Use early return.
+ (WebCore::FilterEffectRenderer::clearIntermediateResults): Use modern for loop.
+ (WebCore::FilterEffectRenderer::apply): Use references.
+ (WebCore::FilterEffectRenderer::output): Moved here from header.
+ (WebCore::FilterEffectRenderer::setMaxEffectRects): Moved here from header.
+ (WebCore::FilterEffectRenderer::outputRect): Moved here from header.
+ (WebCore::FilterEffectRendererHelper::prepareFilterEffect): Take references.
+ (WebCore::FilterEffectRendererHelper::beginFilterEffect): Use auto and references.
+ (WebCore::FilterEffectRendererHelper::applyFilterEffect): Ditto.
+ * rendering/FilterEffectRenderer.h: Updated for the above changes. Made a lot more
+ things private.
+
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::filterPainter): Added. Helper so setupFilters does not
+ have to do things twice.
+ (WebCore::RenderLayer::hasFilterThatIsPainting): Updated to call filterPainter.
+ (WebCore::RenderLayer::setupFilters): Ditto.
+ (WebCore::RenderLayer::calculateClipRects): Pass reference.
+ * rendering/RenderLayer.h: Updated for the above changes.
+
+ * rendering/style/ContentData.cpp:
+ (WebCore::ContentData::clone): Use auto.
+ (WebCore::ImageContentData::createContentRenderer): Updated for reference.
+ * rendering/style/ContentData.h: Use Ref&& instead of PassRefPtr. Made more
+ things private.
+
+ * rendering/style/NinePieceImage.cpp:
+ (WebCore::NinePieceImage::defaultData): Made this a static member so it can
+ get at the now-private class NinePieceImage::Data.
+ (WebCore::NinePieceImage::NinePieceImage): Use RefPtr&& instead of PassRefPtr.
+ Use construction instead of calling m_data.access() over and over again.
+ (WebCore::NinePieceImage::Data::Data): Renamed from NinePieceImageData.
+ Moved initialization to class definition. Added a new overload for the normal
+ creation case.
+ (WebCore::NinePieceImage::Data::create): Ditto.
+ (WebCore::NinePieceImage::Data::copy): Ditto.
+ (WebCore::NinePieceImage::Data::operator==): Ditto.
+ * rendering/style/NinePieceImage.h: Cut down on includes. Moved the class
+ named NinePieceImageData in to become the private struct NinePieceImage::Data.
+
+ * rendering/style/RenderStyle.cpp:
+ (WebCore::RenderStyle::setContent): Pass Ref&& instead of RefPtr&& when
+ creating ImageContentData.
+
+ * rendering/style/ShapeValue.cpp:
+ (WebCore::ShapeValue::isImageValid): Tighten up by using data member directly
+ and using a local variabel.
+ (WebCore::pointersOrValuesEqual): Deleted.
+ (WebCore::ShapeValue::operator==): Use arePointingToEqualData instead the
+ above deleted function template. Wrote as a single return statement for clarity.
+ * rendering/style/ShapeValue.h: Changed all the create function names to just
+ create, using overloading instead of separate names. Use Ref&& instead of PassRefPtr.
+ Removed unused constructor that took a type but no data.
+
2017-01-06 Chris Dumez <[email protected]>
Regression(r189230): DOM Callbacks may use wrong global object
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (210468 => 210469)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -2433,11 +2433,11 @@
ASSERT(shapeValue->type() == ShapeValue::Type::Shape);
- RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+ auto list = CSSValueList::createSpaceSeparated();
list->append(valueForBasicShape(style, *shapeValue->shape()));
if (shapeValue->cssBox() != BoxMissing)
list->append(CSSValuePool::singleton().createValue(shapeValue->cssBox()));
- return list.releaseNonNull();
+ return WTFMove(list);
}
static Ref<CSSValueList> valueForItemPositionWithOverflowAlignment(const StyleSelfAlignmentData& data)
Modified: trunk/Source/WebCore/css/CSSFilterImageValue.cpp (210468 => 210469)
--- trunk/Source/WebCore/css/CSSFilterImageValue.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/css/CSSFilterImageValue.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -33,6 +33,7 @@
#include "CachedSVGDocumentReference.h"
#include "CrossfadeGeneratedImage.h"
#include "FilterEffectRenderer.h"
+#include "GraphicsContext.h"
#include "ImageBuffer.h"
#include "RenderElement.h"
#include "StyleCachedImage.h"
@@ -109,6 +110,8 @@
RefPtr<Image> CSSFilterImageValue::image(RenderElement* renderer, const FloatSize& size)
{
+ ASSERT(renderer);
+
if (size.isEmpty())
return nullptr;
@@ -115,32 +118,28 @@
// FIXME: Skip Content Security Policy check when filter is applied to an element in a user agent shadow tree.
// See <https://bugs.webkit.org/show_bug.cgi?id=146663>.
ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-
- CachedResourceLoader& cachedResourceLoader = renderer->document().cachedResourceLoader();
- CachedImage* cachedImage = cachedImageForCSSValue(m_imageValue, cachedResourceLoader, options);
-
+ auto* cachedImage = cachedImageForCSSValue(m_imageValue, renderer->document().cachedResourceLoader(), options);
if (!cachedImage)
return Image::nullImage();
- Image* image = cachedImage->imageForRenderer(renderer);
-
+ auto* image = cachedImage->imageForRenderer(renderer);
if (!image)
return Image::nullImage();
// Transform Image into ImageBuffer.
// FIXME (149424): This buffer should not be unconditionally unaccelerated.
- std::unique_ptr<ImageBuffer> texture = ImageBuffer::create(size, Unaccelerated);
+ auto texture = ImageBuffer::create(size, Unaccelerated);
if (!texture)
return Image::nullImage();
- FloatRect imageRect = FloatRect(FloatPoint(), size);
+ auto imageRect = FloatRect { { }, size };
texture->context().drawImage(*image, imageRect);
- RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::create();
+ auto filterRenderer = FilterEffectRenderer::create();
filterRenderer->setSourceImage(WTFMove(texture));
filterRenderer->setSourceImageRect(imageRect);
filterRenderer->setFilterRegion(imageRect);
- if (!filterRenderer->build(renderer, m_filterOperations, FilterFunction))
+ if (!filterRenderer->build(*renderer, m_filterOperations, FilterFunction))
return Image::nullImage();
filterRenderer->apply();
@@ -149,8 +148,8 @@
void CSSFilterImageValue::filterImageChanged(const IntRect&)
{
- for (auto it = clients().begin(), end = clients().end(); it != end; ++it)
- it->key->imageChanged(static_cast<WrappedImagePtr>(this));
+ for (auto& client : clients())
+ client.key->imageChanged(static_cast<WrappedImagePtr>(this));
}
void CSSFilterImageValue::createFilterOperations(StyleResolver* resolver)
Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (210468 => 210469)
--- trunk/Source/WebCore/css/StyleBuilderConverter.h 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h 2017-01-07 05:23:54 UTC (rev 210469)
@@ -766,7 +766,7 @@
}
if (isImageShape(value))
- return ShapeValue::createImageValue(styleResolver.styleImage(value));
+ return ShapeValue::create(styleResolver.styleImage(value));
RefPtr<BasicShape> shape;
CSSBoxType referenceBox = BoxMissing;
@@ -786,10 +786,10 @@
}
if (shape)
- return ShapeValue::createShapeValue(WTFMove(shape), referenceBox);
+ return ShapeValue::create(WTFMove(shape), referenceBox);
if (referenceBox != BoxMissing)
- return ShapeValue::createBoxShapeValue(referenceBox);
+ return ShapeValue::create(referenceBox);
ASSERT_NOT_REACHED();
return nullptr;
Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (210468 => 210469)
--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -161,7 +161,7 @@
if (!fromShape.canBlend(toShape))
return to;
- return ShapeValue::createShapeValue(toShape.blend(fromShape, progress), to->cssBox());
+ return ShapeValue::create(toShape.blend(fromShape, progress), to->cssBox());
}
static inline PassRefPtr<FilterOperation> blendFunc(const AnimationBase* animation, FilterOperation* fromOp, FilterOperation* toOp, double progress, bool blendToPassthrough = false)
@@ -365,8 +365,7 @@
if (from.image()->imageSize(anim->renderer(), 1.0) != to.image()->imageSize(anim->renderer(), 1.0))
return to;
- RefPtr<StyleImage> newContentImage = blendFunc(anim, from.image(), to.image(), progress);
-
+ auto newContentImage = blendFunc(anim, from.image(), to.image(), progress);
return NinePieceImage(newContentImage, from.imageSlices(), from.fill(), from.borderSlices(), from.outset(), from.horizontalRule(), from.verticalRule());
}
Modified: trunk/Source/WebCore/platform/graphics/filters/Filter.h (210468 => 210469)
--- trunk/Source/WebCore/platform/graphics/filters/Filter.h 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/platform/graphics/filters/Filter.h 2017-01-07 05:23:54 UTC (rev 210469)
@@ -18,13 +18,10 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef Filter_h
-#define Filter_h
+#pragma once
-#include "FloatRect.h"
#include "FloatSize.h"
#include "ImageBuffer.h"
-#include <wtf/RefCounted.h>
namespace WebCore {
@@ -32,7 +29,6 @@
public:
Filter(const AffineTransform& absoluteTransform, float filterScale = 1)
: m_absoluteTransform(absoluteTransform)
- , m_renderingMode(Unaccelerated)
, m_filterScale(filterScale)
{ }
virtual ~Filter() { }
@@ -60,14 +56,18 @@
virtual FloatRect sourceImageRect() const = 0;
virtual FloatRect filterRegion() const = 0;
+protected:
+ explicit Filter(const FloatSize& filterResolution)
+ : m_filterResolution(filterResolution)
+ {
+ }
+
private:
std::unique_ptr<ImageBuffer> m_sourceImage;
FloatSize m_filterResolution;
AffineTransform m_absoluteTransform;
- RenderingMode m_renderingMode;
- float m_filterScale;
+ RenderingMode m_renderingMode { Unaccelerated };
+ float m_filterScale { 1 };
};
} // namespace WebCore
-
-#endif // Filter_h
Modified: trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp (210468 => 210469)
--- trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,8 +29,6 @@
#include "CachedSVGDocument.h"
#include "CachedSVGDocumentReference.h"
-#include "ColorSpace.h"
-#include "Document.h"
#include "ElementIterator.h"
#include "FEColorMatrix.h"
#include "FEComponentTransfer.h"
@@ -37,11 +35,11 @@
#include "FEDropShadow.h"
#include "FEGaussianBlur.h"
#include "FEMerge.h"
-#include "FloatConversion.h"
-#include "Frame.h"
#include "RenderLayer.h"
#include "SVGElement.h"
+#include "SVGFilterBuilder.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SourceGraphic.h"
#include <algorithm>
#include <wtf/MathExtras.h>
@@ -66,13 +64,17 @@
parameters.append(0);
}
-FilterEffectRenderer::FilterEffectRenderer()
- : Filter(AffineTransform())
+inline FilterEffectRenderer::FilterEffectRenderer()
+ : Filter(FloatSize { 1, 1 })
+ , m_sourceGraphic(SourceGraphic::create(*this))
{
- setFilterResolution(FloatSize(1, 1));
- m_sourceGraphic = SourceGraphic::create(*this);
}
+Ref<FilterEffectRenderer> FilterEffectRenderer::create()
+{
+ return adoptRef(*new FilterEffectRenderer);
+}
+
FilterEffectRenderer::~FilterEffectRenderer()
{
}
@@ -82,36 +84,34 @@
return sourceImage() ? &sourceImage()->context() : nullptr;
}
-RefPtr<FilterEffect> FilterEffectRenderer::buildReferenceFilter(RenderElement* renderer, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation* filterOperation)
+RefPtr<FilterEffect> FilterEffectRenderer::buildReferenceFilter(RenderElement& renderer, FilterEffect& previousEffect, ReferenceFilterOperation& filterOperation)
{
- if (!renderer)
- return nullptr;
+ auto* cachedSVGDocumentReference = filterOperation.cachedSVGDocumentReference();
+ auto* cachedSVGDocument = cachedSVGDocumentReference ? cachedSVGDocumentReference->document() : nullptr;
- Document* document = &renderer->document();
-
- CachedSVGDocumentReference* cachedSVGDocumentReference = filterOperation->cachedSVGDocumentReference();
- CachedSVGDocument* cachedSVGDocument = cachedSVGDocumentReference ? cachedSVGDocumentReference->document() : 0;
-
// If we have an SVG document, this is an external reference. Otherwise
// we look up the referenced node in the current document.
- if (cachedSVGDocument)
+ Document* document;
+ if (!cachedSVGDocument)
+ document = &renderer.document();
+ else {
document = cachedSVGDocument->document();
+ if (!document)
+ return nullptr;
+ }
- if (!document)
- return nullptr;
-
- Element* filter = document->getElementById(filterOperation->fragment());
+ auto* filter = document->getElementById(filterOperation.fragment());
if (!filter) {
// Although we did not find the referenced filter, it might exist later in the document.
// FIXME: This skips anonymous RenderObjects. <https://webkit.org/b/131085>
- if (Element* element = renderer->element())
- document->accessSVGExtensions().addPendingResource(filterOperation->fragment(), element);
+ if (auto* element = renderer.element())
+ document->accessSVGExtensions().addPendingResource(filterOperation.fragment(), element);
return nullptr;
}
RefPtr<FilterEffect> effect;
- auto builder = std::make_unique<SVGFilterBuilder>(previousEffect);
+ auto builder = std::make_unique<SVGFilterBuilder>(&previousEffect);
for (auto& effectElement : childrenOfType<SVGFilterPrimitiveStandardAttributes>(*filter)) {
effect = effectElement.build(builder.get(), *this);
@@ -120,12 +120,12 @@
effectElement.setStandardAttributes(effect.get());
builder->add(effectElement.result(), effect);
- m_effects.append(effect);
+ m_effects.append(*effect);
}
return effect;
}
-bool FilterEffectRenderer::build(RenderElement* renderer, const FilterOperations& operations, FilterConsumer consumer)
+bool FilterEffectRenderer::build(RenderElement& renderer, const FilterOperations& operations, FilterConsumer consumer)
{
m_hasFilterThatMovesPixels = operations.hasFilterThatMovesPixels();
if (m_hasFilterThatMovesPixels)
@@ -133,19 +133,19 @@
m_effects.clear();
- RefPtr<FilterEffect> previousEffect = m_sourceGraphic;
- for (size_t i = 0; i < operations.operations().size(); ++i) {
+ RefPtr<FilterEffect> previousEffect = m_sourceGraphic.ptr();
+ for (auto& operation : operations.operations()) {
RefPtr<FilterEffect> effect;
- FilterOperation& filterOperation = *operations.operations().at(i);
+ auto& filterOperation = *operation;
switch (filterOperation.type()) {
case FilterOperation::REFERENCE: {
- ReferenceFilterOperation& referenceOperation = downcast<ReferenceFilterOperation>(filterOperation);
- effect = buildReferenceFilter(renderer, previousEffect, &referenceOperation);
+ auto& referenceOperation = downcast<ReferenceFilterOperation>(filterOperation);
+ effect = buildReferenceFilter(renderer, *previousEffect, referenceOperation);
referenceOperation.setFilterEffect(effect);
break;
}
case FilterOperation::GRAYSCALE: {
- BasicColorMatrixFilterOperation& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
+ auto& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
Vector<float> inputParameters;
double _oneMinusAmount_ = clampTo(1 - colorMatrixOperation.amount(), 0.0, 1.0);
@@ -173,7 +173,7 @@
break;
}
case FilterOperation::SEPIA: {
- BasicColorMatrixFilterOperation& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
+ auto& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
Vector<float> inputParameters;
double _oneMinusAmount_ = clampTo(1 - colorMatrixOperation.amount(), 0.0, 1.0);
@@ -201,7 +201,7 @@
break;
}
case FilterOperation::SATURATE: {
- BasicColorMatrixFilterOperation& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
+ auto& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
Vector<float> inputParameters;
inputParameters.append(narrowPrecisionToFloat(colorMatrixOperation.amount()));
effect = FEColorMatrix::create(*this, FECOLORMATRIX_TYPE_SATURATE, inputParameters);
@@ -208,7 +208,7 @@
break;
}
case FilterOperation::HUE_ROTATE: {
- BasicColorMatrixFilterOperation& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
+ auto& colorMatrixOperation = downcast<BasicColorMatrixFilterOperation>(filterOperation);
Vector<float> inputParameters;
inputParameters.append(narrowPrecisionToFloat(colorMatrixOperation.amount()));
effect = FEColorMatrix::create(*this, FECOLORMATRIX_TYPE_HUEROTATE, inputParameters);
@@ -215,7 +215,7 @@
break;
}
case FilterOperation::INVERT: {
- BasicComponentTransferFilterOperation& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
+ auto& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
ComponentTransferFunction transferFunction;
transferFunction.type = FECOMPONENTTRANSFER_TYPE_TABLE;
Vector<float> transferParameters;
@@ -228,7 +228,7 @@
break;
}
case FilterOperation::OPACITY: {
- BasicComponentTransferFilterOperation& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
+ auto& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
ComponentTransferFunction transferFunction;
transferFunction.type = FECOMPONENTTRANSFER_TYPE_TABLE;
Vector<float> transferParameters;
@@ -241,7 +241,7 @@
break;
}
case FilterOperation::BRIGHTNESS: {
- BasicComponentTransferFilterOperation& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
+ auto& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
ComponentTransferFunction transferFunction;
transferFunction.type = FECOMPONENTTRANSFER_TYPE_LINEAR;
transferFunction.slope = narrowPrecisionToFloat(componentTransferOperation.amount());
@@ -252,7 +252,7 @@
break;
}
case FilterOperation::CONTRAST: {
- BasicComponentTransferFilterOperation& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
+ auto& componentTransferOperation = downcast<BasicComponentTransferFilterOperation>(filterOperation);
ComponentTransferFunction transferFunction;
transferFunction.type = FECOMPONENTTRANSFER_TYPE_LINEAR;
float amount = narrowPrecisionToFloat(componentTransferOperation.amount());
@@ -264,13 +264,13 @@
break;
}
case FilterOperation::BLUR: {
- BlurFilterOperation& blurOperation = downcast<BlurFilterOperation>(filterOperation);
+ auto& blurOperation = downcast<BlurFilterOperation>(filterOperation);
float stdDeviation = floatValueForLength(blurOperation.stdDeviation(), 0);
effect = FEGaussianBlur::create(*this, stdDeviation, stdDeviation, consumer == FilterProperty ? EDGEMODE_NONE : EDGEMODE_DUPLICATE);
break;
}
case FilterOperation::DROP_SHADOW: {
- DropShadowFilterOperation& dropShadowOperation = downcast<DropShadowFilterOperation>(filterOperation);
+ auto& dropShadowOperation = downcast<DropShadowFilterOperation>(filterOperation);
effect = FEDropShadow::create(*this, dropShadowOperation.stdDeviation(), dropShadowOperation.stdDeviation(),
dropShadowOperation.x(), dropShadowOperation.y(), dropShadowOperation.color(), 1);
break;
@@ -286,19 +286,18 @@
effect->setOperatingColorSpace(ColorSpaceSRGB);
if (filterOperation.type() != FilterOperation::REFERENCE) {
- effect->inputEffects().append(previousEffect);
- m_effects.append(effect);
+ effect->inputEffects().append(WTFMove(previousEffect));
+ m_effects.append(*effect);
}
previousEffect = WTFMove(effect);
}
}
- // If we didn't make any effects, tell our caller we are not valid
- if (!m_effects.size())
+ // If we didn't make any effects, tell our caller we are not valid.
+ if (m_effects.isEmpty())
return false;
setMaxEffectRects(m_sourceDrawingRegion);
-
return true;
}
@@ -319,38 +318,40 @@
// At this point the effect chain has been built, and the
// source image sizes set. We just need to attach the graphic
// buffer if we have not yet done so.
- if (!m_graphicsBufferAttached) {
- IntSize logicalSize(m_sourceDrawingRegion.width(), m_sourceDrawingRegion.height());
- if (!sourceImage() || sourceImage()->logicalSize() != logicalSize) {
+
+ if (m_graphicsBufferAttached)
+ return;
+
+ IntSize logicalSize { m_sourceDrawingRegion.size() };
+ if (!sourceImage() || sourceImage()->logicalSize() != logicalSize) {
#if USE(DIRECT2D)
- setSourceImage(ImageBuffer::create(logicalSize, renderingMode(), &targetContext, filterScale()));
+ setSourceImage(ImageBuffer::create(logicalSize, renderingMode(), &targetContext, filterScale()));
#else
- UNUSED_PARAM(targetContext);
- setSourceImage(ImageBuffer::create(logicalSize, renderingMode(), filterScale()));
+ UNUSED_PARAM(targetContext);
+ setSourceImage(ImageBuffer::create(logicalSize, renderingMode(), filterScale()));
#endif
- }
- m_graphicsBufferAttached = true;
}
+ m_graphicsBufferAttached = true;
}
void FilterEffectRenderer::clearIntermediateResults()
{
m_sourceGraphic->clearResult();
- for (size_t i = 0; i < m_effects.size(); ++i)
- m_effects[i]->clearResult();
+ for (auto& effect : m_effects)
+ effect->clearResult();
}
void FilterEffectRenderer::apply()
{
- RefPtr<FilterEffect> effect = lastEffect();
- effect->apply();
- effect->transformResultColorSpace(ColorSpaceSRGB);
+ auto& effect = m_effects.last().get();
+ effect.apply();
+ effect.transformResultColorSpace(ColorSpaceSRGB);
}
LayoutRect FilterEffectRenderer::computeSourceImageRectForDirtyRect(const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect)
{
// The result of this function is the area in the "filterBoxRect" that needs to be repainted, so that we fully cover the "dirtyRect".
- LayoutRect rectForRepaint = dirtyRect;
+ auto rectForRepaint = dirtyRect;
if (hasFilterThatMovesPixels()) {
// Note that the outsets are reversed here because we are going backwards -> we have the dirty rect and
// need to find out what is the rectangle that might influence the result inside that dirty rect.
@@ -361,31 +362,55 @@
return rectForRepaint;
}
-bool FilterEffectRendererHelper::prepareFilterEffect(RenderLayer* renderLayer, const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect, const LayoutRect& layerRepaintRect)
+ImageBuffer* FilterEffectRenderer::output() const
{
- ASSERT(m_haveFilterEffect && renderLayer->filterRenderer());
- m_renderLayer = renderLayer;
- m_repaintRect = dirtyRect;
+ return const_cast<FilterEffect&>(m_effects.last().get()).asImageBuffer();
+}
- FilterEffectRenderer* filter = renderLayer->filterRenderer();
- LayoutRect filterSourceRect = filter->computeSourceImageRectForDirtyRect(filterBoxRect, dirtyRect);
- m_paintOffset = filterSourceRect.location();
+void FilterEffectRenderer::setMaxEffectRects(const FloatRect& effectRect)
+{
+ for (auto& effect : m_effects)
+ effect->setMaxEffectRect(effectRect);
+}
+IntRect FilterEffectRenderer::outputRect() const
+{
+ auto& lastEffect = const_cast<FilterEffect&>(m_effects.last().get());
+ if (!lastEffect.hasResult())
+ return { };
+ return lastEffect.requestedRegionOfInputImageData(IntRect { m_filterRegion });
+}
+
+bool FilterEffectRendererHelper::prepareFilterEffect(RenderLayer& layer, const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect, const LayoutRect& layerRepaintRect)
+{
+ ASSERT(m_haveFilterEffect);
+ ASSERT(layer.filterRenderer());
+
+ auto& filter = *layer.filterRenderer();
+ auto filterSourceRect = filter.computeSourceImageRectForDirtyRect(filterBoxRect, dirtyRect);
+
if (filterSourceRect.isEmpty()) {
// The dirty rect is not in view, just bail out.
m_haveFilterEffect = false;
return false;
}
-
- bool hasUpdatedBackingStore = filter->updateBackingStoreRect(filterSourceRect);
- if (filter->hasFilterThatMovesPixels()) {
+
+ bool hasUpdatedBackingStore = filter.updateBackingStoreRect(filterSourceRect);
+
+ m_renderLayer = &layer;
+ if (!filter.hasFilterThatMovesPixels())
+ m_repaintRect = dirtyRect;
+ else {
if (hasUpdatedBackingStore)
m_repaintRect = filterSourceRect;
else {
+ m_repaintRect = dirtyRect;
m_repaintRect.unite(layerRepaintRect);
m_repaintRect.intersect(filterSourceRect);
}
}
+ m_paintOffset = filterSourceRect.location();
+
return true;
}
@@ -393,25 +418,24 @@
{
if (!m_haveFilterEffect)
return nullptr;
-
- FilterEffectRenderer* filter = m_renderLayer->filterRenderer();
- return filter->inputContext();
+ return m_renderLayer->filterRenderer()->inputContext();
}
bool FilterEffectRendererHelper::beginFilterEffect()
{
ASSERT(m_renderLayer);
-
- FilterEffectRenderer* filter = m_renderLayer->filterRenderer();
- filter->allocateBackingStoreIfNeeded(m_targetContext);
+ ASSERT(m_renderLayer->filterRenderer());
+
+ auto& filter = *m_renderLayer->filterRenderer();
+ filter.allocateBackingStoreIfNeeded(m_targetContext);
// Paint into the context that represents the SourceGraphic of the filter.
- GraphicsContext* sourceGraphicsContext = filter->inputContext();
- if (!sourceGraphicsContext || filter->filterRegion().isEmpty() || ImageBuffer::sizeNeedsClamping(filter->filterRegion().size())) {
+ auto* sourceGraphicsContext = filter.inputContext();
+ if (!sourceGraphicsContext || filter.filterRegion().isEmpty() || ImageBuffer::sizeNeedsClamping(filter.filterRegion().size())) {
// Disable the filters and continue.
m_haveFilterEffect = false;
return false;
}
-
+
// Translate the context so that the contents of the layer is captured in the offscreen memory buffer.
sourceGraphicsContext->save();
sourceGraphicsContext->translate(-m_paintOffset.x(), -m_paintOffset.y());
@@ -424,20 +448,24 @@
void FilterEffectRendererHelper::applyFilterEffect(GraphicsContext& destinationContext)
{
- ASSERT(m_haveFilterEffect && m_renderLayer->filterRenderer());
- FilterEffectRenderer* filter = m_renderLayer->filterRenderer();
- filter->inputContext()->restore();
+ ASSERT(m_haveFilterEffect);
+ ASSERT(m_renderLayer);
+ ASSERT(m_renderLayer->filterRenderer());
+ ASSERT(m_renderLayer->filterRenderer()->inputContext());
- filter->apply();
-
+ auto& filter = *m_renderLayer->filterRenderer();
+ filter.inputContext()->restore();
+
+ filter.apply();
+
// Get the filtered output and draw it in place.
- LayoutRect destRect = filter->outputRect();
+ LayoutRect destRect = filter.outputRect();
destRect.move(m_paintOffset.x(), m_paintOffset.y());
- if (ImageBuffer* outputBuffer = filter->output())
+ if (auto* outputBuffer = filter.output())
destinationContext.drawImageBuffer(*outputBuffer, snapRectToDevicePixels(destRect, m_renderLayer->renderer().document().deviceScaleFactor()));
- filter->clearIntermediateResults();
+ filter.clearIntermediateResults();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/FilterEffectRenderer.h (210468 => 210469)
--- trunk/Source/WebCore/rendering/FilterEffectRenderer.h 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/FilterEffectRenderer.h 2017-01-07 05:23:54 UTC (rev 210469)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,45 +26,31 @@
#pragma once
#include "Filter.h"
-#include "FilterEffect.h"
-#include "FilterOperations.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "ImageBuffer.h"
#include "IntRectExtent.h"
#include "LayoutRect.h"
-#include "SVGFilterBuilder.h"
-#include "SourceGraphic.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
namespace WebCore {
class Document;
+class FilterEffect;
+class FilterOperations;
class GraphicsContext;
+class ReferenceFilterOperation;
class RenderElement;
class RenderLayer;
+class SourceGraphic;
-typedef Vector<RefPtr<FilterEffect>> FilterEffectList;
+enum FilterConsumer { FilterProperty, FilterFunction };
-enum FilterConsumer {
- FilterProperty,
- FilterFunction
-};
-
class FilterEffectRendererHelper {
WTF_MAKE_FAST_ALLOCATED;
public:
- FilterEffectRendererHelper(bool haveFilterEffect, GraphicsContext& targetContext)
- : m_targetContext(targetContext)
- , m_haveFilterEffect(haveFilterEffect)
- {
- }
-
+ FilterEffectRendererHelper(bool haveFilterEffect, GraphicsContext& targetContext);
+
bool haveFilterEffect() const { return m_haveFilterEffect; }
bool hasStartedFilterEffect() const { return m_startedFilterEffect; }
- bool prepareFilterEffect(RenderLayer*, const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect, const LayoutRect& layerRepaintRect);
+ bool prepareFilterEffect(RenderLayer&, const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect, const LayoutRect& layerRepaintRect);
bool beginFilterEffect();
void applyFilterEffect(GraphicsContext& destinationContext);
@@ -84,63 +70,47 @@
class FilterEffectRenderer final : public Filter {
WTF_MAKE_FAST_ALLOCATED;
public:
- static RefPtr<FilterEffectRenderer> create()
- {
- return adoptRef(new FilterEffectRenderer);
- }
+ friend class FilterEffectRendererHelper;
- void setSourceImageRect(const FloatRect& sourceImageRect)
- {
- m_sourceDrawingRegion = sourceImageRect;
- setMaxEffectRects(sourceImageRect);
- setFilterRegion(sourceImageRect);
- m_graphicsBufferAttached = false;
- }
- FloatRect sourceImageRect() const override { return m_sourceDrawingRegion; }
+ static Ref<FilterEffectRenderer> create();
+ void setSourceImageRect(const FloatRect&);
void setFilterRegion(const FloatRect& filterRegion) { m_filterRegion = filterRegion; }
- FloatRect filterRegion() const override { return m_filterRegion; }
- GraphicsContext* inputContext();
- ImageBuffer* output() const { return lastEffect()->asImageBuffer(); }
+ ImageBuffer* output() const;
- bool build(RenderElement*, const FilterOperations&, FilterConsumer);
- RefPtr<FilterEffect> buildReferenceFilter(RenderElement*, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation*);
- bool updateBackingStoreRect(const FloatRect& filterRect);
- void allocateBackingStoreIfNeeded(const GraphicsContext&);
+ bool build(RenderElement&, const FilterOperations&, FilterConsumer);
void clearIntermediateResults();
void apply();
-
- IntRect outputRect() const { return lastEffect()->hasResult() ? lastEffect()->requestedRegionOfInputImageData(IntRect(m_filterRegion)) : IntRect(); }
bool hasFilterThatMovesPixels() const { return m_hasFilterThatMovesPixels; }
- LayoutRect computeSourceImageRectForDirtyRect(const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect);
private:
- void setMaxEffectRects(const FloatRect& effectRect)
- {
- for (size_t i = 0; i < m_effects.size(); ++i) {
- RefPtr<FilterEffect> effect = m_effects.at(i);
- effect->setMaxEffectRect(effectRect);
- }
- }
+ FilterEffectRenderer();
+ virtual ~FilterEffectRenderer();
- FilterEffect* lastEffect() const
- {
- if (!m_effects.isEmpty())
- return m_effects.last().get();
- return nullptr;
- }
+ FloatRect sourceImageRect() const final { return m_sourceDrawingRegion; }
+ FloatRect filterRegion() const final { return m_filterRegion; }
- FilterEffectRenderer();
- virtual ~FilterEffectRenderer();
-
+ RefPtr<FilterEffect> buildReferenceFilter(RenderElement&, FilterEffect& previousEffect, ReferenceFilterOperation&);
+
+ void setMaxEffectRects(const FloatRect&);
+
+ GraphicsContext* inputContext();
+
+ bool updateBackingStoreRect(const FloatRect& filterRect);
+ void allocateBackingStoreIfNeeded(const GraphicsContext&);
+
+ IntRect outputRect() const;
+
+ LayoutRect computeSourceImageRectForDirtyRect(const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect);
+
FloatRect m_sourceDrawingRegion;
FloatRect m_filterRegion;
-
- FilterEffectList m_effects;
- RefPtr<SourceGraphic> m_sourceGraphic;
-
+
+ Vector<Ref<FilterEffect>> m_effects;
+ Ref<SourceGraphic> m_sourceGraphic;
+
IntRectExtent m_outsets;
bool m_graphicsBufferAttached { false };
@@ -147,4 +117,18 @@
bool m_hasFilterThatMovesPixels { false };
};
+inline FilterEffectRendererHelper::FilterEffectRendererHelper(bool haveFilterEffect, GraphicsContext& targetContext)
+ : m_targetContext(targetContext)
+ , m_haveFilterEffect(haveFilterEffect)
+{
+}
+
+inline void FilterEffectRenderer::setSourceImageRect(const FloatRect& sourceImageRect)
+{
+ m_sourceDrawingRegion = sourceImageRect;
+ setMaxEffectRects(sourceImageRect);
+ setFilterRegion(sourceImageRect);
+ m_graphicsBufferAttached = false;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (210468 => 210469)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
*
* Portions are Copyright (C) 1998 Netscape Communications Corporation.
*
@@ -459,13 +459,13 @@
{
if (!paintsWithFilters())
return false;
- FilterEffectRenderer* renderer = filterRenderer();
+ auto* renderer = filterRenderer();
return renderer && renderer->hasFilterThatMovesPixels();
}
FilterEffectRenderer* RenderLayer::filterRenderer() const
{
- FilterInfo* filterInfo = FilterInfo::getIfExists(*this);
+ auto* filterInfo = FilterInfo::getIfExists(*this);
return filterInfo ? filterInfo->renderer() : nullptr;
}
@@ -4184,36 +4184,43 @@
return false;
}
-bool RenderLayer::hasFilterThatIsPainting(GraphicsContext& context, PaintLayerFlags paintFlags) const
+std::pair<RenderLayer::FilterInfo*, std::unique_ptr<FilterEffectRendererHelper>> RenderLayer::filterPainter(GraphicsContext& context, PaintLayerFlags paintFlags) const
{
if (context.paintingDisabled())
- return false;
+ return { };
if (paintFlags & PaintLayerPaintingOverlayScrollbars)
- return false;
+ return { };
- FilterInfo* filterInfo = FilterInfo::getIfExists(*this);
- bool hasPaintedFilter = filterInfo && filterInfo->renderer() && paintsWithFilters();
- if (!hasPaintedFilter)
- return false;
+ if (!paintsWithFilters())
+ return { };
- auto filterPainter = std::make_unique<FilterEffectRendererHelper>(hasPaintedFilter, context);
- if (!filterPainter->haveFilterEffect())
- return false;
+ auto* info = FilterInfo::getIfExists(*this);
+ if (!info || !info->renderer())
+ return { };
- return true;
+ auto helper = std::make_unique<FilterEffectRendererHelper>(true, context);
+ if (!helper->haveFilterEffect())
+ return { };
+
+ return { info, WTFMove(helper) };
}
+bool RenderLayer::hasFilterThatIsPainting(GraphicsContext& context, PaintLayerFlags paintFlags) const
+{
+ return !!filterPainter(context, paintFlags).first;
+}
+
std::unique_ptr<FilterEffectRendererHelper> RenderLayer::setupFilters(GraphicsContext& context, LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed)
{
- if (!hasFilterThatIsPainting(context, paintFlags))
+ auto painter = filterPainter(context, paintFlags);
+ if (!painter.first)
return nullptr;
- FilterInfo* filterInfo = FilterInfo::getIfExists(*this);
- bool hasPaintedFilter = filterInfo && filterInfo->renderer() && paintsWithFilters();
- auto filterPainter = std::make_unique<FilterEffectRendererHelper>(hasPaintedFilter, context);
+ auto& filterInfo = *painter.first;
+ auto& filterPainter = *painter.second;
- LayoutRect filterRepaintRect = filterInfo->dirtySourceRect();
+ LayoutRect filterRepaintRect = filterInfo.dirtySourceRect();
filterRepaintRect.move(offsetFromRoot);
if (!rootRelativeBoundsComputed) {
@@ -4221,24 +4228,23 @@
rootRelativeBoundsComputed = true;
}
- if (filterPainter->prepareFilterEffect(this, enclosingIntRect(rootRelativeBounds), enclosingIntRect(paintingInfo.paintDirtyRect), enclosingIntRect(filterRepaintRect))) {
- // Now we know for sure, that the source image will be updated, so we can revert our tracking repaint rect back to zero.
- filterInfo->resetDirtySourceRect();
+ if (!filterPainter.prepareFilterEffect(*this, enclosingIntRect(rootRelativeBounds), enclosingIntRect(paintingInfo.paintDirtyRect), enclosingIntRect(filterRepaintRect)))
+ return nullptr;
- if (!filterPainter->beginFilterEffect())
- return nullptr;
+ // Now we know for sure that the source image will be updated, so we can revert our tracking repaint rect back to zero.
+ filterInfo.resetDirtySourceRect();
- // Check that we didn't fail to allocate the graphics context for the offscreen buffer.
- ASSERT(filterPainter->hasStartedFilterEffect());
+ if (!filterPainter.beginFilterEffect())
+ return nullptr;
- paintingInfo.paintDirtyRect = filterPainter->repaintRect();
- // If the filter needs the full source image, we need to avoid using the clip rectangles.
- // Otherwise, if for example this layer has overflow:hidden, a drop shadow will not compute correctly.
- // Note that we will still apply the clipping on the final rendering of the filter.
- paintingInfo.clipToDirtyRect = !filterInfo->renderer()->hasFilterThatMovesPixels();
- return filterPainter;
- }
- return nullptr;
+ paintingInfo.paintDirtyRect = filterPainter.repaintRect();
+
+ // If the filter needs the full source image, we need to avoid using the clip rectangles.
+ // Otherwise, if for example this layer has overflow:hidden, a drop shadow will not compute correctly.
+ // Note that we will still apply the clipping on the final rendering of the filter.
+ paintingInfo.clipToDirtyRect = !filterInfo.renderer()->hasFilterThatMovesPixels();
+
+ return WTFMove(painter.second);
}
void RenderLayer::applyFilters(FilterEffectRendererHelper* filterPainter, GraphicsContext& originalContext, const LayerPaintingInfo& paintingInfo, const LayerFragments& layerFragments)
@@ -7007,7 +7013,7 @@
// If the filter fails to build, remove it from the layer. It will still attempt to
// go through regular processing (e.g. compositing), but never apply anything.
- if (!filterInfo.renderer()->build(&renderer(), renderer().style().filter(), FilterProperty))
+ if (!filterInfo.renderer()->build(renderer(), renderer().style().filter(), FilterProperty))
filterInfo.setRenderer(nullptr);
}
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (210468 => 210469)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2017-01-07 05:23:54 UTC (rev 210469)
@@ -783,6 +783,8 @@
bool setupClipPath(GraphicsContext&, const LayerPaintingInfo&, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed);
+ class FilterInfo;
+ std::pair<FilterInfo*, std::unique_ptr<FilterEffectRendererHelper>> filterPainter(GraphicsContext&, PaintLayerFlags) const;
bool hasFilterThatIsPainting(GraphicsContext&, PaintLayerFlags) const;
std::unique_ptr<FilterEffectRendererHelper> setupFilters(GraphicsContext&, LayerPaintingInfo&, PaintLayerFlags, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed);
void applyFilters(FilterEffectRendererHelper*, GraphicsContext& originalContext, const LayerPaintingInfo&, const LayerFragments&);
@@ -1148,8 +1150,6 @@
IntRect m_blockSelectionGapsBounds;
std::unique_ptr<RenderLayerBacking> m_backing;
-
- class FilterInfo;
};
inline void RenderLayer::clearZOrderLists()
Modified: trunk/Source/WebCore/rendering/style/ContentData.cpp (210468 => 210469)
--- trunk/Source/WebCore/rendering/style/ContentData.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/style/ContentData.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999 Antti Koivisto ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -36,20 +36,18 @@
std::unique_ptr<ContentData> ContentData::clone() const
{
auto result = cloneInternal();
-
- ContentData* lastNewData = result.get();
- for (const ContentData* contentData = next(); contentData; contentData = contentData->next()) {
+ auto* lastNewData = result.get();
+ for (auto* contentData = next(); contentData; contentData = contentData->next()) {
auto newData = contentData->cloneInternal();
lastNewData->setNext(WTFMove(newData));
lastNewData = lastNewData->next();
}
-
return result;
}
RenderPtr<RenderObject> ImageContentData::createContentRenderer(Document& document, const RenderStyle& pseudoStyle) const
{
- auto image = createRenderer<RenderImage>(document, RenderStyle::createStyleInheritingFromPseudoStyle(pseudoStyle), m_image.get());
+ auto image = createRenderer<RenderImage>(document, RenderStyle::createStyleInheritingFromPseudoStyle(pseudoStyle), const_cast<StyleImage*>(m_image.ptr()));
image->initializeStyle();
image->setAltText(altText());
return WTFMove(image);
Modified: trunk/Source/WebCore/rendering/style/ContentData.h (210468 => 210469)
--- trunk/Source/WebCore/rendering/style/ContentData.h 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/style/ContentData.h 2017-01-07 05:23:54 UTC (rev 210469)
@@ -2,7 +2,7 @@
* Copyright (C) 2000 Lars Knoll ([email protected])
* (C) 2000 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
- * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis ([email protected])
*
* This library is free software; you can redistribute it and/or
@@ -79,37 +79,33 @@
class ImageContentData final : public ContentData {
public:
- explicit ImageContentData(PassRefPtr<StyleImage> image)
+ explicit ImageContentData(Ref<StyleImage>&& image)
: ContentData(ImageDataType)
- , m_image(image)
+ , m_image(WTFMove(image))
{
- ASSERT(m_image);
}
- const StyleImage& image() const { return *m_image; }
- void setImage(PassRefPtr<StyleImage> image)
+ const StyleImage& image() const { return m_image.get(); }
+ void setImage(Ref<StyleImage>&& image)
{
- ASSERT(image);
- m_image = image;
+ m_image = WTFMove(image);
}
- RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
-
private:
- std::unique_ptr<ContentData> cloneInternal() const override
+ RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const final;
+ std::unique_ptr<ContentData> cloneInternal() const final
{
- std::unique_ptr<ContentData> image = std::make_unique<ImageContentData>(m_image.get());
+ auto image = std::make_unique<ImageContentData>(m_image.copyRef());
image->setAltText(altText());
-
- return image;
+ return WTFMove(image);
}
- RefPtr<StyleImage> m_image;
+ Ref<StyleImage> m_image;
};
inline bool operator==(const ImageContentData& a, const ImageContentData& b)
{
- return a.image() == b.image();
+ return &a.image() == &b.image();
}
inline bool operator!=(const ImageContentData& a, const ImageContentData& b)
@@ -128,10 +124,9 @@
const String& text() const { return m_text; }
void setText(const String& text) { m_text = text; }
- RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
-
private:
- std::unique_ptr<ContentData> cloneInternal() const override { return std::make_unique<TextContentData>(text()); }
+ RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const final;
+ std::unique_ptr<ContentData> cloneInternal() const final { return std::make_unique<TextContentData>(text()); }
String m_text;
};
@@ -162,13 +157,11 @@
m_counter = WTFMove(counter);
}
- RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
-
private:
- std::unique_ptr<ContentData> cloneInternal() const override
+ RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const final;
+ std::unique_ptr<ContentData> cloneInternal() const final
{
- auto counterData = std::make_unique<CounterContent>(counter());
- return std::make_unique<CounterContentData>(WTFMove(counterData));
+ return std::make_unique<CounterContentData>(std::make_unique<CounterContent>(counter()));
}
std::unique_ptr<CounterContent> m_counter;
@@ -195,10 +188,9 @@
QuoteType quote() const { return m_quote; }
void setQuote(QuoteType quote) { m_quote = quote; }
- RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
-
private:
- std::unique_ptr<ContentData> cloneInternal() const override { return std::make_unique<QuoteContentData>(quote()); }
+ RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const final;
+ std::unique_ptr<ContentData> cloneInternal() const final { return std::make_unique<QuoteContentData>(quote()); }
QuoteType m_quote;
};
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.cpp (210468 => 210469)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -2,7 +2,7 @@
* Copyright (C) 2000 Lars Knoll ([email protected])
* (C) 2000 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
- * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -33,9 +33,9 @@
namespace WebCore {
-static DataRef<NinePieceImageData>& defaultData()
+inline DataRef<NinePieceImage::Data>& NinePieceImage::defaultData()
{
- static NeverDestroyed<DataRef<NinePieceImageData>> data(NinePieceImageData::create());
+ static NeverDestroyed<DataRef<Data>> data { Data::create() };
return data.get();
}
@@ -44,16 +44,9 @@
{
}
-NinePieceImage::NinePieceImage(PassRefPtr<StyleImage> image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule)
- : m_data(NinePieceImageData::create())
+NinePieceImage::NinePieceImage(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule)
+ : m_data(Data::create(WTFMove(image), imageSlices, fill, borderSlices, outset, horizontalRule, verticalRule))
{
- m_data.access()->image = image;
- m_data.access()->imageSlices = WTFMove(imageSlices);
- m_data.access()->borderSlices = WTFMove(borderSlices);
- m_data.access()->outset = WTFMove(outset);
- m_data.access()->fill = fill;
- m_data.access()->horizontalRule = horizontalRule;
- m_data.access()->verticalRule = verticalRule;
}
LayoutUnit NinePieceImage::computeSlice(Length length, LayoutUnit width, LayoutUnit slice, LayoutUnit extent)
@@ -195,7 +188,8 @@
void NinePieceImage::paint(GraphicsContext& graphicsContext, RenderElement* renderer, const RenderStyle& style, const LayoutRect& destination, const LayoutSize& source, float deviceScaleFactor, CompositeOperator op) const
{
StyleImage* styleImage = image();
- ASSERT(styleImage && styleImage->isLoaded());
+ ASSERT(styleImage);
+ ASSERT(styleImage->isLoaded());
LayoutBoxExtent sourceSlices = computeSlices(source, imageSlices(), styleImage->imageScaleFactor());
LayoutBoxExtent destinationSlices = computeSlices(destination.size(), borderSlices(), style.borderWidth(), sourceSlices);
@@ -225,19 +219,26 @@
}
}
-NinePieceImageData::NinePieceImageData()
+inline NinePieceImage::Data::Data()
: fill(false)
, horizontalRule(StretchImageRule)
, verticalRule(StretchImageRule)
- , image(nullptr)
- , imageSlices(Length(100, Percent), Length(100, Percent), Length(100, Percent), Length(100, Percent))
- , borderSlices(Length(1, Relative), Length(1, Relative), Length(1, Relative), Length(1, Relative))
- , outset(0)
{
}
-inline NinePieceImageData::NinePieceImageData(const NinePieceImageData& other)
- : RefCounted<NinePieceImageData>()
+inline NinePieceImage::Data::Data(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule)
+ : fill(fill)
+ , horizontalRule(horizontalRule)
+ , verticalRule(verticalRule)
+ , image(WTFMove(image))
+ , imageSlices(imageSlices)
+ , borderSlices(borderSlices)
+ , outset(outset)
+{
+}
+
+inline NinePieceImage::Data::Data(const Data& other)
+ : RefCounted<Data>()
, fill(other.fill)
, horizontalRule(other.horizontalRule)
, verticalRule(other.verticalRule)
@@ -248,13 +249,23 @@
{
}
-Ref<NinePieceImageData> NinePieceImageData::copy() const
+inline Ref<NinePieceImage::Data> NinePieceImage::Data::create()
{
- return adoptRef(*new NinePieceImageData(*this));
+ return adoptRef(*new Data);
}
-bool NinePieceImageData::operator==(const NinePieceImageData& other) const
+inline Ref<NinePieceImage::Data> NinePieceImage::Data::create(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule)
{
+ return adoptRef(*new Data(WTFMove(image), imageSlices, fill, borderSlices, outset, horizontalRule, verticalRule));
+}
+
+Ref<NinePieceImage::Data> NinePieceImage::Data::copy() const
+{
+ return adoptRef(*new Data(*this));
+}
+
+bool NinePieceImage::Data::operator==(const Data& other) const
+{
return arePointingToEqualData(image, other.image)
&& imageSlices == other.imageSlices
&& fill == other.fill
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.h (210468 => 210469)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.h 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.h 2017-01-07 05:23:54 UTC (rev 210469)
@@ -2,7 +2,7 @@
* Copyright (C) 2000 Lars Knoll ([email protected])
* (C) 2000 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
- * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -24,9 +24,6 @@
#pragma once
#include "DataRef.h"
-#include "LayoutRect.h"
-#include "LayoutSize.h"
-#include "LayoutUnit.h"
#include "LengthBox.h"
#include "StyleImage.h"
#include <wtf/Vector.h>
@@ -33,10 +30,12 @@
namespace WebCore {
-enum ENinePieceImageRule {
- StretchImageRule, RoundImageRule, SpaceImageRule, RepeatImageRule
-};
+class LayoutSize;
+class LayoutRect;
+class RenderStyle;
+enum ENinePieceImageRule { StretchImageRule, RoundImageRule, SpaceImageRule, RepeatImageRule };
+
enum ImagePiece {
MinPiece = 0,
TopLeftPiece = MinPiece,
@@ -99,33 +98,10 @@
return NilSide;
}
-class RenderStyle;
-
-class NinePieceImageData : public RefCounted<NinePieceImageData> {
-public:
- static Ref<NinePieceImageData> create() { return adoptRef(*new NinePieceImageData); }
- Ref<NinePieceImageData> copy() const;
-
- bool operator==(const NinePieceImageData&) const;
- bool operator!=(const NinePieceImageData& o) const { return !(*this == o); }
-
- bool fill : 1;
- unsigned horizontalRule : 2; // ENinePieceImageRule
- unsigned verticalRule : 2; // ENinePieceImageRule
- RefPtr<StyleImage> image;
- LengthBox imageSlices;
- LengthBox borderSlices;
- LengthBox outset;
-
-private:
- NinePieceImageData();
- NinePieceImageData(const NinePieceImageData&);
-};
-
class NinePieceImage {
public:
NinePieceImage();
- NinePieceImage(PassRefPtr<StyleImage>, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule);
+ NinePieceImage(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule);
bool operator==(const NinePieceImage& other) const { return m_data == other.m_data; }
bool operator!=(const NinePieceImage& other) const { return m_data != other.m_data; }
@@ -132,8 +108,8 @@
bool hasImage() const { return m_data->image; }
StyleImage* image() const { return m_data->image.get(); }
- void setImage(PassRefPtr<StyleImage> image) { m_data.access()->image = image; }
-
+ void setImage(RefPtr<StyleImage>&& image) { m_data.access()->image = WTFMove(image); }
+
const LengthBox& imageSlices() const { return m_data->imageSlices; }
void setImageSlices(LengthBox slices) { m_data.access()->imageSlices = WTFMove(slices); }
@@ -206,7 +182,31 @@
void paint(GraphicsContext&, RenderElement*, const RenderStyle&, const LayoutRect& destination, const LayoutSize& source, float deviceScaleFactor, CompositeOperator) const;
private:
- DataRef<NinePieceImageData> m_data;
+ struct Data : RefCounted<Data> {
+ static Ref<Data> create();
+ static Ref<Data> create(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule);
+ Ref<Data> copy() const;
+
+ bool operator==(const Data&) const;
+ bool operator!=(const Data& other) const { return !(*this == other); }
+
+ bool fill : 1;
+ unsigned horizontalRule : 2; // ENinePieceImageRule
+ unsigned verticalRule : 2; // ENinePieceImageRule
+ RefPtr<StyleImage> image;
+ LengthBox imageSlices { { 100, Percent }, { 100, Percent }, { 100, Percent }, { 100, Percent } };
+ LengthBox borderSlices { { 1, Relative }, { 1, Relative }, { 1, Relative }, { 1, Relative } };
+ LengthBox outset { 0 };
+
+ private:
+ Data();
+ Data(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule);
+ Data(const Data&);
+ };
+
+ static DataRef<Data>& defaultData();
+
+ DataRef<Data> m_data;
};
TextStream& operator<<(TextStream&, const NinePieceImage&);
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (210468 => 210469)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -1012,11 +1012,11 @@
return;
if (add) {
- appendContent(std::make_unique<ImageContentData>(image));
+ appendContent(std::make_unique<ImageContentData>(image.releaseNonNull()));
return;
}
- rareNonInheritedData.access()->m_content = std::make_unique<ImageContentData>(WTFMove(image));
+ rareNonInheritedData.access()->m_content = std::make_unique<ImageContentData>(image.releaseNonNull());
if (!rareNonInheritedData.access()->m_altText.isNull())
rareNonInheritedData.access()->m_content->setAltText(rareNonInheritedData.access()->m_altText);
}
Modified: trunk/Source/WebCore/rendering/style/ShapeValue.cpp (210468 => 210469)
--- trunk/Source/WebCore/rendering/style/ShapeValue.cpp 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/style/ShapeValue.cpp 2017-01-07 05:23:54 UTC (rev 210469)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,42 +24,30 @@
*/
#include "config.h"
-
#include "ShapeValue.h"
#include "CachedImage.h"
+#include <wtf/PointerComparison.h>
namespace WebCore {
bool ShapeValue::isImageValid() const
{
- if (!image())
+ if (!m_image)
return false;
- if (image()->isCachedImage())
- return image()->cachedImage() && image()->cachedImage()->hasImage();
- return image()->isGeneratedImage();
+ if (m_image->isCachedImage()) {
+ auto* cachedImage = m_image->cachedImage();
+ return cachedImage && cachedImage->hasImage();
+ }
+ return m_image->isGeneratedImage();
}
-template <typename T>
-bool pointersOrValuesEqual(T p1, T p2)
-{
- if (p1 == p2)
- return true;
-
- if (!p1 || !p2)
- return false;
-
- return *p1 == *p2;
-}
-
bool ShapeValue::operator==(const ShapeValue& other) const
{
- if (m_type != other.m_type || m_cssBox != other.m_cssBox)
- return false;
-
- return pointersOrValuesEqual(m_shape.get(), other.m_shape.get())
- && pointersOrValuesEqual(m_image.get(), other.m_image.get());
+ return m_type == other.m_type
+ && m_cssBox == other.m_cssBox
+ && arePointingToEqualData(m_shape, other.m_shape)
+ && arePointingToEqualData(m_image, other.m_image);
}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/style/ShapeValue.h (210468 => 210469)
--- trunk/Source/WebCore/rendering/style/ShapeValue.h 2017-01-07 04:02:06 UTC (rev 210468)
+++ trunk/Source/WebCore/rendering/style/ShapeValue.h 2017-01-07 05:23:54 UTC (rev 210469)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,49 +31,38 @@
#pragma once
#include "BasicShapes.h"
-#include "CSSValueKeywords.h"
#include "StyleImage.h"
-#include <wtf/PassRefPtr.h>
namespace WebCore {
class ShapeValue : public RefCounted<ShapeValue> {
public:
- enum class Type {
- // The None value is defined by a null ShapeValue*
- Shape,
- Box,
- Image
- };
-
- static Ref<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox)
+ static Ref<ShapeValue> create(RefPtr<BasicShape>&& shape, CSSBoxType cssBox)
{
- return adoptRef(*new ShapeValue(shape, cssBox));
+ return adoptRef(*new ShapeValue(WTFMove(shape), cssBox));
}
- static Ref<ShapeValue> createBoxShapeValue(CSSBoxType boxShape)
+ static Ref<ShapeValue> create(CSSBoxType boxShape)
{
return adoptRef(*new ShapeValue(boxShape));
}
- static Ref<ShapeValue> createImageValue(PassRefPtr<StyleImage> image)
+ static Ref<ShapeValue> create(RefPtr<StyleImage>&& image)
{
- return adoptRef(*new ShapeValue(image));
+ return adoptRef(*new ShapeValue(WTFMove(image)));
}
+ enum class Type { Shape, Box, Image };
Type type() const { return m_type; }
BasicShape* shape() const { return m_shape.get(); }
CSSBoxType cssBox() const { return m_cssBox; }
-
StyleImage* image() const { return m_image.get(); }
-
bool isImageValid() const;
- void setImage(PassRefPtr<StyleImage> image)
+ void setImage(Ref<StyleImage>&& image)
{
- ASSERT(type() == Type::Image);
- if (m_image != image)
- m_image = image;
+ ASSERT(m_type == Type::Image);
+ m_image = WTFMove(image);
}
bool operator==(const ShapeValue&) const;
@@ -82,23 +72,20 @@
}
private:
- ShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox)
+ ShapeValue(RefPtr<BasicShape>&& shape, CSSBoxType cssBox)
: m_type(Type::Shape)
- , m_shape(shape)
+ , m_shape(WTFMove(shape))
, m_cssBox(cssBox)
{
}
- ShapeValue(Type type)
- : m_type(type)
- {
- }
- ShapeValue(PassRefPtr<StyleImage> image)
+
+ explicit ShapeValue(RefPtr<StyleImage>&& image)
: m_type(Type::Image)
- , m_image(image)
+ , m_image(WTFMove(image))
{
}
- ShapeValue(CSSBoxType cssBox)
+ explicit ShapeValue(CSSBoxType cssBox)
: m_type(Type::Box)
, m_cssBox(cssBox)
{