Skip to content

Commit

Permalink
Use StylePath instead of (Path)StyleMotionPath
Browse files Browse the repository at this point in the history
Replace uses of PathStyleMotionPath with StylePath and remove the former
as well as the StyleMotionPath base-class. The methods length() and
isClosed() are transferred to StylePath.
Pass const CSSValue& to StyleBuilderConverter::convertPath (fixup to
https://codereview.chromium.org/1545713003) necessitating mutability.
Convert motion-path style building to use a converter.

BUG=535429

Review URL: https://codereview.chromium.org/1649003002

Cr-Commit-Position: refs/heads/master@{#372643}
  • Loading branch information
fs authored and Commit bot committed Feb 1, 2016
1 parent 2973c23 commit 7b3f2bb
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 165 deletions.
3 changes: 0 additions & 3 deletions third_party/WebKit/Source/core/core.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,6 @@
'style/ComputedStyle.cpp',
'style/ComputedStyle.h',
'style/NinePieceImage.cpp',
'style/PathStyleMotionPath.cpp',
'style/PathStyleMotionPath.h',
'style/QuotesData.cpp',
'style/QuotesData.h',
'style/ShadowData.cpp',
Expand All @@ -800,7 +798,6 @@
'style/StyleInvalidImage.h',
'style/StyleMotionData.cpp',
'style/StyleMotionData.h',
'style/StyleMotionPath.h',
'style/StyleMotionRotation.h',
'style/StyleMultiColData.cpp',
'style/StylePath.cpp',
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/core/css/CSSPathValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CSSPathValue* CSSPathValue::emptyPathValue()
return empty.get();
}

StylePath* CSSPathValue::cachedPath()
StylePath* CSSPathValue::cachedPath() const
{
if (!m_cachedPath)
m_cachedPath = StylePath::create(m_pathByteStream);
Expand Down
4 changes: 2 additions & 2 deletions third_party/WebKit/Source/core/css/CSSPathValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CSSPathValue : public CSSValue {

static CSSPathValue* emptyPathValue();

StylePath* cachedPath();
StylePath* cachedPath() const;
String customCSSText() const;

bool equals(const CSSPathValue&) const;
Expand All @@ -36,7 +36,7 @@ class CSSPathValue : public CSSValue {
CSSPathValue(PassRefPtr<SVGPathByteStream>, StylePath*);

RefPtr<SVGPathByteStream> m_pathByteStream;
RefPtr<StylePath> m_cachedPath;
mutable RefPtr<StylePath> m_cachedPath;
};

DEFINE_CSS_VALUE_TYPE_CASTS(CSSPathValue, isPathValue());
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/core/css/CSSProperties.in
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ min-height interpolable, initial=initialMinSize, converter=convertLengthSizing
min-width interpolable, initial=initialMinSize, converter=convertLengthSizing
mix-blend-mode runtime_flag=CSSCompositing, type_name=blink::WebBlendMode, name_for_methods=BlendMode
motion-offset interpolable, converter=convertLength
motion-path custom_all
motion-path converter=convertPathOrNone
motion-rotation interpolable, converter=convertMotionRotation
object-fit type_name=ObjectFit
object-position interpolable, converter=convertPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
#include "core/layout/LayoutObject.h"
#include "core/style/ComputedStyle.h"
#include "core/style/ContentData.h"
#include "core/style/PathStyleMotionPath.h"
#include "core/style/QuotesData.h"
#include "core/style/ShadowList.h"
#include "core/style/StyleVariableData.h"
#include "core/svg/SVGPathUtilities.h"
#include "platform/LengthFunctions.h"

namespace blink {
Expand Down Expand Up @@ -2452,14 +2450,10 @@ PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID
case CSSPropertyMotion:
return valuesForShorthandProperty(motionShorthand(), style, layoutObject, styledNode, allowVisitedStyle);

case CSSPropertyMotionPath: {
const StyleMotionPath* styleMotionPath = style.motionPath();
if (!styleMotionPath)
return cssValuePool().createIdentifierValue(CSSValueNone);

ASSERT(styleMotionPath->isPathStyleMotionPath());
return CSSPathValue::create(toPathStyleMotionPath(styleMotionPath)->pathString());
}
case CSSPropertyMotionPath:
if (const StylePath* styleMotionPath = style.motionPath())
return styleMotionPath->computedCSSValue();
return cssValuePool().createIdentifierValue(CSSValueNone);

case CSSPropertyMotionOffset:
return zoomAdjustedPixelValueForLength(style.motionOffset(), style);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,9 +975,17 @@ RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
return primitiveValue.getValueID() == CSSValueFromImage ? RespectImageOrientation : DoNotRespectImageOrientation;
}

PassRefPtr<StylePath> StyleBuilderConverter::convertPath(StyleResolverState&, CSSValue& value)
PassRefPtr<StylePath> StyleBuilderConverter::convertPath(StyleResolverState&, const CSSValue& value)
{
return toCSSPathValue(value).cachedPath();
}

PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone(StyleResolverState& state, const CSSValue& value)
{
if (value.isPathValue())
return convertPath(state, value);
ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == CSSValueNone);
return nullptr;
}

} // namespace blink
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class StyleBuilderConverter {
static PassRefPtr<RotateTransformOperation> convertRotate(StyleResolverState&, const CSSValue&);
static PassRefPtr<ScaleTransformOperation> convertScale(StyleResolverState&, const CSSValue&);
static RespectImageOrientationEnum convertImageOrientation(StyleResolverState&, const CSSValue&);
static PassRefPtr<StylePath> convertPath(StyleResolverState&, CSSValue&);
static PassRefPtr<StylePath> convertPath(StyleResolverState&, const CSSValue&);
static PassRefPtr<StylePath> convertPathOrNone(StyleResolverState&, const CSSValue&);
};

template <typename T>
Expand Down
26 changes: 0 additions & 26 deletions third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#include "core/style/CounterContent.h"
#include "core/style/ComputedStyle.h"
#include "core/style/ComputedStyleConstants.h"
#include "core/style/PathStyleMotionPath.h"
#include "core/style/QuotesData.h"
#include "core/style/SVGComputedStyle.h"
#include "core/style/StyleGeneratedImage.h"
Expand Down Expand Up @@ -433,31 +432,6 @@ void StyleBuilderFunctions::applyValueCSSPropertyTransform(StyleResolverState& s
state.style()->setTransform(operations);
}

void StyleBuilderFunctions::applyInheritCSSPropertyMotionPath(StyleResolverState& state)
{
if (state.parentStyle()->motionPath())
state.style()->setMotionPath(state.parentStyle()->motionPath());
else
state.style()->resetMotionPath();
}

void StyleBuilderFunctions::applyValueCSSPropertyMotionPath(StyleResolverState& state, CSSValue* value)
{
if (value->isPathValue()) {
const String& pathString = toCSSPathValue(value)->pathString();
state.style()->setMotionPath(PathStyleMotionPath::create(pathString));
return;
}

ASSERT(value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
state.style()->resetMotionPath();
}

void StyleBuilderFunctions::applyInitialCSSPropertyMotionPath(StyleResolverState& state)
{
state.style()->resetMotionPath();
}

void StyleBuilderFunctions::applyInheritCSSPropertyVerticalAlign(StyleResolverState& state)
{
EVerticalAlign verticalAlign = state.parentStyle()->verticalAlign();
Expand Down
13 changes: 3 additions & 10 deletions third_party/WebKit/Source/core/style/ComputedStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "core/style/ContentData.h"
#include "core/style/DataEquivalency.h"
#include "core/style/ComputedStyleConstants.h"
#include "core/style/PathStyleMotionPath.h"
#include "core/style/QuotesData.h"
#include "core/style/ShadowList.h"
#include "core/style/StyleImage.h"
Expand Down Expand Up @@ -992,8 +991,8 @@ void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect
void ComputedStyle::applyMotionPathTransform(float originX, float originY, TransformationMatrix& transform) const
{
const StyleMotionData& motionData = rareNonInheritedData->m_transform->m_motion;
ASSERT(motionData.m_path && motionData.m_path->isPathStyleMotionPath());
const PathStyleMotionPath& motionPath = toPathStyleMotionPath(*motionData.m_path);
ASSERT(motionData.m_path);
const StylePath& motionPath = *motionData.m_path;
float pathLength = motionPath.length();
float distance = floatValueForLength(motionData.m_offset, pathLength);
float computedDistance;
Expand Down Expand Up @@ -1681,17 +1680,11 @@ void ComputedStyle::setMarginEnd(const Length& margin)
}
}

void ComputedStyle::setMotionPath(PassRefPtr<StyleMotionPath> path)
void ComputedStyle::setMotionPath(PassRefPtr<StylePath> path)
{
ASSERT(path);
rareNonInheritedData.access()->m_transform.access()->m_motion.m_path = path;
}

void ComputedStyle::resetMotionPath()
{
rareNonInheritedData.access()->m_transform.access()->m_motion.m_path = nullptr;
}

int ComputedStyle::outlineOutsetExtent() const
{
if (!hasOutline())
Expand Down
8 changes: 3 additions & 5 deletions third_party/WebKit/Source/core/style/ComputedStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "core/style/StyleGridData.h"
#include "core/style/StyleGridItemData.h"
#include "core/style/StyleInheritedData.h"
#include "core/style/StyleMotionPath.h"
#include "core/style/StyleMotionRotation.h"
#include "core/style/StyleMultiColData.h"
#include "core/style/StyleRareInheritedData.h"
Expand Down Expand Up @@ -896,7 +895,7 @@ class CORE_EXPORT ComputedStyle: public RefCounted<ComputedStyle> {
bool hasTransformOperations() const { return !rareNonInheritedData->m_transform->m_operations.operations().isEmpty(); }
bool transformDataEquivalent(const ComputedStyle& otherStyle) const { return rareNonInheritedData->m_transform == otherStyle.rareNonInheritedData->m_transform; }

StyleMotionPath* motionPath() const { return rareNonInheritedData->m_transform->m_motion.m_path.get(); }
StylePath* motionPath() const { return rareNonInheritedData->m_transform->m_motion.m_path.get(); }
bool hasMotionPath() const { return rareNonInheritedData->m_transform->m_motion.m_path; }
const Length& motionOffset() const { return rareNonInheritedData->m_transform->m_motion.m_offset; }
const StyleMotionRotation& motionRotation() const { return rareNonInheritedData->m_transform->m_motion.m_rotation; }
Expand Down Expand Up @@ -1423,8 +1422,7 @@ class CORE_EXPORT ComputedStyle: public RefCounted<ComputedStyle> {
void setTextEmphasisPosition(TextEmphasisPosition position) { SET_VAR(rareInheritedData, textEmphasisPosition, position); }
bool setTextOrientation(TextOrientation);

void setMotionPath(PassRefPtr<StyleMotionPath>);
void resetMotionPath();
void setMotionPath(PassRefPtr<StylePath>);
void setMotionOffset(const Length& motionOffset) { SET_NESTED_VAR(rareNonInheritedData, m_transform, m_motion.m_offset, motionOffset); }
void setMotionRotation(const StyleMotionRotation& motionRotation) { SET_NESTED_VAR(rareNonInheritedData, m_transform, m_motion.m_rotation, motionRotation); }

Expand Down Expand Up @@ -1747,7 +1745,7 @@ class CORE_EXPORT ComputedStyle: public RefCounted<ComputedStyle> {
static TransformOrigin initialTransformOrigin() { return TransformOrigin(Length(50.0, Percent), Length(50.0, Percent), 0); }
static EPointerEvents initialPointerEvents() { return PE_AUTO; }
static ETransformStyle3D initialTransformStyle3D() { return TransformStyle3DFlat; }
static const StyleMotionPath* initialMotionPath() { return nullptr; }
static StylePath* initialMotionPath() { return nullptr; }
static Length initialMotionOffset() { return Length(0, Fixed); }
static StyleMotionRotation initialMotionRotation() { return StyleMotionRotation(0, MotionRotationAuto); }
static EBackfaceVisibility initialBackfaceVisibility() { return BackfaceVisibilityVisible; }
Expand Down
23 changes: 0 additions & 23 deletions third_party/WebKit/Source/core/style/PathStyleMotionPath.cpp

This file was deleted.

50 changes: 0 additions & 50 deletions third_party/WebKit/Source/core/style/PathStyleMotionPath.h

This file was deleted.

7 changes: 1 addition & 6 deletions third_party/WebKit/Source/core/style/StyleMotionData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "core/style/StyleMotionData.h"

#include "core/style/PathStyleMotionPath.h"

namespace blink {

bool StyleMotionData::operator==(const StyleMotionData& o) const
Expand All @@ -16,10 +14,7 @@ bool StyleMotionData::operator==(const StyleMotionData& o) const
if (!m_path || !o.m_path)
return !m_path && !o.m_path;

if (m_path->isPathStyleMotionPath() && o.m_path->isPathStyleMotionPath())
return toPathStyleMotionPath(*m_path).equals(toPathStyleMotionPath(*o.m_path));

return false;
return m_path->equals(*o.m_path);
}

} // namespace blink
6 changes: 3 additions & 3 deletions third_party/WebKit/Source/core/style/StyleMotionData.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef StyleMotionData_h
#define StyleMotionData_h

#include "core/style/StyleMotionPath.h"
#include "core/style/StyleMotionRotation.h"
#include "core/style/StylePath.h"
#include "platform/Length.h"
#include "wtf/Allocator.h"

Expand All @@ -15,7 +15,7 @@ namespace blink {
class StyleMotionData {
DISALLOW_NEW();
public:
StyleMotionData(StyleMotionPath* path, const Length& offset, StyleMotionRotation rotation)
StyleMotionData(StylePath* path, const Length& offset, StyleMotionRotation rotation)
: m_path(path)
, m_offset(offset)
, m_rotation(rotation)
Expand All @@ -27,7 +27,7 @@ class StyleMotionData {
bool operator!=(const StyleMotionData& o) const { return !(*this == o); }

// Must be public for SET_VAR in ComputedStyle.h
RefPtr<StyleMotionPath> m_path; // nullptr indicates path is 'none'
RefPtr<StylePath> m_path; // nullptr indicates path is 'none'
Length m_offset;
StyleMotionRotation m_rotation;
};
Expand Down
23 changes: 0 additions & 23 deletions third_party/WebKit/Source/core/style/StyleMotionPath.h

This file was deleted.

Loading

0 comments on commit 7b3f2bb

Please sign in to comment.