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

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

Issue 2706583002: Fix the way <title> is read under <use> shadow tree (Closed)
Patch Set: Add testharness based test case and remove shadow tree test case Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann
3 * <zimmermann@kde.org> 3 * <zimmermann@kde.org>
4 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 4 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
6 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 6 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
7 * Copyright (C) 2012 University of Szeged 7 * Copyright (C) 2012 University of Szeged
8 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> 8 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 22 matching lines...) Expand all
33 #include "core/dom/StyleChangeReason.h" 33 #include "core/dom/StyleChangeReason.h"
34 #include "core/dom/TaskRunnerHelper.h" 34 #include "core/dom/TaskRunnerHelper.h"
35 #include "core/dom/shadow/ElementShadow.h" 35 #include "core/dom/shadow/ElementShadow.h"
36 #include "core/dom/shadow/ShadowRoot.h" 36 #include "core/dom/shadow/ShadowRoot.h"
37 #include "core/events/Event.h" 37 #include "core/events/Event.h"
38 #include "core/layout/svg/LayoutSVGTransformableContainer.h" 38 #include "core/layout/svg/LayoutSVGTransformableContainer.h"
39 #include "core/svg/SVGGElement.h" 39 #include "core/svg/SVGGElement.h"
40 #include "core/svg/SVGLengthContext.h" 40 #include "core/svg/SVGLengthContext.h"
41 #include "core/svg/SVGSVGElement.h" 41 #include "core/svg/SVGSVGElement.h"
42 #include "core/svg/SVGSymbolElement.h" 42 #include "core/svg/SVGSymbolElement.h"
43 #include "core/svg/SVGTitleElement.h"
43 #include "core/svg/SVGTreeScopeResources.h" 44 #include "core/svg/SVGTreeScopeResources.h"
44 #include "core/xml/parser/XMLDocumentParser.h" 45 #include "core/xml/parser/XMLDocumentParser.h"
45 #include "platform/loader/fetch/FetchRequest.h" 46 #include "platform/loader/fetch/FetchRequest.h"
46 #include "platform/loader/fetch/ResourceFetcher.h" 47 #include "platform/loader/fetch/ResourceFetcher.h"
47 #include "wtf/Vector.h" 48 #include "wtf/Vector.h"
48 49
49 namespace blink { 50 namespace blink {
50 51
51 inline SVGUseElement::SVGUseElement(Document& document) 52 inline SVGUseElement::SVGUseElement(Document& document)
52 : SVGGraphicsElement(SVGNames::useTag, document), 53 : SVGGraphicsElement(SVGNames::useTag, document),
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 return; 333 return;
333 Element* target = resolveTargetElement(); 334 Element* target = resolveTargetElement();
334 if (target && target->isSVGElement()) { 335 if (target && target->isSVGElement()) {
335 buildShadowAndInstanceTree(toSVGElement(*target)); 336 buildShadowAndInstanceTree(toSVGElement(*target));
336 invalidateDependentShadowTrees(); 337 invalidateDependentShadowTrees();
337 } 338 }
338 339
339 ASSERT(!m_needsShadowTreeRecreation); 340 ASSERT(!m_needsShadowTreeRecreation);
340 } 341 }
341 342
343 String SVGUseElement::title() const {
344 // Find the first <title> child in <use> which doesn't cover shadow tree.
345 if (Element* titleElement = Traversal<SVGTitleElement>::firstChild(*this))
346 return titleElement->innerText();
347
348 // If there is no <title> child in <use>, we lookup first <title> child in
349 // shadow tree.
350 if (!m_targetElementInstance) {
fs 2017/03/02 08:45:07 Reverse condition.
mrunal 2017/03/02 23:49:07 Oops..I mistakenly replaced the other way I was pl
351 if (Element* titleElement =
352 Traversal<SVGTitleElement>::firstChild(*m_targetElementInstance))
353 return titleElement->innerText();
354 }
355 // Otherwise return a null string.
356 return String();
357 }
358
342 static void associateCorrespondingElements(SVGElement& targetRoot, 359 static void associateCorrespondingElements(SVGElement& targetRoot,
343 SVGElement& instanceRoot) { 360 SVGElement& instanceRoot) {
344 auto targetRange = Traversal<SVGElement>::inclusiveDescendantsOf(targetRoot); 361 auto targetRange = Traversal<SVGElement>::inclusiveDescendantsOf(targetRoot);
345 auto targetIterator = targetRange.begin(); 362 auto targetIterator = targetRange.begin();
346 for (SVGElement& instance : 363 for (SVGElement& instance :
347 Traversal<SVGElement>::inclusiveDescendantsOf(instanceRoot)) { 364 Traversal<SVGElement>::inclusiveDescendantsOf(instanceRoot)) {
348 ASSERT(!instance.correspondingElement()); 365 ASSERT(!instance.correspondingElement());
349 instance.setCorrespondingElement(&*targetIterator); 366 instance.setCorrespondingElement(&*targetIterator);
350 ++targetIterator; 367 ++targetIterator;
351 } 368 }
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 741
725 if (m_resource) 742 if (m_resource)
726 m_resource->removeClient(this); 743 m_resource->removeClient(this);
727 744
728 m_resource = resource; 745 m_resource = resource;
729 if (m_resource) 746 if (m_resource)
730 m_resource->addClient(this); 747 m_resource->addClient(this);
731 } 748 }
732 749
733 } // namespace blink 750 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698