| 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 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 { | 422 { |
| 423 AffineTransform viewBoxTransform; | 423 AffineTransform viewBoxTransform; |
| 424 if (!hasEmptyViewBox()) { | 424 if (!hasEmptyViewBox()) { |
| 425 FloatSize size = currentViewportSize(); | 425 FloatSize size = currentViewportSize(); |
| 426 viewBoxTransform = viewBoxToViewTransform(size.width(), size.height()); | 426 viewBoxTransform = viewBoxToViewTransform(size.width(), size.height()); |
| 427 } | 427 } |
| 428 | 428 |
| 429 AffineTransform transform; | 429 AffineTransform transform; |
| 430 if (!isOutermostSVGSVGElement()) { | 430 if (!isOutermostSVGSVGElement()) { |
| 431 SVGLengthContext lengthContext(this); | 431 SVGLengthContext lengthContext(this); |
| 432 transform.translate(x().value(lengthContext), y().value(lengthContext)); | 432 transform.translate(xCurrentValue().value(lengthContext), yCurrentValue(
).value(lengthContext)); |
| 433 } else if (mode == SVGLocatable::ScreenScope) { | 433 } else if (mode == SVGLocatable::ScreenScope) { |
| 434 if (RenderObject* renderer = this->renderer()) { | 434 if (RenderObject* renderer = this->renderer()) { |
| 435 FloatPoint location; | 435 FloatPoint location; |
| 436 float zoomFactor = 1; | 436 float zoomFactor = 1; |
| 437 | 437 |
| 438 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localT
oBorderBoxTransform | 438 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localT
oBorderBoxTransform |
| 439 // to map an element from SVG viewport coordinates to CSS box coordi
nates. | 439 // to map an element from SVG viewport coordinates to CSS box coordi
nates. |
| 440 // RenderSVGRoot's localToAbsolute method expects CSS box coordinate
s. | 440 // RenderSVGRoot's localToAbsolute method expects CSS box coordinate
s. |
| 441 // We also need to adjust for the zoom level factored into CSS coord
inates (bug #96361). | 441 // We also need to adjust for the zoom level factored into CSS coord
inates (bug #96361). |
| 442 if (renderer->isSVGRoot()) { | 442 if (renderer->isSVGRoot()) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 void SVGSVGElement::setCurrentTime(float seconds) | 530 void SVGSVGElement::setCurrentTime(float seconds) |
| 531 { | 531 { |
| 532 if (std::isnan(seconds)) | 532 if (std::isnan(seconds)) |
| 533 return; | 533 return; |
| 534 seconds = max(seconds, 0.0f); | 534 seconds = max(seconds, 0.0f); |
| 535 m_timeContainer->setElapsed(seconds); | 535 m_timeContainer->setElapsed(seconds); |
| 536 } | 536 } |
| 537 | 537 |
| 538 bool SVGSVGElement::selfHasRelativeLengths() const | 538 bool SVGSVGElement::selfHasRelativeLengths() const |
| 539 { | 539 { |
| 540 return x().isRelative() | 540 return xCurrentValue().isRelative() |
| 541 || y().isRelative() | 541 || yCurrentValue().isRelative() |
| 542 || width().isRelative() | 542 || widthCurrentValue().isRelative() |
| 543 || height().isRelative() | 543 || heightCurrentValue().isRelative() |
| 544 || hasAttribute(SVGNames::viewBoxAttr); | 544 || hasAttribute(SVGNames::viewBoxAttr); |
| 545 } | 545 } |
| 546 | 546 |
| 547 FloatRect SVGSVGElement::currentViewBoxRect() const | 547 FloatRect SVGSVGElement::currentViewBoxRect() const |
| 548 { | 548 { |
| 549 if (m_useCurrentView) | 549 if (m_useCurrentView) |
| 550 return m_viewSpec ? m_viewSpec->viewBox() : FloatRect(); | 550 return m_viewSpec ? m_viewSpec->viewBoxCurrentValue() : FloatRect(); |
| 551 | 551 |
| 552 FloatRect useViewBox = viewBox(); | 552 FloatRect useViewBox = viewBoxCurrentValue(); |
| 553 if (!useViewBox.isEmpty()) | 553 if (!useViewBox.isEmpty()) |
| 554 return useViewBox; | 554 return useViewBox; |
| 555 if (!renderer() || !renderer()->isSVGRoot()) | 555 if (!renderer() || !renderer()->isSVGRoot()) |
| 556 return FloatRect(); | 556 return FloatRect(); |
| 557 if (!toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage()) | 557 if (!toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage()) |
| 558 return FloatRect(); | 558 return FloatRect(); |
| 559 | 559 |
| 560 Length intrinsicWidth = this->intrinsicWidth(); | 560 Length intrinsicWidth = this->intrinsicWidth(); |
| 561 Length intrinsicHeight = this->intrinsicHeight(); | 561 Length intrinsicHeight = this->intrinsicHeight(); |
| 562 if (!intrinsicWidth.isFixed() || !intrinsicHeight.isFixed()) | 562 if (!intrinsicWidth.isFixed() || !intrinsicHeight.isFixed()) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV
G. | 630 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV
G. |
| 631 if (root->isEmbeddedThroughSVGImage() || document()->documentElement() != th
is) | 631 if (root->isEmbeddedThroughSVGImage() || document()->documentElement() != th
is) |
| 632 return !root->hasReplacedLogicalHeight(); | 632 return !root->hasReplacedLogicalHeight(); |
| 633 | 633 |
| 634 return true; | 634 return true; |
| 635 } | 635 } |
| 636 | 636 |
| 637 Length SVGSVGElement::intrinsicWidth(ConsiderCSSMode mode) const | 637 Length SVGSVGElement::intrinsicWidth(ConsiderCSSMode mode) const |
| 638 { | 638 { |
| 639 if (widthAttributeEstablishesViewport() || mode == IgnoreCSSProperties) { | 639 if (widthAttributeEstablishesViewport() || mode == IgnoreCSSProperties) { |
| 640 if (width().unitType() == LengthTypePercentage) | 640 if (widthCurrentValue().unitType() == LengthTypePercentage) |
| 641 return Length(width().valueAsPercentage() * 100, Percent); | 641 return Length(widthCurrentValue().valueAsPercentage() * 100, Percent
); |
| 642 | 642 |
| 643 SVGLengthContext lengthContext(this); | 643 SVGLengthContext lengthContext(this); |
| 644 return Length(width().value(lengthContext), Fixed); | 644 return Length(widthCurrentValue().value(lengthContext), Fixed); |
| 645 } | 645 } |
| 646 | 646 |
| 647 ASSERT(renderer()); | 647 ASSERT(renderer()); |
| 648 return renderer()->style()->width(); | 648 return renderer()->style()->width(); |
| 649 } | 649 } |
| 650 | 650 |
| 651 Length SVGSVGElement::intrinsicHeight(ConsiderCSSMode mode) const | 651 Length SVGSVGElement::intrinsicHeight(ConsiderCSSMode mode) const |
| 652 { | 652 { |
| 653 if (heightAttributeEstablishesViewport() || mode == IgnoreCSSProperties) { | 653 if (heightAttributeEstablishesViewport() || mode == IgnoreCSSProperties) { |
| 654 if (height().unitType() == LengthTypePercentage) | 654 if (heightCurrentValue().unitType() == LengthTypePercentage) |
| 655 return Length(height().valueAsPercentage() * 100, Percent); | 655 return Length(heightCurrentValue().valueAsPercentage() * 100, Percen
t); |
| 656 | 656 |
| 657 SVGLengthContext lengthContext(this); | 657 SVGLengthContext lengthContext(this); |
| 658 return Length(height().value(lengthContext), Fixed); | 658 return Length(heightCurrentValue().value(lengthContext), Fixed); |
| 659 } | 659 } |
| 660 | 660 |
| 661 ASSERT(renderer()); | 661 ASSERT(renderer()); |
| 662 return renderer()->style()->height(); | 662 return renderer()->style()->height(); |
| 663 } | 663 } |
| 664 | 664 |
| 665 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie
wHeight) const | 665 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie
wHeight) const |
| 666 { | 666 { |
| 667 if (!m_useCurrentView || !m_viewSpec) | 667 if (!m_useCurrentView || !m_viewSpec) |
| 668 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre
serveAspectRatio(), viewWidth, viewHeight); | 668 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre
serveAspectRatioCurrentValue(), viewWidth, viewHeight); |
| 669 | 669 |
| 670 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox
Rect(), m_viewSpec->preserveAspectRatio(), viewWidth, viewHeight); | 670 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox
Rect(), m_viewSpec->preserveAspectRatioCurrentValue(), viewWidth, viewHeight); |
| 671 const SVGTransformList& transformList = m_viewSpec->transformBaseValue(); | 671 const SVGTransformList& transformList = m_viewSpec->transformBaseValue(); |
| 672 if (transformList.isEmpty()) | 672 if (transformList.isEmpty()) |
| 673 return ctm; | 673 return ctm; |
| 674 | 674 |
| 675 AffineTransform transform; | 675 AffineTransform transform; |
| 676 if (transformList.concatenate(transform)) | 676 if (transformList.concatenate(transform)) |
| 677 ctm *= transform; | 677 ctm *= transform; |
| 678 | 678 |
| 679 return ctm; | 679 return ctm; |
| 680 } | 680 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 // FIXME: We need to decide which <svg> to focus on, and zoom to it. | 731 // FIXME: We need to decide which <svg> to focus on, and zoom to it. |
| 732 // FIXME: We need to actually "highlight" the viewTarget(s). | 732 // FIXME: We need to actually "highlight" the viewTarget(s). |
| 733 } | 733 } |
| 734 | 734 |
| 735 void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement) | 735 void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement) |
| 736 { | 736 { |
| 737 SVGViewSpec* view = currentView(); | 737 SVGViewSpec* view = currentView(); |
| 738 m_useCurrentView = true; | 738 m_useCurrentView = true; |
| 739 | 739 |
| 740 if (viewElement->hasAttribute(SVGNames::viewBoxAttr)) | 740 if (viewElement->hasAttribute(SVGNames::viewBoxAttr)) |
| 741 view->setViewBoxBaseValue(viewElement->viewBox()); | 741 view->setViewBoxBaseValue(viewElement->viewBoxCurrentValue()); |
| 742 else | 742 else |
| 743 view->setViewBoxBaseValue(viewBox()); | 743 view->setViewBoxBaseValue(viewBoxCurrentValue()); |
| 744 | 744 |
| 745 if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) | 745 if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) |
| 746 view->setPreserveAspectRatioBaseValue(viewElement->preserveAspectRatioBa
seValue()); | 746 view->setPreserveAspectRatioBaseValue(viewElement->preserveAspectRatioBa
seValue()); |
| 747 else | 747 else |
| 748 view->setPreserveAspectRatioBaseValue(preserveAspectRatioBaseValue()); | 748 view->setPreserveAspectRatioBaseValue(preserveAspectRatioBaseValue()); |
| 749 | 749 |
| 750 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) | 750 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) |
| 751 view->setZoomAndPanBaseValue(viewElement->zoomAndPan()); | 751 view->setZoomAndPanBaseValue(viewElement->zoomAndPan()); |
| 752 else | 752 else |
| 753 view->setZoomAndPanBaseValue(zoomAndPan()); | 753 view->setZoomAndPanBaseValue(zoomAndPan()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 768 continue; | 768 continue; |
| 769 | 769 |
| 770 Element* element = toElement(node); | 770 Element* element = toElement(node); |
| 771 if (element->getIdAttribute() == id) | 771 if (element->getIdAttribute() == id) |
| 772 return element; | 772 return element; |
| 773 } | 773 } |
| 774 return 0; | 774 return 0; |
| 775 } | 775 } |
| 776 | 776 |
| 777 } | 777 } |
| OLD | NEW |