- Revision
- 251156
- Author
- simon.fra...@apple.com
- Date
- 2019-10-15 14:06:30 -0700 (Tue, 15 Oct 2019)
Log Message
Don't mutate a NinePieceImage to create a mask default image
https://bugs.webkit.org/show_bug.cgi?id=202967
Reviewed by Dean Jackson.
For every StyleRareNonInheritedData, the maskBoxImage undergoes copy-on-write
via maskBoxImage.setMaskDefaults(). Fix by giving NinePieceImage a constructor
argument that cna make the mask flavor of image.
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertBorderMask):
(WebCore::StyleBuilderConverter::convertReflection):
* rendering/style/NinePieceImage.cpp:
(WebCore::NinePieceImage::defaultMaskData):
(WebCore::NinePieceImage::NinePieceImage):
* rendering/style/NinePieceImage.h:
(WebCore::NinePieceImage::setMaskDefaults): Deleted.
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
* rendering/style/StyleReflection.h:
(WebCore::StyleReflection::StyleReflection):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (251155 => 251156)
--- trunk/Source/WebCore/ChangeLog 2019-10-15 20:54:22 UTC (rev 251155)
+++ trunk/Source/WebCore/ChangeLog 2019-10-15 21:06:30 UTC (rev 251156)
@@ -1,3 +1,27 @@
+2019-10-15 Simon Fraser <simon.fra...@apple.com>
+
+ Don't mutate a NinePieceImage to create a mask default image
+ https://bugs.webkit.org/show_bug.cgi?id=202967
+
+ Reviewed by Dean Jackson.
+
+ For every StyleRareNonInheritedData, the maskBoxImage undergoes copy-on-write
+ via maskBoxImage.setMaskDefaults(). Fix by giving NinePieceImage a constructor
+ argument that cna make the mask flavor of image.
+
+ * css/StyleBuilderConverter.h:
+ (WebCore::StyleBuilderConverter::convertBorderMask):
+ (WebCore::StyleBuilderConverter::convertReflection):
+ * rendering/style/NinePieceImage.cpp:
+ (WebCore::NinePieceImage::defaultMaskData):
+ (WebCore::NinePieceImage::NinePieceImage):
+ * rendering/style/NinePieceImage.h:
+ (WebCore::NinePieceImage::setMaskDefaults): Deleted.
+ * rendering/style/StyleRareNonInheritedData.cpp:
+ (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+ * rendering/style/StyleReflection.h:
+ (WebCore::StyleReflection::StyleReflection):
+
2019-10-15 youenn fablet <you...@apple.com>
Move headers to keep from a HTTPHeaderNameSet to an OptionSet
Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (251155 => 251156)
--- trunk/Source/WebCore/css/StyleBuilderConverter.h 2019-10-15 20:54:22 UTC (rev 251155)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h 2019-10-15 21:06:30 UTC (rev 251156)
@@ -456,8 +456,7 @@
template<CSSPropertyID property>
inline NinePieceImage StyleBuilderConverter::convertBorderMask(StyleResolver& styleResolver, CSSValue& value)
{
- NinePieceImage image;
- image.setMaskDefaults();
+ NinePieceImage image(NinePieceImage::Type::Mask);
styleResolver.styleMap()->mapNinePieceImage(property, &value, image);
return image;
}
@@ -752,8 +751,7 @@
reflection->setDirection(reflectValue.direction());
reflection->setOffset(reflectValue.offset().convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(styleResolver.state().cssToLengthConversionData()));
- NinePieceImage mask;
- mask.setMaskDefaults();
+ NinePieceImage mask(NinePieceImage::Type::Mask);
styleResolver.styleMap()->mapNinePieceImage(CSSPropertyWebkitBoxReflect, reflectValue.mask(), mask);
reflection->setMask(mask);
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.cpp (251155 => 251156)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.cpp 2019-10-15 20:54:22 UTC (rev 251155)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.cpp 2019-10-15 21:06:30 UTC (rev 251156)
@@ -40,11 +40,21 @@
return data.get();
}
-NinePieceImage::NinePieceImage()
- : m_data(defaultData())
+inline DataRef<NinePieceImage::Data>& NinePieceImage::defaultMaskData()
{
+ static NeverDestroyed<DataRef<Data>> maskData { Data::create() };
+ auto& data = ""
+ data.imageSlices = LengthBox(0);
+ data.fill = true;
+ data.borderSlices = LengthBox();
+ return maskData.get();
}
+NinePieceImage::NinePieceImage(Type imageType)
+ : m_data(imageType == Type::Normal ? defaultData() : defaultMaskData())
+{
+}
+
NinePieceImage::NinePieceImage(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, NinePieceImageRule horizontalRule, NinePieceImageRule verticalRule)
: m_data(Data::create(WTFMove(image), imageSlices, fill, borderSlices, outset, horizontalRule, verticalRule))
{
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.h (251155 => 251156)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.h 2019-10-15 20:54:22 UTC (rev 251155)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.h 2019-10-15 21:06:30 UTC (rev 251156)
@@ -106,7 +106,12 @@
class NinePieceImage {
public:
- NinePieceImage();
+ enum class Type {
+ Normal,
+ Mask
+ };
+
+ NinePieceImage(Type = Type::Normal);
NinePieceImage(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, NinePieceImageRule horizontalRule, NinePieceImageRule verticalRule);
bool operator==(const NinePieceImage& other) const { return m_data == other.m_data; }
@@ -156,13 +161,6 @@
m_data.access().verticalRule = other.m_data->verticalRule;
}
- void setMaskDefaults()
- {
- m_data.access().imageSlices = LengthBox(0);
- m_data.access().fill = true;
- m_data.access().borderSlices = LengthBox();
- }
-
static LayoutUnit computeOutset(const Length& outsetSide, LayoutUnit borderSide)
{
if (outsetSide.isRelative())
@@ -211,6 +209,7 @@
};
static DataRef<Data>& defaultData();
+ static DataRef<Data>& defaultMaskData();
DataRef<Data> m_data;
};
Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (251155 => 251156)
--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp 2019-10-15 20:54:22 UTC (rev 251155)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp 2019-10-15 21:06:30 UTC (rev 251156)
@@ -34,6 +34,7 @@
#include "StyleScrollSnapPoints.h"
#include <wtf/PointerComparison.h>
#include <wtf/RefPtr.h>
+#include <wtf/text/TextStream.h>
namespace WebCore {
@@ -63,6 +64,7 @@
#endif
, willChange(RenderStyle::initialWillChange())
, mask(FillLayerType::Mask)
+ , maskBoxImage(NinePieceImage::Type::Mask)
, objectPosition(RenderStyle::initialObjectPosition())
, shapeOutside(RenderStyle::initialShapeOutside())
, shapeMargin(RenderStyle::initialShapeMargin())
@@ -110,7 +112,6 @@
, columnGap(RenderStyle::initialColumnGap())
, rowGap(RenderStyle::initialRowGap())
{
- maskBoxImage.setMaskDefaults();
}
inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o)
Modified: trunk/Source/WebCore/rendering/style/StyleReflection.h (251155 => 251156)
--- trunk/Source/WebCore/rendering/style/StyleReflection.h 2019-10-15 20:54:22 UTC (rev 251155)
+++ trunk/Source/WebCore/rendering/style/StyleReflection.h 2019-10-15 21:06:30 UTC (rev 251156)
@@ -55,8 +55,8 @@
private:
StyleReflection()
: m_offset(0, Fixed)
+ , m_mask(NinePieceImage::Type::Mask)
{
- m_mask.setMaskDefaults();
}
ReflectionDirection m_direction { ReflectionDirection::Below };