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

Side by Side Diff: Source/core/svg/SVGUseElement.cpp

Issue 112003003: [SVG] SVGLength{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revert aggressive svgAttributeChanged, add NeedsRebaseline Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGUseElement.h ('k') | Source/core/svg/properties/NewSVGListPropertyHelper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
6 * Copyright (C) 2012 University of Szeged 6 * Copyright (C) 2012 University of Szeged
7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> 7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Dump SVGElementInstance object tree - useful to debug instanceRoot problems 46 // Dump SVGElementInstance object tree - useful to debug instanceRoot problems
47 // #define DUMP_INSTANCE_TREE 47 // #define DUMP_INSTANCE_TREE
48 48
49 // Dump the deep-expanded shadow tree (where the renderers are built from) 49 // Dump the deep-expanded shadow tree (where the renderers are built from)
50 // #define DUMP_SHADOW_TREE 50 // #define DUMP_SHADOW_TREE
51 51
52 namespace WebCore { 52 namespace WebCore {
53 53
54 // Animated property definitions 54 // Animated property definitions
55 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::xAttr, X, x)
56 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::yAttr, Y, y)
57 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::widthAttr, Width, width)
58 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::heightAttr, Height, height)
59 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) 55 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href)
60 56
61 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) 57 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement)
62 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
63 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
64 REGISTER_LOCAL_ANIMATED_PROPERTY(width)
65 REGISTER_LOCAL_ANIMATED_PROPERTY(height)
66 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 58 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
67 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 59 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
68 END_REGISTER_ANIMATED_PROPERTIES 60 END_REGISTER_ANIMATED_PROPERTIES
69 61
70 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser ) 62 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser )
71 : SVGGraphicsElement(SVGNames::useTag, document) 63 : SVGGraphicsElement(SVGNames::useTag, document)
72 , m_x(LengthModeWidth) 64 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth)))
73 , m_y(LengthModeHeight) 65 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight)))
74 , m_width(LengthModeWidth) 66 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth)))
75 , m_height(LengthModeHeight) 67 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight)))
76 , m_wasInsertedByParser(wasInsertedByParser) 68 , m_wasInsertedByParser(wasInsertedByParser)
77 , m_haveFiredLoadEvent(false) 69 , m_haveFiredLoadEvent(false)
78 , m_needsShadowTreeRecreation(false) 70 , m_needsShadowTreeRecreation(false)
79 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) 71 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
80 { 72 {
81 ASSERT(hasCustomStyleCallbacks()); 73 ASSERT(hasCustomStyleCallbacks());
82 ScriptWrappable::init(this); 74 ScriptWrappable::init(this);
75
76 addToPropertyMap(m_x);
77 addToPropertyMap(m_y);
78 addToPropertyMap(m_width);
79 addToPropertyMap(m_height);
83 registerAnimatedPropertiesForSVGUseElement(); 80 registerAnimatedPropertiesForSVGUseElement();
84 } 81 }
85 82
86 PassRefPtr<SVGUseElement> SVGUseElement::create(Document& document, bool wasInse rtedByParser) 83 PassRefPtr<SVGUseElement> SVGUseElement::create(Document& document, bool wasInse rtedByParser)
87 { 84 {
88 // Always build a #shadow-root for SVGUseElement. 85 // Always build a #shadow-root for SVGUseElement.
89 RefPtr<SVGUseElement> use = adoptRef(new SVGUseElement(document, wasInserted ByParser)); 86 RefPtr<SVGUseElement> use = adoptRef(new SVGUseElement(document, wasInserted ByParser));
90 use->ensureUserAgentShadowRoot(); 87 use->ensureUserAgentShadowRoot();
91 return use.release(); 88 return use.release();
92 } 89 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 126 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
130 } 127 }
131 128
132 void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString & value) 129 void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString & value)
133 { 130 {
134 SVGParsingError parseError = NoError; 131 SVGParsingError parseError = NoError;
135 132
136 if (!isSupportedAttribute(name)) 133 if (!isSupportedAttribute(name))
137 SVGGraphicsElement::parseAttribute(name, value); 134 SVGGraphicsElement::parseAttribute(name, value);
138 else if (name == SVGNames::xAttr) 135 else if (name == SVGNames::xAttr)
139 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 136 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
140 else if (name == SVGNames::yAttr) 137 else if (name == SVGNames::yAttr)
141 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 138 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
142 else if (name == SVGNames::widthAttr) 139 else if (name == SVGNames::widthAttr)
143 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths)); 140 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
144 else if (name == SVGNames::heightAttr) 141 else if (name == SVGNames::heightAttr)
145 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths)); 142 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ;
146 else if (SVGURIReference::parseAttribute(name, value)) { 143 else if (SVGURIReference::parseAttribute(name, value)) {
147 } else 144 } else
148 ASSERT_NOT_REACHED(); 145 ASSERT_NOT_REACHED();
149 146
150 reportAttributeParsingError(parseError, name, value); 147 reportAttributeParsingError(parseError, name, value);
151 } 148 }
152 149
153 #if !ASSERT_DISABLED 150 #if !ASSERT_DISABLED
154 static inline bool isWellFormedDocument(Document* document) 151 static inline bool isWellFormedDocument(Document* document)
155 { 152 {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 return; 536 return;
540 537
541 if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) { 538 if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) {
542 if (!isDirectReference(n)) { 539 if (!isDirectReference(n)) {
543 // Spec: Indirect references are an error (14.3.5) 540 // Spec: Indirect references are an error (14.3.5)
544 document().accessSVGExtensions()->reportError("Not allowed to use in direct reference in <clip-path>"); 541 document().accessSVGExtensions()->reportError("Not allowed to use in direct reference in <clip-path>");
545 } else { 542 } else {
546 toSVGGraphicsElement(n)->toClipPath(path); 543 toSVGGraphicsElement(n)->toClipPath(path);
547 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf ul. 544 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf ul.
548 SVGLengthContext lengthContext(this); 545 SVGLengthContext lengthContext(this);
549 path.translate(FloatSize(xCurrentValue().value(lengthContext), yCurr entValue().value(lengthContext))); 546 path.translate(FloatSize(m_x->currentValue()->value(lengthContext), m_y->currentValue()->value(lengthContext)));
550 path.transform(animatedLocalTransform()); 547 path.transform(animatedLocalTransform());
551 } 548 }
552 } 549 }
553 } 550 }
554 551
555 RenderObject* SVGUseElement::rendererClipChild() const 552 RenderObject* SVGUseElement::rendererClipChild() const
556 { 553 {
557 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeEleme nt() : 0; 554 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeEleme nt() : 0;
558 if (!n) 555 if (!n)
559 return 0; 556 return 0;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 907
911 to->removeAttribute(SVGNames::xAttr); 908 to->removeAttribute(SVGNames::xAttr);
912 to->removeAttribute(SVGNames::yAttr); 909 to->removeAttribute(SVGNames::yAttr);
913 to->removeAttribute(SVGNames::widthAttr); 910 to->removeAttribute(SVGNames::widthAttr);
914 to->removeAttribute(SVGNames::heightAttr); 911 to->removeAttribute(SVGNames::heightAttr);
915 to->removeAttribute(XLinkNames::hrefAttr); 912 to->removeAttribute(XLinkNames::hrefAttr);
916 } 913 }
917 914
918 bool SVGUseElement::selfHasRelativeLengths() const 915 bool SVGUseElement::selfHasRelativeLengths() const
919 { 916 {
920 if (xCurrentValue().isRelative() 917 if (m_x->currentValue()->isRelative()
921 || yCurrentValue().isRelative() 918 || m_y->currentValue()->isRelative()
922 || widthCurrentValue().isRelative() 919 || m_width->currentValue()->isRelative()
923 || heightCurrentValue().isRelative()) 920 || m_height->currentValue()->isRelative())
924 return true; 921 return true;
925 922
926 if (!m_targetElementInstance) 923 if (!m_targetElementInstance)
927 return false; 924 return false;
928 925
929 SVGElement* element = m_targetElementInstance->correspondingElement(); 926 SVGElement* element = m_targetElementInstance->correspondingElement();
930 if (!element) 927 if (!element)
931 return false; 928 return false;
932 929
933 return element->hasRelativeLengths(); 930 return element->hasRelativeLengths();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 983
987 if (m_resource) 984 if (m_resource)
988 m_resource->removeClient(this); 985 m_resource->removeClient(this);
989 986
990 m_resource = resource; 987 m_resource = resource;
991 if (m_resource) 988 if (m_resource)
992 m_resource->addClient(this); 989 m_resource->addClient(this);
993 } 990 }
994 991
995 } 992 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGUseElement.h ('k') | Source/core/svg/properties/NewSVGListPropertyHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698