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

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

Issue 1154853007: Move toClipPath to SVGGeometryElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Draft 3 Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
6 * Copyright (C) 2012 University of Szeged 6 * Copyright (C) 2012 University of Szeged
7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> 7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 || isSVGEllipseElement(element) 437 || isSVGEllipseElement(element)
438 || isSVGPolygonElement(element) 438 || isSVGPolygonElement(element)
439 || isSVGPolylineElement(element) 439 || isSVGPolylineElement(element)
440 || isSVGTextElement(element); 440 || isSVGTextElement(element);
441 } 441 }
442 442
443 void SVGUseElement::toClipPath(Path& path) 443 void SVGUseElement::toClipPath(Path& path)
444 { 444 {
445 ASSERT(path.isEmpty()); 445 ASSERT(path.isEmpty());
446 446
447 Node* n = userAgentShadowRoot()->firstChild(); 447 const SVGGraphicsElement* element = targetGraphicsElementForClipping();
448 if (!n || !n->isSVGElement()) 448
449 if (!element)
449 return; 450 return;
450 SVGElement& element = toSVGElement(*n);
451 451
452 if (element.isSVGGraphicsElement()) { 452 if (!isDirectReference(*element)) {
453 if (!isDirectReference(element)) { 453 // Spec: Indirect references are an error (14.3.5)
454 // Spec: Indirect references are an error (14.3.5) 454 document().accessSVGExtensions().reportError("Not allowed to use indirec t reference in <clip-path>");
455 document().accessSVGExtensions().reportError("Not allowed to use ind irect reference in <clip-path>"); 455 } else if (element->isSVGGeometryElement()) {
456 } else { 456 toSVGGeometryElement(*element).toClipPath(path);
457 toSVGGraphicsElement(element).toClipPath(path); 457 // FIXME: Avoid manual resolution of x/y here. Its potentially harmful.
458 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf ul. 458 SVGLengthContext lengthContext(this);
459 SVGLengthContext lengthContext(this); 459 path.translate(FloatSize(m_x->currentValue()->value(lengthContext), m_y- >currentValue()->value(lengthContext)));
460 path.translate(FloatSize(m_x->currentValue()->value(lengthContext), m_y->currentValue()->value(lengthContext))); 460 path.transform(calculateAnimatedLocalTransform());
461 path.transform(calculateAnimatedLocalTransform());
462 }
463 } 461 }
464 } 462 }
465 463
466 LayoutObject* SVGUseElement::layoutObjectClipChild() const 464 SVGGraphicsElement* SVGUseElement::targetGraphicsElementForClipping() const
467 { 465 {
468 if (Node* n = userAgentShadowRoot()->firstChild()) { 466 Node* n = userAgentShadowRoot()->firstChild();
469 if (n->isSVGElement() && isDirectReference(toSVGElement(*n))) 467 if (!n || !n->isSVGElement())
470 return n->layoutObject(); 468 return nullptr;
469
470 SVGElement& element = toSVGElement(*n);
471 if (element.isSVGGraphicsElement()) {
472 if (isSVGTextElement(element) || isSVGTSpanElement(element) || element.i sSVGGeometryElement())
pdr. 2015/06/17 04:42:13 Lets add a link to the spec here. // Spec: "If a <
473 return &toSVGGraphicsElement(element);
471 } 474 }
472 475
473 return nullptr; 476 return nullptr;
474 } 477 }
475 478
479 LayoutObject* SVGUseElement::layoutObjectClipChild() const
pdr. 2015/06/17 04:42:13 This function is pretty simple now, can you move t
480 {
481 const SVGGraphicsElement* element = targetGraphicsElementForClipping();
482
483 if (!element)
484 return nullptr;
485
486 return element->layoutObject();
487 }
488
476 bool SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstan ce, bool foundUse) 489 bool SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstan ce, bool foundUse)
477 { 490 {
478 ASSERT(target); 491 ASSERT(target);
479 ASSERT(targetInstance); 492 ASSERT(targetInstance);
480 493
481 // Spec: If the referenced object is itself a 'use', or if there are 'use' s ubelements within the referenced 494 // Spec: If the referenced object is itself a 'use', or if there are 'use' s ubelements within the referenced
482 // object, the instance tree will contain recursive expansion of the indirec t references to form a complete tree. 495 // object, the instance tree will contain recursive expansion of the indirec t references to form a complete tree.
483 if (isSVGUseElement(*target)) { 496 if (isSVGUseElement(*target)) {
484 // We only need to track first degree <use> dependencies. Indirect refer ences are handled 497 // We only need to track first degree <use> dependencies. Indirect refer ences are handled
485 // as the invalidation bubbles up the dependency chain. 498 // as the invalidation bubbles up the dependency chain.
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 787
775 if (m_resource) 788 if (m_resource)
776 m_resource->removeClient(this); 789 m_resource->removeClient(this);
777 790
778 m_resource = resource; 791 m_resource = resource;
779 if (m_resource) 792 if (m_resource)
780 m_resource->addClient(this); 793 m_resource->addClient(this);
781 } 794 }
782 795
783 } 796 }
OLDNEW
« Source/core/svg/SVGUseElement.h ('K') | « Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698