summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/style
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
commita4e969f4965059196ca948db781e52f7cfebf19e (patch)
tree6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/WebCore/rendering/style
parent41386e9cb918eed93b3f13648cbef387e371e451 (diff)
downloadWebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/WebCore/rendering/style')
-rw-r--r--Source/WebCore/rendering/style/BasicShapes.cpp508
-rw-r--r--Source/WebCore/rendering/style/BasicShapes.h329
-rw-r--r--Source/WebCore/rendering/style/BorderData.h18
-rw-r--r--Source/WebCore/rendering/style/BorderValue.h8
-rw-r--r--Source/WebCore/rendering/style/CollapsedBorderValue.h15
-rw-r--r--Source/WebCore/rendering/style/ContentData.cpp8
-rw-r--r--Source/WebCore/rendering/style/ContentData.h168
-rw-r--r--Source/WebCore/rendering/style/CounterDirectives.cpp7
-rw-r--r--Source/WebCore/rendering/style/CounterDirectives.h3
-rw-r--r--Source/WebCore/rendering/style/CursorList.h4
-rw-r--r--Source/WebCore/rendering/style/DataRef.h11
-rw-r--r--Source/WebCore/rendering/style/FillLayer.cpp179
-rw-r--r--Source/WebCore/rendering/style/FillLayer.h122
-rw-r--r--Source/WebCore/rendering/style/GridCoordinate.h90
-rw-r--r--Source/WebCore/rendering/style/GridLength.h26
-rw-r--r--Source/WebCore/rendering/style/GridPosition.h20
-rw-r--r--Source/WebCore/rendering/style/GridResolvedPosition.cpp340
-rw-r--r--Source/WebCore/rendering/style/GridResolvedPosition.h128
-rw-r--r--Source/WebCore/rendering/style/GridTrackSize.h90
-rw-r--r--Source/WebCore/rendering/style/KeyframeList.cpp17
-rw-r--r--Source/WebCore/rendering/style/KeyframeList.h7
-rw-r--r--Source/WebCore/rendering/style/NinePieceImage.cpp188
-rw-r--r--Source/WebCore/rendering/style/NinePieceImage.h96
-rw-r--r--Source/WebCore/rendering/style/OutlineValue.h9
-rw-r--r--Source/WebCore/rendering/style/RenderStyle.cpp1180
-rw-r--r--Source/WebCore/rendering/style/RenderStyle.h1336
-rw-r--r--Source/WebCore/rendering/style/RenderStyleConstants.cpp104
-rw-r--r--Source/WebCore/rendering/style/RenderStyleConstants.h278
-rw-r--r--Source/WebCore/rendering/style/SVGRenderStyle.cpp67
-rw-r--r--Source/WebCore/rendering/style/SVGRenderStyle.h97
-rw-r--r--Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp76
-rw-r--r--Source/WebCore/rendering/style/SVGRenderStyleDefs.h89
-rw-r--r--Source/WebCore/rendering/style/ShadowData.cpp6
-rw-r--r--Source/WebCore/rendering/style/ShadowData.h6
-rw-r--r--Source/WebCore/rendering/style/ShapeValue.cpp64
-rw-r--r--Source/WebCore/rendering/style/ShapeValue.h60
-rw-r--r--Source/WebCore/rendering/style/StyleAllInOne.cpp60
-rw-r--r--Source/WebCore/rendering/style/StyleBackgroundData.cpp2
-rw-r--r--Source/WebCore/rendering/style/StyleBackgroundData.h4
-rw-r--r--Source/WebCore/rendering/style/StyleBoxData.cpp2
-rw-r--r--Source/WebCore/rendering/style/StyleBoxData.h4
-rw-r--r--Source/WebCore/rendering/style/StyleCachedImage.cpp8
-rw-r--r--Source/WebCore/rendering/style/StyleCachedImage.h15
-rw-r--r--Source/WebCore/rendering/style/StyleCachedImageSet.cpp10
-rw-r--r--Source/WebCore/rendering/style/StyleCachedImageSet.h12
-rw-r--r--Source/WebCore/rendering/style/StyleContentAlignmentData.h69
-rw-r--r--Source/WebCore/rendering/style/StyleCustomPropertyData.h88
-rw-r--r--Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp2
-rw-r--r--Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h4
-rw-r--r--Source/WebCore/rendering/style/StyleFilterData.cpp11
-rw-r--r--Source/WebCore/rendering/style/StyleFilterData.h12
-rw-r--r--Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp2
-rw-r--r--Source/WebCore/rendering/style/StyleFlexibleBoxData.h4
-rw-r--r--Source/WebCore/rendering/style/StyleGeneratedImage.cpp29
-rw-r--r--Source/WebCore/rendering/style/StyleGeneratedImage.h29
-rw-r--r--Source/WebCore/rendering/style/StyleGridData.cpp13
-rw-r--r--Source/WebCore/rendering/style/StyleGridData.h31
-rw-r--r--Source/WebCore/rendering/style/StyleGridItemData.cpp6
-rw-r--r--Source/WebCore/rendering/style/StyleGridItemData.h7
-rw-r--r--Source/WebCore/rendering/style/StyleImage.h25
-rw-r--r--Source/WebCore/rendering/style/StyleInheritedData.cpp6
-rw-r--r--Source/WebCore/rendering/style/StyleInheritedData.h10
-rw-r--r--Source/WebCore/rendering/style/StyleMarqueeData.cpp2
-rw-r--r--Source/WebCore/rendering/style/StyleMarqueeData.h4
-rw-r--r--Source/WebCore/rendering/style/StyleMultiColData.cpp11
-rw-r--r--Source/WebCore/rendering/style/StyleMultiColData.h7
-rw-r--r--Source/WebCore/rendering/style/StylePendingImage.h28
-rw-r--r--Source/WebCore/rendering/style/StyleRareInheritedData.cpp81
-rw-r--r--Source/WebCore/rendering/style/StyleRareInheritedData.h31
-rw-r--r--Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp211
-rw-r--r--Source/WebCore/rendering/style/StyleRareNonInheritedData.h89
-rw-r--r--Source/WebCore/rendering/style/StyleReflection.h6
-rw-r--r--Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp82
-rw-r--r--Source/WebCore/rendering/style/StyleScrollSnapPoints.h73
-rw-r--r--Source/WebCore/rendering/style/StyleSelfAlignmentData.h70
-rw-r--r--Source/WebCore/rendering/style/StyleSurroundData.cpp2
-rw-r--r--Source/WebCore/rendering/style/StyleSurroundData.h4
-rw-r--r--Source/WebCore/rendering/style/StyleTransformData.cpp2
-rw-r--r--Source/WebCore/rendering/style/StyleTransformData.h6
-rw-r--r--Source/WebCore/rendering/style/StyleVisualData.cpp2
-rw-r--r--Source/WebCore/rendering/style/StyleVisualData.h4
-rw-r--r--Source/WebCore/rendering/style/TextSizeAdjustment.h49
-rw-r--r--Source/WebCore/rendering/style/WillChangeData.cpp150
-rw-r--r--Source/WebCore/rendering/style/WillChangeData.h132
84 files changed, 4938 insertions, 2327 deletions
diff --git a/Source/WebCore/rendering/style/BasicShapes.cpp b/Source/WebCore/rendering/style/BasicShapes.cpp
index 916402a7d..eafeff75b 100644
--- a/Source/WebCore/rendering/style/BasicShapes.cpp
+++ b/Source/WebCore/rendering/style/BasicShapes.cpp
@@ -34,9 +34,15 @@
#include "BasicShapeFunctions.h"
#include "CalculationValue.h"
#include "FloatRect.h"
+#include "FloatRoundedRect.h"
#include "LengthFunctions.h"
#include "Path.h"
#include "RenderBox.h"
+#include "SVGPathByteStream.h"
+#include "SVGPathUtilities.h"
+
+#include <wtf/NeverDestroyed.h>
+#include <wtf/TinyLRUCache.h>
namespace WebCore {
@@ -51,103 +57,105 @@ void BasicShapeCenterCoordinate::updateComputedLength()
return;
}
- OwnPtr<CalcExpressionLength> lhs = adoptPtr(new CalcExpressionLength(Length(100, Percent)));
- OwnPtr<CalcExpressionLength> rhs = adoptPtr(new CalcExpressionLength(m_length));
- OwnPtr<CalcExpressionBinaryOperation> op = adoptPtr(new CalcExpressionBinaryOperation(lhs.release(), rhs.release(), CalcSubtract));
- m_computedLength = Length(CalculationValue::create(op.release(), CalculationRangeAll));
+ auto lhs = std::make_unique<CalcExpressionLength>(Length(100, Percent));
+ auto rhs = std::make_unique<CalcExpressionLength>(m_length);
+ auto op = std::make_unique<CalcExpressionBinaryOperation>(WTFMove(lhs), WTFMove(rhs), CalcSubtract);
+ m_computedLength = Length(CalculationValue::create(WTFMove(op), CalculationRangeAll));
}
-bool BasicShape::canBlend(const BasicShape* other) const
-{
- // FIXME: Support animations between different shapes in the future.
- if (type() != other->type())
- return false;
-
- // Both shapes must use the same reference box.
- if (layoutBox() != other->layoutBox())
- return false;
+struct SVGPathTranslatedByteStream {
+ SVGPathTranslatedByteStream(const FloatPoint& offset, const SVGPathByteStream& rawStream)
+ : m_offset(offset)
+ , m_rawStream(rawStream)
+ { }
+
+ bool operator==(const SVGPathTranslatedByteStream& other) const { return other.m_offset == m_offset && other.m_rawStream == m_rawStream; }
+ bool operator!=(const SVGPathTranslatedByteStream& other) const { return !(*this == other); }
+ bool isEmpty() const { return m_rawStream.isEmpty(); }
+
+ Path path() const
+ {
+ Path path;
+ buildPathFromByteStream(m_rawStream, path);
+ path.translate(toFloatSize(m_offset));
+ return path;
+ }
+
+ FloatPoint m_offset;
+ SVGPathByteStream m_rawStream;
+};
+
+struct EllipsePathPolicy : public TinyLRUCachePolicy<FloatRect, Path> {
+public:
+ static bool isKeyNull(const FloatRect& rect) { return rect.isEmpty(); }
+
+ static Path createValueForKey(const FloatRect& rect)
+ {
+ Path path;
+ path.addEllipse(rect);
+ return path;
+ }
+};
- // Just polygons with same number of vertices can be animated.
- if (type() == BasicShape::BasicShapePolygonType
- && (static_cast<const BasicShapePolygon*>(this)->values().size() != static_cast<const BasicShapePolygon*>(other)->values().size()
- || static_cast<const BasicShapePolygon*>(this)->windRule() != static_cast<const BasicShapePolygon*>(other)->windRule()))
- return false;
+struct RoundedRectPathPolicy : public TinyLRUCachePolicy<FloatRoundedRect, Path> {
+public:
+ static bool isKeyNull(const FloatRoundedRect& rect) { return rect.isEmpty(); }
- // Circles with keywords for radii coordinates cannot be animated.
- if (type() == BasicShape::BasicShapeCircleType) {
- const BasicShapeCircle* thisCircle = static_cast<const BasicShapeCircle*>(this);
- const BasicShapeCircle* otherCircle = static_cast<const BasicShapeCircle*>(other);
- if (!thisCircle->radius().canBlend(otherCircle->radius()))
- return false;
+ static Path createValueForKey(const FloatRoundedRect& rect)
+ {
+ Path path;
+ path.addRoundedRect(rect);
+ return path;
}
+};
- // Ellipses with keywords for radii coordinates cannot be animated.
- if (type() != BasicShape::BasicShapeEllipseType)
- return true;
+struct PolygonPathPolicy : public TinyLRUCachePolicy<Vector<FloatPoint>, Path> {
+public:
+ static bool isKeyNull(const Vector<FloatPoint>& points) { return !points.size(); }
- const BasicShapeEllipse* thisEllipse = static_cast<const BasicShapeEllipse*>(this);
- const BasicShapeEllipse* otherEllipse = static_cast<const BasicShapeEllipse*>(other);
- return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX())
- && thisEllipse->radiusY().canBlend(otherEllipse->radiusY()));
+ static Path createValueForKey(const Vector<FloatPoint>& points) { return Path::polygonPathFromPoints(points); }
+};
+
+struct TranslatedByteStreamPathPolicy : public TinyLRUCachePolicy<SVGPathTranslatedByteStream, Path> {
+public:
+ static bool isKeyNull(const SVGPathTranslatedByteStream& stream) { return stream.isEmpty(); }
+
+ static Path createValueForKey(const SVGPathTranslatedByteStream& stream) { return stream.path(); }
+};
+
+static const Path& cachedEllipsePath(const FloatRect& rect)
+{
+ static NeverDestroyed<TinyLRUCache<FloatRect, Path, 4, EllipsePathPolicy>> cache;
+ return cache.get().get(rect);
}
-void BasicShapeRectangle::path(Path& path, const FloatRect& boundingBox)
+static const Path& cachedRoundedRectPath(const FloatRoundedRect& rect)
{
- ASSERT(path.isEmpty());
- path.addRoundedRect(
- FloatRect(
- floatValueForLength(m_x, boundingBox.width()) + boundingBox.x(),
- floatValueForLength(m_y, boundingBox.height()) + boundingBox.y(),
- floatValueForLength(m_width, boundingBox.width()),
- floatValueForLength(m_height, boundingBox.height())
- ),
- FloatSize(
- floatValueForLength(m_cornerRadiusX, boundingBox.width()),
- floatValueForLength(m_cornerRadiusY, boundingBox.height())
- )
- );
+ static NeverDestroyed<TinyLRUCache<FloatRoundedRect, Path, 4, RoundedRectPathPolicy>> cache;
+ return cache.get().get(rect);
}
-PassRefPtr<BasicShape> BasicShapeRectangle::blend(const BasicShape* other, double progress) const
+static const Path& cachedPolygonPath(const Vector<FloatPoint>& points)
{
- ASSERT(type() == other->type());
-
- const BasicShapeRectangle* o = static_cast<const BasicShapeRectangle*>(other);
- RefPtr<BasicShapeRectangle> result = BasicShapeRectangle::create();
- result->setX(m_x.blend(o->x(), progress));
- result->setY(m_y.blend(o->y(), progress));
- result->setWidth(m_width.blend(o->width(), progress));
- result->setHeight(m_height.blend(o->height(), progress));
- result->setCornerRadiusX(m_cornerRadiusX.blend(o->cornerRadiusX(), progress));
- result->setCornerRadiusY(m_cornerRadiusY.blend(o->cornerRadiusY(), progress));
- return result.release();
+ static NeverDestroyed<TinyLRUCache<Vector<FloatPoint>, Path, 4, PolygonPathPolicy>> cache;
+ return cache.get().get(points);
}
-void DeprecatedBasicShapeCircle::path(Path& path, const FloatRect& boundingBox)
+static const Path& cachedTranslatedByteStreamPath(const SVGPathByteStream& stream, const FloatPoint& offset)
{
- ASSERT(path.isEmpty());
- float diagonal = sqrtf((boundingBox.width() * boundingBox.width() + boundingBox.height() * boundingBox.height()) / 2);
- float centerX = floatValueForLength(m_centerX, boundingBox.width());
- float centerY = floatValueForLength(m_centerY, boundingBox.height());
- float radius = floatValueForLength(m_radius, diagonal);
- path.addEllipse(FloatRect(
- centerX - radius + boundingBox.x(),
- centerY - radius + boundingBox.y(),
- radius * 2,
- radius * 2
- ));
+ static NeverDestroyed<TinyLRUCache<SVGPathTranslatedByteStream, Path, 4, TranslatedByteStreamPathPolicy>> cache;
+ return cache.get().get(SVGPathTranslatedByteStream(offset, stream));
}
-PassRefPtr<BasicShape> DeprecatedBasicShapeCircle::blend(const BasicShape* other, double progress) const
+bool BasicShapeCircle::operator==(const BasicShape& other) const
{
- ASSERT(type() == other->type());
-
- const DeprecatedBasicShapeCircle* o = static_cast<const DeprecatedBasicShapeCircle*>(other);
- RefPtr<DeprecatedBasicShapeCircle> result = DeprecatedBasicShapeCircle::create();
- result->setCenterX(m_centerX.blend(o->centerX(), progress));
- result->setCenterY(m_centerY.blend(o->centerY(), progress));
- result->setRadius(m_radius.blend(o->radius(), progress));
- return result.release();
+ if (type() != other.type())
+ return false;
+
+ auto& otherCircle = downcast<BasicShapeCircle>(other);
+ return m_centerX == otherCircle.m_centerX
+ && m_centerY == otherCircle.m_centerY
+ && m_radius == otherCircle.m_radius;
}
float BasicShapeCircle::floatValueForRadiusInBox(float boxWidth, float boxHeight) const
@@ -158,239 +166,267 @@ float BasicShapeCircle::floatValueForRadiusInBox(float boxWidth, float boxHeight
float centerX = floatValueForCenterCoordinate(m_centerX, boxWidth);
float centerY = floatValueForCenterCoordinate(m_centerY, boxHeight);
+ float widthDelta = std::abs(boxWidth - centerX);
+ float heightDelta = std::abs(boxHeight - centerY);
if (m_radius.type() == BasicShapeRadius::ClosestSide)
- return std::min(std::min(centerX, boxWidth - centerX), std::min(centerY, boxHeight - centerY));
+ return std::min(std::min(std::abs(centerX), widthDelta), std::min(std::abs(centerY), heightDelta));
// If radius.type() == BasicShapeRadius::FarthestSide.
- return std::max(std::max(centerX, boxWidth - centerX), std::max(centerY, boxHeight - centerY));
+ return std::max(std::max(std::abs(centerX), widthDelta), std::max(std::abs(centerY), heightDelta));
}
-void BasicShapeCircle::path(Path& path, const FloatRect& boundingBox)
+const Path& BasicShapeCircle::path(const FloatRect& boundingBox)
{
- ASSERT(path.isEmpty());
-
float centerX = floatValueForCenterCoordinate(m_centerX, boundingBox.width());
float centerY = floatValueForCenterCoordinate(m_centerY, boundingBox.height());
float radius = floatValueForRadiusInBox(boundingBox.width(), boundingBox.height());
- path.addEllipse(FloatRect(
- centerX - radius + boundingBox.x(),
- centerY - radius + boundingBox.y(),
- radius * 2,
- radius * 2
- ));
+
+ return cachedEllipsePath(FloatRect(centerX - radius + boundingBox.x(), centerY - radius + boundingBox.y(), radius * 2, radius * 2));
}
-PassRefPtr<BasicShape> BasicShapeCircle::blend(const BasicShape* other, double progress) const
+bool BasicShapeCircle::canBlend(const BasicShape& other) const
{
- ASSERT(type() == other->type());
- const BasicShapeCircle* o = static_cast<const BasicShapeCircle*>(other);
- RefPtr<BasicShapeCircle> result = BasicShapeCircle::create();
-
- result->setCenterX(m_centerX.blend(o->centerX(), progress));
- result->setCenterY(m_centerY.blend(o->centerY(), progress));
- result->setRadius(m_radius.blend(o->radius(), progress));
- return result.release();
+ if (type() != other.type())
+ return false;
+
+ return radius().canBlend(downcast<BasicShapeCircle>(other).radius());
}
-void DeprecatedBasicShapeEllipse::path(Path& path, const FloatRect& boundingBox)
+Ref<BasicShape> BasicShapeCircle::blend(const BasicShape& other, double progress) const
{
- ASSERT(path.isEmpty());
- float centerX = floatValueForLength(m_centerX, boundingBox.width());
- float centerY = floatValueForLength(m_centerY, boundingBox.height());
- float radiusX = floatValueForLength(m_radiusX, boundingBox.width());
- float radiusY = floatValueForLength(m_radiusY, boundingBox.height());
- path.addEllipse(FloatRect(
- centerX - radiusX + boundingBox.x(),
- centerY - radiusY + boundingBox.y(),
- radiusX * 2,
- radiusY * 2
- ));
+ ASSERT(type() == other.type());
+ auto& otherCircle = downcast<BasicShapeCircle>(other);
+ auto result = BasicShapeCircle::create();
+
+ result->setCenterX(m_centerX.blend(otherCircle.centerX(), progress));
+ result->setCenterY(m_centerY.blend(otherCircle.centerY(), progress));
+ result->setRadius(m_radius.blend(otherCircle.radius(), progress));
+ return WTFMove(result);
}
-PassRefPtr<BasicShape> DeprecatedBasicShapeEllipse::blend(const BasicShape* other, double progress) const
+bool BasicShapeEllipse::operator==(const BasicShape& other) const
{
- ASSERT(type() == other->type());
-
- const DeprecatedBasicShapeEllipse* o = static_cast<const DeprecatedBasicShapeEllipse*>(other);
- RefPtr<DeprecatedBasicShapeEllipse> result = DeprecatedBasicShapeEllipse::create();
- result->setCenterX(m_centerX.blend(o->centerX(), progress));
- result->setCenterY(m_centerY.blend(o->centerY(), progress));
- result->setRadiusX(m_radiusX.blend(o->radiusX(), progress));
- result->setRadiusY(m_radiusY.blend(o->radiusY(), progress));
- return result.release();
+ if (type() != other.type())
+ return false;
+
+ auto& otherEllipse = downcast<BasicShapeEllipse>(other);
+ return m_centerX == otherEllipse.m_centerX
+ && m_centerY == otherEllipse.m_centerY
+ && m_radiusX == otherEllipse.m_radiusX
+ && m_radiusY == otherEllipse.m_radiusY;
}
float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius, float center, float boxWidthOrHeight) const
{
if (radius.type() == BasicShapeRadius::Value)
- return floatValueForLength(radius.value(), boxWidthOrHeight);
+ return floatValueForLength(radius.value(), std::abs(boxWidthOrHeight));
+ float widthOrHeightDelta = std::abs(boxWidthOrHeight - center);
if (radius.type() == BasicShapeRadius::ClosestSide)
- return std::min(center, boxWidthOrHeight - center);
+ return std::min(std::abs(center), widthOrHeightDelta);
ASSERT(radius.type() == BasicShapeRadius::FarthestSide);
- return std::max(center, boxWidthOrHeight - center);
+ return std::max(std::abs(center), widthOrHeightDelta);
}
-void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox)
+const Path& BasicShapeEllipse::path(const FloatRect& boundingBox)
{
- ASSERT(path.isEmpty());
-
float centerX = floatValueForCenterCoordinate(m_centerX, boundingBox.width());
float centerY = floatValueForCenterCoordinate(m_centerY, boundingBox.height());
float radiusX = floatValueForRadiusInBox(m_radiusX, centerX, boundingBox.width());
float radiusY = floatValueForRadiusInBox(m_radiusY, centerY, boundingBox.height());
- path.addEllipse(FloatRect(
- centerX - radiusX + boundingBox.x(),
- centerY - radiusY + boundingBox.y(),
- radiusX * 2,
- radiusY * 2));
+
+ return cachedEllipsePath(FloatRect(centerX - radiusX + boundingBox.x(), centerY - radiusY + boundingBox.y(), radiusX * 2, radiusY * 2));
+}
+
+bool BasicShapeEllipse::canBlend(const BasicShape& other) const
+{
+ if (type() != other.type())
+ return false;
+
+ auto& otherEllipse = downcast<BasicShapeEllipse>(other);
+ return radiusX().canBlend(otherEllipse.radiusX()) && radiusY().canBlend(otherEllipse.radiusY());
}
-PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double progress) const
+Ref<BasicShape> BasicShapeEllipse::blend(const BasicShape& other, double progress) const
{
- ASSERT(type() == other->type());
- const BasicShapeEllipse* o = static_cast<const BasicShapeEllipse*>(other);
- RefPtr<BasicShapeEllipse> result = BasicShapeEllipse::create();
-
- if (m_radiusX.type() != BasicShapeRadius::Value || o->radiusX().type() != BasicShapeRadius::Value
- || m_radiusY.type() != BasicShapeRadius::Value || o->radiusY().type() != BasicShapeRadius::Value) {
- result->setCenterX(o->centerX());
- result->setCenterY(o->centerY());
- result->setRadiusX(o->radiusX());
- result->setRadiusY(o->radiusY());
- return result;
+ ASSERT(type() == other.type());
+ auto& otherEllipse = downcast<BasicShapeEllipse>(other);
+ auto result = BasicShapeEllipse::create();
+
+ if (m_radiusX.type() != BasicShapeRadius::Value || otherEllipse.radiusX().type() != BasicShapeRadius::Value
+ || m_radiusY.type() != BasicShapeRadius::Value || otherEllipse.radiusY().type() != BasicShapeRadius::Value) {
+ result->setCenterX(otherEllipse.centerX());
+ result->setCenterY(otherEllipse.centerY());
+ result->setRadiusX(otherEllipse.radiusX());
+ result->setRadiusY(otherEllipse.radiusY());
+ return WTFMove(result);
}
- result->setCenterX(m_centerX.blend(o->centerX(), progress));
- result->setCenterY(m_centerY.blend(o->centerY(), progress));
- result->setRadiusX(m_radiusX.blend(o->radiusX(), progress));
- result->setRadiusY(m_radiusY.blend(o->radiusY(), progress));
- return result.release();
+ result->setCenterX(m_centerX.blend(otherEllipse.centerX(), progress));
+ result->setCenterY(m_centerY.blend(otherEllipse.centerY(), progress));
+ result->setRadiusX(m_radiusX.blend(otherEllipse.radiusX(), progress));
+ result->setRadiusY(m_radiusY.blend(otherEllipse.radiusY(), progress));
+ return WTFMove(result);
}
-void BasicShapePolygon::path(Path& path, const FloatRect& boundingBox)
+bool BasicShapePolygon::operator==(const BasicShape& other) const
+{
+ if (type() != other.type())
+ return false;
+
+ auto& otherPolygon = downcast<BasicShapePolygon>(other);
+ return m_windRule == otherPolygon.m_windRule
+ && m_values == otherPolygon.m_values;
+}
+
+const Path& BasicShapePolygon::path(const FloatRect& boundingBox)
{
- ASSERT(path.isEmpty());
ASSERT(!(m_values.size() % 2));
size_t length = m_values.size();
-
- if (!length)
- return;
- path.moveTo(FloatPoint(floatValueForLength(m_values.at(0), boundingBox.width()) + boundingBox.x(),
- floatValueForLength(m_values.at(1), boundingBox.height()) + boundingBox.y()));
- for (size_t i = 2; i < length; i = i + 2) {
- path.addLineTo(FloatPoint(floatValueForLength(m_values.at(i), boundingBox.width()) + boundingBox.x(),
- floatValueForLength(m_values.at(i + 1), boundingBox.height()) + boundingBox.y()));
+ Vector<FloatPoint> points(length / 2);
+ for (size_t i = 0; i < points.size(); ++i) {
+ points[i].setX(floatValueForLength(m_values.at(i * 2), boundingBox.width()) + boundingBox.x());
+ points[i].setY(floatValueForLength(m_values.at(i * 2 + 1), boundingBox.height()) + boundingBox.y());
}
- path.closeSubpath();
+
+ return cachedPolygonPath(points);
}
-PassRefPtr<BasicShape> BasicShapePolygon::blend(const BasicShape* other, double progress) const
+bool BasicShapePolygon::canBlend(const BasicShape& other) const
{
- ASSERT(type() == other->type());
+ if (type() != other.type())
+ return false;
- const BasicShapePolygon* o = static_cast<const BasicShapePolygon*>(other);
- ASSERT(m_values.size() == o->values().size());
+ auto& otherPolygon = downcast<BasicShapePolygon>(other);
+ return values().size() == otherPolygon.values().size() && windRule() == otherPolygon.windRule();
+}
+
+Ref<BasicShape> BasicShapePolygon::blend(const BasicShape& other, double progress) const
+{
+ ASSERT(type() == other.type());
+
+ auto& otherPolygon = downcast<BasicShapePolygon>(other);
+ ASSERT(m_values.size() == otherPolygon.values().size());
ASSERT(!(m_values.size() % 2));
size_t length = m_values.size();
- RefPtr<BasicShapePolygon> result = BasicShapePolygon::create();
+ auto result = BasicShapePolygon::create();
if (!length)
- return result.release();
+ return WTFMove(result);
- result->setWindRule(o->windRule());
+ result->setWindRule(otherPolygon.windRule());
for (size_t i = 0; i < length; i = i + 2) {
- result->appendPoint(m_values.at(i).blend(o->values().at(i), progress),
- m_values.at(i + 1).blend(o->values().at(i + 1), progress));
+ result->appendPoint(m_values.at(i).blend(otherPolygon.values().at(i), progress),
+ m_values.at(i + 1).blend(otherPolygon.values().at(i + 1), progress));
}
- return result.release();
+ return WTFMove(result);
}
-void BasicShapeInsetRectangle::path(Path& path, const FloatRect& boundingBox)
+BasicShapePath::BasicShapePath(std::unique_ptr<SVGPathByteStream>&& byteStream)
+ : m_byteStream(WTFMove(byteStream))
{
- ASSERT(path.isEmpty());
- float left = floatValueForLength(m_left, boundingBox.width());
- float top = floatValueForLength(m_top, boundingBox.height());
- path.addRoundedRect(
- FloatRect(
- left + boundingBox.x(),
- top + boundingBox.y(),
- std::max<float>(boundingBox.width() - left - floatValueForLength(m_right, boundingBox.width()), 0),
- std::max<float>(boundingBox.height() - top - floatValueForLength(m_bottom, boundingBox.height()), 0)
- ),
- FloatSize(
- floatValueForLength(m_cornerRadiusX, boundingBox.width()),
- floatValueForLength(m_cornerRadiusY, boundingBox.height())
- )
- );
}
-PassRefPtr<BasicShape> BasicShapeInsetRectangle::blend(const BasicShape* other, double progress) const
+const Path& BasicShapePath::path(const FloatRect& boundingBox)
+{
+ return cachedTranslatedByteStreamPath(*m_byteStream, boundingBox.location());
+}
+
+bool BasicShapePath::operator==(const BasicShape& other) const
{
- ASSERT(type() == other->type());
-
- const BasicShapeInsetRectangle* o = static_cast<const BasicShapeInsetRectangle*>(other);
- RefPtr<BasicShapeInsetRectangle> result = BasicShapeInsetRectangle::create();
- result->setTop(m_top.blend(o->top(), progress));
- result->setRight(m_right.blend(o->right(), progress));
- result->setBottom(m_bottom.blend(o->bottom(), progress));
- result->setLeft(m_left.blend(o->left(), progress));
- result->setCornerRadiusX(m_cornerRadiusX.blend(o->cornerRadiusX(), progress));
- result->setCornerRadiusY(m_cornerRadiusY.blend(o->cornerRadiusY(), progress));
- return result.release();
+ if (type() != other.type())
+ return false;
+
+ auto& otherPath = downcast<BasicShapePath>(other);
+ return m_windRule == otherPath.m_windRule && *m_byteStream == *otherPath.m_byteStream;
+}
+
+bool BasicShapePath::canBlend(const BasicShape& other) const
+{
+ if (type() != other.type())
+ return false;
+
+ auto& otherPath = downcast<BasicShapePath>(other);
+ return windRule() == otherPath.windRule() && canBlendSVGPathByteStreams(*m_byteStream, *otherPath.pathData());
}
-void BasicShapeInset::path(Path& path, const FloatRect& boundingBox)
+Ref<BasicShape> BasicShapePath::blend(const BasicShape& from, double progress) const
+{
+ ASSERT(type() == from.type());
+
+ auto& fromPath = downcast<BasicShapePath>(from);
+
+ auto resultingPathBytes = std::make_unique<SVGPathByteStream>();
+ buildAnimatedSVGPathByteStream(*fromPath.m_byteStream, *m_byteStream, *resultingPathBytes, progress);
+
+ auto result = BasicShapePath::create(WTFMove(resultingPathBytes));
+ result->setWindRule(windRule());
+ return WTFMove(result);
+}
+
+bool BasicShapeInset::operator==(const BasicShape& other) const
+{
+ if (type() != other.type())
+ return false;
+
+ auto& otherInset = downcast<BasicShapeInset>(other);
+ return m_right == otherInset.m_right
+ && m_top == otherInset.m_top
+ && m_bottom == otherInset.m_bottom
+ && m_left == otherInset.m_left
+ && m_topLeftRadius == otherInset.m_topLeftRadius
+ && m_topRightRadius == otherInset.m_topRightRadius
+ && m_bottomRightRadius == otherInset.m_bottomRightRadius
+ && m_bottomLeftRadius == otherInset.m_bottomLeftRadius;
+}
+
+static FloatSize floatSizeForLengthSize(const LengthSize& lengthSize, const FloatRect& boundingBox)
+{
+ return FloatSize(floatValueForLength(lengthSize.width(), boundingBox.width()),
+ floatValueForLength(lengthSize.height(), boundingBox.height()));
+}
+
+const Path& BasicShapeInset::path(const FloatRect& boundingBox)
{
- ASSERT(path.isEmpty());
float left = floatValueForLength(m_left, boundingBox.width());
float top = floatValueForLength(m_top, boundingBox.height());
- path.addRoundedRect(
- FloatRect(
- left + boundingBox.x(),
- top + boundingBox.y(),
- std::max<float>(boundingBox.width() - left - floatValueForLength(m_right, boundingBox.width()), 0),
- std::max<float>(boundingBox.height() - top - floatValueForLength(m_bottom, boundingBox.height()), 0)
- ),
- FloatSize(
- floatValueForLength(m_topLeftRadius.width(), boundingBox.width()),
- floatValueForLength(m_topLeftRadius.height(), boundingBox.height())
- ),
- FloatSize(
- floatValueForLength(m_topRightRadius.width(), boundingBox.width()),
- floatValueForLength(m_topRightRadius.height(), boundingBox.height())
- ),
- FloatSize(
- floatValueForLength(m_bottomRightRadius.width(), boundingBox.width()),
- floatValueForLength(m_bottomRightRadius.height(), boundingBox.height())
- ),
- FloatSize(
- floatValueForLength(m_bottomLeftRadius.width(), boundingBox.width()),
- floatValueForLength(m_bottomLeftRadius.height(), boundingBox.height())
- )
- );
+ auto rect = FloatRect(left + boundingBox.x(), top + boundingBox.y(),
+ std::max<float>(boundingBox.width() - left - floatValueForLength(m_right, boundingBox.width()), 0),
+ std::max<float>(boundingBox.height() - top - floatValueForLength(m_bottom, boundingBox.height()), 0));
+ auto radii = FloatRoundedRect::Radii(floatSizeForLengthSize(m_topLeftRadius, boundingBox),
+ floatSizeForLengthSize(m_topRightRadius, boundingBox),
+ floatSizeForLengthSize(m_bottomLeftRadius, boundingBox),
+ floatSizeForLengthSize(m_bottomRightRadius, boundingBox));
+ radii.scale(calcBorderRadiiConstraintScaleFor(rect, radii));
+
+ return cachedRoundedRectPath(FloatRoundedRect(rect, radii));
+}
+
+bool BasicShapeInset::canBlend(const BasicShape& other) const
+{
+ return type() == other.type();
}
-PassRefPtr<BasicShape> BasicShapeInset::blend(const BasicShape* other, double progress) const
+Ref<BasicShape> BasicShapeInset::blend(const BasicShape& other, double progress) const
{
- ASSERT(type() == other->type());
+ ASSERT(type() == other.type());
- const BasicShapeInset* o = static_cast<const BasicShapeInset*>(other);
- RefPtr<BasicShapeInset> result = BasicShapeInset::create();
- result->setTop(m_top.blend(o->top(), progress));
- result->setRight(m_right.blend(o->right(), progress));
- result->setBottom(m_bottom.blend(o->bottom(), progress));
- result->setLeft(m_left.blend(o->left(), progress));
+ auto& otherInset = downcast<BasicShapeInset>(other);
+ auto result = BasicShapeInset::create();
+ result->setTop(m_top.blend(otherInset.top(), progress));
+ result->setRight(m_right.blend(otherInset.right(), progress));
+ result->setBottom(m_bottom.blend(otherInset.bottom(), progress));
+ result->setLeft(m_left.blend(otherInset.left(), progress));
- result->setTopLeftRadius(m_topLeftRadius.blend(o->topLeftRadius(), progress));
- result->setTopRightRadius(m_topRightRadius.blend(o->topRightRadius(), progress));
- result->setBottomRightRadius(m_bottomRightRadius.blend(o->bottomRightRadius(), progress));
- result->setBottomLeftRadius(m_bottomLeftRadius.blend(o->bottomLeftRadius(), progress));
+ result->setTopLeftRadius(m_topLeftRadius.blend(otherInset.topLeftRadius(), progress));
+ result->setTopRightRadius(m_topRightRadius.blend(otherInset.topRightRadius(), progress));
+ result->setBottomRightRadius(m_bottomRightRadius.blend(otherInset.bottomRightRadius(), progress));
+ result->setBottomLeftRadius(m_bottomLeftRadius.blend(otherInset.bottomLeftRadius(), progress));
- return result.release();
+ return WTFMove(result);
}
}
diff --git a/Source/WebCore/rendering/style/BasicShapes.h b/Source/WebCore/rendering/style/BasicShapes.h
index 36464596a..be1572b13 100644
--- a/Source/WebCore/rendering/style/BasicShapes.h
+++ b/Source/WebCore/rendering/style/BasicShapes.h
@@ -36,6 +36,7 @@
#include "WindRule.h"
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/TypeCasts.h>
#include <wtf/Vector.h>
namespace WebCore {
@@ -43,82 +44,29 @@ namespace WebCore {
class FloatRect;
class Path;
class RenderBox;
+class SVGPathByteStream;
class BasicShape : public RefCounted<BasicShape> {
public:
virtual ~BasicShape() { }
enum Type {
- BasicShapeRectangleType,
- DeprecatedBasicShapeCircleType,
- DeprecatedBasicShapeEllipseType,
BasicShapePolygonType,
- BasicShapeInsetRectangleType,
+ BasicShapePathType,
BasicShapeCircleType,
BasicShapeEllipseType,
BasicShapeInsetType
};
- bool canBlend(const BasicShape*) const;
-
- virtual void path(Path&, const FloatRect&) = 0;
- virtual WindRule windRule() const { return RULE_NONZERO; }
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0;
-
virtual Type type() const = 0;
- LayoutBox layoutBox() const { return m_layoutBox; }
- void setLayoutBox(LayoutBox layoutBox) { m_layoutBox = layoutBox; }
-
-protected:
- BasicShape()
- : m_layoutBox(BoxMissing)
- {
- }
-
-private:
- LayoutBox m_layoutBox;
-};
-
-class BasicShapeRectangle : public BasicShape {
-public:
- static PassRefPtr<BasicShapeRectangle> create() { return adoptRef(new BasicShapeRectangle); }
-
- const Length& x() const { return m_x; }
- const Length& y() const { return m_y; }
- const Length& width() const { return m_width; }
- const Length& height() const { return m_height; }
- const Length& cornerRadiusX() const { return m_cornerRadiusX; }
- const Length& cornerRadiusY() const { return m_cornerRadiusY; }
-
- void setX(Length x) { m_x = std::move(x); }
- void setY(Length y) { m_y = std::move(y); }
- void setWidth(Length width) { m_width = std::move(width); }
- void setHeight(Length height) { m_height = std::move(height); }
- void setCornerRadiusX(Length radiusX)
- {
- ASSERT(!radiusX.isUndefined());
- m_cornerRadiusX = std::move(radiusX);
- }
- void setCornerRadiusY(Length radiusY)
- {
- ASSERT(!radiusY.isUndefined());
- m_cornerRadiusY = std::move(radiusY);
- }
+ virtual const Path& path(const FloatRect&) = 0;
+ virtual WindRule windRule() const { return RULE_NONZERO; }
- virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ virtual bool canBlend(const BasicShape&) const = 0;
+ virtual Ref<BasicShape> blend(const BasicShape&, double) const = 0;
- virtual Type type() const override { return BasicShapeRectangleType; }
-private:
- BasicShapeRectangle() { }
-
- Length m_y;
- Length m_x;
- Length m_width;
- Length m_height;
- Length m_cornerRadiusX;
- Length m_cornerRadiusY;
+ virtual bool operator==(const BasicShape&) const = 0;
};
class BasicShapeCenterCoordinate {
@@ -157,13 +105,20 @@ public:
{
return BasicShapeCenterCoordinate(TopLeft, m_computedLength.blend(other.m_computedLength, progress));
}
+
+ bool operator==(const BasicShapeCenterCoordinate& other) const
+ {
+ return m_direction == other.m_direction
+ && m_length == other.m_length
+ && m_computedLength == other.m_computedLength;
+ }
private:
+ void updateComputedLength();
+
Direction m_direction;
Length m_length;
Length m_computedLength;
-
- void updateComputedLength();
};
class BasicShapeRadius {
@@ -173,10 +128,23 @@ public:
ClosestSide,
FarthestSide
};
- BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { }
- explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { }
- explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { }
- BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_type(other.type()) { }
+ BasicShapeRadius()
+ : m_value(Undefined),
+ m_type(ClosestSide)
+ { }
+
+ explicit BasicShapeRadius(Length v)
+ : m_value(v)
+ , m_type(Value)
+ { }
+ explicit BasicShapeRadius(Type t)
+ : m_value(Undefined)
+ , m_type(t)
+ { }
+ BasicShapeRadius(const BasicShapeRadius& other)
+ : m_value(other.value())
+ , m_type(other.type())
+ { }
const Length& value() const { return m_value; }
Type type() const { return m_type; }
@@ -194,6 +162,11 @@ public:
return BasicShapeRadius(m_value.blend(other.value(), progress));
}
+
+ bool operator==(const BasicShapeRadius& other) const
+ {
+ return m_value == other.m_value && m_type == other.m_type;
+ }
private:
Length m_value;
@@ -201,58 +174,39 @@ private:
};
-class BasicShapeCircle : public BasicShape {
+class BasicShapeCircle final : public BasicShape {
public:
- static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShapeCircle); }
+ static Ref<BasicShapeCircle> create() { return adoptRef(*new BasicShapeCircle); }
const BasicShapeCenterCoordinate& centerX() const { return m_centerX; }
const BasicShapeCenterCoordinate& centerY() const { return m_centerY; }
const BasicShapeRadius& radius() const { return m_radius; }
float floatValueForRadiusInBox(float boxWidth, float boxHeight) const;
- void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = std::move(centerX); }
- void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = std::move(centerY); }
- void setRadius(BasicShapeRadius radius) { m_radius = std::move(radius); }
-
- virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = WTFMove(centerX); }
+ void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = WTFMove(centerY); }
+ void setRadius(BasicShapeRadius radius) { m_radius = WTFMove(radius); }
- virtual Type type() const override { return BasicShapeCircleType; }
private:
- BasicShapeCircle() { }
+ BasicShapeCircle() = default;
- BasicShapeCenterCoordinate m_centerX;
- BasicShapeCenterCoordinate m_centerY;
- BasicShapeRadius m_radius;
-};
-
-class DeprecatedBasicShapeCircle : public BasicShape {
-public:
- static PassRefPtr<DeprecatedBasicShapeCircle> create() { return adoptRef(new DeprecatedBasicShapeCircle); }
-
- const Length& centerX() const { return m_centerX; }
- const Length& centerY() const { return m_centerY; }
- const Length& radius() const { return m_radius; }
+ virtual Type type() const override { return BasicShapeCircleType; }
- void setCenterX(Length centerX) { m_centerX = std::move(centerX); }
- void setCenterY(Length centerY) { m_centerY = std::move(centerY); }
- void setRadius(Length radius) { m_radius = std::move(radius); }
+ virtual const Path& path(const FloatRect&) override;
- virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ virtual bool canBlend(const BasicShape&) const override;
+ virtual Ref<BasicShape> blend(const BasicShape&, double) const override;
- virtual Type type() const override { return DeprecatedBasicShapeCircleType; }
-private:
- DeprecatedBasicShapeCircle() { }
+ virtual bool operator==(const BasicShape&) const override;
- Length m_centerX;
- Length m_centerY;
- Length m_radius;
+ BasicShapeCenterCoordinate m_centerX;
+ BasicShapeCenterCoordinate m_centerY;
+ BasicShapeRadius m_radius;
};
-class BasicShapeEllipse : public BasicShape {
+class BasicShapeEllipse final : public BasicShape {
public:
- static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicShapeEllipse); }
+ static Ref<BasicShapeEllipse> create() { return adoptRef(*new BasicShapeEllipse); }
const BasicShapeCenterCoordinate& centerX() const { return m_centerX; }
const BasicShapeCenterCoordinate& centerY() const { return m_centerY; }
@@ -260,17 +214,22 @@ public:
const BasicShapeRadius& radiusY() const { return m_radiusY; }
float floatValueForRadiusInBox(const BasicShapeRadius&, float center, float boxWidthOrHeight) const;
- void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = std::move(centerX); }
- void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = std::move(centerY); }
- void setRadiusX(BasicShapeRadius radiusX) { m_radiusX = std::move(radiusX); }
- void setRadiusY(BasicShapeRadius radiusY) { m_radiusY = std::move(radiusY); }
+ void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = WTFMove(centerX); }
+ void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = WTFMove(centerY); }
+ void setRadiusX(BasicShapeRadius radiusX) { m_radiusX = WTFMove(radiusX); }
+ void setRadiusY(BasicShapeRadius radiusY) { m_radiusY = WTFMove(radiusY); }
- virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+private:
+ BasicShapeEllipse() = default;
virtual Type type() const override { return BasicShapeEllipseType; }
-private:
- BasicShapeEllipse() { }
+
+ virtual const Path& path(const FloatRect&) override;
+
+ virtual bool canBlend(const BasicShape&) const override;
+ virtual Ref<BasicShape> blend(const BasicShape&, double) const override;
+
+ virtual bool operator==(const BasicShape&) const override;
BasicShapeCenterCoordinate m_centerX;
BasicShapeCenterCoordinate m_centerY;
@@ -278,103 +237,66 @@ private:
BasicShapeRadius m_radiusY;
};
-class DeprecatedBasicShapeEllipse : public BasicShape {
-public:
- static PassRefPtr<DeprecatedBasicShapeEllipse> create() { return adoptRef(new DeprecatedBasicShapeEllipse); }
-
- const Length& centerX() const { return m_centerX; }
- const Length& centerY() const { return m_centerY; }
- const Length& radiusX() const { return m_radiusX; }
- const Length& radiusY() const { return m_radiusY; }
-
- void setCenterX(Length centerX) { m_centerX = std::move(centerX); }
- void setCenterY(Length centerY) { m_centerY = std::move(centerY); }
- void setRadiusX(Length radiusX) { m_radiusX = std::move(radiusX); }
- void setRadiusY(Length radiusY) { m_radiusY = std::move(radiusY); }
-
- virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
-
- virtual Type type() const override { return DeprecatedBasicShapeEllipseType; }
-private:
- DeprecatedBasicShapeEllipse() { }
-
- Length m_centerX;
- Length m_centerY;
- Length m_radiusX;
- Length m_radiusY;
-};
-
-class BasicShapePolygon : public BasicShape {
+class BasicShapePolygon final : public BasicShape {
public:
- static PassRefPtr<BasicShapePolygon> create() { return adoptRef(new BasicShapePolygon); }
+ static Ref<BasicShapePolygon> create() { return adoptRef(*new BasicShapePolygon); }
const Vector<Length>& values() const { return m_values; }
const Length& getXAt(unsigned i) const { return m_values[2 * i]; }
const Length& getYAt(unsigned i) const { return m_values[2 * i + 1]; }
void setWindRule(WindRule windRule) { m_windRule = windRule; }
- void appendPoint(Length x, Length y) { m_values.append(std::move(x)); m_values.append(std::move(y)); }
-
- virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ void appendPoint(Length x, Length y) { m_values.append(WTFMove(x)); m_values.append(WTFMove(y)); }
virtual WindRule windRule() const override { return m_windRule; }
- virtual Type type() const override { return BasicShapePolygonType; }
private:
- BasicShapePolygon()
- : m_windRule(RULE_NONZERO)
- { }
+ BasicShapePolygon() = default;
+
+ virtual Type type() const override { return BasicShapePolygonType; }
+
+ virtual const Path& path(const FloatRect&) override;
- WindRule m_windRule;
+ virtual bool canBlend(const BasicShape&) const override;
+ virtual Ref<BasicShape> blend(const BasicShape&, double) const override;
+
+ virtual bool operator==(const BasicShape&) const override;
+
+ WindRule m_windRule { RULE_NONZERO };
Vector<Length> m_values;
};
-class BasicShapeInsetRectangle : public BasicShape {
+class BasicShapePath final : public BasicShape {
public:
- static PassRefPtr<BasicShapeInsetRectangle> create() { return adoptRef(new BasicShapeInsetRectangle); }
-
- const Length& top() const { return m_top; }
- const Length& right() const { return m_right; }
- const Length& bottom() const { return m_bottom; }
- const Length& left() const { return m_left; }
- const Length& cornerRadiusX() const { return m_cornerRadiusX; }
- const Length& cornerRadiusY() const { return m_cornerRadiusY; }
-
- void setTop(Length top) { m_top = std::move(top); }
- void setRight(Length right) { m_right = std::move(right); }
- void setBottom(Length bottom) { m_bottom = std::move(bottom); }
- void setLeft(Length left) { m_left = std::move(left); }
- void setCornerRadiusX(Length radiusX)
- {
- ASSERT(!radiusX.isUndefined());
- m_cornerRadiusX = std::move(radiusX);
- }
- void setCornerRadiusY(Length radiusY)
+ static Ref<BasicShapePath> create(std::unique_ptr<SVGPathByteStream>&& byteStream)
{
- ASSERT(!radiusY.isUndefined());
- m_cornerRadiusY = std::move(radiusY);
+ return adoptRef(*new BasicShapePath(WTFMove(byteStream)));
}
- virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ void setWindRule(WindRule windRule) { m_windRule = windRule; }
+ virtual WindRule windRule() const override { return m_windRule; }
+
+ const SVGPathByteStream* pathData() const { return m_byteStream.get(); }
- virtual Type type() const override { return BasicShapeInsetRectangleType; }
private:
- BasicShapeInsetRectangle() { }
+ BasicShapePath(std::unique_ptr<SVGPathByteStream>&&);
- Length m_right;
- Length m_top;
- Length m_bottom;
- Length m_left;
- Length m_cornerRadiusX;
- Length m_cornerRadiusY;
+ virtual Type type() const override { return BasicShapePathType; }
+
+ virtual const Path& path(const FloatRect&) override;
+
+ virtual bool canBlend(const BasicShape&) const override;
+ virtual Ref<BasicShape> blend(const BasicShape&, double) const override;
+
+ virtual bool operator==(const BasicShape&) const override;
+
+ std::unique_ptr<SVGPathByteStream> m_byteStream;
+ WindRule m_windRule { RULE_NONZERO };
};
-class BasicShapeInset : public BasicShape {
+class BasicShapeInset final : public BasicShape {
public:
- static PassRefPtr<BasicShapeInset> create() { return adoptRef(new BasicShapeInset); }
+ static Ref<BasicShapeInset> create() { return adoptRef(*new BasicShapeInset); }
const Length& top() const { return m_top; }
const Length& right() const { return m_right; }
@@ -386,22 +308,27 @@ public:
const LengthSize& bottomRightRadius() const { return m_bottomRightRadius; }
const LengthSize& bottomLeftRadius() const { return m_bottomLeftRadius; }
- void setTop(Length top) { m_top = std::move(top); }
- void setRight(Length right) { m_right = std::move(right); }
- void setBottom(Length bottom) { m_bottom = std::move(bottom); }
- void setLeft(Length left) { m_left = std::move(left); }
+ void setTop(Length top) { m_top = WTFMove(top); }
+ void setRight(Length right) { m_right = WTFMove(right); }
+ void setBottom(Length bottom) { m_bottom = WTFMove(bottom); }
+ void setLeft(Length left) { m_left = WTFMove(left); }
- void setTopLeftRadius(LengthSize radius) { m_topLeftRadius = std::move(radius); }
- void setTopRightRadius(LengthSize radius) { m_topRightRadius = std::move(radius); }
- void setBottomRightRadius(LengthSize radius) { m_bottomRightRadius = std::move(radius); }
- void setBottomLeftRadius(LengthSize radius) { m_bottomLeftRadius = std::move(radius); }
+ void setTopLeftRadius(LengthSize radius) { m_topLeftRadius = WTFMove(radius); }
+ void setTopRightRadius(LengthSize radius) { m_topRightRadius = WTFMove(radius); }
+ void setBottomRightRadius(LengthSize radius) { m_bottomRightRadius = WTFMove(radius); }
+ void setBottomLeftRadius(LengthSize radius) { m_bottomLeftRadius = WTFMove(radius); }
- virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+private:
+ BasicShapeInset() = default;
virtual Type type() const override { return BasicShapeInsetType; }
-private:
- BasicShapeInset() { }
+
+ virtual const Path& path(const FloatRect&) override;
+
+ virtual bool canBlend(const BasicShape&) const override;
+ virtual Ref<BasicShape> blend(const BasicShape&, double) const override;
+
+ virtual bool operator==(const BasicShape&) const override;
Length m_right;
Length m_top;
@@ -414,5 +341,17 @@ private:
LengthSize m_bottomLeftRadius;
};
-}
-#endif
+} // namespace WebCore
+
+#define SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+ static bool isType(const WebCore::BasicShape& basicShape) { return basicShape.type() == WebCore::predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapeCircle, BasicShape::BasicShapeCircleType)
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapeEllipse, BasicShape::BasicShapeEllipseType)
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapePolygon, BasicShape::BasicShapePolygonType)
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapePath, BasicShape::BasicShapePathType)
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapeInset, BasicShape::BasicShapeInsetType)
+
+#endif // BasicShapes_h
diff --git a/Source/WebCore/rendering/style/BorderData.h b/Source/WebCore/rendering/style/BorderData.h
index e65628a99..cd1a5834c 100644
--- a/Source/WebCore/rendering/style/BorderData.h
+++ b/Source/WebCore/rendering/style/BorderData.h
@@ -47,6 +47,11 @@ public:
return m_left.nonZero(!haveImage) || m_right.nonZero(!haveImage) || m_top.nonZero(!haveImage) || m_bottom.nonZero(!haveImage);
}
+ bool hasFill() const
+ {
+ return m_image.hasImage() && m_image.fill();
+ }
+
bool hasBorderRadius() const
{
if (!m_topLeft.width().isZero())
@@ -60,33 +65,38 @@ public:
return false;
}
- unsigned borderLeftWidth() const
+ float borderLeftWidth() const
{
if (!m_image.hasImage() && (m_left.style() == BNONE || m_left.style() == BHIDDEN))
return 0;
return m_left.width();
}
- unsigned borderRightWidth() const
+ float borderRightWidth() const
{
if (!m_image.hasImage() && (m_right.style() == BNONE || m_right.style() == BHIDDEN))
return 0;
return m_right.width();
}
- unsigned borderTopWidth() const
+ float borderTopWidth() const
{
if (!m_image.hasImage() && (m_top.style() == BNONE || m_top.style() == BHIDDEN))
return 0;
return m_top.width();
}
- unsigned borderBottomWidth() const
+ float borderBottomWidth() const
{
if (!m_image.hasImage() && (m_bottom.style() == BNONE || m_bottom.style() == BHIDDEN))
return 0;
return m_bottom.width();
}
+
+ FloatBoxExtent borderWidth() const
+ {
+ return FloatBoxExtent(borderTopWidth(), borderRightWidth(), borderBottomWidth(), borderLeftWidth());
+ }
bool operator==(const BorderData& o) const
{
diff --git a/Source/WebCore/rendering/style/BorderValue.h b/Source/WebCore/rendering/style/BorderValue.h
index c8f6512c5..cf340d0f6 100644
--- a/Source/WebCore/rendering/style/BorderValue.h
+++ b/Source/WebCore/rendering/style/BorderValue.h
@@ -34,9 +34,9 @@ class BorderValue {
friend class RenderStyle;
public:
BorderValue()
- : m_color(0)
+ : m_width(3)
+ , m_color(0)
, m_colorIsValid(false)
- , m_width(3)
, m_style(BNONE)
, m_isAuto(AUTO_OFF)
{
@@ -75,14 +75,14 @@ public:
Color color() const { return Color(m_color, m_colorIsValid); }
- unsigned width() const { return m_width; }
+ float width() const { return m_width; }
EBorderStyle style() const { return static_cast<EBorderStyle>(m_style); }
protected:
+ float m_width;
RGBA32 m_color;
unsigned m_colorIsValid : 1;
- unsigned m_width : 26;
unsigned m_style : 4; // EBorderStyle
// This is only used by OutlineValue but moved here to keep the bits packed.
diff --git a/Source/WebCore/rendering/style/CollapsedBorderValue.h b/Source/WebCore/rendering/style/CollapsedBorderValue.h
index 120173bda..da9c53a6f 100644
--- a/Source/WebCore/rendering/style/CollapsedBorderValue.h
+++ b/Source/WebCore/rendering/style/CollapsedBorderValue.h
@@ -26,15 +26,14 @@
#define CollapsedBorderValue_h
#include "BorderValue.h"
+#include "LayoutUnit.h"
namespace WebCore {
class CollapsedBorderValue {
public:
CollapsedBorderValue()
- : m_color(0)
- , m_colorIsValid(false)
- , m_width(0)
+ : m_colorIsValid(false)
, m_style(BNONE)
, m_precedence(BOFF)
, m_transparent(false)
@@ -42,16 +41,16 @@ public:
}
CollapsedBorderValue(const BorderValue& border, const Color& color, EBorderPrecedence precedence)
- : m_color(color.rgb())
+ : m_width(LayoutUnit(border.nonZero() ? border.width() : 0))
+ , m_color(color.rgb())
, m_colorIsValid(color.isValid())
- , m_width(border.nonZero() ? border.width() : 0)
, m_style(border.style())
, m_precedence(precedence)
, m_transparent(border.isTransparent())
{
}
- unsigned width() const { return m_style > BHIDDEN ? m_width : 0; }
+ LayoutUnit width() const { return m_style > BHIDDEN ? m_width : LayoutUnit::fromPixel(0); }
EBorderStyle style() const { return static_cast<EBorderStyle>(m_style); }
bool exists() const { return m_precedence != BOFF; }
Color color() const { return Color(m_color, m_colorIsValid); }
@@ -64,9 +63,9 @@ public:
}
private:
- RGBA32 m_color;
+ LayoutUnit m_width;
+ RGBA32 m_color { 0 };
unsigned m_colorIsValid : 1;
- unsigned m_width : 23;
unsigned m_style : 4; // EBorderStyle
unsigned m_precedence : 3; // EBorderPrecedence
unsigned m_transparent : 1;
diff --git a/Source/WebCore/rendering/style/ContentData.cpp b/Source/WebCore/rendering/style/ContentData.cpp
index b0c469b41..ea28c4269 100644
--- a/Source/WebCore/rendering/style/ContentData.cpp
+++ b/Source/WebCore/rendering/style/ContentData.cpp
@@ -40,7 +40,7 @@ std::unique_ptr<ContentData> ContentData::clone() const
ContentData* lastNewData = result.get();
for (const ContentData* contentData = next(); contentData; contentData = contentData->next()) {
auto newData = contentData->cloneInternal();
- lastNewData->setNext(std::move(newData));
+ lastNewData->setNext(WTFMove(newData));
lastNewData = lastNewData->next();
}
@@ -52,14 +52,14 @@ RenderPtr<RenderObject> ImageContentData::createContentRenderer(Document& docume
auto image = createRenderer<RenderImage>(document, RenderStyle::createStyleInheritingFromPseudoStyle(pseudoStyle), m_image.get());
image->initializeStyle();
image->setAltText(altText());
- return std::move(image);
+ return WTFMove(image);
}
RenderPtr<RenderObject> TextContentData::createContentRenderer(Document& document, const RenderStyle&) const
{
auto fragment = createRenderer<RenderTextFragment>(document, m_text);
fragment->setAltText(altText());
- return std::move(fragment);
+ return WTFMove(fragment);
}
RenderPtr<RenderObject> CounterContentData::createContentRenderer(Document& document, const RenderStyle&) const
@@ -71,7 +71,7 @@ RenderPtr<RenderObject> QuoteContentData::createContentRenderer(Document& docume
{
auto quote = createRenderer<RenderQuote>(document, RenderStyle::createStyleInheritingFromPseudoStyle(pseudoStyle), m_quote);
quote->initializeStyle();
- return std::move(quote);
+ return WTFMove(quote);
}
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/ContentData.h b/Source/WebCore/rendering/style/ContentData.h
index 4d1b9717a..d97a197b8 100644
--- a/Source/WebCore/rendering/style/ContentData.h
+++ b/Source/WebCore/rendering/style/ContentData.h
@@ -28,7 +28,7 @@
#include "CounterContent.h"
#include "StyleImage.h"
#include "RenderPtr.h"
-#include <wtf/OwnPtr.h>
+#include <wtf/TypeCasts.h>
namespace WebCore {
@@ -39,149 +39,199 @@ class RenderStyle;
class ContentData {
WTF_MAKE_FAST_ALLOCATED;
public:
+ enum Type {
+ CounterDataType,
+ ImageDataType,
+ QuoteDataType,
+ TextDataType
+ };
virtual ~ContentData() { }
- virtual bool isCounter() const { return false; }
- virtual bool isImage() const { return false; }
- virtual bool isQuote() const { return false; }
- virtual bool isText() const { return false; }
+ Type type() const { return m_type; }
+
+ bool isCounter() const { return type() == CounterDataType; }
+ bool isImage() const { return type() == ImageDataType; }
+ bool isQuote() const { return type() == QuoteDataType; }
+ bool isText() const { return type() == TextDataType; }
virtual RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const = 0;
std::unique_ptr<ContentData> clone() const;
ContentData* next() const { return m_next.get(); }
- void setNext(std::unique_ptr<ContentData> next) { m_next = std::move(next); }
+ void setNext(std::unique_ptr<ContentData> next) { m_next = WTFMove(next); }
void setAltText(const String& alt) { m_altText = alt; }
const String& altText() const { return m_altText; }
-
- virtual bool equals(const ContentData&) const = 0;
+
+protected:
+ explicit ContentData(Type type)
+ : m_type(type)
+ {
+ }
private:
virtual std::unique_ptr<ContentData> cloneInternal() const = 0;
std::unique_ptr<ContentData> m_next;
String m_altText;
+ Type m_type;
};
class ImageContentData final : public ContentData {
public:
explicit ImageContentData(PassRefPtr<StyleImage> image)
- : m_image(image)
+ : ContentData(ImageDataType)
+ , m_image(image)
{
+ ASSERT(m_image);
}
- const StyleImage* image() const { return m_image.get(); }
- StyleImage* image() { return m_image.get(); }
- void setImage(PassRefPtr<StyleImage> image) { m_image = image; }
-
- virtual bool isImage() const override { return true; }
- virtual RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
-
- virtual bool equals(const ContentData& data) const override
+ const StyleImage& image() const { return *m_image; }
+ void setImage(PassRefPtr<StyleImage> image)
{
- if (!data.isImage())
- return false;
- return *static_cast<const ImageContentData&>(data).image() == *image();
+ ASSERT(image);
+ m_image = image;
}
+ virtual RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
+
private:
virtual std::unique_ptr<ContentData> cloneInternal() const override
{
- RefPtr<StyleImage> image = const_cast<StyleImage*>(this->image());
+ std::unique_ptr<ContentData> image = std::make_unique<ImageContentData>(m_image.get());
+ image->setAltText(altText());
- return std::make_unique<ImageContentData>(image.release());
+ return image;
}
RefPtr<StyleImage> m_image;
};
+inline bool operator==(const ImageContentData& a, const ImageContentData& b)
+{
+ return a.image() == b.image();
+}
+
+inline bool operator!=(const ImageContentData& a, const ImageContentData& b)
+{
+ return !(a == b);
+}
+
class TextContentData final : public ContentData {
public:
explicit TextContentData(const String& text)
- : m_text(text)
+ : ContentData(TextDataType)
+ , m_text(text)
{
}
const String& text() const { return m_text; }
void setText(const String& text) { m_text = text; }
- virtual bool isText() const override { return true; }
virtual RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
- virtual bool equals(const ContentData& data) const override
- {
- if (!data.isText())
- return false;
- return static_cast<const TextContentData&>(data).text() == text();
- }
-
private:
virtual std::unique_ptr<ContentData> cloneInternal() const override { return std::make_unique<TextContentData>(text()); }
String m_text;
};
+inline bool operator==(const TextContentData& a, const TextContentData& b)
+{
+ return a.text() == b.text();
+}
+
+inline bool operator!=(const TextContentData& a, const TextContentData& b)
+{
+ return !(a == b);
+}
+
class CounterContentData final : public ContentData {
public:
explicit CounterContentData(std::unique_ptr<CounterContent> counter)
- : m_counter(std::move(counter))
+ : ContentData(CounterDataType)
+ , m_counter(WTFMove(counter))
{
+ ASSERT(m_counter);
}
- const CounterContent* counter() const { return m_counter.get(); }
- void setCounter(std::unique_ptr<CounterContent> counter) { m_counter = std::move(counter); }
+ const CounterContent& counter() const { return *m_counter; }
+ void setCounter(std::unique_ptr<CounterContent> counter)
+ {
+ ASSERT(counter);
+ m_counter = WTFMove(counter);
+ }
- virtual bool isCounter() const override { return true; }
virtual RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
private:
virtual std::unique_ptr<ContentData> cloneInternal() const override
{
- auto counterData = std::make_unique<CounterContent>(*counter());
- return std::make_unique<CounterContentData>(std::move(counterData));
- }
-
- virtual bool equals(const ContentData& data) const override
- {
- if (!data.isCounter())
- return false;
- return *static_cast<const CounterContentData&>(data).counter() == *counter();
+ auto counterData = std::make_unique<CounterContent>(counter());
+ return std::make_unique<CounterContentData>(WTFMove(counterData));
}
std::unique_ptr<CounterContent> m_counter;
};
+inline bool operator==(const CounterContentData& a, const CounterContentData& b)
+{
+ return a.counter() == b.counter();
+}
+
+inline bool operator!=(const CounterContentData& a, const CounterContentData& b)
+{
+ return !(a == b);
+}
+
class QuoteContentData final : public ContentData {
public:
explicit QuoteContentData(QuoteType quote)
- : m_quote(quote)
+ : ContentData(QuoteDataType)
+ , m_quote(quote)
{
}
QuoteType quote() const { return m_quote; }
void setQuote(QuoteType quote) { m_quote = quote; }
- virtual bool isQuote() const override { return true; }
virtual RenderPtr<RenderObject> createContentRenderer(Document&, const RenderStyle&) const override;
- virtual bool equals(const ContentData& data) const override
- {
- if (!data.isQuote())
- return false;
- return static_cast<const QuoteContentData&>(data).quote() == quote();
- }
-
private:
virtual std::unique_ptr<ContentData> cloneInternal() const override { return std::make_unique<QuoteContentData>(quote()); }
QuoteType m_quote;
};
+inline bool operator==(const QuoteContentData& a, const QuoteContentData& b)
+{
+ return a.quote() == b.quote();
+}
+
+inline bool operator!=(const QuoteContentData& a, const QuoteContentData& b)
+{
+ return !(a == b);
+}
+
inline bool operator==(const ContentData& a, const ContentData& b)
{
- return a.equals(b);
+ if (a.type() != b.type())
+ return false;
+
+ switch (a.type()) {
+ case ContentData::CounterDataType:
+ return downcast<CounterContentData>(a) == downcast<CounterContentData>(b);
+ case ContentData::ImageDataType:
+ return downcast<ImageContentData>(a) == downcast<ImageContentData>(b);
+ case ContentData::QuoteDataType:
+ return downcast<QuoteContentData>(a) == downcast<QuoteContentData>(b);
+ case ContentData::TextDataType:
+ return downcast<TextContentData>(a) == downcast<TextContentData>(b);
+ }
+
+ ASSERT_NOT_REACHED();
+ return false;
}
inline bool operator!=(const ContentData& a, const ContentData& b)
@@ -191,4 +241,14 @@ inline bool operator!=(const ContentData& a, const ContentData& b)
} // namespace WebCore
+#define SPECIALIZE_TYPE_TRAITS_CONTENT_DATA(ToClassName, ContentDataName) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
+ static bool isType(const WebCore::ContentData& contentData) { return contentData.is##ContentDataName(); } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_CONTENT_DATA(ImageContentData, Image)
+SPECIALIZE_TYPE_TRAITS_CONTENT_DATA(TextContentData, Text)
+SPECIALIZE_TYPE_TRAITS_CONTENT_DATA(CounterContentData, Counter)
+SPECIALIZE_TYPE_TRAITS_CONTENT_DATA(QuoteContentData, Quote)
+
#endif // ContentData_h
diff --git a/Source/WebCore/rendering/style/CounterDirectives.cpp b/Source/WebCore/rendering/style/CounterDirectives.cpp
index 06d44ddf6..4b7fd7a1e 100644
--- a/Source/WebCore/rendering/style/CounterDirectives.cpp
+++ b/Source/WebCore/rendering/style/CounterDirectives.cpp
@@ -21,7 +21,6 @@
#include "config.h"
#include "CounterDirectives.h"
-#include <wtf/PassOwnPtr.h>
namespace WebCore {
@@ -33,11 +32,11 @@ bool operator==(const CounterDirectives& a, const CounterDirectives& b)
&& a.resetValue() == b.resetValue();
}
-PassOwnPtr<CounterDirectiveMap> clone(const CounterDirectiveMap& counterDirectives)
+std::unique_ptr<CounterDirectiveMap> clone(const CounterDirectiveMap& counterDirectives)
{
- OwnPtr<CounterDirectiveMap> result = adoptPtr(new CounterDirectiveMap);
+ auto result = std::make_unique<CounterDirectiveMap>();
*result = counterDirectives;
- return result.release();
+ return result;
}
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/CounterDirectives.h b/Source/WebCore/rendering/style/CounterDirectives.h
index cf793bb8f..d5de076cf 100644
--- a/Source/WebCore/rendering/style/CounterDirectives.h
+++ b/Source/WebCore/rendering/style/CounterDirectives.h
@@ -25,6 +25,7 @@
#ifndef CounterDirectives_h
#define CounterDirectives_h
+#include <memory>
#include <wtf/HashMap.h>
#include <wtf/MathExtras.h>
#include <wtf/RefPtr.h>
@@ -104,7 +105,7 @@ inline bool operator!=(const CounterDirectives& a, const CounterDirectives& b) {
typedef HashMap<AtomicString, CounterDirectives> CounterDirectiveMap;
-PassOwnPtr<CounterDirectiveMap> clone(const CounterDirectiveMap&);
+std::unique_ptr<CounterDirectiveMap> clone(const CounterDirectiveMap&);
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/CursorList.h b/Source/WebCore/rendering/style/CursorList.h
index a1d1fe797..4b3e3d358 100644
--- a/Source/WebCore/rendering/style/CursorList.h
+++ b/Source/WebCore/rendering/style/CursorList.h
@@ -33,9 +33,9 @@ namespace WebCore {
class CursorList : public RefCounted<CursorList> {
public:
- static PassRefPtr<CursorList> create()
+ static Ref<CursorList> create()
{
- return adoptRef(new CursorList);
+ return adoptRef(*new CursorList);
}
const CursorData& operator[](int i) const { return m_vector[i]; }
diff --git a/Source/WebCore/rendering/style/DataRef.h b/Source/WebCore/rendering/style/DataRef.h
index 3eb14e1eb..0afb6ecd9 100644
--- a/Source/WebCore/rendering/style/DataRef.h
+++ b/Source/WebCore/rendering/style/DataRef.h
@@ -24,18 +24,17 @@
#ifndef DataRef_h
#define DataRef_h
-#include <wtf/PassRef.h>
#include <wtf/Ref.h>
namespace WebCore {
template <typename T> class DataRef {
public:
- DataRef(PassRef<T> data) : m_data(std::move(data)) { }
+ DataRef(Ref<T>&& data) : m_data(WTFMove(data)) { }
DataRef(const DataRef& other) : m_data(const_cast<T&>(other.m_data.get())) { }
DataRef& operator=(const DataRef& other) { m_data = const_cast<T&>(other.m_data.get()); return *this; }
- const T* get() const { return &m_data.get(); }
+ const T* get() const { return m_data.ptr(); }
const T& operator*() const { return *get(); }
const T* operator->() const { return get(); }
@@ -44,17 +43,17 @@ public:
{
if (!m_data->hasOneRef())
m_data = m_data->copy();
- return &m_data.get();
+ return m_data.ptr();
}
bool operator==(const DataRef<T>& o) const
{
- return &m_data.get() == &o.m_data.get() || m_data.get() == o.m_data.get();
+ return m_data.ptr() == o.m_data.ptr() || m_data.get() == o.m_data.get();
}
bool operator!=(const DataRef<T>& o) const
{
- return &m_data.get() != &o.m_data.get() && m_data.get() != o.m_data.get();
+ return m_data.ptr() != o.m_data.ptr() && m_data.get() != o.m_data.get();
}
private:
diff --git a/Source/WebCore/rendering/style/FillLayer.cpp b/Source/WebCore/rendering/style/FillLayer.cpp
index 3c563b278..a0f0abee4 100644
--- a/Source/WebCore/rendering/style/FillLayer.cpp
+++ b/Source/WebCore/rendering/style/FillLayer.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2014 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
@@ -22,39 +22,40 @@
#include "config.h"
#include "FillLayer.h"
+#include "TextStream.h"
+#include <wtf/PointerComparison.h>
+
namespace WebCore {
struct SameSizeAsFillLayer {
- FillLayer* m_next;
+ FillLayer* next;
- RefPtr<StyleImage> m_image;
+ RefPtr<StyleImage> image;
- Length m_xPosition;
- Length m_yPosition;
+ Length x;
+ Length y;
- LengthSize m_sizeLength;
+ LengthSize sizeLength;
- unsigned m_bitfields: 32;
- unsigned m_bitfields2: 1;
+ unsigned bitfields : 32;
+ unsigned bitfields2 : 11;
};
COMPILE_ASSERT(sizeof(FillLayer) == sizeof(SameSizeAsFillLayer), FillLayer_should_stay_small);
FillLayer::FillLayer(EFillLayerType type)
- : m_next(0)
- , m_image(FillLayer::initialFillImage(type))
+ : m_image(FillLayer::initialFillImage(type))
, m_xPosition(FillLayer::initialFillXPosition(type))
, m_yPosition(FillLayer::initialFillYPosition(type))
- , m_sizeLength(FillLayer::initialFillSizeLength(type))
, m_attachment(FillLayer::initialFillAttachment(type))
, m_clip(FillLayer::initialFillClip(type))
, m_origin(FillLayer::initialFillOrigin(type))
, m_repeatX(FillLayer::initialFillRepeatX(type))
, m_repeatY(FillLayer::initialFillRepeatY(type))
, m_composite(FillLayer::initialFillComposite(type))
- , m_sizeType(FillLayer::initialFillSizeType(type))
+ , m_sizeType(SizeNone)
, m_blendMode(FillLayer::initialFillBlendMode(type))
- , m_maskSourceType(FillLayer::initialMaskSourceType(type))
+ , m_maskSourceType(FillLayer::initialFillMaskSourceType(type))
, m_imageSet(false)
, m_attachmentSet(false)
, m_clipSet(false)
@@ -64,8 +65,8 @@ FillLayer::FillLayer(EFillLayerType type)
, m_xPosSet(false)
, m_yPosSet(false)
, m_backgroundOriginSet(false)
- , m_backgroundXOrigin(LeftEdge)
- , m_backgroundYOrigin(TopEdge)
+ , m_backgroundXOrigin(static_cast<unsigned>(Edge::Left))
+ , m_backgroundYOrigin(static_cast<unsigned>(Edge::Top))
, m_compositeSet(type == MaskFillLayer)
, m_blendModeSet(false)
, m_maskSourceTypeSet(false)
@@ -74,7 +75,7 @@ FillLayer::FillLayer(EFillLayerType type)
}
FillLayer::FillLayer(const FillLayer& o)
- : m_next(o.m_next ? new FillLayer(*o.m_next) : 0)
+ : m_next(o.m_next ? std::make_unique<FillLayer>(*o.m_next) : nullptr)
, m_image(o.m_image)
, m_xPosition(o.m_xPosition)
, m_yPosition(o.m_yPosition)
@@ -108,15 +109,13 @@ FillLayer::FillLayer(const FillLayer& o)
FillLayer::~FillLayer()
{
- delete m_next;
+ // Delete the layers in a loop rather than allowing recursive calls to the destructors.
+ for (std::unique_ptr<FillLayer> next = WTFMove(m_next); next; next = WTFMove(next->m_next)) { }
}
FillLayer& FillLayer::operator=(const FillLayer& o)
{
- if (m_next != o.m_next) {
- delete m_next;
- m_next = o.m_next ? new FillLayer(*o.m_next) : 0;
- }
+ m_next = o.m_next ? std::make_unique<FillLayer>(*o.m_next) : nullptr;
m_image = o.m_image;
m_xPosition = o.m_xPosition;
@@ -155,14 +154,14 @@ FillLayer& FillLayer::operator=(const FillLayer& o)
bool FillLayer::operator==(const FillLayer& o) const
{
// We do not check the "isSet" booleans for each property, since those are only used during initial construction
- // to propagate patterns into layers. All layer comparisons happen after values have all been filled in anyway.
- return StyleImage::imagesEquivalent(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition
- && m_backgroundXOrigin == o.m_backgroundXOrigin && m_backgroundYOrigin == o.m_backgroundYOrigin
- && m_attachment == o.m_attachment && m_clip == o.m_clip && m_composite == o.m_composite
- && m_blendMode == o.m_blendMode && m_origin == o.m_origin && m_repeatX == o.m_repeatX
- && m_repeatY == o.m_repeatY && m_sizeType == o.m_sizeType && m_maskSourceType == o.m_maskSourceType
- && m_sizeLength == o.m_sizeLength && m_type == o.m_type
- && ((m_next && o.m_next) ? *m_next == *o.m_next : m_next == o.m_next);
+ // to propagate patterns into layers. All layer comparisons happen after values have all been filled in anyway.
+ return arePointingToEqualData(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition
+ && m_backgroundXOrigin == o.m_backgroundXOrigin && m_backgroundYOrigin == o.m_backgroundYOrigin
+ && m_attachment == o.m_attachment && m_clip == o.m_clip && m_composite == o.m_composite
+ && m_blendMode == o.m_blendMode && m_origin == o.m_origin && m_repeatX == o.m_repeatX
+ && m_repeatY == o.m_repeatY && m_sizeType == o.m_sizeType && m_maskSourceType == o.m_maskSourceType
+ && m_sizeLength == o.m_sizeLength && m_type == o.m_type
+ && ((m_next && o.m_next) ? *m_next == *o.m_next : m_next == o.m_next);
}
void FillLayer::fillUnsetProperties()
@@ -290,18 +289,15 @@ void FillLayer::fillUnsetProperties()
void FillLayer::cullEmptyLayers()
{
- FillLayer* next;
- for (FillLayer* p = this; p; p = next) {
- next = p->m_next;
- if (next && !next->isImageSet()) {
- delete next;
- p->m_next = 0;
+ for (FillLayer* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_next && !layer->m_next->isImageSet()) {
+ layer->m_next = nullptr;
break;
}
}
}
-static EFillBox clipMax(EFillBox clipA, EFillBox clipB)
+static inline EFillBox clipMax(EFillBox clipA, EFillBox clipB)
{
if (clipA == BorderFillBox || clipB == BorderFillBox)
return BorderFillBox;
@@ -314,11 +310,15 @@ static EFillBox clipMax(EFillBox clipA, EFillBox clipB)
void FillLayer::computeClipMax() const
{
- if (m_next) {
- m_next->computeClipMax();
- m_clipMax = clipMax(clip(), m_next->clip());
- } else
- m_clipMax = m_clip;
+ Vector<const FillLayer*, 4> layers;
+ for (auto* layer = this; layer; layer = layer->m_next.get())
+ layers.append(layer);
+ EFillBox computedClipMax = TextFillBox;
+ for (unsigned i = layers.size(); i; --i) {
+ auto& layer = *layers[i - 1];
+ computedClipMax = clipMax(computedClipMax, layer.clip());
+ layer.m_clipMax = computedClipMax;
+ }
}
bool FillLayer::clipOccludesNextLayers(bool firstLayer) const
@@ -328,29 +328,25 @@ bool FillLayer::clipOccludesNextLayers(bool firstLayer) const
return m_clip == m_clipMax;
}
-bool FillLayer::containsImage(StyleImage* s) const
+bool FillLayer::containsImage(StyleImage& image) const
{
- if (!s)
- return false;
- if (m_image && *s == *m_image)
- return true;
- if (m_next)
- return m_next->containsImage(s);
+ for (auto* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_image && image == *layer->m_image)
+ return true;
+ }
return false;
}
bool FillLayer::imagesAreLoaded() const
{
- const FillLayer* curr;
- for (curr = this; curr; curr = curr->next()) {
- if (curr->m_image && !curr->m_image->isLoaded())
+ for (auto* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_image && !layer->m_image->isLoaded())
return false;
}
-
return true;
}
-bool FillLayer::hasOpaqueImage(const RenderElement* renderer) const
+bool FillLayer::hasOpaqueImage(const RenderElement& renderer) const
{
if (!m_image)
return false;
@@ -358,18 +354,83 @@ bool FillLayer::hasOpaqueImage(const RenderElement* renderer) const
if (m_composite == CompositeClear || m_composite == CompositeCopy)
return true;
- if (m_blendMode != BlendModeNormal)
- return false;
+ return m_blendMode == BlendModeNormal && m_composite == CompositeSourceOver && m_image->knownToBeOpaque(&renderer);
+}
- if (m_composite == CompositeSourceOver)
- return m_image->knownToBeOpaque(renderer);
+bool FillLayer::hasRepeatXY() const
+{
+ return m_repeatX == RepeatFill && m_repeatY == RepeatFill;
+}
+bool FillLayer::hasImage() const
+{
+ for (auto* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->image())
+ return true;
+ }
return false;
}
-bool FillLayer::hasRepeatXY() const
+bool FillLayer::hasFixedImage() const
{
- return m_repeatX == RepeatFill && m_repeatY == RepeatFill;
+ for (auto* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_image && layer->m_attachment == FixedBackgroundAttachment)
+ return true;
+ }
+ return false;
+}
+
+static inline bool layerImagesIdentical(const FillLayer& layer1, const FillLayer& layer2)
+{
+ // We just care about pointer equivalency.
+ return layer1.image() == layer2.image();
+}
+
+bool FillLayer::imagesIdentical(const FillLayer* layer1, const FillLayer* layer2)
+{
+ for (; layer1 && layer2; layer1 = layer1->next(), layer2 = layer2->next()) {
+ if (!layerImagesIdentical(*layer1, *layer2))
+ return false;
+ }
+
+ return !layer1 && !layer2;
+}
+
+TextStream& operator<<(TextStream& ts, FillSize fillSize)
+{
+ return ts << fillSize.type << " " << fillSize.size;
+}
+
+TextStream& operator<<(TextStream& ts, const FillLayer& layer)
+{
+ TextStream::GroupScope scope(ts);
+ ts << "fill-layer";
+
+ ts.startGroup();
+ ts << "position " << layer.xPosition() << " " << layer.yPosition();
+ ts.endGroup();
+
+ ts.dumpProperty("size", layer.size());
+
+ ts.startGroup();
+ ts << "background-origin " << layer.backgroundXOrigin() << " " << layer.backgroundYOrigin();
+ ts.endGroup();
+
+ ts.startGroup();
+ ts << "repeat " << layer.repeatX() << " " << layer.repeatY();
+ ts.endGroup();
+
+ ts.dumpProperty("clip", layer.clip());
+ ts.dumpProperty("origin", layer.origin());
+
+ ts.dumpProperty("composite", layer.composite());
+ ts.dumpProperty("blend-mode", layer.blendMode());
+ ts.dumpProperty("mask-type", layer.maskSourceType());
+
+ if (layer.next())
+ ts << *layer.next();
+
+ return ts;
}
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/FillLayer.h b/Source/WebCore/rendering/style/FillLayer.h
index be4818fff..2358b4db2 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
@@ -26,7 +26,6 @@
#define FillLayer_h
#include "GraphicsTypes.h"
-#include "Length.h"
#include "LengthSize.h"
#include "RenderStyleConstants.h"
#include "StyleImage.h"
@@ -42,36 +41,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,8 +84,8 @@ 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; }
@@ -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(PassRefPtr<StyleImage> image) { m_image = 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_backgroundOriginSet = true; }
+ void setBackgroundYOrigin(Edge o) { m_backgroundYOrigin = static_cast<unsigned>(o); m_backgroundOriginSet = 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_backgroundOriginSet = false; }
+ void clearYPosition() { m_yPosSet = false; m_backgroundOriginSet = 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;
@@ -227,8 +202,8 @@ private:
unsigned m_xPosSet : 1;
unsigned m_yPosSet : 1;
unsigned m_backgroundOriginSet : 1;
- unsigned m_backgroundXOrigin : 2; // BackgroundEdgeOrigin
- unsigned m_backgroundYOrigin : 2; // BackgroundEdgeOrigin
+ unsigned m_backgroundXOrigin : 2; // Edge
+ unsigned m_backgroundYOrigin : 2; // Edge
unsigned m_compositeSet : 1;
unsigned m_blendModeSet : 1;
unsigned m_maskSourceTypeSet : 1;
@@ -238,6 +213,9 @@ private:
mutable unsigned m_clipMax : 2; // EFillBox, maximum m_clip value from this to bottom layer
};
+TextStream& operator<<(TextStream&, FillSize);
+TextStream& operator<<(TextStream&, const FillLayer&);
+
} // namespace WebCore
#endif // FillLayer_h
diff --git a/Source/WebCore/rendering/style/GridCoordinate.h b/Source/WebCore/rendering/style/GridCoordinate.h
index 74a97c7ab..21e040dc2 100644
--- a/Source/WebCore/rendering/style/GridCoordinate.h
+++ b/Source/WebCore/rendering/style/GridCoordinate.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
- * Copyright (C) 2013 Igalia S.L.
+ * Copyright (C) 2013, 2014 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,36 +32,92 @@
#ifndef GridCoordinate_h
#define GridCoordinate_h
+#if ENABLE(CSS_GRID_LAYOUT)
+
+#include "GridResolvedPosition.h"
#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
-// A span in a single direction (either rows or columns). Note that |initialPositionIndex|
-// and |finalPositionIndex| are grid areas' indexes, NOT grid lines'. Iterating over the
-// span should include both |initialPositionIndex| and |finalPositionIndex| to be correct.
+// Recommended maximum size for both explicit and implicit grids.
+const unsigned kGridMaxTracks = 1000000;
+
+// A span in a single direction (either rows or columns). Note that |resolvedInitialPosition|
+// and |resolvedFinalPosition| are grid lines' indexes.
+// Iterating over the span shouldn't include |resolvedFinalPosition| to be correct.
class GridSpan {
public:
- static PassOwnPtr<GridSpan> create(size_t initialPosition, size_t finalPosition)
+
+ static GridSpan definiteGridSpan(const GridResolvedPosition& resolvedInitialPosition, const GridResolvedPosition& resolvedFinalPosition)
{
- return adoptPtr(new GridSpan(initialPosition, finalPosition));
+ return GridSpan(resolvedInitialPosition, resolvedFinalPosition, Definite);
}
- GridSpan(size_t initialPosition, size_t finalPosition)
- : initialPositionIndex(initialPosition)
- , finalPositionIndex(finalPosition)
+ static GridSpan indefiniteGridSpan()
{
- ASSERT(initialPositionIndex <= finalPositionIndex);
+ return GridSpan(0, 1, Indefinite);
}
bool operator==(const GridSpan& o) const
{
- return initialPositionIndex == o.initialPositionIndex && finalPositionIndex == o.finalPositionIndex;
+ return m_type == o.m_type && m_resolvedInitialPosition == o.m_resolvedInitialPosition && m_resolvedFinalPosition == o.m_resolvedFinalPosition;
+ }
+
+ unsigned integerSpan() const
+ {
+ ASSERT(isDefinite());
+ return m_resolvedFinalPosition.toInt() - m_resolvedInitialPosition.toInt();
+ }
+
+ const GridResolvedPosition& resolvedInitialPosition() const
+ {
+ ASSERT(isDefinite());
+ return m_resolvedInitialPosition;
+ }
+
+ const GridResolvedPosition& resolvedFinalPosition() const
+ {
+ ASSERT(isDefinite());
+ return m_resolvedFinalPosition;
+ }
+
+ typedef GridResolvedPosition iterator;
+
+ iterator begin() const
+ {
+ ASSERT(isDefinite());
+ return m_resolvedInitialPosition;
+ }
+
+ iterator end() const
+ {
+ ASSERT(isDefinite());
+ return m_resolvedFinalPosition;
}
- size_t initialPositionIndex;
- size_t finalPositionIndex;
+ bool isDefinite() const
+ {
+ return m_type == Definite;
+ }
+
+private:
+
+ enum GridSpanType {Definite, Indefinite};
+
+ GridSpan(const GridResolvedPosition& resolvedInitialPosition, const GridResolvedPosition& resolvedFinalPosition, GridSpanType type)
+ : m_resolvedInitialPosition(std::min(resolvedInitialPosition.toInt(), kGridMaxTracks - 1))
+ , m_resolvedFinalPosition(std::min(resolvedFinalPosition.toInt(), kGridMaxTracks))
+ , m_type(type)
+ {
+ ASSERT(resolvedInitialPosition < resolvedFinalPosition);
+ }
+
+ GridResolvedPosition m_resolvedInitialPosition;
+ GridResolvedPosition m_resolvedFinalPosition;
+ GridSpanType m_type;
+
+
};
// This represents a grid area that spans in both rows' and columns' direction.
@@ -69,8 +125,8 @@ class GridCoordinate {
public:
// HashMap requires a default constuctor.
GridCoordinate()
- : columns(0, 0)
- , rows(0, 0)
+ : columns(GridSpan::indefiniteGridSpan())
+ , rows(GridSpan::indefiniteGridSpan())
{
}
@@ -98,4 +154,6 @@ typedef HashMap<String, GridCoordinate> NamedGridAreaMap;
} // namespace WebCore
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
+
#endif // GridCoordinate_h
diff --git a/Source/WebCore/rendering/style/GridLength.h b/Source/WebCore/rendering/style/GridLength.h
index 3a9ec4e8c..2747007bb 100644
--- a/Source/WebCore/rendering/style/GridLength.h
+++ b/Source/WebCore/rendering/style/GridLength.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
- * Copyright (C) 2013 Igalia S.L.
+ * Copyright (C) 2013, 2014 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,6 +32,8 @@
#ifndef GridLength_h
#define GridLength_h
+#if ENABLE(CSS_GRID_LAYOUT)
+
#include "Length.h"
namespace WebCore {
@@ -41,17 +43,17 @@ namespace WebCore {
// an new unit to Length.h.
class GridLength {
public:
- GridLength()
- : m_length(Undefined)
+ GridLength(const Length& length)
+ : m_length(length)
, m_flex(0)
, m_type(LengthType)
{
+ ASSERT(!length.isUndefined());
}
- GridLength(const Length& length)
- : m_length(length)
- , m_flex(0)
- , m_type(LengthType)
+ explicit GridLength(double flex)
+ : m_flex(flex)
+ , m_type(FlexType)
{
}
@@ -59,14 +61,10 @@ public:
bool isFlex() const { return m_type == FlexType; }
const Length& length() const { ASSERT(isLength()); return m_length; }
- Length& length() { ASSERT(isLength()); return m_length; }
double flex() const { ASSERT(isFlex()); return m_flex; }
- void setFlex(double flex)
- {
- m_type = FlexType;
- m_flex = flex;
- }
+
+ bool isPercentage() const { return m_type == LengthType && m_length.isPercentOrCalculated(); }
bool operator==(const GridLength& o) const
{
@@ -89,4 +87,6 @@ private:
} // namespace WebCore
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
+
#endif // GridLength_h
diff --git a/Source/WebCore/rendering/style/GridPosition.h b/Source/WebCore/rendering/style/GridPosition.h
index 5a276144e..074ae68e2 100644
--- a/Source/WebCore/rendering/style/GridPosition.h
+++ b/Source/WebCore/rendering/style/GridPosition.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013, 2014 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,6 +32,8 @@
#ifndef GridPosition_h
#define GridPosition_h
+#if ENABLE(CSS_GRID_LAYOUT)
+
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -42,6 +45,13 @@ enum GridPositionType {
NamedGridAreaPosition // <ident>
};
+enum GridPositionSide {
+ ColumnStartSide,
+ ColumnEndSide,
+ RowStartSide,
+ RowEndSide
+};
+
class GridPosition {
public:
GridPosition()
@@ -64,6 +74,12 @@ public:
m_namedGridLine = namedGridLine;
}
+ void setAutoPosition()
+ {
+ m_type = AutoPosition;
+ m_integerPosition = 0;
+ }
+
// 'span' values cannot be negative, yet we reuse the <integer> position which can
// be. This means that we have to convert the span position to an integer, losing
// some precision here. It shouldn't be an issue in practice though.
@@ -100,7 +116,7 @@ public:
bool operator==(const GridPosition& other) const
{
- return m_type == other.m_type && m_integerPosition == other.m_integerPosition;
+ return m_type == other.m_type && m_integerPosition == other.m_integerPosition && m_namedGridLine == other.m_namedGridLine;
}
bool shouldBeResolvedAgainstOppositePosition() const
@@ -115,4 +131,6 @@ private:
} // namespace WebCore
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
+
#endif // GridPosition_h
diff --git a/Source/WebCore/rendering/style/GridResolvedPosition.cpp b/Source/WebCore/rendering/style/GridResolvedPosition.cpp
new file mode 100644
index 000000000..7c2101c83
--- /dev/null
+++ b/Source/WebCore/rendering/style/GridResolvedPosition.cpp
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "GridResolvedPosition.h"
+
+#if ENABLE(CSS_GRID_LAYOUT)
+
+#include "GridCoordinate.h"
+#include "RenderBox.h"
+
+namespace WebCore {
+
+static inline bool isColumnSide(GridPositionSide side)
+{
+ return side == ColumnStartSide || side == ColumnEndSide;
+}
+
+static inline bool isStartSide(GridPositionSide side)
+{
+ return side == ColumnStartSide || side == RowStartSide;
+}
+
+static inline GridPositionSide initialPositionSide(GridTrackSizingDirection direction)
+{
+ return direction == ForColumns ? ColumnStartSide : RowStartSide;
+}
+
+static inline GridPositionSide finalPositionSide(GridTrackSizingDirection direction)
+{
+ return direction == ForColumns ? ColumnEndSide : RowEndSide;
+}
+
+static const NamedGridLinesMap& gridLinesForSide(const RenderStyle& style, GridPositionSide side)
+{
+ return isColumnSide(side) ? style.namedGridColumnLines() : style.namedGridRowLines();
+}
+
+static const String implicitNamedGridLineForSide(const String& lineName, GridPositionSide side)
+{
+ return lineName + (isStartSide(side) ? "-start" : "-end");
+}
+
+bool GridResolvedPosition::isNonExistentNamedLineOrArea(const String& lineName, const RenderStyle& style, GridPositionSide side)
+{
+ const NamedGridLinesMap& gridLineNames = gridLinesForSide(style, side);
+ return !gridLineNames.contains(implicitNamedGridLineForSide(lineName, side)) && !gridLineNames.contains(lineName);
+}
+
+static void adjustGridPositionsFromStyle(const RenderStyle& gridContainerStyle, const RenderBox& gridItem, GridTrackSizingDirection direction, GridPosition& initialPosition, GridPosition& finalPosition)
+{
+ bool isForColumns = direction == ForColumns;
+ initialPosition = isForColumns ? gridItem.style().gridItemColumnStart() : gridItem.style().gridItemRowStart();
+ finalPosition = isForColumns ? gridItem.style().gridItemColumnEnd() : gridItem.style().gridItemRowEnd();
+
+ // We must handle the placement error handling code here instead of in the StyleAdjuster because we don't want to
+ // overwrite the specified values.
+ if (initialPosition.isSpan() && finalPosition.isSpan())
+ finalPosition.setAutoPosition();
+
+ // Try to early detect the case of non existing named grid lines. This way we could assume later that
+ // GridResolvedPosition::resolveGrisPositionFromStyle() won't require the autoplacement to run, i.e., it'll always return a
+ // valid resolved position.
+ if (initialPosition.isNamedGridArea() && GridResolvedPosition::isNonExistentNamedLineOrArea(initialPosition.namedGridLine(), gridContainerStyle, initialPositionSide(direction)))
+ initialPosition.setAutoPosition();
+
+ if (finalPosition.isNamedGridArea() && GridResolvedPosition::isNonExistentNamedLineOrArea(finalPosition.namedGridLine(), gridContainerStyle, finalPositionSide(direction)))
+ finalPosition.setAutoPosition();
+
+ // If the grid item has an automatic position and a grid span for a named line in a given dimension, instead treat the grid span as one.
+ if (initialPosition.isAuto() && finalPosition.isSpan() && !finalPosition.namedGridLine().isNull())
+ finalPosition.setSpanPosition(1, String());
+ if (finalPosition.isAuto() && initialPosition.isSpan() && !initialPosition.namedGridLine().isNull())
+ initialPosition.setSpanPosition(1, String());
+}
+
+unsigned GridResolvedPosition::explicitGridColumnCount(const RenderStyle& gridContainerStyle)
+{
+ return std::min<unsigned>(gridContainerStyle.gridColumns().size(), kGridMaxTracks);
+}
+
+unsigned GridResolvedPosition::explicitGridRowCount(const RenderStyle& gridContainerStyle)
+{
+ return std::min<unsigned>(gridContainerStyle.gridRows().size(), kGridMaxTracks);
+}
+
+static unsigned explicitGridSizeForSide(const RenderStyle& gridContainerStyle, GridPositionSide side)
+{
+ return isColumnSide(side) ? GridResolvedPosition::explicitGridColumnCount(gridContainerStyle) : GridResolvedPosition::explicitGridRowCount(gridContainerStyle);
+}
+
+static GridResolvedPosition resolveNamedGridLinePositionFromStyle(const RenderStyle& gridContainerStyle, const GridPosition& position, GridPositionSide side)
+{
+ ASSERT(!position.namedGridLine().isNull());
+
+ const NamedGridLinesMap& gridLinesNames = isColumnSide(side) ? gridContainerStyle.namedGridColumnLines() : gridContainerStyle.namedGridRowLines();
+ NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGridLine());
+ if (it == gridLinesNames.end()) {
+ if (position.isPositive())
+ return 0;
+ const unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side);
+ return lastLine;
+ }
+
+ unsigned namedGridLineIndex;
+ if (position.isPositive())
+ namedGridLineIndex = std::min<unsigned>(position.integerPosition(), it->value.size()) - 1;
+ else
+ namedGridLineIndex = std::max<int>(0, it->value.size() - abs(position.integerPosition()));
+ return it->value[namedGridLineIndex];
+}
+
+static GridSpan resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, const Vector<unsigned>& gridLines)
+{
+ if (!resolvedOppositePosition.toInt())
+ return GridSpan::definiteGridSpan(resolvedOppositePosition, resolvedOppositePosition.next());
+
+ unsigned firstLineBeforePositionIndex = 0;
+ auto firstLineBeforePosition = std::lower_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition.toInt());
+ if (firstLineBeforePosition != gridLines.end())
+ firstLineBeforePositionIndex = firstLineBeforePosition - gridLines.begin();
+
+ unsigned gridLineIndex = std::max<int>(0, firstLineBeforePositionIndex - position.spanPosition());
+
+ GridResolvedPosition resolvedGridLinePosition = GridResolvedPosition(gridLines[gridLineIndex]);
+ if (resolvedGridLinePosition >= resolvedOppositePosition)
+ resolvedGridLinePosition = resolvedOppositePosition.prev();
+ return GridSpan::definiteGridSpan(std::min<GridResolvedPosition>(resolvedGridLinePosition, resolvedOppositePosition), resolvedOppositePosition);
+}
+
+static GridSpan resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, const Vector<unsigned>& gridLines)
+{
+ ASSERT(gridLines.size());
+ unsigned firstLineAfterOppositePositionIndex = gridLines.size() - 1;
+ const unsigned* firstLineAfterOppositePosition = std::upper_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition);
+ if (firstLineAfterOppositePosition != gridLines.end())
+ firstLineAfterOppositePositionIndex = firstLineAfterOppositePosition - gridLines.begin();
+
+ unsigned gridLineIndex = std::min<unsigned>(gridLines.size() - 1, firstLineAfterOppositePositionIndex + position.spanPosition() - 1);
+ GridResolvedPosition resolvedGridLinePosition = gridLines[gridLineIndex];
+ if (resolvedGridLinePosition <= resolvedOppositePosition)
+ resolvedGridLinePosition = resolvedOppositePosition.next();
+ return GridSpan::definiteGridSpan(resolvedOppositePosition, resolvedGridLinePosition);
+}
+
+static GridSpan resolveNamedGridLinePositionAgainstOppositePosition(const RenderStyle& gridContainerStyle, const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, GridPositionSide side)
+{
+ ASSERT(position.isSpan());
+ ASSERT(!position.namedGridLine().isNull());
+ // Negative positions are not allowed per the specification and should have been handled during parsing.
+ ASSERT(position.spanPosition() > 0);
+
+ const NamedGridLinesMap& gridLinesNames = isColumnSide(side) ? gridContainerStyle.namedGridColumnLines() : gridContainerStyle.namedGridRowLines();
+ NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGridLine());
+
+ // If there is no named grid line of that name, we resolve the position to 'auto' (which is equivalent to 'span 1' in this case).
+ // See http://lists.w3.org/Archives/Public/www-style/2013Jun/0394.html.
+ if (it == gridLinesNames.end()) {
+ if (isStartSide(side) && resolvedOppositePosition.toInt())
+ return GridSpan::definiteGridSpan(resolvedOppositePosition.prev(), resolvedOppositePosition);
+ return GridSpan::definiteGridSpan(resolvedOppositePosition, resolvedOppositePosition.next());
+ }
+
+ if (side == RowStartSide || side == ColumnStartSide)
+ return resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition(resolvedOppositePosition, position, it->value);
+
+ return resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition(resolvedOppositePosition, position, it->value);
+}
+
+static GridSpan resolveGridPositionAgainstOppositePosition(const RenderStyle& gridContainerStyle, const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, GridPositionSide side)
+{
+ if (position.isAuto()) {
+ if (isStartSide(side) && resolvedOppositePosition.toInt())
+ return GridSpan::definiteGridSpan(resolvedOppositePosition.prev(), resolvedOppositePosition);
+ return GridSpan::definiteGridSpan(resolvedOppositePosition, resolvedOppositePosition.next());
+ }
+
+ ASSERT(position.isSpan());
+ ASSERT(position.spanPosition() > 0);
+
+ if (!position.namedGridLine().isNull()) {
+ // span 2 'c' -> we need to find the appropriate grid line before / after our opposite position.
+ return resolveNamedGridLinePositionAgainstOppositePosition(gridContainerStyle, resolvedOppositePosition, position, side);
+ }
+
+ // 'span 1' is contained inside a single grid track regardless of the direction.
+ // That's why the CSS span value is one more than the offset we apply.
+ unsigned positionOffset = position.spanPosition();
+ if (isStartSide(side)) {
+ if (!resolvedOppositePosition.toInt())
+ return GridSpan::definiteGridSpan(resolvedOppositePosition, resolvedOppositePosition.next());
+
+ unsigned initialResolvedPosition = std::max<int>(0, resolvedOppositePosition.toInt() - positionOffset);
+ return GridSpan::definiteGridSpan(initialResolvedPosition, resolvedOppositePosition);
+ }
+
+ return GridSpan::definiteGridSpan(resolvedOppositePosition, resolvedOppositePosition.toInt() + positionOffset);
+}
+
+GridSpan GridResolvedPosition::resolveGridPositionsFromAutoPlacementPosition(const RenderStyle& gridContainerStyle, const RenderBox& gridItem, GridTrackSizingDirection direction, const GridResolvedPosition& resolvedInitialPosition)
+{
+ GridPosition initialPosition, finalPosition;
+ adjustGridPositionsFromStyle(gridContainerStyle, gridItem, direction, initialPosition, finalPosition);
+
+ GridPositionSide finalSide = finalPositionSide(direction);
+ // This method will only be used when both positions need to be resolved against the opposite one.
+ ASSERT(initialPosition.shouldBeResolvedAgainstOppositePosition() && finalPosition.shouldBeResolvedAgainstOppositePosition());
+
+ GridResolvedPosition resolvedFinalPosition = resolvedInitialPosition.next();
+
+ if (initialPosition.isSpan())
+ return resolveGridPositionAgainstOppositePosition(gridContainerStyle, resolvedInitialPosition, initialPosition, finalSide);
+ if (finalPosition.isSpan())
+ return resolveGridPositionAgainstOppositePosition(gridContainerStyle, resolvedInitialPosition, finalPosition, finalSide);
+
+ return GridSpan::definiteGridSpan(resolvedInitialPosition, resolvedFinalPosition);
+}
+
+static GridResolvedPosition resolveGridPositionFromStyle(const RenderStyle& gridContainerStyle, const GridPosition& position, GridPositionSide side)
+{
+ switch (position.type()) {
+ case ExplicitPosition: {
+ ASSERT(position.integerPosition());
+
+ if (!position.namedGridLine().isNull())
+ return resolveNamedGridLinePositionFromStyle(gridContainerStyle, position, side);
+
+ // Handle <integer> explicit position.
+ if (position.isPositive())
+ return position.integerPosition() - 1;
+
+ unsigned resolvedPosition = abs(position.integerPosition()) - 1;
+ const unsigned endOfTrack = explicitGridSizeForSide(gridContainerStyle, side);
+
+ // Per http://lists.w3.org/Archives/Public/www-style/2013Mar/0589.html, we clamp negative value to the first line.
+ if (endOfTrack < resolvedPosition)
+ return 0;
+
+ return endOfTrack - resolvedPosition;
+ }
+ case NamedGridAreaPosition:
+ {
+ // First attempt to match the grid area's edge to a named grid area: if there is a named line with the name
+ // ''<custom-ident>-start (for grid-*-start) / <custom-ident>-end'' (for grid-*-end), contributes the first such
+ // line to the grid item's placement.
+ String namedGridLine = position.namedGridLine();
+ ASSERT(!GridResolvedPosition::isNonExistentNamedLineOrArea(namedGridLine, gridContainerStyle, side));
+
+ const NamedGridLinesMap& gridLineNames = gridLinesForSide(gridContainerStyle, side);
+ auto implicitLine = gridLineNames.find(implicitNamedGridLineForSide(namedGridLine, side));
+ if (implicitLine != gridLineNames.end())
+ return implicitLine->value[0];
+
+ // Otherwise, if there is a named line with the specified name, contributes the first such line to the grid
+ // item's placement.
+ auto explicitLine = gridLineNames.find(namedGridLine);
+ if (explicitLine != gridLineNames.end())
+ return explicitLine->value[0];
+
+ // If none of the above works specs mandate us to treat it as auto BUT we should have detected it before calling
+ // this function in resolveGridPositionsFromStyle(). We should be covered anyway by the ASSERT at the beginning
+ // of this case block.
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+ case AutoPosition:
+ case SpanPosition:
+ // 'auto' and span depend on the opposite position for resolution (e.g. grid-row: auto / 1 or grid-column: span 3 / "myHeader").
+ ASSERT_NOT_REACHED();
+ return GridResolvedPosition(0);
+ }
+ ASSERT_NOT_REACHED();
+ return GridResolvedPosition(0);
+}
+
+GridSpan GridResolvedPosition::resolveGridPositionsFromStyle(const RenderStyle& gridContainerStyle, const RenderBox& gridItem, GridTrackSizingDirection direction)
+{
+ GridPosition initialPosition, finalPosition;
+ adjustGridPositionsFromStyle(gridContainerStyle, gridItem, direction, initialPosition, finalPosition);
+
+ GridPositionSide initialSide = initialPositionSide(direction);
+ GridPositionSide finalSide = finalPositionSide(direction);
+
+ // We can't get our grid positions without running the auto placement algorithm.
+ if (initialPosition.shouldBeResolvedAgainstOppositePosition() && finalPosition.shouldBeResolvedAgainstOppositePosition())
+ return GridSpan::indefiniteGridSpan();
+
+ if (initialPosition.shouldBeResolvedAgainstOppositePosition()) {
+ // Infer the position from the final position ('auto / 1' or 'span 2 / 3' case).
+ auto finalResolvedPosition = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, finalSide);
+ return resolveGridPositionAgainstOppositePosition(gridContainerStyle, finalResolvedPosition, initialPosition, initialSide);
+ }
+
+ if (finalPosition.shouldBeResolvedAgainstOppositePosition()) {
+ // Infer our position from the initial position ('1 / auto' or '3 / span 2' case).
+ auto initialResolvedPosition = resolveGridPositionFromStyle(gridContainerStyle, initialPosition, initialSide);
+ return resolveGridPositionAgainstOppositePosition(gridContainerStyle, initialResolvedPosition, finalPosition, finalSide);
+ }
+
+ GridResolvedPosition resolvedInitialPosition = resolveGridPositionFromStyle(gridContainerStyle, initialPosition, initialSide);
+ GridResolvedPosition resolvedFinalPosition = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, finalSide);
+
+ if (resolvedInitialPosition > resolvedFinalPosition)
+ std::swap(resolvedInitialPosition, resolvedFinalPosition);
+ else if (resolvedInitialPosition == resolvedFinalPosition)
+ resolvedFinalPosition = resolvedInitialPosition.next();
+
+ return GridSpan::definiteGridSpan(resolvedInitialPosition, std::max(resolvedInitialPosition, resolvedFinalPosition));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_GRID_LAYOUT)
diff --git a/Source/WebCore/rendering/style/GridResolvedPosition.h b/Source/WebCore/rendering/style/GridResolvedPosition.h
new file mode 100644
index 000000000..3d91eecb0
--- /dev/null
+++ b/Source/WebCore/rendering/style/GridResolvedPosition.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 GridResolvedPosition_h
+#define GridResolvedPosition_h
+
+#if ENABLE(CSS_GRID_LAYOUT)
+
+#include "GridPosition.h"
+
+namespace WebCore {
+
+class GridSpan;
+class RenderBox;
+class RenderStyle;
+
+enum GridTrackSizingDirection {
+ ForColumns,
+ ForRows
+};
+
+// This class represents a line index into one of the dimensions of the grid array.
+// Wraps an unsigned integer just for the purpose of knowing what we manipulate in the grid code.
+class GridResolvedPosition {
+public:
+ GridResolvedPosition(unsigned position)
+ : m_integerPosition(position)
+ {
+ }
+
+ GridResolvedPosition& operator*()
+ {
+ return *this;
+ }
+
+ GridResolvedPosition& operator++()
+ {
+ m_integerPosition++;
+ return *this;
+ }
+
+ bool operator==(const GridResolvedPosition& other) const
+ {
+ return m_integerPosition == other.m_integerPosition;
+ }
+
+ bool operator!=(const GridResolvedPosition& other) const
+ {
+ return m_integerPosition != other.m_integerPosition;
+ }
+
+ bool operator<(const GridResolvedPosition& other) const
+ {
+ return m_integerPosition < other.m_integerPosition;
+ }
+
+ bool operator>(const GridResolvedPosition& other) const
+ {
+ return m_integerPosition > other.m_integerPosition;
+ }
+
+ bool operator<=(const GridResolvedPosition& other) const
+ {
+ return m_integerPosition <= other.m_integerPosition;
+ }
+
+ bool operator>=(const GridResolvedPosition& other) const
+ {
+ return m_integerPosition >= other.m_integerPosition;
+ }
+
+ unsigned toInt() const
+ {
+ return m_integerPosition;
+ }
+
+ GridResolvedPosition next() const
+ {
+ return GridResolvedPosition(m_integerPosition + 1);
+ }
+
+ GridResolvedPosition prev() const
+ {
+ return m_integerPosition ? m_integerPosition - 1 : 0;
+ }
+
+ static GridSpan resolveGridPositionsFromAutoPlacementPosition(const RenderStyle&, const RenderBox&, GridTrackSizingDirection, const GridResolvedPosition&);
+ static GridSpan resolveGridPositionsFromStyle(const RenderStyle&, const RenderBox&, GridTrackSizingDirection);
+ static unsigned explicitGridColumnCount(const RenderStyle&);
+ static unsigned explicitGridRowCount(const RenderStyle&);
+ static bool isNonExistentNamedLineOrArea(const String& lineName, const RenderStyle&, GridPositionSide);
+
+private:
+ unsigned m_integerPosition;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_GRID_LAYOUT)
+
+#endif // GridResolvedPosition_h
diff --git a/Source/WebCore/rendering/style/GridTrackSize.h b/Source/WebCore/rendering/style/GridTrackSize.h
index d5fca8948..6063792ca 100644
--- a/Source/WebCore/rendering/style/GridTrackSize.h
+++ b/Source/WebCore/rendering/style/GridTrackSize.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013, 2014 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,7 +32,10 @@
#ifndef GridTrackSize_h
#define GridTrackSize_h
+#if ENABLE(CSS_GRID_LAYOUT)
+
#include "GridLength.h"
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -42,11 +46,20 @@ enum GridTrackSizeType {
class GridTrackSize {
public:
- GridTrackSize(LengthType type = Undefined)
+ GridTrackSize(const GridLength& length)
: m_type(LengthTrackSizing)
- , m_minTrackBreadth(type)
- , m_maxTrackBreadth(type)
+ , m_minTrackBreadth(length)
+ , m_maxTrackBreadth(length)
{
+ cacheMinMaxTrackBreadthTypes();
+ }
+
+ GridTrackSize(const GridLength& minTrackBreadth, const GridLength& maxTrackBreadth)
+ : m_type(MinMaxTrackSizing)
+ , m_minTrackBreadth(minTrackBreadth)
+ , m_maxTrackBreadth(maxTrackBreadth)
+ {
+ cacheMinMaxTrackBreadthTypes();
}
const GridLength& length() const
@@ -54,64 +67,61 @@ public:
ASSERT(m_type == LengthTrackSizing);
ASSERT(m_minTrackBreadth == m_maxTrackBreadth);
const GridLength& minTrackBreadth = m_minTrackBreadth;
- ASSERT(!minTrackBreadth.isLength() || !minTrackBreadth.length().isUndefined());
return minTrackBreadth;
}
- void setLength(const GridLength& length)
- {
- m_type = LengthTrackSizing;
- m_minTrackBreadth = length;
- m_maxTrackBreadth = length;
- }
+ const GridLength& minTrackBreadth() const { return m_minTrackBreadth; }
- const GridLength& minTrackBreadth() const
- {
- ASSERT(!m_minTrackBreadth.isLength() || !m_minTrackBreadth.length().isUndefined());
- if (m_minTrackBreadth.isLength() && m_minTrackBreadth.length().isAuto()) {
- DEFINE_STATIC_LOCAL(GridLength, minContent, (MinContent));
- return minContent;
- }
- return m_minTrackBreadth;
- }
-
- const GridLength& maxTrackBreadth() const
- {
- ASSERT(!m_maxTrackBreadth.isLength() || !m_maxTrackBreadth.length().isUndefined());
- if (m_maxTrackBreadth.isLength() && m_maxTrackBreadth.length().isAuto()) {
- DEFINE_STATIC_LOCAL(GridLength, maxContent, (MaxContent));
- return maxContent;
- }
- return m_maxTrackBreadth;
- }
-
- void setMinMax(const GridLength& minTrackBreadth, const GridLength& maxTrackBreadth)
- {
- m_type = MinMaxTrackSizing;
- m_minTrackBreadth = minTrackBreadth;
- m_maxTrackBreadth = maxTrackBreadth;
- }
+ const GridLength& maxTrackBreadth() const { return m_maxTrackBreadth; }
GridTrackSizeType type() const { return m_type; }
bool isContentSized() const { return m_minTrackBreadth.isContentSized() || m_maxTrackBreadth.isContentSized(); }
+ bool isPercentage() const { return m_type == LengthTrackSizing && length().isLength() && length().length().isPercentOrCalculated(); }
+
bool operator==(const GridTrackSize& other) const
{
return m_type == other.m_type && m_minTrackBreadth == other.m_minTrackBreadth && m_maxTrackBreadth == other.m_maxTrackBreadth;
}
- bool hasMinOrMaxContentMinTrackBreadth() const { return minTrackBreadth().isLength() && (minTrackBreadth().length().isMinContent() || minTrackBreadth().length().isMaxContent()); }
- bool hasMaxContentMinTrackBreadth() const { return minTrackBreadth().isLength() && minTrackBreadth().length().isMaxContent(); }
- bool hasMinOrMaxContentMaxTrackBreadth() const { return maxTrackBreadth().isLength() && (maxTrackBreadth().length().isMinContent() || maxTrackBreadth().length().isMaxContent()); }
- bool hasMaxContentMaxTrackBreadth() const { return maxTrackBreadth().isLength() && maxTrackBreadth().length().isMaxContent(); }
+ void cacheMinMaxTrackBreadthTypes()
+ {
+ m_minTrackBreadthIsAuto = minTrackBreadth().isLength() && minTrackBreadth().length().isAuto();
+ m_minTrackBreadthIsMinContent = minTrackBreadth().isLength() && minTrackBreadth().length().isMinContent();
+ m_minTrackBreadthIsMaxContent = minTrackBreadth().isLength() && minTrackBreadth().length().isMaxContent();
+ m_maxTrackBreadthIsMaxContent = maxTrackBreadth().isLength() && maxTrackBreadth().length().isMaxContent();
+ m_maxTrackBreadthIsMinContent = maxTrackBreadth().isLength() && maxTrackBreadth().length().isMinContent();
+ m_maxTrackBreadthIsAuto = maxTrackBreadth().isLength() && maxTrackBreadth().length().isAuto();
+ }
+
+ bool hasIntrinsicMinTrackBreadth() const { return m_minTrackBreadthIsMaxContent || m_minTrackBreadthIsMinContent || m_minTrackBreadthIsAuto; }
+ bool hasMinOrMaxContentMinTrackBreadth() const { return m_minTrackBreadthIsMaxContent || m_minTrackBreadthIsMinContent; }
+ bool hasAutoMinTrackBreadth() const { return m_minTrackBreadthIsAuto; }
+ bool hasAutoMaxTrackBreadth() const { return m_maxTrackBreadthIsAuto; }
+ bool hasMaxContentMaxTrackBreadth() const { return m_maxTrackBreadthIsMaxContent; }
+ bool hasMaxContentOrAutoMaxTrackBreadth() const { return m_maxTrackBreadthIsMaxContent || m_maxTrackBreadthIsAuto; }
+ bool hasMinContentMaxTrackBreadth() const { return m_maxTrackBreadthIsMinContent; }
+ bool hasMinOrMaxContentMaxTrackBreadth() const { return m_maxTrackBreadthIsMaxContent || m_maxTrackBreadthIsMinContent; }
+ bool hasMaxContentMinTrackBreadth() const { return m_minTrackBreadthIsMaxContent; }
+ bool hasMinContentMinTrackBreadth() const { return m_minTrackBreadthIsMinContent; }
+ bool hasMaxContentMinTrackBreadthAndMaxContentMaxTrackBreadth() const { return m_minTrackBreadthIsMaxContent && m_maxTrackBreadthIsMaxContent; }
+ bool hasAutoOrMinContentMinTrackBreadthAndIntrinsicMaxTrackBreadth() const { return (m_minTrackBreadthIsMinContent || m_minTrackBreadthIsAuto) && (m_maxTrackBreadthIsAuto || hasMinOrMaxContentMaxTrackBreadth()); }
private:
GridTrackSizeType m_type;
GridLength m_minTrackBreadth;
GridLength m_maxTrackBreadth;
+ bool m_minTrackBreadthIsAuto;
+ bool m_minTrackBreadthIsMaxContent;
+ bool m_minTrackBreadthIsMinContent;
+ bool m_maxTrackBreadthIsAuto;
+ bool m_maxTrackBreadthIsMaxContent;
+ bool m_maxTrackBreadthIsMinContent;
};
} // namespace WebCore
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
+
#endif // GridTrackSize_h
diff --git a/Source/WebCore/rendering/style/KeyframeList.cpp b/Source/WebCore/rendering/style/KeyframeList.cpp
index a127b468b..545bca23a 100644
--- a/Source/WebCore/rendering/style/KeyframeList.cpp
+++ b/Source/WebCore/rendering/style/KeyframeList.cpp
@@ -21,10 +21,27 @@
#include "config.h"
#include "KeyframeList.h"
+
+#include "Animation.h"
#include "RenderObject.h"
namespace WebCore {
+TimingFunction* KeyframeValue::timingFunction(const AtomicString& name) const
+{
+ const RenderStyle* keyframeStyle = style();
+ if (!keyframeStyle || !keyframeStyle->animations())
+ return nullptr;
+
+ for (size_t i = 0; i < keyframeStyle->animations()->size(); ++i) {
+ const Animation& animation = keyframeStyle->animations()->animation(i);
+ if (name == animation.name())
+ return animation.timingFunction().get();
+ }
+
+ return nullptr;
+}
+
KeyframeList::~KeyframeList()
{
clear();
diff --git a/Source/WebCore/rendering/style/KeyframeList.h b/Source/WebCore/rendering/style/KeyframeList.h
index 6b8c7f323..4df5f4db6 100644
--- a/Source/WebCore/rendering/style/KeyframeList.h
+++ b/Source/WebCore/rendering/style/KeyframeList.h
@@ -35,6 +35,7 @@
namespace WebCore {
class RenderStyle;
+class TimingFunction;
class KeyframeValue {
public:
@@ -54,6 +55,8 @@ public:
const RenderStyle* style() const { return m_style.get(); }
void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; }
+ TimingFunction* timingFunction(const AtomicString& name) const;
+
private:
double m_key;
HashSet<CSSPropertyID> m_properties; // The properties specified in this keyframe.
@@ -79,13 +82,13 @@ public:
void addProperty(CSSPropertyID prop) { m_properties.add(prop); }
bool containsProperty(CSSPropertyID prop) const { return m_properties.contains(prop); }
- HashSet<CSSPropertyID>::const_iterator beginProperties() const { return m_properties.begin(); }
- HashSet<CSSPropertyID>::const_iterator endProperties() const { return m_properties.end(); }
+ const HashSet<CSSPropertyID>& properties() const { return m_properties; }
void clear();
bool isEmpty() const { return m_keyframes.isEmpty(); }
size_t size() const { return m_keyframes.size(); }
const KeyframeValue& operator[](size_t index) const { return m_keyframes[index]; }
+ const Vector<KeyframeValue>& keyframes() const { return m_keyframes; }
private:
AtomicString m_animationName;
diff --git a/Source/WebCore/rendering/style/NinePieceImage.cpp b/Source/WebCore/rendering/style/NinePieceImage.cpp
index 43bd1b043..b4c33f4f0 100644
--- a/Source/WebCore/rendering/style/NinePieceImage.cpp
+++ b/Source/WebCore/rendering/style/NinePieceImage.cpp
@@ -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, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2013, 2015 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
@@ -23,7 +23,12 @@
#include "config.h"
#include "NinePieceImage.h"
+
+#include "GraphicsContext.h"
+#include "LengthFunctions.h"
+#include "RenderStyle.h"
#include <wtf/NeverDestroyed.h>
+#include <wtf/PointerComparison.h>
namespace WebCore {
@@ -42,19 +47,188 @@ NinePieceImage::NinePieceImage(PassRefPtr<StyleImage> image, LengthBox imageSlic
: m_data(NinePieceImageData::create())
{
m_data.access()->image = image;
- m_data.access()->imageSlices = std::move(imageSlices);
- m_data.access()->borderSlices = std::move(borderSlices);
- m_data.access()->outset = std::move(outset);
+ 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)
+{
+ if (length.isRelative())
+ return length.value() * width;
+ if (length.isAuto())
+ return slice;
+ return valueForLength(length, extent);
+}
+
+LayoutBoxExtent NinePieceImage::computeSlices(const LayoutSize& size, const LengthBox& lengths, int scaleFactor)
+{
+ LayoutUnit top = std::min<LayoutUnit>(size.height(), valueForLength(lengths.top(), size.height())) * scaleFactor;
+ LayoutUnit right = std::min<LayoutUnit>(size.width(), valueForLength(lengths.right(), size.width())) * scaleFactor;
+ LayoutUnit bottom = std::min<LayoutUnit>(size.height(), valueForLength(lengths.bottom(), size.height())) * scaleFactor;
+ LayoutUnit left = std::min<LayoutUnit>(size.width(), valueForLength(lengths.left(), size.width())) * scaleFactor;
+ return LayoutBoxExtent(top, right, bottom, left);
+}
+
+LayoutBoxExtent NinePieceImage::computeSlices(const LayoutSize& size, const LengthBox& lengths, const FloatBoxExtent& widths, const LayoutBoxExtent& slices)
+{
+ LayoutUnit top = computeSlice(lengths.top(), widths.top(), slices.top(), size.height());
+ LayoutUnit right = computeSlice(lengths.right(), widths.right(), slices.right(), size.width());
+ LayoutUnit bottom = computeSlice(lengths.bottom(), widths.bottom(), slices.bottom(), size.height());
+ LayoutUnit left = computeSlice(lengths.left(), widths.left(), slices.left(), size.width());
+ return LayoutBoxExtent(top, right, bottom, left);
+}
+
+void NinePieceImage::scaleSlicesIfNeeded(const LayoutSize& size, LayoutBoxExtent& slices, float deviceScaleFactor)
+{
+ LayoutUnit width = std::max<LayoutUnit>(1 / deviceScaleFactor, slices.left() + slices.right());
+ LayoutUnit height = std::max<LayoutUnit>(1 / deviceScaleFactor, slices.top() + slices.bottom());
+
+ float sliceScaleFactor = std::min((float)size.width() / width, (float)size.height() / height);
+
+ if (sliceScaleFactor >= 1)
+ return;
+
+ // All slices are reduced by multiplying them by sliceScaleFactor.
+ slices.top() *= sliceScaleFactor;
+ slices.right() *= sliceScaleFactor;
+ slices.bottom() *= sliceScaleFactor;
+ slices.left() *= sliceScaleFactor;
+}
+
+bool NinePieceImage::isEmptyPieceRect(ImagePiece piece, const LayoutBoxExtent& slices)
+{
+ if (piece == MiddlePiece)
+ return false;
+
+ PhysicalBoxSide horizontalSide = imagePieceHorizontalSide(piece);
+ PhysicalBoxSide verticalSide = imagePieceVerticalSide(piece);
+ return !((horizontalSide == NilSide || slices.at(horizontalSide)) && (verticalSide == NilSide || slices.at(verticalSide)));
+}
+
+bool NinePieceImage::isEmptyPieceRect(ImagePiece piece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects)
+{
+ return destinationRects[piece].isEmpty() || sourceRects[piece].isEmpty();
+}
+
+Vector<FloatRect> NinePieceImage::computeNineRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor)
+{
+ FloatRect inner = outer;
+ inner.move(slices.left(), slices.top());
+ inner.contract(slices.left() + slices.right(), slices.top() + slices.bottom());
+ ASSERT(outer.contains(inner));
+
+ Vector<FloatRect> rects(MaxPiece);
+
+ rects[TopLeftPiece] = snapRectToDevicePixels(outer.x(), outer.y(), slices.left(), slices.top(), deviceScaleFactor);
+ rects[BottomLeftPiece] = snapRectToDevicePixels(outer.x(), inner.maxY(), slices.left(), slices.bottom(), deviceScaleFactor);
+ rects[LeftPiece] = snapRectToDevicePixels(outer.x(), inner.y(), slices.left(), inner.height(), deviceScaleFactor);
+
+ rects[TopRightPiece] = snapRectToDevicePixels(inner.maxX(), outer.y(), slices.right(), slices.top(), deviceScaleFactor);
+ rects[BottomRightPiece] = snapRectToDevicePixels(inner.maxX(), inner.maxY(), slices.right(), slices.bottom(), deviceScaleFactor);
+ rects[RightPiece] = snapRectToDevicePixels(inner.maxX(), inner.y(), slices.right(), inner.height(), deviceScaleFactor);
+
+ rects[TopPiece] = snapRectToDevicePixels(inner.x(), outer.y(), inner.width(), slices.top(), deviceScaleFactor);
+ rects[BottomPiece] = snapRectToDevicePixels(inner.x(), inner.maxY(), inner.width(), slices.bottom(), deviceScaleFactor);
+
+ rects[MiddlePiece] = snapRectToDevicePixels(inner.x(), inner.y(), inner.width(), inner.height(), deviceScaleFactor);
+ return rects;
+}
+
+FloatSize NinePieceImage::computeSideTileScale(ImagePiece piece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects)
+{
+ ASSERT(!isCornerPiece(piece) && !isMiddlePiece(piece));
+ if (isEmptyPieceRect(piece, destinationRects, sourceRects))
+ return FloatSize(1, 1);
+
+ float scale;
+ if (isHorizontalPiece(piece))
+ scale = destinationRects[piece].height() / sourceRects[piece].height();
+ else
+ scale = destinationRects[piece].width() / sourceRects[piece].width();
+
+ return FloatSize(scale, scale);
+}
+
+FloatSize NinePieceImage::computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
+{
+ FloatSize scale(1, 1);
+ if (isEmptyPieceRect(MiddlePiece, destinationRects, sourceRects))
+ return scale;
+
+ // Unlike the side pieces, the middle piece can have "stretch" specified in one axis but not the other.
+ // In fact the side pieces don't even use the scale factor unless they have a rule other than "stretch".
+ if (hRule == StretchImageRule)
+ scale.setWidth(destinationRects[MiddlePiece].width() / sourceRects[MiddlePiece].width());
+ else if (!isEmptyPieceRect(TopPiece, destinationRects, sourceRects))
+ scale.setWidth(scales[TopPiece].width());
+ else if (!isEmptyPieceRect(BottomPiece, destinationRects, sourceRects))
+ scale.setWidth(scales[BottomPiece].width());
+
+ if (vRule == StretchImageRule)
+ scale.setHeight(destinationRects[MiddlePiece].height() / sourceRects[MiddlePiece].height());
+ else if (!isEmptyPieceRect(LeftPiece, destinationRects, sourceRects))
+ scale.setHeight(scales[LeftPiece].height());
+ else if (!isEmptyPieceRect(RightPiece, destinationRects, sourceRects))
+ scale.setHeight(scales[RightPiece].height());
+
+ return scale;
+}
+
+Vector<FloatSize> NinePieceImage::computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
+{
+ Vector<FloatSize> scales(MaxPiece, FloatSize(1, 1));
+
+ scales[TopPiece] = computeSideTileScale(TopPiece, destinationRects, sourceRects);
+ scales[RightPiece] = computeSideTileScale(RightPiece, destinationRects, sourceRects);
+ scales[BottomPiece] = computeSideTileScale(BottomPiece, destinationRects, sourceRects);
+ scales[LeftPiece] = computeSideTileScale(LeftPiece, destinationRects, sourceRects);
+
+ scales[MiddlePiece] = computeMiddleTileScale(scales, destinationRects, sourceRects, hRule, vRule);
+ return scales;
+}
+
+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());
+
+ LayoutBoxExtent sourceSlices = computeSlices(source, imageSlices(), styleImage->imageScaleFactor());
+ LayoutBoxExtent destinationSlices = computeSlices(destination.size(), borderSlices(), style.borderWidth(), sourceSlices);
+
+ scaleSlicesIfNeeded(destination.size(), destinationSlices, deviceScaleFactor);
+
+ Vector<FloatRect> destinationRects = computeNineRects(destination, destinationSlices, deviceScaleFactor);
+ Vector<FloatRect> sourceRects = computeNineRects(FloatRect(FloatPoint(), source), sourceSlices, deviceScaleFactor);
+ Vector<FloatSize> tileScales = computeTileScales(destinationRects, sourceRects, horizontalRule(), verticalRule());
+
+ RefPtr<Image> image = styleImage->image(renderer, source);
+ if (!image)
+ return;
+
+ for (ImagePiece piece = MinPiece; piece < MaxPiece; ++piece) {
+ if ((piece == MiddlePiece && !fill()) || isEmptyPieceRect(piece, destinationRects, sourceRects))
+ continue;
+
+ if (isCornerPiece(piece)) {
+ graphicsContext.drawImage(*image, destinationRects[piece], sourceRects[piece], op);
+ continue;
+ }
+
+ Image::TileRule hRule = isHorizontalPiece(piece) ? static_cast<Image::TileRule>(horizontalRule()) : Image::StretchTile;
+ Image::TileRule vRule = isVerticalPiece(piece) ? static_cast<Image::TileRule>(verticalRule()) : Image::StretchTile;
+ graphicsContext.drawTiledImage(*image, destinationRects[piece], sourceRects[piece], tileScales[piece], hRule, vRule, op);
+ }
+}
+
NinePieceImageData::NinePieceImageData()
: fill(false)
, horizontalRule(StretchImageRule)
, verticalRule(StretchImageRule)
- , image(0)
+ , 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)
@@ -73,14 +247,14 @@ inline NinePieceImageData::NinePieceImageData(const NinePieceImageData& other)
{
}
-PassRef<NinePieceImageData> NinePieceImageData::copy() const
+Ref<NinePieceImageData> NinePieceImageData::copy() const
{
return adoptRef(*new NinePieceImageData(*this));
}
bool NinePieceImageData::operator==(const NinePieceImageData& other) const
{
- return StyleImage::imagesEquivalent(image.get(), other.image.get())
+ return arePointingToEqualData(image, other.image)
&& imageSlices == other.imageSlices
&& fill == other.fill
&& borderSlices == other.borderSlices
diff --git a/Source/WebCore/rendering/style/NinePieceImage.h b/Source/WebCore/rendering/style/NinePieceImage.h
index e34924147..414af9d87 100644
--- a/Source/WebCore/rendering/style/NinePieceImage.h
+++ b/Source/WebCore/rendering/style/NinePieceImage.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, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2013, 2015 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
@@ -25,9 +25,12 @@
#define NinePieceImage_h
#include "DataRef.h"
+#include "LayoutRect.h"
+#include "LayoutSize.h"
#include "LayoutUnit.h"
#include "LengthBox.h"
#include "StyleImage.h"
+#include <wtf/Vector.h>
namespace WebCore {
@@ -35,10 +38,74 @@ enum ENinePieceImageRule {
StretchImageRule, RoundImageRule, SpaceImageRule, RepeatImageRule
};
+enum ImagePiece {
+ MinPiece = 0,
+ TopLeftPiece = MinPiece,
+ LeftPiece,
+ BottomLeftPiece,
+ TopRightPiece,
+ RightPiece,
+ BottomRightPiece,
+ TopPiece,
+ BottomPiece,
+ MiddlePiece,
+ MaxPiece
+};
+
+inline ImagePiece& operator++(ImagePiece& piece)
+{
+ piece = static_cast<ImagePiece>(static_cast<int>(piece) + 1);
+ return piece;
+}
+
+inline bool isCornerPiece(ImagePiece piece)
+{
+ return piece == TopLeftPiece || piece == TopRightPiece || piece == BottomLeftPiece || piece == BottomRightPiece;
+}
+
+inline bool isMiddlePiece(ImagePiece piece)
+{
+ return piece == MiddlePiece;
+}
+
+inline bool isHorizontalPiece(ImagePiece piece)
+{
+ return piece == TopPiece || piece == BottomPiece || piece == MiddlePiece;
+}
+
+inline bool isVerticalPiece(ImagePiece piece)
+{
+ return piece == LeftPiece || piece == RightPiece || piece == MiddlePiece;
+}
+
+inline PhysicalBoxSide imagePieceHorizontalSide(ImagePiece piece)
+{
+ if (piece == TopLeftPiece || piece == TopPiece || piece == TopRightPiece)
+ return TopSide;
+
+ if (piece == BottomLeftPiece || piece == BottomPiece || piece == BottomRightPiece)
+ return BottomSide;
+
+ return NilSide;
+}
+
+inline PhysicalBoxSide imagePieceVerticalSide(ImagePiece piece)
+{
+ if (piece == TopLeftPiece || piece == LeftPiece || piece == BottomLeftPiece)
+ return LeftSide;
+
+ if (piece == TopRightPiece || piece == RightPiece || piece == BottomRightPiece)
+ return RightSide;
+
+ return NilSide;
+}
+
+class RenderStyle;
+
class NinePieceImageData : public RefCounted<NinePieceImageData> {
public:
- static PassRef<NinePieceImageData> create() { return adoptRef(*new NinePieceImageData); }
- PassRef<NinePieceImageData> copy() const;
+ 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); }
@@ -69,16 +136,16 @@ public:
void setImage(PassRefPtr<StyleImage> image) { m_data.access()->image = image; }
const LengthBox& imageSlices() const { return m_data->imageSlices; }
- void setImageSlices(LengthBox slices) { m_data.access()->imageSlices = std::move(slices); }
+ void setImageSlices(LengthBox slices) { m_data.access()->imageSlices = WTFMove(slices); }
bool fill() const { return m_data->fill; }
void setFill(bool fill) { m_data.access()->fill = fill; }
const LengthBox& borderSlices() const { return m_data->borderSlices; }
- void setBorderSlices(LengthBox slices) { m_data.access()->borderSlices = std::move(slices); }
+ void setBorderSlices(LengthBox slices) { m_data.access()->borderSlices = WTFMove(slices); }
const LengthBox& outset() const { return m_data->outset; }
- void setOutset(LengthBox outset) { m_data.access()->outset = std::move(outset); }
+ void setOutset(LengthBox outset) { m_data.access()->outset = WTFMove(outset); }
ENinePieceImageRule horizontalRule() const { return static_cast<ENinePieceImageRule>(m_data->horizontalRule); }
void setHorizontalRule(ENinePieceImageRule rule) { m_data.access()->horizontalRule = rule; }
@@ -122,6 +189,23 @@ public:
return outsetSide.value();
}
+ static LayoutUnit computeSlice(Length, LayoutUnit width, LayoutUnit slice, LayoutUnit extent);
+ static LayoutBoxExtent computeSlices(const LayoutSize&, const LengthBox& lengths, int scaleFactor);
+ static LayoutBoxExtent computeSlices(const LayoutSize&, const LengthBox& lengths, const FloatBoxExtent& widths, const LayoutBoxExtent& slices);
+
+ static bool isEmptyPieceRect(ImagePiece, const LayoutBoxExtent& slices);
+ static bool isEmptyPieceRect(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
+
+ static Vector<FloatRect> computeNineRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor);
+
+ static void scaleSlicesIfNeeded(const LayoutSize&, LayoutBoxExtent& slices, float deviceScaleFactor);
+
+ static FloatSize computeSideTileScale(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
+ static FloatSize computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
+ static Vector<FloatSize> computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
+
+ void paint(GraphicsContext&, RenderElement*, const RenderStyle&, const LayoutRect& destination, const LayoutSize& source, float deviceScaleFactor, CompositeOperator) const;
+
private:
DataRef<NinePieceImageData> m_data;
};
diff --git a/Source/WebCore/rendering/style/OutlineValue.h b/Source/WebCore/rendering/style/OutlineValue.h
index f380af628..0afe5a812 100644
--- a/Source/WebCore/rendering/style/OutlineValue.h
+++ b/Source/WebCore/rendering/style/OutlineValue.h
@@ -32,11 +32,6 @@ namespace WebCore {
class OutlineValue : public BorderValue {
friend class RenderStyle;
public:
- OutlineValue()
- : m_offset(0)
- {
- }
-
bool operator==(const OutlineValue& o) const
{
return m_width == o.m_width && m_style == o.m_style && m_color == o.m_color && m_colorIsValid == o.m_colorIsValid && m_offset == o.m_offset && m_isAuto == o.m_isAuto;
@@ -47,11 +42,11 @@ public:
return !(*this == o);
}
- int offset() const { return m_offset; }
+ float offset() const { return m_offset; }
OutlineIsAuto isAuto() const { return static_cast<OutlineIsAuto>(m_isAuto); }
private:
- int m_offset;
+ float m_offset { 0 };
};
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp
index fffd1c19f..ebd4c9142 100644
--- a/Source/WebCore/rendering/style/RenderStyle.cpp
+++ b/Source/WebCore/rendering/style/RenderStyle.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
* Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -24,22 +24,29 @@
#include "RenderStyle.h"
#include "ContentData.h"
-#include "CursorList.h"
+#include "CSSCustomPropertyValue.h"
#include "CSSPropertyNames.h"
-#include "Font.h"
+#include "CSSVariableDependentValue.h"
+#include "CursorList.h"
+#include "FloatRoundedRect.h"
+#include "FontCascade.h"
#include "FontSelector.h"
+#include "InlineTextBoxStyle.h"
#include "Pagination.h"
#include "QuotesData.h"
#include "RenderObject.h"
+#include "RenderTheme.h"
#include "ScaleTransformOperation.h"
#include "ShadowData.h"
#include "StyleImage.h"
#include "StyleInheritedData.h"
#include "StyleResolver.h"
-#if ENABLE(TOUCH_EVENTS)
-#include "RenderTheme.h"
-#endif
+#include "StyleScrollSnapPoints.h"
+#include "StyleSelfAlignmentData.h"
+#include "StyleTreeResolver.h"
+#include "WillChangeData.h"
#include <wtf/MathExtras.h>
+#include <wtf/PointerComparison.h>
#include <wtf/StdLibExtras.h>
#include <algorithm>
@@ -54,8 +61,9 @@
namespace WebCore {
struct SameSizeAsBorderValue {
+ float m_width;
RGBA32 m_color;
- unsigned m_width;
+ int m_restBits;
};
COMPILE_ASSERT(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), BorderValue_should_not_grow);
@@ -63,15 +71,13 @@ COMPILE_ASSERT(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), BorderValue
struct SameSizeAsRenderStyle : public RefCounted<SameSizeAsRenderStyle> {
void* dataRefs[7];
void* ownPtrs[1];
-#if ENABLE(SVG)
void* dataRefSvgStyle;
-#endif
struct InheritedFlags {
unsigned m_bitfields[2];
} inherited_flags;
struct NonInheritedFlags {
- unsigned m_bitfields[2];
+ uint64_t m_flags;
} noninherited_flags;
};
@@ -83,17 +89,17 @@ inline RenderStyle& defaultStyle()
return style;
}
-PassRef<RenderStyle> RenderStyle::create()
+Ref<RenderStyle> RenderStyle::create()
{
- return adoptRef(*new RenderStyle());
+ return adoptRef(*new RenderStyle(defaultStyle()));
}
-PassRef<RenderStyle> RenderStyle::createDefaultStyle()
+Ref<RenderStyle> RenderStyle::createDefaultStyle()
{
return adoptRef(*new RenderStyle(true));
}
-PassRef<RenderStyle> RenderStyle::createAnonymousStyleWithDisplay(const RenderStyle* parentStyle, EDisplay display)
+Ref<RenderStyle> RenderStyle::createAnonymousStyleWithDisplay(const RenderStyle* parentStyle, EDisplay display)
{
auto newStyle = RenderStyle::create();
newStyle.get().inheritFrom(parentStyle);
@@ -102,40 +108,20 @@ PassRef<RenderStyle> RenderStyle::createAnonymousStyleWithDisplay(const RenderSt
return newStyle;
}
-PassRef<RenderStyle> RenderStyle::clone(const RenderStyle* other)
+Ref<RenderStyle> RenderStyle::clone(const RenderStyle* other)
{
return adoptRef(*new RenderStyle(*other));
}
-PassRef<RenderStyle> RenderStyle::createStyleInheritingFromPseudoStyle(const RenderStyle& pseudoStyle)
+Ref<RenderStyle> RenderStyle::createStyleInheritingFromPseudoStyle(const RenderStyle& pseudoStyle)
{
ASSERT(pseudoStyle.styleType() == BEFORE || pseudoStyle.styleType() == AFTER);
- // Images are special and must inherit the pseudoStyle so the width and height of
- // the pseudo element doesn't change the size of the image. In all other cases we
- // can just share the style.
auto style = RenderStyle::create();
style.get().inheritFrom(&pseudoStyle);
return style;
}
-ALWAYS_INLINE RenderStyle::RenderStyle()
- : m_box(defaultStyle().m_box)
- , visual(defaultStyle().visual)
- , m_background(defaultStyle().m_background)
- , surround(defaultStyle().surround)
- , rareNonInheritedData(defaultStyle().rareNonInheritedData)
- , rareInheritedData(defaultStyle().rareInheritedData)
- , inherited(defaultStyle().inherited)
-#if ENABLE(SVG)
- , m_svgStyle(defaultStyle().m_svgStyle)
-#endif
-{
- setBitDefaults(); // Would it be faster to copy this from the default style?
- COMPILE_ASSERT((sizeof(InheritedFlags) <= 8), InheritedFlags_does_not_grow);
- COMPILE_ASSERT((sizeof(NonInheritedFlags) <= 8), NonInheritedFlags_does_not_grow);
-}
-
ALWAYS_INLINE RenderStyle::RenderStyle(bool)
: m_box(StyleBoxData::create())
, visual(StyleVisualData::create())
@@ -144,11 +130,33 @@ ALWAYS_INLINE RenderStyle::RenderStyle(bool)
, rareNonInheritedData(StyleRareNonInheritedData::create())
, rareInheritedData(StyleRareInheritedData::create())
, inherited(StyleInheritedData::create())
-#if ENABLE(SVG)
, m_svgStyle(SVGRenderStyle::create())
-#endif
{
- setBitDefaults();
+ inherited_flags._empty_cells = initialEmptyCells();
+ inherited_flags._caption_side = initialCaptionSide();
+ inherited_flags._list_style_type = initialListStyleType();
+ inherited_flags._list_style_position = initialListStylePosition();
+ inherited_flags._visibility = initialVisibility();
+ inherited_flags._text_align = initialTextAlign();
+ inherited_flags._text_transform = initialTextTransform();
+ inherited_flags._text_decorations = initialTextDecoration();
+ inherited_flags._cursor_style = initialCursor();
+#if ENABLE(CURSOR_VISIBILITY)
+ inherited_flags.m_cursorVisibility = initialCursorVisibility();
+#endif
+ inherited_flags._direction = initialDirection();
+ inherited_flags._white_space = initialWhiteSpace();
+ inherited_flags._border_collapse = initialBorderCollapse();
+ inherited_flags.m_rtlOrdering = initialRTLOrdering();
+ inherited_flags._box_direction = initialBoxDirection();
+ inherited_flags.m_printColorAdjust = initialPrintColorAdjust();
+ inherited_flags._pointerEvents = initialPointerEvents();
+ inherited_flags._insideLink = NotInsideLink;
+ inherited_flags._insideDefaultButton = false;
+ inherited_flags.m_writingMode = initialWritingMode();
+
+ static_assert((sizeof(InheritedFlags) <= 8), "InheritedFlags does not grow");
+ static_assert((sizeof(NonInheritedFlags) <= 8), "NonInheritedFlags does not grow");
}
ALWAYS_INLINE RenderStyle::RenderStyle(const RenderStyle& o)
@@ -160,14 +168,80 @@ ALWAYS_INLINE RenderStyle::RenderStyle(const RenderStyle& o)
, rareNonInheritedData(o.rareNonInheritedData)
, rareInheritedData(o.rareInheritedData)
, inherited(o.inherited)
-#if ENABLE(SVG)
, m_svgStyle(o.m_svgStyle)
-#endif
, inherited_flags(o.inherited_flags)
, noninherited_flags(o.noninherited_flags)
{
}
+static inline StyleSelfAlignmentData resolveAlignmentData(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
+{
+ // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto".
+ if (childStyle.alignSelfPosition() == ItemPositionAuto)
+ return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? StyleSelfAlignmentData(resolvedAutoPositionForRenderer, OverflowAlignmentDefault) : parentStyle.alignItems();
+ return childStyle.alignSelf();
+}
+
+static inline StyleSelfAlignmentData resolveJustificationData(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
+{
+ // The auto keyword computes to the parent's justify-items computed value, or to "stretch", if not set or "auto".
+ if (childStyle.justifySelfPosition() == ItemPositionAuto)
+ return (parentStyle.justifyItemsPosition() == ItemPositionAuto) ? StyleSelfAlignmentData(resolvedAutoPositionForRenderer, OverflowAlignmentDefault) : parentStyle.justifyItems();
+ return childStyle.justifySelf();
+}
+
+ItemPosition RenderStyle::resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
+{
+ return resolveAlignmentData(parentStyle, childStyle, resolvedAutoPositionForRenderer).position();
+}
+
+OverflowAlignment RenderStyle::resolveAlignmentOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle)
+{
+ return resolveAlignmentData(parentStyle, childStyle, ItemPositionStretch).overflow();
+}
+
+ItemPosition RenderStyle::resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
+{
+ return resolveJustificationData(parentStyle, childStyle, resolvedAutoPositionForRenderer).position();
+}
+
+OverflowAlignment RenderStyle::resolveJustificationOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle)
+{
+ return resolveJustificationData(parentStyle, childStyle, ItemPositionStretch).overflow();
+}
+
+ContentPosition RenderStyle::resolvedAlignContentPosition() const
+{
+ const StyleContentAlignmentData& align = alignContent();
+ if (align.position() != ContentPositionAuto || align.distribution() != ContentDistributionDefault)
+ return align.position();
+ // 'auto' computes to 'stretch' for flexbox, hence it's managed by distribution().
+ return isDisplayFlexibleBox() ? ContentPositionAuto : ContentPositionStart;
+}
+
+ContentDistributionType RenderStyle::resolvedAlignContentDistribution() const
+{
+ const StyleContentAlignmentData& align = alignContent();
+ if (align.position() != ContentPositionAuto || align.distribution() != ContentDistributionDefault)
+ return align.distribution();
+ return isDisplayFlexibleBox() ? ContentDistributionStretch : ContentDistributionDefault;
+}
+
+ContentPosition RenderStyle::resolvedJustifyContentPosition() const
+{
+ const StyleContentAlignmentData& justify = justifyContent();
+ if (justify.position() != ContentPositionAuto || justify.distribution() != ContentDistributionDefault)
+ return justify.position();
+ // 'auto' computes to 'stretch' for flexbox, but since flexing in the main axis is controlled by flex, it behaves as flex-start.
+ return isDisplayFlexibleBox() ? ContentPositionFlexStart : ContentPositionStart;
+}
+
+ContentDistributionType RenderStyle::resolvedJustifyContentDistribution() const
+{
+ // even that 'auto' computes to 'stretch' for flexbox it behaves as flex-start, hence it's managed by position().
+ return justifyContentDistribution();
+}
+
void RenderStyle::inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary isAtShadowBoundary)
{
if (isAtShadowBoundary == AtShadowBoundary) {
@@ -179,10 +253,9 @@ void RenderStyle::inheritFrom(const RenderStyle* inheritParent, IsAtShadowBounda
rareInheritedData = inheritParent->rareInheritedData;
inherited = inheritParent->inherited;
inherited_flags = inheritParent->inherited_flags;
-#if ENABLE(SVG)
+
if (m_svgStyle != inheritParent->m_svgStyle)
m_svgStyle.access()->inheritFrom(inheritParent->m_svgStyle.get());
-#endif
}
void RenderStyle::copyNonInheritedFrom(const RenderStyle* other)
@@ -192,25 +265,11 @@ void RenderStyle::copyNonInheritedFrom(const RenderStyle* other)
m_background = other->m_background;
surround = other->surround;
rareNonInheritedData = other->rareNonInheritedData;
- // The flags are copied one-by-one because noninherited_flags contains a bunch of stuff other than real style data.
- noninherited_flags._effectiveDisplay = other->noninherited_flags._effectiveDisplay;
- noninherited_flags._originalDisplay = other->noninherited_flags._originalDisplay;
- noninherited_flags._overflowX = other->noninherited_flags._overflowX;
- noninherited_flags._overflowY = other->noninherited_flags._overflowY;
- noninherited_flags._vertical_align = other->noninherited_flags._vertical_align;
- noninherited_flags._clear = other->noninherited_flags._clear;
- noninherited_flags._position = other->noninherited_flags._position;
- noninherited_flags._floating = other->noninherited_flags._floating;
- noninherited_flags._table_layout = other->noninherited_flags._table_layout;
- noninherited_flags._unicodeBidi = other->noninherited_flags._unicodeBidi;
- noninherited_flags._page_break_before = other->noninherited_flags._page_break_before;
- noninherited_flags._page_break_after = other->noninherited_flags._page_break_after;
- noninherited_flags._page_break_inside = other->noninherited_flags._page_break_inside;
- noninherited_flags.explicitInheritance = other->noninherited_flags.explicitInheritance;
-#if ENABLE(SVG)
+ noninherited_flags.copyNonInheritedFrom(other->noninherited_flags);
+
if (m_svgStyle != other->m_svgStyle)
m_svgStyle.access()->copyNonInheritedFrom(other->m_svgStyle.get());
-#endif
+
ASSERT(zoom() == initialZoom());
}
@@ -226,15 +285,13 @@ bool RenderStyle::operator==(const RenderStyle& o) const
&& rareNonInheritedData == o.rareNonInheritedData
&& rareInheritedData == o.rareInheritedData
&& inherited == o.inherited
-#if ENABLE(SVG)
&& m_svgStyle == o.m_svgStyle
-#endif
;
}
bool RenderStyle::isStyleAvailable() const
{
- return this != StyleResolver::styleNotYetAvailable();
+ return !Style::isPlaceholderStyle(*this);
}
bool RenderStyle::hasUniquePseudoStyle() const
@@ -254,10 +311,10 @@ bool RenderStyle::hasUniquePseudoStyle() const
RenderStyle* RenderStyle::getCachedPseudoStyle(PseudoId pid) const
{
if (!m_cachedPseudoStyles || !m_cachedPseudoStyles->size())
- return 0;
+ return nullptr;
if (styleType() != NOPSEUDO)
- return 0;
+ return nullptr;
for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) {
RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
@@ -265,20 +322,20 @@ RenderStyle* RenderStyle::getCachedPseudoStyle(PseudoId pid) const
return pseudoStyle;
}
- return 0;
+ return nullptr;
}
RenderStyle* RenderStyle::addCachedPseudoStyle(PassRefPtr<RenderStyle> pseudo)
{
if (!pseudo)
- return 0;
+ return nullptr;
ASSERT(pseudo->styleType() > NOPSEUDO);
RenderStyle* result = pseudo.get();
if (!m_cachedPseudoStyles)
- m_cachedPseudoStyles = adoptPtr(new PseudoStyleCache);
+ m_cachedPseudoStyles = std::make_unique<PseudoStyleCache>();
m_cachedPseudoStyles->append(pseudo);
@@ -302,28 +359,24 @@ bool RenderStyle::inheritedNotEqual(const RenderStyle* other) const
{
return inherited_flags != other->inherited_flags
|| inherited != other->inherited
-#if ENABLE(SVG)
|| m_svgStyle->inheritedNotEqual(other->m_svgStyle.get())
-#endif
|| rareInheritedData != other->rareInheritedData;
}
#if ENABLE(IOS_TEXT_AUTOSIZING)
-inline unsigned computeFontHash(const Font& font)
+
+static inline unsigned computeFontHash(const FontCascade& font)
{
- unsigned hashCodes[2] = {
- CaseFoldingHash::hash(font.fontDescription().firstFamily().impl()),
- static_cast<unsigned>(font.fontDescription().specifiedSize())
- };
- return StringHasher::computeHash(reinterpret_cast<UChar*>(hashCodes), 2 * sizeof(unsigned) / sizeof(UChar));
+ IntegerHasher hasher;
+ hasher.add(ASCIICaseInsensitiveHash::hash(font.fontDescription().firstFamily()));
+ hasher.add(font.fontDescription().specifiedSize());
+ return hasher.hash();
}
-uint32_t RenderStyle::hashForTextAutosizing() const
+unsigned RenderStyle::hashForTextAutosizing() const
{
// FIXME: Not a very smart hash. Could be improved upon. See <https://bugs.webkit.org/show_bug.cgi?id=121131>.
- uint32_t hash = 0;
-
- hash ^= rareNonInheritedData->m_appearance;
+ unsigned hash = rareNonInheritedData->m_appearance;
hash ^= rareNonInheritedData->marginBeforeCollapse;
hash ^= rareNonInheritedData->marginAfterCollapse;
hash ^= rareNonInheritedData->lineClamp.value();
@@ -331,13 +384,13 @@ uint32_t RenderStyle::hashForTextAutosizing() const
hash ^= rareInheritedData->nbspMode;
hash ^= rareInheritedData->lineBreak;
hash ^= WTF::FloatHash<float>::hash(inherited->specifiedLineHeight.value());
- hash ^= computeFontHash(inherited->font);
+ hash ^= computeFontHash(inherited->fontCascade);
hash ^= inherited->horizontal_border_spacing;
hash ^= inherited->vertical_border_spacing;
hash ^= inherited_flags._box_direction;
hash ^= inherited_flags.m_rtlOrdering;
- hash ^= noninherited_flags._position;
- hash ^= noninherited_flags._floating;
+ hash ^= noninherited_flags.position();
+ hash ^= noninherited_flags.floating();
hash ^= rareNonInheritedData->textOverflow;
hash ^= rareInheritedData->textSecurity;
return hash;
@@ -355,15 +408,16 @@ bool RenderStyle::equalForTextAutosizing(const RenderStyle* other) const
&& rareInheritedData->lineBreak == other->rareInheritedData->lineBreak
&& rareInheritedData->textSecurity == other->rareInheritedData->textSecurity
&& inherited->specifiedLineHeight == other->inherited->specifiedLineHeight
- && inherited->font.equalForTextAutoSizing(other->inherited->font)
+ && inherited->fontCascade.equalForTextAutoSizing(other->inherited->fontCascade)
&& inherited->horizontal_border_spacing == other->inherited->horizontal_border_spacing
&& inherited->vertical_border_spacing == other->inherited->vertical_border_spacing
&& inherited_flags._box_direction == other->inherited_flags._box_direction
&& inherited_flags.m_rtlOrdering == other->inherited_flags.m_rtlOrdering
- && noninherited_flags._position == other->noninherited_flags._position
- && noninherited_flags._floating == other->noninherited_flags._floating
+ && noninherited_flags.position() == other->noninherited_flags.position()
+ && noninherited_flags.floating() == other->noninherited_flags.floating()
&& rareNonInheritedData->textOverflow == other->rareNonInheritedData->textOverflow;
}
+
#endif // ENABLE(IOS_TEXT_AUTOSIZING)
bool RenderStyle::inheritedDataShared(const RenderStyle* other) const
@@ -371,9 +425,7 @@ bool RenderStyle::inheritedDataShared(const RenderStyle* other) const
// This is a fast check that only looks if the data structures are shared.
return inherited_flags == other->inherited_flags
&& inherited.get() == other->inherited.get()
-#if ENABLE(SVG)
&& m_svgStyle.get() == other->m_svgStyle.get()
-#endif
&& rareInheritedData.get() == other->rareInheritedData.get();
}
@@ -404,250 +456,263 @@ static bool positionChangeIsMovementOnly(const LengthBox& a, const LengthBox& b,
return true;
}
-bool RenderStyle::changeRequiresLayout(const RenderStyle* other, unsigned& changedContextSensitiveProperties) const
+inline bool RenderStyle::changeAffectsVisualOverflow(const RenderStyle& other) const
{
- if (m_box->width() != other->m_box->width()
- || m_box->minWidth() != other->m_box->minWidth()
- || m_box->maxWidth() != other->m_box->maxWidth()
- || m_box->height() != other->m_box->height()
- || m_box->minHeight() != other->m_box->minHeight()
- || m_box->maxHeight() != other->m_box->maxHeight())
+ if (rareNonInheritedData.get() != other.rareNonInheritedData.get()
+ && !arePointingToEqualData(rareNonInheritedData->m_boxShadow, other.rareNonInheritedData->m_boxShadow))
return true;
- if (m_box->verticalAlign() != other->m_box->verticalAlign() || noninherited_flags._vertical_align != other->noninherited_flags._vertical_align)
+ if (rareInheritedData.get() != other.rareInheritedData.get()
+ && !arePointingToEqualData(rareInheritedData->textShadow, other.rareInheritedData->textShadow))
return true;
- if (m_box->boxSizing() != other->m_box->boxSizing())
+ if (inherited_flags._text_decorations != other.inherited_flags._text_decorations
+ || visual->textDecoration != other.visual->textDecoration
+ || rareNonInheritedData->m_textDecorationStyle != other.rareNonInheritedData->m_textDecorationStyle) {
+ // Underlines are always drawn outside of their textbox bounds when text-underline-position: under;
+ // is specified. We can take an early out here.
+ if (textUnderlinePosition() == TextUnderlinePositionUnder
+ || other.textUnderlinePosition() == TextUnderlinePositionUnder)
+ return true;
+ return visualOverflowForDecorations(*this, nullptr) != visualOverflowForDecorations(other, nullptr);
+ }
+
+ if (hasOutlineInVisualOverflow() != other.hasOutlineInVisualOverflow())
return true;
+ return false;
+}
- if (surround->margin != other->surround->margin)
+bool RenderStyle::changeRequiresLayout(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
+{
+ if (m_box->width() != other.m_box->width()
+ || m_box->minWidth() != other.m_box->minWidth()
+ || m_box->maxWidth() != other.m_box->maxWidth()
+ || m_box->height() != other.m_box->height()
+ || m_box->minHeight() != other.m_box->minHeight()
+ || m_box->maxHeight() != other.m_box->maxHeight())
return true;
- if (surround->padding != other->surround->padding)
+ if (m_box->verticalAlign() != other.m_box->verticalAlign() || noninherited_flags.verticalAlign() != other.noninherited_flags.verticalAlign())
return true;
- if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) {
- if (rareNonInheritedData->m_appearance != other->rareNonInheritedData->m_appearance
- || rareNonInheritedData->marginBeforeCollapse != other->rareNonInheritedData->marginBeforeCollapse
- || rareNonInheritedData->marginAfterCollapse != other->rareNonInheritedData->marginAfterCollapse
- || rareNonInheritedData->lineClamp != other->rareNonInheritedData->lineClamp
- || rareNonInheritedData->textOverflow != other->rareNonInheritedData->textOverflow)
- return true;
+ if (m_box->boxSizing() != other.m_box->boxSizing())
+ return true;
+
+ if (surround->margin != other.surround->margin)
+ return true;
+
+ if (surround->padding != other.surround->padding)
+ return true;
+
+ // FIXME: We should add an optimized form of layout that just recomputes visual overflow.
+ if (changeAffectsVisualOverflow(other))
+ return true;
- if (rareNonInheritedData->m_regionFragment != other->rareNonInheritedData->m_regionFragment)
+ if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) {
+ if (rareNonInheritedData->m_appearance != other.rareNonInheritedData->m_appearance
+ || rareNonInheritedData->marginBeforeCollapse != other.rareNonInheritedData->marginBeforeCollapse
+ || rareNonInheritedData->marginAfterCollapse != other.rareNonInheritedData->marginAfterCollapse
+ || rareNonInheritedData->lineClamp != other.rareNonInheritedData->lineClamp
+ || rareNonInheritedData->m_initialLetter != other.rareNonInheritedData->m_initialLetter
+ || rareNonInheritedData->textOverflow != other.rareNonInheritedData->textOverflow)
return true;
- if (rareNonInheritedData->m_wrapFlow != other->rareNonInheritedData->m_wrapFlow
- || rareNonInheritedData->m_wrapThrough != other->rareNonInheritedData->m_wrapThrough)
+ if (rareNonInheritedData->m_regionFragment != other.rareNonInheritedData->m_regionFragment)
return true;
#if ENABLE(CSS_SHAPES)
- if (rareNonInheritedData->m_shapeMargin != other->rareNonInheritedData->m_shapeMargin
- || rareNonInheritedData->m_shapePadding != other->rareNonInheritedData->m_shapePadding)
+ if (rareNonInheritedData->m_shapeMargin != other.rareNonInheritedData->m_shapeMargin)
return true;
#endif
- if (rareNonInheritedData->m_deprecatedFlexibleBox.get() != other->rareNonInheritedData->m_deprecatedFlexibleBox.get()
- && *rareNonInheritedData->m_deprecatedFlexibleBox.get() != *other->rareNonInheritedData->m_deprecatedFlexibleBox.get())
+ if (rareNonInheritedData->m_deprecatedFlexibleBox != other.rareNonInheritedData->m_deprecatedFlexibleBox)
return true;
- if (rareNonInheritedData->m_flexibleBox.get() != other->rareNonInheritedData->m_flexibleBox.get()
- && *rareNonInheritedData->m_flexibleBox.get() != *other->rareNonInheritedData->m_flexibleBox.get())
- return true;
- if (rareNonInheritedData->m_order != other->rareNonInheritedData->m_order
- || rareNonInheritedData->m_alignContent != other->rareNonInheritedData->m_alignContent
- || rareNonInheritedData->m_alignItems != other->rareNonInheritedData->m_alignItems
- || rareNonInheritedData->m_alignSelf != other->rareNonInheritedData->m_alignSelf
- || rareNonInheritedData->m_justifyContent != other->rareNonInheritedData->m_justifyContent)
+ if (rareNonInheritedData->m_flexibleBox != other.rareNonInheritedData->m_flexibleBox)
return true;
- // FIXME: We should add an optimized form of layout that just recomputes visual overflow.
- if (!rareNonInheritedData->shadowDataEquivalent(*other->rareNonInheritedData.get()))
+ if (rareNonInheritedData->m_order != other.rareNonInheritedData->m_order
+ || rareNonInheritedData->m_alignContent != other.rareNonInheritedData->m_alignContent
+ || rareNonInheritedData->m_alignItems != other.rareNonInheritedData->m_alignItems
+ || rareNonInheritedData->m_alignSelf != other.rareNonInheritedData->m_alignSelf
+ || rareNonInheritedData->m_justifyContent != other.rareNonInheritedData->m_justifyContent
+ || rareNonInheritedData->m_justifyItems != other.rareNonInheritedData->m_justifyItems
+ || rareNonInheritedData->m_justifySelf != other.rareNonInheritedData->m_justifySelf)
return true;
- if (!rareNonInheritedData->reflectionDataEquivalent(*other->rareNonInheritedData.get()))
+ if (!arePointingToEqualData(rareNonInheritedData->m_boxReflect, other.rareNonInheritedData->m_boxReflect))
return true;
- if (rareNonInheritedData->m_multiCol.get() != other->rareNonInheritedData->m_multiCol.get()
- && *rareNonInheritedData->m_multiCol.get() != *other->rareNonInheritedData->m_multiCol.get())
+ if (rareNonInheritedData->m_multiCol != other.rareNonInheritedData->m_multiCol)
return true;
- if (rareNonInheritedData->m_transform.get() != other->rareNonInheritedData->m_transform.get()
- && *rareNonInheritedData->m_transform.get() != *other->rareNonInheritedData->m_transform.get()) {
-#if USE(ACCELERATED_COMPOSITING)
- changedContextSensitiveProperties |= ContextSensitivePropertyTransform;
- // Don't return; keep looking for another change
-#else
- UNUSED_PARAM(changedContextSensitiveProperties);
- return true;
-#endif
+ if (rareNonInheritedData->m_transform != other.rareNonInheritedData->m_transform) {
+ if (rareNonInheritedData->m_transform->hasTransform() != other.rareNonInheritedData->m_transform->hasTransform())
+ return true;
+ if (*rareNonInheritedData->m_transform != *other.rareNonInheritedData->m_transform) {
+ changedContextSensitiveProperties |= ContextSensitivePropertyTransform;
+ // Don't return; keep looking for another change
+ }
}
- if (rareNonInheritedData->m_grid.get() != other->rareNonInheritedData->m_grid.get()
- || rareNonInheritedData->m_gridItem.get() != other->rareNonInheritedData->m_gridItem.get())
+#if ENABLE(CSS_GRID_LAYOUT)
+ if (rareNonInheritedData->m_grid != other.rareNonInheritedData->m_grid
+ || rareNonInheritedData->m_gridItem != other.rareNonInheritedData->m_gridItem)
return true;
-
-#if !USE(ACCELERATED_COMPOSITING)
- if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) {
- if (rareNonInheritedData->m_transformStyle3D != other->rareNonInheritedData->m_transformStyle3D
- || rareNonInheritedData->m_backfaceVisibility != other->rareNonInheritedData->m_backfaceVisibility
- || rareNonInheritedData->m_perspective != other->rareNonInheritedData->m_perspective
- || rareNonInheritedData->m_perspectiveOriginX != other->rareNonInheritedData->m_perspectiveOriginX
- || rareNonInheritedData->m_perspectiveOriginY != other->rareNonInheritedData->m_perspectiveOriginY)
- return true;
- }
#endif
#if ENABLE(DASHBOARD_SUPPORT)
// If regions change, trigger a relayout to re-calc regions.
- if (rareNonInheritedData->m_dashboardRegions != other->rareNonInheritedData->m_dashboardRegions)
+ if (rareNonInheritedData->m_dashboardRegions != other.rareNonInheritedData->m_dashboardRegions)
return true;
#endif
-#if ENABLE(CSS_SHAPES)
- if (rareNonInheritedData->m_shapeInside != other->rareNonInheritedData->m_shapeInside)
- return true;
-#endif
+ if (!arePointingToEqualData(rareNonInheritedData->m_willChange, other.rareNonInheritedData->m_willChange)) {
+ changedContextSensitiveProperties |= ContextSensitivePropertyWillChange;
+ // Don't return; keep looking for another change
+ }
}
- if (rareInheritedData.get() != other->rareInheritedData.get()) {
- if (rareInheritedData->highlight != other->rareInheritedData->highlight
- || rareInheritedData->indent != other->rareInheritedData->indent
+ if (rareInheritedData.get() != other.rareInheritedData.get()) {
+ if (rareInheritedData->indent != other.rareInheritedData->indent
#if ENABLE(CSS3_TEXT)
- || rareInheritedData->m_textAlignLast != other->rareInheritedData->m_textAlignLast
- || rareInheritedData->m_textIndentLine != other->rareInheritedData->m_textIndentLine
+ || rareInheritedData->m_textAlignLast != other.rareInheritedData->m_textAlignLast
+ || rareInheritedData->m_textJustify != other.rareInheritedData->m_textJustify
+ || rareInheritedData->m_textIndentLine != other.rareInheritedData->m_textIndentLine
#endif
- || rareInheritedData->m_effectiveZoom != other->rareInheritedData->m_effectiveZoom
+ || rareInheritedData->m_effectiveZoom != other.rareInheritedData->m_effectiveZoom
+ || rareInheritedData->m_textZoom != other.rareInheritedData->m_textZoom
#if ENABLE(IOS_TEXT_AUTOSIZING)
- || rareInheritedData->textSizeAdjust != other->rareInheritedData->textSizeAdjust
+ || rareInheritedData->textSizeAdjust != other.rareInheritedData->textSizeAdjust
#endif
- || rareInheritedData->wordBreak != other->rareInheritedData->wordBreak
- || rareInheritedData->overflowWrap != other->rareInheritedData->overflowWrap
- || rareInheritedData->nbspMode != other->rareInheritedData->nbspMode
- || rareInheritedData->lineBreak != other->rareInheritedData->lineBreak
- || rareInheritedData->textSecurity != other->rareInheritedData->textSecurity
- || rareInheritedData->hyphens != other->rareInheritedData->hyphens
- || rareInheritedData->hyphenationLimitBefore != other->rareInheritedData->hyphenationLimitBefore
- || rareInheritedData->hyphenationLimitAfter != other->rareInheritedData->hyphenationLimitAfter
- || rareInheritedData->hyphenationString != other->rareInheritedData->hyphenationString
- || rareInheritedData->locale != other->rareInheritedData->locale
- || rareInheritedData->m_rubyPosition != other->rareInheritedData->m_rubyPosition
- || rareInheritedData->textEmphasisMark != other->rareInheritedData->textEmphasisMark
- || rareInheritedData->textEmphasisPosition != other->rareInheritedData->textEmphasisPosition
- || rareInheritedData->textEmphasisCustomMark != other->rareInheritedData->textEmphasisCustomMark
- || rareInheritedData->m_textOrientation != other->rareInheritedData->m_textOrientation
- || rareInheritedData->m_tabSize != other->rareInheritedData->m_tabSize
- || rareInheritedData->m_lineBoxContain != other->rareInheritedData->m_lineBoxContain
- || rareInheritedData->m_lineGrid != other->rareInheritedData->m_lineGrid
+ || rareInheritedData->wordBreak != other.rareInheritedData->wordBreak
+ || rareInheritedData->overflowWrap != other.rareInheritedData->overflowWrap
+ || rareInheritedData->nbspMode != other.rareInheritedData->nbspMode
+ || rareInheritedData->lineBreak != other.rareInheritedData->lineBreak
+ || rareInheritedData->textSecurity != other.rareInheritedData->textSecurity
+ || rareInheritedData->hyphens != other.rareInheritedData->hyphens
+ || rareInheritedData->hyphenationLimitBefore != other.rareInheritedData->hyphenationLimitBefore
+ || rareInheritedData->hyphenationLimitAfter != other.rareInheritedData->hyphenationLimitAfter
+ || rareInheritedData->hyphenationString != other.rareInheritedData->hyphenationString
+ || rareInheritedData->m_rubyPosition != other.rareInheritedData->m_rubyPosition
+ || rareInheritedData->textEmphasisMark != other.rareInheritedData->textEmphasisMark
+ || rareInheritedData->textEmphasisPosition != other.rareInheritedData->textEmphasisPosition
+ || rareInheritedData->textEmphasisCustomMark != other.rareInheritedData->textEmphasisCustomMark
+ || rareInheritedData->m_textOrientation != other.rareInheritedData->m_textOrientation
+ || rareInheritedData->m_tabSize != other.rareInheritedData->m_tabSize
+ || rareInheritedData->m_lineBoxContain != other.rareInheritedData->m_lineBoxContain
+ || rareInheritedData->m_lineGrid != other.rareInheritedData->m_lineGrid
#if ENABLE(CSS_IMAGE_ORIENTATION)
- || rareInheritedData->m_imageOrientation != other->rareInheritedData->m_imageOrientation
+ || rareInheritedData->m_imageOrientation != other.rareInheritedData->m_imageOrientation
#endif
#if ENABLE(CSS_IMAGE_RESOLUTION)
- || rareInheritedData->m_imageResolutionSource != other->rareInheritedData->m_imageResolutionSource
- || rareInheritedData->m_imageResolutionSnap != other->rareInheritedData->m_imageResolutionSnap
- || rareInheritedData->m_imageResolution != other->rareInheritedData->m_imageResolution
+ || rareInheritedData->m_imageResolutionSource != other.rareInheritedData->m_imageResolutionSource
+ || rareInheritedData->m_imageResolutionSnap != other.rareInheritedData->m_imageResolutionSnap
+ || rareInheritedData->m_imageResolution != other.rareInheritedData->m_imageResolution
#endif
- || rareInheritedData->m_lineSnap != other->rareInheritedData->m_lineSnap
- || rareInheritedData->m_lineAlign != other->rareInheritedData->m_lineAlign
+ || rareInheritedData->m_lineSnap != other.rareInheritedData->m_lineSnap
+ || rareInheritedData->m_lineAlign != other.rareInheritedData->m_lineAlign
+ || rareInheritedData->m_hangingPunctuation != other.rareInheritedData->m_hangingPunctuation
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
- || rareInheritedData->useTouchOverflowScrolling != other->rareInheritedData->useTouchOverflowScrolling
+ || rareInheritedData->useTouchOverflowScrolling != other.rareInheritedData->useTouchOverflowScrolling
#endif
- || rareInheritedData->listStyleImage != other->rareInheritedData->listStyleImage)
- return true;
-
- if (!rareInheritedData->shadowDataEquivalent(*other->rareInheritedData.get()))
+ || rareInheritedData->listStyleImage != other.rareInheritedData->listStyleImage) // FIXME: needs arePointingToEqualData()?
return true;
- if (textStrokeWidth() != other->textStrokeWidth())
+ if (textStrokeWidth() != other.textStrokeWidth())
return true;
}
#if ENABLE(TEXT_AUTOSIZING)
- if (visual->m_textAutosizingMultiplier != other->visual->m_textAutosizingMultiplier)
+ if (visual->m_textAutosizingMultiplier != other.visual->m_textAutosizingMultiplier)
return true;
#endif
- if (inherited->line_height != other->inherited->line_height
+ if (inherited->line_height != other.inherited->line_height
#if ENABLE(IOS_TEXT_AUTOSIZING)
- || inherited->specifiedLineHeight != other->inherited->specifiedLineHeight
+ || inherited->specifiedLineHeight != other.inherited->specifiedLineHeight
#endif
- || inherited->font != other->inherited->font
- || inherited->horizontal_border_spacing != other->inherited->horizontal_border_spacing
- || inherited->vertical_border_spacing != other->inherited->vertical_border_spacing
- || inherited_flags._box_direction != other->inherited_flags._box_direction
- || inherited_flags.m_rtlOrdering != other->inherited_flags.m_rtlOrdering
- || noninherited_flags._position != other->noninherited_flags._position
- || noninherited_flags._floating != other->noninherited_flags._floating
- || noninherited_flags._originalDisplay != other->noninherited_flags._originalDisplay)
+ || inherited->fontCascade != other.inherited->fontCascade
+ || inherited->horizontal_border_spacing != other.inherited->horizontal_border_spacing
+ || inherited->vertical_border_spacing != other.inherited->vertical_border_spacing
+ || inherited_flags._box_direction != other.inherited_flags._box_direction
+ || inherited_flags.m_rtlOrdering != other.inherited_flags.m_rtlOrdering
+ || noninherited_flags.position() != other.noninherited_flags.position()
+ || noninherited_flags.floating() != other.noninherited_flags.floating()
+ || noninherited_flags.originalDisplay() != other.noninherited_flags.originalDisplay())
return true;
- if (((int)noninherited_flags._effectiveDisplay) >= TABLE) {
- if (inherited_flags._border_collapse != other->inherited_flags._border_collapse
- || inherited_flags._empty_cells != other->inherited_flags._empty_cells
- || inherited_flags._caption_side != other->inherited_flags._caption_side
- || noninherited_flags._table_layout != other->noninherited_flags._table_layout)
+ if ((noninherited_flags.effectiveDisplay()) >= TABLE) {
+ if (inherited_flags._border_collapse != other.inherited_flags._border_collapse
+ || inherited_flags._empty_cells != other.inherited_flags._empty_cells
+ || inherited_flags._caption_side != other.inherited_flags._caption_side
+ || noninherited_flags.tableLayout() != other.noninherited_flags.tableLayout())
return true;
// In the collapsing border model, 'hidden' suppresses other borders, while 'none'
// does not, so these style differences can be width differences.
if (inherited_flags._border_collapse
- && ((borderTopStyle() == BHIDDEN && other->borderTopStyle() == BNONE)
- || (borderTopStyle() == BNONE && other->borderTopStyle() == BHIDDEN)
- || (borderBottomStyle() == BHIDDEN && other->borderBottomStyle() == BNONE)
- || (borderBottomStyle() == BNONE && other->borderBottomStyle() == BHIDDEN)
- || (borderLeftStyle() == BHIDDEN && other->borderLeftStyle() == BNONE)
- || (borderLeftStyle() == BNONE && other->borderLeftStyle() == BHIDDEN)
- || (borderRightStyle() == BHIDDEN && other->borderRightStyle() == BNONE)
- || (borderRightStyle() == BNONE && other->borderRightStyle() == BHIDDEN)))
+ && ((borderTopStyle() == BHIDDEN && other.borderTopStyle() == BNONE)
+ || (borderTopStyle() == BNONE && other.borderTopStyle() == BHIDDEN)
+ || (borderBottomStyle() == BHIDDEN && other.borderBottomStyle() == BNONE)
+ || (borderBottomStyle() == BNONE && other.borderBottomStyle() == BHIDDEN)
+ || (borderLeftStyle() == BHIDDEN && other.borderLeftStyle() == BNONE)
+ || (borderLeftStyle() == BNONE && other.borderLeftStyle() == BHIDDEN)
+ || (borderRightStyle() == BHIDDEN && other.borderRightStyle() == BNONE)
+ || (borderRightStyle() == BNONE && other.borderRightStyle() == BHIDDEN)))
return true;
}
- if (noninherited_flags._effectiveDisplay == LIST_ITEM) {
- if (inherited_flags._list_style_type != other->inherited_flags._list_style_type
- || inherited_flags._list_style_position != other->inherited_flags._list_style_position)
+ if (noninherited_flags.effectiveDisplay() == LIST_ITEM) {
+ if (inherited_flags._list_style_type != other.inherited_flags._list_style_type
+ || inherited_flags._list_style_position != other.inherited_flags._list_style_position)
return true;
}
- if (inherited_flags._text_align != other->inherited_flags._text_align
- || inherited_flags._text_transform != other->inherited_flags._text_transform
- || inherited_flags._direction != other->inherited_flags._direction
- || inherited_flags._white_space != other->inherited_flags._white_space
- || noninherited_flags._clear != other->noninherited_flags._clear
- || noninherited_flags._unicodeBidi != other->noninherited_flags._unicodeBidi)
+ if (inherited_flags._text_align != other.inherited_flags._text_align
+ || inherited_flags._text_transform != other.inherited_flags._text_transform
+ || inherited_flags._direction != other.inherited_flags._direction
+ || inherited_flags._white_space != other.inherited_flags._white_space
+ || noninherited_flags.clear() != other.noninherited_flags.clear()
+ || noninherited_flags.unicodeBidi() != other.noninherited_flags.unicodeBidi())
return true;
// Check block flow direction.
- if (inherited_flags.m_writingMode != other->inherited_flags.m_writingMode)
+ if (inherited_flags.m_writingMode != other.inherited_flags.m_writingMode)
return true;
// Check text combine mode.
- if (rareNonInheritedData->m_textCombine != other->rareNonInheritedData->m_textCombine)
+ if (rareNonInheritedData->m_textCombine != other.rareNonInheritedData->m_textCombine)
+ return true;
+
+ // Check breaks.
+ if (rareNonInheritedData->m_breakBefore != other.rareNonInheritedData->m_breakBefore
+ || rareNonInheritedData->m_breakAfter != other.rareNonInheritedData->m_breakAfter
+ || rareNonInheritedData->m_breakInside != other.rareNonInheritedData->m_breakInside)
return true;
// Overflow returns a layout hint.
- if (noninherited_flags._overflowX != other->noninherited_flags._overflowX
- || noninherited_flags._overflowY != other->noninherited_flags._overflowY)
+ if (noninherited_flags.overflowX() != other.noninherited_flags.overflowX()
+ || noninherited_flags.overflowY() != other.noninherited_flags.overflowY())
return true;
// If our border widths change, then we need to layout. Other changes to borders
// only necessitate a repaint.
- if (borderLeftWidth() != other->borderLeftWidth()
- || borderTopWidth() != other->borderTopWidth()
- || borderBottomWidth() != other->borderBottomWidth()
- || borderRightWidth() != other->borderRightWidth())
+ if (borderLeftWidth() != other.borderLeftWidth()
+ || borderTopWidth() != other.borderTopWidth()
+ || borderBottomWidth() != other.borderBottomWidth()
+ || borderRightWidth() != other.borderRightWidth())
return true;
// If the counter directives change, trigger a relayout to re-calculate counter values and rebuild the counter node tree.
- const CounterDirectiveMap* mapA = rareNonInheritedData->m_counterDirectives.get();
- const CounterDirectiveMap* mapB = other->rareNonInheritedData->m_counterDirectives.get();
- if (!(mapA == mapB || (mapA && mapB && *mapA == *mapB)))
+ if (!arePointingToEqualData(rareNonInheritedData->m_counterDirectives, other.rareNonInheritedData->m_counterDirectives))
return true;
- if ((visibility() == COLLAPSE) != (other->visibility() == COLLAPSE))
+ if ((visibility() == COLLAPSE) != (other.visibility() == COLLAPSE))
return true;
- if (rareNonInheritedData->hasOpacity() != other->rareNonInheritedData->hasOpacity()) {
+ if (rareNonInheritedData->hasOpacity() != other.rareNonInheritedData->hasOpacity()) {
// FIXME: We would like to use SimplifiedLayout here, but we can't quite do that yet.
// We need to make sure SimplifiedLayout can operate correctly on RenderInlines (we will need
// to add a selfNeedsSimplifiedLayout bit in order to not get confused and taint every line).
@@ -656,18 +721,19 @@ bool RenderStyle::changeRequiresLayout(const RenderStyle* other, unsigned& chang
return true;
}
-#if ENABLE(CSS_FILTERS)
- if (rareNonInheritedData->hasFilters() != other->rareNonInheritedData->hasFilters())
+ if (rareNonInheritedData->hasFilters() != other.rareNonInheritedData->hasFilters())
+ return true;
+
+#if ENABLE(FILTERS_LEVEL_2)
+ if (rareNonInheritedData->hasBackdropFilters() != other.rareNonInheritedData->hasBackdropFilters())
return true;
#endif
- const QuotesData* quotesDataA = rareInheritedData->quotes.get();
- const QuotesData* quotesDataB = other->rareInheritedData->quotes.get();
- if (!(quotesDataA == quotesDataB || (quotesDataA && quotesDataB && *quotesDataA == *quotesDataB)))
+ if (!arePointingToEqualData(rareInheritedData->quotes, other.rareInheritedData->quotes))
return true;
if (position() != StaticPosition) {
- if (surround->offset != other->surround->offset) {
+ if (surround->offset != other.surround->offset) {
// FIXME: We would like to use SimplifiedLayout for relative positioning, but we can't quite do that yet.
// We need to make sure SimplifiedLayout can operate correctly on RenderInlines (we will need
// to add a selfNeedsSimplifiedLayout bit in order to not get confused and taint every line).
@@ -675,7 +741,7 @@ bool RenderStyle::changeRequiresLayout(const RenderStyle* other, unsigned& chang
return true;
// Optimize for the case where a positioned layer is moving but not changing size.
- if (!positionChangeIsMovementOnly(surround->offset, other->surround->offset, m_box->width()))
+ if (!positionChangeIsMovementOnly(surround->offset, other.surround->offset, m_box->width()))
return true;
}
}
@@ -683,153 +749,136 @@ bool RenderStyle::changeRequiresLayout(const RenderStyle* other, unsigned& chang
return false;
}
-bool RenderStyle::changeRequiresPositionedLayoutOnly(const RenderStyle* other, unsigned&) const
+bool RenderStyle::changeRequiresPositionedLayoutOnly(const RenderStyle& other, unsigned&) const
{
if (position() == StaticPosition)
return false;
- if (surround->offset != other->surround->offset) {
+ if (surround->offset != other.surround->offset) {
// Optimize for the case where a positioned layer is moving but not changing size.
- if (position() == AbsolutePosition && positionChangeIsMovementOnly(surround->offset, other->surround->offset, m_box->width()))
+ if (position() == AbsolutePosition && positionChangeIsMovementOnly(surround->offset, other.surround->offset, m_box->width()))
return true;
}
return false;
}
-bool RenderStyle::changeRequiresLayerRepaint(const RenderStyle* other, unsigned& changedContextSensitiveProperties) const
+bool RenderStyle::changeRequiresLayerRepaint(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
{
+ // StyleResolver has ensured that zIndex is non-auto only if it's applicable.
+ if (m_box->zIndex() != other.m_box->zIndex() || m_box->hasAutoZIndex() != other.m_box->hasAutoZIndex())
+ return true;
+
if (position() != StaticPosition) {
- if (m_box->zIndex() != other->m_box->zIndex()
- || m_box->hasAutoZIndex() != other->m_box->hasAutoZIndex()
- || visual->clip != other->visual->clip
- || visual->hasClip != other->visual->hasClip)
+ if (visual->clip != other.visual->clip || visual->hasClip != other.visual->hasClip) {
+ changedContextSensitiveProperties |= ContextSensitivePropertyClipRect;
return true;
+ }
}
#if ENABLE(CSS_COMPOSITING)
- if (rareNonInheritedData->m_effectiveBlendMode != other->rareNonInheritedData->m_effectiveBlendMode)
+ if (rareNonInheritedData->m_effectiveBlendMode != other.rareNonInheritedData->m_effectiveBlendMode)
return true;
#endif
- if (rareNonInheritedData->opacity != other->rareNonInheritedData->opacity) {
-#if USE(ACCELERATED_COMPOSITING)
+ if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity) {
changedContextSensitiveProperties |= ContextSensitivePropertyOpacity;
// Don't return; keep looking for another change.
-#else
- UNUSED_PARAM(changedContextSensitiveProperties);
- return true;
-#endif
}
-#if ENABLE(CSS_FILTERS)
- if (rareNonInheritedData->m_filter.get() != other->rareNonInheritedData->m_filter.get()
- && *rareNonInheritedData->m_filter.get() != *other->rareNonInheritedData->m_filter.get()) {
-#if USE(ACCELERATED_COMPOSITING)
+ if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filter) {
changedContextSensitiveProperties |= ContextSensitivePropertyFilter;
// Don't return; keep looking for another change.
-#else
- return true;
-#endif
}
-#endif
- if (rareNonInheritedData->m_mask != other->rareNonInheritedData->m_mask
- || rareNonInheritedData->m_maskBoxImage != other->rareNonInheritedData->m_maskBoxImage)
+ if (rareNonInheritedData->m_mask != other.rareNonInheritedData->m_mask
+ || rareNonInheritedData->m_maskBoxImage != other.rareNonInheritedData->m_maskBoxImage)
return true;
return false;
}
-bool RenderStyle::changeRequiresRepaint(const RenderStyle* other, unsigned&) const
-{
- if (inherited_flags._visibility != other->inherited_flags._visibility
- || inherited_flags.m_printColorAdjust != other->inherited_flags.m_printColorAdjust
- || inherited_flags._insideLink != other->inherited_flags._insideLink
- || surround->border != other->surround->border
- || !m_background->isEquivalentForPainting(*other->m_background)
- || rareInheritedData->userModify != other->rareInheritedData->userModify
- || rareInheritedData->userSelect != other->rareInheritedData->userSelect
- || rareNonInheritedData->userDrag != other->rareNonInheritedData->userDrag
- || rareNonInheritedData->m_borderFit != other->rareNonInheritedData->m_borderFit
- || rareNonInheritedData->m_objectFit != other->rareNonInheritedData->m_objectFit
- || rareInheritedData->m_imageRendering != other->rareInheritedData->m_imageRendering)
+bool RenderStyle::changeRequiresRepaint(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
+{
+ if (inherited_flags._visibility != other.inherited_flags._visibility
+ || inherited_flags.m_printColorAdjust != other.inherited_flags.m_printColorAdjust
+ || inherited_flags._insideLink != other.inherited_flags._insideLink
+ || inherited_flags._insideDefaultButton != other.inherited_flags._insideDefaultButton
+ || surround->border != other.surround->border
+ || !m_background->isEquivalentForPainting(*other.m_background)
+ || rareInheritedData->userModify != other.rareInheritedData->userModify
+ || rareInheritedData->userSelect != other.rareInheritedData->userSelect
+ || rareNonInheritedData->userDrag != other.rareNonInheritedData->userDrag
+ || rareNonInheritedData->m_borderFit != other.rareNonInheritedData->m_borderFit
+ || rareNonInheritedData->m_objectFit != other.rareNonInheritedData->m_objectFit
+ || rareInheritedData->m_imageRendering != other.rareInheritedData->m_imageRendering)
return true;
#if ENABLE(CSS_SHAPES)
- // FIXME: The current spec is being reworked to remove dependencies between exclusions and affected
- // content. There's a proposal to use floats instead. In that case, wrap-shape should actually relayout
- // the parent container. For sure, I will have to revisit this code, but for now I've added this in order
- // to avoid having diff() == StyleDifferenceEqual where wrap-shapes actually differ.
- // Tracking bug: https://bugs.webkit.org/show_bug.cgi?id=62991
- if (rareNonInheritedData->m_shapeOutside != other->rareNonInheritedData->m_shapeOutside)
+ if (rareNonInheritedData->m_shapeOutside != other.rareNonInheritedData->m_shapeOutside)
return true;
#endif
- if (rareNonInheritedData->m_clipPath != other->rareNonInheritedData->m_clipPath)
- return true;
+ // FIXME: this should probably be moved to changeRequiresLayerRepaint().
+ if (rareNonInheritedData->m_clipPath != other.rareNonInheritedData->m_clipPath) {
+ changedContextSensitiveProperties |= ContextSensitivePropertyClipPath;
+ // Don't return; keep looking for another change.
+ }
return false;
}
-bool RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline(const RenderStyle* other, unsigned&) const
+bool RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline(const RenderStyle& other, unsigned&) const
{
- if (inherited->color != other->inherited->color
- || inherited_flags._text_decorations != other->inherited_flags._text_decorations
- || visual->textDecoration != other->visual->textDecoration
- || rareNonInheritedData->m_textDecorationStyle != other->rareNonInheritedData->m_textDecorationStyle
- || rareNonInheritedData->m_textDecorationColor != other->rareNonInheritedData->m_textDecorationColor
- || rareInheritedData->m_textDecorationSkip != other->rareInheritedData->m_textDecorationSkip
- || rareInheritedData->textFillColor != other->rareInheritedData->textFillColor
- || rareInheritedData->textStrokeColor != other->rareInheritedData->textStrokeColor
- || rareInheritedData->textEmphasisColor != other->rareInheritedData->textEmphasisColor
- || rareInheritedData->textEmphasisFill != other->rareInheritedData->textEmphasisFill)
+ if (inherited->color != other.inherited->color
+ || inherited_flags._text_decorations != other.inherited_flags._text_decorations
+ || visual->textDecoration != other.visual->textDecoration
+ || rareNonInheritedData->m_textDecorationStyle != other.rareNonInheritedData->m_textDecorationStyle
+ || rareNonInheritedData->m_textDecorationColor != other.rareNonInheritedData->m_textDecorationColor
+ || rareInheritedData->m_textDecorationSkip != other.rareInheritedData->m_textDecorationSkip
+ || rareInheritedData->textFillColor != other.rareInheritedData->textFillColor
+ || rareInheritedData->textStrokeColor != other.rareInheritedData->textStrokeColor
+ || rareInheritedData->textEmphasisColor != other.rareInheritedData->textEmphasisColor
+ || rareInheritedData->textEmphasisFill != other.rareInheritedData->textEmphasisFill)
return true;
return false;
}
-bool RenderStyle::changeRequiresRecompositeLayer(const RenderStyle* other, unsigned&) const
+bool RenderStyle::changeRequiresRecompositeLayer(const RenderStyle& other, unsigned&) const
{
-#if USE(ACCELERATED_COMPOSITING)
- if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) {
- if (rareNonInheritedData->m_transformStyle3D != other->rareNonInheritedData->m_transformStyle3D
- || rareNonInheritedData->m_backfaceVisibility != other->rareNonInheritedData->m_backfaceVisibility
- || rareNonInheritedData->m_perspective != other->rareNonInheritedData->m_perspective
- || rareNonInheritedData->m_perspectiveOriginX != other->rareNonInheritedData->m_perspectiveOriginX
- || rareNonInheritedData->m_perspectiveOriginY != other->rareNonInheritedData->m_perspectiveOriginY)
+ if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) {
+ if (rareNonInheritedData->m_transformStyle3D != other.rareNonInheritedData->m_transformStyle3D
+ || rareNonInheritedData->m_backfaceVisibility != other.rareNonInheritedData->m_backfaceVisibility
+ || rareNonInheritedData->m_perspective != other.rareNonInheritedData->m_perspective
+ || rareNonInheritedData->m_perspectiveOriginX != other.rareNonInheritedData->m_perspectiveOriginX
+ || rareNonInheritedData->m_perspectiveOriginY != other.rareNonInheritedData->m_perspectiveOriginY)
return true;
}
-#else
- UNUSED_PARAM(other);
-#endif
+
return false;
}
-StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedContextSensitiveProperties) const
+StyleDifference RenderStyle::diff(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
{
changedContextSensitiveProperties = ContextSensitivePropertyNone;
-#if ENABLE(SVG)
StyleDifference svgChange = StyleDifferenceEqual;
- if (m_svgStyle != other->m_svgStyle) {
- svgChange = m_svgStyle->diff(other->m_svgStyle.get());
+ if (m_svgStyle != other.m_svgStyle) {
+ svgChange = m_svgStyle->diff(other.m_svgStyle.get());
if (svgChange == StyleDifferenceLayout)
return svgChange;
}
-#endif
if (changeRequiresLayout(other, changedContextSensitiveProperties))
return StyleDifferenceLayout;
-#if ENABLE(SVG)
// SVGRenderStyle::diff() might have returned StyleDifferenceRepaint, eg. if fill changes.
// If eg. the font-size changed at the same time, we're not allowed to return StyleDifferenceRepaint,
// but have to return StyleDifferenceLayout, that's why this if branch comes after all branches
// that are relevant for SVG and might return StyleDifferenceLayout.
if (svgChange != StyleDifferenceEqual)
return svgChange;
-#endif
if (changeRequiresPositionedLayoutOnly(other, changedContextSensitiveProperties))
return StyleDifferenceLayoutPositionedMovementOnly;
@@ -840,10 +889,8 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
if (changeRequiresRepaint(other, changedContextSensitiveProperties))
return StyleDifferenceRepaint;
-#if USE(ACCELERATED_COMPOSITING)
if (changeRequiresRecompositeLayer(other, changedContextSensitiveProperties))
return StyleDifferenceRecompositeLayer;
-#endif
if (changeRequiresRepaintIfTextOrBorderOrOutline(other, changedContextSensitiveProperties))
return StyleDifferenceRepaintIfTextOrBorderOrOutline;
@@ -856,19 +903,26 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
return StyleDifferenceEqual;
}
-bool RenderStyle::diffRequiresRepaint(const RenderStyle* style) const
+bool RenderStyle::diffRequiresLayerRepaint(const RenderStyle& style, bool isComposited) const
{
unsigned changedContextSensitiveProperties = 0;
- return changeRequiresRepaint(style, changedContextSensitiveProperties);
+
+ if (changeRequiresRepaint(style, changedContextSensitiveProperties))
+ return true;
+
+ if (isComposited && changeRequiresLayerRepaint(style, changedContextSensitiveProperties))
+ return changedContextSensitiveProperties & ContextSensitivePropertyClipRect;
+
+ return false;
}
void RenderStyle::setClip(Length top, Length right, Length bottom, Length left)
{
StyleVisualData* data = visual.access();
- data->clip.m_top = top;
- data->clip.m_right = right;
- data->clip.m_bottom = bottom;
- data->clip.m_left = left;
+ data->clip.top() = top;
+ data->clip.right() = right;
+ data->clip.bottom() = bottom;
+ data->clip.left() = left;
}
void RenderStyle::addCursor(PassRefPtr<StyleImage> image, const IntPoint& hotSpot)
@@ -891,10 +945,18 @@ void RenderStyle::setQuotes(PassRefPtr<QuotesData> q)
rareInheritedData.access()->quotes = q;
}
+void RenderStyle::setWillChange(PassRefPtr<WillChangeData> willChangeData)
+{
+ if (arePointingToEqualData(rareNonInheritedData->m_willChange.get(), willChangeData.get()))
+ return;
+
+ rareNonInheritedData.access()->m_willChange = WTFMove(willChangeData);
+}
+
void RenderStyle::clearCursorList()
{
if (rareInheritedData->cursorData)
- rareInheritedData.access()->cursorData = 0;
+ rareInheritedData.access()->cursorData = nullptr;
}
void RenderStyle::clearContent()
@@ -911,9 +973,9 @@ void RenderStyle::appendContent(std::unique_ptr<ContentData> contentData)
lastContent = lastContent->next();
if (lastContent)
- lastContent->setNext(std::move(contentData));
+ lastContent->setNext(WTFMove(contentData));
else
- content = std::move(contentData);
+ content = WTFMove(contentData);
}
void RenderStyle::setContent(PassRefPtr<StyleImage> image, bool add)
@@ -941,9 +1003,9 @@ void RenderStyle::setContent(const String& string, bool add)
if (lastContent) {
// We attempt to merge with the last ContentData if possible.
- if (lastContent->isText()) {
- TextContentData* textContent = static_cast<TextContentData*>(lastContent);
- textContent->setText(textContent->text() + string);
+ if (is<TextContentData>(*lastContent)) {
+ TextContentData& textContent = downcast<TextContentData>(*lastContent);
+ textContent.setText(textContent.text() + string);
} else
lastContent->setNext(std::make_unique<TextContentData>(string));
@@ -964,11 +1026,11 @@ void RenderStyle::setContent(std::unique_ptr<CounterContent> counter, bool add)
return;
if (add) {
- appendContent(std::make_unique<CounterContentData>(std::move(counter)));
+ appendContent(std::make_unique<CounterContentData>(WTFMove(counter)));
return;
}
- rareNonInheritedData.access()->m_content = std::make_unique<CounterContentData>(std::move(counter));
+ rareNonInheritedData.access()->m_content = std::make_unique<CounterContentData>(WTFMove(counter));
}
void RenderStyle::setContent(QuoteType quote, bool add)
@@ -994,7 +1056,8 @@ const String& RenderStyle::contentAltText() const
return rareNonInheritedData->m_altText;
}
-inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& transformOperations, RenderStyle::ApplyTransformOrigin applyOrigin)
+// FIXME: use affectedByTransformOrigin().
+static inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& transformOperations, RenderStyle::ApplyTransformOrigin applyOrigin)
{
// transform-origin brackets the transform with translate operations.
// Optimize for the case where the only transform is a translation, since the transform-origin is irrelevant
@@ -1002,9 +1065,8 @@ inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& tra
if (applyOrigin != RenderStyle::IncludeTransformOrigin)
return false;
- unsigned size = transformOperations.size();
- for (unsigned i = 0; i < size; ++i) {
- TransformOperation::OperationType type = transformOperations[i]->type();
+ for (auto& operation : transformOperations) {
+ TransformOperation::OperationType type = operation->type();
if (type != TransformOperation::TRANSLATE_X
&& type != TransformOperation::TRANSLATE_Y
&& type != TransformOperation::TRANSLATE
@@ -1012,47 +1074,27 @@ inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& tra
&& type != TransformOperation::TRANSLATE_3D)
return true;
}
-
+
return false;
}
-void RenderStyle::applyTransform(TransformationMatrix& transform, const LayoutSize& borderBoxSize, ApplyTransformOrigin applyOrigin) const
+void RenderStyle::applyTransform(TransformationMatrix& transform, const FloatRect& boundingBox, ApplyTransformOrigin applyOrigin) const
{
- // FIXME: when subpixel layout is supported (bug 71143) the body of this function could be replaced by
- // applyTransform(transform, FloatRect(FloatPoint(), borderBoxSize), applyOrigin);
-
- const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInheritedData->m_transform->m_operations.operations();
- bool applyTransformOrigin = requireTransformOrigin(transformOperations, applyOrigin);
+ auto& operations = rareNonInheritedData->m_transform->m_operations.operations();
+ bool applyTransformOrigin = requireTransformOrigin(operations, applyOrigin);
- if (applyTransformOrigin)
- transform.translate3d(floatValueForLength(transformOriginX(), borderBoxSize.width()), floatValueForLength(transformOriginY(), borderBoxSize.height()), transformOriginZ());
-
- unsigned size = transformOperations.size();
- for (unsigned i = 0; i < size; ++i)
- transformOperations[i]->apply(transform, borderBoxSize);
-
- if (applyTransformOrigin)
- transform.translate3d(-floatValueForLength(transformOriginX(), borderBoxSize.width()), -floatValueForLength(transformOriginY(), borderBoxSize.height()), -transformOriginZ());
-}
+ float offsetX = transformOriginX().isPercent() ? boundingBox.x() : 0;
+ float offsetY = transformOriginY().isPercent() ? boundingBox.y() : 0;
-void RenderStyle::applyTransform(TransformationMatrix& transform, const FloatRect& boundingBox, ApplyTransformOrigin applyOrigin) const
-{
- const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInheritedData->m_transform->m_operations.operations();
- bool applyTransformOrigin = requireTransformOrigin(transformOperations, applyOrigin);
-
- float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0;
- float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0;
-
if (applyTransformOrigin) {
transform.translate3d(floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX,
floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY,
transformOriginZ());
}
-
- unsigned size = transformOperations.size();
- for (unsigned i = 0; i < size; ++i)
- transformOperations[i]->apply(transform, boundingBox.size());
-
+
+ for (auto& operation : operations)
+ operation->apply(transform, boundingBox.size());
+
if (applyTransformOrigin) {
transform.translate3d(-floatValueForLength(transformOriginX(), boundingBox.width()) - offsetX,
-floatValueForLength(transformOriginY(), boundingBox.height()) - offsetY,
@@ -1071,75 +1113,43 @@ void RenderStyle::setPageScaleTransform(float scale)
setTransformOriginY(Length(0, Fixed));
}
-void RenderStyle::setTextShadow(PassOwnPtr<ShadowData> shadowData, bool add)
+void RenderStyle::setTextShadow(std::unique_ptr<ShadowData> shadowData, bool add)
{
ASSERT(!shadowData || (!shadowData->spread() && shadowData->style() == Normal));
StyleRareInheritedData* rareData = rareInheritedData.access();
if (!add) {
- rareData->textShadow = shadowData;
+ rareData->textShadow = WTFMove(shadowData);
return;
}
- shadowData->setNext(rareData->textShadow.release());
- rareData->textShadow = shadowData;
+ shadowData->setNext(WTFMove(rareData->textShadow));
+ rareData->textShadow = WTFMove(shadowData);
}
-void RenderStyle::setBoxShadow(PassOwnPtr<ShadowData> shadowData, bool add)
+void RenderStyle::setBoxShadow(std::unique_ptr<ShadowData> shadowData, bool add)
{
StyleRareNonInheritedData* rareData = rareNonInheritedData.access();
if (!add) {
- rareData->m_boxShadow = shadowData;
+ rareData->m_boxShadow = WTFMove(shadowData);
return;
}
- shadowData->setNext(rareData->m_boxShadow.release());
- rareData->m_boxShadow = shadowData;
+ shadowData->setNext(WTFMove(rareData->m_boxShadow));
+ rareData->m_boxShadow = WTFMove(shadowData);
}
-static RoundedRect::Radii calcRadiiFor(const BorderData& border, IntSize size, RenderView* renderView)
+static RoundedRect::Radii calcRadiiFor(const BorderData& border, const LayoutSize& size)
{
return RoundedRect::Radii(
- IntSize(valueForLength(border.topLeft().width(), size.width(), renderView),
- valueForLength(border.topLeft().height(), size.height(), renderView)),
- IntSize(valueForLength(border.topRight().width(), size.width(), renderView),
- valueForLength(border.topRight().height(), size.height(), renderView)),
- IntSize(valueForLength(border.bottomLeft().width(), size.width(), renderView),
- valueForLength(border.bottomLeft().height(), size.height(), renderView)),
- IntSize(valueForLength(border.bottomRight().width(), size.width(), renderView),
- valueForLength(border.bottomRight().height(), size.height(), renderView)));
-}
-
-static float calcConstraintScaleFor(const IntRect& rect, const RoundedRect::Radii& radii)
-{
- // Constrain corner radii using CSS3 rules:
- // http://www.w3.org/TR/css3-background/#the-border-radius
-
- float factor = 1;
- unsigned radiiSum;
-
- // top
- radiiSum = static_cast<unsigned>(radii.topLeft().width()) + static_cast<unsigned>(radii.topRight().width()); // Casts to avoid integer overflow.
- if (radiiSum > static_cast<unsigned>(rect.width()))
- factor = std::min(static_cast<float>(rect.width()) / radiiSum, factor);
-
- // bottom
- radiiSum = static_cast<unsigned>(radii.bottomLeft().width()) + static_cast<unsigned>(radii.bottomRight().width());
- if (radiiSum > static_cast<unsigned>(rect.width()))
- factor = std::min(static_cast<float>(rect.width()) / radiiSum, factor);
-
- // left
- radiiSum = static_cast<unsigned>(radii.topLeft().height()) + static_cast<unsigned>(radii.bottomLeft().height());
- if (radiiSum > static_cast<unsigned>(rect.height()))
- factor = std::min(static_cast<float>(rect.height()) / radiiSum, factor);
-
- // right
- radiiSum = static_cast<unsigned>(radii.topRight().height()) + static_cast<unsigned>(radii.bottomRight().height());
- if (radiiSum > static_cast<unsigned>(rect.height()))
- factor = std::min(static_cast<float>(rect.height()) / radiiSum, factor);
-
- ASSERT(factor <= 1);
- return factor;
+ LayoutSize(valueForLength(border.topLeft().width(), size.width()),
+ valueForLength(border.topLeft().height(), size.height())),
+ LayoutSize(valueForLength(border.topRight().width(), size.width()),
+ valueForLength(border.topRight().height(), size.height())),
+ LayoutSize(valueForLength(border.bottomLeft().width(), size.width()),
+ valueForLength(border.bottomLeft().height(), size.height())),
+ LayoutSize(valueForLength(border.bottomRight().width(), size.width()),
+ valueForLength(border.bottomRight().height(), size.height())));
}
StyleImage* RenderStyle::listStyleImage() const { return rareInheritedData->listStyleImage.get(); }
@@ -1159,13 +1169,12 @@ short RenderStyle::verticalBorderSpacing() const { return inherited->vertical_bo
void RenderStyle::setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horizontal_border_spacing, v); }
void RenderStyle::setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertical_border_spacing, v); }
-RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, RenderView* renderView, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
+RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
{
- IntRect snappedBorderRect(pixelSnappedIntRect(borderRect));
- RoundedRect roundedRect(snappedBorderRect);
+ RoundedRect roundedRect(borderRect);
if (hasBorderRadius()) {
- RoundedRect::Radii radii = calcRadiiFor(surround->border, snappedBorderRect.size(), renderView);
- radii.scale(calcConstraintScaleFor(snappedBorderRect, radii));
+ RoundedRect::Radii radii = calcRadiiFor(surround->border, borderRect.size());
+ radii.scale(calcBorderRadiiConstraintScaleFor(borderRect, radii));
roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
}
return roundedRect;
@@ -1175,23 +1184,23 @@ RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect,
{
bool horizontal = isHorizontalWritingMode();
- int leftWidth = (!horizontal || includeLogicalLeftEdge) ? borderLeftWidth() : 0;
- int rightWidth = (!horizontal || includeLogicalRightEdge) ? borderRightWidth() : 0;
- int topWidth = (horizontal || includeLogicalLeftEdge) ? borderTopWidth() : 0;
- int bottomWidth = (horizontal || includeLogicalRightEdge) ? borderBottomWidth() : 0;
+ LayoutUnit leftWidth = (!horizontal || includeLogicalLeftEdge) ? borderLeftWidth() : 0;
+ LayoutUnit rightWidth = (!horizontal || includeLogicalRightEdge) ? borderRightWidth() : 0;
+ LayoutUnit topWidth = (horizontal || includeLogicalLeftEdge) ? borderTopWidth() : 0;
+ LayoutUnit bottomWidth = (horizontal || includeLogicalRightEdge) ? borderBottomWidth() : 0;
return getRoundedInnerBorderFor(borderRect, topWidth, bottomWidth, leftWidth, rightWidth, includeLogicalLeftEdge, includeLogicalRightEdge);
}
-RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect,
- int topWidth, int bottomWidth, int leftWidth, int rightWidth, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
+RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect, LayoutUnit topWidth, LayoutUnit bottomWidth,
+ LayoutUnit leftWidth, LayoutUnit rightWidth, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
{
LayoutRect innerRect(borderRect.x() + leftWidth,
borderRect.y() + topWidth,
borderRect.width() - leftWidth - rightWidth,
borderRect.height() - topWidth - bottomWidth);
- RoundedRect roundedRect(pixelSnappedIntRect(innerRect));
+ RoundedRect roundedRect(innerRect);
if (hasBorderRadius()) {
RoundedRect::Radii radii = getRoundedBorderFor(borderRect).radii();
@@ -1223,9 +1232,9 @@ const CounterDirectiveMap* RenderStyle::counterDirectives() const
CounterDirectiveMap& RenderStyle::accessCounterDirectives()
{
- OwnPtr<CounterDirectiveMap>& map = rareNonInheritedData.access()->m_counterDirectives;
+ auto& map = rareNonInheritedData.access()->m_counterDirectives;
if (!map)
- map = adoptPtr(new CounterDirectiveMap);
+ map = std::make_unique<CounterDirectiveMap>();
return *map;
}
@@ -1245,9 +1254,9 @@ const AtomicString& RenderStyle::hyphenString() const
return hyphenationString;
// FIXME: This should depend on locale.
- DEFINE_STATIC_LOCAL(AtomicString, hyphenMinusString, (&hyphenMinus, 1));
- DEFINE_STATIC_LOCAL(AtomicString, hyphenString, (&hyphen, 1));
- return font().primaryFontHasGlyphForCharacter(hyphen) ? hyphenString : hyphenMinusString;
+ static NeverDestroyed<AtomicString> hyphenMinusString(&hyphenMinus, 1);
+ static NeverDestroyed<AtomicString> hyphenString(&hyphen, 1);
+ return fontCascade().primaryFont().glyphForCharacter(hyphen) ? hyphenString : hyphenMinusString;
}
const AtomicString& RenderStyle::textEmphasisMarkString() const
@@ -1258,28 +1267,28 @@ const AtomicString& RenderStyle::textEmphasisMarkString() const
case TextEmphasisMarkCustom:
return textEmphasisCustomMark();
case TextEmphasisMarkDot: {
- DEFINE_STATIC_LOCAL(AtomicString, filledDotString, (&bullet, 1));
- DEFINE_STATIC_LOCAL(AtomicString, openDotString, (&whiteBullet, 1));
+ static NeverDestroyed<AtomicString> filledDotString(&bullet, 1);
+ static NeverDestroyed<AtomicString> openDotString(&whiteBullet, 1);
return textEmphasisFill() == TextEmphasisFillFilled ? filledDotString : openDotString;
}
case TextEmphasisMarkCircle: {
- DEFINE_STATIC_LOCAL(AtomicString, filledCircleString, (&blackCircle, 1));
- DEFINE_STATIC_LOCAL(AtomicString, openCircleString, (&whiteCircle, 1));
+ static NeverDestroyed<AtomicString> filledCircleString(&blackCircle, 1);
+ static NeverDestroyed<AtomicString> openCircleString(&whiteCircle, 1);
return textEmphasisFill() == TextEmphasisFillFilled ? filledCircleString : openCircleString;
}
case TextEmphasisMarkDoubleCircle: {
- DEFINE_STATIC_LOCAL(AtomicString, filledDoubleCircleString, (&fisheye, 1));
- DEFINE_STATIC_LOCAL(AtomicString, openDoubleCircleString, (&bullseye, 1));
+ static NeverDestroyed<AtomicString> filledDoubleCircleString(&fisheye, 1);
+ static NeverDestroyed<AtomicString> openDoubleCircleString(&bullseye, 1);
return textEmphasisFill() == TextEmphasisFillFilled ? filledDoubleCircleString : openDoubleCircleString;
}
case TextEmphasisMarkTriangle: {
- DEFINE_STATIC_LOCAL(AtomicString, filledTriangleString, (&blackUpPointingTriangle, 1));
- DEFINE_STATIC_LOCAL(AtomicString, openTriangleString, (&whiteUpPointingTriangle, 1));
+ static NeverDestroyed<AtomicString> filledTriangleString(&blackUpPointingTriangle, 1);
+ static NeverDestroyed<AtomicString> openTriangleString(&whiteUpPointingTriangle, 1);
return textEmphasisFill() == TextEmphasisFillFilled ? filledTriangleString : openTriangleString;
}
case TextEmphasisMarkSesame: {
- DEFINE_STATIC_LOCAL(AtomicString, filledSesameString, (&sesameDot, 1));
- DEFINE_STATIC_LOCAL(AtomicString, openSesameString, (&whiteSesameDot, 1));
+ static NeverDestroyed<AtomicString> filledSesameString(&sesameDot, 1);
+ static NeverDestroyed<AtomicString> openSesameString(&whiteSesameDot, 1);
return textEmphasisFill() == TextEmphasisFillFilled ? filledSesameString : openSesameString;
}
case TextEmphasisMarkAuto:
@@ -1294,24 +1303,24 @@ const AtomicString& RenderStyle::textEmphasisMarkString() const
#if ENABLE(DASHBOARD_SUPPORT)
const Vector<StyleDashboardRegion>& RenderStyle::initialDashboardRegions()
{
- DEFINE_STATIC_LOCAL(Vector<StyleDashboardRegion>, emptyList, ());
+ static NeverDestroyed<Vector<StyleDashboardRegion>> emptyList;
return emptyList;
}
const Vector<StyleDashboardRegion>& RenderStyle::noneDashboardRegions()
{
- DEFINE_STATIC_LOCAL(Vector<StyleDashboardRegion>, noneList, ());
+ static NeverDestroyed<Vector<StyleDashboardRegion>> noneList;
static bool noneListInitialized = false;
if (!noneListInitialized) {
StyleDashboardRegion region;
region.label = "";
- region.offset.m_top = Length();
- region.offset.m_right = Length();
- region.offset.m_bottom = Length();
- region.offset.m_left = Length();
+ region.offset.top() = Length();
+ region.offset.right() = Length();
+ region.offset.bottom() = Length();
+ region.offset.left() = Length();
region.type = StyleDashboardRegion::None;
- noneList.append(region);
+ noneList.get().append(region);
noneListInitialized = true;
}
return noneList;
@@ -1376,18 +1385,18 @@ void RenderStyle::adjustTransitions()
}
}
-AnimationList* RenderStyle::accessAnimations()
+AnimationList& RenderStyle::ensureAnimations()
{
if (!rareNonInheritedData.access()->m_animations)
- rareNonInheritedData.access()->m_animations = adoptPtr(new AnimationList());
- return rareNonInheritedData->m_animations.get();
+ rareNonInheritedData.access()->m_animations = std::make_unique<AnimationList>();
+ return *rareNonInheritedData->m_animations;
}
-AnimationList* RenderStyle::accessTransitions()
+AnimationList& RenderStyle::ensureTransitions()
{
if (!rareNonInheritedData.access()->m_transitions)
- rareNonInheritedData.access()->m_transitions = adoptPtr(new AnimationList());
- return rareNonInheritedData->m_transitions.get();
+ rareNonInheritedData.access()->m_transitions = std::make_unique<AnimationList>();
+ return *rareNonInheritedData->m_transitions;
}
const Animation* RenderStyle::transitionForProperty(CSSPropertyID property) const
@@ -1403,20 +1412,20 @@ const Animation* RenderStyle::transitionForProperty(CSSPropertyID property) cons
return 0;
}
-const Font& RenderStyle::font() const { return inherited->font; }
-const FontMetrics& RenderStyle::fontMetrics() const { return inherited->font.fontMetrics(); }
-const FontDescription& RenderStyle::fontDescription() const { return inherited->font.fontDescription(); }
+const FontCascade& RenderStyle::fontCascade() const { return inherited->fontCascade; }
+const FontMetrics& RenderStyle::fontMetrics() const { return inherited->fontCascade.fontMetrics(); }
+const FontCascadeDescription& RenderStyle::fontDescription() const { return inherited->fontCascade.fontDescription(); }
float RenderStyle::specifiedFontSize() const { return fontDescription().specifiedSize(); }
float RenderStyle::computedFontSize() const { return fontDescription().computedSize(); }
-int RenderStyle::fontSize() const { return inherited->font.pixelSize(); }
+int RenderStyle::fontSize() const { return inherited->fontCascade.pixelSize(); }
const Length& RenderStyle::wordSpacing() const { return rareInheritedData->wordSpacing; }
-float RenderStyle::letterSpacing() const { return inherited->font.letterSpacing(); }
+float RenderStyle::letterSpacing() const { return inherited->fontCascade.letterSpacing(); }
-bool RenderStyle::setFontDescription(const FontDescription& v)
+bool RenderStyle::setFontDescription(const FontCascadeDescription& v)
{
- if (inherited->font.fontDescription() != v) {
- inherited.access()->font = Font(v, inherited->font.letterSpacing(), inherited->font.wordSpacing());
+ if (inherited->fontCascade.fontDescription() != v) {
+ inherited.access()->fontCascade = FontCascade(v, inherited->fontCascade.letterSpacing(), inherited->fontCascade.wordSpacing());
return true;
}
return false;
@@ -1445,7 +1454,7 @@ Length RenderStyle::lineHeight() const
}
void RenderStyle::setLineHeight(Length specifiedLineHeight) { SET_VAR(inherited, line_height, specifiedLineHeight); }
-int RenderStyle::computedLineHeight(RenderView* renderView) const
+int RenderStyle::computedLineHeight() const
{
const Length& lh = lineHeight();
@@ -1453,41 +1462,38 @@ int RenderStyle::computedLineHeight(RenderView* renderView) const
if (lh.isNegative())
return fontMetrics().lineSpacing();
- if (lh.isPercent())
+ if (lh.isPercentOrCalculated())
return minimumValueForLength(lh, fontSize());
- if (lh.isViewportPercentage())
- return valueForLength(lh, 0, renderView);
-
- return lh.value();
+ return clampTo<int>(lh.value());
}
-void RenderStyle::setWordSpacing(Length v)
+void RenderStyle::setWordSpacing(Length value)
{
float fontWordSpacing;
- switch (v.type()) {
+ switch (value.type()) {
case Auto:
fontWordSpacing = 0;
- FALLTHROUGH;
+ break;
case Percent:
- fontWordSpacing = v.getFloatValue() * font().spaceWidth() / 100;
+ fontWordSpacing = value.percent() * fontCascade().spaceWidth() / 100;
break;
case Fixed:
- fontWordSpacing = v.getFloatValue();
+ fontWordSpacing = value.value();
break;
case Calculated:
- fontWordSpacing = v.nonNanCalculatedValue(maxValueForCssLength);
+ fontWordSpacing = value.nonNanCalculatedValue(maxValueForCssLength);
break;
default:
ASSERT_NOT_REACHED();
fontWordSpacing = 0;
break;
}
- inherited.access()->font.setWordSpacing(fontWordSpacing);
- rareInheritedData.access()->wordSpacing = std::move(v);
+ inherited.access()->fontCascade.setWordSpacing(fontWordSpacing);
+ rareInheritedData.access()->wordSpacing = WTFMove(value);
}
-void RenderStyle::setLetterSpacing(float v) { inherited.access()->font.setLetterSpacing(v); }
+void RenderStyle::setLetterSpacing(float v) { inherited.access()->fontCascade.setLetterSpacing(v); }
void RenderStyle::setFontSize(float size)
{
@@ -1500,21 +1506,21 @@ void RenderStyle::setFontSize(float size)
else
size = std::min(maximumAllowedFontSize, size);
- FontSelector* currentFontSelector = font().fontSelector();
- FontDescription desc(fontDescription());
- desc.setSpecifiedSize(size);
- desc.setComputedSize(size);
+ FontSelector* currentFontSelector = fontCascade().fontSelector();
+ auto description = fontDescription();
+ description.setSpecifiedSize(size);
+ description.setComputedSize(size);
#if ENABLE(TEXT_AUTOSIZING)
float multiplier = textAutosizingMultiplier();
if (multiplier > 1) {
float autosizedFontSize = TextAutosizer::computeAutosizedFontSize(size, multiplier);
- desc.setComputedSize(min(maximumAllowedFontSize, autosizedFontSize));
+ description.setComputedSize(min(maximumAllowedFontSize, autosizedFontSize));
}
#endif
- setFontDescription(desc);
- font().update(currentFontSelector);
+ setFontDescription(description);
+ fontCascade().update(currentFontSelector);
}
void RenderStyle::getShadowExtent(const ShadowData* shadow, LayoutUnit &top, LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const
@@ -1616,7 +1622,7 @@ Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) c
case CSSPropertyOutlineColor:
result = visitedLink ? visitedLinkOutlineColor() : outlineColor();
break;
- case CSSPropertyWebkitColumnRuleColor:
+ case CSSPropertyColumnRuleColor:
result = visitedLink ? visitedLinkColumnRuleColor() : columnRuleColor();
break;
case CSSPropertyWebkitTextDecorationColor:
@@ -1715,7 +1721,7 @@ const BorderValue& RenderStyle::borderEnd() const
return isLeftToRightDirection() ? borderBottom() : borderTop();
}
-unsigned short RenderStyle::borderBeforeWidth() const
+float RenderStyle::borderBeforeWidth() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
@@ -1731,7 +1737,7 @@ unsigned short RenderStyle::borderBeforeWidth() const
return borderTopWidth();
}
-unsigned short RenderStyle::borderAfterWidth() const
+float RenderStyle::borderAfterWidth() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
@@ -1747,14 +1753,14 @@ unsigned short RenderStyle::borderAfterWidth() const
return borderBottomWidth();
}
-unsigned short RenderStyle::borderStartWidth() const
+float RenderStyle::borderStartWidth() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth();
return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth();
}
-unsigned short RenderStyle::borderEndWidth() const
+float RenderStyle::borderEndWidth() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth();
@@ -1818,42 +1824,23 @@ LayoutBoxExtent RenderStyle::imageOutsets(const NinePieceImage& image) const
NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth()));
}
-void RenderStyle::getFontAndGlyphOrientation(FontOrientation& fontOrientation, NonCJKGlyphOrientation& glyphOrientation)
+std::pair<FontOrientation, NonCJKGlyphOrientation> RenderStyle::fontAndGlyphOrientation()
{
- if (isHorizontalWritingMode()) {
- fontOrientation = Horizontal;
- glyphOrientation = NonCJKGlyphOrientationVerticalRight;
- return;
- }
+ // FIXME: TextOrientationSideways should map to sideways-left in vertical-lr, which is not supported yet.
+
+ if (isHorizontalWritingMode())
+ return { Horizontal, NonCJKGlyphOrientation::Mixed };
switch (textOrientation()) {
- case TextOrientationVerticalRight:
- fontOrientation = Vertical;
- glyphOrientation = NonCJKGlyphOrientationVerticalRight;
- return;
- case TextOrientationUpright:
- fontOrientation = Vertical;
- glyphOrientation = NonCJKGlyphOrientationUpright;
- return;
- case TextOrientationSideways:
- if (writingMode() == LeftToRightWritingMode) {
- // FIXME: This should map to sideways-left, which is not supported yet.
- fontOrientation = Vertical;
- glyphOrientation = NonCJKGlyphOrientationVerticalRight;
- return;
- }
- fontOrientation = Horizontal;
- glyphOrientation = NonCJKGlyphOrientationVerticalRight;
- return;
- case TextOrientationSidewaysRight:
- fontOrientation = Horizontal;
- glyphOrientation = NonCJKGlyphOrientationVerticalRight;
- return;
+ case TextOrientation::Mixed:
+ return { Vertical, NonCJKGlyphOrientation::Mixed };
+ case TextOrientation::Upright:
+ return { Vertical, NonCJKGlyphOrientation::Upright };
+ case TextOrientation::Sideways:
+ return { Horizontal, NonCJKGlyphOrientation::Mixed };
default:
ASSERT_NOT_REACHED();
- fontOrientation = Horizontal;
- glyphOrientation = NonCJKGlyphOrientationVerticalRight;
- return;
+ return { Horizontal, NonCJKGlyphOrientation::Mixed };
}
}
@@ -1889,7 +1876,9 @@ void RenderStyle::setColumnStylesFromPaginationMode(const Pagination::Mode& pagi
{
if (paginationMode == Pagination::Unpaginated)
return;
-
+
+ setColumnFill(ColumnFillAuto);
+
switch (paginationMode) {
case Pagination::LeftToRightPaginated:
setColumnAxis(HorizontalColumnAxis);
@@ -1925,4 +1914,149 @@ void RenderStyle::setColumnStylesFromPaginationMode(const Pagination::Mode& pagi
}
}
+#if ENABLE(CSS_SCROLL_SNAP)
+LengthSize RenderStyle::initialScrollSnapDestination()
+{
+ return defaultScrollSnapDestination();
+}
+
+Vector<LengthSize> RenderStyle::initialScrollSnapCoordinates()
+{
+ return Vector<LengthSize>();
+}
+
+const ScrollSnapPoints* RenderStyle::scrollSnapPointsX() const
+{
+ return rareNonInheritedData->m_scrollSnapPoints->xPoints.get();
+}
+
+const ScrollSnapPoints* RenderStyle::scrollSnapPointsY() const
+{
+ return rareNonInheritedData->m_scrollSnapPoints->yPoints.get();
+}
+
+const LengthSize& RenderStyle::scrollSnapDestination() const
+{
+ return rareNonInheritedData->m_scrollSnapPoints->destination;
+}
+
+const Vector<LengthSize>& RenderStyle::scrollSnapCoordinates() const
+{
+ return rareNonInheritedData->m_scrollSnapPoints->coordinates;
+}
+
+void RenderStyle::setScrollSnapPointsX(std::unique_ptr<ScrollSnapPoints> points)
+{
+ if (rareNonInheritedData->m_scrollSnapPoints->xPoints.get() == points.get())
+ return;
+ rareNonInheritedData.access()->m_scrollSnapPoints.access()->xPoints = WTFMove(points);
+}
+
+void RenderStyle::setScrollSnapPointsY(std::unique_ptr<ScrollSnapPoints> points)
+{
+ if (rareNonInheritedData->m_scrollSnapPoints->yPoints.get() == points.get())
+ return;
+ rareNonInheritedData.access()->m_scrollSnapPoints.access()->yPoints = WTFMove(points);
+}
+
+void RenderStyle::setScrollSnapDestination(LengthSize destination)
+{
+ if (rareNonInheritedData->m_scrollSnapPoints->destination == destination)
+ return;
+ rareNonInheritedData.access()->m_scrollSnapPoints.access()->destination = WTFMove(destination);
+}
+
+void RenderStyle::setScrollSnapCoordinates(Vector<LengthSize> coordinates)
+{
+ if (rareNonInheritedData->m_scrollSnapPoints->coordinates == coordinates)
+ return;
+ rareNonInheritedData.access()->m_scrollSnapPoints.access()->coordinates = WTFMove(coordinates);
+}
+
+#endif
+
+bool RenderStyle::hasReferenceFilterOnly() const
+{
+ if (!hasFilter())
+ return false;
+
+ const FilterOperations& filterOperations = rareNonInheritedData->m_filter->m_operations;
+ if (filterOperations.size() != 1)
+ return false;
+
+ const FilterOperation& filterOperation = *filterOperations.at(0);
+ if (filterOperation.type() != FilterOperation::REFERENCE)
+ return false;
+
+ return true;
+}
+
+void RenderStyle::checkVariablesInCustomProperties()
+{
+ if (!rareInheritedData->m_customProperties->containsVariables())
+ return;
+
+ // Our first pass checks the variables for validity and replaces any properties that became
+ // invalid with empty values.
+ auto& customProperties = rareInheritedData.access()->m_customProperties.access()->values();
+ HashSet<AtomicString> invalidProperties;
+ for (auto entry : customProperties) {
+ if (!entry.value->isVariableDependentValue())
+ continue;
+ HashSet<AtomicString> seenProperties;
+ downcast<CSSVariableDependentValue>(*entry.value).checkVariablesForCycles(entry.key, customProperties, seenProperties, invalidProperties);
+ }
+
+ // Now insert invalid values.
+ if (!invalidProperties.isEmpty()) {
+ RefPtr<CSSValue> invalidValue = CSSCustomPropertyValue::createInvalid();
+ for (auto& property : invalidProperties)
+ customProperties.set(property, invalidValue);
+ }
+
+ // Now that all of the properties have been tested for validity and replaced with
+ // invalid values if they failed, we can perform variable substitution on the valid values.
+ Vector<RefPtr<CSSCustomPropertyValue>> resolvedValues;
+ for (auto entry : customProperties) {
+ if (!entry.value->isVariableDependentValue())
+ continue;
+
+ CSSParserValueList parserList;
+ RefPtr<CSSCustomPropertyValue> result;
+ if (!downcast<CSSVariableDependentValue>(*entry.value).valueList()->buildParserValueListSubstitutingVariables(&parserList, customProperties)) {
+ RefPtr<CSSValue> invalidResult = CSSCustomPropertyValue::createInvalid();
+ result = CSSCustomPropertyValue::create(entry.key, invalidResult);
+ } else {
+ RefPtr<CSSValue> newValueList = CSSValueList::createFromParserValueList(parserList);
+ result = CSSCustomPropertyValue::create(entry.key, newValueList);
+ }
+ resolvedValues.append(result);
+ }
+
+ // With all results computed, we can now mutate our table to eliminate the variables and
+ // hold the final values. This way when we inherit, we don't end up resubstituting variables, etc.
+ for (auto& resolvedValue : resolvedValues)
+ customProperties.set(resolvedValue->name(), resolvedValue->value());
+
+ rareInheritedData.access()->m_customProperties.access()->setContainsVariables(false);
+}
+
+float RenderStyle::outlineWidth() const
+{
+ if (m_background->outline().style() == BNONE)
+ return 0;
+ if (outlineStyleIsAuto())
+ return std::max(m_background->outline().width(), RenderTheme::platformFocusRingWidth());
+ return m_background->outline().width();
+}
+
+float RenderStyle::outlineOffset() const
+{
+ if (m_background->outline().style() == BNONE)
+ return 0;
+ if (outlineStyleIsAuto())
+ return (m_background->outline().offset() + RenderTheme::platformFocusRingOffset(outlineWidth()));
+ return m_background->outline().offset();
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h
index 73a5350ce..559df8182 100644
--- a/Source/WebCore/rendering/style/RenderStyle.h
+++ b/Source/WebCore/rendering/style/RenderStyle.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, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-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
@@ -37,7 +37,6 @@
#include "FontBaseline.h"
#include "FontDescription.h"
#include "GraphicsTypes.h"
-#include "LayoutBoxExtent.h"
#include "Length.h"
#include "LengthBox.h"
#include "LengthFunctions.h"
@@ -48,14 +47,15 @@
#include "Pagination.h"
#include "RenderStyleConstants.h"
#include "RoundedRect.h"
+#include "SVGPaint.h"
+#include "SVGRenderStyle.h"
#include "ShadowData.h"
#include "ShapeValue.h"
#include "StyleBackgroundData.h"
#include "StyleBoxData.h"
#include "StyleDeprecatedFlexibleBoxData.h"
+#include "StyleFilterData.h"
#include "StyleFlexibleBoxData.h"
-#include "StyleGridData.h"
-#include "StyleGridItemData.h"
#include "StyleMarqueeData.h"
#include "StyleMultiColData.h"
#include "StyleRareInheritedData.h"
@@ -64,18 +64,20 @@
#include "StyleSurroundData.h"
#include "StyleTransformData.h"
#include "StyleVisualData.h"
-#include "TextDirection.h"
+#include "TextFlags.h"
#include "ThemeTypes.h"
#include "TransformOperations.h"
#include "UnicodeBidi.h"
+#include <memory>
#include <wtf/Forward.h>
-#include <wtf/OwnPtr.h>
+#include <wtf/NeverDestroyed.h>
#include <wtf/RefCounted.h>
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
-#if ENABLE(CSS_FILTERS)
-#include "StyleFilterData.h"
+#if ENABLE(CSS_GRID_LAYOUT)
+#include "StyleGridData.h"
+#include "StyleGridItemData.h"
#endif
#if ENABLE(DASHBOARD_SUPPORT)
@@ -86,31 +88,28 @@
#include "TextSizeAdjustment.h"
#endif
-#if ENABLE(SVG)
-#include "SVGPaint.h"
-#include "SVGRenderStyle.h"
-#endif
-
-template<typename T, typename U> inline bool compareEqual(const T& t, const U& u) { return t == static_cast<T>(u); }
+template<typename T, typename U> inline bool compareEqual(const T& t, const U& u) { return t == static_cast<const T&>(u); }
#define SET_VAR(group, variable, value) \
if (!compareEqual(group->variable, value)) \
group.access()->variable = value
+#define SET_NESTED_VAR(group, parentVariable, variable, value) \
+ if (!compareEqual(group->parentVariable->variable, value)) \
+ group.access()->parentVariable.access()->variable = value
+
#define SET_BORDERVALUE_COLOR(group, variable, value) \
if (!compareEqual(group->variable.color(), value)) \
group.access()->variable.setColor(value)
namespace WebCore {
-#if ENABLE(CSS_FILTERS)
-class FilterOperations;
-#endif
-
class BorderData;
+class ContentData;
class CounterContent;
class CursorList;
-class Font;
+class FilterOperations;
+class FontCascade;
class FontMetrics;
class IntRect;
class Pair;
@@ -120,20 +119,273 @@ class StyleInheritedData;
class StyleResolver;
class TransformationMatrix;
-class ContentData;
+struct ScrollSnapPoints;
typedef Vector<RefPtr<RenderStyle>, 4> PseudoStyleCache;
class RenderStyle: public RefCounted<RenderStyle> {
friend class CSSPropertyAnimationWrapperMap; // Used by CSS animations. We can't allow them to animate based off visited colors.
friend class ApplyStyleCommand; // Editing has to only reveal unvisited info.
- friend class DeprecatedStyleBuilder; // Sets members directly.
friend class EditingStyle; // Editing has to only reveal unvisited info.
friend class ComputedStyleExtractor; // Ignores visited styles, so needs to be able to see unvisited info.
friend class PropertyWrapperMaybeInvalidColor; // Used by CSS animations. We can't allow them to animate based off visited colors.
friend class RenderSVGResource; // FIXME: Needs to alter the visited state by hand. Should clean the SVG code up and move it into RenderStyle perhaps.
friend class RenderTreeAsText; // FIXME: Only needed so the render tree can keep lying and dump the wrong colors. Rebaselining would allow this to be yanked.
+ friend class StyleBuilderConverter; // Sets members directly.
+ friend class StyleBuilderCustom; // Sets members directly.
+ friend class StyleBuilderFunctions; // Sets members directly.
friend class StyleResolver; // Sets members directly.
+
+public:
+ struct NonInheritedFlags {
+ NonInheritedFlags()
+ {
+ // The default values should all be zero.
+ ASSERT(!initialOverflowX());
+ ASSERT(!initialOverflowY());
+ ASSERT(!initialClear());
+ ASSERT(!initialDisplay());
+ ASSERT(!initialUnicodeBidi());
+ ASSERT(!initialPosition());
+ ASSERT(!initialVerticalAlign());
+ ASSERT(!initialFloating());
+ ASSERT(!initialTableLayout());
+
+ m_flags = 0;
+ }
+
+ bool operator==(const NonInheritedFlags& other) const
+ {
+ return m_flags == other.m_flags;
+ }
+
+ bool operator!=(const NonInheritedFlags& other) const { return !(*this == other); }
+
+ void copyNonInheritedFrom(const NonInheritedFlags& other)
+ {
+ // Only a subset is copied because NonInheritedFlags contains a bunch of stuff other than real style data.
+ uint64_t nonInheritedMask = overflowMask << overflowXOffset
+ | overflowMask << overflowYOffset
+ | clearMask << clearOffset
+ | displayMask << effectiveDisplayOffset
+ | positionMask << positionOffset
+ | displayMask << originalDisplayOffset
+ | unicodeBidiMask << unicodeBidiOffset
+ | verticalAlignMask << verticalAlignOffset
+ | floatingMask << floatingOffset
+ | oneBitMask << explicitInheritanceOffset
+ | tableLayoutBitMask << tableLayoutOffset
+ | hasViewportUnitsBitMask << hasViewportUnitsOffset;
+
+ m_flags = (m_flags & ~nonInheritedMask) | (other.m_flags & nonInheritedMask);
+ }
+
+ EOverflow overflowX() const { return static_cast<EOverflow>(getValue(overflowMask, overflowXOffset)); }
+ void setOverflowX(EOverflow overflowX) { updateValue(overflowX, overflowMask, overflowXOffset); }
+
+ EOverflow overflowY() const { return static_cast<EOverflow>(getValue(overflowMask, overflowYOffset)); }
+ void setOverflowY(EOverflow overflowY) { updateValue(overflowY, overflowMask, overflowYOffset); }
+
+ EClear clear() const { return static_cast<EClear>(getValue(clearMask, clearOffset)); }
+ void setClear(EClear clear) { updateValue(clear, clearMask, clearOffset); }
+
+ EDisplay effectiveDisplay() const { return static_cast<EDisplay>(getValue(displayMask, effectiveDisplayOffset)); }
+ void setEffectiveDisplay(EDisplay effectiveDisplay) { updateValue(effectiveDisplay, displayMask, effectiveDisplayOffset); }
+
+ EPosition position() const { return static_cast<EPosition>(getValue(positionMask, positionOffset)); }
+ void setPosition(EPosition position) { updateValue(position, positionMask, positionOffset); }
+
+ EDisplay originalDisplay() const { return static_cast<EDisplay>(getValue(displayMask, originalDisplayOffset)); }
+ void setOriginalDisplay(EDisplay originalDisplay) { updateValue(originalDisplay, displayMask, originalDisplayOffset); }
+
+ EUnicodeBidi unicodeBidi() const { return static_cast<EUnicodeBidi>(getValue(unicodeBidiMask, unicodeBidiOffset)); }
+ void setUnicodeBidi(EUnicodeBidi unicodeBidi) { updateValue(unicodeBidi, unicodeBidiMask, unicodeBidiOffset); }
+
+ bool hasViewportUnits() const { return getBoolean(hasViewportUnitsOffset); }
+ void setHasViewportUnits(bool value) { updateBoolean(value, hasViewportUnitsOffset); }
+
+ EVerticalAlign verticalAlign() const { return static_cast<EVerticalAlign>(getValue(verticalAlignMask, verticalAlignOffset)); }
+ void setVerticalAlign(EVerticalAlign verticalAlign) { updateValue(verticalAlign, verticalAlignMask, verticalAlignOffset); }
+
+ bool hasExplicitlyInheritedProperties() const { return getBoolean(explicitInheritanceOffset); }
+ void setHasExplicitlyInheritedProperties(bool value) { updateBoolean(value, explicitInheritanceOffset); }
+
+ bool isFloating() const { return floating() != NoFloat; }
+ EFloat floating() const { return static_cast<EFloat>(getValue(floatingMask, floatingOffset)); }
+ void setFloating(EFloat floating) { updateValue(floating, floatingMask, floatingOffset); }
+
+ bool hasAnyPublicPseudoStyles() const { return PUBLIC_PSEUDOID_MASK & getValue(pseudoBitsMask, pseudoBitsOffset); }
+ bool hasPseudoStyle(PseudoId pseudo) const
+ {
+ ASSERT(pseudo > NOPSEUDO);
+ ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID);
+ return (oneBitMask << (pseudoBitsOffset - 1 + pseudo)) & m_flags;
+ }
+ void setHasPseudoStyle(PseudoId pseudo)
+ {
+ ASSERT(pseudo > NOPSEUDO);
+ ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID);
+ m_flags |= oneBitMask << (pseudoBitsOffset - 1 + pseudo);
+ }
+ void setHasPseudoStyles(PseudoIdSet pseudoIdSet)
+ {
+ ASSERT(pseudoIdSet);
+ uint64_t rawPseudoIdSet = pseudoIdSet.data();
+ ASSERT((rawPseudoIdSet & PUBLIC_PSEUDOID_MASK) == rawPseudoIdSet);
+ static_assert(pseudoBitsOffset >= 1, "(pseudoBitsOffset - 1) should be valid.");
+ m_flags |= (static_cast<uint64_t>(rawPseudoIdSet) << (pseudoBitsOffset - 1));
+ }
+
+ ETableLayout tableLayout() const { return static_cast<ETableLayout>(getValue(tableLayoutBitMask, tableLayoutOffset)); }
+ void setTableLayout(ETableLayout tableLayout) { updateValue(tableLayout, tableLayoutBitMask, tableLayoutOffset); }
+
+ PseudoId styleType() const { return static_cast<PseudoId>(getValue(styleTypeMask, styleTypeOffset)); }
+ void setStyleType(PseudoId styleType) { updateValue(styleType, styleTypeMask, styleTypeOffset); }
+
+ bool isUnique() const { return getBoolean(isUniqueOffset); }
+ void setIsUnique() { updateBoolean(true, isUniqueOffset); }
+
+ bool emptyState() const { return getBoolean(emptyStateOffset); }
+ void setEmptyState(bool value) { updateBoolean(value, emptyStateOffset); }
+
+ bool firstChildState() const { return getBoolean(firstChildStateOffset); }
+ void setFirstChildState(bool value) { updateBoolean(value, firstChildStateOffset); }
+
+ bool lastChildState() const { return getBoolean(lastChildStateOffset); }
+ void setLastChildState(bool value) { updateBoolean(value, lastChildStateOffset); }
+
+ bool affectedByHover() const { return getBoolean(affectedByHoverOffset); }
+ void setAffectedByHover(bool value) { updateBoolean(value, affectedByHoverOffset); }
+
+ bool affectedByActive() const { return getBoolean(affectedByActiveOffset); }
+ void setAffectedByActive(bool value) { updateBoolean(value, affectedByActiveOffset); }
+
+ bool affectedByDrag() const { return getBoolean(affectedByDragOffset); }
+ void setAffectedByDrag(bool value) { updateBoolean(value, affectedByDragOffset); }
+
+ bool isLink() const { return getBoolean(isLinkOffset); }
+ void setIsLink(bool value) { updateBoolean(value, isLinkOffset); }
+
+ bool hasExplicitlySetDirection() const { return getBoolean(hasExplicitlySetDirectionOffset); }
+ void setHasExplicitlySetDirection(bool value) { updateBoolean(value, hasExplicitlySetDirectionOffset); }
+
+ bool hasExplicitlySetWritingMode() const { return getBoolean(hasExplicitlySetWritingModeOffset); }
+ void setHasExplicitlySetWritingMode(bool value) { updateBoolean(value, hasExplicitlySetWritingModeOffset); }
+
+ static ptrdiff_t flagsMemoryOffset() { return OBJECT_OFFSETOF(NonInheritedFlags, m_flags); }
+ static uint64_t flagIsaffectedByActive() { return oneBitMask << affectedByActiveOffset; }
+ static uint64_t flagIsaffectedByHover() { return oneBitMask << affectedByHoverOffset; }
+ static uint64_t flagPseudoStyle(PseudoId pseudo) { return oneBitMask << (pseudoBitsOffset - 1 + pseudo); }
+ static uint64_t setFirstChildStateFlags() { return flagFirstChildState() | flagIsUnique(); }
+ static uint64_t setLastChildStateFlags() { return flagLastChildState() | flagIsUnique(); }
+ private:
+ void updateBoolean(bool isSet, uint64_t offset)
+ {
+ if (isSet)
+ m_flags |= (oneBitMask << offset);
+ else
+ m_flags &= ~(oneBitMask << offset);
+ }
+
+ bool getBoolean(uint64_t offset) const
+ {
+ return m_flags & (oneBitMask << offset);
+ }
+
+ void updateValue(uint8_t newValue, uint64_t positionIndependentMask, uint64_t offset)
+ {
+ ASSERT(!(newValue & ~positionIndependentMask));
+ uint64_t positionDependentMask = positionIndependentMask << offset;
+ m_flags = (m_flags & ~positionDependentMask) | (static_cast<uint64_t>(newValue) << offset);
+ }
+
+ unsigned getValue(uint64_t positionIndependentMask, uint64_t offset) const
+ {
+ return static_cast<unsigned>((m_flags >> offset) & positionIndependentMask);
+ }
+
+ static uint64_t flagIsUnique() { return oneBitMask << isUniqueOffset; }
+ static uint64_t flagFirstChildState() { return oneBitMask << firstChildStateOffset; }
+ static uint64_t flagLastChildState() { return oneBitMask << lastChildStateOffset; }
+
+ // To type the bit mask properly on 64bits.
+ static const uint64_t oneBitMask = 0x1;
+
+ // Byte 1.
+ static const unsigned overflowBitCount = 3;
+ static const uint64_t overflowMask = (oneBitMask << overflowBitCount) - 1;
+ static const unsigned overflowXOffset = 0;
+ static const unsigned overflowYOffset = overflowXOffset + overflowBitCount;
+ static const unsigned clearBitCount = 2;
+ static const uint64_t clearMask = (oneBitMask << clearBitCount) - 1;
+ static const unsigned clearOffset = overflowYOffset + overflowBitCount;
+
+ // Byte 2.
+ static const unsigned displayBitCount = 5;
+ static const uint64_t displayMask = (oneBitMask << displayBitCount) - 1;
+ static const unsigned effectiveDisplayOffset = clearOffset + clearBitCount;
+ static const unsigned positionBitCount = 3;
+ static const uint64_t positionMask = (oneBitMask << positionBitCount) - 1;
+ static const unsigned positionOffset = effectiveDisplayOffset + displayBitCount;
+
+ // Byte 3.
+ static const unsigned originalDisplayOffset = positionOffset + positionBitCount;
+ static const unsigned unicodeBidiBitCount = 3;
+ static const uint64_t unicodeBidiMask = (oneBitMask << unicodeBidiBitCount) - 1;
+ static const unsigned unicodeBidiOffset = originalDisplayOffset + displayBitCount;
+
+ // Byte 4.
+ static const unsigned floatingBitCount = 2;
+ static const uint64_t floatingMask = (oneBitMask << floatingBitCount) - 1;
+ static const unsigned floatingOffset = unicodeBidiOffset + unicodeBidiBitCount;
+ static const unsigned hasExplicitlySetDirectionBitcount = 1;
+ static const unsigned hasExplicitlySetDirectionOffset = floatingOffset + floatingBitCount;
+ static const unsigned hasExplicitlySetWritingModeBitcount = 1;
+ static const unsigned hasExplicitlySetWritingModeOffset = hasExplicitlySetDirectionOffset + hasExplicitlySetDirectionBitcount;
+
+ // Byte 5.
+ static const unsigned explicitInheritanceBitCount = 1;
+ static const unsigned explicitInheritanceOffset = hasExplicitlySetWritingModeOffset + hasExplicitlySetWritingModeBitcount;
+ static const unsigned tableLayoutBitCount = 1;
+ static const uint64_t tableLayoutBitMask = oneBitMask;
+ static const unsigned tableLayoutOffset = explicitInheritanceOffset + explicitInheritanceBitCount;
+ static const unsigned verticalAlignBitCount = 4;
+ static const unsigned verticalAlignPadding = 2;
+ static const unsigned verticalAlignAndPaddingBitCount = verticalAlignBitCount + verticalAlignPadding;
+ static const uint64_t verticalAlignMask = (oneBitMask << verticalAlignBitCount) - 1;
+ static const unsigned verticalAlignOffset = tableLayoutOffset + tableLayoutBitCount;
+
+ // Byte 6.
+ static const unsigned pseudoBitsBitCount = 7;
+ static const uint64_t pseudoBitsMask = (oneBitMask << pseudoBitsBitCount) - 1;
+ static const unsigned pseudoBitsOffset = verticalAlignOffset + verticalAlignBitCount;
+
+ static const unsigned hasViewportUnitsBitCount = 1;
+ static const uint64_t hasViewportUnitsBitMask = (oneBitMask << hasViewportUnitsBitCount) - 1;
+ static const unsigned hasViewportUnitsOffset = pseudoBitsOffset + pseudoBitsBitCount;
+
+ // Byte 7.
+ static const unsigned styleTypeBitCount = 6;
+ static const unsigned styleTypePadding = 2;
+ static const unsigned styleTypeAndPaddingBitCount = styleTypeBitCount + styleTypePadding;
+ static const uint64_t styleTypeMask = (oneBitMask << styleTypeAndPaddingBitCount) - 1;
+ static const unsigned styleTypeOffset = hasViewportUnitsBitCount + hasViewportUnitsOffset;
+
+ // Byte 8.
+ static const unsigned isUniqueOffset = styleTypeOffset + styleTypeAndPaddingBitCount;
+ static const unsigned emptyStateOffset = isUniqueOffset + 1;
+ static const unsigned firstChildStateOffset = emptyStateOffset + 1;
+ static const unsigned lastChildStateOffset = firstChildStateOffset + 1;
+ static const unsigned affectedByHoverOffset = lastChildStateOffset + 1;
+ static const unsigned affectedByActiveOffset = affectedByHoverOffset + 1;
+ static const unsigned affectedByDragOffset = affectedByActiveOffset + 1;
+ static const unsigned isLinkOffset = affectedByDragOffset + 1;
+
+ // 60 bits are assigned. There are 4 bits available currently used as padding to improve code generation.
+ // If you add more style bits here, you will also need to update RenderStyle::copyNonInheritedFrom().
+ uint64_t m_flags;
+ };
+
protected:
// non-inherited attributes
@@ -148,11 +400,9 @@ protected:
DataRef<StyleInheritedData> inherited;
// list of associated pseudo styles
- OwnPtr<PseudoStyleCache> m_cachedPseudoStyles;
+ std::unique_ptr<PseudoStyleCache> m_cachedPseudoStyles;
-#if ENABLE(SVG)
DataRef<SVGRenderStyle> m_svgStyle;
-#endif
// !START SYNC!: Keep this in sync with the copy constructor in RenderStyle.cpp and implicitlyInherited() in StyleResolver.cpp
@@ -180,6 +430,7 @@ protected:
&& (m_printColorAdjust == other.m_printColorAdjust)
&& (_pointerEvents == other._pointerEvents)
&& (_insideLink == other._insideLink)
+ && (_insideDefaultButton == other._insideDefaultButton)
&& (m_writingMode == other.m_writingMode);
}
@@ -208,152 +459,40 @@ protected:
unsigned m_printColorAdjust : PrintColorAdjustBits;
unsigned _pointerEvents : 4; // EPointerEvents
unsigned _insideLink : 2; // EInsideLink
- // 43 bits
+ unsigned _insideDefaultButton : 1;
+ // 44 bits
// CSS Text Layout Module Level 3: Vertical writing support
unsigned m_writingMode : 2; // WritingMode
- // 45 bits
+ // 46 bits
} inherited_flags;
// don't inherit
- struct NonInheritedFlags {
- bool operator==(const NonInheritedFlags& other) const
- {
- return _effectiveDisplay == other._effectiveDisplay
- && _originalDisplay == other._originalDisplay
- && _overflowX == other._overflowX
- && _overflowY == other._overflowY
- && _vertical_align == other._vertical_align
- && _clear == other._clear
- && _position == other._position
- && _floating == other._floating
- && _table_layout == other._table_layout
- && _page_break_before == other._page_break_before
- && _page_break_after == other._page_break_after
- && _page_break_inside == other._page_break_inside
- && _styleType == other._styleType
- && _affectedByHover == other._affectedByHover
- && _affectedByActive == other._affectedByActive
- && _affectedByDrag == other._affectedByDrag
- && _pseudoBits == other._pseudoBits
- && _unicodeBidi == other._unicodeBidi
- && explicitInheritance == other.explicitInheritance
- && unique == other.unique
- && emptyState == other.emptyState
- && firstChildState == other.firstChildState
- && lastChildState == other.lastChildState
- && _isLink == other._isLink;
- }
-
- bool operator!=(const NonInheritedFlags& other) const { return !(*this == other); }
-
- unsigned _effectiveDisplay : 5; // EDisplay
- unsigned _originalDisplay : 5; // EDisplay
- unsigned _overflowX : 3; // EOverflow
- unsigned _overflowY : 3; // EOverflow
- unsigned _vertical_align : 4; // EVerticalAlign
- unsigned _clear : 2; // EClear
- unsigned _position : 3; // EPosition
- unsigned _floating : 2; // EFloat
- unsigned _table_layout : 1; // ETableLayout
-
- unsigned _unicodeBidi : 3; // EUnicodeBidi
- // 31 bits
- unsigned _page_break_before : 2; // EPageBreak
- unsigned _page_break_after : 2; // EPageBreak
- unsigned _page_break_inside : 2; // EPageBreak
-
- unsigned _styleType : 6; // PseudoId
- unsigned _pseudoBits : 7;
- unsigned explicitInheritance : 1; // Explicitly inherits a non-inherited property
- unsigned unique : 1; // Style can not be shared.
- unsigned emptyState : 1;
- unsigned firstChildState : 1;
- unsigned lastChildState : 1;
-
- bool affectedByHover() const { return _affectedByHover; }
- void setAffectedByHover(bool value) { _affectedByHover = value; }
- bool affectedByActive() const { return _affectedByActive; }
- void setAffectedByActive(bool value) { _affectedByActive = value; }
- bool affectedByDrag() const { return _affectedByDrag; }
- void setAffectedByDrag(bool value) { _affectedByDrag = value; }
- bool isLink() const { return _isLink; }
- void setIsLink(bool value) { _isLink = value; }
- private:
- unsigned _affectedByHover : 1;
- unsigned _affectedByActive : 1;
- unsigned _affectedByDrag : 1;
- unsigned _isLink : 1;
- // If you add more style bits here, you will also need to update RenderStyle::copyNonInheritedFrom()
- // 59 bits
- } noninherited_flags;
+ NonInheritedFlags noninherited_flags;
// !END SYNC!
-
-protected:
- void setBitDefaults()
- {
- inherited_flags._empty_cells = initialEmptyCells();
- inherited_flags._caption_side = initialCaptionSide();
- inherited_flags._list_style_type = initialListStyleType();
- inherited_flags._list_style_position = initialListStylePosition();
- inherited_flags._visibility = initialVisibility();
- inherited_flags._text_align = initialTextAlign();
- inherited_flags._text_transform = initialTextTransform();
- inherited_flags._text_decorations = initialTextDecoration();
- inherited_flags._cursor_style = initialCursor();
-#if ENABLE(CURSOR_VISIBILITY)
- inherited_flags.m_cursorVisibility = initialCursorVisibility();
-#endif
- inherited_flags._direction = initialDirection();
- inherited_flags._white_space = initialWhiteSpace();
- inherited_flags._border_collapse = initialBorderCollapse();
- inherited_flags.m_rtlOrdering = initialRTLOrdering();
- inherited_flags._box_direction = initialBoxDirection();
- inherited_flags.m_printColorAdjust = initialPrintColorAdjust();
- inherited_flags._pointerEvents = initialPointerEvents();
- inherited_flags._insideLink = NotInsideLink;
- inherited_flags.m_writingMode = initialWritingMode();
-
- noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay();
- noninherited_flags._overflowX = initialOverflowX();
- noninherited_flags._overflowY = initialOverflowY();
- noninherited_flags._vertical_align = initialVerticalAlign();
- noninherited_flags._clear = initialClear();
- noninherited_flags._position = initialPosition();
- noninherited_flags._floating = initialFloating();
- noninherited_flags._table_layout = initialTableLayout();
- noninherited_flags._unicodeBidi = initialUnicodeBidi();
- noninherited_flags._page_break_before = initialPageBreak();
- noninherited_flags._page_break_after = initialPageBreak();
- noninherited_flags._page_break_inside = initialPageBreak();
- noninherited_flags._styleType = NOPSEUDO;
- noninherited_flags._pseudoBits = 0;
- noninherited_flags.explicitInheritance = false;
- noninherited_flags.unique = false;
- noninherited_flags.emptyState = false;
- noninherited_flags.firstChildState = false;
- noninherited_flags.lastChildState = false;
- noninherited_flags.setAffectedByHover(false);
- noninherited_flags.setAffectedByActive(false);
- noninherited_flags.setAffectedByDrag(false);
- noninherited_flags.setIsLink(false);
- }
-
private:
- ALWAYS_INLINE RenderStyle();
// used to create the default style.
ALWAYS_INLINE RenderStyle(bool);
ALWAYS_INLINE RenderStyle(const RenderStyle&);
public:
- static PassRef<RenderStyle> create();
- static PassRef<RenderStyle> createDefaultStyle();
- static PassRef<RenderStyle> createAnonymousStyleWithDisplay(const RenderStyle* parentStyle, EDisplay);
- static PassRef<RenderStyle> clone(const RenderStyle*);
+ static Ref<RenderStyle> create();
+ static Ref<RenderStyle> createDefaultStyle();
+ static Ref<RenderStyle> createAnonymousStyleWithDisplay(const RenderStyle* parentStyle, EDisplay);
+ static Ref<RenderStyle> clone(const RenderStyle*);
// Create a RenderStyle for generated content by inheriting from a pseudo style.
- static PassRef<RenderStyle> createStyleInheritingFromPseudoStyle(const RenderStyle& pseudoStyle);
+ static Ref<RenderStyle> createStyleInheritingFromPseudoStyle(const RenderStyle& pseudoStyle);
+
+ ContentPosition resolvedAlignContentPosition() const;
+ ContentDistributionType resolvedAlignContentDistribution() const;
+ ContentPosition resolvedJustifyContentPosition() const;
+ ContentDistributionType resolvedJustifyContentDistribution() const;
+ static ItemPosition resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer);
+ static OverflowAlignment resolveAlignmentOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle);
+ static ItemPosition resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer);
+ static OverflowAlignment resolveJustificationOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle);
enum IsAtShadowBoundary {
AtShadowBoundary,
@@ -363,8 +502,8 @@ public:
void inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary = NotAtShadowBoundary);
void copyNonInheritedFrom(const RenderStyle*);
- PseudoId styleType() const { return static_cast<PseudoId>(noninherited_flags._styleType); }
- void setStyleType(PseudoId styleType) { noninherited_flags._styleType = styleType; }
+ PseudoId styleType() const { return noninherited_flags.styleType(); }
+ void setStyleType(PseudoId styleType) { noninherited_flags.setStyleType(styleType); }
RenderStyle* getCachedPseudoStyle(PseudoId) const;
RenderStyle* addCachedPseudoStyle(PassRefPtr<RenderStyle>);
@@ -372,6 +511,14 @@ public:
const PseudoStyleCache* cachedPseudoStyles() const { return m_cachedPseudoStyles.get(); }
+ void setCustomPropertyValue(const AtomicString& name, const RefPtr<CSSValue>& value) { rareInheritedData.access()->m_customProperties.access()->setCustomPropertyValue(name, value); }
+ RefPtr<CSSValue> getCustomPropertyValue(const AtomicString& name) const { return rareInheritedData->m_customProperties->getCustomPropertyValue(name); }
+ bool hasCustomProperty(const AtomicString& name) const { return rareInheritedData->m_customProperties->hasCustomProperty(name); }
+ const CustomPropertyValueMap& customProperties() const { return rareInheritedData->m_customProperties->m_values; }
+
+ void setHasViewportUnits(bool hasViewportUnits = true) { noninherited_flags.setHasViewportUnits(hasViewportUnits); }
+ bool hasViewportUnits() const { return noninherited_flags.hasViewportUnits(); }
+
bool affectedByHover() const { return noninherited_flags.affectedByHover(); }
bool affectedByActive() const { return noninherited_flags.affectedByActive(); }
bool affectedByDrag() const { return noninherited_flags.affectedByDrag(); }
@@ -384,13 +531,15 @@ public:
bool operator==(const RenderStyle& other) const;
bool operator!=(const RenderStyle& other) const { return !(*this == other); }
- bool isFloating() const { return noninherited_flags._floating != NoFloat; }
- bool hasMargin() const { return surround->margin.nonZero(); }
+ bool isFloating() const { return noninherited_flags.isFloating(); }
+ bool hasMargin() const { return !surround->margin.isZero(); }
bool hasBorder() const { return surround->border.hasBorder(); }
- bool hasPadding() const { return surround->padding.nonZero(); }
- bool hasOffset() const { return surround->offset.nonZero(); }
- bool hasMarginBeforeQuirk() const { return marginBefore().quirk(); }
- bool hasMarginAfterQuirk() const { return marginAfter().quirk(); }
+ bool hasBorderFill() const { return surround->border.hasFill(); }
+ bool hasBorderDecoration() const { return hasBorder() || hasBorderFill(); }
+ bool hasPadding() const { return !surround->padding.isZero(); }
+ bool hasOffset() const { return !surround->offset.isZero(); }
+ bool hasMarginBeforeQuirk() const { return marginBefore().hasQuirk(); }
+ bool hasMarginAfterQuirk() const { return marginAfter().hasQuirk(); }
bool hasBackgroundImage() const { return m_background->background().hasImage(); }
bool hasFixedBackgroundImage() const { return m_background->background().hasFixedImage(); }
@@ -410,7 +559,7 @@ public:
LayoutBoxExtent imageOutsets(const NinePieceImage&) const;
bool hasBorderImageOutsets() const
{
- return borderImage().hasImage() && borderImage().outset().nonZero();
+ return borderImage().hasImage() && !borderImage().outset().isZero();
}
LayoutBoxExtent borderImageOutsets() const
{
@@ -422,10 +571,8 @@ public:
return imageOutsets(maskBoxImage());
}
-#if ENABLE(CSS_FILTERS)
bool hasFilterOutsets() const { return hasFilter() && filter().hasOutsets(); }
FilterOutsets filterOutsets() const { return hasFilter() ? filter().outsets() : FilterOutsets(); }
-#endif
Order rtlOrdering() const { return static_cast<Order>(inherited_flags.m_rtlOrdering); }
void setRTLOrdering(Order o) { inherited_flags.m_rtlOrdering = o; }
@@ -435,12 +582,13 @@ public:
bool hasAnyPublicPseudoStyles() const;
bool hasPseudoStyle(PseudoId pseudo) const;
void setHasPseudoStyle(PseudoId pseudo);
+ void setHasPseudoStyles(PseudoIdSet);
bool hasUniquePseudoStyle() const;
// attribute getter methods
- EDisplay display() const { return static_cast<EDisplay>(noninherited_flags._effectiveDisplay); }
- EDisplay originalDisplay() const { return static_cast<EDisplay>(noninherited_flags._originalDisplay); }
+ EDisplay display() const { return noninherited_flags.effectiveDisplay(); }
+ EDisplay originalDisplay() const { return noninherited_flags.originalDisplay(); }
const Length& left() const { return surround->offset.left(); }
const Length& right() const { return surround->offset.right(); }
@@ -448,8 +596,8 @@ public:
const Length& bottom() const { return surround->offset.bottom(); }
// Accessors for positioned object edges that take into account writing mode.
- const Length& logicalLeft() const { return surround->offset.logicalLeft(writingMode()); }
- const Length& logicalRight() const { return surround->offset.logicalRight(writingMode()); }
+ const Length& logicalLeft() const { return surround->offset.start(writingMode()); }
+ const Length& logicalRight() const { return surround->offset.end(writingMode()); }
const Length& logicalTop() const { return surround->offset.before(writingMode()); }
const Length& logicalBottom() const { return surround->offset.after(writingMode()); }
@@ -460,11 +608,11 @@ public:
bool hasStaticInlinePosition(bool horizontal) const { return horizontal ? hasAutoLeftAndRight() : hasAutoTopAndBottom(); }
bool hasStaticBlockPosition(bool horizontal) const { return horizontal ? hasAutoTopAndBottom() : hasAutoLeftAndRight(); }
- EPosition position() const { return static_cast<EPosition>(noninherited_flags._position); }
+ EPosition position() const { return noninherited_flags.position(); }
bool hasOutOfFlowPosition() const { return position() == AbsolutePosition || position() == FixedPosition; }
bool hasInFlowPosition() const { return position() == RelativePosition || position() == StickyPosition; }
bool hasViewportConstrainedPosition() const { return position() == FixedPosition || position() == StickyPosition; }
- EFloat floating() const { return static_cast<EFloat>(noninherited_flags._floating); }
+ EFloat floating() const { return noninherited_flags.floating(); }
const Length& width() const { return m_box->width(); }
const Length& height() const { return m_box->height(); }
@@ -503,40 +651,37 @@ public:
const LengthSize& borderBottomRightRadius() const { return surround->border.bottomRight(); }
bool hasBorderRadius() const { return surround->border.hasBorderRadius(); }
- unsigned borderLeftWidth() const { return surround->border.borderLeftWidth(); }
+ float borderLeftWidth() const { return surround->border.borderLeftWidth(); }
EBorderStyle borderLeftStyle() const { return surround->border.left().style(); }
bool borderLeftIsTransparent() const { return surround->border.left().isTransparent(); }
- unsigned borderRightWidth() const { return surround->border.borderRightWidth(); }
+ float borderRightWidth() const { return surround->border.borderRightWidth(); }
EBorderStyle borderRightStyle() const { return surround->border.right().style(); }
bool borderRightIsTransparent() const { return surround->border.right().isTransparent(); }
- unsigned borderTopWidth() const { return surround->border.borderTopWidth(); }
+ float borderTopWidth() const { return surround->border.borderTopWidth(); }
EBorderStyle borderTopStyle() const { return surround->border.top().style(); }
bool borderTopIsTransparent() const { return surround->border.top().isTransparent(); }
- unsigned borderBottomWidth() const { return surround->border.borderBottomWidth(); }
+ float borderBottomWidth() const { return surround->border.borderBottomWidth(); }
EBorderStyle borderBottomStyle() const { return surround->border.bottom().style(); }
bool borderBottomIsTransparent() const { return surround->border.bottom().isTransparent(); }
-
- unsigned short borderBeforeWidth() const;
- unsigned short borderAfterWidth() const;
- unsigned short borderStartWidth() const;
- unsigned short borderEndWidth() const;
+ FloatBoxExtent borderWidth() const { return surround->border.borderWidth(); }
- unsigned short outlineSize() const { return std::max(0, outlineWidth() + outlineOffset()); }
- unsigned short outlineWidth() const
- {
- if (m_background->outline().style() == BNONE)
- return 0;
- return m_background->outline().width();
- }
- bool hasOutline() const { return outlineWidth() > 0 && outlineStyle() > BHIDDEN; }
+ float borderBeforeWidth() const;
+ float borderAfterWidth() const;
+ float borderStartWidth() const;
+ float borderEndWidth() const;
+
+ float outlineSize() const { return std::max<float>(0, outlineWidth() + outlineOffset()); }
+ float outlineWidth() const;
+ bool hasOutline() const { return outlineStyle() > BHIDDEN && outlineWidth() > 0; }
EBorderStyle outlineStyle() const { return m_background->outline().style(); }
OutlineIsAuto outlineStyleIsAuto() const { return static_cast<OutlineIsAuto>(m_background->outline().isAuto()); }
+ bool hasOutlineInVisualOverflow() const { return hasOutline() && outlineSize() > 0; }
- EOverflow overflowX() const { return static_cast<EOverflow>(noninherited_flags._overflowX); }
- EOverflow overflowY() const { return static_cast<EOverflow>(noninherited_flags._overflowY); }
+ EOverflow overflowX() const { return noninherited_flags.overflowX(); }
+ EOverflow overflowY() const { return noninherited_flags.overflowY(); }
EVisibility visibility() const { return static_cast<EVisibility>(inherited_flags._visibility); }
- EVerticalAlign verticalAlign() const { return static_cast<EVerticalAlign>(noninherited_flags._vertical_align); }
+ EVerticalAlign verticalAlign() const { return noninherited_flags.verticalAlign(); }
const Length& verticalAlignLength() const { return m_box->verticalAlign(); }
const Length& clipLeft() const { return visual->clip.left(); }
@@ -546,18 +691,18 @@ public:
const LengthBox& clip() const { return visual->clip; }
bool hasClip() const { return visual->hasClip; }
- EUnicodeBidi unicodeBidi() const { return static_cast<EUnicodeBidi>(noninherited_flags._unicodeBidi); }
+ EUnicodeBidi unicodeBidi() const { return noninherited_flags.unicodeBidi(); }
- EClear clear() const { return static_cast<EClear>(noninherited_flags._clear); }
- ETableLayout tableLayout() const { return static_cast<ETableLayout>(noninherited_flags._table_layout); }
+ EClear clear() const { return noninherited_flags.clear(); }
+ ETableLayout tableLayout() const { return noninherited_flags.tableLayout(); }
- const Font& font() const;
- const FontMetrics& fontMetrics() const;
- const FontDescription& fontDescription() const;
+ WEBCORE_EXPORT const FontCascade& fontCascade() const;
+ WEBCORE_EXPORT const FontMetrics& fontMetrics() const;
+ WEBCORE_EXPORT const FontCascadeDescription& fontDescription() const;
float specifiedFontSize() const;
float computedFontSize() const;
int fontSize() const;
- void getFontAndGlyphOrientation(FontOrientation&, NonCJKGlyphOrientation&);
+ std::pair<FontOrientation, NonCJKGlyphOrientation> fontAndGlyphOrientation();
#if ENABLE(TEXT_AUTOSIZING)
float textAutosizingMultiplier() const { return visual->m_textAutosizingMultiplier; }
@@ -585,13 +730,16 @@ public:
float zoom() const { return visual->m_zoom; }
float effectiveZoom() const { return rareInheritedData->m_effectiveZoom; }
+
+ TextZoom textZoom() const { return static_cast<TextZoom>(rareInheritedData->m_textZoom); }
TextDirection direction() const { return static_cast<TextDirection>(inherited_flags._direction); }
bool isLeftToRightDirection() const { return direction() == LTR; }
+ bool hasExplicitlySetDirection() const { return noninherited_flags.hasExplicitlySetDirection(); }
const Length& specifiedLineHeight() const;
Length lineHeight() const;
- int computedLineHeight(RenderView* = 0) const;
+ int computedLineHeight() const;
EWhiteSpace whiteSpace() const { return static_cast<EWhiteSpace>(inherited_flags._white_space); }
static bool autoWrap(EWhiteSpace ws)
@@ -659,7 +807,7 @@ public:
const Length& backgroundYPosition() const { return m_background->background().yPosition(); }
EFillSizeType backgroundSizeType() const { return m_background->background().sizeType(); }
const LengthSize& backgroundSizeLength() const { return m_background->background().sizeLength(); }
- FillLayer* accessBackgroundLayers() { return &(m_background.access()->m_background); }
+ FillLayer& ensureBackgroundLayers() { return m_background.access()->m_background; }
const FillLayer* backgroundLayers() const { return &(m_background->background()); }
StyleImage* maskImage() const { return rareNonInheritedData->m_mask.image(); }
@@ -672,7 +820,7 @@ public:
const Length& maskYPosition() const { return rareNonInheritedData->m_mask.yPosition(); }
EFillSizeType maskSizeType() const { return rareNonInheritedData->m_mask.sizeType(); }
const LengthSize& maskSizeLength() const { return rareNonInheritedData->m_mask.sizeLength(); }
- FillLayer* accessMaskLayers() { return &(rareNonInheritedData.access()->m_mask); }
+ FillLayer& ensureMaskLayers() { return rareNonInheritedData.access()->m_mask; }
const FillLayer* maskLayers() const { return &(rareNonInheritedData->m_mask); }
const NinePieceImage& maskBoxImage() const { return rareNonInheritedData->m_maskBoxImage; }
StyleImage* maskBoxImageSource() const { return rareNonInheritedData->m_maskBoxImage.image(); }
@@ -720,23 +868,21 @@ public:
EInsideLink insideLink() const { return static_cast<EInsideLink>(inherited_flags._insideLink); }
bool isLink() const { return noninherited_flags.isLink(); }
+ bool insideDefaultButton() const { return inherited_flags._insideDefaultButton; }
+
short widows() const { return rareInheritedData->widows; }
short orphans() const { return rareInheritedData->orphans; }
bool hasAutoWidows() const { return rareInheritedData->m_hasAutoWidows; }
bool hasAutoOrphans() const { return rareInheritedData->m_hasAutoOrphans; }
- EPageBreak pageBreakInside() const { return static_cast<EPageBreak>(noninherited_flags._page_break_inside); }
- EPageBreak pageBreakBefore() const { return static_cast<EPageBreak>(noninherited_flags._page_break_before); }
- EPageBreak pageBreakAfter() const { return static_cast<EPageBreak>(noninherited_flags._page_break_after); }
// CSS3 Getter Methods
+ BreakInside breakInside() const { return static_cast<BreakInside>(rareNonInheritedData->m_breakInside); }
+ BreakBetween breakBefore() const { return static_cast<BreakBetween>(rareNonInheritedData->m_breakBefore); }
+ BreakBetween breakAfter() const { return static_cast<BreakBetween>(rareNonInheritedData->m_breakAfter); }
+
+ HangingPunctuation hangingPunctuation() const { return static_cast<HangingPunctuation>(rareInheritedData->m_hangingPunctuation); }
- int outlineOffset() const
- {
- if (m_background->outline().style() == BNONE)
- return 0;
- return m_background->outline().offset();
- }
-
+ float outlineOffset() const;
const ShadowData* textShadow() const { return rareInheritedData->textShadow.get(); }
void getTextShadowExtent(LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const { getShadowExtent(textShadow(), top, right, bottom, left); }
void getTextShadowHorizontalExtent(LayoutUnit& left, LayoutUnit& right) const { getShadowHorizontalExtent(textShadow(), left, right); }
@@ -745,11 +891,9 @@ public:
void getTextShadowBlockDirectionExtent(LayoutUnit& logicalTop, LayoutUnit& logicalBottom) const { getShadowBlockDirectionExtent(textShadow(), logicalTop, logicalBottom); }
float textStrokeWidth() const { return rareInheritedData->textStrokeWidth; }
- ColorSpace colorSpace() const { return static_cast<ColorSpace>(rareInheritedData->colorSpace); }
float opacity() const { return rareNonInheritedData->opacity; }
ControlPart appearance() const { return static_cast<ControlPart>(rareNonInheritedData->m_appearance); }
- // aspect ratio convenience method
- bool hasAspectRatio() const { return rareNonInheritedData->m_hasAspectRatio; }
+ AspectRatioType aspectRatioType() const { return static_cast<AspectRatioType>(rareNonInheritedData->m_aspectRatioType); }
float aspectRatio() const { return aspectRatioNumerator() / aspectRatioDenominator(); }
float aspectRatioDenominator() const { return rareNonInheritedData->m_aspectRatioDenominator; }
float aspectRatioNumerator() const { return rareNonInheritedData->m_aspectRatioNumerator; }
@@ -766,30 +910,58 @@ public:
float flexGrow() const { return rareNonInheritedData->m_flexibleBox->m_flexGrow; }
float flexShrink() const { return rareNonInheritedData->m_flexibleBox->m_flexShrink; }
const Length& flexBasis() const { return rareNonInheritedData->m_flexibleBox->m_flexBasis; }
- EAlignContent alignContent() const { return static_cast<EAlignContent>(rareNonInheritedData->m_alignContent); }
- EAlignItems alignItems() const { return static_cast<EAlignItems>(rareNonInheritedData->m_alignItems); }
- EAlignItems alignSelf() const { return static_cast<EAlignItems>(rareNonInheritedData->m_alignSelf); }
+ const StyleContentAlignmentData& alignContent() const { return rareNonInheritedData->m_alignContent; }
+ ContentPosition alignContentPosition() const { return rareNonInheritedData->m_alignContent.position(); }
+ ContentDistributionType alignContentDistribution() const { return rareNonInheritedData->m_alignContent.distribution(); }
+ OverflowAlignment alignContentOverflowAlignment() const { return rareNonInheritedData->m_alignContent.overflow(); }
+ const StyleSelfAlignmentData& alignItems() const { return rareNonInheritedData->m_alignItems; }
+ ItemPosition alignItemsPosition() const { return rareNonInheritedData->m_alignItems.position(); }
+ OverflowAlignment alignItemsOverflowAlignment() const { return rareNonInheritedData->m_alignItems.overflow(); }
+ const StyleSelfAlignmentData& alignSelf() const { return rareNonInheritedData->m_alignSelf; }
+ ItemPosition alignSelfPosition() const { return rareNonInheritedData->m_alignSelf.position(); }
+ OverflowAlignment alignSelfOverflowAlignment() const { return rareNonInheritedData->m_alignSelf.overflow(); }
EFlexDirection flexDirection() const { return static_cast<EFlexDirection>(rareNonInheritedData->m_flexibleBox->m_flexDirection); }
bool isColumnFlexDirection() const { return flexDirection() == FlowColumn || flexDirection() == FlowColumnReverse; }
bool isReverseFlexDirection() const { return flexDirection() == FlowRowReverse || flexDirection() == FlowColumnReverse; }
EFlexWrap flexWrap() const { return static_cast<EFlexWrap>(rareNonInheritedData->m_flexibleBox->m_flexWrap); }
- EJustifyContent justifyContent() const { return static_cast<EJustifyContent>(rareNonInheritedData->m_justifyContent); }
-
+ const StyleContentAlignmentData& justifyContent() const { return rareNonInheritedData->m_justifyContent; }
+ ContentPosition justifyContentPosition() const { return rareNonInheritedData->m_justifyContent.position(); }
+ ContentDistributionType justifyContentDistribution() const { return rareNonInheritedData->m_justifyContent.distribution(); }
+ OverflowAlignment justifyContentOverflowAlignment() const { return rareNonInheritedData->m_justifyContent.overflow(); }
+ const StyleSelfAlignmentData& justifyItems() const { return rareNonInheritedData->m_justifyItems; }
+ ItemPosition justifyItemsPosition() const { return rareNonInheritedData->m_justifyItems.position(); }
+ OverflowAlignment justifyItemsOverflowAlignment() const { return rareNonInheritedData->m_justifyItems.overflow(); }
+ ItemPositionType justifyItemsPositionType() const { return rareNonInheritedData->m_justifyItems.positionType(); }
+ const StyleSelfAlignmentData& justifySelf() const { return rareNonInheritedData->m_justifySelf; }
+ ItemPosition justifySelfPosition() const { return rareNonInheritedData->m_justifySelf.position(); }
+ OverflowAlignment justifySelfOverflowAlignment() const { return rareNonInheritedData->m_justifySelf.overflow(); }
+
+#if ENABLE(CSS_GRID_LAYOUT)
const Vector<GridTrackSize>& gridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; }
const Vector<GridTrackSize>& gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; }
const NamedGridLinesMap& namedGridColumnLines() const { return rareNonInheritedData->m_grid->m_namedGridColumnLines; }
const NamedGridLinesMap& namedGridRowLines() const { return rareNonInheritedData->m_grid->m_namedGridRowLines; }
+ const OrderedNamedGridLinesMap& orderedNamedGridColumnLines() const { return rareNonInheritedData->m_grid->m_orderedNamedGridColumnLines; }
+ const OrderedNamedGridLinesMap& orderedNamedGridRowLines() const { return rareNonInheritedData->m_grid->m_orderedNamedGridRowLines; }
const NamedGridAreaMap& namedGridArea() const { return rareNonInheritedData->m_grid->m_namedGridArea; }
size_t namedGridAreaRowCount() const { return rareNonInheritedData->m_grid->m_namedGridAreaRowCount; }
size_t namedGridAreaColumnCount() const { return rareNonInheritedData->m_grid->m_namedGridAreaColumnCount; }
- GridAutoFlow gridAutoFlow() const { return rareNonInheritedData->m_grid->m_gridAutoFlow; }
+ GridAutoFlow gridAutoFlow() const { return static_cast<GridAutoFlow>(rareNonInheritedData->m_grid->m_gridAutoFlow); }
+ bool isGridAutoFlowDirectionRow() const { return (rareNonInheritedData->m_grid->m_gridAutoFlow & InternalAutoFlowDirectionRow); }
+ bool isGridAutoFlowDirectionColumn() const { return (rareNonInheritedData->m_grid->m_gridAutoFlow & InternalAutoFlowDirectionColumn); }
+ bool isGridAutoFlowAlgorithmSparse() const { return (rareNonInheritedData->m_grid->m_gridAutoFlow & InternalAutoFlowAlgorithmSparse); }
+ bool isGridAutoFlowAlgorithmDense() const { return (rareNonInheritedData->m_grid->m_gridAutoFlow & InternalAutoFlowAlgorithmDense); }
const GridTrackSize& gridAutoColumns() const { return rareNonInheritedData->m_grid->m_gridAutoColumns; }
const GridTrackSize& gridAutoRows() const { return rareNonInheritedData->m_grid->m_gridAutoRows; }
+ const Length& gridColumnGap() const { return rareNonInheritedData->m_grid->m_gridColumnGap; }
+ const Length& gridRowGap() const { return rareNonInheritedData->m_grid->m_gridRowGap; }
+
const GridPosition& gridItemColumnStart() const { return rareNonInheritedData->m_gridItem->m_gridColumnStart; }
const GridPosition& gridItemColumnEnd() const { return rareNonInheritedData->m_gridItem->m_gridColumnEnd; }
const GridPosition& gridItemRowStart() const { return rareNonInheritedData->m_gridItem->m_gridRowStart; }
const GridPosition& gridItemRowEnd() const { return rareNonInheritedData->m_gridItem->m_gridRowEnd; }
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
void getBoxShadowExtent(LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const { getShadowExtent(boxShadow(), top, right, bottom, left); }
@@ -819,15 +991,14 @@ public:
EOverflowWrap overflowWrap() const { return static_cast<EOverflowWrap>(rareInheritedData->overflowWrap); }
ENBSPMode nbspMode() const { return static_cast<ENBSPMode>(rareInheritedData->nbspMode); }
LineBreak lineBreak() const { return static_cast<LineBreak>(rareInheritedData->lineBreak); }
- const AtomicString& highlight() const { return rareInheritedData->highlight; }
Hyphens hyphens() const { return static_cast<Hyphens>(rareInheritedData->hyphens); }
short hyphenationLimitBefore() const { return rareInheritedData->hyphenationLimitBefore; }
short hyphenationLimitAfter() const { return rareInheritedData->hyphenationLimitAfter; }
short hyphenationLimitLines() const { return rareInheritedData->hyphenationLimitLines; }
const AtomicString& hyphenationString() const { return rareInheritedData->hyphenationString; }
- const AtomicString& locale() const { return rareInheritedData->locale; }
+ const AtomicString& locale() const { return fontDescription().locale(); }
EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
- EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); }
+ EResize resize() const { return static_cast<EResize>(rareNonInheritedData->m_resize); }
ColumnAxis columnAxis() const { return static_cast<ColumnAxis>(rareNonInheritedData->m_multiCol->m_axis); }
bool hasInlineColumnAxis() const {
ColumnAxis axis = columnAxis();
@@ -846,12 +1017,7 @@ public:
unsigned short columnRuleWidth() const { return rareNonInheritedData->m_multiCol->ruleWidth(); }
bool columnRuleIsTransparent() const { return rareNonInheritedData->m_multiCol->m_rule.isTransparent(); }
ColumnSpan columnSpan() const { return static_cast<ColumnSpan>(rareNonInheritedData->m_multiCol->m_columnSpan); }
- EPageBreak columnBreakBefore() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakBefore); }
- EPageBreak columnBreakInside() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakInside); }
- EPageBreak columnBreakAfter() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakAfter); }
- EPageBreak regionBreakBefore() const { return static_cast<EPageBreak>(rareNonInheritedData->m_regionBreakBefore); }
- EPageBreak regionBreakInside() const { return static_cast<EPageBreak>(rareNonInheritedData->m_regionBreakInside); }
- EPageBreak regionBreakAfter() const { return static_cast<EPageBreak>(rareNonInheritedData->m_regionBreakAfter); }
+
const TransformOperations& transform() const { return rareNonInheritedData->m_transform->m_operations; }
const Length& transformOriginX() const { return rareNonInheritedData->m_transform->m_x; }
const Length& transformOriginY() const { return rareNonInheritedData->m_transform->m_y; }
@@ -875,7 +1041,6 @@ public:
bool hasTransformRelatedProperty() const { return hasTransform() || preserves3D() || hasPerspective(); }
enum ApplyTransformOrigin { IncludeTransformOrigin, ExcludeTransformOrigin };
- void applyTransform(TransformationMatrix&, const LayoutSize& borderBoxSize, ApplyTransformOrigin = IncludeTransformOrigin) const;
void applyTransform(TransformationMatrix&, const FloatRect& boundingBox, ApplyTransformOrigin = IncludeTransformOrigin) const;
void setPageScaleTransform(float);
@@ -888,6 +1053,7 @@ public:
// End CSS3 Getters
+ bool hasFlowInto() const { return !rareNonInheritedData->m_flowThread.isNull(); }
const AtomicString& flowThread() const { return rareNonInheritedData->m_flowThread; }
bool hasFlowFrom() const { return !rareNonInheritedData->m_regionThread.isNull(); }
const AtomicString& regionThread() const { return rareNonInheritedData->m_regionThread; }
@@ -897,16 +1063,18 @@ public:
LineSnap lineSnap() const { return static_cast<LineSnap>(rareInheritedData->m_lineSnap); }
LineAlign lineAlign() const { return static_cast<LineAlign>(rareInheritedData->m_lineAlign); }
- WrapFlow wrapFlow() const { return static_cast<WrapFlow>(rareNonInheritedData->m_wrapFlow); }
- WrapThrough wrapThrough() const { return static_cast<WrapThrough>(rareNonInheritedData->m_wrapThrough); }
-
// Apple-specific property getter methods
EPointerEvents pointerEvents() const { return static_cast<EPointerEvents>(inherited_flags._pointerEvents); }
const AnimationList* animations() const { return rareNonInheritedData->m_animations.get(); }
const AnimationList* transitions() const { return rareNonInheritedData->m_transitions.get(); }
- AnimationList* accessAnimations();
- AnimationList* accessTransitions();
+ AnimationList* animations() { return rareNonInheritedData->m_animations.get(); }
+ AnimationList* transitions() { return rareNonInheritedData->m_transitions.get(); }
+
+ bool hasAnimationsOrTransitions() const { return rareNonInheritedData->hasAnimationsOrTransitions(); }
+
+ AnimationList& ensureAnimations();
+ AnimationList& ensureTransitions();
bool hasAnimations() const { return rareNonInheritedData->m_animations && rareNonInheritedData->m_animations->size() > 0; }
bool hasTransitions() const { return rareNonInheritedData->m_transitions && rareNonInheritedData->m_transitions->size() > 0; }
@@ -925,36 +1093,58 @@ public:
const LengthSize& pageSize() const { return rareNonInheritedData->m_pageSize; }
PageSizeType pageSizeType() const { return static_cast<PageSizeType>(rareNonInheritedData->m_pageSizeType); }
-#if USE(ACCELERATED_COMPOSITING)
// When set, this ensures that styles compare as different. Used during accelerated animations.
bool isRunningAcceleratedAnimation() const { return rareNonInheritedData->m_runningAcceleratedAnimation; }
-#endif
LineBoxContain lineBoxContain() const { return rareInheritedData->m_lineBoxContain; }
const LineClampValue& lineClamp() const { return rareNonInheritedData->lineClamp; }
+ const IntSize& initialLetter() const { return rareNonInheritedData->m_initialLetter; }
+ int initialLetterDrop() const { return initialLetter().width(); }
+ int initialLetterHeight() const { return initialLetter().height(); }
+
+#if ENABLE(TOUCH_EVENTS)
+ TouchAction touchAction() const { return static_cast<TouchAction>(rareNonInheritedData->m_touchAction); }
+#endif
+
+#if ENABLE(CSS_SCROLL_SNAP)
+ ScrollSnapType scrollSnapType() const { return static_cast<ScrollSnapType>(rareNonInheritedData->m_scrollSnapType); }
+ const ScrollSnapPoints* scrollSnapPointsX() const;
+ const ScrollSnapPoints* scrollSnapPointsY() const;
+ const LengthSize& scrollSnapDestination() const;
+ WEBCORE_EXPORT const Vector<LengthSize>& scrollSnapCoordinates() const;
+#endif
+
#if ENABLE(TOUCH_EVENTS)
Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
#endif
+
#if PLATFORM(IOS)
bool touchCalloutEnabled() const { return rareInheritedData->touchCalloutEnabled; }
- Color compositionFillColor() const { return rareInheritedData->compositionFillColor; }
#endif
+
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
bool useTouchOverflowScrolling() const { return rareInheritedData->useTouchOverflowScrolling; }
#endif
+
#if ENABLE(IOS_TEXT_AUTOSIZING)
TextSizeAdjustment textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
#endif
+
ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
WritingMode writingMode() const { return static_cast<WritingMode>(inherited_flags.m_writingMode); }
bool isHorizontalWritingMode() const { return WebCore::isHorizontalWritingMode(writingMode()); }
bool isFlippedLinesWritingMode() const { return WebCore::isFlippedLinesWritingMode(writingMode()); }
- bool isFlippedBlocksWritingMode() const { return WebCore::isFlippedBlocksWritingMode(writingMode()); }
+ bool isFlippedBlocksWritingMode() const { return WebCore::isFlippedWritingMode(writingMode()); }
+ ImageOrientationEnum imageOrientation() const
+ {
#if ENABLE(CSS_IMAGE_ORIENTATION)
- ImageOrientationEnum imageOrientation() const { return static_cast<ImageOrientationEnum>(rareInheritedData->m_imageOrientation); }
+ return static_cast<ImageOrientationEnum>(rareInheritedData->m_imageOrientation);
+#else
+ return DefaultImageOrientation;
#endif
+ }
EImageRendering imageRendering() const { return static_cast<EImageRendering>(rareInheritedData->m_imageRendering); }
@@ -966,20 +1156,33 @@ public:
ESpeak speak() const { return static_cast<ESpeak>(rareInheritedData->speak); }
-#if ENABLE(CSS_FILTERS)
FilterOperations& mutableFilter() { return rareNonInheritedData.access()->m_filter.access()->m_operations; }
const FilterOperations& filter() const { return rareNonInheritedData->m_filter->m_operations; }
bool hasFilter() const { return !rareNonInheritedData->m_filter->m_operations.operations().isEmpty(); }
+ bool hasReferenceFilterOnly() const;
+
+#if ENABLE(FILTERS_LEVEL_2)
+ FilterOperations& mutableBackdropFilter() { return rareNonInheritedData.access()->m_backdropFilter.access()->m_operations; }
+ const FilterOperations& backdropFilter() const { return rareNonInheritedData->m_backdropFilter->m_operations; }
+ bool hasBackdropFilter() const { return !rareNonInheritedData->m_backdropFilter->m_operations.operations().isEmpty(); }
#else
- bool hasFilter() const { return false; }
+ bool hasBackdropFilter() const { return false; }
#endif
#if ENABLE(CSS_COMPOSITING)
BlendMode blendMode() const { return static_cast<BlendMode>(rareNonInheritedData->m_effectiveBlendMode); }
- void setBlendMode(BlendMode v) { rareNonInheritedData.access()->m_effectiveBlendMode = v; }
+ void setBlendMode(BlendMode blendMode) { SET_VAR(rareNonInheritedData, m_effectiveBlendMode, blendMode); }
bool hasBlendMode() const { return static_cast<BlendMode>(rareNonInheritedData->m_effectiveBlendMode) != BlendModeNormal; }
+
+ Isolation isolation() const { return static_cast<Isolation>(rareNonInheritedData->m_isolation); }
+ void setIsolation(Isolation isolation) { SET_VAR(rareNonInheritedData, m_isolation, isolation); }
+ bool hasIsolation() const { return rareNonInheritedData->m_isolation != IsolationAuto; }
#else
+ BlendMode blendMode() const { return BlendModeNormal; }
bool hasBlendMode() const { return false; }
+
+ Isolation isolation() const { return IsolationAuto; }
+ bool hasIsolation() const { return false; }
#endif
#if USE(RTL_SCROLLBAR)
@@ -987,44 +1190,50 @@ public:
#else
bool shouldPlaceBlockDirectionScrollbarOnLogicalLeft() const { return false; }
#endif
-
+
+#if ENABLE(CSS_TRAILING_WORD)
+ TrailingWord trailingWord() const { return static_cast<TrailingWord>(rareInheritedData->trailingWord); }
+#endif
+
+ void checkVariablesInCustomProperties();
+
// attribute setter methods
- void setDisplay(EDisplay v) { noninherited_flags._effectiveDisplay = v; }
- void setOriginalDisplay(EDisplay v) { noninherited_flags._originalDisplay = v; }
- void setPosition(EPosition v) { noninherited_flags._position = v; }
- void setFloating(EFloat v) { noninherited_flags._floating = v; }
+ void setDisplay(EDisplay v) { noninherited_flags.setEffectiveDisplay(v); }
+ void setOriginalDisplay(EDisplay v) { noninherited_flags.setOriginalDisplay(v); }
+ void setPosition(EPosition v) { noninherited_flags.setPosition(v); }
+ void setFloating(EFloat v) { noninherited_flags.setFloating(v); }
- void setLeft(Length v) { SET_VAR(surround, offset.m_left, std::move(v)); }
- void setRight(Length v) { SET_VAR(surround, offset.m_right, std::move(v)); }
- void setTop(Length v) { SET_VAR(surround, offset.m_top, std::move(v)); }
- void setBottom(Length v) { SET_VAR(surround, offset.m_bottom, std::move(v)); }
+ void setLeft(Length v) { SET_VAR(surround, offset.left(), WTFMove(v)); }
+ void setRight(Length v) { SET_VAR(surround, offset.right(), WTFMove(v)); }
+ void setTop(Length v) { SET_VAR(surround, offset.top(), WTFMove(v)); }
+ void setBottom(Length v) { SET_VAR(surround, offset.bottom(), WTFMove(v)); }
- void setWidth(Length v) { SET_VAR(m_box, m_width, std::move(v)); }
- void setHeight(Length v) { SET_VAR(m_box, m_height, std::move(v)); }
+ void setWidth(Length v) { SET_VAR(m_box, m_width, WTFMove(v)); }
+ void setHeight(Length v) { SET_VAR(m_box, m_height, WTFMove(v)); }
void setLogicalWidth(Length v)
{
if (isHorizontalWritingMode()) {
- SET_VAR(m_box, m_width, std::move(v));
+ SET_VAR(m_box, m_width, WTFMove(v));
} else {
- SET_VAR(m_box, m_height, std::move(v));
+ SET_VAR(m_box, m_height, WTFMove(v));
}
}
void setLogicalHeight(Length v)
{
if (isHorizontalWritingMode()) {
- SET_VAR(m_box, m_height, std::move(v));
+ SET_VAR(m_box, m_height, WTFMove(v));
} else {
- SET_VAR(m_box, m_width, std::move(v));
+ SET_VAR(m_box, m_width, WTFMove(v));
}
}
- void setMinWidth(Length v) { SET_VAR(m_box, m_minWidth, std::move(v)); }
- void setMaxWidth(Length v) { SET_VAR(m_box, m_maxWidth, std::move(v)); }
- void setMinHeight(Length v) { SET_VAR(m_box, m_minHeight, std::move(v)); }
- void setMaxHeight(Length v) { SET_VAR(m_box, m_maxHeight, std::move(v)); }
+ void setMinWidth(Length v) { SET_VAR(m_box, m_minWidth, WTFMove(v)); }
+ void setMaxWidth(Length v) { SET_VAR(m_box, m_maxWidth, WTFMove(v)); }
+ void setMinHeight(Length v) { SET_VAR(m_box, m_minHeight, WTFMove(v)); }
+ void setMaxHeight(Length v) { SET_VAR(m_box, m_maxHeight, WTFMove(v)); }
#if ENABLE(DASHBOARD_SUPPORT)
Vector<StyleDashboardRegion> dashboardRegions() const { return rareNonInheritedData->m_dashboardRegions; }
@@ -1034,10 +1243,10 @@ public:
{
StyleDashboardRegion region;
region.label = label;
- region.offset.m_top = std::move(t);
- region.offset.m_right = std::move(r);
- region.offset.m_bottom = std::move(b);
- region.offset.m_left = std::move(l);
+ region.offset.top() = WTFMove(t);
+ region.offset.right() = WTFMove(r);
+ region.offset.bottom() = WTFMove(b);
+ region.offset.left() = WTFMove(l);
region.type = type;
if (!append)
rareNonInheritedData.access()->m_dashboardRegions.clear();
@@ -1059,10 +1268,10 @@ public:
void setBackgroundColor(const Color& v) { SET_VAR(m_background, m_color, v); }
- void setBackgroundXPosition(Length length) { SET_VAR(m_background, m_background.m_xPosition, std::move(length)); }
- void setBackgroundYPosition(Length length) { SET_VAR(m_background, m_background.m_yPosition, std::move(length)); }
+ void setBackgroundXPosition(Length length) { SET_VAR(m_background, m_background.m_xPosition, WTFMove(length)); }
+ void setBackgroundYPosition(Length length) { SET_VAR(m_background, m_background.m_yPosition, WTFMove(length)); }
void setBackgroundSize(EFillSizeType b) { SET_VAR(m_background, m_background.m_sizeType, b); }
- void setBackgroundSizeLength(LengthSize size) { SET_VAR(m_background, m_background.m_sizeLength, std::move(size)); }
+ void setBackgroundSizeLength(LengthSize size) { SET_VAR(m_background, m_background.m_sizeLength, WTFMove(size)); }
void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.m_image, b); }
void setBorderImageSource(PassRefPtr<StyleImage>);
@@ -1070,10 +1279,10 @@ public:
void setBorderImageWidth(LengthBox);
void setBorderImageOutset(LengthBox);
- void setBorderTopLeftRadius(LengthSize size) { SET_VAR(surround, border.m_topLeft, std::move(size)); }
- void setBorderTopRightRadius(LengthSize size) { SET_VAR(surround, border.m_topRight, std::move(size)); }
- void setBorderBottomLeftRadius(LengthSize size) { SET_VAR(surround, border.m_bottomLeft, std::move(size)); }
- void setBorderBottomRightRadius(LengthSize size) { SET_VAR(surround, border.m_bottomRight, std::move(size)); }
+ void setBorderTopLeftRadius(LengthSize size) { SET_VAR(surround, border.m_topLeft, WTFMove(size)); }
+ void setBorderTopRightRadius(LengthSize size) { SET_VAR(surround, border.m_topRight, WTFMove(size)); }
+ void setBorderBottomLeftRadius(LengthSize size) { SET_VAR(surround, border.m_bottomLeft, WTFMove(size)); }
+ void setBorderBottomRightRadius(LengthSize size) { SET_VAR(surround, border.m_bottomRight, WTFMove(size)); }
void setBorderRadius(LengthSize s)
{
@@ -1087,50 +1296,50 @@ public:
setBorderRadius(LengthSize(Length(s.width(), Fixed), Length(s.height(), Fixed)));
}
- RoundedRect getRoundedBorderFor(const LayoutRect& borderRect, RenderView* = 0, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
+ RoundedRect getRoundedBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
RoundedRect getRoundedInnerBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
- RoundedRect getRoundedInnerBorderFor(const LayoutRect& borderRect,
- int topWidth, int bottomWidth, int leftWidth, int rightWidth, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;
+ RoundedRect getRoundedInnerBorderFor(const LayoutRect& borderRect, LayoutUnit topWidth, LayoutUnit bottomWidth,
+ LayoutUnit leftWidth, LayoutUnit rightWidth, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
- void setBorderLeftWidth(unsigned v) { SET_VAR(surround, border.m_left.m_width, v); }
+ void setBorderLeftWidth(float v) { SET_VAR(surround, border.m_left.m_width, v); }
void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.m_left.m_style, v); }
void setBorderLeftColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_left, v); }
- void setBorderRightWidth(unsigned v) { SET_VAR(surround, border.m_right.m_width, v); }
+ void setBorderRightWidth(float v) { SET_VAR(surround, border.m_right.m_width, v); }
void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround, border.m_right.m_style, v); }
void setBorderRightColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_right, v); }
- void setBorderTopWidth(unsigned v) { SET_VAR(surround, border.m_top.m_width, v); }
+ void setBorderTopWidth(float v) { SET_VAR(surround, border.m_top.m_width, v); }
void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround, border.m_top.m_style, v); }
void setBorderTopColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_top, v); }
- void setBorderBottomWidth(unsigned v) { SET_VAR(surround, border.m_bottom.m_width, v); }
+ void setBorderBottomWidth(float v) { SET_VAR(surround, border.m_bottom.m_width, v); }
void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround, border.m_bottom.m_style, v); }
void setBorderBottomColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_bottom, v); }
- void setOutlineWidth(unsigned short v) { SET_VAR(m_background, m_outline.m_width, v); }
+ void setOutlineWidth(float v) { SET_VAR(m_background, m_outline.m_width, v); }
void setOutlineStyleIsAuto(OutlineIsAuto isAuto) { SET_VAR(m_background, m_outline.m_isAuto, isAuto); }
void setOutlineStyle(EBorderStyle v) { SET_VAR(m_background, m_outline.m_style, v); }
void setOutlineColor(const Color& v) { SET_BORDERVALUE_COLOR(m_background, m_outline, v); }
- void setOverflowX(EOverflow v) { noninherited_flags._overflowX = v; }
- void setOverflowY(EOverflow v) { noninherited_flags._overflowY = v; }
+ void setOverflowX(EOverflow v) { noninherited_flags.setOverflowX(v); }
+ void setOverflowY(EOverflow v) { noninherited_flags.setOverflowY(v); }
void setVisibility(EVisibility v) { inherited_flags._visibility = v; }
- void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; }
- void setVerticalAlignLength(Length length) { setVerticalAlign(LENGTH); SET_VAR(m_box, m_verticalAlign, std::move(length)); }
+ void setVerticalAlign(EVerticalAlign v) { noninherited_flags.setVerticalAlign(v); }
+ void setVerticalAlignLength(Length length) { setVerticalAlign(LENGTH); SET_VAR(m_box, m_verticalAlign, WTFMove(length)); }
void setHasClip(bool b = true) { SET_VAR(visual, hasClip, b); }
- void setClipLeft(Length length) { SET_VAR(visual, clip.m_left, std::move(length)); }
- void setClipRight(Length length) { SET_VAR(visual, clip.m_right, std::move(length)); }
- void setClipTop(Length length) { SET_VAR(visual, clip.m_top, std::move(length)); }
- void setClipBottom(Length length) { SET_VAR(visual, clip.m_bottom, std::move(length)); }
+ void setClipLeft(Length length) { SET_VAR(visual, clip.left(), WTFMove(length)); }
+ void setClipRight(Length length) { SET_VAR(visual, clip.right(), WTFMove(length)); }
+ void setClipTop(Length length) { SET_VAR(visual, clip.top(), WTFMove(length)); }
+ void setClipBottom(Length length) { SET_VAR(visual, clip.bottom(), WTFMove(length)); }
void setClip(Length top, Length right, Length bottom, Length left);
- void setClip(LengthBox box) { SET_VAR(visual, clip, std::move(box)); }
+ void setClip(LengthBox box) { SET_VAR(visual, clip, WTFMove(box)); }
- void setUnicodeBidi(EUnicodeBidi b) { noninherited_flags._unicodeBidi = b; }
+ void setUnicodeBidi(EUnicodeBidi b) { noninherited_flags.setUnicodeBidi(b); }
- void setClear(EClear v) { noninherited_flags._clear = v; }
- void setTableLayout(ETableLayout v) { noninherited_flags._table_layout = v; }
+ void setClear(EClear v) { noninherited_flags.setClear(v); }
+ void setTableLayout(ETableLayout v) { noninherited_flags.setTableLayout(v); }
- bool setFontDescription(const FontDescription&);
+ bool setFontDescription(const FontCascadeDescription&);
// Only used for blending font sizes when animating, for MathML anonymous blocks, and for text autosizing.
void setFontSize(float);
@@ -1143,7 +1352,7 @@ public:
#endif
void setColor(const Color&);
- void setTextIndent(Length length) { SET_VAR(rareInheritedData, indent, std::move(length)); }
+ void setTextIndent(Length length) { SET_VAR(rareInheritedData, indent, WTFMove(length)); }
#if ENABLE(CSS3_TEXT)
void setTextIndentLine(TextIndentLine v) { SET_VAR(rareInheritedData, m_textIndentLine, v); }
void setTextIndentType(TextIndentType v) { SET_VAR(rareInheritedData, m_textIndentType, v); }
@@ -1156,11 +1365,12 @@ public:
#if ENABLE(CSS3_TEXT)
void setTextAlignLast(TextAlignLast v) { SET_VAR(rareInheritedData, m_textAlignLast, v); }
void setTextJustify(TextJustify v) { SET_VAR(rareInheritedData, m_textJustify, v); }
-#endif // CSS3_TEXT
+#endif
void setTextDecorationStyle(TextDecorationStyle v) { SET_VAR(rareNonInheritedData, m_textDecorationStyle, v); }
void setTextDecorationSkip(TextDecorationSkip skip) { SET_VAR(rareInheritedData, m_textDecorationSkip, skip); }
void setTextUnderlinePosition(TextUnderlinePosition v) { SET_VAR(rareInheritedData, m_textUnderlinePosition, v); }
void setDirection(TextDirection v) { inherited_flags._direction = v; }
+ void setHasExplicitlySetDirection(bool v) { noninherited_flags.setHasExplicitlySetDirection(v); }
#if ENABLE(IOS_TEXT_AUTOSIZING)
void setSpecifiedLineHeight(Length v);
#endif
@@ -1168,7 +1378,8 @@ public:
bool setZoom(float);
void setZoomWithoutReturnValue(float f) { setZoom(f); }
bool setEffectiveZoom(float);
-
+ void setTextZoom(TextZoom v) { SET_VAR(rareInheritedData, m_textZoom, v); }
+
#if ENABLE(CSS_IMAGE_ORIENTATION)
void setImageOrientation(ImageOrientationEnum v) { SET_VAR(rareInheritedData, m_imageOrientation, static_cast<int>(v)); }
#endif
@@ -1192,8 +1403,8 @@ public:
void adjustBackgroundLayers()
{
if (backgroundLayers()->next()) {
- accessBackgroundLayers()->cullEmptyLayers();
- accessBackgroundLayers()->fillUnsetProperties();
+ ensureBackgroundLayers().cullEmptyLayers();
+ ensureBackgroundLayers().fillUnsetProperties();
}
}
@@ -1203,8 +1414,8 @@ public:
void adjustMaskLayers()
{
if (maskLayers()->next()) {
- accessMaskLayers()->cullEmptyLayers();
- accessMaskLayers()->fillUnsetProperties();
+ ensureMaskLayers().cullEmptyLayers();
+ ensureMaskLayers().fillUnsetProperties();
}
}
@@ -1212,9 +1423,9 @@ public:
void setMaskBoxImage(const NinePieceImage& b) { SET_VAR(rareNonInheritedData, m_maskBoxImage, b); }
void setMaskBoxImageSource(PassRefPtr<StyleImage> v) { rareNonInheritedData.access()->m_maskBoxImage.setImage(v); }
- void setMaskXPosition(Length length) { SET_VAR(rareNonInheritedData, m_mask.m_xPosition, std::move(length)); }
- void setMaskYPosition(Length length) { SET_VAR(rareNonInheritedData, m_mask.m_yPosition, std::move(length)); }
- void setMaskSize(LengthSize size) { SET_VAR(rareNonInheritedData, m_mask.m_sizeLength, std::move(size)); }
+ void setMaskXPosition(Length length) { SET_VAR(rareNonInheritedData, m_mask.m_xPosition, WTFMove(length)); }
+ void setMaskYPosition(Length length) { SET_VAR(rareNonInheritedData, m_mask.m_yPosition, WTFMove(length)); }
+ void setMaskSize(LengthSize size) { SET_VAR(rareNonInheritedData, m_mask.m_sizeLength, WTFMove(size)); }
void setBorderCollapse(EBorderCollapse collapse) { inherited_flags._border_collapse = collapse; }
void setHorizontalBorderSpacing(short);
@@ -1222,7 +1433,7 @@ public:
void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
- void setHasAspectRatio(bool b) { SET_VAR(rareNonInheritedData, m_hasAspectRatio, b); }
+ void setAspectRatioType(AspectRatioType aspectRatioType) { SET_VAR(rareNonInheritedData, m_aspectRatioType, aspectRatioType); }
void setAspectRatioDenominator(float v) { SET_VAR(rareNonInheritedData, m_aspectRatioDenominator, v); }
void setAspectRatioNumerator(float v) { SET_VAR(rareNonInheritedData, m_aspectRatioNumerator, v); }
@@ -1231,19 +1442,19 @@ public:
void setListStylePosition(EListStylePosition v) { inherited_flags._list_style_position = v; }
void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)); }
- void setMarginTop(Length length) { SET_VAR(surround, margin.m_top, std::move(length)); }
- void setMarginBottom(Length length) { SET_VAR(surround, margin.m_bottom, std::move(length)); }
- void setMarginLeft(Length length) { SET_VAR(surround, margin.m_left, std::move(length)); }
- void setMarginRight(Length length) { SET_VAR(surround, margin.m_right, std::move(length)); }
+ void setMarginTop(Length length) { SET_VAR(surround, margin.top(), WTFMove(length)); }
+ void setMarginBottom(Length length) { SET_VAR(surround, margin.bottom(), WTFMove(length)); }
+ void setMarginLeft(Length length) { SET_VAR(surround, margin.left(), WTFMove(length)); }
+ void setMarginRight(Length length) { SET_VAR(surround, margin.right(), WTFMove(length)); }
void setMarginStart(Length);
void setMarginEnd(Length);
void resetPadding() { SET_VAR(surround, padding, LengthBox(Auto)); }
- void setPaddingBox(LengthBox box) { SET_VAR(surround, padding, std::move(box)); }
- void setPaddingTop(Length length) { SET_VAR(surround, padding.m_top, std::move(length)); }
- void setPaddingBottom(Length length) { SET_VAR(surround, padding.m_bottom, std::move(length)); }
- void setPaddingLeft(Length length) { SET_VAR(surround, padding.m_left, std::move(length)); }
- void setPaddingRight(Length length) { SET_VAR(surround, padding.m_right, std::move(length)); }
+ void setPaddingBox(LengthBox box) { SET_VAR(surround, padding, WTFMove(box)); }
+ void setPaddingTop(Length length) { SET_VAR(surround, padding.top(), WTFMove(length)); }
+ void setPaddingBottom(Length length) { SET_VAR(surround, padding.bottom(), WTFMove(length)); }
+ void setPaddingLeft(Length length) { SET_VAR(surround, padding.left(), WTFMove(length)); }
+ void setPaddingRight(Length length) { SET_VAR(surround, padding.right(), WTFMove(length)); }
void setCursor(ECursor c) { inherited_flags._cursor_style = c; }
void addCursor(PassRefPtr<StyleImage>, const IntPoint& hotSpot = IntPoint());
@@ -1257,6 +1468,8 @@ public:
void setInsideLink(EInsideLink insideLink) { inherited_flags._insideLink = insideLink; }
void setIsLink(bool b) { noninherited_flags.setIsLink(b); }
+ void setInsideDefaultButton(bool insideDefaultButton) { inherited_flags._insideDefaultButton = insideDefaultButton; }
+
PrintColorAdjust printColorAdjust() const { return static_cast<PrintColorAdjust>(inherited_flags.m_printColorAdjust); }
void setPrintColorAdjust(PrintColorAdjust value) { inherited_flags.m_printColorAdjust = value; }
@@ -1271,65 +1484,81 @@ public:
void setHasAutoOrphans() { SET_VAR(rareInheritedData, m_hasAutoOrphans, true); SET_VAR(rareInheritedData, orphans, initialOrphans()); }
void setOrphans(short o) { SET_VAR(rareInheritedData, m_hasAutoOrphans, false); SET_VAR(rareInheritedData, orphans, o); }
- // For valid values of page-break-inside see http://www.w3.org/TR/CSS21/page.html#page-break-props
- void setPageBreakInside(EPageBreak b) { ASSERT(b == PBAUTO || b == PBAVOID); noninherited_flags._page_break_inside = b; }
- void setPageBreakBefore(EPageBreak b) { noninherited_flags._page_break_before = b; }
- void setPageBreakAfter(EPageBreak b) { noninherited_flags._page_break_after = b; }
-
// CSS3 Setters
- void setOutlineOffset(int v) { SET_VAR(m_background, m_outline.m_offset, v); }
- void setTextShadow(PassOwnPtr<ShadowData>, bool add = false);
+ void setOutlineOffset(float v) { SET_VAR(m_background, m_outline.m_offset, v); }
+ void setTextShadow(std::unique_ptr<ShadowData>, bool add = false);
void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c); }
void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w); }
void setTextFillColor(const Color& c) { SET_VAR(rareInheritedData, textFillColor, c); }
- void setColorSpace(ColorSpace space) { SET_VAR(rareInheritedData, colorSpace, space); }
void setOpacity(float f) { float v = clampTo<float>(f, 0, 1); SET_VAR(rareNonInheritedData, opacity, v); }
void setAppearance(ControlPart a) { SET_VAR(rareNonInheritedData, m_appearance, a); }
// For valid values of box-align see http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment
- void setBoxAlign(EBoxAlignment a) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, align, a); }
+ void setBoxAlign(EBoxAlignment a) { SET_NESTED_VAR(rareNonInheritedData, m_deprecatedFlexibleBox, align, a); }
#if ENABLE(CSS_BOX_DECORATION_BREAK)
void setBoxDecorationBreak(EBoxDecorationBreak b) { SET_VAR(m_box, m_boxDecorationBreak, b); }
#endif
void setBoxDirection(EBoxDirection d) { inherited_flags._box_direction = d; }
- void setBoxFlex(float f) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, flex, f); }
- void setBoxFlexGroup(unsigned int fg) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, flex_group, fg); }
- void setBoxLines(EBoxLines l) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, lines, l); }
- void setBoxOrdinalGroup(unsigned int og) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, ordinal_group, og); }
- void setBoxOrient(EBoxOrient o) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, orient, o); }
- void setBoxPack(EBoxPack p) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, pack, p); }
- void setBoxShadow(PassOwnPtr<ShadowData>, bool add = false);
+ void setBoxFlex(float f) { SET_NESTED_VAR(rareNonInheritedData, m_deprecatedFlexibleBox, flex, f); }
+ void setBoxFlexGroup(unsigned int fg) { SET_NESTED_VAR(rareNonInheritedData, m_deprecatedFlexibleBox, flex_group, fg); }
+ void setBoxLines(EBoxLines l) { SET_NESTED_VAR(rareNonInheritedData, m_deprecatedFlexibleBox, lines, l); }
+ void setBoxOrdinalGroup(unsigned int og) { SET_NESTED_VAR(rareNonInheritedData, m_deprecatedFlexibleBox, ordinal_group, og); }
+ void setBoxOrient(EBoxOrient o) { SET_NESTED_VAR(rareNonInheritedData, m_deprecatedFlexibleBox, orient, o); }
+ void setBoxPack(EBoxPack p) { SET_NESTED_VAR(rareNonInheritedData, m_deprecatedFlexibleBox, pack, p); }
+ void setBoxShadow(std::unique_ptr<ShadowData>, bool add = false);
void setBoxReflect(PassRefPtr<StyleReflection> reflect) { if (rareNonInheritedData->m_boxReflect != reflect) rareNonInheritedData.access()->m_boxReflect = reflect; }
void setBoxSizing(EBoxSizing s) { SET_VAR(m_box, m_boxSizing, s); }
- void setFlexGrow(float f) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexGrow, f); }
- void setFlexShrink(float f) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexShrink, f); }
- void setFlexBasis(Length length) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexBasis, std::move(length)); }
+ void setFlexGrow(float f) { SET_NESTED_VAR(rareNonInheritedData, m_flexibleBox, m_flexGrow, f); }
+ void setFlexShrink(float f) { SET_NESTED_VAR(rareNonInheritedData, m_flexibleBox, m_flexShrink, f); }
+ void setFlexBasis(Length length) { SET_NESTED_VAR(rareNonInheritedData, m_flexibleBox, m_flexBasis, WTFMove(length)); }
void setOrder(int o) { SET_VAR(rareNonInheritedData, m_order, o); }
- void setAlignContent(EAlignContent p) { SET_VAR(rareNonInheritedData, m_alignContent, p); }
- void setAlignItems(EAlignItems a) { SET_VAR(rareNonInheritedData, m_alignItems, a); }
- void setAlignSelf(EAlignItems a) { SET_VAR(rareNonInheritedData, m_alignSelf, a); }
- void setFlexDirection(EFlexDirection direction) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexDirection, direction); }
- void setFlexWrap(EFlexWrap w) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexWrap, w); }
- void setJustifyContent(EJustifyContent p) { SET_VAR(rareNonInheritedData, m_justifyContent, p); }
- void setGridAutoColumns(const GridTrackSize& length) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridAutoColumns, length); }
- void setGridAutoRows(const GridTrackSize& length) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridAutoRows, length); }
- void setGridColumns(const Vector<GridTrackSize>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, lengths); }
- void setGridRows(const Vector<GridTrackSize>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, lengths); }
- void setNamedGridColumnLines(const NamedGridLinesMap& namedGridColumnLines) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridColumnLines, namedGridColumnLines); }
- void setNamedGridRowLines(const NamedGridLinesMap& namedGridRowLines) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridRowLines, namedGridRowLines); }
- void setNamedGridArea(const NamedGridAreaMap& namedGridArea) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridArea, namedGridArea); }
- void setNamedGridAreaRowCount(size_t rowCount) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridAreaRowCount, rowCount); }
- void setNamedGridAreaColumnCount(size_t columnCount) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridAreaColumnCount, columnCount); }
- void setGridAutoFlow(GridAutoFlow flow) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridAutoFlow, flow); }
- void setGridItemColumnStart(const GridPosition& columnStartPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridColumnStart, columnStartPosition); }
- void setGridItemColumnEnd(const GridPosition& columnEndPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridColumnEnd, columnEndPosition); }
- void setGridItemRowStart(const GridPosition& rowStartPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridRowStart, rowStartPosition); }
- void setGridItemRowEnd(const GridPosition& rowEndPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridRowEnd, rowEndPosition); }
-
- void setMarqueeIncrement(Length length) { SET_VAR(rareNonInheritedData.access()->m_marquee, increment, std::move(length)); }
- void setMarqueeSpeed(int f) { SET_VAR(rareNonInheritedData.access()->m_marquee, speed, f); }
- void setMarqueeDirection(EMarqueeDirection d) { SET_VAR(rareNonInheritedData.access()->m_marquee, direction, d); }
- void setMarqueeBehavior(EMarqueeBehavior b) { SET_VAR(rareNonInheritedData.access()->m_marquee, behavior, b); }
- void setMarqueeLoopCount(int i) { SET_VAR(rareNonInheritedData.access()->m_marquee, loops, i); }
+ void setAlignContent(const StyleContentAlignmentData& data) { SET_VAR(rareNonInheritedData, m_alignContent, data); }
+ void setAlignContentPosition(ContentPosition position) { rareNonInheritedData.access()->m_alignContent.setPosition(position); }
+ void setAlignContentOverflow(OverflowAlignment overflow) { rareNonInheritedData.access()->m_alignContent.setOverflow(overflow); }
+ void setAlignContentDistribution(ContentDistributionType distribution) { rareNonInheritedData.access()->m_alignContent.setDistribution(distribution); }
+ void setAlignItems(const StyleSelfAlignmentData& data) { SET_VAR(rareNonInheritedData, m_alignItems, data); }
+ void setAlignItemsPosition(ItemPosition position) { rareNonInheritedData.access()->m_alignItems.setPosition(position); }
+ void setAlignItemsOverflow(OverflowAlignment overflow) { rareNonInheritedData.access()->m_alignItems.setOverflow(overflow); }
+ void setAlignSelf(const StyleSelfAlignmentData& data) { SET_VAR(rareNonInheritedData, m_alignSelf, data); }
+ void setAlignSelfPosition(ItemPosition position) { rareNonInheritedData.access()->m_alignSelf.setPosition(position); }
+ void setAlignSelfOverflow(OverflowAlignment overflow) { rareNonInheritedData.access()->m_alignSelf.setOverflow(overflow); }
+ void setFlexDirection(EFlexDirection direction) { SET_NESTED_VAR(rareNonInheritedData, m_flexibleBox, m_flexDirection, direction); }
+ void setFlexWrap(EFlexWrap w) { SET_NESTED_VAR(rareNonInheritedData, m_flexibleBox, m_flexWrap, w); }
+ void setJustifyContent(const StyleContentAlignmentData& data) { SET_VAR(rareNonInheritedData, m_justifyContent, data); }
+ void setJustifyContentPosition(ContentPosition position) { rareNonInheritedData.access()->m_justifyContent.setPosition(position); }
+ void setJustifyContentOverflow(OverflowAlignment overflow) { rareNonInheritedData.access()->m_justifyContent.setOverflow(overflow); }
+ void setJustifyContentDistribution(ContentDistributionType distribution) { rareNonInheritedData.access()->m_justifyContent.setDistribution(distribution); }
+ void setJustifyItems(const StyleSelfAlignmentData& data) { SET_VAR(rareNonInheritedData, m_justifyItems, data); }
+ void setJustifyItemsPosition(ItemPosition position) { rareNonInheritedData.access()->m_justifyItems.setPosition(position); }
+ void setJustifyItemsOverflow(OverflowAlignment overflow) { rareNonInheritedData.access()->m_justifyItems.setOverflow(overflow); }
+ void setJustifyItemsPositionType(ItemPositionType positionType) { rareNonInheritedData.access()->m_justifyItems.setPositionType(positionType); }
+ void setJustifySelf(const StyleSelfAlignmentData& data) { SET_VAR(rareNonInheritedData, m_justifySelf, data); }
+ void setJustifySelfPosition(ItemPosition position) { rareNonInheritedData.access()->m_justifySelf.setPosition(position); }
+ void setJustifySelfOverflow(OverflowAlignment overflow) { rareNonInheritedData.access()->m_justifySelf.setOverflow(overflow); }
+#if ENABLE(CSS_GRID_LAYOUT)
+ void setGridAutoColumns(const GridTrackSize& length) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_gridAutoColumns, length); }
+ void setGridAutoRows(const GridTrackSize& length) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_gridAutoRows, length); }
+ void setGridColumns(const Vector<GridTrackSize>& lengths) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_gridColumns, lengths); }
+ void setGridRows(const Vector<GridTrackSize>& lengths) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_gridRows, lengths); }
+ void setNamedGridColumnLines(const NamedGridLinesMap& namedGridColumnLines) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_namedGridColumnLines, namedGridColumnLines); }
+ void setNamedGridRowLines(const NamedGridLinesMap& namedGridRowLines) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_namedGridRowLines, namedGridRowLines); }
+ void setOrderedNamedGridColumnLines(const OrderedNamedGridLinesMap& orderedNamedGridColumnLines) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_orderedNamedGridColumnLines, orderedNamedGridColumnLines); }
+ void setOrderedNamedGridRowLines(const OrderedNamedGridLinesMap& orderedNamedGridRowLines) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_orderedNamedGridRowLines, orderedNamedGridRowLines); }
+ void setNamedGridArea(const NamedGridAreaMap& namedGridArea) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_namedGridArea, namedGridArea); }
+ void setNamedGridAreaRowCount(size_t rowCount) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_namedGridAreaRowCount, rowCount); }
+ void setNamedGridAreaColumnCount(size_t columnCount) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_namedGridAreaColumnCount, columnCount); }
+ void setGridAutoFlow(GridAutoFlow flow) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_gridAutoFlow, flow); }
+ void setGridItemColumnStart(const GridPosition& columnStartPosition) { SET_NESTED_VAR(rareNonInheritedData, m_gridItem, m_gridColumnStart, columnStartPosition); }
+ void setGridItemColumnEnd(const GridPosition& columnEndPosition) { SET_NESTED_VAR(rareNonInheritedData, m_gridItem, m_gridColumnEnd, columnEndPosition); }
+ void setGridItemRowStart(const GridPosition& rowStartPosition) { SET_NESTED_VAR(rareNonInheritedData, m_gridItem, m_gridRowStart, rowStartPosition); }
+ void setGridItemRowEnd(const GridPosition& rowEndPosition) { SET_NESTED_VAR(rareNonInheritedData, m_gridItem, m_gridRowEnd, rowEndPosition); }
+ void setGridColumnGap(const Length& v) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_gridColumnGap, v); }
+ void setGridRowGap(const Length& v) { SET_NESTED_VAR(rareNonInheritedData, m_grid, m_gridRowGap, v); }
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
+ void setMarqueeIncrement(Length length) { SET_NESTED_VAR(rareNonInheritedData, m_marquee, increment, WTFMove(length)); }
+ void setMarqueeSpeed(int f) { SET_NESTED_VAR(rareNonInheritedData, m_marquee, speed, f); }
+ void setMarqueeDirection(EMarqueeDirection d) { SET_NESTED_VAR(rareNonInheritedData, m_marquee, direction, d); }
+ void setMarqueeBehavior(EMarqueeBehavior b) { SET_NESTED_VAR(rareNonInheritedData, m_marquee, behavior, b); }
+ void setMarqueeLoopCount(int i) { SET_NESTED_VAR(rareNonInheritedData, m_marquee, loops, i); }
void setUserModify(EUserModify u) { SET_VAR(rareInheritedData, userModify, u); }
void setUserDrag(EUserDrag d) { SET_VAR(rareNonInheritedData, userDrag, d); }
void setUserSelect(EUserSelect s) { SET_VAR(rareInheritedData, userSelect, s); }
@@ -1340,41 +1569,32 @@ public:
void setOverflowWrap(EOverflowWrap b) { SET_VAR(rareInheritedData, overflowWrap, b); }
void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); }
void setLineBreak(LineBreak b) { SET_VAR(rareInheritedData, lineBreak, b); }
- void setHighlight(const AtomicString& h) { SET_VAR(rareInheritedData, highlight, h); }
void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); }
void setHyphenationLimitBefore(short limit) { SET_VAR(rareInheritedData, hyphenationLimitBefore, limit); }
void setHyphenationLimitAfter(short limit) { SET_VAR(rareInheritedData, hyphenationLimitAfter, limit); }
void setHyphenationLimitLines(short limit) { SET_VAR(rareInheritedData, hyphenationLimitLines, limit); }
void setHyphenationString(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationString, h); }
- void setLocale(const AtomicString& locale) { SET_VAR(rareInheritedData, locale, locale); }
void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
- void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); }
- void setColumnAxis(ColumnAxis axis) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_axis, axis); }
- void setColumnProgression(ColumnProgression progression) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_progression, progression); }
- void setColumnWidth(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, f); }
- void setHasAutoColumnWidth() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, 0); }
- void setColumnCount(unsigned short c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, c); }
- void setHasAutoColumnCount() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, 0); }
- void setColumnFill(ColumnFill columnFill) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_fill, columnFill); }
- void setColumnGap(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, f); }
- void setHasNormalColumnGap() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, 0); }
+ void setResize(EResize r) { SET_VAR(rareNonInheritedData, m_resize, r); }
+ void setColumnAxis(ColumnAxis axis) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_axis, axis); }
+ void setColumnProgression(ColumnProgression progression) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_progression, progression); }
+ void setColumnWidth(float f) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_autoWidth, false); SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_width, f); }
+ void setHasAutoColumnWidth() { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_autoWidth, true); SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_width, 0); }
+ void setColumnCount(unsigned short c) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_autoCount, false); SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_count, c); }
+ void setHasAutoColumnCount() { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_autoCount, true); SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_count, 0); }
+ void setColumnFill(ColumnFill columnFill) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_fill, columnFill); }
+ void setColumnGap(float f) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_normalGap, false); SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_gap, f); }
+ void setHasNormalColumnGap() { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_normalGap, true); SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_gap, 0); }
void setColumnRuleColor(const Color& c) { SET_BORDERVALUE_COLOR(rareNonInheritedData.access()->m_multiCol, m_rule, c); }
- void setColumnRuleStyle(EBorderStyle b) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_style, b); }
- void setColumnRuleWidth(unsigned short w) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_width, w); }
- void resetColumnRule() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule, BorderValue()); }
- void setColumnSpan(ColumnSpan columnSpan) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_columnSpan, columnSpan); }
- void setColumnBreakBefore(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakBefore, p); }
- // For valid values of column-break-inside see http://www.w3.org/TR/css3-multicol/#break-before-break-after-break-inside
- void setColumnBreakInside(EPageBreak p) { ASSERT(p == PBAUTO || p == PBAVOID); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakInside, p); }
- void setColumnBreakAfter(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakAfter, p); }
- void setRegionBreakBefore(EPageBreak p) { SET_VAR(rareNonInheritedData, m_regionBreakBefore, p); }
- void setRegionBreakInside(EPageBreak p) { ASSERT(p == PBAUTO || p == PBAVOID); SET_VAR(rareNonInheritedData, m_regionBreakInside, p); }
- void setRegionBreakAfter(EPageBreak p) { SET_VAR(rareNonInheritedData, m_regionBreakAfter, p); }
+ void setColumnRuleStyle(EBorderStyle b) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_rule.m_style, b); }
+ void setColumnRuleWidth(unsigned short w) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_rule.m_width, w); }
+ void resetColumnRule() { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_rule, BorderValue()); }
+ void setColumnSpan(ColumnSpan columnSpan) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_columnSpan, columnSpan); }
void inheritColumnPropertiesFrom(RenderStyle* parent) { rareNonInheritedData.access()->m_multiCol = parent->rareNonInheritedData->m_multiCol; }
- void setTransform(const TransformOperations& ops) { SET_VAR(rareNonInheritedData.access()->m_transform, m_operations, ops); }
- void setTransformOriginX(Length length) { SET_VAR(rareNonInheritedData.access()->m_transform, m_x, std::move(length)); }
- void setTransformOriginY(Length length) { SET_VAR(rareNonInheritedData.access()->m_transform, m_y, std::move(length)); }
- void setTransformOriginZ(float f) { SET_VAR(rareNonInheritedData.access()->m_transform, m_z, f); }
+ void setTransform(const TransformOperations& ops) { SET_NESTED_VAR(rareNonInheritedData, m_transform, m_operations, ops); }
+ void setTransformOriginX(Length length) { SET_NESTED_VAR(rareNonInheritedData, m_transform, m_x, WTFMove(length)); }
+ void setTransformOriginY(Length length) { SET_NESTED_VAR(rareNonInheritedData, m_transform, m_y, WTFMove(length)); }
+ void setTransformOriginZ(float f) { SET_NESTED_VAR(rareNonInheritedData, m_transform, m_z, f); }
void setSpeak(ESpeak s) { SET_VAR(rareInheritedData, speak, s); }
void setTextCombine(TextCombine v) { SET_VAR(rareNonInheritedData, m_textCombine, v); }
void setTextDecorationColor(const Color& c) { SET_VAR(rareNonInheritedData, m_textDecorationColor, c); }
@@ -1389,12 +1609,19 @@ public:
void setRubyPosition(RubyPosition position) { SET_VAR(rareInheritedData, m_rubyPosition, position); }
-#if ENABLE(CSS_FILTERS)
- void setFilter(const FilterOperations& ops) { SET_VAR(rareNonInheritedData.access()->m_filter, m_operations, ops); }
+ void setFilter(const FilterOperations& ops) { SET_NESTED_VAR(rareNonInheritedData, m_filter, m_operations, ops); }
+#if ENABLE(FILTERS_LEVEL_2)
+ void setBackdropFilter(const FilterOperations& ops) { SET_NESTED_VAR(rareNonInheritedData, m_backdropFilter, m_operations, ops); }
#endif
void setTabSize(unsigned size) { SET_VAR(rareInheritedData, m_tabSize, size); }
+ void setBreakBefore(BreakBetween breakBehavior) { SET_VAR(rareNonInheritedData, m_breakBefore, breakBehavior); }
+ void setBreakAfter(BreakBetween breakBehavior) { SET_VAR(rareNonInheritedData, m_breakAfter, breakBehavior); }
+ void setBreakInside(BreakInside breakBehavior) { SET_VAR(rareNonInheritedData, m_breakInside, breakBehavior); }
+
+ void setHangingPunctuation(HangingPunctuation punctuation) { SET_VAR(rareInheritedData, m_hangingPunctuation, punctuation); }
+
// End CSS3 Setters
void setLineGrid(const AtomicString& lineGrid) { SET_VAR(rareInheritedData, m_lineGrid, lineGrid); }
@@ -1405,58 +1632,74 @@ public:
void setRegionThread(const AtomicString& regionThread) { SET_VAR(rareNonInheritedData, m_regionThread, regionThread); }
void setRegionFragment(RegionFragment regionFragment) { SET_VAR(rareNonInheritedData, m_regionFragment, regionFragment); }
- void setWrapFlow(WrapFlow wrapFlow) { SET_VAR(rareNonInheritedData, m_wrapFlow, wrapFlow); }
- void setWrapThrough(WrapThrough wrapThrough) { SET_VAR(rareNonInheritedData, m_wrapThrough, wrapThrough); }
-
// Apple-specific property setters
void setPointerEvents(EPointerEvents p) { inherited_flags._pointerEvents = p; }
void clearAnimations()
{
- rareNonInheritedData.access()->m_animations.clear();
+ rareNonInheritedData.access()->m_animations = nullptr;
}
void clearTransitions()
{
- rareNonInheritedData.access()->m_transitions.clear();
+ rareNonInheritedData.access()->m_transitions = nullptr;
}
- void inheritAnimations(const AnimationList* parent) { rareNonInheritedData.access()->m_animations = parent ? adoptPtr(new AnimationList(*parent)) : nullptr; }
- void inheritTransitions(const AnimationList* parent) { rareNonInheritedData.access()->m_transitions = parent ? adoptPtr(new AnimationList(*parent)) : nullptr; }
+ void inheritAnimations(const AnimationList* parent) { rareNonInheritedData.access()->m_animations = parent ? std::make_unique<AnimationList>(*parent) : nullptr; }
+ void inheritTransitions(const AnimationList* parent) { rareNonInheritedData.access()->m_transitions = parent ? std::make_unique<AnimationList>(*parent) : nullptr; }
void adjustAnimations();
void adjustTransitions();
void setTransformStyle3D(ETransformStyle3D b) { SET_VAR(rareNonInheritedData, m_transformStyle3D, b); }
void setBackfaceVisibility(EBackfaceVisibility b) { SET_VAR(rareNonInheritedData, m_backfaceVisibility, b); }
void setPerspective(float p) { SET_VAR(rareNonInheritedData, m_perspective, p); }
- void setPerspectiveOriginX(Length length) { SET_VAR(rareNonInheritedData, m_perspectiveOriginX, std::move(length)); }
- void setPerspectiveOriginY(Length length) { SET_VAR(rareNonInheritedData, m_perspectiveOriginY, std::move(length)); }
- void setPageSize(LengthSize size) { SET_VAR(rareNonInheritedData, m_pageSize, std::move(size)); }
+ void setPerspectiveOriginX(Length length) { SET_VAR(rareNonInheritedData, m_perspectiveOriginX, WTFMove(length)); }
+ void setPerspectiveOriginY(Length length) { SET_VAR(rareNonInheritedData, m_perspectiveOriginY, WTFMove(length)); }
+ void setPageSize(LengthSize size) { SET_VAR(rareNonInheritedData, m_pageSize, WTFMove(size)); }
void setPageSizeType(PageSizeType t) { SET_VAR(rareNonInheritedData, m_pageSizeType, t); }
void resetPageSizeType() { SET_VAR(rareNonInheritedData, m_pageSizeType, PAGE_SIZE_AUTO); }
-#if USE(ACCELERATED_COMPOSITING)
void setIsRunningAcceleratedAnimation(bool b = true) { SET_VAR(rareNonInheritedData, m_runningAcceleratedAnimation, b); }
-#endif
void setLineBoxContain(LineBoxContain c) { SET_VAR(rareInheritedData, m_lineBoxContain, c); }
void setLineClamp(LineClampValue c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
+
+ void setInitialLetter(const IntSize& size) { SET_VAR(rareNonInheritedData, m_initialLetter, size); }
+
+#if ENABLE(TOUCH_EVENTS)
+ void setTouchAction(TouchAction touchAction) { SET_VAR(rareNonInheritedData, m_touchAction, static_cast<unsigned>(touchAction)); }
+#endif
+
+#if ENABLE(CSS_SCROLL_SNAP)
+ void setScrollSnapType(ScrollSnapType type) { SET_VAR(rareNonInheritedData, m_scrollSnapType, static_cast<unsigned>(type)); }
+ void setScrollSnapPointsX(std::unique_ptr<ScrollSnapPoints>);
+ void setScrollSnapPointsY(std::unique_ptr<ScrollSnapPoints>);
+ void setScrollSnapDestination(LengthSize);
+ void setScrollSnapCoordinates(Vector<LengthSize>);
+#endif
+
#if ENABLE(TOUCH_EVENTS)
void setTapHighlightColor(const Color& c) { SET_VAR(rareInheritedData, tapHighlightColor, c); }
#endif
+
#if PLATFORM(IOS)
void setTouchCalloutEnabled(bool v) { SET_VAR(rareInheritedData, touchCalloutEnabled, v); }
- void setCompositionFillColor(const Color &c) { SET_VAR(rareInheritedData, compositionFillColor, c); }
#endif
+
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
void setUseTouchOverflowScrolling(bool v) { SET_VAR(rareInheritedData, useTouchOverflowScrolling, v); }
#endif
+
#if ENABLE(IOS_TEXT_AUTOSIZING)
void setTextSizeAdjust(TextSizeAdjustment anAdjustment) { SET_VAR(rareInheritedData, textSizeAdjust, anAdjustment); }
#endif
+
void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
-#if ENABLE(SVG)
+#if ENABLE(CSS_TRAILING_WORD)
+ void setTrailingWord(TrailingWord v) { SET_VAR(rareInheritedData, trailingWord, static_cast<unsigned>(v)); }
+#endif
+
const SVGRenderStyle& svgStyle() const { return *m_svgStyle; }
SVGRenderStyle& accessSVGStyle() { return *m_svgStyle.access(); }
@@ -1471,15 +1714,30 @@ public:
void setStrokePaintColor(const Color& c) { accessSVGStyle().setStrokePaint(SVGPaint::SVG_PAINTTYPE_RGBCOLOR, c, ""); }
float strokeOpacity() const { return svgStyle().strokeOpacity(); }
void setStrokeOpacity(float f) { accessSVGStyle().setStrokeOpacity(f); }
- SVGLength strokeWidth() const { return svgStyle().strokeWidth(); }
- void setStrokeWidth(SVGLength w) { accessSVGStyle().setStrokeWidth(w); }
+ const Length& strokeWidth() const { return svgStyle().strokeWidth(); }
+ void setStrokeWidth(Length w) { accessSVGStyle().setStrokeWidth(w); }
Vector<SVGLength> strokeDashArray() const { return svgStyle().strokeDashArray(); }
void setStrokeDashArray(Vector<SVGLength> array) { accessSVGStyle().setStrokeDashArray(array); }
- SVGLength strokeDashOffset() const { return svgStyle().strokeDashOffset(); }
- void setStrokeDashOffset(SVGLength d) { accessSVGStyle().setStrokeDashOffset(d); }
+ const Length& strokeDashOffset() const { return svgStyle().strokeDashOffset(); }
+ void setStrokeDashOffset(Length d) { accessSVGStyle().setStrokeDashOffset(d); }
float strokeMiterLimit() const { return svgStyle().strokeMiterLimit(); }
void setStrokeMiterLimit(float f) { accessSVGStyle().setStrokeMiterLimit(f); }
+ const Length& cx() const { return svgStyle().cx(); }
+ void setCx(Length cx) { accessSVGStyle().setCx(cx); }
+ const Length& cy() const { return svgStyle().cy(); }
+ void setCy(Length cy) { accessSVGStyle().setCy(cy); }
+ const Length& r() const { return svgStyle().r(); }
+ void setR(Length r) { accessSVGStyle().setR(r); }
+ const Length& rx() const { return svgStyle().rx(); }
+ void setRx(Length rx) { accessSVGStyle().setRx(rx); }
+ const Length& ry() const { return svgStyle().ry(); }
+ void setRy(Length ry) { accessSVGStyle().setRy(ry); }
+ const Length& x() const { return svgStyle().x(); }
+ void setX(Length x) { accessSVGStyle().setX(x); }
+ const Length& y() const { return svgStyle().y(); }
+ void setY(Length y) { accessSVGStyle().setY(y); }
+
float floodOpacity() const { return svgStyle().floodOpacity(); }
void setFloodOpacity(float f) { accessSVGStyle().setFloodOpacity(f); }
@@ -1494,24 +1752,8 @@ public:
void setBaselineShiftValue(SVGLength s) { accessSVGStyle().setBaselineShiftValue(s); }
SVGLength kerning() const { return svgStyle().kerning(); }
void setKerning(SVGLength k) { accessSVGStyle().setKerning(k); }
-#endif
#if ENABLE(CSS_SHAPES)
- void setShapeInside(PassRefPtr<ShapeValue> value)
- {
- if (rareNonInheritedData->m_shapeInside == value)
- return;
- rareNonInheritedData.access()->m_shapeInside = value;
- }
- ShapeValue* shapeInside() const { return rareNonInheritedData->m_shapeInside.get(); }
- ShapeValue* resolvedShapeInside() const
- {
- ShapeValue* shapeInside = this->shapeInside();
- if (shapeInside && shapeInside->type() == ShapeValue::Outside)
- return shapeOutside();
- return shapeInside;
- }
-
void setShapeOutside(PassRefPtr<ShapeValue> value)
{
if (rareNonInheritedData->m_shapeOutside == value)
@@ -1520,15 +1762,10 @@ public:
}
ShapeValue* shapeOutside() const { return rareNonInheritedData->m_shapeOutside.get(); }
- static ShapeValue* initialShapeInside() { return 0; }
static ShapeValue* initialShapeOutside() { return 0; }
- const Length& shapePadding() const { return rareNonInheritedData->m_shapePadding; }
- void setShapePadding(Length shapePadding) { SET_VAR(rareNonInheritedData, m_shapePadding, std::move(shapePadding)); }
- static Length initialShapePadding() { return Length(0, Fixed); }
-
const Length& shapeMargin() const { return rareNonInheritedData->m_shapeMargin; }
- void setShapeMargin(Length shapeMargin) { SET_VAR(rareNonInheritedData, m_shapeMargin, std::move(shapeMargin)); }
+ void setShapeMargin(Length shapeMargin) { SET_VAR(rareNonInheritedData, m_shapeMargin, WTFMove(shapeMargin)); }
static Length initialShapeMargin() { return Length(0, Fixed); }
float shapeImageThreshold() const { return rareNonInheritedData->m_shapeImageThreshold; }
@@ -1547,7 +1784,7 @@ public:
}
ClipPathOperation* clipPath() const { return rareNonInheritedData->m_clipPath.get(); }
- static ClipPathOperation* initialClipPath() { return 0; }
+ static ClipPathOperation* initialClipPath() { return nullptr; }
bool hasContent() const { return contentData(); }
const ContentData* contentData() const { return rareNonInheritedData->m_content.get(); }
@@ -1567,6 +1804,17 @@ public:
QuotesData* quotes() const { return rareInheritedData->quotes.get(); }
void setQuotes(PassRefPtr<QuotesData>);
+ WillChangeData* willChange() const { return rareNonInheritedData->m_willChange.get(); }
+ void setWillChange(PassRefPtr<WillChangeData>);
+
+ bool willChangeCreatesStackingContext() const
+ {
+ if (!willChange())
+ return false;
+
+ return willChange()->canCreateStackingContext();
+ }
+
const AtomicString& hyphenString() const;
bool inheritedNotEqual(const RenderStyle*) const;
@@ -1577,12 +1825,14 @@ public:
bool equalForTextAutosizing(const RenderStyle *other) const;
#endif
- StyleDifference diff(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
- bool diffRequiresRepaint(const RenderStyle*) const;
+ StyleDifference diff(const RenderStyle&, unsigned& changedContextSensitiveProperties) const;
+ bool diffRequiresLayerRepaint(const RenderStyle&, bool isComposited) const;
bool isDisplayReplacedType() const { return isDisplayReplacedType(display()); }
bool isDisplayInlineType() const { return isDisplayInlineType(display()); }
bool isOriginalDisplayInlineType() const { return isDisplayInlineType(originalDisplay()); }
+ bool isDisplayFlexibleOrGridBox() const { return isDisplayFlexibleOrGridBox(display()); }
+ bool isDisplayFlexibleBox() const { return isDisplayFlexibleBox(display()); }
bool isDisplayRegionType() const
{
return display() == BLOCK || display() == INLINE_BLOCK
@@ -1599,82 +1849,90 @@ public:
return true;
}
+ bool hasExplicitlySetWritingMode() const { return noninherited_flags.hasExplicitlySetWritingMode(); }
+ void setHasExplicitlySetWritingMode(bool v) { noninherited_flags.setHasExplicitlySetWritingMode(v); }
+
// A unique style is one that has matches something that makes it impossible to share.
- bool unique() const { return noninherited_flags.unique; }
- void setUnique() { noninherited_flags.unique = true; }
+ bool unique() const { return noninherited_flags.isUnique(); }
+ void setUnique() { noninherited_flags.setIsUnique(); }
- bool emptyState() const { return noninherited_flags.emptyState; }
- void setEmptyState(bool b) { setUnique(); noninherited_flags.emptyState = b; }
- bool firstChildState() const { return noninherited_flags.firstChildState; }
- void setFirstChildState() { setUnique(); noninherited_flags.firstChildState = true; }
- bool lastChildState() const { return noninherited_flags.lastChildState; }
- void setLastChildState() { setUnique(); noninherited_flags.lastChildState = true; }
+ bool emptyState() const { return noninherited_flags.emptyState(); }
+ void setEmptyState(bool b) { setUnique(); noninherited_flags.setEmptyState(b); }
+ bool firstChildState() const { return noninherited_flags.firstChildState(); }
+ void setFirstChildState() { setUnique(); noninherited_flags.setFirstChildState(true); }
+ bool lastChildState() const { return noninherited_flags.lastChildState(); }
+ void setLastChildState() { setUnique(); noninherited_flags.setLastChildState(true); }
- Color visitedDependentColor(int colorProperty) const;
+ WEBCORE_EXPORT Color visitedDependentColor(int colorProperty) const;
+ bool backgroundColorEqualsToColorIgnoringVisited(const Color& color) const { return color == backgroundColor(); }
- void setHasExplicitlyInheritedProperties() { noninherited_flags.explicitInheritance = true; }
- bool hasExplicitlyInheritedProperties() const { return noninherited_flags.explicitInheritance; }
+ void setHasExplicitlyInheritedProperties() { noninherited_flags.setHasExplicitlyInheritedProperties(true); }
+ bool hasExplicitlyInheritedProperties() const { return noninherited_flags.hasExplicitlyInheritedProperties(); }
// Initial values for all the properties
+ static EOverflow initialOverflowX() { return OVISIBLE; }
+ static EOverflow initialOverflowY() { return OVISIBLE; }
+ static EClear initialClear() { return CNONE; }
+ static EDisplay initialDisplay() { return INLINE; }
+ static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
+ static EPosition initialPosition() { return StaticPosition; }
+ static EVerticalAlign initialVerticalAlign() { return BASELINE; }
+ static EFloat initialFloating() { return NoFloat; }
+ static BreakBetween initialBreakBetween() { return AutoBreakBetween; }
+ static BreakInside initialBreakInside() { return AutoBreakInside; }
+ static HangingPunctuation initialHangingPunctuation() { return NoHangingPunctuation; }
+ static ETableLayout initialTableLayout() { return TAUTO; }
static EBorderCollapse initialBorderCollapse() { return BSEPARATE; }
static EBorderStyle initialBorderStyle() { return BNONE; }
static OutlineIsAuto initialOutlineStyleIsAuto() { return AUTO_OFF; }
static NinePieceImage initialNinePieceImage() { return NinePieceImage(); }
static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed), Length(0, Fixed)); }
static ECaptionSide initialCaptionSide() { return CAPTOP; }
- static EClear initialClear() { return CNONE; }
- static ColorSpace initialColorSpace() { return ColorSpaceDeviceRGB; }
static ColumnAxis initialColumnAxis() { return AutoColumnAxis; }
static ColumnProgression initialColumnProgression() { return NormalColumnProgression; }
static TextDirection initialDirection() { return LTR; }
static WritingMode initialWritingMode() { return TopToBottomWritingMode; }
static TextCombine initialTextCombine() { return TextCombineNone; }
- static TextOrientation initialTextOrientation() { return TextOrientationVerticalRight; }
+ static TextOrientation initialTextOrientation() { return TextOrientation::
+ Mixed; }
static ObjectFit initialObjectFit() { return ObjectFitFill; }
- static EDisplay initialDisplay() { return INLINE; }
static EEmptyCell initialEmptyCells() { return SHOW; }
- static EFloat initialFloating() { return NoFloat; }
static EListStylePosition initialListStylePosition() { return OUTSIDE; }
static EListStyleType initialListStyleType() { return Disc; }
- static EOverflow initialOverflowX() { return OVISIBLE; }
- static EOverflow initialOverflowY() { return OVISIBLE; }
- static EPageBreak initialPageBreak() { return PBAUTO; }
- static EPosition initialPosition() { return StaticPosition; }
- static ETableLayout initialTableLayout() { return TAUTO; }
- static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
static ETextTransform initialTextTransform() { return TTNONE; }
static EVisibility initialVisibility() { return VISIBLE; }
static EWhiteSpace initialWhiteSpace() { return NORMAL; }
static short initialHorizontalBorderSpacing() { return 0; }
static short initialVerticalBorderSpacing() { return 0; }
- static ECursor initialCursor() { return CURSOR_AUTO; }
+ static ECursor initialCursor() { return CursorAuto; }
#if ENABLE(CURSOR_VISIBILITY)
static CursorVisibility initialCursorVisibility() { return CursorVisibilityAuto; }
#endif
static Color initialColor() { return Color::black; }
static StyleImage* initialListStyleImage() { return 0; }
- static unsigned initialBorderWidth() { return 3; }
+ static float initialBorderWidth() { return 3; }
static unsigned short initialColumnRuleWidth() { return 3; }
- static unsigned short initialOutlineWidth() { return 3; }
+ static float initialOutlineWidth() { return 3; }
static float initialLetterSpacing() { return 0; }
static Length initialWordSpacing() { return Length(Fixed); }
static Length initialSize() { return Length(); }
- static Length initialMinSize() { return Length(Fixed); }
+ static Length initialMinSize() { return Length(); }
static Length initialMaxSize() { return Length(Undefined); }
static Length initialOffset() { return Length(); }
static Length initialMargin() { return Length(Fixed); }
static Length initialPadding() { return Length(Fixed); }
static Length initialTextIndent() { return Length(Fixed); }
+ static Length initialZeroLength() { return Length(Fixed); }
+ static Length initialOneLength() { return Length(1, Fixed); }
#if ENABLE(CSS3_TEXT)
static TextIndentLine initialTextIndentLine() { return TextIndentFirstLine; }
static TextIndentType initialTextIndentType() { return TextIndentNormal; }
#endif
- static EVerticalAlign initialVerticalAlign() { return BASELINE; }
static short initialWidows() { return 2; }
static short initialOrphans() { return 2; }
- static Length initialLineHeight() { return Length(-100.0, Percent); }
+ static Length initialLineHeight() { return Length(-100.0f, Percent); }
#if ENABLE(IOS_TEXT_AUTOSIZING)
- static Length initialSpecifiedLineHeight() { return Length(-100, Percent); }
+ static Length initialSpecifiedLineHeight() { return Length(-100.0f, Percent); }
#endif
static ETextAlign initialTextAlign() { return TASTART; }
static TextDecoration initialTextDecoration() { return TextDecorationNone; }
@@ -1683,10 +1941,11 @@ public:
static TextJustify initialTextJustify() { return TextJustifyAuto; }
#endif // CSS3_TEXT
static TextDecorationStyle initialTextDecorationStyle() { return TextDecorationStyleSolid; }
- static TextDecorationSkip initialTextDecorationSkip() { return TextDecorationSkipInk; }
+ static TextDecorationSkip initialTextDecorationSkip() { return TextDecorationSkipAuto; }
static TextUnderlinePosition initialTextUnderlinePosition() { return TextUnderlinePositionAuto; }
static float initialZoom() { return 1.0f; }
- static int initialOutlineOffset() { return 0; }
+ static TextZoom initialTextZoom() { return TextZoomNormal; }
+ static float initialOutlineOffset() { return 0; }
static float initialOpacity() { return 1.0f; }
static EBoxAlignment initialBoxAlign() { return BSTRETCH; }
static EBoxDecorationBreak initialBoxDecorationBreak() { return DSLICE; }
@@ -1703,12 +1962,10 @@ public:
static float initialFlexShrink() { return 1; }
static Length initialFlexBasis() { return Length(Auto); }
static int initialOrder() { return 0; }
- static EAlignContent initialAlignContent() { return AlignContentStretch; }
- static EAlignItems initialAlignItems() { return AlignStretch; }
- static EAlignItems initialAlignSelf() { return AlignAuto; }
+ static StyleSelfAlignmentData initialSelfAlignment() { return StyleSelfAlignmentData(ItemPositionAuto, OverflowAlignmentDefault); }
+ static StyleContentAlignmentData initialContentAlignment() { return StyleContentAlignmentData(ContentPositionAuto, ContentDistributionDefault, OverflowAlignmentDefault); }
static EFlexDirection initialFlexDirection() { return FlowRow; }
static EFlexWrap initialFlexWrap() { return FlexNoWrap; }
- static EJustifyContent initialJustifyContent() { return JustifyFlexStart; }
static int initialMarqueeLoopCount() { return -1; }
static int initialMarqueeSpeed() { return 85; }
static Length initialMarqueeIncrement() { return Length(6, Fixed); }
@@ -1724,18 +1981,16 @@ public:
static EOverflowWrap initialOverflowWrap() { return NormalOverflowWrap; }
static ENBSPMode initialNBSPMode() { return NBNORMAL; }
static LineBreak initialLineBreak() { return LineBreakAuto; }
- static const AtomicString& initialHighlight() { return nullAtom; }
static ESpeak initialSpeak() { return SpeakNormal; }
static Hyphens initialHyphens() { return HyphensManual; }
static short initialHyphenationLimitBefore() { return -1; }
static short initialHyphenationLimitAfter() { return -1; }
static short initialHyphenationLimitLines() { return -1; }
static const AtomicString& initialHyphenationString() { return nullAtom; }
- static const AtomicString& initialLocale() { return nullAtom; }
static EBorderFit initialBorderFit() { return BorderFitBorder; }
static EResize initialResize() { return RESIZE_NONE; }
static ControlPart initialAppearance() { return NoControlPart; }
- static bool initialHasAspectRatio() { return false; }
+ static AspectRatioType initialAspectRatioType() { return AspectRatioAuto; }
static float initialAspectRatioDenominator() { return 1; }
static float initialAspectRatioNumerator() { return 1; }
static Order initialRTLOrdering() { return LogicalOrder; }
@@ -1743,16 +1998,16 @@ public:
static unsigned short initialColumnCount() { return 1; }
static ColumnFill initialColumnFill() { return ColumnFillBalance; }
static ColumnSpan initialColumnSpan() { return ColumnSpanNone; }
- static const TransformOperations& initialTransform() { DEFINE_STATIC_LOCAL(TransformOperations, ops, ()); return ops; }
- static Length initialTransformOriginX() { return Length(50.0, Percent); }
- static Length initialTransformOriginY() { return Length(50.0, Percent); }
+ static const TransformOperations& initialTransform() { static NeverDestroyed<TransformOperations> ops; return ops; }
+ static Length initialTransformOriginX() { return Length(50.0f, Percent); }
+ static Length initialTransformOriginY() { return Length(50.0f, Percent); }
static EPointerEvents initialPointerEvents() { return PE_AUTO; }
static float initialTransformOriginZ() { return 0; }
static ETransformStyle3D initialTransformStyle3D() { return TransformStyle3DFlat; }
static EBackfaceVisibility initialBackfaceVisibility() { return BackfaceVisibilityVisible; }
static float initialPerspective() { return 0; }
- static Length initialPerspectiveOriginX() { return Length(50.0, Percent); }
- static Length initialPerspectiveOriginY() { return Length(50.0, Percent); }
+ static Length initialPerspectiveOriginX() { return Length(50.0f, Percent); }
+ static Length initialPerspectiveOriginY() { return Length(50.0f, Percent); }
static Color initialBackgroundColor() { return Color::transparent; }
static Color initialTextEmphasisColor() { return TextEmphasisFillFilled; }
static TextEmphasisFill initialTextEmphasisFill() { return TextEmphasisFillFilled; }
@@ -1766,18 +2021,39 @@ public:
static ImageResolutionSource initialImageResolutionSource() { return ImageResolutionSpecified; }
static ImageResolutionSnap initialImageResolutionSnap() { return ImageResolutionNoSnap; }
static float initialImageResolution() { return 1; }
- static StyleImage* initialBorderImageSource() { return 0; }
- static StyleImage* initialMaskBoxImageSource() { return 0; }
+ static StyleImage* initialBorderImageSource() { return nullptr; }
+ static StyleImage* initialMaskBoxImageSource() { return nullptr; }
static PrintColorAdjust initialPrintColorAdjust() { return PrintColorAdjustEconomy; }
+ static QuotesData* initialQuotes() { return nullptr; }
+ static const AtomicString& initialContentAltText() { return emptyAtom; }
+
+ static WillChangeData* initialWillChange() { return nullptr; }
+
+#if ENABLE(TOUCH_EVENTS)
+ static TouchAction initialTouchAction() { return TouchAction::Auto; }
+#endif
+
+#if ENABLE(CSS_SCROLL_SNAP)
+ static ScrollSnapType initialScrollSnapType() { return ScrollSnapType::None; }
+ static ScrollSnapPoints* initialScrollSnapPointsX() { return nullptr; }
+ static ScrollSnapPoints* initialScrollSnapPointsY() { return nullptr; }
+ static LengthSize initialScrollSnapDestination();
+ static Vector<LengthSize> initialScrollSnapCoordinates();
+#endif
+#if ENABLE(CSS_TRAILING_WORD)
+ static TrailingWord initialTrailingWord() { return TrailingWord::Auto; }
+#endif
+
+#if ENABLE(CSS_GRID_LAYOUT)
// The initial value is 'none' for grid tracks.
static Vector<GridTrackSize> initialGridColumns() { return Vector<GridTrackSize>(); }
static Vector<GridTrackSize> initialGridRows() { return Vector<GridTrackSize>(); }
- static GridAutoFlow initialGridAutoFlow() { return AutoFlowNone; }
+ static GridAutoFlow initialGridAutoFlow() { return AutoFlowRow; }
- static GridTrackSize initialGridAutoColumns() { return GridTrackSize(Auto); }
- static GridTrackSize initialGridAutoRows() { return GridTrackSize(Auto); }
+ static GridTrackSize initialGridAutoColumns() { return GridTrackSize(Length(Auto)); }
+ static GridTrackSize initialGridAutoRows() { return GridTrackSize(Length(Auto)); }
static NamedGridAreaMap initialNamedGridArea() { return NamedGridAreaMap(); }
static size_t initialNamedGridAreaCount() { return 0; }
@@ -1785,11 +2061,18 @@ public:
static NamedGridLinesMap initialNamedGridColumnLines() { return NamedGridLinesMap(); }
static NamedGridLinesMap initialNamedGridRowLines() { return NamedGridLinesMap(); }
+ static OrderedNamedGridLinesMap initialOrderedNamedGridColumnLines() { return OrderedNamedGridLinesMap(); }
+ static OrderedNamedGridLinesMap initialOrderedNamedGridRowLines() { return OrderedNamedGridLinesMap(); }
+
+ static Length initialGridColumnGap() { return Length(Fixed); }
+ static Length initialGridRowGap() { return Length(Fixed); }
+
// 'auto' is the default.
static GridPosition initialGridItemColumnStart() { return GridPosition(); }
static GridPosition initialGridItemColumnEnd() { return GridPosition(); }
static GridPosition initialGridItemRowStart() { return GridPosition(); }
static GridPosition initialGridItemRowEnd() { return GridPosition(); }
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
static unsigned initialTabSize() { return 8; }
@@ -1801,10 +2084,8 @@ public:
static const AtomicString& initialRegionThread() { return nullAtom; }
static RegionFragment initialRegionFragment() { return AutoRegionFragment; }
- static WrapFlow initialWrapFlow() { return WrapFlowAuto; }
- static WrapThrough initialWrapThrough() { return WrapThroughWrap; }
-
// Keep these at the end.
+ static IntSize initialInitialLetter() { return IntSize(); }
static LineClampValue initialLineClamp() { return LineClampValue(); }
static ETextSecurity initialTextSecurity() { return TSNONE; }
#if ENABLE(IOS_TEXT_AUTOSIZING)
@@ -1812,7 +2093,6 @@ public:
#endif
#if PLATFORM(IOS)
static bool initialTouchCalloutEnabled() { return true; }
- static Color initialCompositionFillColor() { return Color::compositionFill; }
#endif
#if ENABLE(TOUCH_EVENTS)
static Color initialTapHighlightColor();
@@ -1824,20 +2104,25 @@ public:
static const Vector<StyleDashboardRegion>& initialDashboardRegions();
static const Vector<StyleDashboardRegion>& noneDashboardRegions();
#endif
-#if ENABLE(CSS_FILTERS)
- static const FilterOperations& initialFilter() { DEFINE_STATIC_LOCAL(FilterOperations, ops, ()); return ops; }
+ static const FilterOperations& initialFilter() { static NeverDestroyed<FilterOperations> ops; return ops; }
+#if ENABLE(FILTERS_LEVEL_2)
+ static const FilterOperations& initialBackdropFilter() { static NeverDestroyed<FilterOperations> ops; return ops; }
#endif
#if ENABLE(CSS_COMPOSITING)
static BlendMode initialBlendMode() { return BlendModeNormal; }
+ static Isolation initialIsolation() { return IsolationAuto; }
#endif
+ static ptrdiff_t noninheritedFlagsMemoryOffset() { return OBJECT_OFFSETOF(RenderStyle, noninherited_flags); }
+
private:
- bool changeRequiresLayout(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
- bool changeRequiresPositionedLayoutOnly(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
- bool changeRequiresLayerRepaint(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
- bool changeRequiresRepaint(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
- bool changeRequiresRepaintIfTextOrBorderOrOutline(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
- bool changeRequiresRecompositeLayer(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
+ bool changeAffectsVisualOverflow(const RenderStyle&) const;
+ bool changeRequiresLayout(const RenderStyle&, unsigned& changedContextSensitiveProperties) const;
+ bool changeRequiresPositionedLayoutOnly(const RenderStyle&, unsigned& changedContextSensitiveProperties) const;
+ bool changeRequiresLayerRepaint(const RenderStyle&, unsigned& changedContextSensitiveProperties) const;
+ bool changeRequiresRepaint(const RenderStyle&, unsigned& changedContextSensitiveProperties) const;
+ bool changeRequiresRepaintIfTextOrBorderOrOutline(const RenderStyle&, unsigned& changedContextSensitiveProperties) const;
+ bool changeRequiresRecompositeLayer(const RenderStyle&, unsigned& changedContextSensitiveProperties) const;
void setVisitedLinkColor(const Color&);
void setVisitedLinkBackgroundColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBackgroundColor, v); }
@@ -1846,13 +2131,13 @@ private:
void setVisitedLinkBorderBottomColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderBottomColor, v); }
void setVisitedLinkBorderTopColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderTopColor, v); }
void setVisitedLinkOutlineColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkOutlineColor, v); }
- void setVisitedLinkColumnRuleColor(const Color& v) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_visitedLinkColumnRuleColor, v); }
+ void setVisitedLinkColumnRuleColor(const Color& v) { SET_NESTED_VAR(rareNonInheritedData, m_multiCol, m_visitedLinkColumnRuleColor, v); }
void setVisitedLinkTextDecorationColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkTextDecorationColor, v); }
void setVisitedLinkTextEmphasisColor(const Color& v) { SET_VAR(rareInheritedData, visitedLinkTextEmphasisColor, v); }
void setVisitedLinkTextFillColor(const Color& v) { SET_VAR(rareInheritedData, visitedLinkTextFillColor, v); }
void setVisitedLinkTextStrokeColor(const Color& v) { SET_VAR(rareInheritedData, visitedLinkTextStrokeColor, v); }
- void inheritUnicodeBidiFrom(const RenderStyle* parent) { noninherited_flags._unicodeBidi = parent->noninherited_flags._unicodeBidi; }
+ void inheritUnicodeBidiFrom(const RenderStyle* parent) { noninherited_flags.setUnicodeBidi(parent->noninherited_flags.unicodeBidi()); }
void getShadowExtent(const ShadowData*, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const;
LayoutBoxExtent getShadowInsetExtent(const ShadowData*) const;
void getShadowHorizontalExtent(const ShadowData*, LayoutUnit& left, LayoutUnit& right) const;
@@ -1869,7 +2154,10 @@ private:
bool isDisplayReplacedType(EDisplay display) const
{
return display == INLINE_BLOCK || display == INLINE_BOX || display == INLINE_FLEX
- || display == INLINE_TABLE || display == INLINE_GRID;
+#if ENABLE(CSS_GRID_LAYOUT)
+ || display == INLINE_GRID
+#endif
+ || display == INLINE_TABLE;
}
bool isDisplayInlineType(EDisplay display) const
@@ -1877,8 +2165,28 @@ private:
return display == INLINE || isDisplayReplacedType(display);
}
+ bool isDisplayFlexibleBox(EDisplay display) const
+ {
+ return display == FLEX || display == INLINE_FLEX;
+ }
+
+ bool isDisplayGridBox(EDisplay display) const
+ {
+#if ENABLE(CSS_GRID_LAYOUT)
+ return display == GRID || display == INLINE_GRID;
+#else
+ UNUSED_PARAM(display);
+ return false;
+#endif
+ }
+
+ bool isDisplayFlexibleOrGridBox(EDisplay display) const
+ {
+ return isDisplayFlexibleBox(display) || isDisplayGridBox(display);
+ }
+
// Color accessors are all private to make sure callers use visitedDependentColor instead to access them.
- Color invalidColor() const { static Color invalid; return invalid; }
+ static Color invalidColor() { return Color(); }
Color borderLeftColor() const { return surround->border.left().color(); }
Color borderRightColor() const { return surround->border.right().color(); }
Color borderTopColor() const { return surround->border.top().color(); }
@@ -1906,11 +2214,9 @@ private:
Color colorIncludingFallback(int colorProperty, bool visitedLink) const;
-#if ENABLE(SVG)
Color stopColor() const { return svgStyle().stopColor(); }
Color floodColor() const { return svgStyle().floodColor(); }
Color lightingColor() const { return svgStyle().lightingColor(); }
-#endif
void appendContent(std::unique_ptr<ContentData>);
};
@@ -1931,24 +2237,31 @@ inline int adjustForAbsoluteZoom(int value, const RenderStyle& style)
return roundForImpreciseConversion<int>(value / zoomFactor);
}
-inline float adjustFloatForAbsoluteZoom(float value, const RenderStyle* style)
+inline float adjustFloatForAbsoluteZoom(float value, const RenderStyle& style)
{
- return value / style->effectiveZoom();
+ return value / style.effectiveZoom();
}
-#if ENABLE(SUBPIXEL_LAYOUT)
inline LayoutUnit adjustLayoutUnitForAbsoluteZoom(LayoutUnit value, const RenderStyle& style)
{
return value / style.effectiveZoom();
}
-#endif
+
+inline EBorderStyle collapsedBorderStyle(EBorderStyle style)
+{
+ if (style == OUTSET)
+ return GROOVE;
+ if (style == INSET)
+ return RIDGE;
+ return style;
+}
inline bool RenderStyle::setZoom(float f)
{
+ setEffectiveZoom(effectiveZoom() * f);
if (compareEqual(visual->m_zoom, f))
return false;
visual.access()->m_zoom = f;
- setEffectiveZoom(effectiveZoom() * zoom());
return true;
}
@@ -1962,30 +2275,31 @@ inline bool RenderStyle::setEffectiveZoom(float f)
inline bool RenderStyle::setTextOrientation(TextOrientation textOrientation)
{
- if (compareEqual(rareInheritedData->m_textOrientation, textOrientation))
+ if (compareEqual(rareInheritedData->m_textOrientation, static_cast<unsigned>(textOrientation)))
return false;
- rareInheritedData.access()->m_textOrientation = textOrientation;
+ rareInheritedData.access()->m_textOrientation = static_cast<unsigned>(textOrientation);
return true;
}
inline bool RenderStyle::hasAnyPublicPseudoStyles() const
{
- return PUBLIC_PSEUDOID_MASK & noninherited_flags._pseudoBits;
+ return noninherited_flags.hasAnyPublicPseudoStyles();
}
inline bool RenderStyle::hasPseudoStyle(PseudoId pseudo) const
{
- ASSERT(pseudo > NOPSEUDO);
- ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID);
- return (1 << (pseudo - 1)) & noninherited_flags._pseudoBits;
+ return noninherited_flags.hasPseudoStyle(pseudo);
}
inline void RenderStyle::setHasPseudoStyle(PseudoId pseudo)
{
- ASSERT(pseudo > NOPSEUDO);
- ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID);
- noninherited_flags._pseudoBits |= 1 << (pseudo - 1);
+ noninherited_flags.setHasPseudoStyle(pseudo);
+}
+
+inline void RenderStyle::setHasPseudoStyles(PseudoIdSet pseudoIdSet)
+{
+ noninherited_flags.setHasPseudoStyles(pseudoIdSet);
}
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/RenderStyleConstants.cpp b/Source/WebCore/rendering/style/RenderStyleConstants.cpp
new file mode 100644
index 000000000..f13cd7bd9
--- /dev/null
+++ b/Source/WebCore/rendering/style/RenderStyleConstants.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2015 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 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 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 "RenderStyleConstants.h"
+
+#include "TextStream.h"
+
+namespace WebCore {
+
+TextStream& operator<<(TextStream& ts, EFillSizeType sizeType)
+{
+ switch (sizeType) {
+ case Contain: ts << "contain"; break;
+ case Cover: ts << "cover"; break;
+ case SizeLength: ts << "size-length"; break;
+ case SizeNone: ts << "size-none"; break;
+ }
+
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, EFillAttachment attachment)
+{
+ switch (attachment) {
+ case ScrollBackgroundAttachment: ts << "scroll"; break;
+ case LocalBackgroundAttachment: ts << "local"; break;
+ case FixedBackgroundAttachment: ts << "fixed"; break;
+ }
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, EFillBox fill)
+{
+ switch (fill) {
+ case BorderFillBox: ts << "border"; break;
+ case PaddingFillBox: ts << "padding"; break;
+ case ContentFillBox: ts << "content"; break;
+ case TextFillBox: ts << "text"; break;
+ }
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, EFillRepeat repeat)
+{
+ switch (repeat) {
+ case RepeatFill: ts << "repeat"; break;
+ case NoRepeatFill: ts << "no-repeat"; break;
+ case RoundFill: ts << "round"; break;
+ case SpaceFill: ts << "space"; break;
+ }
+
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, EMaskSourceType maskSource)
+{
+ switch (maskSource) {
+ case MaskAlpha: ts << "alpha"; break;
+ case MaskLuminance: ts << "luminance"; break;
+ }
+
+ return ts;
+}
+
+TextStream& operator<<(TextStream& ts, Edge edge)
+{
+ switch (edge) {
+ case Edge::Top: ts << "top"; break;
+ case Edge::Right: ts << "right"; break;
+ case Edge::Bottom: ts << "bottom"; break;
+ case Edge::Left: ts << "left"; break;
+ }
+ return ts;
+}
+
+bool alwaysPageBreak(BreakBetween between)
+{
+ return between >= PageBreakBetween;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/RenderStyleConstants.h b/Source/WebCore/rendering/style/RenderStyleConstants.h
index 11b428559..492f78c4d 100644
--- a/Source/WebCore/rendering/style/RenderStyleConstants.h
+++ b/Source/WebCore/rendering/style/RenderStyleConstants.h
@@ -26,8 +26,12 @@
#ifndef RenderStyleConstants_h
#define RenderStyleConstants_h
+#include <initializer_list>
+
namespace WebCore {
+class TextStream;
+
static const size_t PrintColorAdjustBits = 1;
enum PrintColorAdjust {
PrintColorAdjustEconomy,
@@ -46,16 +50,15 @@ enum PrintColorAdjust {
// - StyleDifferenceLayout - A full layout is required.
enum StyleDifference {
StyleDifferenceEqual,
-#if USE(ACCELERATED_COMPOSITING)
StyleDifferenceRecompositeLayer,
-#endif
StyleDifferenceRepaint,
StyleDifferenceRepaintIfTextOrBorderOrOutline,
StyleDifferenceRepaintLayer,
StyleDifferenceLayoutPositionedMovementOnly,
StyleDifferenceSimplifiedLayout,
StyleDifferenceSimplifiedLayoutAndPositionedMovement,
- StyleDifferenceLayout
+ StyleDifferenceLayout,
+ StyleDifferenceNewStyle
};
// When some style properties change, different amounts of work have to be done depending on
@@ -63,26 +66,91 @@ enum StyleDifference {
// A simple StyleDifference does not provide enough information so we return a bit mask of
// StyleDifferenceContextSensitiveProperties from RenderStyle::diff() too.
enum StyleDifferenceContextSensitiveProperty {
- ContextSensitivePropertyNone = 0,
- ContextSensitivePropertyTransform = (1 << 0),
- ContextSensitivePropertyOpacity = (1 << 1),
- ContextSensitivePropertyFilter = (1 << 2)
+ ContextSensitivePropertyNone = 0,
+ ContextSensitivePropertyTransform = 1 << 0,
+ ContextSensitivePropertyOpacity = 1 << 1,
+ ContextSensitivePropertyFilter = 1 << 2,
+ ContextSensitivePropertyClipRect = 1 << 3,
+ ContextSensitivePropertyClipPath = 1 << 4,
+ ContextSensitivePropertyWillChange = 1 << 5,
};
// Static pseudo styles. Dynamic ones are produced on the fly.
-enum PseudoId {
+enum PseudoId : unsigned char {
// The order must be NOP ID, public IDs, and then internal IDs.
NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, SCROLLBAR,
// Internal IDs follow:
SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER,
- INPUT_LIST_BUTTON,
AFTER_LAST_INTERNAL_PSEUDOID,
- FULL_SCREEN, FULL_SCREEN_DOCUMENT, FULL_SCREEN_ANCESTOR, ANIMATING_FULL_SCREEN_TRANSITION,
FIRST_PUBLIC_PSEUDOID = FIRST_LINE,
FIRST_INTERNAL_PSEUDOID = SCROLLBAR_THUMB,
PUBLIC_PSEUDOID_MASK = ((1 << FIRST_INTERNAL_PSEUDOID) - 1) & ~((1 << FIRST_PUBLIC_PSEUDOID) - 1)
};
+class PseudoIdSet {
+public:
+ PseudoIdSet()
+ : m_data(0)
+ {
+ }
+
+ PseudoIdSet(std::initializer_list<PseudoId> initializerList)
+ : m_data(0)
+ {
+ for (PseudoId pseudoId : initializerList)
+ add(pseudoId);
+ }
+
+ static PseudoIdSet fromMask(unsigned rawPseudoIdSet)
+ {
+ return PseudoIdSet(rawPseudoIdSet);
+ }
+
+ bool has(PseudoId pseudoId) const
+ {
+ ASSERT((sizeof(m_data) * 8) > pseudoId);
+ return m_data & (1U << pseudoId);
+ }
+
+ void add(PseudoId pseudoId)
+ {
+ ASSERT((sizeof(m_data) * 8) > pseudoId);
+ m_data |= (1U << pseudoId);
+ }
+
+ void merge(PseudoIdSet source)
+ {
+ m_data |= source.m_data;
+ }
+
+ PseudoIdSet operator &(const PseudoIdSet& pseudoIdSet) const
+ {
+ return PseudoIdSet(m_data & pseudoIdSet.m_data);
+ }
+
+ PseudoIdSet operator |(const PseudoIdSet& pseudoIdSet) const
+ {
+ return PseudoIdSet(m_data | pseudoIdSet.m_data);
+ }
+
+ explicit operator bool() const
+ {
+ return m_data;
+ }
+
+ unsigned data() const { return m_data; }
+
+ static ptrdiff_t dataMemoryOffset() { return OBJECT_OFFSETOF(PseudoIdSet, m_data); }
+
+private:
+ explicit PseudoIdSet(unsigned rawPseudoIdSet)
+ : m_data(rawPseudoIdSet)
+ {
+ }
+
+ unsigned m_data;
+};
+
enum ColumnFill { ColumnFillBalance, ColumnFillAuto };
enum ColumnSpan { ColumnSpanNone = 0, ColumnSpanAll };
@@ -162,8 +230,8 @@ enum EFillLayerType {
// CSS3 Background Values
enum EFillSizeType { Contain, Cover, SizeLength, SizeNone };
-// CSS3 Background Position
-enum BackgroundEdgeOrigin { TopEdge, RightEdge, BottomEdge, LeftEdge };
+// CSS3 <position>
+enum class Edge { Top, Right, Bottom, Left };
// CSS3 Mask Source Types
enum EMaskSourceType { MaskAlpha, MaskLuminance };
@@ -184,10 +252,13 @@ enum EBoxDirection { BNORMAL, BREVERSE };
// CSS3 Flexbox Properties
enum EAlignContent { AlignContentFlexStart, AlignContentFlexEnd, AlignContentCenter, AlignContentSpaceBetween, AlignContentSpaceAround, AlignContentStretch };
-enum EAlignItems { AlignAuto, AlignFlexStart, AlignFlexEnd, AlignCenter, AlignStretch, AlignBaseline };
enum EFlexDirection { FlowRow, FlowRowReverse, FlowColumn, FlowColumnReverse };
enum EFlexWrap { FlexNoWrap, FlexWrap, FlexWrapReverse };
-enum EJustifyContent { JustifyFlexStart, JustifyFlexEnd, JustifyCenter, JustifySpaceBetween, JustifySpaceAround };
+enum ItemPosition {ItemPositionAuto, ItemPositionStretch, ItemPositionBaseline, ItemPositionLastBaseline, ItemPositionCenter, ItemPositionStart, ItemPositionEnd, ItemPositionSelfStart, ItemPositionSelfEnd, ItemPositionFlexStart, ItemPositionFlexEnd, ItemPositionLeft, ItemPositionRight};
+enum OverflowAlignment {OverflowAlignmentDefault, OverflowAlignmentUnsafe, OverflowAlignmentSafe};
+enum ItemPositionType {NonLegacyPosition, LegacyPosition};
+enum ContentPosition {ContentPositionAuto, ContentPositionBaseline, ContentPositionLastBaseline, ContentPositionCenter, ContentPositionStart, ContentPositionEnd, ContentPositionFlexStart, ContentPositionFlexEnd, ContentPositionLeft, ContentPositionRight};
+enum ContentDistributionType {ContentDistributionDefault, ContentDistributionSpaceBetween, ContentDistributionSpaceAround, ContentDistributionSpaceEvenly, ContentDistributionStretch};
enum ETextSecurity {
TSNONE, TSDISC, TSCIRCLE, TSSQUARE
@@ -216,10 +287,12 @@ enum ObjectFit {
ObjectFitFill, ObjectFitContain, ObjectFitCover, ObjectFitNone, ObjectFitScaleDown
};
-// Word Break Values. Matches WinIE, rather than CSS3
+enum AspectRatioType {
+ AspectRatioAuto, AspectRatioFromIntrinsic, AspectRatioFromDimensions, AspectRatioSpecified
+};
enum EWordBreak {
- NormalWordBreak, BreakAllWordBreak, BreakWordBreak
+ NormalWordBreak, BreakAllWordBreak, KeepAllWordBreak, BreakWordBreak
};
enum EOverflowWrap {
@@ -381,13 +454,15 @@ enum TextAlignLast {
};
enum TextJustify {
- TextJustifyAuto, TextJustifyNone, TextJustifyInterWord, TextJustifyInterIdeograph, TextJustifyInterCluster, TextJustifyDistribute, TextJustifyKashida
+ TextJustifyAuto, TextJustifyNone, TextJustifyInterWord, TextJustifyDistribute
};
#endif // CSS3_TEXT
enum TextDecorationSkipItems {
TextDecorationSkipNone = 0,
- TextDecorationSkipInk = 1 << 0
+ TextDecorationSkipInk = 1 << 0,
+ TextDecorationSkipObjects = 1 << 1,
+ TextDecorationSkipAuto = 1 << 2
};
typedef unsigned TextDecorationSkip;
@@ -396,10 +471,29 @@ enum TextUnderlinePosition {
TextUnderlinePositionAuto = 0x1, TextUnderlinePositionAlphabetic = 0x2, TextUnderlinePositionUnder = 0x4
};
-enum EPageBreak {
- PBAUTO, PBALWAYS, PBAVOID
+enum TextZoom {
+ TextZoomNormal, TextZoomReset
};
+enum BreakBetween {
+ AutoBreakBetween, AvoidBreakBetween, AvoidColumnBreakBetween, AvoidPageBreakBetween, AvoidRegionBreakBetween, ColumnBreakBetween, RegionBreakBetween, PageBreakBetween, LeftPageBreakBetween, RightPageBreakBetween, RectoPageBreakBetween, VersoPageBreakBetween
+};
+bool alwaysPageBreak(BreakBetween);
+
+enum BreakInside {
+ AutoBreakInside, AvoidBreakInside, AvoidColumnBreakInside, AvoidPageBreakInside, AvoidRegionBreakInside
+};
+
+enum HangingPunctuation {
+ NoHangingPunctuation = 0,
+ FirstHangingPunctuation = 1 << 0,
+ LastHangingPunctuation = 1 << 1,
+ AllowEndHangingPunctuation = 1 << 2,
+ ForceEndHangingPunctuation = 1 << 3
+};
+inline HangingPunctuation operator| (HangingPunctuation a, HangingPunctuation b) { return HangingPunctuation(int(a) | int(b)); }
+inline HangingPunctuation& operator|= (HangingPunctuation& a, HangingPunctuation b) { return a = a | b; }
+
enum EEmptyCell {
SHOW, HIDE
};
@@ -414,44 +508,44 @@ enum EVisibility { VISIBLE, HIDDEN, COLLAPSE };
enum ECursor {
// The following must match the order in CSSValueKeywords.in.
- CURSOR_AUTO,
- CURSOR_CROSS,
- CURSOR_DEFAULT,
- CURSOR_POINTER,
- CURSOR_MOVE,
- CURSOR_VERTICAL_TEXT,
- CURSOR_CELL,
- CURSOR_CONTEXT_MENU,
- CURSOR_ALIAS,
- CURSOR_PROGRESS,
- CURSOR_NO_DROP,
- CURSOR_NOT_ALLOWED,
- CURSOR_WEBKIT_ZOOM_IN,
- CURSOR_WEBKIT_ZOOM_OUT,
- CURSOR_E_RESIZE,
- CURSOR_NE_RESIZE,
- CURSOR_NW_RESIZE,
- CURSOR_N_RESIZE,
- CURSOR_SE_RESIZE,
- CURSOR_SW_RESIZE,
- CURSOR_S_RESIZE,
- CURSOR_W_RESIZE,
- CURSOR_EW_RESIZE,
- CURSOR_NS_RESIZE,
- CURSOR_NESW_RESIZE,
- CURSOR_NWSE_RESIZE,
- CURSOR_COL_RESIZE,
- CURSOR_ROW_RESIZE,
- CURSOR_TEXT,
- CURSOR_WAIT,
- CURSOR_HELP,
- CURSOR_ALL_SCROLL,
- CURSOR_WEBKIT_GRAB,
- CURSOR_WEBKIT_GRABBING,
+ CursorAuto,
+ CursorCross,
+ CursorDefault,
+ CursorPointer,
+ CursorMove,
+ CursorVerticalText,
+ CursorCell,
+ CursorContextMenu,
+ CursorAlias,
+ CursorProgress,
+ CursorNoDrop,
+ CursorNotAllowed,
+ CursorZoomIn,
+ CursorZoomOut,
+ CursorEResize,
+ CursorNeResize,
+ CursorNwResize,
+ CursorNResize,
+ CursorSeResize,
+ CursorSwResize,
+ CursorSResize,
+ CursorWResize,
+ CursorEwResize,
+ CursorNsResize,
+ CursorNeswResize,
+ CursorNwseResize,
+ CursorColResize,
+ CursorRowResize,
+ CursorText,
+ CursorWait,
+ CursorHelp,
+ CursorAllScroll,
+ CursorWebkitGrab,
+ CursorWebkitGrabbing,
// The following are handled as exceptions so don't need to match.
- CURSOR_COPY,
- CURSOR_NONE
+ CursorCopy,
+ CursorNone
};
#if ENABLE(CURSOR_VISIBILITY)
@@ -463,13 +557,15 @@ enum CursorVisibility {
// The order of this enum must match the order of the display values in CSSValueKeywords.in.
enum EDisplay {
- INLINE, BLOCK, LIST_ITEM, RUN_IN, COMPACT, INLINE_BLOCK,
+ INLINE, BLOCK, LIST_ITEM, COMPACT, INLINE_BLOCK,
TABLE, INLINE_TABLE, TABLE_ROW_GROUP,
TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW,
TABLE_COLUMN_GROUP, TABLE_COLUMN, TABLE_CELL,
TABLE_CAPTION, BOX, INLINE_BOX,
- FLEX, INLINE_FLEX,
+ FLEX, WEBKIT_FLEX, INLINE_FLEX, WEBKIT_INLINE_FLEX,
+#if ENABLE(CSS_GRID_LAYOUT)
GRID, INLINE_GRID,
+#endif
NONE
};
@@ -508,11 +604,17 @@ enum TextEmphasisPositions {
};
typedef unsigned TextEmphasisPosition;
-enum TextOrientation { TextOrientationVerticalRight, TextOrientationUpright, TextOrientationSideways, TextOrientationSidewaysRight };
+enum class TextOrientation { Mixed, Upright, Sideways };
enum TextOverflow { TextOverflowClip = 0, TextOverflowEllipsis };
-enum EImageRendering { ImageRenderingAuto = 0, ImageRenderingOptimizeSpeed, ImageRenderingOptimizeQuality, ImageRenderingCrispEdges };
+enum EImageRendering {
+ ImageRenderingAuto = 0,
+ ImageRenderingOptimizeSpeed,
+ ImageRenderingOptimizeQuality,
+ ImageRenderingCrispEdges,
+ ImageRenderingPixelated
+};
enum ImageResolutionSource { ImageResolutionSpecified = 0, ImageResolutionFromImage };
@@ -530,13 +632,27 @@ enum LineSnap { LineSnapNone, LineSnapBaseline, LineSnapContain };
enum LineAlign { LineAlignNone, LineAlignEdges };
-enum WrapFlow { WrapFlowAuto, WrapFlowBoth, WrapFlowStart, WrapFlowEnd, WrapFlowMaximum, WrapFlowClear };
+enum RubyPosition { RubyPositionBefore, RubyPositionAfter, RubyPositionInterCharacter };
-enum WrapThrough { WrapThroughWrap, WrapThroughNone };
+#if ENABLE(CSS_GRID_LAYOUT)
+static const size_t GridAutoFlowBits = 4;
+enum InternalGridAutoFlowAlgorithm {
+ InternalAutoFlowAlgorithmSparse = 0x1,
+ InternalAutoFlowAlgorithmDense = 0x2,
+};
-enum RubyPosition { RubyPositionBefore, RubyPositionAfter };
+enum InternalGridAutoFlowDirection {
+ InternalAutoFlowDirectionRow = 0x4,
+ InternalAutoFlowDirectionColumn = 0x8
+};
-enum GridAutoFlow { AutoFlowNone, AutoFlowColumn, AutoFlowRow };
+enum GridAutoFlow {
+ AutoFlowRow = InternalAutoFlowAlgorithmSparse | InternalAutoFlowDirectionRow,
+ AutoFlowColumn = InternalAutoFlowAlgorithmSparse | InternalAutoFlowDirectionColumn,
+ AutoFlowRowDense = InternalAutoFlowAlgorithmDense | InternalAutoFlowDirectionRow,
+ AutoFlowColumnDense = InternalAutoFlowAlgorithmDense | InternalAutoFlowDirectionColumn
+};
+#endif
// Reasonable maximum to prevent insane font sizes from causing crashes on some platforms (such as Windows).
static const float maximumAllowedFontSize = 1000000.0f;
@@ -546,7 +662,39 @@ enum TextIndentLine { TextIndentFirstLine, TextIndentEachLine };
enum TextIndentType { TextIndentNormal, TextIndentHanging };
#endif
-enum LayoutBox { BoxMissing = 0, MarginBox, BorderBox, PaddingBox, ContentBox, BoundingBox };
+enum Isolation { IsolationAuto, IsolationIsolate };
+
+// Fill, Stroke, ViewBox are just used for SVG.
+enum CSSBoxType { BoxMissing = 0, MarginBox, BorderBox, PaddingBox, ContentBox, Fill, Stroke, ViewBox };
+
+#if ENABLE(TOUCH_EVENTS)
+enum class TouchAction {
+ Auto,
+ Manipulation
+};
+#endif
+
+#if ENABLE(CSS_SCROLL_SNAP)
+enum class ScrollSnapType {
+ None,
+ Proximity,
+ Mandatory
+};
+#endif
+
+#if ENABLE(CSS_TRAILING_WORD)
+enum class TrailingWord {
+ Auto,
+ PartiallyBalanced
+};
+#endif
+
+TextStream& operator<<(TextStream&, EFillSizeType);
+TextStream& operator<<(TextStream&, EFillAttachment);
+TextStream& operator<<(TextStream&, EFillBox);
+TextStream& operator<<(TextStream&, EFillRepeat);
+TextStream& operator<<(TextStream&, EMaskSourceType);
+TextStream& operator<<(TextStream&, Edge);
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/SVGRenderStyle.cpp b/Source/WebCore/rendering/style/SVGRenderStyle.cpp
index 06c793f69..df79aff65 100644
--- a/Source/WebCore/rendering/style/SVGRenderStyle.cpp
+++ b/Source/WebCore/rendering/style/SVGRenderStyle.cpp
@@ -7,7 +7,7 @@
Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org)
- Copyright (C) 2002 Apple Computer, Inc.
+ Copyright (C) 2002 Apple Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -26,8 +26,6 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGRenderStyle.h"
#include "CSSPrimitiveValue.h"
@@ -45,7 +43,7 @@ static const SVGRenderStyle& defaultSVGStyle()
return *style.get().get();
}
-PassRef<SVGRenderStyle> SVGRenderStyle::createDefaultStyle()
+Ref<SVGRenderStyle> SVGRenderStyle::createDefaultStyle()
{
return adoptRef(*new SVGRenderStyle(CreateDefault));
}
@@ -58,6 +56,7 @@ SVGRenderStyle::SVGRenderStyle()
, stops(defaultSVGStyle().stops)
, misc(defaultSVGStyle().misc)
, shadowSVG(defaultSVGStyle().shadowSVG)
+ , layout(defaultSVGStyle().layout)
, resources(defaultSVGStyle().resources)
{
setBitDefaults();
@@ -71,6 +70,7 @@ SVGRenderStyle::SVGRenderStyle(CreateDefaultType)
, stops(StyleStopData::create())
, misc(StyleMiscData::create())
, shadowSVG(StyleShadowSVGData::create())
+ , layout(StyleLayoutData::create())
, resources(StyleResourceData::create())
{
setBitDefaults();
@@ -87,11 +87,12 @@ inline SVGRenderStyle::SVGRenderStyle(const SVGRenderStyle& other)
, stops(other.stops)
, misc(other.misc)
, shadowSVG(other.shadowSVG)
+ , layout(other.layout)
, resources(other.resources)
{
}
-PassRef<SVGRenderStyle> SVGRenderStyle::copy() const
+Ref<SVGRenderStyle> SVGRenderStyle::copy() const
{
return adoptRef(*new SVGRenderStyle(*this));
}
@@ -108,6 +109,7 @@ bool SVGRenderStyle::operator==(const SVGRenderStyle& other) const
&& stops == other.stops
&& misc == other.misc
&& shadowSVG == other.shadowSVG
+ && layout == other.layout
&& inheritedResources == other.inheritedResources
&& resources == other.resources
&& svg_inherited_flags == other.svg_inherited_flags
@@ -142,9 +144,50 @@ void SVGRenderStyle::copyNonInheritedFrom(const SVGRenderStyle* other)
stops = other->stops;
misc = other->misc;
shadowSVG = other->shadowSVG;
+ layout = other->layout;
resources = other->resources;
}
+Vector<PaintType, 3> SVGRenderStyle::paintTypesForPaintOrder() const
+{
+ Vector<PaintType, 3> paintOrder;
+ switch (this->paintOrder()) {
+ case PaintOrderNormal:
+ FALLTHROUGH;
+ case PaintOrderFill:
+ paintOrder.append(PaintTypeFill);
+ paintOrder.append(PaintTypeStroke);
+ paintOrder.append(PaintTypeMarkers);
+ break;
+ case PaintOrderFillMarkers:
+ paintOrder.append(PaintTypeFill);
+ paintOrder.append(PaintTypeMarkers);
+ paintOrder.append(PaintTypeStroke);
+ break;
+ case PaintOrderStroke:
+ paintOrder.append(PaintTypeStroke);
+ paintOrder.append(PaintTypeFill);
+ paintOrder.append(PaintTypeMarkers);
+ break;
+ case PaintOrderStrokeMarkers:
+ paintOrder.append(PaintTypeStroke);
+ paintOrder.append(PaintTypeMarkers);
+ paintOrder.append(PaintTypeFill);
+ break;
+ case PaintOrderMarkers:
+ paintOrder.append(PaintTypeMarkers);
+ paintOrder.append(PaintTypeFill);
+ paintOrder.append(PaintTypeStroke);
+ break;
+ case PaintOrderMarkersStroke:
+ paintOrder.append(PaintTypeMarkers);
+ paintOrder.append(PaintTypeStroke);
+ paintOrder.append(PaintTypeFill);
+ break;
+ };
+ return paintOrder;
+}
+
StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
{
// NOTE: All comparisions that may return StyleDifferenceLayout have to go before those who return StyleDifferenceRepaint
@@ -185,6 +228,10 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
if (shadowSVG != other->shadowSVG)
return StyleDifferenceLayout;
+ // The x or y properties require relayout.
+ if (layout != other->layout)
+ return StyleDifferenceLayout;
+
// Some stroke properties, requires relayouts, as the cached stroke boundaries need to be recalculated.
if (stroke != other->stroke) {
if (stroke->width != other->stroke->width
@@ -204,6 +251,10 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
return StyleDifferenceRepaint;
}
+ // vector-effect changes require a re-layout.
+ if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags.f._vectorEffect)
+ return StyleDifferenceLayout;
+
// NOTE: All comparisions below may only return StyleDifferenceRepaint
// Painting related properties only need repaints.
@@ -232,10 +283,6 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
|| svg_inherited_flags._colorInterpolationFilters != other->svg_inherited_flags._colorInterpolationFilters)
return StyleDifferenceRepaint;
- // FIXME: vector-effect is not taken into account in the layout-phase. Once this is fixed, we should relayout here.
- if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags.f._vectorEffect)
- return StyleDifferenceRepaint;
-
if (svg_noninherited_flags.f.bufferedRendering != other->svg_noninherited_flags.f.bufferedRendering)
return StyleDifferenceRepaint;
@@ -246,5 +293,3 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
}
}
-
-#endif // ENABLE(SVG)
diff --git a/Source/WebCore/rendering/style/SVGRenderStyle.h b/Source/WebCore/rendering/style/SVGRenderStyle.h
index ff07db54c..1eff35685 100644
--- a/Source/WebCore/rendering/style/SVGRenderStyle.h
+++ b/Source/WebCore/rendering/style/SVGRenderStyle.h
@@ -1,8 +1,9 @@
/*
Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005 Rob Buis <buis@kde.org>
- Copyright (C) 2005, 2006 Apple Computer, Inc.
+ Copyright (C) 2005, 2006 Apple Inc.
Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ Copyright (C) 2014 Adobe Systems Incorporated. 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
@@ -23,7 +24,6 @@
#ifndef SVGRenderStyle_h
#define SVGRenderStyle_h
-#if ENABLE(SVG)
#include "CSSValueList.h"
#include "DataRef.h"
#include "ExceptionCodePlaceholder.h"
@@ -41,9 +41,9 @@ class RenderObject;
class SVGRenderStyle : public RefCounted<SVGRenderStyle> {
public:
- static PassRef<SVGRenderStyle> createDefaultStyle();
- static PassRef<SVGRenderStyle> create() { return adoptRef(*new SVGRenderStyle); }
- PassRef<SVGRenderStyle> copy() const;
+ static Ref<SVGRenderStyle> createDefaultStyle();
+ static Ref<SVGRenderStyle> create() { return adoptRef(*new SVGRenderStyle); }
+ Ref<SVGRenderStyle> copy() const;
~SVGRenderStyle();
bool inheritedNotEqual(const SVGRenderStyle*) const;
@@ -90,12 +90,12 @@ public:
static Color initialLightingColor() { return Color(255, 255, 255); }
static ShadowData* initialShadow() { return 0; }
static String initialClipperResource() { return String(); }
- static String initialFilterResource() { return String(); }
static String initialMaskerResource() { return String(); }
static String initialMarkerStartResource() { return String(); }
static String initialMarkerMidResource() { return String(); }
static String initialMarkerEndResource() { return String(); }
static EMaskType initialMaskType() { return MT_LUMINANCE; }
+ static PaintOrder initialPaintOrder() { return PaintOrderNormal; }
static SVGLength initialBaselineShiftValue()
{
@@ -111,20 +111,6 @@ public:
return length;
}
- static SVGLength initialStrokeDashOffset()
- {
- SVGLength length;
- length.newValueSpecifiedUnits(LengthTypeNumber, 0, ASSERT_NO_EXCEPTION);
- return length;
- }
-
- static SVGLength initialStrokeWidth()
- {
- SVGLength length;
- length.newValueSpecifiedUnits(LengthTypeNumber, 1, ASSERT_NO_EXCEPTION);
- return length;
- }
-
// SVG CSS Property setters
void setAlignmentBaseline(EAlignmentBaseline val) { svg_noninherited_flags.f._alignmentBaseline = val; }
void setDominantBaseline(EDominantBaseline val) { svg_noninherited_flags.f._dominantBaseline = val; }
@@ -144,6 +130,42 @@ public:
void setGlyphOrientationHorizontal(EGlyphOrientation val) { svg_inherited_flags._glyphOrientationHorizontal = val; }
void setGlyphOrientationVertical(EGlyphOrientation val) { svg_inherited_flags._glyphOrientationVertical = val; }
void setMaskType(EMaskType val) { svg_noninherited_flags.f.maskType = val; }
+ void setPaintOrder(PaintOrder val) { svg_inherited_flags.paintOrder = val; }
+ void setCx(const Length& obj)
+ {
+ if (!(layout->cx == obj))
+ layout.access()->cx = obj;
+ }
+ void setCy(const Length& obj)
+ {
+ if (!(layout->cy == obj))
+ layout.access()->cy = obj;
+ }
+ void setR(const Length& obj)
+ {
+ if (!(layout->r == obj))
+ layout.access()->r = obj;
+ }
+ void setRx(const Length& obj)
+ {
+ if (!(layout->rx == obj))
+ layout.access()->rx = obj;
+ }
+ void setRy(const Length& obj)
+ {
+ if (!(layout->ry == obj))
+ layout.access()->ry = obj;
+ }
+ void setX(const Length& obj)
+ {
+ if (!(layout->x == obj))
+ layout.access()->x = obj;
+ }
+ void setY(const Length& obj)
+ {
+ if (!(layout->y == obj))
+ layout.access()->y = obj;
+ }
void setFillOpacity(float obj)
{
@@ -209,13 +231,13 @@ public:
stroke.access()->miterLimit = obj;
}
- void setStrokeWidth(const SVGLength& obj)
+ void setStrokeWidth(const Length& obj)
{
if (!(stroke->width == obj))
stroke.access()->width = obj;
}
- void setStrokeDashOffset(const SVGLength& obj)
+ void setStrokeDashOffset(const Length& obj)
{
if (!(stroke->dashOffset == obj))
stroke.access()->dashOffset = obj;
@@ -263,7 +285,7 @@ public:
misc.access()->baselineShiftValue = obj;
}
- void setShadow(PassOwnPtr<ShadowData> obj) { shadowSVG.access()->shadow = obj; }
+ void setShadow(std::unique_ptr<ShadowData> obj) { shadowSVG.access()->shadow = WTFMove(obj); }
// Setters for non-inherited resources
void setClipperResource(const String& obj)
@@ -272,12 +294,6 @@ public:
resources.access()->clipper = obj;
}
- void setFilterResource(const String& obj)
- {
- if (!(resources->filter == obj))
- resources.access()->filter = obj;
- }
-
void setMaskerResource(const String& obj)
{
if (!(resources->masker == obj))
@@ -331,8 +347,8 @@ public:
const String& strokePaintUri() const { return stroke->paintUri; }
Vector<SVGLength> strokeDashArray() const { return stroke->dashArray; }
float strokeMiterLimit() const { return stroke->miterLimit; }
- SVGLength strokeWidth() const { return stroke->width; }
- SVGLength strokeDashOffset() const { return stroke->dashOffset; }
+ const Length& strokeWidth() const { return stroke->width; }
+ const Length& strokeDashOffset() const { return stroke->dashOffset; }
SVGLength kerning() const { return text->kerning; }
float stopOpacity() const { return stops->opacity; }
const Color& stopColor() const { return stops->color; }
@@ -341,13 +357,21 @@ public:
const Color& lightingColor() const { return misc->lightingColor; }
SVGLength baselineShiftValue() const { return misc->baselineShiftValue; }
ShadowData* shadow() const { return shadowSVG->shadow.get(); }
+ const Length& cx() const { return layout->cx; }
+ const Length& cy() const { return layout->cy; }
+ const Length& r() const { return layout->r; }
+ const Length& rx() const { return layout->rx; }
+ const Length& ry() const { return layout->ry; }
+ const Length& x() const { return layout->x; }
+ const Length& y() const { return layout->y; }
String clipperResource() const { return resources->clipper; }
- String filterResource() const { return resources->filter; }
String maskerResource() const { return resources->masker; }
String markerStartResource() const { return inheritedResources->markerStart; }
String markerMidResource() const { return inheritedResources->markerMid; }
String markerEndResource() const { return inheritedResources->markerEnd; }
EMaskType maskType() const { return (EMaskType) svg_noninherited_flags.f.maskType; }
+ PaintOrder paintOrder() const { return (PaintOrder) svg_inherited_flags.paintOrder; }
+ Vector<PaintType, 3> paintTypesForPaintOrder() const;
const SVGPaint::SVGPaintType& visitedLinkFillPaintType() const { return fill->visitedLinkPaintType; }
const Color& visitedLinkFillPaintColor() const { return fill->visitedLinkPaintColor; }
@@ -359,12 +383,12 @@ public:
// convenience
bool hasClipper() const { return !clipperResource().isEmpty(); }
bool hasMasker() const { return !maskerResource().isEmpty(); }
- bool hasFilter() const { return !filterResource().isEmpty(); }
bool hasMarkers() const { return !markerStartResource().isEmpty() || !markerMidResource().isEmpty() || !markerEndResource().isEmpty(); }
bool hasStroke() const { return strokePaintType() != SVGPaint::SVG_PAINTTYPE_NONE; }
bool hasVisibleStroke() const { return hasStroke() && !strokeWidth().isZero(); }
bool hasFill() const { return fillPaintType() != SVGPaint::SVG_PAINTTYPE_NONE; }
bool isVerticalWritingMode() const { return writingMode() == WM_TBRL || writingMode() == WM_TB; }
+ bool isolatesBlending() const { return hasMasker() || shadow(); }
protected:
// inherit
@@ -382,7 +406,8 @@ protected:
&& (_colorInterpolationFilters == other._colorInterpolationFilters)
&& (_writingMode == other._writingMode)
&& (_glyphOrientationHorizontal == other._glyphOrientationHorizontal)
- && (_glyphOrientationVertical == other._glyphOrientationVertical);
+ && (_glyphOrientationVertical == other._glyphOrientationVertical)
+ && (paintOrder == other.paintOrder);
}
bool operator!=(const InheritedFlags& other) const
@@ -402,6 +427,7 @@ protected:
unsigned _writingMode : 3; // SVGWritingMode
unsigned _glyphOrientationHorizontal : 3; // EGlyphOrientation
unsigned _glyphOrientationVertical : 3; // EGlyphOrientation
+ unsigned paintOrder : 3; // PaintOrder
} svg_inherited_flags;
// don't inherit
@@ -434,6 +460,7 @@ protected:
DataRef<StyleStopData> stops;
DataRef<StyleMiscData> misc;
DataRef<StyleShadowSVGData> shadowSVG;
+ DataRef<StyleLayoutData> layout;
DataRef<StyleResourceData> resources;
private:
@@ -457,6 +484,7 @@ private:
svg_inherited_flags._writingMode = initialWritingMode();
svg_inherited_flags._glyphOrientationHorizontal = initialGlyphOrientationHorizontal();
svg_inherited_flags._glyphOrientationVertical = initialGlyphOrientationVertical();
+ svg_inherited_flags.paintOrder = initialPaintOrder();
svg_noninherited_flags._niflags = 0;
svg_noninherited_flags.f._alignmentBaseline = initialAlignmentBaseline();
@@ -470,5 +498,4 @@ private:
} // namespace WebCore
-#endif // ENABLE(SVG)
#endif // SVGRenderStyle_h
diff --git a/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp b/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp
index aed179b9c..20ded8b8b 100644
--- a/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp
+++ b/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp
@@ -2,12 +2,13 @@
Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005, 2007 Rob Buis <buis@kde.org>
Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
Based on khtml code by:
Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org)
- Copyright (C) 2002 Apple Computer, Inc.
+ Copyright (C) 2002 Apple Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -26,12 +27,11 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGRenderStyleDefs.h"
#include "RenderStyle.h"
#include "SVGRenderStyle.h"
+#include <wtf/PointerComparison.h>
namespace WebCore {
@@ -58,7 +58,7 @@ inline StyleFillData::StyleFillData(const StyleFillData& other)
{
}
-PassRef<StyleFillData> StyleFillData::copy() const
+Ref<StyleFillData> StyleFillData::copy() const
{
return adoptRef(*new StyleFillData(*this));
}
@@ -77,8 +77,8 @@ bool StyleFillData::operator==(const StyleFillData& other) const
StyleStrokeData::StyleStrokeData()
: opacity(SVGRenderStyle::initialStrokeOpacity())
, miterLimit(SVGRenderStyle::initialStrokeMiterLimit())
- , width(SVGRenderStyle::initialStrokeWidth())
- , dashOffset(SVGRenderStyle::initialStrokeDashOffset())
+ , width(RenderStyle::initialOneLength())
+ , dashOffset(RenderStyle::initialZeroLength())
, dashArray(SVGRenderStyle::initialStrokeDashArray())
, paintType(SVGRenderStyle::initialStrokePaintType())
, paintColor(SVGRenderStyle::initialStrokePaintColor())
@@ -105,7 +105,7 @@ inline StyleStrokeData::StyleStrokeData(const StyleStrokeData& other)
{
}
-PassRef<StyleStrokeData> StyleStrokeData::copy() const
+Ref<StyleStrokeData> StyleStrokeData::copy() const
{
return adoptRef(*new StyleStrokeData(*this));
}
@@ -138,7 +138,7 @@ inline StyleStopData::StyleStopData(const StyleStopData& other)
{
}
-PassRef<StyleStopData> StyleStopData::copy() const
+Ref<StyleStopData> StyleStopData::copy() const
{
return adoptRef(*new StyleStopData(*this));
}
@@ -160,7 +160,7 @@ inline StyleTextData::StyleTextData(const StyleTextData& other)
{
}
-PassRef<StyleTextData> StyleTextData::copy() const
+Ref<StyleTextData> StyleTextData::copy() const
{
return adoptRef(*new StyleTextData(*this));
}
@@ -187,7 +187,7 @@ inline StyleMiscData::StyleMiscData(const StyleMiscData& other)
{
}
-PassRef<StyleMiscData> StyleMiscData::copy() const
+Ref<StyleMiscData> StyleMiscData::copy() const
{
return adoptRef(*new StyleMiscData(*this));
}
@@ -206,27 +206,22 @@ StyleShadowSVGData::StyleShadowSVGData()
inline StyleShadowSVGData::StyleShadowSVGData(const StyleShadowSVGData& other)
: RefCounted<StyleShadowSVGData>()
- , shadow(other.shadow ? adoptPtr(new ShadowData(*other.shadow)) : nullptr)
+ , shadow(other.shadow ? std::make_unique<ShadowData>(*other.shadow) : nullptr)
{
}
-PassRef<StyleShadowSVGData> StyleShadowSVGData::copy() const
+Ref<StyleShadowSVGData> StyleShadowSVGData::copy() const
{
return adoptRef(*new StyleShadowSVGData(*this));
}
bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const
{
- if ((!shadow && other.shadow) || (shadow && !other.shadow))
- return false;
- if (shadow && other.shadow && (*shadow != *other.shadow))
- return false;
- return true;
+ return arePointingToEqualData(shadow, other.shadow);
}
StyleResourceData::StyleResourceData()
: clipper(SVGRenderStyle::initialClipperResource())
- , filter(SVGRenderStyle::initialFilterResource())
, masker(SVGRenderStyle::initialMaskerResource())
{
}
@@ -234,12 +229,11 @@ StyleResourceData::StyleResourceData()
inline StyleResourceData::StyleResourceData(const StyleResourceData& other)
: RefCounted<StyleResourceData>()
, clipper(other.clipper)
- , filter(other.filter)
, masker(other.masker)
{
}
-PassRef<StyleResourceData> StyleResourceData::copy() const
+Ref<StyleResourceData> StyleResourceData::copy() const
{
return adoptRef(*new StyleResourceData(*this));
}
@@ -247,7 +241,6 @@ PassRef<StyleResourceData> StyleResourceData::copy() const
bool StyleResourceData::operator==(const StyleResourceData& other) const
{
return clipper == other.clipper
- && filter == other.filter
&& masker == other.masker;
}
@@ -266,7 +259,7 @@ inline StyleInheritedResourceData::StyleInheritedResourceData(const StyleInherit
{
}
-PassRef<StyleInheritedResourceData> StyleInheritedResourceData::copy() const
+Ref<StyleInheritedResourceData> StyleInheritedResourceData::copy() const
{
return adoptRef(*new StyleInheritedResourceData(*this));
}
@@ -278,6 +271,43 @@ bool StyleInheritedResourceData::operator==(const StyleInheritedResourceData& ot
&& markerEnd == other.markerEnd;
}
+StyleLayoutData::StyleLayoutData()
+ : cx(RenderStyle::initialZeroLength())
+ , cy(RenderStyle::initialZeroLength())
+ , r(RenderStyle::initialZeroLength())
+ , rx(RenderStyle::initialZeroLength())
+ , ry(RenderStyle::initialZeroLength())
+ , x(RenderStyle::initialZeroLength())
+ , y(RenderStyle::initialZeroLength())
+{
+}
+
+inline StyleLayoutData::StyleLayoutData(const StyleLayoutData& other)
+ : RefCounted<StyleLayoutData>()
+ , cx(other.cx)
+ , cy(other.cy)
+ , r(other.r)
+ , rx(other.rx)
+ , ry(other.ry)
+ , x(other.x)
+ , y(other.y)
+{
+}
+
+Ref<StyleLayoutData> StyleLayoutData::copy() const
+{
+ return adoptRef(*new StyleLayoutData(*this));
+}
+
+bool StyleLayoutData::operator==(const StyleLayoutData& other) const
+{
+ return cx == other.cx
+ && cy == other.cy
+ && r == other.r
+ && rx == other.rx
+ && ry == other.ry
+ && x == other.x
+ && y == other.y;
}
-#endif // ENABLE(SVG)
+}
diff --git a/Source/WebCore/rendering/style/SVGRenderStyleDefs.h b/Source/WebCore/rendering/style/SVGRenderStyleDefs.h
index 9c840bc0f..883641970 100644
--- a/Source/WebCore/rendering/style/SVGRenderStyleDefs.h
+++ b/Source/WebCore/rendering/style/SVGRenderStyleDefs.h
@@ -2,12 +2,13 @@
Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005 Rob Buis <buis@kde.org>
Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
Based on khtml code by:
Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org)
(C) 2000 Antti Koivisto (koivisto@kde.org)
(C) 2000-2003 Dirk Mueller (mueller@kde.org)
- (C) 2002-2003 Apple Computer, Inc.
+ (C) 2002-2003 Apple Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -28,12 +29,10 @@
#ifndef SVGRenderStyleDefs_h
#define SVGRenderStyleDefs_h
-#if ENABLE(SVG)
+#include "Length.h"
#include "SVGLength.h"
#include "SVGPaint.h"
#include "ShadowData.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -94,6 +93,23 @@ namespace WebCore {
MT_ALPHA
};
+ // These are all minimized combinations of paint-order.
+ enum PaintOrder {
+ PaintOrderNormal = 0,
+ PaintOrderFill = 1,
+ PaintOrderFillMarkers = 2,
+ PaintOrderStroke = 3,
+ PaintOrderStrokeMarkers = 4,
+ PaintOrderMarkers = 5,
+ PaintOrderMarkersStroke = 6
+ };
+
+ enum PaintType {
+ PaintTypeFill,
+ PaintTypeStroke,
+ PaintTypeMarkers
+ };
+
class CSSValue;
class CSSValueList;
class SVGPaint;
@@ -101,8 +117,8 @@ namespace WebCore {
// Inherited/Non-Inherited Style Datastructures
class StyleFillData : public RefCounted<StyleFillData> {
public:
- static PassRef<StyleFillData> create() { return adoptRef(*new StyleFillData); }
- PassRef<StyleFillData> copy() const;
+ static Ref<StyleFillData> create() { return adoptRef(*new StyleFillData); }
+ Ref<StyleFillData> copy() const;
bool operator==(const StyleFillData&) const;
bool operator!=(const StyleFillData& other) const
@@ -125,8 +141,8 @@ namespace WebCore {
class StyleStrokeData : public RefCounted<StyleStrokeData> {
public:
- static PassRef<StyleStrokeData> create() { return adoptRef(*new StyleStrokeData); }
- PassRef<StyleStrokeData> copy() const;
+ static Ref<StyleStrokeData> create() { return adoptRef(*new StyleStrokeData); }
+ Ref<StyleStrokeData> copy() const;
bool operator==(const StyleStrokeData&) const;
bool operator!=(const StyleStrokeData& other) const
@@ -137,8 +153,8 @@ namespace WebCore {
float opacity;
float miterLimit;
- SVGLength width;
- SVGLength dashOffset;
+ Length width;
+ Length dashOffset;
Vector<SVGLength> dashArray;
SVGPaint::SVGPaintType paintType;
@@ -155,8 +171,8 @@ namespace WebCore {
class StyleStopData : public RefCounted<StyleStopData> {
public:
- static PassRef<StyleStopData> create() { return adoptRef(*new StyleStopData); }
- PassRef<StyleStopData> copy() const;
+ static Ref<StyleStopData> create() { return adoptRef(*new StyleStopData); }
+ Ref<StyleStopData> copy() const;
bool operator==(const StyleStopData&) const;
bool operator!=(const StyleStopData& other) const
@@ -174,8 +190,8 @@ namespace WebCore {
class StyleTextData : public RefCounted<StyleTextData> {
public:
- static PassRef<StyleTextData> create() { return adoptRef(*new StyleTextData); }
- PassRef<StyleTextData> copy() const;
+ static Ref<StyleTextData> create() { return adoptRef(*new StyleTextData); }
+ Ref<StyleTextData> copy() const;
bool operator==(const StyleTextData& other) const;
bool operator!=(const StyleTextData& other) const
@@ -193,8 +209,8 @@ namespace WebCore {
// Note: the rule for this class is, *no inheritance* of these props
class StyleMiscData : public RefCounted<StyleMiscData> {
public:
- static PassRef<StyleMiscData> create() { return adoptRef(*new StyleMiscData); }
- PassRef<StyleMiscData> copy() const;
+ static Ref<StyleMiscData> create() { return adoptRef(*new StyleMiscData); }
+ Ref<StyleMiscData> copy() const;
bool operator==(const StyleMiscData&) const;
bool operator!=(const StyleMiscData& other) const
@@ -216,8 +232,8 @@ namespace WebCore {
class StyleShadowSVGData : public RefCounted<StyleShadowSVGData> {
public:
- static PassRef<StyleShadowSVGData> create() { return adoptRef(*new StyleShadowSVGData); }
- PassRef<StyleShadowSVGData> copy() const;
+ static Ref<StyleShadowSVGData> create() { return adoptRef(*new StyleShadowSVGData); }
+ Ref<StyleShadowSVGData> copy() const;
bool operator==(const StyleShadowSVGData&) const;
bool operator!=(const StyleShadowSVGData& other) const
@@ -225,7 +241,7 @@ namespace WebCore {
return !(*this == other);
}
- OwnPtr<ShadowData> shadow;
+ std::unique_ptr<ShadowData> shadow;
private:
StyleShadowSVGData();
@@ -235,8 +251,8 @@ namespace WebCore {
// Non-inherited resources
class StyleResourceData : public RefCounted<StyleResourceData> {
public:
- static PassRef<StyleResourceData> create() { return adoptRef(*new StyleResourceData); }
- PassRef<StyleResourceData> copy() const;
+ static Ref<StyleResourceData> create() { return adoptRef(*new StyleResourceData); }
+ Ref<StyleResourceData> copy() const;
bool operator==(const StyleResourceData&) const;
bool operator!=(const StyleResourceData& other) const
@@ -245,7 +261,6 @@ namespace WebCore {
}
String clipper;
- String filter;
String masker;
private:
@@ -256,8 +271,8 @@ namespace WebCore {
// Inherited resources
class StyleInheritedResourceData : public RefCounted<StyleInheritedResourceData> {
public:
- static PassRef<StyleInheritedResourceData> create() { return adoptRef(*new StyleInheritedResourceData); }
- PassRef<StyleInheritedResourceData> copy() const;
+ static Ref<StyleInheritedResourceData> create() { return adoptRef(*new StyleInheritedResourceData); }
+ Ref<StyleInheritedResourceData> copy() const;
bool operator==(const StyleInheritedResourceData&) const;
bool operator!=(const StyleInheritedResourceData& other) const
@@ -274,7 +289,31 @@ namespace WebCore {
StyleInheritedResourceData(const StyleInheritedResourceData&);
};
+ // Positioning and sizing properties.
+ class StyleLayoutData : public RefCounted<StyleLayoutData> {
+ public:
+ static Ref<StyleLayoutData> create() { return adoptRef(*new StyleLayoutData); }
+ Ref<StyleLayoutData> copy() const;
+
+ bool operator==(const StyleLayoutData&) const;
+ bool operator!=(const StyleLayoutData& other) const
+ {
+ return !(*this == other);
+ }
+
+ Length cx;
+ Length cy;
+ Length r;
+ Length rx;
+ Length ry;
+ Length x;
+ Length y;
+
+ private:
+ StyleLayoutData();
+ StyleLayoutData(const StyleLayoutData&);
+ };
+
} // namespace WebCore
-#endif // ENABLE(SVG)
#endif // SVGRenderStyleDefs_h
diff --git a/Source/WebCore/rendering/style/ShadowData.cpp b/Source/WebCore/rendering/style/ShadowData.cpp
index d91073bd4..4e5cb90f0 100644
--- a/Source/WebCore/rendering/style/ShadowData.cpp
+++ b/Source/WebCore/rendering/style/ShadowData.cpp
@@ -23,6 +23,7 @@
#include "ShadowData.h"
#include "LayoutRect.h"
+#include <wtf/PointerComparison.h>
namespace WebCore {
@@ -33,14 +34,13 @@ ShadowData::ShadowData(const ShadowData& o)
, m_color(o.m_color)
, m_style(o.m_style)
, m_isWebkitBoxShadow(o.m_isWebkitBoxShadow)
- , m_next(o.m_next ? adoptPtr(new ShadowData(*o.m_next)) : nullptr)
+ , m_next(o.m_next ? std::make_unique<ShadowData>(*o.m_next) : nullptr)
{
}
bool ShadowData::operator==(const ShadowData& o) const
{
- if ((m_next && !o.m_next) || (!m_next && o.m_next)
- || (m_next && o.m_next && *m_next != *o.m_next))
+ if (!arePointingToEqualData(m_next, o.m_next))
return false;
return m_location == o.m_location
diff --git a/Source/WebCore/rendering/style/ShadowData.h b/Source/WebCore/rendering/style/ShadowData.h
index 19be48d6c..4c3dab7a6 100644
--- a/Source/WebCore/rendering/style/ShadowData.h
+++ b/Source/WebCore/rendering/style/ShadowData.h
@@ -28,8 +28,6 @@
#include "Color.h"
#include "FloatRect.h"
#include "LayoutRect.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
namespace WebCore {
@@ -84,7 +82,7 @@ public:
bool isWebkitBoxShadow() const { return m_isWebkitBoxShadow; }
const ShadowData* next() const { return m_next.get(); }
- void setNext(PassOwnPtr<ShadowData> shadow) { m_next = shadow; }
+ void setNext(std::unique_ptr<ShadowData> shadow) { m_next = WTFMove(shadow); }
void adjustRectForShadow(LayoutRect&, int additionalOutlineSize = 0) const;
void adjustRectForShadow(FloatRect&, int additionalOutlineSize = 0) const;
@@ -96,7 +94,7 @@ private:
Color m_color;
ShadowStyle m_style;
bool m_isWebkitBoxShadow;
- OwnPtr<ShadowData> m_next;
+ std::unique_ptr<ShadowData> m_next;
};
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/ShapeValue.cpp b/Source/WebCore/rendering/style/ShapeValue.cpp
new file mode 100644
index 000000000..2eef76042
--- /dev/null
+++ b/Source/WebCore/rendering/style/ShapeValue.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2014 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "ShapeValue.h"
+
+#include "CachedImage.h"
+
+namespace WebCore {
+
+bool ShapeValue::isImageValid() const
+{
+ if (!image())
+ return false;
+ if (image()->isCachedImage() || image()->isCachedImageSet())
+ return image()->cachedImage() && image()->cachedImage()->hasImage();
+ return 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());
+}
+
+
+} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/ShapeValue.h b/Source/WebCore/rendering/style/ShapeValue.h
index 53c11a7e8..f54678d71 100644
--- a/Source/WebCore/rendering/style/ShapeValue.h
+++ b/Source/WebCore/rendering/style/ShapeValue.h
@@ -32,7 +32,6 @@
#include "BasicShapes.h"
#include "CSSValueKeywords.h"
-#include "CachedImage.h"
#include "StyleImage.h"
#include <wtf/PassRefPtr.h>
@@ -40,77 +39,76 @@ namespace WebCore {
class ShapeValue : public RefCounted<ShapeValue> {
public:
- enum ShapeValueType {
+ enum class Type {
// The None value is defined by a null ShapeValue*
Shape,
Box,
- Outside,
Image
};
- static PassRefPtr<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape, LayoutBox layoutBox)
+ static Ref<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox)
{
- return adoptRef(new ShapeValue(shape, layoutBox));
+ return adoptRef(*new ShapeValue(shape, cssBox));
}
- static PassRefPtr<ShapeValue> createLayoutBoxValue(LayoutBox layoutBox)
+ static Ref<ShapeValue> createBoxShapeValue(CSSBoxType boxShape)
{
- return adoptRef(new ShapeValue(layoutBox));
+ return adoptRef(*new ShapeValue(boxShape));
}
- static PassRefPtr<ShapeValue> createOutsideValue()
+ static Ref<ShapeValue> createImageValue(PassRefPtr<StyleImage> image)
{
- return adoptRef(new ShapeValue(Outside));
+ return adoptRef(*new ShapeValue(image));
}
- static PassRefPtr<ShapeValue> createImageValue(PassRefPtr<StyleImage> image)
- {
- return adoptRef(new ShapeValue(image));
- }
-
- ShapeValueType type() const { return m_type; }
+ Type type() const { return m_type; }
BasicShape* shape() const { return m_shape.get(); }
- LayoutBox layoutBox() const { return m_layoutBox; }
+ CSSBoxType cssBox() const { return m_cssBox; }
StyleImage* image() const { return m_image.get(); }
- bool isImageValid() const { return image() && image()->cachedImage() && image()->cachedImage()->hasImage(); }
+
+ bool isImageValid() const;
+
void setImage(PassRefPtr<StyleImage> image)
{
- ASSERT(type() == Image);
+ ASSERT(type() == Type::Image);
if (m_image != image)
m_image = image;
}
- bool operator==(const ShapeValue& other) const { return type() == other.type(); }
+ bool operator==(const ShapeValue&) const;
+ bool operator!=(const ShapeValue& other) const
+ {
+ return !(*this == other);
+ }
private:
- ShapeValue(PassRefPtr<BasicShape> shape, LayoutBox layoutBox)
- : m_type(Shape)
+ ShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox)
+ : m_type(Type::Shape)
, m_shape(shape)
- , m_layoutBox(layoutBox)
+ , m_cssBox(cssBox)
{
}
- ShapeValue(ShapeValueType type)
+ ShapeValue(Type type)
: m_type(type)
- , m_layoutBox(BoxMissing)
{
}
ShapeValue(PassRefPtr<StyleImage> image)
- : m_type(Image)
+ : m_type(Type::Image)
, m_image(image)
- , m_layoutBox(BoxMissing)
{
}
- ShapeValue(LayoutBox layoutBox)
- : m_type(Box)
- , m_layoutBox(layoutBox)
+
+ ShapeValue(CSSBoxType cssBox)
+ : m_type(Type::Box)
+ , m_cssBox(cssBox)
{
}
- ShapeValueType m_type;
+ Type m_type;
RefPtr<BasicShape> m_shape;
RefPtr<StyleImage> m_image;
- LayoutBox m_layoutBox;
+ CSSBoxType m_cssBox { BoxMissing };
};
}
diff --git a/Source/WebCore/rendering/style/StyleAllInOne.cpp b/Source/WebCore/rendering/style/StyleAllInOne.cpp
new file mode 100644
index 000000000..7c6c079d6
--- /dev/null
+++ b/Source/WebCore/rendering/style/StyleAllInOne.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 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 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 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.
+ */
+
+// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
+
+#include "BasicShapes.cpp"
+#include "ContentData.cpp"
+#include "CounterDirectives.cpp"
+#include "FillLayer.cpp"
+#include "GridResolvedPosition.cpp"
+#include "KeyframeList.cpp"
+#include "NinePieceImage.cpp"
+#include "QuotesData.cpp"
+#include "RenderStyle.cpp"
+#include "SVGRenderStyle.cpp"
+#include "SVGRenderStyleDefs.cpp"
+#include "ShadowData.cpp"
+#include "ShapeValue.cpp"
+#include "StyleBackgroundData.cpp"
+#include "StyleBoxData.cpp"
+#include "StyleCachedImage.cpp"
+#include "StyleCachedImageSet.cpp"
+#include "StyleDeprecatedFlexibleBoxData.cpp"
+#include "StyleFilterData.cpp"
+#include "StyleFlexibleBoxData.cpp"
+#include "StyleGeneratedImage.cpp"
+#include "StyleGridData.cpp"
+#include "StyleGridItemData.cpp"
+#include "StyleInheritedData.cpp"
+#include "StyleMarqueeData.cpp"
+#include "StyleMultiColData.cpp"
+#include "StyleRareInheritedData.cpp"
+#include "StyleRareNonInheritedData.cpp"
+#include "StyleScrollSnapPoints.cpp"
+#include "StyleSurroundData.cpp"
+#include "StyleTransformData.cpp"
+#include "StyleVisualData.cpp"
+#include "WillChangeData.cpp"
diff --git a/Source/WebCore/rendering/style/StyleBackgroundData.cpp b/Source/WebCore/rendering/style/StyleBackgroundData.cpp
index c51b8255f..1ba36c4a8 100644
--- a/Source/WebCore/rendering/style/StyleBackgroundData.cpp
+++ b/Source/WebCore/rendering/style/StyleBackgroundData.cpp
@@ -41,7 +41,7 @@ inline StyleBackgroundData::StyleBackgroundData(const StyleBackgroundData& o)
{
}
-PassRef<StyleBackgroundData> StyleBackgroundData::copy() const
+Ref<StyleBackgroundData> StyleBackgroundData::copy() const
{
return adoptRef(*new StyleBackgroundData(*this));
}
diff --git a/Source/WebCore/rendering/style/StyleBackgroundData.h b/Source/WebCore/rendering/style/StyleBackgroundData.h
index b2996dcd8..2e1b69820 100644
--- a/Source/WebCore/rendering/style/StyleBackgroundData.h
+++ b/Source/WebCore/rendering/style/StyleBackgroundData.h
@@ -35,8 +35,8 @@ namespace WebCore {
class StyleBackgroundData : public RefCounted<StyleBackgroundData> {
public:
- static PassRef<StyleBackgroundData> create() { return adoptRef(*new StyleBackgroundData); }
- PassRef<StyleBackgroundData> copy() const;
+ static Ref<StyleBackgroundData> create() { return adoptRef(*new StyleBackgroundData); }
+ Ref<StyleBackgroundData> copy() const;
~StyleBackgroundData() { }
bool operator==(const StyleBackgroundData& o) const;
diff --git a/Source/WebCore/rendering/style/StyleBoxData.cpp b/Source/WebCore/rendering/style/StyleBoxData.cpp
index a1187ff36..392708aae 100644
--- a/Source/WebCore/rendering/style/StyleBoxData.cpp
+++ b/Source/WebCore/rendering/style/StyleBoxData.cpp
@@ -67,7 +67,7 @@ inline StyleBoxData::StyleBoxData(const StyleBoxData& o)
{
}
-PassRef<StyleBoxData> StyleBoxData::copy() const
+Ref<StyleBoxData> StyleBoxData::copy() const
{
return adoptRef(*new StyleBoxData(*this));
}
diff --git a/Source/WebCore/rendering/style/StyleBoxData.h b/Source/WebCore/rendering/style/StyleBoxData.h
index 2c6d03353..ec255f291 100644
--- a/Source/WebCore/rendering/style/StyleBoxData.h
+++ b/Source/WebCore/rendering/style/StyleBoxData.h
@@ -34,8 +34,8 @@ namespace WebCore {
class StyleBoxData : public RefCounted<StyleBoxData> {
public:
- static PassRef<StyleBoxData> create() { return adoptRef(*new StyleBoxData); }
- PassRef<StyleBoxData> copy() const;
+ static Ref<StyleBoxData> create() { return adoptRef(*new StyleBoxData); }
+ Ref<StyleBoxData> copy() const;
bool operator==(const StyleBoxData& o) const;
bool operator!=(const StyleBoxData& o) const
diff --git a/Source/WebCore/rendering/style/StyleCachedImage.cpp b/Source/WebCore/rendering/style/StyleCachedImage.cpp
index 04d55e942..e74940725 100644
--- a/Source/WebCore/rendering/style/StyleCachedImage.cpp
+++ b/Source/WebCore/rendering/style/StyleCachedImage.cpp
@@ -61,7 +61,7 @@ bool StyleCachedImage::errorOccurred() const
return m_image->errorOccurred();
}
-LayoutSize StyleCachedImage::imageSize(const RenderElement* renderer, float multiplier) const
+FloatSize StyleCachedImage::imageSize(const RenderElement* renderer, float multiplier) const
{
return m_image->imageSizeForRenderer(renderer, multiplier);
}
@@ -86,9 +86,9 @@ bool StyleCachedImage::usesImageContainerSize() const
return m_image->usesImageContainerSize();
}
-void StyleCachedImage::setContainerSizeForRenderer(const RenderElement* renderer, const IntSize& imageContainerSize, float imageContainerZoomFactor)
+void StyleCachedImage::setContainerSizeForRenderer(const RenderElement* renderer, const FloatSize& imageContainerSize, float imageContainerZoomFactor)
{
- m_image->setContainerSizeForRenderer(renderer, imageContainerSize, imageContainerZoomFactor);
+ m_image->setContainerSizeForRenderer(renderer, LayoutSize(imageContainerSize), imageContainerZoomFactor);
}
void StyleCachedImage::addClient(RenderElement* renderer)
@@ -101,7 +101,7 @@ void StyleCachedImage::removeClient(RenderElement* renderer)
m_image->removeClient(renderer);
}
-PassRefPtr<Image> StyleCachedImage::image(RenderElement* renderer, const IntSize&) const
+RefPtr<Image> StyleCachedImage::image(RenderElement* renderer, const FloatSize&) const
{
return m_image->imageForRenderer(renderer);
}
diff --git a/Source/WebCore/rendering/style/StyleCachedImage.h b/Source/WebCore/rendering/style/StyleCachedImage.h
index 0ef45d2d6..2d20c34c8 100644
--- a/Source/WebCore/rendering/style/StyleCachedImage.h
+++ b/Source/WebCore/rendering/style/StyleCachedImage.h
@@ -35,7 +35,7 @@ class CachedImage;
class StyleCachedImage final : public StyleImage, private CachedImageClient {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassRefPtr<StyleCachedImage> create(CachedImage* image) { return adoptRef(new StyleCachedImage(image)); }
+ static Ref<StyleCachedImage> create(CachedImage* image) { return adoptRef(*new StyleCachedImage(image)); }
virtual ~StyleCachedImage();
virtual CachedImage* cachedImage() const override { return m_image.get(); }
@@ -48,15 +48,15 @@ private:
virtual bool canRender(const RenderObject*, float multiplier) const override;
virtual bool isLoaded() const override;
virtual bool errorOccurred() const override;
- virtual LayoutSize imageSize(const RenderElement*, float multiplier) const override;
+ virtual FloatSize imageSize(const RenderElement*, float multiplier) const override;
virtual bool imageHasRelativeWidth() const override;
virtual bool imageHasRelativeHeight() const override;
virtual void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
virtual bool usesImageContainerSize() const override;
- virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize&, float) override;
+ virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override;
virtual void addClient(RenderElement*) override;
virtual void removeClient(RenderElement*) override;
- virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const override;
+ virtual RefPtr<Image> image(RenderElement*, const FloatSize&) const override;
virtual bool knownToBeOpaque(const RenderElement*) const override;
explicit StyleCachedImage(CachedImage*);
@@ -64,5 +64,8 @@ private:
CachedResourceHandle<CachedImage> m_image;
};
-}
-#endif
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_STYLE_IMAGE(StyleCachedImage, isCachedImage)
+
+#endif // StyleCachedImage_h
diff --git a/Source/WebCore/rendering/style/StyleCachedImageSet.cpp b/Source/WebCore/rendering/style/StyleCachedImageSet.cpp
index f95b2c940..19764f372 100644
--- a/Source/WebCore/rendering/style/StyleCachedImageSet.cpp
+++ b/Source/WebCore/rendering/style/StyleCachedImageSet.cpp
@@ -69,9 +69,9 @@ bool StyleCachedImageSet::errorOccurred() const
return m_bestFitImage->errorOccurred();
}
-LayoutSize StyleCachedImageSet::imageSize(const RenderElement* renderer, float multiplier) const
+FloatSize StyleCachedImageSet::imageSize(const RenderElement* renderer, float multiplier) const
{
- LayoutSize scaledImageSize = m_bestFitImage->imageSizeForRenderer(renderer, multiplier);
+ FloatSize scaledImageSize = m_bestFitImage->imageSizeForRenderer(renderer, multiplier);
scaledImageSize.scale(1 / m_imageScaleFactor);
return scaledImageSize;
}
@@ -96,9 +96,9 @@ bool StyleCachedImageSet::usesImageContainerSize() const
return m_bestFitImage->usesImageContainerSize();
}
-void StyleCachedImageSet::setContainerSizeForRenderer(const RenderElement* renderer, const IntSize& imageContainerSize, float imageContainerZoomFactor)
+void StyleCachedImageSet::setContainerSizeForRenderer(const RenderElement* renderer, const FloatSize& imageContainerSize, float imageContainerZoomFactor)
{
- m_bestFitImage->setContainerSizeForRenderer(renderer, imageContainerSize, imageContainerZoomFactor);
+ m_bestFitImage->setContainerSizeForRenderer(renderer, LayoutSize(imageContainerSize), imageContainerZoomFactor);
}
void StyleCachedImageSet::addClient(RenderElement* renderer)
@@ -111,7 +111,7 @@ void StyleCachedImageSet::removeClient(RenderElement* renderer)
m_bestFitImage->removeClient(renderer);
}
-PassRefPtr<Image> StyleCachedImageSet::image(RenderElement* renderer, const IntSize&) const
+RefPtr<Image> StyleCachedImageSet::image(RenderElement* renderer, const FloatSize&) const
{
return m_bestFitImage->imageForRenderer(renderer);
}
diff --git a/Source/WebCore/rendering/style/StyleCachedImageSet.h b/Source/WebCore/rendering/style/StyleCachedImageSet.h
index d0ad5c913..24d8330d9 100644
--- a/Source/WebCore/rendering/style/StyleCachedImageSet.h
+++ b/Source/WebCore/rendering/style/StyleCachedImageSet.h
@@ -43,9 +43,9 @@ class CSSImageSetValue;
class StyleCachedImageSet final : public StyleImage, private CachedImageClient {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassRefPtr<StyleCachedImageSet> create(CachedImage* image, float imageScaleFactor, CSSImageSetValue* value)
+ static Ref<StyleCachedImageSet> create(CachedImage* image, float imageScaleFactor, CSSImageSetValue* value)
{
- return adoptRef(new StyleCachedImageSet(image, imageScaleFactor, value));
+ return adoptRef(*new StyleCachedImageSet(image, imageScaleFactor, value));
}
virtual ~StyleCachedImageSet();
@@ -64,15 +64,15 @@ private:
virtual bool canRender(const RenderObject*, float multiplier) const override;
virtual bool isLoaded() const override;
virtual bool errorOccurred() const override;
- virtual LayoutSize imageSize(const RenderElement*, float multiplier) const override;
+ virtual FloatSize imageSize(const RenderElement*, float multiplier) const override;
virtual bool imageHasRelativeWidth() const override;
virtual bool imageHasRelativeHeight() const override;
virtual void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
virtual bool usesImageContainerSize() const override;
- virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize&, float) override;
+ virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override;
virtual void addClient(RenderElement*) override;
virtual void removeClient(RenderElement*) override;
- virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const override;
+ virtual RefPtr<Image> image(RenderElement*, const FloatSize&) const override;
virtual float imageScaleFactor() const override { return m_imageScaleFactor; }
virtual bool knownToBeOpaque(const RenderElement*) const override;
@@ -85,6 +85,8 @@ private:
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_STYLE_IMAGE(StyleCachedImageSet, isCachedImageSet)
+
#endif // ENABLE(CSS_IMAGE_SET)
#endif // StyleCachedImageSet_h
diff --git a/Source/WebCore/rendering/style/StyleContentAlignmentData.h b/Source/WebCore/rendering/style/StyleContentAlignmentData.h
new file mode 100644
index 000000000..31b61b4c3
--- /dev/null
+++ b/Source/WebCore/rendering/style/StyleContentAlignmentData.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2015 Igalia S.L. 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 StyleContentAlignmentData_h
+#define StyleContentAlignmentData_h
+
+#include "RenderStyleConstants.h"
+
+namespace WebCore {
+
+class StyleContentAlignmentData {
+public:
+ // Style data for Content-Distribution properties: align-content, justify-content.
+ // <content-distribution> || [ <overflow-position>? && <content-position> ]
+ StyleContentAlignmentData(ContentPosition position, ContentDistributionType distribution, OverflowAlignment overflow = OverflowAlignmentDefault)
+ : m_position(position)
+ , m_distribution(distribution)
+ , m_overflow(overflow)
+ {
+ }
+
+ void setPosition(ContentPosition position) { m_position = position; }
+ void setDistribution(ContentDistributionType distribution) { m_distribution = distribution; }
+ void setOverflow(OverflowAlignment overflow) { m_overflow = overflow; }
+
+ ContentPosition position() const { return static_cast<ContentPosition>(m_position); }
+ ContentDistributionType distribution() const { return static_cast<ContentDistributionType>(m_distribution); }
+ OverflowAlignment overflow() const { return static_cast<OverflowAlignment>(m_overflow); }
+
+ bool operator==(const StyleContentAlignmentData& o) const
+ {
+ return m_position == o.m_position && m_distribution == o.m_distribution && m_overflow == o.m_overflow;
+ }
+
+ bool operator!=(const StyleContentAlignmentData& o) const
+ {
+ return !(*this == o);
+ }
+
+private:
+ unsigned m_position : 4; // ContentPosition
+ unsigned m_distribution : 3; // ContentDistributionType
+ unsigned m_overflow : 2; // OverflowAlignment
+};
+
+} // namespace WebCore
+
+#endif // StyleContentAlignmentData_h
diff --git a/Source/WebCore/rendering/style/StyleCustomPropertyData.h b/Source/WebCore/rendering/style/StyleCustomPropertyData.h
new file mode 100644
index 000000000..c0a19684d
--- /dev/null
+++ b/Source/WebCore/rendering/style/StyleCustomPropertyData.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Google 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef StyleCustomPropertyData_h
+#define StyleCustomPropertyData_h
+
+#include "CSSValue.h"
+#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/AtomicStringHash.h>
+
+namespace WebCore {
+
+class StyleCustomPropertyData : public RefCounted<StyleCustomPropertyData> {
+public:
+ static Ref<StyleCustomPropertyData> create() { return adoptRef(*new StyleCustomPropertyData); }
+ Ref<StyleCustomPropertyData> copy() const { return adoptRef(*new StyleCustomPropertyData(*this)); }
+
+ bool operator==(const StyleCustomPropertyData& o) const
+ {
+ if (m_containsVariables != o.m_containsVariables)
+ return false;
+
+ if (m_values.size() != o.m_values.size())
+ return false;
+
+ for (WTF::KeyValuePair<AtomicString, RefPtr<CSSValue>> entry : m_values) {
+ RefPtr<CSSValue> other = o.m_values.get(entry.key);
+ if (!other || !entry.value->equals(*other))
+ return false;
+ }
+ return true;
+ }
+
+ bool operator!=(const StyleCustomPropertyData &o) const { return !(*this == o); }
+
+ void setCustomPropertyValue(const AtomicString& name, const RefPtr<CSSValue>& value)
+ {
+ m_values.set(name, value);
+ if (value->isVariableDependentValue())
+ m_containsVariables = true;
+ }
+
+ RefPtr<CSSValue> getCustomPropertyValue(const AtomicString& name) const { return m_values.get(name); }
+ CustomPropertyValueMap& values() { return m_values; }
+
+ bool hasCustomProperty(const AtomicString& name) const { return m_values.contains(name); }
+
+ bool containsVariables() const { return m_containsVariables; }
+ void setContainsVariables(bool containsVariables) { m_containsVariables = containsVariables; }
+
+ CustomPropertyValueMap m_values;
+ bool m_containsVariables { false };
+
+private:
+ explicit StyleCustomPropertyData()
+ : RefCounted<StyleCustomPropertyData>()
+ { }
+ StyleCustomPropertyData(const StyleCustomPropertyData& other)
+ : RefCounted<StyleCustomPropertyData>()
+ , m_values(CustomPropertyValueMap(other.m_values))
+ , m_containsVariables(other.m_containsVariables)
+ { }
+};
+
+} // namespace WebCore
+
+#endif // StyleCustomPropertyData_h
diff --git a/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp b/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp
index 3c835923a..32f7805eb 100644
--- a/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp
+++ b/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp
@@ -49,7 +49,7 @@ inline StyleDeprecatedFlexibleBoxData::StyleDeprecatedFlexibleBoxData(const Styl
{
}
-PassRef<StyleDeprecatedFlexibleBoxData> StyleDeprecatedFlexibleBoxData::copy() const
+Ref<StyleDeprecatedFlexibleBoxData> StyleDeprecatedFlexibleBoxData::copy() const
{
return adoptRef(*new StyleDeprecatedFlexibleBoxData(*this));
}
diff --git a/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h b/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h
index 64c9c7fa0..20fee8bb2 100644
--- a/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h
+++ b/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h
@@ -32,8 +32,8 @@ namespace WebCore {
class StyleDeprecatedFlexibleBoxData : public RefCounted<StyleDeprecatedFlexibleBoxData> {
public:
- static PassRef<StyleDeprecatedFlexibleBoxData> create() { return adoptRef(*new StyleDeprecatedFlexibleBoxData); }
- PassRef<StyleDeprecatedFlexibleBoxData> copy() const;
+ static Ref<StyleDeprecatedFlexibleBoxData> create() { return adoptRef(*new StyleDeprecatedFlexibleBoxData); }
+ Ref<StyleDeprecatedFlexibleBoxData> copy() const;
bool operator==(const StyleDeprecatedFlexibleBoxData&) const;
bool operator!=(const StyleDeprecatedFlexibleBoxData& o) const
diff --git a/Source/WebCore/rendering/style/StyleFilterData.cpp b/Source/WebCore/rendering/style/StyleFilterData.cpp
index d1eb94bd4..b0d3be110 100644
--- a/Source/WebCore/rendering/style/StyleFilterData.cpp
+++ b/Source/WebCore/rendering/style/StyleFilterData.cpp
@@ -10,10 +10,10 @@
* 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
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE 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
@@ -27,9 +27,6 @@
#include "StyleFilterData.h"
#include "FEGaussianBlur.h"
-
-#if ENABLE(CSS_FILTERS)
-
#include "RenderStyle.h"
namespace WebCore {
@@ -45,7 +42,7 @@ inline StyleFilterData::StyleFilterData(const StyleFilterData& o)
{
}
-PassRef<StyleFilterData> StyleFilterData::copy() const
+Ref<StyleFilterData> StyleFilterData::copy() const
{
return adoptRef(*new StyleFilterData(*this));
}
@@ -56,5 +53,3 @@ bool StyleFilterData::operator==(const StyleFilterData& o) const
}
} // namespace WebCore
-
-#endif // ENABLE(CSS_FILTERS)
diff --git a/Source/WebCore/rendering/style/StyleFilterData.h b/Source/WebCore/rendering/style/StyleFilterData.h
index 25e2f7a3b..210d0ecb9 100644
--- a/Source/WebCore/rendering/style/StyleFilterData.h
+++ b/Source/WebCore/rendering/style/StyleFilterData.h
@@ -10,10 +10,10 @@
* 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
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE 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
@@ -26,8 +26,6 @@
#ifndef StyleFilterData_h
#define StyleFilterData_h
-#if ENABLE(CSS_FILTERS)
-
#include "FilterOperations.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -36,8 +34,8 @@ namespace WebCore {
class StyleFilterData : public RefCounted<StyleFilterData> {
public:
- static PassRef<StyleFilterData> create() { return adoptRef(*new StyleFilterData); }
- PassRef<StyleFilterData> copy() const;
+ static Ref<StyleFilterData> create() { return adoptRef(*new StyleFilterData); }
+ Ref<StyleFilterData> copy() const;
bool operator==(const StyleFilterData&) const;
bool operator!=(const StyleFilterData& o) const
@@ -54,6 +52,4 @@ private:
} // namespace WebCore
-#endif // ENABLE(CSS_FILTERS)
-
#endif // StyleFilterData_h
diff --git a/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp b/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp
index 775886b6e..99e55eb7e 100644
--- a/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp
+++ b/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp
@@ -49,7 +49,7 @@ inline StyleFlexibleBoxData::StyleFlexibleBoxData(const StyleFlexibleBoxData& o)
{
}
-PassRef<StyleFlexibleBoxData> StyleFlexibleBoxData::copy() const
+Ref<StyleFlexibleBoxData> StyleFlexibleBoxData::copy() const
{
return adoptRef(*new StyleFlexibleBoxData(*this));
}
diff --git a/Source/WebCore/rendering/style/StyleFlexibleBoxData.h b/Source/WebCore/rendering/style/StyleFlexibleBoxData.h
index 0e3352c09..d332de552 100644
--- a/Source/WebCore/rendering/style/StyleFlexibleBoxData.h
+++ b/Source/WebCore/rendering/style/StyleFlexibleBoxData.h
@@ -35,8 +35,8 @@ namespace WebCore {
class StyleFlexibleBoxData : public RefCounted<StyleFlexibleBoxData> {
public:
- static PassRef<StyleFlexibleBoxData> create() { return adoptRef(*new StyleFlexibleBoxData); }
- PassRef<StyleFlexibleBoxData> copy() const;
+ static Ref<StyleFlexibleBoxData> create() { return adoptRef(*new StyleFlexibleBoxData); }
+ Ref<StyleFlexibleBoxData> copy() const;
bool operator==(const StyleFlexibleBoxData&) const;
bool operator!=(const StyleFlexibleBoxData& o) const
diff --git a/Source/WebCore/rendering/style/StyleGeneratedImage.cpp b/Source/WebCore/rendering/style/StyleGeneratedImage.cpp
index 6b59fe7c4..24ae933a9 100644
--- a/Source/WebCore/rendering/style/StyleGeneratedImage.cpp
+++ b/Source/WebCore/rendering/style/StyleGeneratedImage.cpp
@@ -30,8 +30,8 @@
namespace WebCore {
-StyleGeneratedImage::StyleGeneratedImage(PassRef<CSSImageGeneratorValue> value)
- : m_imageGeneratorValue(std::move(value))
+StyleGeneratedImage::StyleGeneratedImage(Ref<CSSImageGeneratorValue>&& value)
+ : m_imageGeneratorValue(WTFMove(value))
, m_fixedSize(m_imageGeneratorValue->isFixedSize())
{
m_isGeneratedImage = true;
@@ -39,27 +39,28 @@ StyleGeneratedImage::StyleGeneratedImage(PassRef<CSSImageGeneratorValue> value)
PassRefPtr<CSSValue> StyleGeneratedImage::cssValue() const
{
- return &const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get());
+ return const_cast<CSSImageGeneratorValue*>(m_imageGeneratorValue.ptr());
}
-LayoutSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float multiplier) const
+FloatSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float multiplier) const
{
if (m_fixedSize) {
- IntSize fixedSize = const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).fixedSize(renderer);
+ FloatSize fixedSize = const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).fixedSize(renderer);
if (multiplier == 1.0f)
return fixedSize;
- LayoutUnit width = fixedSize.width() * multiplier;
- LayoutUnit height = fixedSize.height() * multiplier;
+ float width = fixedSize.width() * multiplier;
+ float height = fixedSize.height() * multiplier;
- // Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
+ // Don't let images that have a width/height >= 1 shrink below 1 device pixel when zoomed.
+ float deviceScaleFactor = renderer ? renderer->document().deviceScaleFactor() : 1;
if (fixedSize.width() > 0)
- width = std::max<LayoutUnit>(1, width);
+ width = std::max<float>(1 / deviceScaleFactor, width);
if (fixedSize.height() > 0)
- height = std::max<LayoutUnit>(1, height);
+ height = std::max<float>(1 / deviceScaleFactor, height);
- return LayoutSize(width, height);
+ return FloatSize(width, height);
}
return m_containerSize;
@@ -67,8 +68,8 @@ LayoutSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float m
void StyleGeneratedImage::computeIntrinsicDimensions(const RenderElement* renderer, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
- // At a zoom level of 1 the image is guaranteed to have an integer size.
- IntSize size = flooredIntSize(imageSize(renderer, 1));
+ // At a zoom level of 1 the image is guaranteed to have a device pixel size.
+ FloatSize size = floorSizeToDevicePixels(LayoutSize(imageSize(renderer, 1)), renderer ? renderer->document().deviceScaleFactor() : 1);
intrinsicWidth = Length(size.width(), Fixed);
intrinsicHeight = Length(size.height(), Fixed);
intrinsicRatio = size;
@@ -84,7 +85,7 @@ void StyleGeneratedImage::removeClient(RenderElement* renderer)
m_imageGeneratorValue->removeClient(renderer);
}
-PassRefPtr<Image> StyleGeneratedImage::image(RenderElement* renderer, const IntSize& size) const
+RefPtr<Image> StyleGeneratedImage::image(RenderElement* renderer, const FloatSize& size) const
{
return const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).image(renderer, size);
}
diff --git a/Source/WebCore/rendering/style/StyleGeneratedImage.h b/Source/WebCore/rendering/style/StyleGeneratedImage.h
index 756ca2152..db49dd544 100644
--- a/Source/WebCore/rendering/style/StyleGeneratedImage.h
+++ b/Source/WebCore/rendering/style/StyleGeneratedImage.h
@@ -33,41 +33,38 @@ class CSSImageGeneratorValue;
class StyleGeneratedImage final : public StyleImage {
public:
- static PassRefPtr<StyleGeneratedImage> create(PassRef<CSSImageGeneratorValue> value)
+ static Ref<StyleGeneratedImage> create(Ref<CSSImageGeneratorValue>&& value)
{
- return adoptRef(new StyleGeneratedImage(std::move(value)));
+ return adoptRef(*new StyleGeneratedImage(WTFMove(value)));
}
- CSSImageGeneratorValue& imageValue() { return m_imageGeneratorValue.get(); }
+ CSSImageGeneratorValue& imageValue() { return m_imageGeneratorValue; }
private:
- virtual WrappedImagePtr data() const override { return &m_imageGeneratorValue.get(); }
+ virtual WrappedImagePtr data() const override { return m_imageGeneratorValue.ptr(); }
virtual PassRefPtr<CSSValue> cssValue() const override;
- virtual LayoutSize imageSize(const RenderElement*, float multiplier) const override;
+ virtual FloatSize imageSize(const RenderElement*, float multiplier) const override;
virtual bool imageHasRelativeWidth() const override { return !m_fixedSize; }
virtual bool imageHasRelativeHeight() const override { return !m_fixedSize; }
virtual void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
virtual bool usesImageContainerSize() const override { return !m_fixedSize; }
- virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize& containerSize, float) override { m_containerSize = containerSize; }
+ virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize& containerSize, float) override { m_containerSize = containerSize; }
virtual void addClient(RenderElement*) override;
virtual void removeClient(RenderElement*) override;
- virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const override;
+ virtual RefPtr<Image> image(RenderElement*, const FloatSize&) const override;
virtual bool knownToBeOpaque(const RenderElement*) const override;
- StyleGeneratedImage(PassRef<CSSImageGeneratorValue>);
+ explicit StyleGeneratedImage(Ref<CSSImageGeneratorValue>&&);
Ref<CSSImageGeneratorValue> m_imageGeneratorValue;
- IntSize m_containerSize;
+ FloatSize m_containerSize;
bool m_fixedSize;
};
-inline StyleGeneratedImage* toStyleGeneratedImage(StyleImage* image)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!image || image->isGeneratedImage());
- return static_cast<StyleGeneratedImage*>(image);
-}
+} // namespace WebCore
-}
-#endif
+SPECIALIZE_TYPE_TRAITS_STYLE_IMAGE(StyleGeneratedImage, isGeneratedImage)
+
+#endif // StyleGeneratedImage_h
diff --git a/Source/WebCore/rendering/style/StyleGridData.cpp b/Source/WebCore/rendering/style/StyleGridData.cpp
index 10eccc0d8..fa22ed2c3 100644
--- a/Source/WebCore/rendering/style/StyleGridData.cpp
+++ b/Source/WebCore/rendering/style/StyleGridData.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "StyleGridData.h"
+#if ENABLE(CSS_GRID_LAYOUT)
+
#include "RenderStyle.h"
namespace WebCore {
@@ -35,12 +37,16 @@ StyleGridData::StyleGridData()
, m_gridRows(RenderStyle::initialGridRows())
, m_namedGridColumnLines(RenderStyle::initialNamedGridColumnLines())
, m_namedGridRowLines(RenderStyle::initialNamedGridRowLines())
+ , m_orderedNamedGridColumnLines(RenderStyle::initialOrderedNamedGridColumnLines())
+ , m_orderedNamedGridRowLines(RenderStyle::initialOrderedNamedGridRowLines())
, m_gridAutoFlow(RenderStyle::initialGridAutoFlow())
, m_gridAutoRows(RenderStyle::initialGridAutoRows())
, m_gridAutoColumns(RenderStyle::initialGridAutoColumns())
, m_namedGridArea(RenderStyle::initialNamedGridArea())
, m_namedGridAreaRowCount(RenderStyle::initialNamedGridAreaCount())
, m_namedGridAreaColumnCount(RenderStyle::initialNamedGridAreaCount())
+ , m_gridColumnGap(RenderStyle::initialGridColumnGap())
+ , m_gridRowGap(RenderStyle::initialGridRowGap())
{
}
@@ -50,19 +56,24 @@ inline StyleGridData::StyleGridData(const StyleGridData& o)
, m_gridRows(o.m_gridRows)
, m_namedGridColumnLines(o.m_namedGridColumnLines)
, m_namedGridRowLines(o.m_namedGridRowLines)
+ , m_orderedNamedGridColumnLines(o.m_orderedNamedGridColumnLines)
+ , m_orderedNamedGridRowLines(o.m_orderedNamedGridRowLines)
, m_gridAutoFlow(o.m_gridAutoFlow)
, m_gridAutoRows(o.m_gridAutoRows)
, m_gridAutoColumns(o.m_gridAutoColumns)
, m_namedGridArea(o.m_namedGridArea)
, m_namedGridAreaRowCount(o.m_namedGridAreaRowCount)
, m_namedGridAreaColumnCount(o.m_namedGridAreaColumnCount)
+ , m_gridColumnGap(o.m_gridColumnGap)
+ , m_gridRowGap(o.m_gridRowGap)
{
}
-PassRef<StyleGridData> StyleGridData::copy() const
+Ref<StyleGridData> StyleGridData::copy() const
{
return adoptRef(*new StyleGridData(*this));
}
} // namespace WebCore
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
diff --git a/Source/WebCore/rendering/style/StyleGridData.h b/Source/WebCore/rendering/style/StyleGridData.h
index 7fe4c9588..d895cdaa7 100644
--- a/Source/WebCore/rendering/style/StyleGridData.h
+++ b/Source/WebCore/rendering/style/StyleGridData.h
@@ -26,6 +26,8 @@
#ifndef StyleGridData_h
#define StyleGridData_h
+#if ENABLE(CSS_GRID_LAYOUT)
+
#include "GridCoordinate.h"
#include "GridTrackSize.h"
#include "RenderStyleConstants.h"
@@ -36,17 +38,24 @@
namespace WebCore {
-typedef HashMap<String, Vector<size_t>> NamedGridLinesMap;
+typedef HashMap<String, Vector<unsigned>> NamedGridLinesMap;
+typedef HashMap<unsigned, Vector<String>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> OrderedNamedGridLinesMap;
class StyleGridData : public RefCounted<StyleGridData> {
public:
- static PassRef<StyleGridData> create() { return adoptRef(*new StyleGridData); }
- PassRef<StyleGridData> copy() const;
+ static Ref<StyleGridData> create() { return adoptRef(*new StyleGridData); }
+ Ref<StyleGridData> copy() const;
bool operator==(const StyleGridData& o) const
{
// FIXME: comparing two hashes doesn't look great for performance. Something to keep in mind going forward.
- return m_gridColumns == o.m_gridColumns && m_gridRows == o.m_gridRows && m_gridAutoFlow == o.m_gridAutoFlow && m_gridAutoRows == o.m_gridAutoRows && m_gridAutoColumns == o.m_gridAutoColumns && m_namedGridColumnLines == o.m_namedGridColumnLines && m_namedGridRowLines == o.m_namedGridRowLines && m_namedGridArea == o.m_namedGridArea && m_namedGridArea == o.m_namedGridArea && m_namedGridAreaRowCount == o.m_namedGridAreaRowCount && m_namedGridAreaColumnCount == o.m_namedGridAreaColumnCount;
+ return m_gridColumns == o.m_gridColumns && m_gridRows == o.m_gridRows
+ && m_gridAutoFlow == o.m_gridAutoFlow && m_gridAutoRows == o.m_gridAutoRows && m_gridAutoColumns == o.m_gridAutoColumns
+ && m_namedGridColumnLines == o.m_namedGridColumnLines && m_namedGridRowLines == o.m_namedGridRowLines
+ && m_namedGridArea == o.m_namedGridArea && m_namedGridArea == o.m_namedGridArea
+ && m_namedGridAreaRowCount == o.m_namedGridAreaRowCount && m_namedGridAreaColumnCount == o.m_namedGridAreaColumnCount
+ && m_orderedNamedGridRowLines == o.m_orderedNamedGridRowLines && m_orderedNamedGridColumnLines == o.m_orderedNamedGridColumnLines
+ && m_gridColumnGap == o.m_gridColumnGap && m_gridRowGap == o.m_gridRowGap;
}
bool operator!=(const StyleGridData& o) const
@@ -61,7 +70,10 @@ public:
NamedGridLinesMap m_namedGridColumnLines;
NamedGridLinesMap m_namedGridRowLines;
- GridAutoFlow m_gridAutoFlow;
+ OrderedNamedGridLinesMap m_orderedNamedGridColumnLines;
+ OrderedNamedGridLinesMap m_orderedNamedGridRowLines;
+
+ unsigned m_gridAutoFlow : GridAutoFlowBits;
GridTrackSize m_gridAutoRows;
GridTrackSize m_gridAutoColumns;
@@ -69,8 +81,11 @@ public:
NamedGridAreaMap m_namedGridArea;
// Because m_namedGridArea doesn't store the unnamed grid areas, we need to keep track
// of the explicit grid size defined by both named and unnamed grid areas.
- size_t m_namedGridAreaRowCount;
- size_t m_namedGridAreaColumnCount;
+ unsigned m_namedGridAreaRowCount;
+ unsigned m_namedGridAreaColumnCount;
+
+ Length m_gridColumnGap;
+ Length m_gridRowGap;
private:
StyleGridData();
@@ -79,4 +94,6 @@ private:
} // namespace WebCore
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
+
#endif // StyleGridData_h
diff --git a/Source/WebCore/rendering/style/StyleGridItemData.cpp b/Source/WebCore/rendering/style/StyleGridItemData.cpp
index 0c9929a7d..102be908d 100644
--- a/Source/WebCore/rendering/style/StyleGridItemData.cpp
+++ b/Source/WebCore/rendering/style/StyleGridItemData.cpp
@@ -30,6 +30,8 @@
#include "config.h"
#include "StyleGridItemData.h"
+#if ENABLE(CSS_GRID_LAYOUT)
+
#include "RenderStyle.h"
namespace WebCore {
@@ -51,9 +53,11 @@ inline StyleGridItemData::StyleGridItemData(const StyleGridItemData& o)
{
}
-PassRef<StyleGridItemData> StyleGridItemData::copy() const
+Ref<StyleGridItemData> StyleGridItemData::copy() const
{
return adoptRef(*new StyleGridItemData(*this));
}
} // namespace WebCore
+
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
diff --git a/Source/WebCore/rendering/style/StyleGridItemData.h b/Source/WebCore/rendering/style/StyleGridItemData.h
index c0f9d987a..d6678174b 100644
--- a/Source/WebCore/rendering/style/StyleGridItemData.h
+++ b/Source/WebCore/rendering/style/StyleGridItemData.h
@@ -31,6 +31,7 @@
#ifndef StyleGridItemData_h
#define StyleGridItemData_h
+#if ENABLE(CSS_GRID_LAYOUT)
#include "GridPosition.h"
#include <wtf/PassRefPtr.h>
@@ -41,8 +42,8 @@ namespace WebCore {
class StyleGridItemData : public RefCounted<StyleGridItemData> {
public:
- static PassRef<StyleGridItemData> create() { return adoptRef(*new StyleGridItemData); }
- PassRef<StyleGridItemData> copy() const;
+ static Ref<StyleGridItemData> create() { return adoptRef(*new StyleGridItemData); }
+ Ref<StyleGridItemData> copy() const;
bool operator==(const StyleGridItemData& o) const
{
@@ -67,4 +68,6 @@ private:
} // namespace WebCore
+#endif /* ENABLE(CSS_GRID_LAYOUT) */
+
#endif // StyleGridItemData_h
diff --git a/Source/WebCore/rendering/style/StyleImage.h b/Source/WebCore/rendering/style/StyleImage.h
index a0bd45a6f..0e83f2e96 100644
--- a/Source/WebCore/rendering/style/StyleImage.h
+++ b/Source/WebCore/rendering/style/StyleImage.h
@@ -25,12 +25,12 @@
#define StyleImage_h
#include "CSSValue.h"
+#include "FloatSize.h"
#include "Image.h"
-#include "IntSize.h"
-#include "LayoutSize.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/TypeCasts.h>
namespace WebCore {
@@ -55,15 +55,15 @@ public:
virtual bool canRender(const RenderObject*, float /*multiplier*/) const { return true; }
virtual bool isLoaded() const { return true; }
virtual bool errorOccurred() const { return false; }
- virtual LayoutSize imageSize(const RenderElement*, float multiplier) const = 0;
+ virtual FloatSize imageSize(const RenderElement*, float multiplier) const = 0;
virtual void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) = 0;
virtual bool imageHasRelativeWidth() const = 0;
virtual bool imageHasRelativeHeight() const = 0;
virtual bool usesImageContainerSize() const = 0;
- virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize&, float) = 0;
+ virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) = 0;
virtual void addClient(RenderElement*) = 0;
virtual void removeClient(RenderElement*) = 0;
- virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const = 0;
+ virtual RefPtr<Image> image(RenderElement*, const FloatSize&) const = 0;
virtual WrappedImagePtr data() const = 0;
virtual float imageScaleFactor() const { return 1; }
virtual bool knownToBeOpaque(const RenderElement*) const = 0;
@@ -74,11 +74,6 @@ public:
ALWAYS_INLINE bool isGeneratedImage() const { return m_isGeneratedImage; }
ALWAYS_INLINE bool isCachedImageSet() const { return m_isCachedImageSet; }
- static bool imagesEquivalent(StyleImage* image1, StyleImage* image2)
- {
- return image1 == image2 || (image1 && image2 && *image1 == *image2);
- }
-
protected:
StyleImage()
: m_isCachedImage(false)
@@ -93,5 +88,11 @@ protected:
bool m_isCachedImageSet : 1;
};
-}
-#endif
+} // namespace WebCore
+
+#define SPECIALIZE_TYPE_TRAITS_STYLE_IMAGE(ToClassName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
+ static bool isType(const WebCore::StyleImage& image) { return image.predicate(); } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif // StyleImage_h
diff --git a/Source/WebCore/rendering/style/StyleInheritedData.cpp b/Source/WebCore/rendering/style/StyleInheritedData.cpp
index 7f2e1c551..bfceeca72 100644
--- a/Source/WebCore/rendering/style/StyleInheritedData.cpp
+++ b/Source/WebCore/rendering/style/StyleInheritedData.cpp
@@ -50,13 +50,13 @@ inline StyleInheritedData::StyleInheritedData(const StyleInheritedData& o)
#if ENABLE(IOS_TEXT_AUTOSIZING)
, specifiedLineHeight(o.specifiedLineHeight)
#endif
- , font(o.font)
+ , fontCascade(o.fontCascade)
, color(o.color)
, visitedLinkColor(o.visitedLinkColor)
{
}
-PassRef<StyleInheritedData> StyleInheritedData::copy() const
+Ref<StyleInheritedData> StyleInheritedData::copy() const
{
return adoptRef(*new StyleInheritedData(*this));
}
@@ -67,7 +67,7 @@ bool StyleInheritedData::operator==(const StyleInheritedData& o) const
#if ENABLE(IOS_TEXT_AUTOSIZING)
&& specifiedLineHeight == o.specifiedLineHeight
#endif
- && font == o.font
+ && fontCascade == o.fontCascade
&& color == o.color
&& visitedLinkColor == o.visitedLinkColor
&& horizontal_border_spacing == o.horizontal_border_spacing
diff --git a/Source/WebCore/rendering/style/StyleInheritedData.h b/Source/WebCore/rendering/style/StyleInheritedData.h
index a65beff47..ae2cf678c 100644
--- a/Source/WebCore/rendering/style/StyleInheritedData.h
+++ b/Source/WebCore/rendering/style/StyleInheritedData.h
@@ -26,9 +26,9 @@
#define StyleInheritedData_h
#include "Color.h"
-#include "Font.h"
+#include "FontCascade.h"
#include "Length.h"
-#include <wtf/PassRefPtr.h>
+#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -36,8 +36,8 @@ namespace WebCore {
class StyleInheritedData : public RefCounted<StyleInheritedData> {
public:
- static PassRef<StyleInheritedData> create() { return adoptRef(*new StyleInheritedData); }
- PassRef<StyleInheritedData> copy() const;
+ static Ref<StyleInheritedData> create() { return adoptRef(*new StyleInheritedData); }
+ Ref<StyleInheritedData> copy() const;
~StyleInheritedData();
bool operator==(const StyleInheritedData& o) const;
@@ -56,7 +56,7 @@ public:
Length specifiedLineHeight;
#endif
- Font font;
+ FontCascade fontCascade;
Color color;
Color visitedLinkColor;
diff --git a/Source/WebCore/rendering/style/StyleMarqueeData.cpp b/Source/WebCore/rendering/style/StyleMarqueeData.cpp
index 5e25e4983..597b3f776 100644
--- a/Source/WebCore/rendering/style/StyleMarqueeData.cpp
+++ b/Source/WebCore/rendering/style/StyleMarqueeData.cpp
@@ -45,7 +45,7 @@ inline StyleMarqueeData::StyleMarqueeData(const StyleMarqueeData& o)
{
}
-PassRef<StyleMarqueeData> StyleMarqueeData::copy() const
+Ref<StyleMarqueeData> StyleMarqueeData::copy() const
{
return adoptRef(*new StyleMarqueeData(*this));
}
diff --git a/Source/WebCore/rendering/style/StyleMarqueeData.h b/Source/WebCore/rendering/style/StyleMarqueeData.h
index 69e9dcc3c..dd11a6ed1 100644
--- a/Source/WebCore/rendering/style/StyleMarqueeData.h
+++ b/Source/WebCore/rendering/style/StyleMarqueeData.h
@@ -34,8 +34,8 @@ namespace WebCore {
class StyleMarqueeData : public RefCounted<StyleMarqueeData> {
public:
- static PassRef<StyleMarqueeData> create() { return adoptRef(*new StyleMarqueeData); }
- PassRef<StyleMarqueeData> copy() const;
+ static Ref<StyleMarqueeData> create() { return adoptRef(*new StyleMarqueeData); }
+ Ref<StyleMarqueeData> copy() const;
bool operator==(const StyleMarqueeData& o) const;
bool operator!=(const StyleMarqueeData& o) const
diff --git a/Source/WebCore/rendering/style/StyleMultiColData.cpp b/Source/WebCore/rendering/style/StyleMultiColData.cpp
index 68b6178ed..5c90e20a1 100644
--- a/Source/WebCore/rendering/style/StyleMultiColData.cpp
+++ b/Source/WebCore/rendering/style/StyleMultiColData.cpp
@@ -35,9 +35,6 @@ StyleMultiColData::StyleMultiColData()
, m_normalGap(true)
, m_fill(RenderStyle::initialColumnFill())
, m_columnSpan(false)
- , m_breakBefore(RenderStyle::initialPageBreak())
- , m_breakAfter(RenderStyle::initialPageBreak())
- , m_breakInside(RenderStyle::initialPageBreak())
, m_axis(RenderStyle::initialColumnAxis())
, m_progression(RenderStyle::initialColumnProgression())
{
@@ -55,15 +52,12 @@ inline StyleMultiColData::StyleMultiColData(const StyleMultiColData& o)
, m_normalGap(o.m_normalGap)
, m_fill(o.m_fill)
, m_columnSpan(o.m_columnSpan)
- , m_breakBefore(o.m_breakBefore)
- , m_breakAfter(o.m_breakAfter)
- , m_breakInside(o.m_breakInside)
, m_axis(o.m_axis)
, m_progression(o.m_progression)
{
}
-PassRef<StyleMultiColData> StyleMultiColData::copy() const
+Ref<StyleMultiColData> StyleMultiColData::copy() const
{
return adoptRef(*new StyleMultiColData(*this));
}
@@ -71,10 +65,9 @@ PassRef<StyleMultiColData> StyleMultiColData::copy() const
bool StyleMultiColData::operator==(const StyleMultiColData& o) const
{
return m_width == o.m_width && m_count == o.m_count && m_gap == o.m_gap
- && m_rule == o.m_rule && m_visitedLinkColumnRuleColor == o.m_visitedLinkColumnRuleColor && m_breakBefore == o.m_breakBefore
+ && m_rule == o.m_rule && m_visitedLinkColumnRuleColor == o.m_visitedLinkColumnRuleColor
&& m_autoWidth == o.m_autoWidth && m_autoCount == o.m_autoCount && m_normalGap == o.m_normalGap
&& m_fill == o.m_fill && m_columnSpan == o.m_columnSpan
- && m_breakAfter == o.m_breakAfter && m_breakInside == o.m_breakInside
&& m_axis == o.m_axis && m_progression == o.m_progression;
}
diff --git a/Source/WebCore/rendering/style/StyleMultiColData.h b/Source/WebCore/rendering/style/StyleMultiColData.h
index 0e42e6f29..f16ea5fd9 100644
--- a/Source/WebCore/rendering/style/StyleMultiColData.h
+++ b/Source/WebCore/rendering/style/StyleMultiColData.h
@@ -37,8 +37,8 @@ namespace WebCore {
class StyleMultiColData : public RefCounted<StyleMultiColData> {
public:
- static PassRef<StyleMultiColData> create() { return adoptRef(*new StyleMultiColData); }
- PassRef<StyleMultiColData> copy() const;
+ static Ref<StyleMultiColData> create() { return adoptRef(*new StyleMultiColData); }
+ Ref<StyleMultiColData> copy() const;
bool operator==(const StyleMultiColData& o) const;
bool operator!=(const StyleMultiColData &o) const
@@ -64,9 +64,6 @@ public:
bool m_normalGap : 1;
unsigned m_fill : 1; // ColumnFill
unsigned m_columnSpan : 1;
- unsigned m_breakBefore : 2; // EPageBreak
- unsigned m_breakAfter : 2; // EPageBreak
- unsigned m_breakInside : 2; // EPageBreak
unsigned m_axis : 2; // ColumnAxis
unsigned m_progression : 2; // ColumnProgression
diff --git a/Source/WebCore/rendering/style/StylePendingImage.h b/Source/WebCore/rendering/style/StylePendingImage.h
index 68ca1c222..1924fba7a 100644
--- a/Source/WebCore/rendering/style/StylePendingImage.h
+++ b/Source/WebCore/rendering/style/StylePendingImage.h
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY APPLE 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
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE 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
@@ -41,16 +41,16 @@ namespace WebCore {
// style resolution, in order to avoid loading images that are not referenced by the final style.
// They should never exist in a RenderStyle after it has been returned from the style selector.
-class StylePendingImage : public StyleImage {
+class StylePendingImage final : public StyleImage {
public:
- static PassRefPtr<StylePendingImage> create(CSSValue* value) { return adoptRef(new StylePendingImage(value)); }
+ static Ref<StylePendingImage> create(CSSValue* value) { return adoptRef(*new StylePendingImage(value)); }
- CSSImageValue* cssImageValue() const { return m_value && m_value->isImageValue() ? toCSSImageValue(m_value) : nullptr; }
- CSSImageGeneratorValue* cssImageGeneratorValue() const { return m_value && m_value->isImageGeneratorValue() ? static_cast<CSSImageGeneratorValue*>(m_value) : nullptr; }
- CSSCursorImageValue* cssCursorImageValue() const { return m_value && m_value->isCursorImageValue() ? toCSSCursorImageValue(m_value) : nullptr; }
+ CSSImageValue* cssImageValue() const { return is<CSSImageValue>(m_value) ? downcast<CSSImageValue>(m_value) : nullptr; }
+ CSSImageGeneratorValue* cssImageGeneratorValue() const { return is<CSSImageGeneratorValue>(m_value) ? static_cast<CSSImageGeneratorValue*>(m_value) : nullptr; }
+ CSSCursorImageValue* cssCursorImageValue() const { return is<CSSCursorImageValue>(m_value) ? downcast<CSSCursorImageValue>(m_value) : nullptr; }
#if ENABLE(CSS_IMAGE_SET)
- CSSImageSetValue* cssImageSetValue() const { return m_value && m_value->isImageSetValue() ? toCSSImageSetValue(m_value) : nullptr; }
+ CSSImageSetValue* cssImageSetValue() const { return is<CSSImageSetValue>(m_value) ? downcast<CSSImageSetValue>(m_value) : nullptr; }
#endif
void detachFromCSSValue() { m_value = nullptr; }
@@ -60,16 +60,16 @@ private:
virtual PassRefPtr<CSSValue> cssValue() const override { return m_value; }
- virtual LayoutSize imageSize(const RenderElement*, float /*multiplier*/) const override { return LayoutSize(); }
+ virtual FloatSize imageSize(const RenderElement*, float /*multiplier*/) const override { return FloatSize(); }
virtual bool imageHasRelativeWidth() const override { return false; }
virtual bool imageHasRelativeHeight() const override { return false; }
- virtual void computeIntrinsicDimensions(const RenderElement*, Length& /* intrinsicWidth */ , Length& /* intrinsicHeight */, FloatSize& /* intrinsicRatio */) { }
+ virtual void computeIntrinsicDimensions(const RenderElement*, Length& /* intrinsicWidth */ , Length& /* intrinsicHeight */, FloatSize& /* intrinsicRatio */) override { }
virtual bool usesImageContainerSize() const override { return false; }
- virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize&, float) override { }
+ virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override { }
virtual void addClient(RenderElement*) override { }
virtual void removeClient(RenderElement*) override { }
- virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const override
+ virtual RefPtr<Image> image(RenderElement*, const FloatSize&) const override
{
ASSERT_NOT_REACHED();
return nullptr;
@@ -86,6 +86,8 @@ private:
CSSValue* m_value; // Not retained; it owns us.
};
-}
+} // namespace WebCore
-#endif
+SPECIALIZE_TYPE_TRAITS_STYLE_IMAGE(StylePendingImage, isPendingImage)
+
+#endif // StylePendingImage_h
diff --git a/Source/WebCore/rendering/style/StyleRareInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
index dcca2021d..2098b9179 100644
--- a/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
+++ b/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
@@ -23,11 +23,14 @@
#include "StyleRareInheritedData.h"
#include "CursorList.h"
+#include "DataRef.h"
#include "QuotesData.h"
#include "RenderStyle.h"
#include "RenderStyleConstants.h"
#include "ShadowData.h"
+#include "StyleCustomPropertyData.h"
#include "StyleImage.h"
+#include <wtf/PointerComparison.h>
namespace WebCore {
@@ -60,6 +63,8 @@ struct GreaterThanOrSameSizeAsStyleRareInheritedData : public RefCounted<Greater
#if ENABLE(TOUCH_EVENTS)
Color tapHighlightColor;
#endif
+
+ void* customPropertyDataRefs[1];
};
COMPILE_ASSERT(sizeof(StyleRareInheritedData) <= sizeof(GreaterThanOrSameSizeAsStyleRareInheritedData), StyleRareInheritedData_should_bit_pack);
@@ -69,6 +74,7 @@ StyleRareInheritedData::StyleRareInheritedData()
, textStrokeWidth(RenderStyle::initialTextStrokeWidth())
, indent(RenderStyle::initialTextIndent())
, m_effectiveZoom(RenderStyle::initialZoom())
+ , m_customProperties(StyleCustomPropertyData::create())
, widows(RenderStyle::initialWidows())
, orphans(RenderStyle::initialOrphans())
, m_hasAutoWidows(true)
@@ -79,15 +85,13 @@ StyleRareInheritedData::StyleRareInheritedData()
, overflowWrap(RenderStyle::initialOverflowWrap())
, nbspMode(NBNORMAL)
, lineBreak(LineBreakAuto)
- , resize(RenderStyle::initialResize())
, userSelect(RenderStyle::initialUserSelect())
- , colorSpace(ColorSpaceDeviceRGB)
, speak(SpeakNormal)
, hyphens(HyphensManual)
, textEmphasisFill(TextEmphasisFillFilled)
, textEmphasisMark(TextEmphasisMarkNone)
, textEmphasisPosition(TextEmphasisPositionOver | TextEmphasisPositionRight)
- , m_textOrientation(TextOrientationVerticalRight)
+ , m_textOrientation(static_cast<unsigned>(TextOrientation::Mixed))
#if ENABLE(CSS3_TEXT)
, m_textIndentLine(RenderStyle::initialTextIndentLine())
, m_textIndentType(RenderStyle::initialTextIndentType())
@@ -113,17 +117,19 @@ StyleRareInheritedData::StyleRareInheritedData()
, m_textDecorationSkip(RenderStyle::initialTextDecorationSkip())
, m_textUnderlinePosition(RenderStyle::initialTextUnderlinePosition())
, m_rubyPosition(RenderStyle::initialRubyPosition())
+ , m_textZoom(RenderStyle::initialTextZoom())
#if PLATFORM(IOS)
, touchCalloutEnabled(RenderStyle::initialTouchCalloutEnabled())
#endif
+#if ENABLE(CSS_TRAILING_WORD)
+ , trailingWord(static_cast<unsigned>(RenderStyle::initialTrailingWord()))
+#endif
+ , m_hangingPunctuation(RenderStyle::initialHangingPunctuation())
, hyphenationLimitBefore(-1)
, hyphenationLimitAfter(-1)
, hyphenationLimitLines(-1)
, m_lineGrid(RenderStyle::initialLineGrid())
, m_tabSize(RenderStyle::initialTabSize())
-#if PLATFORM(IOS)
- , compositionFillColor(RenderStyle::initialCompositionFillColor())
-#endif
#if ENABLE(IOS_TEXT_AUTOSIZING)
, textSizeAdjust(RenderStyle::initialTextSizeAdjust())
#endif
@@ -146,11 +152,11 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
, visitedLinkTextStrokeColor(o.visitedLinkTextStrokeColor)
, visitedLinkTextFillColor(o.visitedLinkTextFillColor)
, visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor)
- , textShadow(o.textShadow ? adoptPtr(new ShadowData(*o.textShadow)) : nullptr)
- , highlight(o.highlight)
+ , textShadow(o.textShadow ? std::make_unique<ShadowData>(*o.textShadow) : nullptr)
, cursorData(o.cursorData)
, indent(o.indent)
, m_effectiveZoom(o.m_effectiveZoom)
+ , m_customProperties(o.m_customProperties)
, widows(o.widows)
, orphans(o.orphans)
, m_hasAutoWidows(o.m_hasAutoWidows)
@@ -161,9 +167,7 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
, overflowWrap(o.overflowWrap)
, nbspMode(o.nbspMode)
, lineBreak(o.lineBreak)
- , resize(o.resize)
, userSelect(o.userSelect)
- , colorSpace(o.colorSpace)
, speak(o.speak)
, hyphens(o.hyphens)
, textEmphasisFill(o.textEmphasisFill)
@@ -195,20 +199,21 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
, m_textDecorationSkip(o.m_textDecorationSkip)
, m_textUnderlinePosition(o.m_textUnderlinePosition)
, m_rubyPosition(o.m_rubyPosition)
+ , m_textZoom(o.m_textZoom)
#if PLATFORM(IOS)
, touchCalloutEnabled(o.touchCalloutEnabled)
#endif
+#if ENABLE(CSS_TRAILING_WORD)
+ , trailingWord(o.trailingWord)
+#endif
+ , m_hangingPunctuation(o.m_hangingPunctuation)
, hyphenationString(o.hyphenationString)
, hyphenationLimitBefore(o.hyphenationLimitBefore)
, hyphenationLimitAfter(o.hyphenationLimitAfter)
, hyphenationLimitLines(o.hyphenationLimitLines)
- , locale(o.locale)
, textEmphasisCustomMark(o.textEmphasisCustomMark)
, m_lineGrid(o.m_lineGrid)
, m_tabSize(o.m_tabSize)
-#if PLATFORM(IOS)
- , compositionFillColor(o.compositionFillColor)
-#endif
#if ENABLE(IOS_TEXT_AUTOSIZING)
, textSizeAdjust(o.textSizeAdjust)
#endif
@@ -221,7 +226,7 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
{
}
-PassRef<StyleRareInheritedData> StyleRareInheritedData::copy() const
+Ref<StyleRareInheritedData> StyleRareInheritedData::copy() const
{
return adoptRef(*new StyleRareInheritedData(*this));
}
@@ -230,24 +235,6 @@ StyleRareInheritedData::~StyleRareInheritedData()
{
}
-static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
-{
- if (c1 == c2)
- return true;
- if ((!c1 && c2) || (c1 && !c2))
- return false;
- return (*c1 == *c2);
-}
-
-static bool quotesDataEquivalent(const QuotesData* q1, const QuotesData* q2)
-{
- if (q1 == q2)
- return true;
- if ((!q1 && q2) || (q1 && !q2))
- return false;
- return (*q1 == *q2);
-}
-
bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
{
return textStrokeColor == o.textStrokeColor
@@ -260,9 +247,8 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
#if ENABLE(TOUCH_EVENTS)
&& tapHighlightColor == o.tapHighlightColor
#endif
- && shadowDataEquivalent(o)
- && highlight == o.highlight
- && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
+ && arePointingToEqualData(textShadow, o.textShadow)
+ && arePointingToEqualData(cursorData, o.cursorData)
&& indent == o.indent
&& m_effectiveZoom == o.m_effectiveZoom
&& widows == o.widows
@@ -281,9 +267,7 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
#if ENABLE(IOS_TEXT_AUTOSIZING)
&& textSizeAdjust == o.textSizeAdjust
#endif
- && resize == o.resize
&& userSelect == o.userSelect
- && colorSpace == o.colorSpace
&& speak == o.speak
&& hyphens == o.hyphens
&& hyphenationLimitBefore == o.hyphenationLimitBefore
@@ -300,12 +284,10 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
&& m_lineBoxContain == o.m_lineBoxContain
#if PLATFORM(IOS)
&& touchCalloutEnabled == o.touchCalloutEnabled
- && compositionFillColor == o.compositionFillColor
#endif
&& hyphenationString == o.hyphenationString
- && locale == o.locale
&& textEmphasisCustomMark == o.textEmphasisCustomMark
- && quotesDataEquivalent(quotes.get(), o.quotes.get())
+ && arePointingToEqualData(quotes, o.quotes)
&& m_tabSize == o.m_tabSize
&& m_lineGrid == o.m_lineGrid
#if ENABLE(CSS_IMAGE_ORIENTATION)
@@ -324,18 +306,15 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
&& m_textDecorationSkip == o.m_textDecorationSkip
&& m_textUnderlinePosition == o.m_textUnderlinePosition
&& m_rubyPosition == o.m_rubyPosition
+ && m_textZoom == o.m_textZoom
&& m_lineSnap == o.m_lineSnap
&& m_lineAlign == o.m_lineAlign
- && StyleImage::imagesEquivalent(listStyleImage.get(), o.listStyleImage.get());
-}
-
-bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
-{
- if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
- return false;
- if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
- return false;
- return true;
+#if ENABLE(CSS_TRAILING_WORD)
+ && trailingWord == o.trailingWord
+#endif
+ && m_hangingPunctuation == o.m_hangingPunctuation
+ && m_customProperties == o.m_customProperties
+ && arePointingToEqualData(listStyleImage, o.listStyleImage);
}
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/StyleRareInheritedData.h b/Source/WebCore/rendering/style/StyleRareInheritedData.h
index ec0183544..5f7c23636 100644
--- a/Source/WebCore/rendering/style/StyleRareInheritedData.h
+++ b/Source/WebCore/rendering/style/StyleRareInheritedData.h
@@ -26,7 +26,9 @@
#define StyleRareInheritedData_h
#include "Color.h"
+#include "DataRef.h"
#include "Length.h"
+#include "StyleCustomPropertyData.h"
#include <wtf/RefCounted.h>
#include <wtf/PassRefPtr.h>
#include <wtf/text/AtomicString.h>
@@ -47,8 +49,8 @@ class StyleImage;
// actually uses one of these properties.
class StyleRareInheritedData : public RefCounted<StyleRareInheritedData> {
public:
- static PassRef<StyleRareInheritedData> create() { return adoptRef(*new StyleRareInheritedData); }
- PassRef<StyleRareInheritedData> copy() const;
+ static Ref<StyleRareInheritedData> create() { return adoptRef(*new StyleRareInheritedData); }
+ Ref<StyleRareInheritedData> copy() const;
~StyleRareInheritedData();
bool operator==(const StyleRareInheritedData& o) const;
@@ -56,7 +58,6 @@ public:
{
return !(*this == o);
}
- bool shadowDataEquivalent(const StyleRareInheritedData&) const;
RefPtr<StyleImage> listStyleImage;
@@ -69,8 +70,7 @@ public:
Color visitedLinkTextFillColor;
Color visitedLinkTextEmphasisColor;
- OwnPtr<ShadowData> textShadow; // Our text shadow information for shadowed text drawing.
- AtomicString highlight; // Apple-specific extension for custom highlight rendering.
+ std::unique_ptr<ShadowData> textShadow; // Our text shadow information for shadowed text drawing.
RefPtr<CursorList> cursorData;
Length indent;
@@ -78,6 +78,8 @@ public:
Length wordSpacing;
+ DataRef<StyleCustomPropertyData> m_customProperties;
+
// Paged media properties.
short widows;
short orphans;
@@ -90,7 +92,6 @@ public:
unsigned overflowWrap : 1; // EOverflowWrap
unsigned nbspMode : 1; // ENBSPMode
unsigned lineBreak : 3; // LineBreak
- unsigned resize : 2; // EResize
unsigned userSelect : 2; // EUserSelect
unsigned colorSpace : 1; // ColorSpace
unsigned speak : 3; // ESpeak
@@ -108,7 +109,7 @@ public:
#if ENABLE(CSS_IMAGE_ORIENTATION)
unsigned m_imageOrientation : 4; // ImageOrientationEnum
#endif
- unsigned m_imageRendering : 2; // EImageRendering
+ unsigned m_imageRendering : 3; // EImageRendering
unsigned m_lineSnap : 2; // LineSnap
unsigned m_lineAlign : 1; // LineAlign
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
@@ -120,32 +121,34 @@ public:
#endif
#if ENABLE(CSS3_TEXT)
unsigned m_textAlignLast : 3; // TextAlignLast
- unsigned m_textJustify : 3; // TextJustify
+ unsigned m_textJustify : 2; // TextJustify
#endif // CSS3_TEXT
unsigned m_textDecorationSkip : 5; // TextDecorationSkip
unsigned m_textUnderlinePosition : 3; // TextUnderlinePosition
- unsigned m_rubyPosition : 1; // RubyPosition
+ unsigned m_rubyPosition : 2; // RubyPosition
+ unsigned m_textZoom: 1; // TextZoom
#if PLATFORM(IOS)
unsigned touchCalloutEnabled : 1;
#endif
+#if ENABLE(CSS_TRAILING_WORD)
+ unsigned trailingWord : 1;
+#endif
+
+ unsigned m_hangingPunctuation : 4;
+
AtomicString hyphenationString;
short hyphenationLimitBefore;
short hyphenationLimitAfter;
short hyphenationLimitLines;
- AtomicString locale;
-
AtomicString textEmphasisCustomMark;
RefPtr<QuotesData> quotes;
AtomicString m_lineGrid;
unsigned m_tabSize;
-#if PLATFORM(IOS)
- Color compositionFillColor;
-#endif
#if ENABLE(IOS_TEXT_AUTOSIZING)
TextSizeAdjustment textSizeAdjust;
#endif
diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
index d2bd56f70..24ae59cf2 100644
--- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
+++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
@@ -30,6 +30,9 @@
#include "StyleTransformData.h"
#include "StyleImage.h"
#include "StyleResolver.h"
+#include "StyleScrollSnapPoints.h"
+#include <wtf/PointerComparison.h>
+#include <wtf/RefPtr.h>
namespace WebCore {
@@ -41,23 +44,28 @@ StyleRareNonInheritedData::StyleRareNonInheritedData()
, m_perspectiveOriginX(RenderStyle::initialPerspectiveOriginX())
, m_perspectiveOriginY(RenderStyle::initialPerspectiveOriginY())
, lineClamp(RenderStyle::initialLineClamp())
+ , m_initialLetter(RenderStyle::initialInitialLetter())
, m_deprecatedFlexibleBox(StyleDeprecatedFlexibleBoxData::create())
, m_flexibleBox(StyleFlexibleBoxData::create())
, m_marquee(StyleMarqueeData::create())
, m_multiCol(StyleMultiColData::create())
, m_transform(StyleTransformData::create())
-#if ENABLE(CSS_FILTERS)
, m_filter(StyleFilterData::create())
+#if ENABLE(FILTERS_LEVEL_2)
+ , m_backdropFilter(StyleFilterData::create())
#endif
+#if ENABLE(CSS_GRID_LAYOUT)
, m_grid(StyleGridData::create())
, m_gridItem(StyleGridItemData::create())
+#endif
+#if ENABLE(CSS_SCROLL_SNAP)
+ , m_scrollSnapPoints(StyleScrollSnapPoints::create())
+#endif
+ , m_willChange(RenderStyle::initialWillChange())
, m_mask(FillLayer(MaskFillLayer))
- , m_pageSize()
#if ENABLE(CSS_SHAPES)
- , m_shapeInside(RenderStyle::initialShapeInside())
, m_shapeOutside(RenderStyle::initialShapeOutside())
, m_shapeMargin(RenderStyle::initialShapeMargin())
- , m_shapePadding(RenderStyle::initialShapePadding())
, m_shapeImageThreshold(RenderStyle::initialShapeImageThreshold())
#endif
, m_clipPath(RenderStyle::initialClipPath())
@@ -65,17 +73,22 @@ StyleRareNonInheritedData::StyleRareNonInheritedData()
, m_order(RenderStyle::initialOrder())
, m_flowThread(RenderStyle::initialFlowThread())
, m_regionThread(RenderStyle::initialRegionThread())
+ , m_alignContent(RenderStyle::initialContentAlignment())
+ , m_alignItems(RenderStyle::initialSelfAlignment())
+ , m_alignSelf(RenderStyle::initialSelfAlignment())
+ , m_justifyContent(RenderStyle::initialContentAlignment())
+ , m_justifyItems(RenderStyle::initialSelfAlignment())
+ , m_justifySelf(RenderStyle::initialSelfAlignment())
+#if ENABLE(TOUCH_EVENTS)
+ , m_touchAction(static_cast<unsigned>(RenderStyle::initialTouchAction()))
+#endif
+#if ENABLE(CSS_SCROLL_SNAP)
+ , m_scrollSnapType(static_cast<unsigned>(RenderStyle::initialScrollSnapType()))
+#endif
, m_regionFragment(RenderStyle::initialRegionFragment())
- , m_regionBreakAfter(RenderStyle::initialPageBreak())
- , m_regionBreakBefore(RenderStyle::initialPageBreak())
- , m_regionBreakInside(RenderStyle::initialPageBreak())
, m_pageSizeType(PAGE_SIZE_AUTO)
, m_transformStyle3D(RenderStyle::initialTransformStyle3D())
, m_backfaceVisibility(RenderStyle::initialBackfaceVisibility())
- , m_alignContent(RenderStyle::initialAlignContent())
- , m_alignItems(RenderStyle::initialAlignItems())
- , m_alignSelf(RenderStyle::initialAlignSelf())
- , m_justifyContent(RenderStyle::initialJustifyContent())
, userDrag(RenderStyle::initialUserDrag())
, textOverflow(RenderStyle::initialTextOverflow())
, marginBeforeCollapse(MCOLLAPSE)
@@ -84,16 +97,17 @@ StyleRareNonInheritedData::StyleRareNonInheritedData()
, m_borderFit(RenderStyle::initialBorderFit())
, m_textCombine(RenderStyle::initialTextCombine())
, m_textDecorationStyle(RenderStyle::initialTextDecorationStyle())
- , m_wrapFlow(RenderStyle::initialWrapFlow())
- , m_wrapThrough(RenderStyle::initialWrapThrough())
-#if USE(ACCELERATED_COMPOSITING)
, m_runningAcceleratedAnimation(false)
-#endif
- , m_hasAspectRatio(false)
+ , m_aspectRatioType(RenderStyle::initialAspectRatioType())
#if ENABLE(CSS_COMPOSITING)
, m_effectiveBlendMode(RenderStyle::initialBlendMode())
+ , m_isolation(RenderStyle::initialIsolation())
#endif
, m_objectFit(RenderStyle::initialObjectFit())
+ , m_breakBefore(RenderStyle::initialBreakBetween())
+ , m_breakAfter(RenderStyle::initialBreakBetween())
+ , m_breakInside(RenderStyle::initialBreakInside())
+ , m_resize(RenderStyle::initialResize())
{
m_maskBoxImage.setMaskDefaults();
}
@@ -107,30 +121,37 @@ inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonIn
, m_perspectiveOriginX(o.m_perspectiveOriginX)
, m_perspectiveOriginY(o.m_perspectiveOriginY)
, lineClamp(o.lineClamp)
+ , m_initialLetter(o.m_initialLetter)
, m_deprecatedFlexibleBox(o.m_deprecatedFlexibleBox)
, m_flexibleBox(o.m_flexibleBox)
, m_marquee(o.m_marquee)
, m_multiCol(o.m_multiCol)
, m_transform(o.m_transform)
-#if ENABLE(CSS_FILTERS)
, m_filter(o.m_filter)
+#if ENABLE(FILTERS_LEVEL_2)
+ , m_backdropFilter(o.m_backdropFilter)
#endif
+#if ENABLE(CSS_GRID_LAYOUT)
, m_grid(o.m_grid)
, m_gridItem(o.m_gridItem)
+#endif
+#if ENABLE(CSS_SCROLL_SNAP)
+ , m_scrollSnapPoints(o.m_scrollSnapPoints)
+#endif
, m_content(o.m_content ? o.m_content->clone() : nullptr)
, m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr)
- , m_boxShadow(o.m_boxShadow ? adoptPtr(new ShadowData(*o.m_boxShadow)) : nullptr)
+ , m_altText(o.m_altText)
+ , m_boxShadow(o.m_boxShadow ? std::make_unique<ShadowData>(*o.m_boxShadow) : nullptr)
+ , m_willChange(o.m_willChange)
, m_boxReflect(o.m_boxReflect)
- , m_animations(o.m_animations ? adoptPtr(new AnimationList(*o.m_animations)) : nullptr)
- , m_transitions(o.m_transitions ? adoptPtr(new AnimationList(*o.m_transitions)) : nullptr)
+ , m_animations(o.m_animations ? std::make_unique<AnimationList>(*o.m_animations) : nullptr)
+ , m_transitions(o.m_transitions ? std::make_unique<AnimationList>(*o.m_transitions) : nullptr)
, m_mask(o.m_mask)
, m_maskBoxImage(o.m_maskBoxImage)
, m_pageSize(o.m_pageSize)
#if ENABLE(CSS_SHAPES)
- , m_shapeInside(o.m_shapeInside)
, m_shapeOutside(o.m_shapeOutside)
, m_shapeMargin(o.m_shapeMargin)
- , m_shapePadding(o.m_shapePadding)
, m_shapeImageThreshold(o.m_shapeImageThreshold)
#endif
, m_clipPath(o.m_clipPath)
@@ -145,17 +166,22 @@ inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonIn
, m_order(o.m_order)
, m_flowThread(o.m_flowThread)
, m_regionThread(o.m_regionThread)
- , m_regionFragment(o.m_regionFragment)
- , m_regionBreakAfter(o.m_regionBreakAfter)
- , m_regionBreakBefore(o.m_regionBreakBefore)
- , m_regionBreakInside(o.m_regionBreakInside)
- , m_pageSizeType(o.m_pageSizeType)
- , m_transformStyle3D(o.m_transformStyle3D)
- , m_backfaceVisibility(o.m_backfaceVisibility)
, m_alignContent(o.m_alignContent)
, m_alignItems(o.m_alignItems)
, m_alignSelf(o.m_alignSelf)
, m_justifyContent(o.m_justifyContent)
+ , m_justifyItems(o.m_justifyItems)
+ , m_justifySelf(o.m_justifySelf)
+#if ENABLE(TOUCH_EVENTS)
+ , m_touchAction(o.m_touchAction)
+#endif
+#if ENABLE(CSS_SCROLL_SNAP)
+ , m_scrollSnapType(o.m_scrollSnapType)
+#endif
+ , m_regionFragment(o.m_regionFragment)
+ , m_pageSizeType(o.m_pageSizeType)
+ , m_transformStyle3D(o.m_transformStyle3D)
+ , m_backfaceVisibility(o.m_backfaceVisibility)
, userDrag(o.userDrag)
, textOverflow(o.textOverflow)
, marginBeforeCollapse(o.marginBeforeCollapse)
@@ -164,20 +190,21 @@ inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonIn
, m_borderFit(o.m_borderFit)
, m_textCombine(o.m_textCombine)
, m_textDecorationStyle(o.m_textDecorationStyle)
- , m_wrapFlow(o.m_wrapFlow)
- , m_wrapThrough(o.m_wrapThrough)
-#if USE(ACCELERATED_COMPOSITING)
, m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation)
-#endif
- , m_hasAspectRatio(o.m_hasAspectRatio)
+ , m_aspectRatioType(o.m_aspectRatioType)
#if ENABLE(CSS_COMPOSITING)
, m_effectiveBlendMode(o.m_effectiveBlendMode)
+ , m_isolation(o.m_isolation)
#endif
, m_objectFit(o.m_objectFit)
+ , m_breakBefore(o.m_breakBefore)
+ , m_breakAfter(o.m_breakAfter)
+ , m_breakInside(o.m_breakInside)
+ , m_resize(o.m_resize)
{
}
-PassRef<StyleRareNonInheritedData> StyleRareNonInheritedData::copy() const
+Ref<StyleRareNonInheritedData> StyleRareNonInheritedData::copy() const
{
return adoptRef(*new StyleRareNonInheritedData(*this));
}
@@ -195,6 +222,7 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
&& m_perspectiveOriginX == o.m_perspectiveOriginX
&& m_perspectiveOriginY == o.m_perspectiveOriginY
&& lineClamp == o.lineClamp
+ && m_initialLetter == o.m_initialLetter
#if ENABLE(DASHBOARD_SUPPORT)
&& m_dashboardRegions == o.m_dashboardRegions
#endif
@@ -203,28 +231,34 @@ 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
+#if ENABLE(FILTERS_LEVEL_2)
+ && m_backdropFilter == o.m_backdropFilter
#endif
+#if ENABLE(CSS_GRID_LAYOUT)
&& m_grid == o.m_grid
&& m_gridItem == o.m_gridItem
+#endif
+#if ENABLE(CSS_SCROLL_SNAP)
+ && m_scrollSnapPoints == o.m_scrollSnapPoints
+#endif
&& contentDataEquivalent(o)
- && counterDataEquivalent(o)
- && shadowDataEquivalent(o)
- && reflectionDataEquivalent(o)
- && animationDataEquivalent(o)
- && transitionDataEquivalent(o)
+ && arePointingToEqualData(m_counterDirectives, o.m_counterDirectives)
+ && m_altText == o.m_altText
+ && arePointingToEqualData(m_boxShadow, o.m_boxShadow)
+ && arePointingToEqualData(m_willChange, o.m_willChange)
+ && arePointingToEqualData(m_boxReflect, o.m_boxReflect)
+ && arePointingToEqualData(m_animations, o.m_animations)
+ && arePointingToEqualData(m_transitions, o.m_transitions)
&& m_mask == o.m_mask
&& m_maskBoxImage == o.m_maskBoxImage
&& m_pageSize == o.m_pageSize
#if ENABLE(CSS_SHAPES)
- && m_shapeInside == o.m_shapeInside
- && m_shapeOutside == o.m_shapeOutside
+ && arePointingToEqualData(m_shapeOutside, o.m_shapeOutside)
&& m_shapeMargin == o.m_shapeMargin
- && m_shapePadding == o.m_shapePadding
&& m_shapeImageThreshold == o.m_shapeImageThreshold
#endif
- && m_clipPath == o.m_clipPath
+ && arePointingToEqualData(m_clipPath, o.m_clipPath)
&& m_textDecorationColor == o.m_textDecorationColor
&& m_visitedLinkTextDecorationColor == o.m_visitedLinkTextDecorationColor
&& m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
@@ -235,18 +269,17 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
&& m_visitedLinkBorderBottomColor == o.m_visitedLinkBorderBottomColor
&& m_order == o.m_order
&& m_flowThread == o.m_flowThread
+ && m_alignContent == o.m_alignContent
+ && m_alignItems == o.m_alignItems
+ && m_alignSelf == o.m_alignSelf
+ && m_justifyContent == o.m_justifyContent
+ && m_justifyItems == o.m_justifyItems
+ && m_justifySelf == o.m_justifySelf
&& m_regionThread == o.m_regionThread
&& m_regionFragment == o.m_regionFragment
- && m_regionBreakAfter == o.m_regionBreakAfter
- && m_regionBreakBefore == o.m_regionBreakBefore
- && m_regionBreakInside == o.m_regionBreakInside
&& m_pageSizeType == o.m_pageSizeType
&& m_transformStyle3D == o.m_transformStyle3D
&& m_backfaceVisibility == o.m_backfaceVisibility
- && m_alignContent == o.m_alignContent
- && m_alignItems == o.m_alignItems
- && m_alignSelf == o.m_alignSelf
- && m_justifyContent == o.m_justifyContent
&& userDrag == o.userDrag
&& textOverflow == o.textOverflow
&& marginBeforeCollapse == o.marginBeforeCollapse
@@ -255,16 +288,23 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
&& m_borderFit == o.m_borderFit
&& m_textCombine == o.m_textCombine
&& m_textDecorationStyle == o.m_textDecorationStyle
- && m_wrapFlow == o.m_wrapFlow
- && m_wrapThrough == o.m_wrapThrough
-#if USE(ACCELERATED_COMPOSITING)
- && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation
+#if ENABLE(TOUCH_EVENTS)
+ && m_touchAction == o.m_touchAction
+#endif
+#if ENABLE(CSS_SCROLL_SNAP)
+ && m_scrollSnapType == o.m_scrollSnapType
#endif
+ && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation
#if ENABLE(CSS_COMPOSITING)
&& m_effectiveBlendMode == o.m_effectiveBlendMode
+ && m_isolation == o.m_isolation
#endif
- && m_hasAspectRatio == o.m_hasAspectRatio
- && m_objectFit == o.m_objectFit;
+ && m_aspectRatioType == o.m_aspectRatioType
+ && m_objectFit == o.m_objectFit
+ && m_breakAfter == o.m_breakAfter
+ && m_breakBefore == o.m_breakBefore
+ && m_breakInside == o.m_breakInside
+ && m_resize == o.m_resize;
}
bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const
@@ -280,61 +320,16 @@ bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInherite
return !a && !b;
}
-bool StyleRareNonInheritedData::counterDataEquivalent(const StyleRareNonInheritedData& o) const
-{
- if (m_counterDirectives.get() == o.m_counterDirectives.get())
- return true;
-
- if (m_counterDirectives && o.m_counterDirectives && *m_counterDirectives == *o.m_counterDirectives)
- return true;
-
- return false;
-}
-
-bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
-{
- if ((!m_boxShadow && o.m_boxShadow) || (m_boxShadow && !o.m_boxShadow))
- return false;
- if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow))
- return false;
- return true;
-}
-
-bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const
-{
- if (m_boxReflect != o.m_boxReflect) {
- if (!m_boxReflect || !o.m_boxReflect)
- return false;
- return *m_boxReflect == *o.m_boxReflect;
- }
- return true;
-}
-
-bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const
+bool StyleRareNonInheritedData::hasFilters() const
{
- if ((!m_animations && o.m_animations) || (m_animations && !o.m_animations))
- return false;
- if (m_animations && o.m_animations && (*m_animations != *o.m_animations))
- return false;
- return true;
+ return m_filter.get() && !m_filter->m_operations.isEmpty();
}
-bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const
+#if ENABLE(FILTERS_LEVEL_2)
+bool StyleRareNonInheritedData::hasBackdropFilters() const
{
- if ((!m_transitions && o.m_transitions) || (m_transitions && !o.m_transitions))
- return false;
- if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions))
- return false;
- return true;
+ return m_backdropFilter.get() && !m_backdropFilter->m_operations.isEmpty();
}
-
-bool StyleRareNonInheritedData::hasFilters() const
-{
-#if ENABLE(CSS_FILTERS)
- return m_filter.get() && !m_filter->m_operations.isEmpty();
-#else
- return false;
#endif
-}
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h
index 4523f3be4..9b1b2ad53 100644
--- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h
+++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h
@@ -26,6 +26,7 @@
#define StyleRareNonInheritedData_h
#include "BasicShapes.h"
+#include "CSSPropertyNames.h"
#include "ClipPathOperation.h"
#include "CounterDirectives.h"
#include "CursorData.h"
@@ -34,7 +35,10 @@
#include "LineClampValue.h"
#include "NinePieceImage.h"
#include "ShapeValue.h"
-#include <wtf/OwnPtr.h>
+#include "StyleContentAlignmentData.h"
+#include "StyleSelfAlignmentData.h"
+#include "WillChangeData.h"
+#include <memory>
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
@@ -43,17 +47,20 @@ namespace WebCore {
class AnimationList;
class ShadowData;
class StyleDeprecatedFlexibleBoxData;
-#if ENABLE(CSS_FILTERS)
class StyleFilterData;
-#endif
class StyleFlexibleBoxData;
+#if ENABLE(CSS_GRID_LAYOUT)
class StyleGridData;
class StyleGridItemData;
+#endif
class StyleMarqueeData;
class StyleMultiColData;
class StyleReflection;
class StyleResolver;
class StyleTransformData;
+#if ENABLE(CSS_SCROLL_SNAP)
+class StyleScrollSnapPoints;
+#endif
class ContentData;
struct LengthSize;
@@ -77,22 +84,23 @@ enum PageSizeType {
// actually uses one of these properties.
class StyleRareNonInheritedData : public RefCounted<StyleRareNonInheritedData> {
public:
- static PassRef<StyleRareNonInheritedData> create() { return adoptRef(*new StyleRareNonInheritedData); }
- PassRef<StyleRareNonInheritedData> copy() const;
+ static Ref<StyleRareNonInheritedData> create() { return adoptRef(*new StyleRareNonInheritedData); }
+ Ref<StyleRareNonInheritedData> copy() const;
~StyleRareNonInheritedData();
bool operator==(const StyleRareNonInheritedData&) const;
bool operator!=(const StyleRareNonInheritedData& o) const { return !(*this == o); }
bool contentDataEquivalent(const StyleRareNonInheritedData&) const;
- bool counterDataEquivalent(const StyleRareNonInheritedData&) const;
- bool shadowDataEquivalent(const StyleRareNonInheritedData&) const;
- bool reflectionDataEquivalent(const StyleRareNonInheritedData&) const;
- bool animationDataEquivalent(const StyleRareNonInheritedData&) const;
- bool transitionDataEquivalent(const StyleRareNonInheritedData&) const;
+
bool hasFilters() const;
+#if ENABLE(FILTERS_LEVEL_2)
+ bool hasBackdropFilters() const;
+#endif
bool hasOpacity() const { return opacity < 1; }
+ bool hasAnimationsOrTransitions() const { return m_animations || m_transitions; }
+
float opacity;
float m_aspectRatioDenominator;
@@ -103,6 +111,9 @@ public:
Length m_perspectiveOriginY;
LineClampValue lineClamp; // An Apple extension.
+
+ IntSize m_initialLetter;
+
#if ENABLE(DASHBOARD_SUPPORT)
Vector<StyleDashboardRegion> m_dashboardRegions;
#endif
@@ -112,24 +123,32 @@ public:
DataRef<StyleMarqueeData> m_marquee; // Marquee properties
DataRef<StyleMultiColData> m_multiCol; // CSS3 multicol properties
DataRef<StyleTransformData> m_transform; // Transform properties (rotate, scale, skew, etc.)
-
-#if ENABLE(CSS_FILTERS)
DataRef<StyleFilterData> m_filter; // Filter operations (url, sepia, blur, etc.)
+#if ENABLE(FILTERS_LEVEL_2)
+ DataRef<StyleFilterData> m_backdropFilter; // Filter operations (url, sepia, blur, etc.)
#endif
+#if ENABLE(CSS_GRID_LAYOUT)
DataRef<StyleGridData> m_grid;
DataRef<StyleGridItemData> m_gridItem;
+#endif
+
+#if ENABLE(CSS_SCROLL_SNAP)
+ DataRef<StyleScrollSnapPoints> m_scrollSnapPoints;
+#endif
std::unique_ptr<ContentData> m_content;
- OwnPtr<CounterDirectiveMap> m_counterDirectives;
+ std::unique_ptr<CounterDirectiveMap> m_counterDirectives;
String m_altText;
- OwnPtr<ShadowData> m_boxShadow; // For box-shadow decorations.
+ std::unique_ptr<ShadowData> m_boxShadow; // For box-shadow decorations.
+
+ RefPtr<WillChangeData> m_willChange; // Null indicates 'auto'.
RefPtr<StyleReflection> m_boxReflect;
- OwnPtr<AnimationList> m_animations;
- OwnPtr<AnimationList> m_transitions;
+ std::unique_ptr<AnimationList> m_animations;
+ std::unique_ptr<AnimationList> m_transitions;
FillLayer m_mask;
NinePieceImage m_maskBoxImage;
@@ -137,10 +156,8 @@ public:
LengthSize m_pageSize;
#if ENABLE(CSS_SHAPES)
- RefPtr<ShapeValue> m_shapeInside;
RefPtr<ShapeValue> m_shapeOutside;
Length m_shapeMargin;
- Length m_shapePadding;
float m_shapeImageThreshold;
#endif
@@ -159,20 +176,28 @@ public:
AtomicString m_flowThread;
AtomicString m_regionThread;
- unsigned m_regionFragment : 1; // RegionFragment
- unsigned m_regionBreakAfter : 2; // EPageBreak
- unsigned m_regionBreakBefore : 2; // EPageBreak
- unsigned m_regionBreakInside : 2; // EPageBreak
+ StyleContentAlignmentData m_alignContent;
+ StyleSelfAlignmentData m_alignItems;
+ StyleSelfAlignmentData m_alignSelf;
+ StyleContentAlignmentData m_justifyContent;
+ StyleSelfAlignmentData m_justifyItems;
+ StyleSelfAlignmentData m_justifySelf;
+
+#if ENABLE(TOUCH_EVENTS)
+ unsigned m_touchAction : 1; // TouchAction
+#endif
+
+#if ENABLE(CSS_SCROLL_SNAP)
+ unsigned m_scrollSnapType : 2; // ScrollSnapType
+#endif
+
+ unsigned m_regionFragment : 1; // RegionFragment
unsigned m_pageSizeType : 2; // PageSizeType
unsigned m_transformStyle3D : 1; // ETransformStyle3D
unsigned m_backfaceVisibility : 1; // EBackfaceVisibility
- unsigned m_alignContent : 3; // EAlignContent
- unsigned m_alignItems : 3; // EAlignItems
- unsigned m_alignSelf : 3; // EAlignItems
- unsigned m_justifyContent : 3; // EJustifyContent
unsigned userDrag : 2; // EUserDrag
unsigned textOverflow : 1; // Whether or not lines that spill out should be truncated with "..."
@@ -183,20 +208,22 @@ public:
unsigned m_textCombine : 1; // CSS3 text-combine properties
unsigned m_textDecorationStyle : 3; // TextDecorationStyle
- unsigned m_wrapFlow: 3; // WrapFlow
- unsigned m_wrapThrough: 1; // WrapThrough
-#if USE(ACCELERATED_COMPOSITING)
unsigned m_runningAcceleratedAnimation : 1;
-#endif
- unsigned m_hasAspectRatio : 1; // Whether or not an aspect ratio has been specified.
+ unsigned m_aspectRatioType : 2;
#if ENABLE(CSS_COMPOSITING)
unsigned m_effectiveBlendMode: 5; // EBlendMode
+ unsigned m_isolation : 1; // Isolation
#endif
unsigned m_objectFit : 3; // ObjectFit
+
+ unsigned m_breakBefore : 4; // BreakBetween
+ unsigned m_breakAfter : 4;
+ unsigned m_breakInside : 3; // BreakInside
+ unsigned m_resize : 2; // EResize
private:
StyleRareNonInheritedData();
diff --git a/Source/WebCore/rendering/style/StyleReflection.h b/Source/WebCore/rendering/style/StyleReflection.h
index 45b93e204..17f7f7195 100644
--- a/Source/WebCore/rendering/style/StyleReflection.h
+++ b/Source/WebCore/rendering/style/StyleReflection.h
@@ -34,9 +34,9 @@ namespace WebCore {
class StyleReflection : public RefCounted<StyleReflection> {
public:
- static PassRefPtr<StyleReflection> create()
+ static Ref<StyleReflection> create()
{
- return adoptRef(new StyleReflection);
+ return adoptRef(*new StyleReflection);
}
bool operator==(const StyleReflection& o) const
@@ -50,7 +50,7 @@ public:
const NinePieceImage& mask() const { return m_mask; }
void setDirection(CSSReflectionDirection dir) { m_direction = dir; }
- void setOffset(Length offset) { m_offset = std::move(offset); }
+ void setOffset(Length offset) { m_offset = WTFMove(offset); }
void setMask(const NinePieceImage& image) { m_mask = image; }
private:
diff --git a/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp b/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp
new file mode 100644
index 000000000..8d8858f84
--- /dev/null
+++ b/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2014 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "StyleScrollSnapPoints.h"
+
+#if ENABLE(CSS_SCROLL_SNAP)
+
+namespace WebCore {
+
+ScrollSnapPoints::ScrollSnapPoints()
+ : repeatOffset(100, Percent)
+ , hasRepeat(true)
+ , usesElements(false)
+{
+}
+
+bool operator==(const ScrollSnapPoints& a, const ScrollSnapPoints& b)
+{
+ return a.repeatOffset == b.repeatOffset
+ && a.hasRepeat == b.hasRepeat
+ && a.usesElements == b.usesElements
+ && a.offsets == b.offsets;
+}
+
+LengthSize defaultScrollSnapDestination()
+{
+ return LengthSize(Length(0, Fixed), Length(0, Fixed));
+}
+
+StyleScrollSnapPoints::StyleScrollSnapPoints()
+ : destination(defaultScrollSnapDestination())
+{
+}
+
+inline StyleScrollSnapPoints::StyleScrollSnapPoints(const StyleScrollSnapPoints& other)
+ : RefCounted()
+ , xPoints(other.xPoints ? std::make_unique<ScrollSnapPoints>(*other.xPoints) : nullptr)
+ , yPoints(other.yPoints ? std::make_unique<ScrollSnapPoints>(*other.yPoints) : nullptr)
+ , destination(other.destination)
+ , coordinates(other.coordinates)
+{
+}
+
+Ref<StyleScrollSnapPoints> StyleScrollSnapPoints::copy() const
+{
+ return adoptRef(*new StyleScrollSnapPoints(*this));
+}
+
+bool operator==(const StyleScrollSnapPoints& a, const StyleScrollSnapPoints& b)
+{
+ return a.xPoints == b.xPoints
+ && a.yPoints == b.yPoints
+ && a.destination == b.destination
+ && a.coordinates == b.coordinates;
+}
+
+} // namespace WebCore
+
+#endif /* ENABLE(CSS_SCROLL_SNAP) */
diff --git a/Source/WebCore/rendering/style/StyleScrollSnapPoints.h b/Source/WebCore/rendering/style/StyleScrollSnapPoints.h
new file mode 100644
index 000000000..a4861f835
--- /dev/null
+++ b/Source/WebCore/rendering/style/StyleScrollSnapPoints.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 StyleScrollSnapPoints_h
+#define StyleScrollSnapPoints_h
+
+#if ENABLE(CSS_SCROLL_SNAP)
+
+#include "LengthSize.h"
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+struct ScrollSnapPoints {
+ Length repeatOffset;
+ bool hasRepeat;
+ bool usesElements;
+ Vector<Length> offsets;
+
+ ScrollSnapPoints();
+};
+
+bool operator==(const ScrollSnapPoints&, const ScrollSnapPoints&);
+inline bool operator!=(const ScrollSnapPoints& a, const ScrollSnapPoints& b) { return !(a == b); }
+
+LengthSize defaultScrollSnapDestination();
+
+class StyleScrollSnapPoints : public RefCounted<StyleScrollSnapPoints> {
+public:
+ static Ref<StyleScrollSnapPoints> create() { return adoptRef(*new StyleScrollSnapPoints); }
+ Ref<StyleScrollSnapPoints> copy() const;
+
+ std::unique_ptr<ScrollSnapPoints> xPoints;
+ std::unique_ptr<ScrollSnapPoints> yPoints;
+ LengthSize destination;
+ Vector<LengthSize> coordinates;
+
+private:
+ StyleScrollSnapPoints();
+ StyleScrollSnapPoints(const StyleScrollSnapPoints&);
+};
+
+bool operator==(const StyleScrollSnapPoints&, const StyleScrollSnapPoints&);
+inline bool operator!=(const StyleScrollSnapPoints& a, const StyleScrollSnapPoints& b) { return !(a == b); }
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_SCROLL_SNAP)
+
+#endif // StyleScrollSnapPoints_h
diff --git a/Source/WebCore/rendering/style/StyleSelfAlignmentData.h b/Source/WebCore/rendering/style/StyleSelfAlignmentData.h
new file mode 100644
index 000000000..895558d42
--- /dev/null
+++ b/Source/WebCore/rendering/style/StyleSelfAlignmentData.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2015 Igalia S.L. 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 StyleSelfAlignmentData_h
+#define StyleSelfAlignmentData_h
+
+#include "RenderStyleConstants.h"
+
+
+namespace WebCore {
+
+class StyleSelfAlignmentData {
+public:
+ // Style data for Self-Aligment and Default-Alignment properties: align-{self, items}, justify-{self, items}.
+ // [ <self-position> && <overflow-position>? ] | [ legacy && [ left | right | center ] ]
+ StyleSelfAlignmentData(ItemPosition position, OverflowAlignment overflow, ItemPositionType positionType = NonLegacyPosition)
+ : m_position(position)
+ , m_positionType(positionType)
+ , m_overflow(overflow)
+ {
+ }
+
+ void setPosition(ItemPosition position) { m_position = position; }
+ void setPositionType(ItemPositionType positionType) { m_positionType = positionType; }
+ void setOverflow(OverflowAlignment overflow) { m_overflow = overflow; }
+
+ ItemPosition position() const { return static_cast<ItemPosition>(m_position); }
+ ItemPositionType positionType() const { return static_cast<ItemPositionType>(m_positionType); }
+ OverflowAlignment overflow() const { return static_cast<OverflowAlignment>(m_overflow); }
+
+ bool operator==(const StyleSelfAlignmentData& o) const
+ {
+ return m_position == o.m_position && m_positionType == o.m_positionType && m_overflow == o.m_overflow;
+ }
+
+ bool operator!=(const StyleSelfAlignmentData& o) const
+ {
+ return !(*this == o);
+ }
+
+private:
+ unsigned m_position : 4; // ItemPosition
+ unsigned m_positionType: 1; // Whether or not alignment uses the 'legacy' keyword.
+ unsigned m_overflow : 2; // OverflowAlignment
+};
+
+} // namespace WebCore
+
+#endif // StyleSelfAlignmentData_h
diff --git a/Source/WebCore/rendering/style/StyleSurroundData.cpp b/Source/WebCore/rendering/style/StyleSurroundData.cpp
index 766a70f46..5c9bbdbec 100644
--- a/Source/WebCore/rendering/style/StyleSurroundData.cpp
+++ b/Source/WebCore/rendering/style/StyleSurroundData.cpp
@@ -39,7 +39,7 @@ inline StyleSurroundData::StyleSurroundData(const StyleSurroundData& o)
{
}
-PassRef<StyleSurroundData> StyleSurroundData::copy() const
+Ref<StyleSurroundData> StyleSurroundData::copy() const
{
return adoptRef(*new StyleSurroundData(*this));
}
diff --git a/Source/WebCore/rendering/style/StyleSurroundData.h b/Source/WebCore/rendering/style/StyleSurroundData.h
index 0dce31811..00bf5f0b3 100644
--- a/Source/WebCore/rendering/style/StyleSurroundData.h
+++ b/Source/WebCore/rendering/style/StyleSurroundData.h
@@ -34,8 +34,8 @@ namespace WebCore {
class StyleSurroundData : public RefCounted<StyleSurroundData> {
public:
- static PassRef<StyleSurroundData> create() { return adoptRef(*new StyleSurroundData); }
- PassRef<StyleSurroundData> copy() const;
+ static Ref<StyleSurroundData> create() { return adoptRef(*new StyleSurroundData); }
+ Ref<StyleSurroundData> copy() const;
bool operator==(const StyleSurroundData& o) const;
bool operator!=(const StyleSurroundData& o) const
diff --git a/Source/WebCore/rendering/style/StyleTransformData.cpp b/Source/WebCore/rendering/style/StyleTransformData.cpp
index c3f91ea2a..eaf310b63 100644
--- a/Source/WebCore/rendering/style/StyleTransformData.cpp
+++ b/Source/WebCore/rendering/style/StyleTransformData.cpp
@@ -43,7 +43,7 @@ inline StyleTransformData::StyleTransformData(const StyleTransformData& o)
{
}
-PassRef<StyleTransformData> StyleTransformData::copy() const
+Ref<StyleTransformData> StyleTransformData::copy() const
{
return adoptRef(*new StyleTransformData(*this));
}
diff --git a/Source/WebCore/rendering/style/StyleTransformData.h b/Source/WebCore/rendering/style/StyleTransformData.h
index e82ea2063..b8fb09053 100644
--- a/Source/WebCore/rendering/style/StyleTransformData.h
+++ b/Source/WebCore/rendering/style/StyleTransformData.h
@@ -34,14 +34,16 @@ namespace WebCore {
class StyleTransformData : public RefCounted<StyleTransformData> {
public:
- static PassRef<StyleTransformData> create() { return adoptRef(*new StyleTransformData); }
- PassRef<StyleTransformData> copy() const;
+ static Ref<StyleTransformData> create() { return adoptRef(*new StyleTransformData); }
+ Ref<StyleTransformData> copy() const;
bool operator==(const StyleTransformData& o) const;
bool operator!=(const StyleTransformData& o) const
{
return !(*this == o);
}
+
+ bool hasTransform() const { return m_operations.size(); }
TransformOperations m_operations;
Length m_x;
diff --git a/Source/WebCore/rendering/style/StyleVisualData.cpp b/Source/WebCore/rendering/style/StyleVisualData.cpp
index 23e6cd225..d8fb8869b 100644
--- a/Source/WebCore/rendering/style/StyleVisualData.cpp
+++ b/Source/WebCore/rendering/style/StyleVisualData.cpp
@@ -52,7 +52,7 @@ inline StyleVisualData::StyleVisualData(const StyleVisualData& o)
{
}
-PassRef<StyleVisualData> StyleVisualData::copy() const
+Ref<StyleVisualData> StyleVisualData::copy() const
{
return adoptRef(*new StyleVisualData(*this));
}
diff --git a/Source/WebCore/rendering/style/StyleVisualData.h b/Source/WebCore/rendering/style/StyleVisualData.h
index 2b2d63027..5b2496ca3 100644
--- a/Source/WebCore/rendering/style/StyleVisualData.h
+++ b/Source/WebCore/rendering/style/StyleVisualData.h
@@ -34,8 +34,8 @@ namespace WebCore {
class StyleVisualData : public RefCounted<StyleVisualData> {
public:
- static PassRef<StyleVisualData> create() { return adoptRef(*new StyleVisualData); }
- PassRef<StyleVisualData> copy() const;
+ static Ref<StyleVisualData> create() { return adoptRef(*new StyleVisualData); }
+ Ref<StyleVisualData> copy() const;
~StyleVisualData();
bool operator==(const StyleVisualData& o) const
diff --git a/Source/WebCore/rendering/style/TextSizeAdjustment.h b/Source/WebCore/rendering/style/TextSizeAdjustment.h
new file mode 100644
index 000000000..d56d6760c
--- /dev/null
+++ b/Source/WebCore/rendering/style/TextSizeAdjustment.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TextSizeAdjustment_h
+#define TextSizeAdjustment_h
+
+#if ENABLE(IOS_TEXT_AUTOSIZING)
+
+enum TextSizeAdjustmentType { AutoTextSizeAdjustment = -1, NoTextSizeAdjustment = -2 };
+
+class TextSizeAdjustment {
+public:
+ TextSizeAdjustment() : m_value(AutoTextSizeAdjustment) { }
+ TextSizeAdjustment(float value) : m_value(value) { }
+
+ float percentage() const { return m_value; }
+ float multiplier() const { return m_value / 100; }
+
+ bool isAuto() const { return m_value == AutoTextSizeAdjustment; }
+ bool isNone() const { return m_value == NoTextSizeAdjustment; }
+ bool isPercentage() const { return m_value >= 0; }
+
+ bool operator==(const TextSizeAdjustment& anAdjustment) const { return m_value == anAdjustment.m_value; }
+ bool operator!=(const TextSizeAdjustment& anAdjustment) const { return m_value != anAdjustment.m_value; }
+
+private:
+ float m_value;
+};
+
+#endif // ENABLE(IOS_TEXT_AUTOSIZING)
+
+#endif // TextSizeAdjustment_h
diff --git a/Source/WebCore/rendering/style/WillChangeData.cpp b/Source/WebCore/rendering/style/WillChangeData.cpp
new file mode 100644
index 000000000..77d4aa871
--- /dev/null
+++ b/Source/WebCore/rendering/style/WillChangeData.cpp
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2015 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WillChangeData.h"
+
+namespace WebCore {
+
+bool WillChangeData::operator==(const WillChangeData& other) const
+{
+ return m_animatableFeatures == other.m_animatableFeatures;
+}
+
+bool WillChangeData::containsScrollPosition() const
+{
+ for (const auto& feature : m_animatableFeatures) {
+ if (feature.feature() == ScrollPosition)
+ return true;
+ }
+ return false;
+}
+
+bool WillChangeData::containsContents() const
+{
+ for (const auto& feature : m_animatableFeatures) {
+ if (feature.feature() == Contents)
+ return true;
+ }
+ return false;
+}
+
+bool WillChangeData::containsProperty(CSSPropertyID property) const
+{
+ for (const auto& feature : m_animatableFeatures) {
+ if (feature.property() == property)
+ return true;
+ }
+ return false;
+}
+
+// "If any non-initial value of a property would create a stacking context on the element,
+// specifying that property in will-change must create a stacking context on the element."
+static bool propertyCreatesStackingContext(CSSPropertyID property)
+{
+ switch (property) {
+ case CSSPropertyPerspective:
+ case CSSPropertyTransform:
+ case CSSPropertyTransformStyle:
+ case CSSPropertyWebkitTransformStyle:
+ case CSSPropertyClipPath:
+ case CSSPropertyWebkitClipPath:
+ case CSSPropertyMask:
+ case CSSPropertyOpacity:
+ case CSSPropertyPosition:
+ case CSSPropertyZIndex:
+ case CSSPropertyWebkitBoxReflect:
+#if ENABLE(CSS_COMPOSITING)
+ case CSSPropertyMixBlendMode:
+ case CSSPropertyIsolation:
+#endif
+ case CSSPropertyFilter:
+#if ENABLE(FILTERS_LEVEL_2)
+ case CSSPropertyWebkitBackdropFilter:
+#endif
+ case CSSPropertyWebkitMask:
+ case CSSPropertyWebkitMaskImage:
+ case CSSPropertyWebkitMaskBoxImage:
+#if ENABLE(CSS_REGIONS)
+ case CSSPropertyWebkitFlowFrom:
+#endif
+#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
+ case CSSPropertyWebkitOverflowScrolling:
+#endif
+ return true;
+ default:
+ return false;
+ }
+}
+
+static bool propertyTriggersCompositing(CSSPropertyID property)
+{
+ switch (property) {
+ case CSSPropertyOpacity:
+ case CSSPropertyFilter:
+#if ENABLE(FILTERS_LEVEL_2)
+ case CSSPropertyWebkitBackdropFilter:
+#endif
+ return true;
+ default:
+ return false;
+ }
+}
+
+static bool propertyTriggersCompositingOnBoxesOnly(CSSPropertyID property)
+{
+ // Don't trigger for perspective and transform-style, because those
+ // only do compositing if they have a 3d-transformed descendant and
+ // we don't want to do compositing all the time.
+ // Similarly, we don't want -webkit-overflow-scrolling-touch to
+ // always composite if there's no scrollable overflow.
+ switch (property) {
+ case CSSPropertyTransform:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void WillChangeData::addFeature(Feature feature, CSSPropertyID propertyID)
+{
+ ASSERT(feature == Property || propertyID == CSSPropertyInvalid);
+ m_animatableFeatures.append(AnimatableFeature(feature, propertyID));
+
+ m_canCreateStackingContext |= propertyCreatesStackingContext(propertyID);
+
+ m_canTriggerCompositingOnInline |= propertyTriggersCompositing(propertyID);
+ m_canTriggerCompositing |= m_canTriggerCompositingOnInline | propertyTriggersCompositingOnBoxesOnly(propertyID);
+}
+
+WillChangeData::FeaturePropertyPair WillChangeData::featureAt(size_t index) const
+{
+ if (index >= m_animatableFeatures.size())
+ return FeaturePropertyPair(Invalid, CSSPropertyInvalid);
+
+ return m_animatableFeatures[index].featurePropertyPair();
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/WillChangeData.h b/Source/WebCore/rendering/style/WillChangeData.h
new file mode 100644
index 000000000..49e76089d
--- /dev/null
+++ b/Source/WebCore/rendering/style/WillChangeData.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2015 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WillChangeData_h
+#define WillChangeData_h
+
+#include "CSSPropertyNames.h"
+#include "RenderStyleConstants.h"
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class WillChangeData : public RefCounted<WillChangeData> {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ static Ref<WillChangeData> create()
+ {
+ return adoptRef(*new WillChangeData);
+ }
+
+ bool operator==(const WillChangeData&) const;
+ bool operator!=(const WillChangeData& o) const
+ {
+ return !(*this == o);
+ }
+
+ bool isAuto() const { return m_animatableFeatures.isEmpty(); }
+ size_t numFeatures() const { return m_animatableFeatures.size(); }
+
+ bool containsScrollPosition() const;
+ bool containsContents() const;
+ bool containsProperty(CSSPropertyID) const;
+
+ bool canCreateStackingContext() const { return m_canCreateStackingContext; }
+ bool canTriggerCompositing() const { return m_canTriggerCompositing; }
+ bool canTriggerCompositingOnInline() const { return m_canTriggerCompositingOnInline; }
+
+ enum Feature {
+ ScrollPosition,
+ Contents,
+ Property,
+ Invalid
+ };
+
+ void addFeature(Feature, CSSPropertyID = CSSPropertyInvalid);
+
+ typedef std::pair<Feature, CSSPropertyID> FeaturePropertyPair;
+ FeaturePropertyPair featureAt(size_t) const;
+
+private:
+ WillChangeData()
+ {
+ }
+
+ struct AnimatableFeature {
+ static const int numCSSPropertyIDBits = 14;
+ COMPILE_ASSERT(numCSSProperties < (1 << numCSSPropertyIDBits), CSSPropertyID_should_fit_in_14_bits);
+
+ unsigned m_feature : 2;
+ unsigned m_cssPropertyID : numCSSPropertyIDBits;
+
+ Feature feature() const
+ {
+ return static_cast<Feature>(m_feature);
+ }
+
+ CSSPropertyID property() const
+ {
+ return feature() == Property ? static_cast<CSSPropertyID>(m_cssPropertyID) : CSSPropertyInvalid;
+ }
+
+ FeaturePropertyPair featurePropertyPair() const
+ {
+ return FeaturePropertyPair(feature(), property());
+ }
+
+ AnimatableFeature(Feature willChange, CSSPropertyID willChangeProperty = CSSPropertyInvalid)
+ {
+ switch (willChange) {
+ case Property:
+ ASSERT(willChangeProperty != CSSPropertyInvalid);
+ m_cssPropertyID = willChangeProperty;
+ FALLTHROUGH;
+ case ScrollPosition:
+ case Contents:
+ m_feature = static_cast<unsigned>(willChange);
+ break;
+ case Invalid:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
+ bool operator==(const AnimatableFeature& other) const
+ {
+ return m_feature == other.m_feature && m_cssPropertyID == other.m_cssPropertyID;
+ }
+ };
+
+ Vector<AnimatableFeature, 1> m_animatableFeatures;
+ bool m_canCreateStackingContext { false };
+ bool m_canTriggerCompositing { false };
+ bool m_canTriggerCompositingOnInline { false };
+};
+
+
+} // namespace WebCore
+
+#endif // WillChangeData_h