OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 #include "core/fetch/FetchRequest.h" | 36 #include "core/fetch/FetchRequest.h" |
37 #include "core/fetch/ResourceFetcher.h" | 37 #include "core/fetch/ResourceFetcher.h" |
38 #include "core/rendering/svg/RenderSVGResource.h" | 38 #include "core/rendering/svg/RenderSVGResource.h" |
39 #include "core/rendering/svg/RenderSVGTransformableContainer.h" | 39 #include "core/rendering/svg/RenderSVGTransformableContainer.h" |
40 #include "core/svg/SVGElementInstance.h" | 40 #include "core/svg/SVGElementInstance.h" |
41 #include "core/svg/SVGGElement.h" | 41 #include "core/svg/SVGGElement.h" |
42 #include "core/svg/SVGLengthContext.h" | 42 #include "core/svg/SVGLengthContext.h" |
43 #include "core/svg/SVGSVGElement.h" | 43 #include "core/svg/SVGSVGElement.h" |
44 #include "core/xml/parser/XMLDocumentParser.h" | 44 #include "core/xml/parser/XMLDocumentParser.h" |
45 | 45 |
46 // Dump SVGElementInstance object tree - useful to debug instanceRoot problems | |
47 // #define DUMP_INSTANCE_TREE | |
48 | |
49 // Dump the deep-expanded shadow tree (where the renderers are built from) | |
50 // #define DUMP_SHADOW_TREE | |
51 | |
52 namespace WebCore { | 46 namespace WebCore { |
53 | 47 |
54 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser
) | 48 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser
) |
55 : SVGGraphicsElement(SVGNames::useTag, document) | 49 : SVGGraphicsElement(SVGNames::useTag, document) |
56 , SVGURIReference(this) | 50 , SVGURIReference(this) |
57 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth), AllowNegativeLengths)) | 51 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth), AllowNegativeLengths)) |
58 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight), AllowNegativeLengths)) | 52 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight), AllowNegativeLengths)) |
59 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth), ForbidNegativeLengths)) | 53 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth), ForbidNegativeLengths)) |
60 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight), ForbidNegativeLengths)) | 54 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight), ForbidNegativeLengths)) |
61 , m_wasInsertedByParser(wasInsertedByParser) | 55 , m_wasInsertedByParser(wasInsertedByParser) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 253 |
260 return; | 254 return; |
261 } | 255 } |
262 | 256 |
263 if (!renderer) | 257 if (!renderer) |
264 return; | 258 return; |
265 | 259 |
266 ASSERT_NOT_REACHED(); | 260 ASSERT_NOT_REACHED(); |
267 } | 261 } |
268 | 262 |
269 #ifdef DUMP_INSTANCE_TREE | |
270 static void dumpInstanceTree(unsigned& depth, String& text, SVGElementInstance*
targetInstance) | |
271 { | |
272 SVGElement* element = targetInstance->correspondingElement(); | |
273 ASSERT(element); | |
274 | |
275 if (isSVGUseElement(*element) && toSVGUseElement(*element).resourceIsStillLo
ading()) | |
276 return; | |
277 | |
278 SVGElement* shadowTreeElement = targetInstance->shadowTreeElement(); | |
279 ASSERT(shadowTreeElement); | |
280 | |
281 SVGUseElement* directUseElement = targetInstance->directUseElement(); | |
282 String directUseElementName = directUseElement ? directUseElement->nodeName(
) : "null"; | |
283 | |
284 String elementId = element->getIdAttribute(); | |
285 String elementNodeName = element->nodeName(); | |
286 String shadowTreeElementNodeName = shadowTreeElement->nodeName(); | |
287 String parentNodeName = element->parentNode() ? element->parentNode()->nodeN
ame() : "null"; | |
288 String firstChildNodeName = element->firstChild() ? element->firstChild()->n
odeName() : "null"; | |
289 | |
290 for (unsigned i = 0; i < depth; ++i) | |
291 text += " "; | |
292 | |
293 text += String::format("SVGElementInstance this=%p, (parentNode=%s (%p), fir
stChild=%s (%p), correspondingElement=%s (%p), directUseElement=%s (%p), shadowT
reeElement=%s (%p), id=%s)\n", | |
294 targetInstance, parentNodeName.latin1().data(), eleme
nt->parentNode(), firstChildNodeName.latin1().data(), element->firstChild(), | |
295 elementNodeName.latin1().data(), element, directUseEl
ementName.latin1().data(), directUseElement, shadowTreeElementNodeName.latin1().
data(), shadowTreeElement, elementId.latin1().data()); | |
296 | |
297 for (unsigned i = 0; i < depth; ++i) | |
298 text += " "; | |
299 | |
300 const HashSet<SVGElementInstance*>& elementInstances = element->instancesFor
Element(); | |
301 text += "Corresponding element is associated with " + String::number(element
Instances.size()) + " instance(s):\n"; | |
302 | |
303 const HashSet<SVGElementInstance*>::const_iterator end = elementInstances.en
d(); | |
304 for (HashSet<SVGElementInstance*>::const_iterator it = elementInstances.begi
n(); it != end; ++it) { | |
305 for (unsigned i = 0; i < depth; ++i) | |
306 text += " "; | |
307 | |
308 text += String::format(" -> SVGElementInstance this=%p, (refCount: %i, s
hadowTreeElement in document? %i)\n", | |
309 *it, (*it)->refCount(), (*it)->shadowTreeElement(
)->inDocument()); | |
310 } | |
311 | |
312 ++depth; | |
313 | |
314 for (SVGElementInstance* instance = targetInstance->firstChild(); instance;
instance = instance->nextSibling()) | |
315 dumpInstanceTree(depth, text, instance); | |
316 | |
317 --depth; | |
318 } | |
319 #endif | |
320 | |
321 static bool isDisallowedElement(Node* node) | 263 static bool isDisallowedElement(Node* node) |
322 { | 264 { |
323 // Spec: "Any 'svg', 'symbol', 'g', graphics element or other 'use' is poten
tially a template object that can be re-used | 265 // Spec: "Any 'svg', 'symbol', 'g', graphics element or other 'use' is poten
tially a template object that can be re-used |
324 // (i.e., "instanced") in the SVG document via a 'use' element." | 266 // (i.e., "instanced") in the SVG document via a 'use' element." |
325 // "Graphics Element" is defined as 'circle', 'ellipse', 'image', 'line', 'p
ath', 'polygon', 'polyline', 'rect', 'text' | 267 // "Graphics Element" is defined as 'circle', 'ellipse', 'image', 'line', 'p
ath', 'polygon', 'polyline', 'rect', 'text' |
326 // Excluded are anything that is used by reference or that only make sense t
o appear once in a document. | 268 // Excluded are anything that is used by reference or that only make sense t
o appear once in a document. |
327 // We must also allow the shadow roots of other use elements. | 269 // We must also allow the shadow roots of other use elements. |
328 if (node->isShadowRoot() || node->isTextNode()) | 270 if (node->isShadowRoot() || node->isTextNode()) |
329 return false; | 271 return false; |
330 | 272 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 ASSERT(shadowTreeTargetElement->correspondingElement()); | 450 ASSERT(shadowTreeTargetElement->correspondingElement()); |
509 transferUseWidthAndHeightIfNeeded(*this, shadowTreeTargetElement, *shadowTre
eTargetElement->correspondingElement()); | 451 transferUseWidthAndHeightIfNeeded(*this, shadowTreeTargetElement, *shadowTre
eTargetElement->correspondingElement()); |
510 | 452 |
511 ASSERT(shadowTreeTargetElement->parentNode() == shadowTreeRootElement); | 453 ASSERT(shadowTreeTargetElement->parentNode() == shadowTreeRootElement); |
512 | 454 |
513 // Transfer event listeners assigned to the referenced element to our shadow
tree elements. | 455 // Transfer event listeners assigned to the referenced element to our shadow
tree elements. |
514 transferEventListenersToShadowTree(shadowTreeTargetElement); | 456 transferEventListenersToShadowTree(shadowTreeTargetElement); |
515 | 457 |
516 // Update relative length information. | 458 // Update relative length information. |
517 updateRelativeLengthsInformation(); | 459 updateRelativeLengthsInformation(); |
518 | |
519 // Eventually dump instance tree | |
520 #ifdef DUMP_INSTANCE_TREE | |
521 String text; | |
522 unsigned depth = 0; | |
523 | |
524 dumpInstanceTree(depth, text, m_targetElementInstance.get()); | |
525 fprintf(stderr, "\nDumping <use> instance tree:\n%s\n", text.latin1().data()
); | |
526 #endif | |
527 | |
528 // Eventually dump shadow tree | |
529 #ifdef DUMP_SHADOW_TREE | |
530 RefPtr<XMLSerializer> serializer = XMLSerializer::create(); | |
531 String markup = serializer->serializeToString(shadowTreeRootElement, ASSERT_
NO_EXCEPTION); | |
532 fprintf(stderr, "Dumping <use> shadow tree markup:\n%s\n", markup.latin1().d
ata()); | |
533 #endif | |
534 } | 460 } |
535 | 461 |
536 RenderObject* SVGUseElement::createRenderer(RenderStyle*) | 462 RenderObject* SVGUseElement::createRenderer(RenderStyle*) |
537 { | 463 { |
538 return new RenderSVGTransformableContainer(this); | 464 return new RenderSVGTransformableContainer(this); |
539 } | 465 } |
540 | 466 |
541 static bool isDirectReference(const Node& node) | 467 static bool isDirectReference(const Node& node) |
542 { | 468 { |
543 return isSVGPathElement(node) | 469 return isSVGPathElement(node) |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 | 920 |
995 if (m_resource) | 921 if (m_resource) |
996 m_resource->removeClient(this); | 922 m_resource->removeClient(this); |
997 | 923 |
998 m_resource = resource; | 924 m_resource = resource; |
999 if (m_resource) | 925 if (m_resource) |
1000 m_resource->addClient(this); | 926 m_resource->addClient(this); |
1001 } | 927 } |
1002 | 928 |
1003 } | 929 } |
OLD | NEW |