OLD | NEW |
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, 2008 Rob Buis <buis@kde.org> | 4 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> |
5 * Copyright (C) 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 6 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
7 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 7 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
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 30 matching lines...) Expand all Loading... |
41 #include "core/events/Event.h" | 41 #include "core/events/Event.h" |
42 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
43 #include "core/html/HTMLElement.h" | 43 #include "core/html/HTMLElement.h" |
44 #include "core/layout/LayoutObject.h" | 44 #include "core/layout/LayoutObject.h" |
45 #include "core/layout/svg/LayoutSVGResourceContainer.h" | 45 #include "core/layout/svg/LayoutSVGResourceContainer.h" |
46 #include "core/svg/SVGDocumentExtensions.h" | 46 #include "core/svg/SVGDocumentExtensions.h" |
47 #include "core/svg/SVGElementRareData.h" | 47 #include "core/svg/SVGElementRareData.h" |
48 #include "core/svg/SVGGraphicsElement.h" | 48 #include "core/svg/SVGGraphicsElement.h" |
49 #include "core/svg/SVGSVGElement.h" | 49 #include "core/svg/SVGSVGElement.h" |
50 #include "core/svg/SVGTitleElement.h" | 50 #include "core/svg/SVGTitleElement.h" |
| 51 #include "core/svg/SVGTreeScopeResources.h" |
51 #include "core/svg/SVGUseElement.h" | 52 #include "core/svg/SVGUseElement.h" |
52 #include "core/svg/properties/SVGProperty.h" | 53 #include "core/svg/properties/SVGProperty.h" |
53 #include "wtf/AutoReset.h" | 54 #include "wtf/AutoReset.h" |
54 #include "wtf/Threading.h" | 55 #include "wtf/Threading.h" |
55 | 56 |
56 namespace blink { | 57 namespace blink { |
57 | 58 |
58 using namespace HTMLNames; | 59 using namespace HTMLNames; |
59 using namespace SVGNames; | 60 using namespace SVGNames; |
60 | 61 |
(...skipping 19 matching lines...) Expand all Loading... |
80 if (SVGElement* element = correspondingElement()) | 81 if (SVGElement* element = correspondingElement()) |
81 element->removeInstanceMapping(this); | 82 element->removeInstanceMapping(this); |
82 } | 83 } |
83 | 84 |
84 void SVGElement::attachLayoutTree(const AttachContext& context) { | 85 void SVGElement::attachLayoutTree(const AttachContext& context) { |
85 Element::attachLayoutTree(context); | 86 Element::attachLayoutTree(context); |
86 if (SVGElement* element = correspondingElement()) | 87 if (SVGElement* element = correspondingElement()) |
87 element->mapInstanceToElement(this); | 88 element->mapInstanceToElement(this); |
88 } | 89 } |
89 | 90 |
| 91 TreeScope& SVGElement::treeScopeForIdResolution() const { |
| 92 const SVGElement* treeScopeElement = this; |
| 93 if (const SVGElement* element = correspondingElement()) |
| 94 treeScopeElement = element; |
| 95 return treeScopeElement->treeScope(); |
| 96 } |
| 97 |
90 int SVGElement::tabIndex() const { | 98 int SVGElement::tabIndex() const { |
91 if (supportsFocus()) | 99 if (supportsFocus()) |
92 return Element::tabIndex(); | 100 return Element::tabIndex(); |
93 return -1; | 101 return -1; |
94 } | 102 } |
95 | 103 |
96 void SVGElement::willRecalcStyle(StyleRecalcChange change) { | 104 void SVGElement::willRecalcStyle(StyleRecalcChange change) { |
97 if (!hasSVGRareData()) | 105 if (!hasSVGRareData()) |
98 return; | 106 return; |
99 // If the style changes because of a regular property change (not induced by | 107 // If the style changes because of a regular property change (not induced by |
100 // SMIL animations themselves) reset the "computed style without SMIL style | 108 // SMIL animations themselves) reset the "computed style without SMIL style |
101 // properties", so the base value change gets reflected. | 109 // properties", so the base value change gets reflected. |
102 if (change > NoChange || needsStyleRecalc()) | 110 if (change > NoChange || needsStyleRecalc()) |
103 svgRareData()->setNeedsOverrideComputedStyleUpdate(); | 111 svgRareData()->setNeedsOverrideComputedStyleUpdate(); |
104 } | 112 } |
105 | 113 |
106 void SVGElement::buildPendingResourcesIfNeeded() { | 114 void SVGElement::buildPendingResourcesIfNeeded() { |
107 Document& document = this->document(); | |
108 if (!needsPendingResourceHandling() || !isConnected() || inUseShadowTree()) | 115 if (!needsPendingResourceHandling() || !isConnected() || inUseShadowTree()) |
109 return; | 116 return; |
110 | 117 |
111 SVGDocumentExtensions& extensions = document.accessSVGExtensions(); | 118 SVGTreeScopeResources& treeScopeResources = |
| 119 treeScope().accessSVGTreeScopedResources(); |
112 AtomicString resourceId = getIdAttribute(); | 120 AtomicString resourceId = getIdAttribute(); |
113 if (!extensions.hasPendingResource(resourceId)) | 121 if (!treeScopeResources.hasPendingResource(resourceId)) |
114 return; | 122 return; |
115 // Guaranteed by hasPendingResource. | 123 // Guaranteed by hasPendingResource. |
116 DCHECK(!resourceId.isEmpty()); | 124 DCHECK(!resourceId.isEmpty()); |
117 | 125 |
118 // Get pending elements for this id. | 126 // Get pending elements for this id. |
119 SVGDocumentExtensions::SVGPendingElements* pendingElements = | 127 SVGTreeScopeResources::SVGPendingElements* pendingElements = |
120 extensions.removePendingResource(resourceId); | 128 treeScopeResources.removePendingResource(resourceId); |
121 if (!pendingElements || pendingElements->isEmpty()) | 129 if (!pendingElements || pendingElements->isEmpty()) |
122 return; | 130 return; |
123 | 131 |
124 // Rebuild pending resources for each client of a pending resource that is | 132 // Rebuild pending resources for each client of a pending resource that is |
125 // being removed. | 133 // being removed. |
126 for (Element* clientElement : *pendingElements) { | 134 for (Element* clientElement : *pendingElements) { |
127 DCHECK(clientElement->hasPendingResources()); | 135 DCHECK(clientElement->hasPendingResources()); |
128 if (!clientElement->hasPendingResources()) | 136 if (!clientElement->hasPendingResources()) |
129 continue; | 137 continue; |
130 // TODO(fs): Ideally we'd always resolve pending resources async instead of | 138 // TODO(fs): Ideally we'd always resolve pending resources async instead of |
131 // inside insertedInto and svgAttributeChanged. For now we only do it for | 139 // inside insertedInto and svgAttributeChanged. For now we only do it for |
132 // <use> since that would stamp out DOM. | 140 // <use> since that would stamp out DOM. |
133 if (isSVGUseElement(clientElement)) | 141 if (isSVGUseElement(clientElement)) |
134 toSVGUseElement(clientElement)->invalidateShadowTree(); | 142 toSVGUseElement(clientElement)->invalidateShadowTree(); |
135 else | 143 else |
136 clientElement->buildPendingResource(); | 144 clientElement->buildPendingResource(); |
137 extensions.clearHasPendingResourcesIfPossible(clientElement); | 145 treeScopeResources.clearHasPendingResourcesIfPossible(clientElement); |
138 } | 146 } |
139 } | 147 } |
140 | 148 |
141 SVGElementRareData* SVGElement::ensureSVGRareData() { | 149 SVGElementRareData* SVGElement::ensureSVGRareData() { |
142 if (hasSVGRareData()) | 150 if (hasSVGRareData()) |
143 return svgRareData(); | 151 return svgRareData(); |
144 | 152 |
145 m_SVGRareData = new SVGElementRareData(this); | 153 m_SVGRareData = new SVGElementRareData(this); |
146 return m_SVGRareData.get(); | 154 return m_SVGRareData.get(); |
147 } | 155 } |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 visitor->trace(m_className); | 1295 visitor->trace(m_className); |
1288 Element::trace(visitor); | 1296 Element::trace(visitor); |
1289 } | 1297 } |
1290 | 1298 |
1291 const AtomicString& SVGElement::eventParameterName() { | 1299 const AtomicString& SVGElement::eventParameterName() { |
1292 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); | 1300 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); |
1293 return evtString; | 1301 return evtString; |
1294 } | 1302 } |
1295 | 1303 |
1296 } // namespace blink | 1304 } // namespace blink |
OLD | NEW |