summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc160
1 files changed, 15 insertions, 145 deletions
diff --git a/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc b/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc
index 8ae6921ecdf..aacccd53811 100644
--- a/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc
+++ b/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map.cc
@@ -10,161 +10,24 @@
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_variable_data.h"
+#include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/pseudo_element.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
-#include "third_party/blink/renderer/platform/transforms/matrix_3d_transform_operation.h"
-#include "third_party/blink/renderer/platform/transforms/matrix_transform_operation.h"
-#include "third_party/blink/renderer/platform/transforms/perspective_transform_operation.h"
-#include "third_party/blink/renderer/platform/transforms/skew_transform_operation.h"
namespace blink {
namespace {
-// We collapse functions like translateX into translate, since we will reify
-// them as a translate anyway.
-const CSSValue* ComputedTransformComponent(const TransformOperation& operation,
- float zoom) {
- switch (operation.GetType()) {
- case TransformOperation::kScaleX:
- case TransformOperation::kScaleY:
- case TransformOperation::kScaleZ:
- case TransformOperation::kScale:
- case TransformOperation::kScale3D: {
- const auto& scale = ToScaleTransformOperation(operation);
- CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>(
- operation.Is3DOperation() ? CSSValueID::kScale3d
- : CSSValueID::kScale);
- result->Append(*CSSNumericLiteralValue::Create(
- scale.X(), CSSPrimitiveValue::UnitType::kNumber));
- result->Append(*CSSNumericLiteralValue::Create(
- scale.Y(), CSSPrimitiveValue::UnitType::kNumber));
- if (operation.Is3DOperation()) {
- result->Append(*CSSNumericLiteralValue::Create(
- scale.Z(), CSSPrimitiveValue::UnitType::kNumber));
- }
- return result;
- }
- case TransformOperation::kTranslateX:
- case TransformOperation::kTranslateY:
- case TransformOperation::kTranslateZ:
- case TransformOperation::kTranslate:
- case TransformOperation::kTranslate3D: {
- const auto& translate = ToTranslateTransformOperation(operation);
- CSSFunctionValue* result = MakeGarbageCollected<CSSFunctionValue>(
- operation.Is3DOperation() ? CSSValueID::kTranslate3d
- : CSSValueID::kTranslate);
- result->Append(*CSSPrimitiveValue::CreateFromLength(translate.X(), zoom));
- result->Append(*CSSPrimitiveValue::CreateFromLength(translate.Y(), zoom));
- if (operation.Is3DOperation()) {
- result->Append(*CSSNumericLiteralValue::Create(
- translate.Z(), CSSPrimitiveValue::UnitType::kPixels));
- }
- return result;
- }
- case TransformOperation::kRotateX:
- case TransformOperation::kRotateY:
- case TransformOperation::kRotate3D: {
- const auto& rotate = ToRotateTransformOperation(operation);
- CSSFunctionValue* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate3d);
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.X(), CSSPrimitiveValue::UnitType::kNumber));
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.Y(), CSSPrimitiveValue::UnitType::kNumber));
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.Z(), CSSPrimitiveValue::UnitType::kNumber));
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kRotate: {
- const auto& rotate = ToRotateTransformOperation(operation);
- auto* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kRotate);
- result->Append(*CSSNumericLiteralValue::Create(
- rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kSkewX: {
- const auto& skew = ToSkewTransformOperation(operation);
- auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewX);
- result->Append(*CSSNumericLiteralValue::Create(
- skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kSkewY: {
- const auto& skew = ToSkewTransformOperation(operation);
- auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkewY);
- result->Append(*CSSNumericLiteralValue::Create(
- skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kSkew: {
- const auto& skew = ToSkewTransformOperation(operation);
- auto* result = MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kSkew);
- result->Append(*CSSNumericLiteralValue::Create(
- skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees));
- result->Append(*CSSNumericLiteralValue::Create(
- skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees));
- return result;
- }
- case TransformOperation::kPerspective: {
- const auto& perspective = ToPerspectiveTransformOperation(operation);
- auto* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kPerspective);
- result->Append(*CSSNumericLiteralValue::Create(
- perspective.Perspective(), CSSPrimitiveValue::UnitType::kPixels));
- return result;
- }
- case TransformOperation::kMatrix: {
- const auto& matrix = ToMatrixTransformOperation(operation).Matrix();
- auto* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix);
- double values[6] = {matrix.A(), matrix.B(), matrix.C(),
- matrix.D(), matrix.E(), matrix.F()};
- for (double value : values) {
- result->Append(*CSSNumericLiteralValue::Create(
- value, CSSPrimitiveValue::UnitType::kNumber));
- }
- return result;
- }
- case TransformOperation::kMatrix3D: {
- const auto& matrix = ToMatrix3DTransformOperation(operation).Matrix();
- CSSFunctionValue* result =
- MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kMatrix3d);
- double values[16] = {
- matrix.M11(), matrix.M12(), matrix.M13(), matrix.M14(),
- matrix.M21(), matrix.M22(), matrix.M23(), matrix.M24(),
- matrix.M31(), matrix.M32(), matrix.M33(), matrix.M34(),
- matrix.M41(), matrix.M42(), matrix.M43(), matrix.M44()};
- for (double value : values) {
- result->Append(*CSSNumericLiteralValue::Create(
- value, CSSPrimitiveValue::UnitType::kNumber));
- }
- return result;
- }
- case TransformOperation::kInterpolated:
- // TODO(816803): The computed value in this case is not fully spec'd
- // See https://github.com/w3c/css-houdini-drafts/issues/425
- return CSSIdentifierValue::Create(CSSValueID::kNone);
- default:
- // The remaining operations are unsupported.
- NOTREACHED();
- return CSSIdentifierValue::Create(CSSValueID::kNone);
- }
-}
-
const CSSValue* ComputedTransform(const ComputedStyle& style) {
if (style.Transform().Operations().size() == 0)
return CSSIdentifierValue::Create(CSSValueID::kNone);
CSSValueList* components = CSSValueList::CreateSpaceSeparated();
for (const auto& operation : style.Transform().Operations()) {
- components->Append(
- *ComputedTransformComponent(*operation, style.EffectiveZoom()));
+ components->Append(*ComputedStyleUtils::ValueForTransformOperation(
+ *operation, style.EffectiveZoom()));
}
return components;
}
@@ -177,9 +40,12 @@ unsigned int ComputedStylePropertyMap::size() const {
return 0;
DCHECK(StyledNode());
- return CSSComputedStyleDeclaration::ComputableProperties().size() +
+ const Document& document = StyledNode()->GetDocument();
+ return CSSComputedStyleDeclaration::ComputableProperties(
+ StyledNode()->GetExecutionContext())
+ .size() +
ComputedStyleCSSValueMapping::GetVariables(
- *style, StyledNode()->GetDocument().GetPropertyRegistry())
+ *style, document.GetPropertyRegistry())
.size();
}
@@ -242,6 +108,8 @@ const CSSValue* ComputedStylePropertyMap::GetProperty(
switch (property_id) {
case CSSPropertyID::kTransform:
return ComputedTransform(*style);
+ case CSSPropertyID::kLineHeight:
+ return ComputedStyleUtils::ComputedValueForLineHeight(*style);
default:
return CSSProperty::Get(property_id)
.CSSValueFromComputedStyle(*style, nullptr /* layout_object */,
@@ -265,11 +133,14 @@ void ComputedStylePropertyMap::ForEachProperty(
if (!style)
return;
+ DCHECK(StyledNode());
+ const Document& document = StyledNode()->GetDocument();
// Have to sort by all properties by code point, so we have to store
// them in a buffer first.
HeapVector<std::pair<CSSPropertyName, Member<const CSSValue>>> values;
for (const CSSProperty* property :
- CSSComputedStyleDeclaration::ComputableProperties()) {
+ CSSComputedStyleDeclaration::ComputableProperties(
+ StyledNode()->GetExecutionContext())) {
DCHECK(property);
DCHECK(!property->IDEquals(CSSPropertyID::kVariable));
const CSSValue* value = property->CSSValueFromComputedStyle(
@@ -278,8 +149,7 @@ void ComputedStylePropertyMap::ForEachProperty(
values.emplace_back(CSSPropertyName(property->PropertyID()), value);
}
- PropertyRegistry* registry =
- StyledNode()->GetDocument().GetPropertyRegistry();
+ const PropertyRegistry* registry = document.GetPropertyRegistry();
for (const auto& name_value :
ComputedStyleCSSValueMapping::GetVariables(*style, registry)) {