| OLD | NEW |
| 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 Loading... |
| 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 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGSVGElement::viewport() const | 102 RawPtr<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 SVGViewSpec* SVGSVGElement::currentView() | 109 SVGViewSpec* SVGSVGElement::currentView() |
| 110 { | 110 { |
| 111 if (!m_viewSpec) | 111 if (!m_viewSpec) |
| 112 m_viewSpec = SVGViewSpec::create(this); | 112 m_viewSpec = SVGViewSpec::create(this); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // We choose the ignore this call, it's pretty useless to support calling se
tCurrentScale() from within | 146 // We choose the ignore this call, it's pretty useless to support calling se
tCurrentScale() from within |
| 147 // an embedded SVG document, for the same reasons as in currentScale() - nee
ds resolution by SVG WG. | 147 // an embedded SVG document, for the same reasons as in currentScale() - nee
ds resolution by SVG WG. |
| 148 if (frameTree.parent()) | 148 if (frameTree.parent()) |
| 149 return; | 149 return; |
| 150 | 150 |
| 151 frame->setPageZoomFactor(scale); | 151 frame->setPageZoomFactor(scale); |
| 152 } | 152 } |
| 153 | 153 |
| 154 class SVGCurrentTranslateTearOff : public SVGPointTearOff { | 154 class SVGCurrentTranslateTearOff : public SVGPointTearOff { |
| 155 public: | 155 public: |
| 156 static PassRefPtrWillBeRawPtr<SVGCurrentTranslateTearOff> create(SVGSVGEleme
nt* contextElement) | 156 static RawPtr<SVGCurrentTranslateTearOff> create(SVGSVGElement* contextEleme
nt) |
| 157 { | 157 { |
| 158 return adoptRefWillBeNoop(new SVGCurrentTranslateTearOff(contextElement)
); | 158 return new SVGCurrentTranslateTearOff(contextElement); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void commitChange() override | 161 void commitChange() override |
| 162 { | 162 { |
| 163 ASSERT(contextElement()); | 163 ASSERT(contextElement()); |
| 164 toSVGSVGElement(contextElement())->updateCurrentTranslate(); | 164 toSVGSVGElement(contextElement())->updateCurrentTranslate(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 private: | 167 private: |
| 168 SVGCurrentTranslateTearOff(SVGSVGElement* contextElement) | 168 SVGCurrentTranslateTearOff(SVGSVGElement* contextElement) |
| 169 : SVGPointTearOff(contextElement->m_translation, contextElement, Propert
yIsNotAnimVal) | 169 : SVGPointTearOff(contextElement->m_translation, contextElement, Propert
yIsNotAnimVal) |
| 170 { | 170 { |
| 171 } | 171 } |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGSVGElement::currentTranslateFromJavas
cript() | 174 RawPtr<SVGPointTearOff> SVGSVGElement::currentTranslateFromJavascript() |
| 175 { | 175 { |
| 176 return SVGCurrentTranslateTearOff::create(this); | 176 return SVGCurrentTranslateTearOff::create(this); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point) | 179 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point) |
| 180 { | 180 { |
| 181 m_translation->setValue(point); | 181 m_translation->setValue(point); |
| 182 updateCurrentTranslate(); | 182 updateCurrentTranslate(); |
| 183 } | 183 } |
| 184 | 184 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 result = rect.contains(mappedRepaintRect); | 351 result = rect.contains(mappedRepaintRect); |
| 352 break; | 352 break; |
| 353 default: | 353 default: |
| 354 ASSERT_NOT_REACHED(); | 354 ASSERT_NOT_REACHED(); |
| 355 break; | 355 break; |
| 356 } | 356 } |
| 357 | 357 |
| 358 return result; | 358 return result; |
| 359 } | 359 } |
| 360 | 360 |
| 361 PassRefPtrWillBeRawPtr<StaticNodeList> SVGSVGElement::collectIntersectionOrEnclo
sureList(const FloatRect& rect, | 361 RawPtr<StaticNodeList> SVGSVGElement::collectIntersectionOrEnclosureList(const F
loatRect& rect, |
| 362 SVGElement* referenceElement, CheckIntersectionOrEnclosure mode) const | 362 SVGElement* referenceElement, CheckIntersectionOrEnclosure mode) const |
| 363 { | 363 { |
| 364 WillBeHeapVector<RefPtrWillBeMember<Node>> nodes; | 364 HeapVector<Member<Node>> nodes; |
| 365 | 365 |
| 366 const SVGElement* root = this; | 366 const SVGElement* root = this; |
| 367 if (referenceElement) { | 367 if (referenceElement) { |
| 368 // Only the common subtree needs to be traversed. | 368 // Only the common subtree needs to be traversed. |
| 369 if (contains(referenceElement)) { | 369 if (contains(referenceElement)) { |
| 370 root = referenceElement; | 370 root = referenceElement; |
| 371 } else if (!isDescendantOf(referenceElement)) { | 371 } else if (!isDescendantOf(referenceElement)) { |
| 372 // No common subtree. | 372 // No common subtree. |
| 373 return StaticNodeList::adopt(nodes); | 373 return StaticNodeList::adopt(nodes); |
| 374 } | 374 } |
| 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
fPtrWillBeRawPtr<SVGRectTearOff> rect, SVGElement* referenceElement) const | 385 RawPtr<StaticNodeList> SVGSVGElement::getIntersectionList(RawPtr<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
rWillBeRawPtr<SVGRectTearOff> rect, SVGElement* referenceElement) const | 392 RawPtr<StaticNodeList> SVGSVGElement::getEnclosureList(RawPtr<SVGRectTearOff> re
ct, 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, PassRefPtrWillBeRawPt
r<SVGRectTearOff> rect) const | 399 bool SVGSVGElement::checkIntersection(SVGElement* element, RawPtr<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, PassRefPtrWillBeRawPtr<S
VGRectTearOff> rect) const | 407 bool SVGSVGElement::checkEnclosure(SVGElement* element, RawPtr<SVGRectTearOff> r
ect) 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 PassRefPtrWillBeRawPtr<SVGNumberTearOff> SVGSVGElement::createSVGNumber() | 421 RawPtr<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 PassRefPtrWillBeRawPtr<SVGLengthTearOff> SVGSVGElement::createSVGLength() | 426 RawPtr<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 PassRefPtrWillBeRawPtr<SVGAngleTearOff> SVGSVGElement::createSVGAngle() | 431 RawPtr<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 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGSVGElement::createSVGPoint() | 436 RawPtr<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 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGSVGElement::createSVGMatrix() | 441 RawPtr<SVGMatrixTearOff> SVGSVGElement::createSVGMatrix() |
| 442 { | 442 { |
| 443 return SVGMatrixTearOff::create(AffineTransform()); | 443 return SVGMatrixTearOff::create(AffineTransform()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGSVGElement::createSVGRect() | 446 RawPtr<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 PassRefPtrWillBeRawPtr<SVGTransformTearOff> SVGSVGElement::createSVGTransform() | 451 RawPtr<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 PassRefPtrWillBeRawPtr<SVGTransformTearOff> SVGSVGElement::createSVGTransformFro
mMatrix(PassRefPtrWillBeRawPtr<SVGMatrixTearOff> matrix) | 456 RawPtr<SVGTransformTearOff> SVGSVGElement::createSVGTransformFromMatrix(RawPtr<S
VGMatrixTearOff> 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 SVGLengthContext lengthContext(this); | 656 SVGLengthContext lengthContext(this); |
| 657 return height()->currentValue()->value(lengthContext); | 657 return height()->currentValue()->value(lengthContext); |
| 658 } | 658 } |
| 659 | 659 |
| 660 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie
wHeight) const | 660 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie
wHeight) const |
| 661 { | 661 { |
| 662 if (!m_useCurrentView || !m_viewSpec) | 662 if (!m_useCurrentView || !m_viewSpec) |
| 663 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre
serveAspectRatio()->currentValue(), viewWidth, viewHeight); | 663 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre
serveAspectRatio()->currentValue(), viewWidth, viewHeight); |
| 664 | 664 |
| 665 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox
Rect(), m_viewSpec->preserveAspectRatio()->currentValue(), viewWidth, viewHeight
); | 665 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox
Rect(), m_viewSpec->preserveAspectRatio()->currentValue(), viewWidth, viewHeight
); |
| 666 RefPtrWillBeRawPtr<SVGTransformList> transformList = m_viewSpec->transform()
; | 666 RawPtr<SVGTransformList> transformList = m_viewSpec->transform(); |
| 667 if (transformList->isEmpty()) | 667 if (transformList->isEmpty()) |
| 668 return ctm; | 668 return ctm; |
| 669 | 669 |
| 670 AffineTransform transform; | 670 AffineTransform transform; |
| 671 if (transformList->concatenate(transform)) | 671 if (transformList->concatenate(transform)) |
| 672 ctm *= transform; | 672 ctm *= transform; |
| 673 | 673 |
| 674 return ctm; | 674 return ctm; |
| 675 } | 675 } |
| 676 | 676 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 visitor->trace(m_width); | 762 visitor->trace(m_width); |
| 763 visitor->trace(m_height); | 763 visitor->trace(m_height); |
| 764 visitor->trace(m_translation); | 764 visitor->trace(m_translation); |
| 765 visitor->trace(m_timeContainer); | 765 visitor->trace(m_timeContainer); |
| 766 visitor->trace(m_viewSpec); | 766 visitor->trace(m_viewSpec); |
| 767 SVGGraphicsElement::trace(visitor); | 767 SVGGraphicsElement::trace(visitor); |
| 768 SVGFitToViewBox::trace(visitor); | 768 SVGFitToViewBox::trace(visitor); |
| 769 } | 769 } |
| 770 | 770 |
| 771 } // namespace blink | 771 } // namespace blink |
| OLD | NEW |