Commit 387c6ce7 authored by fs's avatar fs Committed by Commit bot

Reland of Evacuate ComputedStyle references from the CSS*Value hierarchy

Fold uses of:

  CSSPrimitiveValue::create(..., const ComputedStyle&)
  CSSValuePair::create(..., const ComputedStyle&)

into the (few) users. Handle the fall-out.

Review-Url: https://codereview.chromium.org/2345893004
Cr-Commit-Position: refs/heads/master@{#419390}
parent 7e410b31
...@@ -41,18 +41,29 @@ namespace blink { ...@@ -41,18 +41,29 @@ namespace blink {
static CSSValue* valueForCenterCoordinate(const ComputedStyle& style, const BasicShapeCenterCoordinate& center, EBoxOrient orientation) static CSSValue* valueForCenterCoordinate(const ComputedStyle& style, const BasicShapeCenterCoordinate& center, EBoxOrient orientation)
{ {
if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft) if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft)
return CSSPrimitiveValue::create(center.length(), style); return CSSPrimitiveValue::create(center.length(), style.effectiveZoom());
CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBottom; CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBottom;
return CSSValuePair::create(CSSPrimitiveValue::createIdentifier(keyword), CSSPrimitiveValue::create(center.length(), style), CSSValuePair::DropIdenticalValues); return CSSValuePair::create(
CSSPrimitiveValue::createIdentifier(keyword),
CSSPrimitiveValue::create(center.length(), style.effectiveZoom()),
CSSValuePair::DropIdenticalValues);
}
static CSSValuePair* valueForLengthSize(const LengthSize& lengthSize, const ComputedStyle& style)
{
return CSSValuePair::create(
CSSPrimitiveValue::create(lengthSize.width(), style.effectiveZoom()),
CSSPrimitiveValue::create(lengthSize.height(), style.effectiveZoom()),
CSSValuePair::KeepIdenticalValues);
} }
static CSSPrimitiveValue* basicShapeRadiusToCSSValue(const ComputedStyle& style, const BasicShapeRadius& radius) static CSSPrimitiveValue* basicShapeRadiusToCSSValue(const ComputedStyle& style, const BasicShapeRadius& radius)
{ {
switch (radius.type()) { switch (radius.type()) {
case BasicShapeRadius::Value: case BasicShapeRadius::Value:
return CSSPrimitiveValue::create(radius.value(), style); return CSSPrimitiveValue::create(radius.value(), style.effectiveZoom());
case BasicShapeRadius::ClosestSide: case BasicShapeRadius::ClosestSide:
return CSSPrimitiveValue::createIdentifier(CSSValueClosestSide); return CSSPrimitiveValue::createIdentifier(CSSValueClosestSide);
case BasicShapeRadius::FarthestSide: case BasicShapeRadius::FarthestSide:
...@@ -91,24 +102,26 @@ CSSValue* valueForBasicShape(const ComputedStyle& style, const BasicShape* basic ...@@ -91,24 +102,26 @@ CSSValue* valueForBasicShape(const ComputedStyle& style, const BasicShape* basic
polygonValue->setWindRule(polygon->getWindRule()); polygonValue->setWindRule(polygon->getWindRule());
const Vector<Length>& values = polygon->values(); const Vector<Length>& values = polygon->values();
for (unsigned i = 0; i < values.size(); i += 2) for (unsigned i = 0; i < values.size(); i += 2) {
polygonValue->appendPoint(CSSPrimitiveValue::create(values.at(i), style), CSSPrimitiveValue::create(values.at(i + 1), style)); polygonValue->appendPoint(
CSSPrimitiveValue::create(values.at(i), style.effectiveZoom()),
CSSPrimitiveValue::create(values.at(i + 1), style.effectiveZoom()));
}
return polygonValue; return polygonValue;
} }
case BasicShape::BasicShapeInsetType: { case BasicShape::BasicShapeInsetType: {
const BasicShapeInset* inset = toBasicShapeInset(basicShape); const BasicShapeInset* inset = toBasicShapeInset(basicShape);
CSSBasicShapeInsetValue* insetValue = CSSBasicShapeInsetValue::create(); CSSBasicShapeInsetValue* insetValue = CSSBasicShapeInsetValue::create();
insetValue->setTop(CSSPrimitiveValue::create(inset->top(), style)); insetValue->setTop(CSSPrimitiveValue::create(inset->top(), style.effectiveZoom()));
insetValue->setRight(CSSPrimitiveValue::create(inset->right(), style)); insetValue->setRight(CSSPrimitiveValue::create(inset->right(), style.effectiveZoom()));
insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom(), style)); insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom(), style.effectiveZoom()));
insetValue->setLeft(CSSPrimitiveValue::create(inset->left(), style)); insetValue->setLeft(CSSPrimitiveValue::create(inset->left(), style.effectiveZoom()));
insetValue->setTopLeftRadius(CSSValuePair::create(inset->topLeftRadius(), style)); insetValue->setTopLeftRadius(valueForLengthSize(inset->topLeftRadius(), style));
insetValue->setTopRightRadius(CSSValuePair::create(inset->topRightRadius(), style)); insetValue->setTopRightRadius(valueForLengthSize(inset->topRightRadius(), style));
insetValue->setBottomRightRadius(CSSValuePair::create(inset->bottomRightRadius(), style)); insetValue->setBottomRightRadius(valueForLengthSize(inset->bottomRightRadius(), style));
insetValue->setBottomLeftRadius(CSSValuePair::create(inset->bottomLeftRadius(), style)); insetValue->setBottomLeftRadius(valueForLengthSize(inset->bottomLeftRadius(), style));
return insetValue; return insetValue;
} }
......
...@@ -25,14 +25,8 @@ ...@@ -25,14 +25,8 @@
#include "core/css/CSSMarkup.h" #include "core/css/CSSMarkup.h"
#include "core/css/CSSToLengthConversionData.h" #include "core/css/CSSToLengthConversionData.h"
#include "core/css/CSSValuePool.h" #include "core/css/CSSValuePool.h"
#include "core/css/StyleSheetContents.h"
#include "core/dom/Node.h"
#include "core/style/ComputedStyle.h"
#include "platform/LayoutUnit.h" #include "platform/LayoutUnit.h"
#include "platform/fonts/FontMetrics.h"
#include "wtf/StdLibExtras.h" #include "wtf/StdLibExtras.h"
#include "wtf/text/StringBuffer.h"
#include "wtf/text/StringBuilder.h"
using namespace WTF; using namespace WTF;
...@@ -146,11 +140,6 @@ CSSPrimitiveValue* CSSPrimitiveValue::create(double value, UnitType type) ...@@ -146,11 +140,6 @@ CSSPrimitiveValue* CSSPrimitiveValue::create(double value, UnitType type)
} }
} }
CSSPrimitiveValue* CSSPrimitiveValue::create(const Length& value, const ComputedStyle& style)
{
return CSSPrimitiveValue::create(value, style.effectiveZoom());
}
using CSSTextCache = PersistentHeapHashMap<WeakMember<const CSSPrimitiveValue>, String>; using CSSTextCache = PersistentHeapHashMap<WeakMember<const CSSPrimitiveValue>, String>;
static CSSTextCache& cssTextCache() static CSSTextCache& cssTextCache()
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "wtf/BitVector.h" #include "wtf/BitVector.h"
#include "wtf/Forward.h" #include "wtf/Forward.h"
#include "wtf/MathExtras.h" #include "wtf/MathExtras.h"
#include "wtf/PassRefPtr.h"
#include "wtf/TypeTraits.h" #include "wtf/TypeTraits.h"
#include "wtf/text/StringHash.h" #include "wtf/text/StringHash.h"
#include "wtf/text/StringView.h" #include "wtf/text/StringView.h"
...@@ -39,7 +38,6 @@ namespace blink { ...@@ -39,7 +38,6 @@ namespace blink {
class CSSCalcValue; class CSSCalcValue;
class CSSToLengthConversionData; class CSSToLengthConversionData;
class Length; class Length;
class ComputedStyle;
// Dimension calculations are imprecise, often resulting in values of e.g. // Dimension calculations are imprecise, often resulting in values of e.g.
// 44.99998. We need to go ahead and round if we're really close to the next // 44.99998. We need to go ahead and round if we're really close to the next
...@@ -209,9 +207,6 @@ public: ...@@ -209,9 +207,6 @@ public:
static CSSPrimitiveValue* createIdentifier(CSSValueID); static CSSPrimitiveValue* createIdentifier(CSSValueID);
static CSSPrimitiveValue* create(double value, UnitType); static CSSPrimitiveValue* create(double value, UnitType);
// TODO(sashab): Remove this create() method, CSSPrimitiveValue should not
// reference ComputedStyle.
static CSSPrimitiveValue* create(const Length& value, const ComputedStyle&);
static CSSPrimitiveValue* create(const Length& value, float zoom) static CSSPrimitiveValue* create(const Length& value, float zoom)
{ {
return new CSSPrimitiveValue(value, zoom); return new CSSPrimitiveValue(value, zoom);
......
...@@ -22,11 +22,8 @@ ...@@ -22,11 +22,8 @@
#define CSSValuePair_h #define CSSValuePair_h
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValue.h" #include "core/css/CSSValue.h"
#include "core/style/ComputedStyle.h" #include "wtf/text/WTFString.h"
#include "platform/Length.h"
#include "wtf/text/StringBuilder.h"
namespace blink { namespace blink {
...@@ -40,11 +37,6 @@ public: ...@@ -40,11 +37,6 @@ public:
return new CSSValuePair(first, second, identicalValuesPolicy); return new CSSValuePair(first, second, identicalValuesPolicy);
} }
static CSSValuePair* create(const LengthSize& lengthSize, const ComputedStyle& style)
{
return new CSSValuePair(CSSPrimitiveValue::create(lengthSize.width(), style.effectiveZoom()), CSSPrimitiveValue::create(lengthSize.height(), style.effectiveZoom()), KeepIdenticalValues);
}
const CSSValue& first() const { return *m_first; } const CSSValue& first() const { return *m_first; }
const CSSValue& second() const { return *m_second; } const CSSValue& second() const { return *m_second; }
......
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
#include "core/css/CSSValuePool.h" #include "core/css/CSSValuePool.h"
#include "core/css/CSSValueList.h"
#include "core/css/parser/CSSParser.h"
#include "core/style/ComputedStyle.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "wtf/Threading.h" #include "wtf/Threading.h"
......
...@@ -87,7 +87,7 @@ static CSSPrimitiveValue* zoomAdjustedPixelValueForLength(const Length& length, ...@@ -87,7 +87,7 @@ static CSSPrimitiveValue* zoomAdjustedPixelValueForLength(const Length& length,
{ {
if (length.isFixed()) if (length.isFixed())
return zoomAdjustedPixelValue(length.value(), style); return zoomAdjustedPixelValue(length.value(), style);
return CSSPrimitiveValue::create(length, style); return CSSPrimitiveValue::create(length, style.effectiveZoom());
} }
static CSSPrimitiveValue* pixelValueForUnzoomedLength(const UnzoomedLength& unzoomedLength, const ComputedStyle& style) static CSSPrimitiveValue* pixelValueForUnzoomedLength(const UnzoomedLength& unzoomedLength, const ComputedStyle& style)
...@@ -95,7 +95,7 @@ static CSSPrimitiveValue* pixelValueForUnzoomedLength(const UnzoomedLength& unzo ...@@ -95,7 +95,7 @@ static CSSPrimitiveValue* pixelValueForUnzoomedLength(const UnzoomedLength& unzo
const Length& length = unzoomedLength.length(); const Length& length = unzoomedLength.length();
if (length.isFixed()) if (length.isFixed())
return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::UnitType::Pixels); return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::UnitType::Pixels);
return CSSPrimitiveValue::create(length, style); return CSSPrimitiveValue::create(length, style.effectiveZoom());
} }
static CSSValueList* createPositionListForLayer(CSSPropertyID propertyID, const FillLayer& layer, const ComputedStyle& style) static CSSValueList* createPositionListForLayer(CSSPropertyID propertyID, const FillLayer& layer, const ComputedStyle& style)
...@@ -313,6 +313,13 @@ static CSSBorderImageSliceValue* valueForNinePieceImageSlice(const NinePieceImag ...@@ -313,6 +313,13 @@ static CSSBorderImageSliceValue* valueForNinePieceImageSlice(const NinePieceImag
return CSSBorderImageSliceValue::create(CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::SerializeAsQuad), image.fill()); return CSSBorderImageSliceValue::create(CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::SerializeAsQuad), image.fill());
} }
static CSSPrimitiveValue* valueForBorderImageLength(const BorderImageLength& borderImageLength, const ComputedStyle& style)
{
if (borderImageLength.isNumber())
return CSSPrimitiveValue::create(borderImageLength.number(), CSSPrimitiveValue::UnitType::Number);
return CSSPrimitiveValue::create(borderImageLength.length(), style.effectiveZoom());
}
static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box, const ComputedStyle& style) static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box, const ComputedStyle& style)
{ {
// Create the slices. // Create the slices.
...@@ -321,41 +328,27 @@ static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box, ...@@ -321,41 +328,27 @@ static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box,
CSSPrimitiveValue* bottom = nullptr; CSSPrimitiveValue* bottom = nullptr;
CSSPrimitiveValue* left = nullptr; CSSPrimitiveValue* left = nullptr;
if (box.top().isNumber()) top = valueForBorderImageLength(box.top(), style);
top = CSSPrimitiveValue::create(box.top().number(), CSSPrimitiveValue::UnitType::Number);
else
top = CSSPrimitiveValue::create(box.top().length(), style);
if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) { if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
right = top; right = top;
bottom = top; bottom = top;
left = top; left = top;
} else { } else {
if (box.right().isNumber()) right = valueForBorderImageLength(box.right(), style);
right = CSSPrimitiveValue::create(box.right().number(), CSSPrimitiveValue::UnitType::Number);
else
right = CSSPrimitiveValue::create(box.right().length(), style);
if (box.bottom() == box.top() && box.right() == box.left()) { if (box.bottom() == box.top() && box.right() == box.left()) {
bottom = top; bottom = top;
left = right; left = right;
} else { } else {
if (box.bottom().isNumber()) bottom = valueForBorderImageLength(box.bottom(), style);
bottom = CSSPrimitiveValue::create(box.bottom().number(), CSSPrimitiveValue::UnitType::Number);
else
bottom = CSSPrimitiveValue::create(box.bottom().length(), style);
if (box.left() == box.right()) { if (box.left() == box.right())
left = right; left = right;
} else { else
if (box.left().isNumber()) left = valueForBorderImageLength(box.left(), style);
left = CSSPrimitiveValue::create(box.left().number(), CSSPrimitiveValue::UnitType::Number);
else
left = CSSPrimitiveValue::create(box.left().length(), style);
}
} }
} }
return CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::SerializeAsQuad); return CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::SerializeAsQuad);
} }
...@@ -2659,7 +2652,7 @@ const CSSValue* ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, cons ...@@ -2659,7 +2652,7 @@ const CSSValue* ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, cons
} }
return CSSPrimitiveValue::createIdentifier(CSSValueNone); return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyShapeMargin: case CSSPropertyShapeMargin:
return CSSPrimitiveValue::create(style.shapeMargin(), style); return CSSPrimitiveValue::create(style.shapeMargin(), style.effectiveZoom());
case CSSPropertyShapeImageThreshold: case CSSPropertyShapeImageThreshold:
return CSSPrimitiveValue::create(style.shapeImageThreshold(), CSSPrimitiveValue::UnitType::Number); return CSSPrimitiveValue::create(style.shapeImageThreshold(), CSSPrimitiveValue::UnitType::Number);
case CSSPropertyShapeOutside: case CSSPropertyShapeOutside:
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
#include "core/css/CSSStringValue.h" #include "core/css/CSSStringValue.h"
#include "core/css/CSSURIValue.h" #include "core/css/CSSURIValue.h"
#include "core/css/CSSValuePair.h" #include "core/css/CSSValuePair.h"
#include "core/css/StyleColor.h"
#include "core/frame/UseCounter.h" #include "core/frame/UseCounter.h"
#include "platform/RuntimeEnabledFeatures.h"
namespace blink { namespace blink {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
namespace blink { namespace blink {
class ComputedStyle;
class Document; class Document;
class FontCachePurgePreventer; class FontCachePurgePreventer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment