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

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

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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/SVGRectElement.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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point) 200 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point)
201 { 201 {
202 m_translation->setValue(point); 202 m_translation->setValue(point);
203 updateCurrentTranslate(); 203 updateCurrentTranslate();
204 } 204 }
205 205
206 void SVGSVGElement::updateCurrentTranslate() 206 void SVGSVGElement::updateCurrentTranslate()
207 { 207 {
208 if (LayoutObject* object = renderer()) 208 if (LayoutObject* object = layoutObject())
209 object->setNeedsLayoutAndFullPaintInvalidation(); 209 object->setNeedsLayoutAndFullPaintInvalidation();
210 } 210 }
211 211
212 bool SVGSVGElement::zoomAndPanEnabled() const 212 bool SVGSVGElement::zoomAndPanEnabled() const
213 { 213 {
214 const SVGZoomAndPan* currentViewSpec = this; 214 const SVGZoomAndPan* currentViewSpec = this;
215 if (m_useCurrentView) 215 if (m_useCurrentView)
216 currentViewSpec = m_viewSpec.get(); 216 currentViewSpec = m_viewSpec.get();
217 return currentViewSpec && currentViewSpec->zoomAndPan() == SVGZoomAndPanMagn ify; 217 return currentViewSpec && currentViewSpec->zoomAndPan() == SVGZoomAndPanMagn ify;
218 } 218 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 invalidateRelativeLengthClients(); 295 invalidateRelativeLengthClients();
296 296
297 // At the SVG/HTML boundary (aka LayoutSVGRoot), the width and 297 // At the SVG/HTML boundary (aka LayoutSVGRoot), the width and
298 // height attributes can affect the replaced size so we need 298 // height attributes can affect the replaced size so we need
299 // to mark it for updating. 299 // to mark it for updating.
300 // 300 //
301 // FIXME: For width/height animated as XML attributes on SVG 301 // FIXME: For width/height animated as XML attributes on SVG
302 // roots, there is an attribute synchronization missing. See 302 // roots, there is an attribute synchronization missing. See
303 // http://crbug.com/364807 303 // http://crbug.com/364807
304 if (widthChanged || heightChanged) { 304 if (widthChanged || heightChanged) {
305 LayoutObject* layoutObject = renderer(); 305 LayoutObject* layoutObject = this->layoutObject();
306 if (layoutObject && layoutObject->isSVGRoot()) { 306 if (layoutObject && layoutObject->isSVGRoot()) {
307 invalidateSVGPresentationAttributeStyle(); 307 invalidateSVGPresentationAttributeStyle();
308 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::create(StyleChangeReason::SVGContainerSizeChange)); 308 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::create(StyleChangeReason::SVGContainerSizeChange));
309 } 309 }
310 } else { 310 } else {
311 invalidateSVGPresentationAttributeStyle(); 311 invalidateSVGPresentationAttributeStyle();
312 setNeedsStyleRecalc(LocalStyleChange, 312 setNeedsStyleRecalc(LocalStyleChange,
313 StyleChangeReasonForTracing::fromAttribute(attrName)); 313 StyleChangeReasonForTracing::fromAttribute(attrName));
314 } 314 }
315 } 315 }
316 316
317 if (SVGFitToViewBox::isKnownAttribute(attrName)) { 317 if (SVGFitToViewBox::isKnownAttribute(attrName)) {
318 updateRelativeLengthsOrViewBox = true; 318 updateRelativeLengthsOrViewBox = true;
319 if (LayoutObject* object = renderer()) 319 if (LayoutObject* object = layoutObject())
320 object->setNeedsTransformUpdate(); 320 object->setNeedsTransformUpdate();
321 } 321 }
322 322
323 SVGElement::InvalidationGuard invalidationGuard(this); 323 SVGElement::InvalidationGuard invalidationGuard(this);
324 324
325 if (updateRelativeLengthsOrViewBox 325 if (updateRelativeLengthsOrViewBox
326 || SVGZoomAndPan::isKnownAttribute(attrName)) { 326 || SVGZoomAndPan::isKnownAttribute(attrName)) {
327 if (renderer()) 327 if (layoutObject())
328 markForLayoutAndParentResourceInvalidation(renderer()); 328 markForLayoutAndParentResourceInvalidation(layoutObject());
329 return; 329 return;
330 } 330 }
331 331
332 SVGGraphicsElement::svgAttributeChanged(attrName); 332 SVGGraphicsElement::svgAttributeChanged(attrName);
333 } 333 }
334 334
335 // FloatRect::intersects does not consider horizontal or vertical lines (because of isEmpty()). 335 // FloatRect::intersects does not consider horizontal or vertical lines (because of isEmpty()).
336 static bool intersectsAllowingEmpty(const FloatRect& r1, const FloatRect& r2) 336 static bool intersectsAllowingEmpty(const FloatRect& r1, const FloatRect& r2)
337 { 337 {
338 if (r1.width() < 0 || r1.height() < 0 || r2.width() < 0 || r2.height() < 0) 338 if (r1.width() < 0 || r1.height() < 0 || r2.width() < 0 || r2.height() < 0)
339 return false; 339 return false;
340 340
341 return r1.x() < r2.maxX() && r2.x() < r1.maxX() 341 return r1.x() < r2.maxX() && r2.x() < r1.maxX()
342 && r1.y() < r2.maxY() && r2.y() < r1.maxY(); 342 && r1.y() < r2.maxY() && r2.y() < r1.maxY();
343 } 343 }
344 344
345 // One of the element types that can cause graphics to be drawn onto the target canvas. 345 // One of the element types that can cause graphics to be drawn onto the target canvas.
346 // Specifically: circle, ellipse, image, line, path, polygon, polyline, rect, te xt and use. 346 // Specifically: circle, ellipse, image, line, path, polygon, polyline, rect, te xt and use.
347 static bool isIntersectionOrEnclosureTarget(LayoutObject* renderer) 347 static bool isIntersectionOrEnclosureTarget(LayoutObject* renderer)
348 { 348 {
349 return renderer->isSVGShape() 349 return renderer->isSVGShape()
350 || renderer->isSVGText() 350 || renderer->isSVGText()
351 || renderer->isSVGImage() 351 || renderer->isSVGImage()
352 || isSVGUseElement(*renderer->node()); 352 || isSVGUseElement(*renderer->node());
353 } 353 }
354 354
355 bool SVGSVGElement::checkIntersectionOrEnclosure(const SVGElement& element, cons t FloatRect& rect, 355 bool SVGSVGElement::checkIntersectionOrEnclosure(const SVGElement& element, cons t FloatRect& rect,
356 CheckIntersectionOrEnclosure mode) const 356 CheckIntersectionOrEnclosure mode) const
357 { 357 {
358 LayoutObject* renderer = element.renderer(); 358 LayoutObject* renderer = element.layoutObject();
359 ASSERT(!renderer || renderer->style()); 359 ASSERT(!renderer || renderer->style());
360 if (!renderer || renderer->style()->pointerEvents() == PE_NONE) 360 if (!renderer || renderer->style()->pointerEvents() == PE_NONE)
361 return false; 361 return false;
362 362
363 if (!isIntersectionOrEnclosureTarget(renderer)) 363 if (!isIntersectionOrEnclosureTarget(renderer))
364 return false; 364 return false;
365 365
366 AffineTransform ctm = toSVGGraphicsElement(element).computeCTM(AncestorScope , DisallowStyleUpdate, this); 366 AffineTransform ctm = toSVGGraphicsElement(element).computeCTM(AncestorScope , DisallowStyleUpdate, this);
367 FloatRect mappedRepaintRect = ctm.mapRect(renderer->paintInvalidationRectInL ocalCoordinates()); 367 FloatRect mappedRepaintRect = ctm.mapRect(renderer->paintInvalidationRectInL ocalCoordinates());
368 368
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 if (!hasEmptyViewBox()) { 488 if (!hasEmptyViewBox()) {
489 FloatSize size = currentViewportSize(); 489 FloatSize size = currentViewportSize();
490 viewBoxTransform = viewBoxToViewTransform(size.width(), size.height()); 490 viewBoxTransform = viewBoxToViewTransform(size.width(), size.height());
491 } 491 }
492 492
493 AffineTransform transform; 493 AffineTransform transform;
494 if (!isOutermostSVGSVGElement()) { 494 if (!isOutermostSVGSVGElement()) {
495 SVGLengthContext lengthContext(this); 495 SVGLengthContext lengthContext(this);
496 transform.translate(m_x->currentValue()->value(lengthContext), m_y->curr entValue()->value(lengthContext)); 496 transform.translate(m_x->currentValue()->value(lengthContext), m_y->curr entValue()->value(lengthContext));
497 } else if (mode == SVGElement::ScreenScope) { 497 } else if (mode == SVGElement::ScreenScope) {
498 if (LayoutObject* renderer = this->renderer()) { 498 if (LayoutObject* renderer = this->layoutObject()) {
499 FloatPoint location; 499 FloatPoint location;
500 float zoomFactor = 1; 500 float zoomFactor = 1;
501 501
502 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localT oBorderBoxTransform 502 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localT oBorderBoxTransform
503 // to map an element from SVG viewport coordinates to CSS box coordi nates. 503 // to map an element from SVG viewport coordinates to CSS box coordi nates.
504 // LayoutSVGRoot's localToAbsolute method expects CSS box coordinate s. 504 // LayoutSVGRoot's localToAbsolute method expects CSS box coordinate s.
505 // We also need to adjust for the zoom level factored into CSS coord inates (bug #96361). 505 // We also need to adjust for the zoom level factored into CSS coord inates (bug #96361).
506 if (renderer->isSVGRoot()) { 506 if (renderer->isSVGRoot()) {
507 location = toLayoutSVGRoot(renderer)->localToBorderBoxTransform( ).mapPoint(location); 507 location = toLayoutSVGRoot(renderer)->localToBorderBoxTransform( ).mapPoint(location);
508 zoomFactor = 1 / renderer->style()->effectiveZoom(); 508 zoomFactor = 1 / renderer->style()->effectiveZoom();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 } 616 }
617 617
618 FloatRect SVGSVGElement::currentViewBoxRect() const 618 FloatRect SVGSVGElement::currentViewBoxRect() const
619 { 619 {
620 if (m_useCurrentView) 620 if (m_useCurrentView)
621 return m_viewSpec ? m_viewSpec->viewBox()->currentValue()->value() : Flo atRect(); 621 return m_viewSpec ? m_viewSpec->viewBox()->currentValue()->value() : Flo atRect();
622 622
623 FloatRect useViewBox = viewBox()->currentValue()->value(); 623 FloatRect useViewBox = viewBox()->currentValue()->value();
624 if (!useViewBox.isEmpty()) 624 if (!useViewBox.isEmpty())
625 return useViewBox; 625 return useViewBox;
626 if (!renderer() || !renderer()->isSVGRoot()) 626 if (!layoutObject() || !layoutObject()->isSVGRoot())
627 return FloatRect(); 627 return FloatRect();
628 if (!toLayoutSVGRoot(renderer())->isEmbeddedThroughSVGImage()) 628 if (!toLayoutSVGRoot(layoutObject())->isEmbeddedThroughSVGImage())
629 return FloatRect(); 629 return FloatRect();
630 630
631 // If no viewBox is specified but non-relative width/height values, then we 631 // If no viewBox is specified but non-relative width/height values, then we
632 // should always synthesize a viewBox if we're embedded through a SVGImage. 632 // should always synthesize a viewBox if we're embedded through a SVGImage.
633 return FloatRect(FloatPoint(), FloatSize(floatValueForLength(intrinsicWidth( ), 0), floatValueForLength(intrinsicHeight(), 0))); 633 return FloatRect(FloatPoint(), FloatSize(floatValueForLength(intrinsicWidth( ), 0), floatValueForLength(intrinsicHeight(), 0)));
634 } 634 }
635 635
636 FloatSize SVGSVGElement::currentViewportSize() const 636 FloatSize SVGSVGElement::currentViewportSize() const
637 { 637 {
638 if (!renderer()) 638 if (!layoutObject())
639 return FloatSize(); 639 return FloatSize();
640 640
641 if (renderer()->isSVGRoot()) { 641 if (layoutObject()->isSVGRoot()) {
642 LayoutRect contentBoxRect = toLayoutSVGRoot(renderer())->contentBoxRect( ); 642 LayoutRect contentBoxRect = toLayoutSVGRoot(layoutObject())->contentBoxR ect();
643 return FloatSize(contentBoxRect.width() / renderer()->style()->effective Zoom(), contentBoxRect.height() / renderer()->style()->effectiveZoom()); 643 return FloatSize(contentBoxRect.width() / layoutObject()->style()->effec tiveZoom(), contentBoxRect.height() / layoutObject()->style()->effectiveZoom());
644 } 644 }
645 645
646 FloatRect viewportRect = toLayoutSVGViewportContainer(renderer())->viewport( ); 646 FloatRect viewportRect = toLayoutSVGViewportContainer(layoutObject())->viewp ort();
647 return FloatSize(viewportRect.width(), viewportRect.height()); 647 return FloatSize(viewportRect.width(), viewportRect.height());
648 } 648 }
649 649
650 bool SVGSVGElement::hasIntrinsicWidth() const 650 bool SVGSVGElement::hasIntrinsicWidth() const
651 { 651 {
652 return width()->currentValue()->unitType() != LengthTypePercentage; 652 return width()->currentValue()->unitType() != LengthTypePercentage;
653 } 653 }
654 654
655 bool SVGSVGElement::hasIntrinsicHeight() const 655 bool SVGSVGElement::hasIntrinsicHeight() const
656 { 656 {
(...skipping 30 matching lines...) Expand all
687 687
688 AffineTransform transform; 688 AffineTransform transform;
689 if (transformList->concatenate(transform)) 689 if (transformList->concatenate(transform))
690 ctm *= transform; 690 ctm *= transform;
691 691
692 return ctm; 692 return ctm;
693 } 693 }
694 694
695 void SVGSVGElement::setupInitialView(const String& fragmentIdentifier, Element* anchorNode) 695 void SVGSVGElement::setupInitialView(const String& fragmentIdentifier, Element* anchorNode)
696 { 696 {
697 LayoutObject* renderer = this->renderer(); 697 LayoutObject* renderer = this->layoutObject();
698 SVGViewSpec* view = m_viewSpec.get(); 698 SVGViewSpec* view = m_viewSpec.get();
699 if (view) 699 if (view)
700 view->reset(); 700 view->reset();
701 701
702 bool hadUseCurrentView = m_useCurrentView; 702 bool hadUseCurrentView = m_useCurrentView;
703 m_useCurrentView = false; 703 m_useCurrentView = false;
704 704
705 if (fragmentIdentifier.startsWith("xpointer(")) { 705 if (fragmentIdentifier.startsWith("xpointer(")) {
706 // FIXME: XPointer references are ignored (https://bugs.webkit.org/show_ bug.cgi?id=17491) 706 // FIXME: XPointer references are ignored (https://bugs.webkit.org/show_ bug.cgi?id=17491)
707 if (renderer && hadUseCurrentView) 707 if (renderer && hadUseCurrentView)
(...skipping 18 matching lines...) Expand all
726 // Spec: If the SVG fragment identifier addresses a 'view' element within an SVG document (e.g., MyDrawing.svg#MyView 726 // Spec: If the SVG fragment identifier addresses a 'view' element within an SVG document (e.g., MyDrawing.svg#MyView
727 // or MyDrawing.svg#xpointer(id('MyView'))) then the closest ancestor 'svg' element is displayed in the viewport. 727 // or MyDrawing.svg#xpointer(id('MyView'))) then the closest ancestor 'svg' element is displayed in the viewport.
728 // Any view specification attributes included on the given 'view' element ov erride the corresponding view specification 728 // Any view specification attributes included on the given 'view' element ov erride the corresponding view specification
729 // attributes on the closest ancestor 'svg' element. 729 // attributes on the closest ancestor 'svg' element.
730 if (isSVGViewElement(anchorNode)) { 730 if (isSVGViewElement(anchorNode)) {
731 SVGViewElement& viewElement = toSVGViewElement(*anchorNode); 731 SVGViewElement& viewElement = toSVGViewElement(*anchorNode);
732 732
733 if (SVGSVGElement* svg = viewElement.ownerSVGElement()) { 733 if (SVGSVGElement* svg = viewElement.ownerSVGElement()) {
734 svg->inheritViewAttributes(&viewElement); 734 svg->inheritViewAttributes(&viewElement);
735 735
736 if (LayoutObject* renderer = svg->renderer()) 736 if (LayoutObject* renderer = svg->layoutObject())
737 markForLayoutAndParentResourceInvalidation(renderer); 737 markForLayoutAndParentResourceInvalidation(renderer);
738 738
739 return; 739 return;
740 } 740 }
741 } 741 }
742 742
743 // If we previously had a view and didn't get a new one, we need to 743 // If we previously had a view and didn't get a new one, we need to
744 // layout again. 744 // layout again.
745 if (renderer && hadUseCurrentView) 745 if (renderer && hadUseCurrentView)
746 markForLayoutAndParentResourceInvalidation(renderer); 746 markForLayoutAndParentResourceInvalidation(renderer);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 visitor->trace(m_width); 793 visitor->trace(m_width);
794 visitor->trace(m_height); 794 visitor->trace(m_height);
795 visitor->trace(m_translation); 795 visitor->trace(m_translation);
796 visitor->trace(m_timeContainer); 796 visitor->trace(m_timeContainer);
797 visitor->trace(m_viewSpec); 797 visitor->trace(m_viewSpec);
798 SVGGraphicsElement::trace(visitor); 798 SVGGraphicsElement::trace(visitor);
799 SVGFitToViewBox::trace(visitor); 799 SVGFitToViewBox::trace(visitor);
800 } 800 }
801 801
802 } // namespace blink 802 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/svg/SVGRectElement.cpp ('k') | Source/core/svg/SVGStopElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698