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..2a0cc16ed8666799994551820159d8ee4e73c46a 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,56 @@ void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p |
result.append(value); |
} |
+String StylePropertySerializer::offsetValue() const |
Timothy Loh
2016/09/27 08:17:48
This is going to do the wrong thing when the ancho
Eric Willigers
2016/09/29 03:53:18
Now changed to never read them if not enabled.
|
+{ |
+ int offsetPositionPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyOffsetPosition); |
+ int offsetPathPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyOffsetPath); |
+ int offsetDistancePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyOffsetDistance); |
+ int offsetRotationPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyOffsetRotation); |
+ int offsetAnchorPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyOffsetAnchor); |
+ DCHECK_NE(offsetPositionPropertyIndex, -1); |
+ DCHECK_NE(offsetPathPropertyIndex, -1); |
+ DCHECK_NE(offsetDistancePropertyIndex, -1); |
+ DCHECK_NE(offsetRotationPropertyIndex, -1); |
+ DCHECK_NE(offsetAnchorPropertyIndex, -1); |
+ |
+ PropertyValueForSerializer offsetPositionProperty = m_propertySet.propertyAt(offsetPositionPropertyIndex); |
+ PropertyValueForSerializer offsetPathProperty = m_propertySet.propertyAt(offsetPathPropertyIndex); |
+ PropertyValueForSerializer offsetDistanceProperty = m_propertySet.propertyAt(offsetDistancePropertyIndex); |
+ PropertyValueForSerializer offsetRotationProperty = m_propertySet.propertyAt(offsetRotationPropertyIndex); |
+ PropertyValueForSerializer offsetAnchorProperty = m_propertySet.propertyAt(offsetAnchorPropertyIndex); |
+ |
+ const CSSValue* offsetPositionValue = offsetPositionProperty.value(); |
Timothy Loh
2016/09/27 08:17:48
= m_propertySet.getPropertyCSSValue(CSSPropertyOff
Eric Willigers
2016/09/29 03:53:18
Done.
|
+ const CSSValue* offsetPathValue = offsetPathProperty.value(); |
+ const CSSValue* offsetDistanceValue = offsetDistanceProperty.value(); |
+ const CSSValue* offsetRotationValue = offsetRotationProperty.value(); |
+ const CSSValue* offsetAnchorValue = offsetAnchorProperty.value(); |
+ |
+ StringBuilder result; |
+ if (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 = false; |
+ if (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); |