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

Unified Diff: third_party/WebKit/Source/core/svg/SVGPathElement.cpp

Issue 1439793003: SVG: Promote d to a property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RefPtrWillBePersistent Created 5 years 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/svg/SVGPathElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGPathElement.cpp b/third_party/WebKit/Source/core/svg/SVGPathElement.cpp
index dc0b4b416ad6382fa0fb6c8552b6b3138345e7dd..4fa72db0557e5edb56ddf276f09eb82aebdc5f9c 100644
--- a/third_party/WebKit/Source/core/svg/SVGPathElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGPathElement.cpp
@@ -21,10 +21,12 @@
#include "config.h"
#include "core/svg/SVGPathElement.h"
+#include "core/dom/NodeComputedStyle.h"
fs 2015/12/11 13:01:58 No longer needed?
Eric Willigers 2015/12/14 05:36:46 Acknowledged.
#include "core/layout/svg/LayoutSVGPath.h"
#include "core/svg/SVGDocumentExtensions.h"
#include "core/svg/SVGMPathElement.h"
#include "core/svg/SVGPathQuery.h"
+#include "core/svg/SVGPathUtilities.h"
#include "core/svg/SVGPointTearOff.h"
namespace blink {
@@ -72,52 +74,92 @@ DEFINE_NODE_FACTORY(SVGPathElement)
Path SVGPathElement::asPath() const
{
- // If this is a <use> instance, return the referenced path to maximize geometry sharing.
- if (const SVGElement* element = correspondingElement())
- return toSVGPathElement(element)->asPath();
+ Path path;
+ buildPathFromByteStream(pathByteStream(), path);
+ return path;
+}
+
+const SVGPathByteStream& SVGPathElement::pathByteStream() const
+{
+ if (layoutObject()) {
+ const SVGComputedStyle& svgStyle = layoutObject()->styleRef().svgStyle();
+ return svgStyle.d()->byteStream();
+
+ }
- return m_path->currentValue()->path();
+ return m_path->currentValue()->byteStream();
}
float SVGPathElement::getTotalLength()
{
- return SVGPathQuery(m_path->currentValue()->byteStream()).getTotalLength();
+ document().updateLayoutIgnorePendingStylesheets();
+ return SVGPathQuery(pathByteStream()).getTotalLength();
}
PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGPathElement::getPointAtLength(float length)
{
- FloatPoint point = SVGPathQuery(m_path->currentValue()->byteStream()).getPointAtLength(length);
+ document().updateLayoutIgnorePendingStylesheets();
+ FloatPoint point = SVGPathQuery(pathByteStream()).getPointAtLength(length);
return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnimVal);
}
unsigned SVGPathElement::getPathSegAtLength(float length)
{
- return SVGPathQuery(m_path->currentValue()->byteStream()).getPathSegIndexAtLength(length);
+ document().updateLayoutIgnorePendingStylesheets();
+ return SVGPathQuery(pathByteStream()).getPathSegIndexAtLength(length);
+}
+
+bool SVGPathElement::isPresentationAttribute(const QualifiedName& attrName) const
+{
+ if (attrName == SVGNames::dAttr)
+ return true;
+ return SVGGeometryElement::isPresentationAttribute(attrName);
+}
+
+bool SVGPathElement::isPresentationAttributeWithSVGDOM(const QualifiedName& attrName) const
+{
+ if (attrName == SVGNames::dAttr)
+ return true;
+ return SVGGeometryElement::isPresentationAttributeWithSVGDOM(attrName);
}
void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName)
{
- if (attrName == SVGNames::dAttr || attrName == SVGNames::pathLengthAttr) {
+ if (attrName == SVGNames::dAttr) {
SVGElement::InvalidationGuard invalidationGuard(this);
+ invalidateSVGPresentationAttributeStyle();
+ setNeedsStyleRecalc(LocalStyleChange,
+ StyleChangeReasonForTracing::fromAttribute(attrName));
- LayoutSVGShape* layoutObject = toLayoutSVGShape(this->layoutObject());
-
- if (attrName == SVGNames::dAttr) {
- if (layoutObject)
- layoutObject->setNeedsShapeUpdate();
+ if (LayoutSVGShape* layoutPath = toLayoutSVGShape(this->layoutObject()))
+ layoutPath->setNeedsShapeUpdate();
- invalidateMPathDependencies();
- }
+ invalidateMPathDependencies();
+ if (layoutObject())
+ markForLayoutAndParentResourceInvalidation(layoutObject());
- if (layoutObject)
- markForLayoutAndParentResourceInvalidation(layoutObject);
+ return;
+ }
+ if (attrName == SVGNames::pathLengthAttr) {
+ SVGElement::InvalidationGuard invalidationGuard(this);
+ if (layoutObject())
+ markForLayoutAndParentResourceInvalidation(layoutObject());
return;
}
SVGGeometryElement::svgAttributeChanged(attrName);
}
+void SVGPathElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
+{
+ RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = propertyFromAttribute(name);
+ if (property == m_path)
+ addPropertyToPresentationAttributeStyle(style, CSSPropertyD, m_path->currentValue()->pathValue());
+ else
+ SVGGeometryElement::collectStyleForPresentationAttribute(name, value, style);
+}
+
void SVGPathElement::invalidateMPathDependencies()
{
// <mpath> can only reference <path> but this dependency is not handled in

Powered by Google App Engine
This is Rietveld 408576698