Commit 533dcff1 authored by avi's avatar avi Committed by Commit bot

Revert of Evacuate ComputedStyle references from the CSS*Value hierarchy...

Revert of Evacuate ComputedStyle references from the CSS*Value hierarchy (patchset #1 id:1 of https://codereview.chromium.org/2345893004/ )

Reason for revert:
Tree is red; this patch fails to compile:

../../third_party/WebKit/Source/core/css/CSSValuePair.h:42:12: error: incomplete result type 'WTF::String' in function definition
    String customCSSText() const

Original issue's description:
> 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.
>
> Committed: https://crrev.com/ba9df880383908b052d5a7d00abb32deec94cfc5
> Cr-Commit-Position: refs/heads/master@{#419382}

TBR=sashab@chromium.org,timloh@chromium.org,fs@opera.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2343343002
Cr-Commit-Position: refs/heads/master@{#419385}
parent e1cc00be
...@@ -41,29 +41,18 @@ namespace blink { ...@@ -41,29 +41,18 @@ 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.effectiveZoom()); return CSSPrimitiveValue::create(center.length(), style);
CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBottom; CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBottom;
return CSSValuePair::create( return CSSValuePair::create(CSSPrimitiveValue::createIdentifier(keyword), CSSPrimitiveValue::create(center.length(), style), CSSValuePair::DropIdenticalValues);
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.effectiveZoom()); return CSSPrimitiveValue::create(radius.value(), style);
case BasicShapeRadius::ClosestSide: case BasicShapeRadius::ClosestSide:
return CSSPrimitiveValue::createIdentifier(CSSValueClosestSide); return CSSPrimitiveValue::createIdentifier(CSSValueClosestSide);
case BasicShapeRadius::FarthestSide: case BasicShapeRadius::FarthestSide:
...@@ -102,26 +91,24 @@ CSSValue* valueForBasicShape(const ComputedStyle& style, const BasicShape* basic ...@@ -102,26 +91,24 @@ 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( polygonValue->appendPoint(CSSPrimitiveValue::create(values.at(i), style), CSSPrimitiveValue::create(values.at(i + 1), style));
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.effectiveZoom())); insetValue->setTop(CSSPrimitiveValue::create(inset->top(), style));
insetValue->setRight(CSSPrimitiveValue::create(inset->right(), style.effectiveZoom())); insetValue->setRight(CSSPrimitiveValue::create(inset->right(), style));
insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom(), style.effectiveZoom())); insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom(), style));
insetValue->setLeft(CSSPrimitiveValue::create(inset->left(), style.effectiveZoom())); insetValue->setLeft(CSSPrimitiveValue::create(inset->left(), style));
insetValue->setTopLeftRadius(valueForLengthSize(inset->topLeftRadius(), style)); insetValue->setTopLeftRadius(CSSValuePair::create(inset->topLeftRadius(), style));
insetValue->setTopRightRadius(valueForLengthSize(inset->topRightRadius(), style)); insetValue->setTopRightRadius(CSSValuePair::create(inset->topRightRadius(), style));
insetValue->setBottomRightRadius(valueForLengthSize(inset->bottomRightRadius(), style)); insetValue->setBottomRightRadius(CSSValuePair::create(inset->bottomRightRadius(), style));
insetValue->setBottomLeftRadius(valueForLengthSize(inset->bottomLeftRadius(), style)); insetValue->setBottomLeftRadius(CSSValuePair::create(inset->bottomLeftRadius(), style));
return insetValue; return insetValue;
} }
......
...@@ -25,8 +25,14 @@ ...@@ -25,8 +25,14 @@
#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;
...@@ -140,6 +146,11 @@ CSSPrimitiveValue* CSSPrimitiveValue::create(double value, UnitType type) ...@@ -140,6 +146,11 @@ 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,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#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"
...@@ -38,6 +39,7 @@ namespace blink { ...@@ -38,6 +39,7 @@ 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
...@@ -207,6 +209,9 @@ public: ...@@ -207,6 +209,9 @@ 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,7 +22,11 @@ ...@@ -22,7 +22,11 @@
#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 "platform/Length.h"
#include "wtf/text/StringBuilder.h"
namespace blink { namespace blink {
...@@ -36,6 +40,11 @@ public: ...@@ -36,6 +40,11 @@ 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,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#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.effectiveZoom()); return CSSPrimitiveValue::create(length, style);
} }
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.effectiveZoom()); return CSSPrimitiveValue::create(length, style);
} }
static CSSValueList* createPositionListForLayer(CSSPropertyID propertyID, const FillLayer& layer, const ComputedStyle& style) static CSSValueList* createPositionListForLayer(CSSPropertyID propertyID, const FillLayer& layer, const ComputedStyle& style)
...@@ -313,13 +313,6 @@ static CSSBorderImageSliceValue* valueForNinePieceImageSlice(const NinePieceImag ...@@ -313,13 +313,6 @@ 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.
...@@ -328,27 +321,41 @@ static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box, ...@@ -328,27 +321,41 @@ static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box,
CSSPrimitiveValue* bottom = nullptr; CSSPrimitiveValue* bottom = nullptr;
CSSPrimitiveValue* left = nullptr; CSSPrimitiveValue* left = nullptr;
top = valueForBorderImageLength(box.top(), style); if (box.top().isNumber())
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 {
right = valueForBorderImageLength(box.right(), style); if (box.right().isNumber())
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 {
bottom = valueForBorderImageLength(box.bottom(), style); if (box.bottom().isNumber())
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 {
left = valueForBorderImageLength(box.left(), style); if (box.left().isNumber())
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);
} }
...@@ -2652,7 +2659,7 @@ const CSSValue* ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, cons ...@@ -2652,7 +2659,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.effectiveZoom()); return CSSPrimitiveValue::create(style.shapeMargin(), style);
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,9 +14,7 @@ ...@@ -14,9 +14,7 @@
#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,7 +17,6 @@ ...@@ -17,7 +17,6 @@
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