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 16 matching lines...) Expand all Loading... |
77 if (SVGElement* element = correspondingElement()) | 78 if (SVGElement* element = correspondingElement()) |
78 element->removeInstanceMapping(this); | 79 element->removeInstanceMapping(this); |
79 } | 80 } |
80 | 81 |
81 void SVGElement::attachLayoutTree(const AttachContext& context) { | 82 void SVGElement::attachLayoutTree(const AttachContext& context) { |
82 Element::attachLayoutTree(context); | 83 Element::attachLayoutTree(context); |
83 if (SVGElement* element = correspondingElement()) | 84 if (SVGElement* element = correspondingElement()) |
84 element->mapInstanceToElement(this); | 85 element->mapInstanceToElement(this); |
85 } | 86 } |
86 | 87 |
| 88 TreeScope& SVGElement::treeScopeForIdResolution() const { |
| 89 const SVGElement* treeScopeElement = this; |
| 90 if (const SVGElement* element = correspondingElement()) |
| 91 treeScopeElement = element; |
| 92 return treeScopeElement->treeScope(); |
| 93 } |
| 94 |
87 int SVGElement::tabIndex() const { | 95 int SVGElement::tabIndex() const { |
88 if (supportsFocus()) | 96 if (supportsFocus()) |
89 return Element::tabIndex(); | 97 return Element::tabIndex(); |
90 return -1; | 98 return -1; |
91 } | 99 } |
92 | 100 |
93 void SVGElement::willRecalcStyle(StyleRecalcChange change) { | 101 void SVGElement::willRecalcStyle(StyleRecalcChange change) { |
94 if (!hasSVGRareData()) | 102 if (!hasSVGRareData()) |
95 return; | 103 return; |
96 // If the style changes because of a regular property change (not induced by | 104 // If the style changes because of a regular property change (not induced by |
97 // SMIL animations themselves) reset the "computed style without SMIL style | 105 // SMIL animations themselves) reset the "computed style without SMIL style |
98 // properties", so the base value change gets reflected. | 106 // properties", so the base value change gets reflected. |
99 if (change > NoChange || needsStyleRecalc()) | 107 if (change > NoChange || needsStyleRecalc()) |
100 svgRareData()->setNeedsOverrideComputedStyleUpdate(); | 108 svgRareData()->setNeedsOverrideComputedStyleUpdate(); |
101 } | 109 } |
102 | 110 |
103 void SVGElement::buildPendingResourcesIfNeeded() { | 111 void SVGElement::buildPendingResourcesIfNeeded() { |
104 Document& document = this->document(); | |
105 if (!needsPendingResourceHandling() || !isConnected() || inUseShadowTree()) | 112 if (!needsPendingResourceHandling() || !isConnected() || inUseShadowTree()) |
106 return; | 113 return; |
107 | 114 |
108 SVGDocumentExtensions& extensions = document.accessSVGExtensions(); | 115 SVGTreeScopeResources& treeScopeResources = |
| 116 treeScope().ensureSVGTreeScopedResources(); |
109 AtomicString resourceId = getIdAttribute(); | 117 AtomicString resourceId = getIdAttribute(); |
110 if (!extensions.hasPendingResource(resourceId)) | 118 if (!treeScopeResources.hasPendingResource(resourceId)) |
111 return; | 119 return; |
112 // Guaranteed by hasPendingResource. | 120 // Guaranteed by hasPendingResource. |
113 DCHECK(!resourceId.isEmpty()); | 121 DCHECK(!resourceId.isEmpty()); |
114 | 122 |
115 // Get pending elements for this id. | 123 // Get pending elements for this id. |
116 SVGDocumentExtensions::SVGPendingElements* pendingElements = | 124 SVGTreeScopeResources::SVGPendingElements* pendingElements = |
117 extensions.removePendingResource(resourceId); | 125 treeScopeResources.removePendingResource(resourceId); |
118 if (!pendingElements || pendingElements->isEmpty()) | 126 if (!pendingElements || pendingElements->isEmpty()) |
119 return; | 127 return; |
120 | 128 |
121 // Rebuild pending resources for each client of a pending resource that is | 129 // Rebuild pending resources for each client of a pending resource that is |
122 // being removed. | 130 // being removed. |
123 for (Element* clientElement : *pendingElements) { | 131 for (Element* clientElement : *pendingElements) { |
124 DCHECK(clientElement->hasPendingResources()); | 132 DCHECK(clientElement->hasPendingResources()); |
125 if (!clientElement->hasPendingResources()) | 133 if (!clientElement->hasPendingResources()) |
126 continue; | 134 continue; |
127 // TODO(fs): Ideally we'd always resolve pending resources async instead of | 135 // TODO(fs): Ideally we'd always resolve pending resources async instead of |
128 // inside insertedInto and svgAttributeChanged. For now we only do it for | 136 // inside insertedInto and svgAttributeChanged. For now we only do it for |
129 // <use> since that would stamp out DOM. | 137 // <use> since that would stamp out DOM. |
130 if (isSVGUseElement(clientElement)) | 138 if (isSVGUseElement(clientElement)) |
131 toSVGUseElement(clientElement)->invalidateShadowTree(); | 139 toSVGUseElement(clientElement)->invalidateShadowTree(); |
132 else | 140 else |
133 clientElement->buildPendingResource(); | 141 clientElement->buildPendingResource(); |
134 extensions.clearHasPendingResourcesIfPossible(clientElement); | 142 treeScopeResources.clearHasPendingResourcesIfPossible(clientElement); |
135 } | 143 } |
136 } | 144 } |
137 | 145 |
138 SVGElementRareData* SVGElement::ensureSVGRareData() { | 146 SVGElementRareData* SVGElement::ensureSVGRareData() { |
139 if (hasSVGRareData()) | 147 if (hasSVGRareData()) |
140 return svgRareData(); | 148 return svgRareData(); |
141 | 149 |
142 m_SVGRareData = new SVGElementRareData(this); | 150 m_SVGRareData = new SVGElementRareData(this); |
143 return m_SVGRareData.get(); | 151 return m_SVGRareData.get(); |
144 } | 152 } |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 visitor->trace(m_className); | 1292 visitor->trace(m_className); |
1285 Element::trace(visitor); | 1293 Element::trace(visitor); |
1286 } | 1294 } |
1287 | 1295 |
1288 const AtomicString& SVGElement::eventParameterName() { | 1296 const AtomicString& SVGElement::eventParameterName() { |
1289 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); | 1297 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); |
1290 return evtString; | 1298 return evtString; |
1291 } | 1299 } |
1292 | 1300 |
1293 } // namespace blink | 1301 } // namespace blink |
OLD | NEW |