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

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

Issue 678163002: Oilpan: move SVG property hierarchy to the heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased upto r185213 Created 6 years, 1 month 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/SVGSVGElement.h ('k') | Source/core/svg/SVGScriptElement.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 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2014 Google, Inc. 5 * Copyright (C) 2014 Google, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // There are cases where removedFromDocument() is not called. 92 // There are cases where removedFromDocument() is not called.
93 // see ContainerNode::removeAllChildren, called by its destructor. 93 // see ContainerNode::removeAllChildren, called by its destructor.
94 // With Oilpan, either removedFrom is called or the document 94 // With Oilpan, either removedFrom is called or the document
95 // is dead as well and there is no reason to clear the extensions. 95 // is dead as well and there is no reason to clear the extensions.
96 document().accessSVGExtensions().removeTimeContainer(this); 96 document().accessSVGExtensions().removeTimeContainer(this);
97 97
98 ASSERT(inDocument() || !accessDocumentSVGExtensions().isSVGRootWithRelativeL engthDescendents(this)); 98 ASSERT(inDocument() || !accessDocumentSVGExtensions().isSVGRootWithRelativeL engthDescendents(this));
99 #endif 99 #endif
100 } 100 }
101 101
102 PassRefPtr<SVGRectTearOff> SVGSVGElement::viewport() const 102 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGSVGElement::viewport() const
103 { 103 {
104 // FIXME: This method doesn't follow the spec and is basically untested. Par ent documents are not considered here. 104 // FIXME: This method doesn't follow the spec and is basically untested. Par ent documents are not considered here.
105 // As we have no test coverage for this, we're going to disable it completly for now. 105 // As we have no test coverage for this, we're going to disable it completly for now.
106 return SVGRectTearOff::create(SVGRect::create(), 0, PropertyIsNotAnimVal); 106 return SVGRectTearOff::create(SVGRect::create(), 0, PropertyIsNotAnimVal);
107 } 107 }
108 108
109 float SVGSVGElement::pixelUnitToMillimeterX() const 109 float SVGSVGElement::pixelUnitToMillimeterX() const
110 { 110 {
111 return 1 / cssPixelsPerMillimeter; 111 return 1 / cssPixelsPerMillimeter;
112 } 112 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // We choose the ignore this call, it's pretty useless to support calling se tCurrentScale() from within 165 // We choose the ignore this call, it's pretty useless to support calling se tCurrentScale() from within
166 // an embedded SVG document, for the same reasons as in currentScale() - nee ds resolution by SVG WG. 166 // an embedded SVG document, for the same reasons as in currentScale() - nee ds resolution by SVG WG.
167 if (frameTree.parent()) 167 if (frameTree.parent())
168 return; 168 return;
169 169
170 frame->setPageZoomFactor(scale); 170 frame->setPageZoomFactor(scale);
171 } 171 }
172 172
173 class SVGCurrentTranslateTearOff : public SVGPointTearOff { 173 class SVGCurrentTranslateTearOff : public SVGPointTearOff {
174 public: 174 public:
175 static PassRefPtr<SVGCurrentTranslateTearOff> create(SVGSVGElement* contextE lement) 175 static PassRefPtrWillBeRawPtr<SVGCurrentTranslateTearOff> create(SVGSVGEleme nt* contextElement)
176 { 176 {
177 return adoptRef(new SVGCurrentTranslateTearOff(contextElement)); 177 return adoptRefWillBeNoop(new SVGCurrentTranslateTearOff(contextElement) );
178 } 178 }
179 179
180 virtual void commitChange() override 180 virtual void commitChange() override
181 { 181 {
182 ASSERT(contextElement()); 182 ASSERT(contextElement());
183 toSVGSVGElement(contextElement())->updateCurrentTranslate(); 183 toSVGSVGElement(contextElement())->updateCurrentTranslate();
184 } 184 }
185 185
186 private: 186 private:
187 SVGCurrentTranslateTearOff(SVGSVGElement* contextElement) 187 SVGCurrentTranslateTearOff(SVGSVGElement* contextElement)
188 : SVGPointTearOff(contextElement->m_translation, contextElement, Propert yIsNotAnimVal) 188 : SVGPointTearOff(contextElement->m_translation, contextElement, Propert yIsNotAnimVal)
189 { 189 {
190 } 190 }
191 }; 191 };
192 192
193 PassRefPtr<SVGPointTearOff> SVGSVGElement::currentTranslateFromJavascript() 193 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGSVGElement::currentTranslateFromJavas cript()
194 { 194 {
195 return SVGCurrentTranslateTearOff::create(this); 195 return SVGCurrentTranslateTearOff::create(this);
196 } 196 }
197 197
198 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point) 198 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point)
199 { 199 {
200 m_translation->setValue(point); 200 m_translation->setValue(point);
201 updateCurrentTranslate(); 201 updateCurrentTranslate();
202 } 202 }
203 203
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 bool SVGSVGElement::isPresentationAttribute(const QualifiedName& name) const 241 bool SVGSVGElement::isPresentationAttribute(const QualifiedName& name) const
242 { 242 {
243 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr)) 243 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr))
244 return true; 244 return true;
245 return SVGGraphicsElement::isPresentationAttribute(name); 245 return SVGGraphicsElement::isPresentationAttribute(name);
246 } 246 }
247 247
248 void SVGSVGElement::collectStyleForPresentationAttribute(const QualifiedName& na me, const AtomicString& value, MutableStylePropertySet* style) 248 void SVGSVGElement::collectStyleForPresentationAttribute(const QualifiedName& na me, const AtomicString& value, MutableStylePropertySet* style)
249 { 249 {
250 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr)) { 250 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SV GNames::heightAttr)) {
251 RefPtr<SVGLength> length = SVGLength::create(LengthModeOther); 251 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther );
252 TrackExceptionState exceptionState; 252 TrackExceptionState exceptionState;
253 length->setValueAsString(value, exceptionState); 253 length->setValueAsString(value, exceptionState);
254 if (!exceptionState.hadException()) { 254 if (!exceptionState.hadException()) {
255 if (name == SVGNames::widthAttr) 255 if (name == SVGNames::widthAttr)
256 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value); 256 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value);
257 else if (name == SVGNames::heightAttr) 257 else if (name == SVGNames::heightAttr)
258 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight , value); 258 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight , value);
259 } 259 }
260 } else { 260 } else {
261 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle); 261 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 376
377 for (SVGGraphicsElement& element : Traversal<SVGGraphicsElement>::descendant sOf(*root)) { 377 for (SVGGraphicsElement& element : Traversal<SVGGraphicsElement>::descendant sOf(*root)) {
378 if (checkIntersectionOrEnclosure(element, rect, mode)) 378 if (checkIntersectionOrEnclosure(element, rect, mode))
379 nodes.append(&element); 379 nodes.append(&element);
380 } 380 }
381 381
382 return StaticNodeList::adopt(nodes); 382 return StaticNodeList::adopt(nodes);
383 } 383 }
384 384
385 PassRefPtrWillBeRawPtr<StaticNodeList> SVGSVGElement::getIntersectionList(PassRe fPtr<SVGRectTearOff> rect, SVGElement* referenceElement) const 385 PassRefPtrWillBeRawPtr<StaticNodeList> SVGSVGElement::getIntersectionList(PassRe fPtrWillBeRawPtr<SVGRectTearOff> rect, SVGElement* referenceElement) const
386 { 386 {
387 document().updateLayoutIgnorePendingStylesheets(); 387 document().updateLayoutIgnorePendingStylesheets();
388 388
389 return collectIntersectionOrEnclosureList(rect->target()->value(), reference Element, CheckIntersection); 389 return collectIntersectionOrEnclosureList(rect->target()->value(), reference Element, CheckIntersection);
390 } 390 }
391 391
392 PassRefPtrWillBeRawPtr<StaticNodeList> SVGSVGElement::getEnclosureList(PassRefPt r<SVGRectTearOff> rect, SVGElement* referenceElement) const 392 PassRefPtrWillBeRawPtr<StaticNodeList> SVGSVGElement::getEnclosureList(PassRefPt rWillBeRawPtr<SVGRectTearOff> rect, SVGElement* referenceElement) const
393 { 393 {
394 document().updateLayoutIgnorePendingStylesheets(); 394 document().updateLayoutIgnorePendingStylesheets();
395 395
396 return collectIntersectionOrEnclosureList(rect->target()->value(), reference Element, CheckEnclosure); 396 return collectIntersectionOrEnclosureList(rect->target()->value(), reference Element, CheckEnclosure);
397 } 397 }
398 398
399 bool SVGSVGElement::checkIntersection(SVGElement* element, PassRefPtr<SVGRectTea rOff> rect) const 399 bool SVGSVGElement::checkIntersection(SVGElement* element, PassRefPtrWillBeRawPt r<SVGRectTearOff> rect) const
400 { 400 {
401 ASSERT(element); 401 ASSERT(element);
402 document().updateLayoutIgnorePendingStylesheets(); 402 document().updateLayoutIgnorePendingStylesheets();
403 403
404 return checkIntersectionOrEnclosure(*element, rect->target()->value(), Check Intersection); 404 return checkIntersectionOrEnclosure(*element, rect->target()->value(), Check Intersection);
405 } 405 }
406 406
407 bool SVGSVGElement::checkEnclosure(SVGElement* element, PassRefPtr<SVGRectTearOf f> rect) const 407 bool SVGSVGElement::checkEnclosure(SVGElement* element, PassRefPtrWillBeRawPtr<S VGRectTearOff> rect) const
408 { 408 {
409 ASSERT(element); 409 ASSERT(element);
410 document().updateLayoutIgnorePendingStylesheets(); 410 document().updateLayoutIgnorePendingStylesheets();
411 411
412 return checkIntersectionOrEnclosure(*element, rect->target()->value(), Check Enclosure); 412 return checkIntersectionOrEnclosure(*element, rect->target()->value(), Check Enclosure);
413 } 413 }
414 414
415 void SVGSVGElement::deselectAll() 415 void SVGSVGElement::deselectAll()
416 { 416 {
417 if (LocalFrame* frame = document().frame()) 417 if (LocalFrame* frame = document().frame())
418 frame->selection().clear(); 418 frame->selection().clear();
419 } 419 }
420 420
421 PassRefPtr<SVGNumberTearOff> SVGSVGElement::createSVGNumber() 421 PassRefPtrWillBeRawPtr<SVGNumberTearOff> SVGSVGElement::createSVGNumber()
422 { 422 {
423 return SVGNumberTearOff::create(SVGNumber::create(0.0f), 0, PropertyIsNotAni mVal); 423 return SVGNumberTearOff::create(SVGNumber::create(0.0f), 0, PropertyIsNotAni mVal);
424 } 424 }
425 425
426 PassRefPtr<SVGLengthTearOff> SVGSVGElement::createSVGLength() 426 PassRefPtrWillBeRawPtr<SVGLengthTearOff> SVGSVGElement::createSVGLength()
427 { 427 {
428 return SVGLengthTearOff::create(SVGLength::create(), 0, PropertyIsNotAnimVal ); 428 return SVGLengthTearOff::create(SVGLength::create(), 0, PropertyIsNotAnimVal );
429 } 429 }
430 430
431 PassRefPtr<SVGAngleTearOff> SVGSVGElement::createSVGAngle() 431 PassRefPtrWillBeRawPtr<SVGAngleTearOff> SVGSVGElement::createSVGAngle()
432 { 432 {
433 return SVGAngleTearOff::create(SVGAngle::create(), 0, PropertyIsNotAnimVal); 433 return SVGAngleTearOff::create(SVGAngle::create(), 0, PropertyIsNotAnimVal);
434 } 434 }
435 435
436 PassRefPtr<SVGPointTearOff> SVGSVGElement::createSVGPoint() 436 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGSVGElement::createSVGPoint()
437 { 437 {
438 return SVGPointTearOff::create(SVGPoint::create(), 0, PropertyIsNotAnimVal); 438 return SVGPointTearOff::create(SVGPoint::create(), 0, PropertyIsNotAnimVal);
439 } 439 }
440 440
441 PassRefPtr<SVGMatrixTearOff> SVGSVGElement::createSVGMatrix() 441 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGSVGElement::createSVGMatrix()
442 { 442 {
443 return SVGMatrixTearOff::create(AffineTransform()); 443 return SVGMatrixTearOff::create(AffineTransform());
444 } 444 }
445 445
446 PassRefPtr<SVGRectTearOff> SVGSVGElement::createSVGRect() 446 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGSVGElement::createSVGRect()
447 { 447 {
448 return SVGRectTearOff::create(SVGRect::create(), 0, PropertyIsNotAnimVal); 448 return SVGRectTearOff::create(SVGRect::create(), 0, PropertyIsNotAnimVal);
449 } 449 }
450 450
451 PassRefPtr<SVGTransformTearOff> SVGSVGElement::createSVGTransform() 451 PassRefPtrWillBeRawPtr<SVGTransformTearOff> SVGSVGElement::createSVGTransform()
452 { 452 {
453 return SVGTransformTearOff::create(SVGTransform::create(SVG_TRANSFORM_MATRIX ), 0, PropertyIsNotAnimVal); 453 return SVGTransformTearOff::create(SVGTransform::create(SVG_TRANSFORM_MATRIX ), 0, PropertyIsNotAnimVal);
454 } 454 }
455 455
456 PassRefPtr<SVGTransformTearOff> SVGSVGElement::createSVGTransformFromMatrix(Pass RefPtr<SVGMatrixTearOff> matrix) 456 PassRefPtrWillBeRawPtr<SVGTransformTearOff> SVGSVGElement::createSVGTransformFro mMatrix(PassRefPtrWillBeRawPtr<SVGMatrixTearOff> matrix)
457 { 457 {
458 return SVGTransformTearOff::create(SVGTransform::create(matrix->value()), 0, PropertyIsNotAnimVal); 458 return SVGTransformTearOff::create(SVGTransform::create(matrix->value()), 0, PropertyIsNotAnimVal);
459 } 459 }
460 460
461 AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGElement::CTMScop e mode) const 461 AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGElement::CTMScop e mode) const
462 { 462 {
463 AffineTransform viewBoxTransform; 463 AffineTransform viewBoxTransform;
464 if (!hasEmptyViewBox()) { 464 if (!hasEmptyViewBox()) {
465 FloatSize size = currentViewportSize(); 465 FloatSize size = currentViewportSize();
466 viewBoxTransform = viewBoxToViewTransform(size.width(), size.height()); 466 viewBoxTransform = viewBoxToViewTransform(size.width(), size.height());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 SVGLengthContext lengthContext(this); 651 SVGLengthContext lengthContext(this);
652 return Length(height()->currentValue()->value(lengthContext), Fixed); 652 return Length(height()->currentValue()->value(lengthContext), Fixed);
653 } 653 }
654 654
655 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie wHeight) const 655 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie wHeight) const
656 { 656 {
657 if (!m_useCurrentView || !m_viewSpec) 657 if (!m_useCurrentView || !m_viewSpec)
658 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre serveAspectRatio()->currentValue(), viewWidth, viewHeight); 658 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre serveAspectRatio()->currentValue(), viewWidth, viewHeight);
659 659
660 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox Rect(), m_viewSpec->preserveAspectRatio()->currentValue(), viewWidth, viewHeight ); 660 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox Rect(), m_viewSpec->preserveAspectRatio()->currentValue(), viewWidth, viewHeight );
661 RefPtr<SVGTransformList> transformList = m_viewSpec->transform(); 661 RefPtrWillBeRawPtr<SVGTransformList> transformList = m_viewSpec->transform() ;
662 if (transformList->isEmpty()) 662 if (transformList->isEmpty())
663 return ctm; 663 return ctm;
664 664
665 AffineTransform transform; 665 AffineTransform transform;
666 if (transformList->concatenate(transform)) 666 if (transformList->concatenate(transform))
667 ctm *= transform; 667 ctm *= transform;
668 668
669 return ctm; 669 return ctm;
670 } 670 }
671 671
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 if (isOutermostSVGSVGElement()) 751 if (isOutermostSVGSVGElement())
752 return; 752 return;
753 753
754 // finishParsingChildren() is called when the close tag is reached for an el ement (e.g. </svg>) 754 // finishParsingChildren() is called when the close tag is reached for an el ement (e.g. </svg>)
755 // we send SVGLoad events here if we can, otherwise they'll be sent when any required loads finish 755 // we send SVGLoad events here if we can, otherwise they'll be sent when any required loads finish
756 sendSVGLoadEventIfPossible(); 756 sendSVGLoadEventIfPossible();
757 } 757 }
758 758
759 void SVGSVGElement::trace(Visitor* visitor) 759 void SVGSVGElement::trace(Visitor* visitor)
760 { 760 {
761 visitor->trace(m_x);
762 visitor->trace(m_y);
763 visitor->trace(m_width);
764 visitor->trace(m_height);
765 visitor->trace(m_translation);
761 visitor->trace(m_timeContainer); 766 visitor->trace(m_timeContainer);
762 visitor->trace(m_viewSpec); 767 visitor->trace(m_viewSpec);
763 SVGGraphicsElement::trace(visitor); 768 SVGGraphicsElement::trace(visitor);
769 SVGFitToViewBox::trace(visitor);
764 } 770 }
765 771
766 } // namespace blink 772 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/svg/SVGSVGElement.h ('k') | Source/core/svg/SVGScriptElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698