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

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

Issue 933953003: Move the remaining rendering/svg/RenderSVG* files to layout. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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/SVGLengthContext.cpp ('k') | Source/core/svg/SVGStopElement.cpp » ('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 20 matching lines...) Expand all
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/ElementTraversal.h" 32 #include "core/dom/ElementTraversal.h"
33 #include "core/dom/StaticNodeList.h" 33 #include "core/dom/StaticNodeList.h"
34 #include "core/editing/FrameSelection.h" 34 #include "core/editing/FrameSelection.h"
35 #include "core/events/EventListener.h" 35 #include "core/events/EventListener.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/page/FrameTree.h" 37 #include "core/page/FrameTree.h"
38 #include "core/frame/FrameView.h" 38 #include "core/frame/FrameView.h"
39 #include "core/frame/UseCounter.h" 39 #include "core/frame/UseCounter.h"
40 #include "core/layout/LayoutObject.h" 40 #include "core/layout/LayoutObject.h"
41 #include "core/layout/svg/LayoutSVGModelObject.h"
42 #include "core/layout/svg/LayoutSVGRoot.h"
41 #include "core/layout/svg/LayoutSVGViewportContainer.h" 43 #include "core/layout/svg/LayoutSVGViewportContainer.h"
42 #include "core/rendering/svg/RenderSVGModelObject.h"
43 #include "core/rendering/svg/RenderSVGRoot.h"
44 #include "core/svg/SVGAngleTearOff.h" 44 #include "core/svg/SVGAngleTearOff.h"
45 #include "core/svg/SVGNumberTearOff.h" 45 #include "core/svg/SVGNumberTearOff.h"
46 #include "core/svg/SVGPreserveAspectRatio.h" 46 #include "core/svg/SVGPreserveAspectRatio.h"
47 #include "core/svg/SVGRectTearOff.h" 47 #include "core/svg/SVGRectTearOff.h"
48 #include "core/svg/SVGTransform.h" 48 #include "core/svg/SVGTransform.h"
49 #include "core/svg/SVGTransformList.h" 49 #include "core/svg/SVGTransformList.h"
50 #include "core/svg/SVGTransformTearOff.h" 50 #include "core/svg/SVGTransformTearOff.h"
51 #include "core/svg/SVGViewElement.h" 51 #include "core/svg/SVGViewElement.h"
52 #include "core/svg/SVGViewSpec.h" 52 #include "core/svg/SVGViewSpec.h"
53 #include "core/svg/animation/SMILTimeContainer.h" 53 #include "core/svg/animation/SMILTimeContainer.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 bool updateRelativeLengthsOrViewBox = false; 279 bool updateRelativeLengthsOrViewBox = false;
280 bool widthChanged = attrName == SVGNames::widthAttr; 280 bool widthChanged = attrName == SVGNames::widthAttr;
281 bool heightChanged = attrName == SVGNames::heightAttr; 281 bool heightChanged = attrName == SVGNames::heightAttr;
282 if (widthChanged || heightChanged 282 if (widthChanged || heightChanged
283 || attrName == SVGNames::xAttr 283 || attrName == SVGNames::xAttr
284 || attrName == SVGNames::yAttr) { 284 || attrName == SVGNames::yAttr) {
285 updateRelativeLengthsOrViewBox = true; 285 updateRelativeLengthsOrViewBox = true;
286 updateRelativeLengthsInformation(); 286 updateRelativeLengthsInformation();
287 invalidateRelativeLengthClients(); 287 invalidateRelativeLengthClients();
288 288
289 // At the SVG/HTML boundary (aka RenderSVGRoot), the width and 289 // At the SVG/HTML boundary (aka LayoutSVGRoot), the width and
290 // height attributes can affect the replaced size so we need 290 // height attributes can affect the replaced size so we need
291 // to mark it for updating. 291 // to mark it for updating.
292 // 292 //
293 // FIXME: For width/height animated as XML attributes on SVG 293 // FIXME: For width/height animated as XML attributes on SVG
294 // roots, there is an attribute synchronization missing. See 294 // roots, there is an attribute synchronization missing. See
295 // http://crbug.com/364807 295 // http://crbug.com/364807
296 if (widthChanged || heightChanged) { 296 if (widthChanged || heightChanged) {
297 LayoutObject* layoutObject = renderer(); 297 LayoutObject* layoutObject = renderer();
298 if (layoutObject && layoutObject->isSVGRoot()) { 298 if (layoutObject && layoutObject->isSVGRoot()) {
299 invalidateSVGPresentationAttributeStyle(); 299 invalidateSVGPresentationAttributeStyle();
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 AffineTransform transform; 485 AffineTransform transform;
486 if (!isOutermostSVGSVGElement()) { 486 if (!isOutermostSVGSVGElement()) {
487 SVGLengthContext lengthContext(this); 487 SVGLengthContext lengthContext(this);
488 transform.translate(m_x->currentValue()->value(lengthContext), m_y->curr entValue()->value(lengthContext)); 488 transform.translate(m_x->currentValue()->value(lengthContext), m_y->curr entValue()->value(lengthContext));
489 } else if (mode == SVGElement::ScreenScope) { 489 } else if (mode == SVGElement::ScreenScope) {
490 if (LayoutObject* renderer = this->renderer()) { 490 if (LayoutObject* renderer = this->renderer()) {
491 FloatPoint location; 491 FloatPoint location;
492 float zoomFactor = 1; 492 float zoomFactor = 1;
493 493
494 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localT oBorderBoxTransform 494 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localT oBorderBoxTransform
495 // to map an element from SVG viewport coordinates to CSS box coordi nates. 495 // to map an element from SVG viewport coordinates to CSS box coordi nates.
496 // RenderSVGRoot's localToAbsolute method expects CSS box coordinate s. 496 // LayoutSVGRoot's localToAbsolute method expects CSS box coordinate s.
497 // We also need to adjust for the zoom level factored into CSS coord inates (bug #96361). 497 // We also need to adjust for the zoom level factored into CSS coord inates (bug #96361).
498 if (renderer->isSVGRoot()) { 498 if (renderer->isSVGRoot()) {
499 location = toRenderSVGRoot(renderer)->localToBorderBoxTransform( ).mapPoint(location); 499 location = toLayoutSVGRoot(renderer)->localToBorderBoxTransform( ).mapPoint(location);
500 zoomFactor = 1 / renderer->style()->effectiveZoom(); 500 zoomFactor = 1 / renderer->style()->effectiveZoom();
501 } 501 }
502 502
503 // Translate in our CSS parent coordinate space 503 // Translate in our CSS parent coordinate space
504 // FIXME: This doesn't work correctly with CSS transforms. 504 // FIXME: This doesn't work correctly with CSS transforms.
505 location = renderer->localToAbsolute(location, UseTransforms); 505 location = renderer->localToAbsolute(location, UseTransforms);
506 location.scale(zoomFactor, zoomFactor); 506 location.scale(zoomFactor, zoomFactor);
507 507
508 // Be careful here! localToBorderBoxTransform() included the x/y off set coming from the viewBoxToViewTransform(), 508 // Be careful here! localToBorderBoxTransform() included the x/y off set coming from the viewBoxToViewTransform(),
509 // so we have to subtract it here (original cause of bug #27183) 509 // so we have to subtract it here (original cause of bug #27183)
510 transform.translate(location.x() - viewBoxTransform.e(), location.y( ) - viewBoxTransform.f()); 510 transform.translate(location.x() - viewBoxTransform.e(), location.y( ) - viewBoxTransform.f());
511 511
512 // Respect scroll offset. 512 // Respect scroll offset.
513 if (FrameView* view = document().view()) { 513 if (FrameView* view = document().view()) {
514 LayoutSize scrollOffset(view->scrollOffset()); 514 LayoutSize scrollOffset(view->scrollOffset());
515 scrollOffset.scale(zoomFactor); 515 scrollOffset.scale(zoomFactor);
516 transform.translate(-scrollOffset.width(), -scrollOffset.height( )); 516 transform.translate(-scrollOffset.width(), -scrollOffset.height( ));
517 } 517 }
518 } 518 }
519 } 519 }
520 520
521 return transform.multiply(viewBoxTransform); 521 return transform.multiply(viewBoxTransform);
522 } 522 }
523 523
524 bool SVGSVGElement::rendererIsNeeded(const LayoutStyle& style) 524 bool SVGSVGElement::rendererIsNeeded(const LayoutStyle& style)
525 { 525 {
526 // FIXME: We should respect display: none on the documentElement svg element 526 // FIXME: We should respect display: none on the documentElement svg element
527 // but many things in FrameView and SVGImage depend on the RenderSVGRoot whe n 527 // but many things in FrameView and SVGImage depend on the LayoutSVGRoot whe n
528 // they should instead depend on the RenderView. 528 // they should instead depend on the RenderView.
529 // https://bugs.webkit.org/show_bug.cgi?id=103493 529 // https://bugs.webkit.org/show_bug.cgi?id=103493
530 if (document().documentElement() == this) 530 if (document().documentElement() == this)
531 return true; 531 return true;
532 return Element::rendererIsNeeded(style); 532 return Element::rendererIsNeeded(style);
533 } 533 }
534 534
535 LayoutObject* SVGSVGElement::createRenderer(const LayoutStyle&) 535 LayoutObject* SVGSVGElement::createRenderer(const LayoutStyle&)
536 { 536 {
537 if (isOutermostSVGSVGElement()) 537 if (isOutermostSVGSVGElement())
538 return new RenderSVGRoot(this); 538 return new LayoutSVGRoot(this);
539 539
540 return new LayoutSVGViewportContainer(this); 540 return new LayoutSVGViewportContainer(this);
541 } 541 }
542 542
543 Node::InsertionNotificationRequest SVGSVGElement::insertedInto(ContainerNode* ro otParent) 543 Node::InsertionNotificationRequest SVGSVGElement::insertedInto(ContainerNode* ro otParent)
544 { 544 {
545 if (rootParent->inDocument()) { 545 if (rootParent->inDocument()) {
546 UseCounter::count(document(), UseCounter::SVGSVGElementInDocument); 546 UseCounter::count(document(), UseCounter::SVGSVGElementInDocument);
547 if (rootParent->document().isXMLDocument()) 547 if (rootParent->document().isXMLDocument())
548 UseCounter::count(document(), UseCounter::SVGSVGElementInXMLDocument ); 548 UseCounter::count(document(), UseCounter::SVGSVGElementInXMLDocument );
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 FloatRect SVGSVGElement::currentViewBoxRect() const 610 FloatRect SVGSVGElement::currentViewBoxRect() const
611 { 611 {
612 if (m_useCurrentView) 612 if (m_useCurrentView)
613 return m_viewSpec ? m_viewSpec->viewBox()->currentValue()->value() : Flo atRect(); 613 return m_viewSpec ? m_viewSpec->viewBox()->currentValue()->value() : Flo atRect();
614 614
615 FloatRect useViewBox = viewBox()->currentValue()->value(); 615 FloatRect useViewBox = viewBox()->currentValue()->value();
616 if (!useViewBox.isEmpty()) 616 if (!useViewBox.isEmpty())
617 return useViewBox; 617 return useViewBox;
618 if (!renderer() || !renderer()->isSVGRoot()) 618 if (!renderer() || !renderer()->isSVGRoot())
619 return FloatRect(); 619 return FloatRect();
620 if (!toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage()) 620 if (!toLayoutSVGRoot(renderer())->isEmbeddedThroughSVGImage())
621 return FloatRect(); 621 return FloatRect();
622 622
623 // If no viewBox is specified but non-relative width/height values, then we 623 // If no viewBox is specified but non-relative width/height values, then we
624 // should always synthesize a viewBox if we're embedded through a SVGImage. 624 // should always synthesize a viewBox if we're embedded through a SVGImage.
625 return FloatRect(FloatPoint(), FloatSize(floatValueForLength(intrinsicWidth( ), 0), floatValueForLength(intrinsicHeight(), 0))); 625 return FloatRect(FloatPoint(), FloatSize(floatValueForLength(intrinsicWidth( ), 0), floatValueForLength(intrinsicHeight(), 0)));
626 } 626 }
627 627
628 FloatSize SVGSVGElement::currentViewportSize() const 628 FloatSize SVGSVGElement::currentViewportSize() const
629 { 629 {
630 if (!renderer()) 630 if (!renderer())
631 return FloatSize(); 631 return FloatSize();
632 632
633 if (renderer()->isSVGRoot()) { 633 if (renderer()->isSVGRoot()) {
634 LayoutRect contentBoxRect = toRenderSVGRoot(renderer())->contentBoxRect( ); 634 LayoutRect contentBoxRect = toLayoutSVGRoot(renderer())->contentBoxRect( );
635 return FloatSize(contentBoxRect.width() / renderer()->style()->effective Zoom(), contentBoxRect.height() / renderer()->style()->effectiveZoom()); 635 return FloatSize(contentBoxRect.width() / renderer()->style()->effective Zoom(), contentBoxRect.height() / renderer()->style()->effectiveZoom());
636 } 636 }
637 637
638 FloatRect viewportRect = toLayoutSVGViewportContainer(renderer())->viewport( ); 638 FloatRect viewportRect = toLayoutSVGViewportContainer(renderer())->viewport( );
639 return FloatSize(viewportRect.width(), viewportRect.height()); 639 return FloatSize(viewportRect.width(), viewportRect.height());
640 } 640 }
641 641
642 bool SVGSVGElement::hasIntrinsicWidth() const 642 bool SVGSVGElement::hasIntrinsicWidth() const
643 { 643 {
644 return width()->currentValue()->unitType() != LengthTypePercentage; 644 return width()->currentValue()->unitType() != LengthTypePercentage;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 visitor->trace(m_width); 785 visitor->trace(m_width);
786 visitor->trace(m_height); 786 visitor->trace(m_height);
787 visitor->trace(m_translation); 787 visitor->trace(m_translation);
788 visitor->trace(m_timeContainer); 788 visitor->trace(m_timeContainer);
789 visitor->trace(m_viewSpec); 789 visitor->trace(m_viewSpec);
790 SVGGraphicsElement::trace(visitor); 790 SVGGraphicsElement::trace(visitor);
791 SVGFitToViewBox::trace(visitor); 791 SVGFitToViewBox::trace(visitor);
792 } 792 }
793 793
794 } // namespace blink 794 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/svg/SVGLengthContext.cpp ('k') | Source/core/svg/SVGStopElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698