Commit ba9df880 authored by fs's avatar fs Committed by Commit bot

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@{#419382}
parent 911e6e4e
......@@ -41,18 +41,29 @@ namespace blink {
static CSSValue* valueForCenterCoordinate(const ComputedStyle& style, const BasicShapeCenterCoordinate& center, EBoxOrient orientation)
{
if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft)
return CSSPrimitiveValue::create(center.length(), style);
return CSSPrimitiveValue::create(center.length(), style.effectiveZoom());
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)
{
switch (radius.type()) {
case BasicShapeRadius::Value:
return CSSPrimitiveValue::create(radius.value(), style);
return CSSPrimitiveValue::create(radius.value(), style.effectiveZoom());
case BasicShapeRadius::ClosestSide:
return CSSPrimitiveValue::createIdentifier(CSSValueClosestSide);
case BasicShapeRadius::FarthestSide:
......@@ -91,24 +102,26 @@ CSSValue* valueForBasicShape(const ComputedStyle& style, const BasicShape* basic
polygonValue->setWindRule(polygon->getWindRule());
const Vector<Length>& values = polygon->values();
for (unsigned i = 0; i < values.size(); i += 2)
polygonValue->appendPoint(CSSPrimitiveValue::create(values.at(i), style), CSSPrimitiveValue::create(values.at(i + 1), style));
for (unsigned i = 0; i < values.size(); i += 2) {
polygonValue->appendPoint(
CSSPrimitiveValue::create(values.at(i), style.effectiveZoom()),
CSSPrimitiveValue::create(values.at(i + 1), style.effectiveZoom()));
}
return polygonValue;
}
case BasicShape::BasicShapeInsetType: {
const BasicShapeInset* inset = toBasicShapeInset(basicShape);
CSSBasicShapeInsetValue* insetValue = CSSBasicShapeInsetValue::create();
insetValue->setTop(CSSPrimitiveValue::create(inset->top(), style));
insetValue->setRight(CSSPrimitiveValue::create(inset->right(), style));
insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom(), style));
insetValue->setLeft(CSSPrimitiveValue::create(inset->left(), style));
insetValue->setTop(CSSPrimitiveValue::create(inset->top(), style.effectiveZoom()));
insetValue->setRight(CSSPrimitiveValue::create(inset->right(), style.effectiveZoom()));
insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom(), style.effectiveZoom()));
insetValue->setLeft(CSSPrimitiveValue::create(inset->left(), style.effectiveZoom()));
insetValue->setTopLeftRadius(CSSValuePair::create(inset->topLeftRadius(), style));
insetValue->setTopRightRadius(CSSValuePair::create(inset->topRightRadius(), style));
insetValue->setBottomRightRadius(CSSValuePair::create(inset->bottomRightRadius(), style));
insetValue->setBottomLeftRadius(CSSValuePair::create(inset->bottomLeftRadius(), style));
insetValue->setTopLeftRadius(valueForLengthSize(inset->topLeftRadius(), style));
insetValue->setTopRightRadius(valueForLengthSize(inset->topRightRadius(), style));
insetValue->setBottomRightRadius(valueForLengthSize(inset->bottomRightRadius(), style));
insetValue->setBottomLeftRadius(valueForLengthSize(inset->bottomLeftRadius(), style));
return insetValue;
}
......
......@@ -25,14 +25,8 @@
#include "core/css/CSSMarkup.h"
#include "core/css/CSSToLengthConversionData.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/fonts/FontMetrics.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/StringBuffer.h"
#include "wtf/text/StringBuilder.h"
using namespace WTF;
......@@ -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>;
static CSSTextCache& cssTextCache()
......
......@@ -29,7 +29,6 @@
#include "wtf/BitVector.h"
#include "wtf/Forward.h"
#include "wtf/MathExtras.h"
#include "wtf/PassRefPtr.h"
#include "wtf/TypeTraits.h"
#include "wtf/text/StringHash.h"
#include "wtf/text/StringView.h"
......@@ -39,7 +38,6 @@ namespace blink {
class CSSCalcValue;
class CSSToLengthConversionData;
class Length;
class ComputedStyle;
// 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
......@@ -209,9 +207,6 @@ public:
static CSSPrimitiveValue* createIdentifier(CSSValueID);
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)
{
return new CSSPrimitiveValue(value, zoom);
......
......@@ -22,11 +22,7 @@
#define CSSValuePair_h
#include "core/CoreExport.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValue.h"
#include "core/style/ComputedStyle.h"
#include "platform/Length.h"
#include "wtf/text/StringBuilder.h"
namespace blink {
......@@ -40,11 +36,6 @@ public:
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& second() const { return *m_second; }
......
......@@ -25,9 +25,6 @@
#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 "wtf/Threading.h"
......
......@@ -87,7 +87,7 @@ static CSSPrimitiveValue* zoomAdjustedPixelValueForLength(const Length& length,
{
if (length.isFixed())
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)
......@@ -95,7 +95,7 @@ static CSSPrimitiveValue* pixelValueForUnzoomedLength(const UnzoomedLength& unzo
const Length& length = unzoomedLength.length();
if (length.isFixed())
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)
......@@ -313,6 +313,13 @@ static CSSBorderImageSliceValue* valueForNinePieceImageSlice(const NinePieceImag
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)
{
// Create the slices.
......@@ -321,41 +328,27 @@ static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box,
CSSPrimitiveValue* bottom = nullptr;
CSSPrimitiveValue* left = nullptr;
if (box.top().isNumber())
top = CSSPrimitiveValue::create(box.top().number(), CSSPrimitiveValue::UnitType::Number);
else
top = CSSPrimitiveValue::create(box.top().length(), style);
top = valueForBorderImageLength(box.top(), style);
if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
right = top;
bottom = top;
left = top;
} else {
if (box.right().isNumber())
right = CSSPrimitiveValue::create(box.right().number(), CSSPrimitiveValue::UnitType::Number);
else
right = CSSPrimitiveValue::create(box.right().length(), style);
right = valueForBorderImageLength(box.right(), style);
if (box.bottom() == box.top() && box.right() == box.left()) {
bottom = top;
left = right;
} else {
if (box.bottom().isNumber())
bottom = CSSPrimitiveValue::create(box.bottom().number(), CSSPrimitiveValue::UnitType::Number);
else
bottom = CSSPrimitiveValue::create(box.bottom().length(), style);
bottom = valueForBorderImageLength(box.bottom(), style);
if (box.left() == box.right()) {
if (box.left() == box.right())
left = right;
} else {
if (box.left().isNumber())
left = CSSPrimitiveValue::create(box.left().number(), CSSPrimitiveValue::UnitType::Number);
else
left = CSSPrimitiveValue::create(box.left().length(), style);
}
else
left = valueForBorderImageLength(box.left(), style);
}
}
return CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::SerializeAsQuad);
}
......@@ -2659,7 +2652,7 @@ const CSSValue* ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, cons
}
return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyShapeMargin:
return CSSPrimitiveValue::create(style.shapeMargin(), style);
return CSSPrimitiveValue::create(style.shapeMargin(), style.effectiveZoom());
case CSSPropertyShapeImageThreshold:
return CSSPrimitiveValue::create(style.shapeImageThreshold(), CSSPrimitiveValue::UnitType::Number);
case CSSPropertyShapeOutside:
......
......@@ -14,7 +14,9 @@
#include "core/css/CSSStringValue.h"
#include "core/css/CSSURIValue.h"
#include "core/css/CSSValuePair.h"
#include "core/css/StyleColor.h"
#include "core/frame/UseCounter.h"
#include "platform/RuntimeEnabledFeatures.h"
namespace blink {
......
......@@ -17,6 +17,7 @@
namespace blink {
class ComputedStyle;
class Document;
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