diff options
Diffstat (limited to 'Source/WebCore/rendering/style/FillLayer.h')
-rw-r--r-- | Source/WebCore/rendering/style/FillLayer.h | 133 |
1 files changed, 55 insertions, 78 deletions
diff --git a/Source/WebCore/rendering/style/FillLayer.h b/Source/WebCore/rendering/style/FillLayer.h index be4818fff..1e624cd02 100644 --- a/Source/WebCore/rendering/style/FillLayer.h +++ b/Source/WebCore/rendering/style/FillLayer.h @@ -2,7 +2,7 @@ * Copyright (C) 2000 Lars Knoll (knoll@kde.org) * (C) 2000 Antti Koivisto (koivisto@kde.org) * (C) 2000 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2014 Apple Inc. All rights reserved. * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) * * This library is free software; you can redistribute it and/or @@ -22,11 +22,9 @@ * */ -#ifndef FillLayer_h -#define FillLayer_h +#pragma once #include "GraphicsTypes.h" -#include "Length.h" #include "LengthSize.h" #include "RenderStyleConstants.h" #include "StyleImage.h" @@ -42,36 +40,37 @@ struct FillSize { { } - FillSize(EFillSizeType t, LengthSize size) - : type(t) - , size(std::move(size)) + FillSize(EFillSizeType type, const LengthSize& size) + : type(type) + , size(size) { } - bool operator==(const FillSize& o) const - { - return type == o.type && size == o.size; - } - bool operator!=(const FillSize& o) const - { - return !(*this == o); - } - EFillSizeType type; LengthSize size; }; +inline bool operator==(const FillSize& a, const FillSize& b) +{ + return a.type == b.type && a.size == b.size; +} + +inline bool operator!=(const FillSize& a, const FillSize& b) +{ + return !(a == b); +} + class FillLayer { WTF_MAKE_FAST_ALLOCATED; public: - FillLayer(EFillLayerType); + explicit FillLayer(EFillLayerType); ~FillLayer(); StyleImage* image() const { return m_image.get(); } const Length& xPosition() const { return m_xPosition; } const Length& yPosition() const { return m_yPosition; } - BackgroundEdgeOrigin backgroundXOrigin() const { return static_cast<BackgroundEdgeOrigin>(m_backgroundXOrigin); } - BackgroundEdgeOrigin backgroundYOrigin() const { return static_cast<BackgroundEdgeOrigin>(m_backgroundYOrigin); } + Edge backgroundXOrigin() const { return static_cast<Edge>(m_backgroundXOrigin); } + Edge backgroundYOrigin() const { return static_cast<Edge>(m_backgroundYOrigin); } EFillAttachment attachment() const { return static_cast<EFillAttachment>(m_attachment); } EFillBox clip() const { return static_cast<EFillBox>(m_clip); } EFillBox origin() const { return static_cast<EFillBox>(m_origin); } @@ -84,13 +83,14 @@ public: FillSize size() const { return FillSize(static_cast<EFillSizeType>(m_sizeType), m_sizeLength); } EMaskSourceType maskSourceType() const { return static_cast<EMaskSourceType>(m_maskSourceType); } - const FillLayer* next() const { return m_next; } - FillLayer* next() { return m_next; } + const FillLayer* next() const { return m_next.get(); } + FillLayer* next() { return m_next.get(); } bool isImageSet() const { return m_imageSet; } bool isXPositionSet() const { return m_xPosSet; } bool isYPositionSet() const { return m_yPosSet; } - bool isBackgroundOriginSet() const { return m_backgroundOriginSet; } + bool isBackgroundXOriginSet() const { return m_backgroundXOriginSet; } + bool isBackgroundYOriginSet() const { return m_backgroundYOriginSet; } bool isAttachmentSet() const { return m_attachmentSet; } bool isClipSet() const { return m_clipSet; } bool isOriginSet() const { return m_originSet; } @@ -101,11 +101,11 @@ public: bool isSizeSet() const { return m_sizeType != SizeNone; } bool isMaskSourceTypeSet() const { return m_maskSourceTypeSet; } - void setImage(PassRefPtr<StyleImage> i) { m_image = i; m_imageSet = true; } - void setXPosition(Length length) { m_xPosition = std::move(length); m_xPosSet = true; } - void setYPosition(Length length) { m_yPosition = std::move(length); m_yPosSet = true; } - void setBackgroundXOrigin(BackgroundEdgeOrigin o) { m_backgroundXOrigin = o; m_backgroundOriginSet = true; } - void setBackgroundYOrigin(BackgroundEdgeOrigin o) { m_backgroundYOrigin = o; m_backgroundOriginSet = true; } + void setImage(RefPtr<StyleImage>&& image) { m_image = WTFMove(image); m_imageSet = true; } + void setXPosition(Length length) { m_xPosition = WTFMove(length); m_xPosSet = true; } + void setYPosition(Length length) { m_yPosition = WTFMove(length); m_yPosSet = true; } + void setBackgroundXOrigin(Edge o) { m_backgroundXOrigin = static_cast<unsigned>(o); m_backgroundXOriginSet = true; } + void setBackgroundYOrigin(Edge o) { m_backgroundYOrigin = static_cast<unsigned>(o); m_backgroundYOriginSet = true; } void setAttachment(EFillAttachment attachment) { m_attachment = attachment; m_attachmentSet = true; } void setClip(EFillBox b) { m_clip = b; m_clipSet = true; } void setOrigin(EFillBox b) { m_origin = b; m_originSet = true; } @@ -118,17 +118,10 @@ public: void setSize(FillSize f) { m_sizeType = f.type; m_sizeLength = f.size; } void setMaskSourceType(EMaskSourceType m) { m_maskSourceType = m; m_maskSourceTypeSet = true; } - void clearImage() { m_image.clear(); m_imageSet = false; } - void clearXPosition() - { - m_xPosSet = false; - m_backgroundOriginSet = false; - } - void clearYPosition() - { - m_yPosSet = false; - m_backgroundOriginSet = false; - } + void clearImage() { m_image = nullptr; m_imageSet = false; } + + void clearXPosition() { m_xPosSet = false; m_backgroundXOriginSet = false; } + void clearYPosition() { m_yPosSet = false; m_backgroundYOriginSet = false; } void clearAttachment() { m_attachmentSet = false; } void clearClip() { m_clipSet = false; } @@ -140,35 +133,19 @@ public: void clearSize() { m_sizeType = SizeNone; } void clearMaskSourceType() { m_maskSourceTypeSet = false; } - void setNext(FillLayer* n) { if (m_next != n) { delete m_next; m_next = n; } } + void setNext(std::unique_ptr<FillLayer> next) { m_next = WTFMove(next); } - FillLayer& operator=(const FillLayer& o); - FillLayer(const FillLayer& o); + FillLayer& operator=(const FillLayer&); + FillLayer(const FillLayer&); - bool operator==(const FillLayer& o) const; - bool operator!=(const FillLayer& o) const - { - return !(*this == o); - } + bool operator==(const FillLayer&) const; + bool operator!=(const FillLayer& other) const { return !(*this == other); } - bool containsImage(StyleImage*) const; + bool containsImage(StyleImage&) const; bool imagesAreLoaded() const; - - bool hasImage() const - { - if (m_image) - return true; - return m_next ? m_next->hasImage() : false; - } - - bool hasFixedImage() const - { - if (m_image && m_attachment == FixedBackgroundAttachment) - return true; - return m_next ? m_next->hasFixedImage() : false; - } - - bool hasOpaqueImage(const RenderElement*) const; + bool hasImage() const; + bool hasFixedImage() const; + bool hasOpaqueImage(const RenderElement&) const; bool hasRepeatXY() const; bool clipOccludesNextLayers(bool firstLayer) const; @@ -177,6 +154,8 @@ public: void fillUnsetProperties(); void cullEmptyLayers(); + static bool imagesIdentical(const FillLayer*, const FillLayer*); + static EFillAttachment initialFillAttachment(EFillLayerType) { return ScrollBackgroundAttachment; } static EFillBox initialFillClip(EFillLayerType) { return BorderFillBox; } static EFillBox initialFillOrigin(EFillLayerType type) { return type == BackgroundFillLayer ? PaddingFillBox : BorderFillBox; } @@ -184,22 +163,18 @@ public: static EFillRepeat initialFillRepeatY(EFillLayerType) { return RepeatFill; } static CompositeOperator initialFillComposite(EFillLayerType) { return CompositeSourceOver; } static BlendMode initialFillBlendMode(EFillLayerType) { return BlendModeNormal; } - static EFillSizeType initialFillSizeType(EFillLayerType) { return SizeNone; } - static LengthSize initialFillSizeLength(EFillLayerType) { return LengthSize(); } - static FillSize initialFillSize(EFillLayerType type) { return FillSize(initialFillSizeType(type), initialFillSizeLength(type)); } - static Length initialFillXPosition(EFillLayerType) { return Length(0.0, Percent); } - static Length initialFillYPosition(EFillLayerType) { return Length(0.0, Percent); } - static StyleImage* initialFillImage(EFillLayerType) { return 0; } - static EMaskSourceType initialMaskSourceType(EFillLayerType) { return MaskAlpha; } + static FillSize initialFillSize(EFillLayerType) { return FillSize(); } + static Length initialFillXPosition(EFillLayerType) { return Length(0.0f, Percent); } + static Length initialFillYPosition(EFillLayerType) { return Length(0.0f, Percent); } + static StyleImage* initialFillImage(EFillLayerType) { return nullptr; } + static EMaskSourceType initialFillMaskSourceType(EFillLayerType) { return MaskAlpha; } private: friend class RenderStyle; void computeClipMax() const; - FillLayer() { } - - FillLayer* m_next; + std::unique_ptr<FillLayer> m_next; RefPtr<StyleImage> m_image; @@ -226,9 +201,10 @@ private: unsigned m_repeatYSet : 1; unsigned m_xPosSet : 1; unsigned m_yPosSet : 1; - unsigned m_backgroundOriginSet : 1; - unsigned m_backgroundXOrigin : 2; // BackgroundEdgeOrigin - unsigned m_backgroundYOrigin : 2; // BackgroundEdgeOrigin + unsigned m_backgroundXOriginSet : 1; + unsigned m_backgroundYOriginSet : 1; + unsigned m_backgroundXOrigin : 2; // Edge + unsigned m_backgroundYOrigin : 2; // Edge unsigned m_compositeSet : 1; unsigned m_blendModeSet : 1; unsigned m_maskSourceTypeSet : 1; @@ -238,6 +214,7 @@ private: mutable unsigned m_clipMax : 2; // EFillBox, maximum m_clip value from this to bottom layer }; -} // namespace WebCore +TextStream& operator<<(TextStream&, FillSize); +TextStream& operator<<(TextStream&, const FillLayer&); -#endif // FillLayer_h +} // namespace WebCore |