Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Unified Diff: third_party/WebKit/Source/core/css/StylePropertySerializer.cpp

Issue 2368013002: [WIP] CSS Motion Path: offset shorthand ready for position and anchor
Patch Set: code review feedback Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
diff --git a/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp b/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
index c067f76c1c233ecc83699205fe30ab7b41faca5f..f31bc6e63e4088702356dea8df9bacfcfab8a5a1 100644
--- a/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
+++ b/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
@@ -27,6 +27,7 @@
#include "core/css/CSSCustomPropertyDeclaration.h"
#include "core/css/CSSPendingSubstitutionValue.h"
#include "core/css/CSSPropertyMetadata.h"
+#include "core/css/CSSValuePair.h"
#include "core/css/CSSValuePool.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/StringBuilder.h"
@@ -457,7 +458,7 @@ String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const
case CSSPropertyMotion:
return getShorthandValue(motionShorthand());
case CSSPropertyOffset:
- return getShorthandValue(offsetShorthand());
+ return offsetValue();
case CSSPropertyWebkitMarginCollapse:
return getShorthandValue(webkitMarginCollapseShorthand());
case CSSPropertyOverflow:
@@ -546,6 +547,44 @@ void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p
result.append(value);
}
+String StylePropertySerializer::offsetValue() const
+{
+ const CSSValue* offsetPathValue = m_propertySet.getPropertyCSSValue(CSSPropertyOffsetPath);
+ const CSSValue* offsetDistanceValue = m_propertySet.getPropertyCSSValue(CSSPropertyOffsetDistance);
+ const CSSValue* offsetRotationValue = m_propertySet.getPropertyCSSValue(CSSPropertyOffsetRotation);
+
+ const CSSValue* offsetPositionValue = nullptr;
+ const CSSValue* offsetAnchorValue = nullptr;
+ if (RuntimeEnabledFeatures::cssOffsetPositionAnchorEnabled()) {
+ offsetPositionValue = m_propertySet.getPropertyCSSValue(CSSPropertyOffsetPosition);
+ offsetAnchorValue = m_propertySet.getPropertyCSSValue(CSSPropertyOffsetAnchor);
+ }
+
+ StringBuilder result;
+ if (offsetPositionValue && offsetPositionValue->isValuePair()) {
+ result.append(offsetPositionValue->cssText());
+ result.append(' ');
+ }
+ result.append(offsetPathValue->cssText());
+ result.append(' ');
+ result.append(offsetDistanceValue->cssText());
+ result.append(' ');
+ result.append(offsetRotationValue->cssText());
+
+ bool anchorIsCentre = !offsetAnchorValue;
+ if (offsetAnchorValue && offsetAnchorValue->isValuePair()) {
+ const CSSValuePair* pair = toCSSValuePair(offsetAnchorValue);
+ const CSSPrimitiveValue& first = toCSSPrimitiveValue(pair->first());
+ const CSSPrimitiveValue& second = toCSSPrimitiveValue(pair->second());
+ anchorIsCentre = first.isPercentage() && first.getDoubleValue() == 50 && second.isPercentage() && second.getDoubleValue() == 50;
+ }
+ if (!anchorIsCentre) {
+ result.append('/');
+ result.append(offsetAnchorValue->cssText());
+ }
+ return result.toString();
+}
+
String StylePropertySerializer::fontValue() const
{
int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontSize);

Powered by Google App Engine
This is Rietveld 408576698