| 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 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 ++depth; | 415 ++depth; |
| 416 | 416 |
| 417 for (SVGElementInstance* instance = targetInstance->firstChild(); instance;
instance = instance->nextSibling()) | 417 for (SVGElementInstance* instance = targetInstance->firstChild(); instance;
instance = instance->nextSibling()) |
| 418 dumpInstanceTree(depth, text, instance); | 418 dumpInstanceTree(depth, text, instance); |
| 419 | 419 |
| 420 --depth; | 420 --depth; |
| 421 } | 421 } |
| 422 #endif | 422 #endif |
| 423 | 423 |
| 424 static bool isDisallowedElement(Node* element) | 424 static bool isDisallowedElement(Node* node) |
| 425 { | 425 { |
| 426 // <foreignObject> should never be contained in a <use> tree. Too dangerous
side effects possible. | 426 // Spec: "Any 'svg', 'symbol', 'g', graphics element or other 'use' is poten
tially a template object that can be re-used |
| 427 if (element->hasTagName(SVGNames::foreignObjectTag)) | 427 // (i.e., "instanced") in the SVG document via a 'use' element." |
| 428 // "Graphics Element" is defined as 'circle', 'ellipse', 'image', 'line', 'p
ath', 'polygon', 'polyline', 'rect', 'text' |
| 429 // Excluded are anything that is used by reference or that only make sense t
o appear once in a document. |
| 430 // We must also allow the shadow roots of other use elements and text. |
| 431 if (node->isTextNode()) |
| 432 return false; |
| 433 |
| 434 if (!node->isSVGElement()) |
| 428 return true; | 435 return true; |
| 429 if (SVGSMILElement::isSMILElement(element)) | 436 |
| 430 return true; | 437 SVGElement* element = static_cast<SVGElement*>(node); |
| 431 return false; | 438 |
| 439 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, allowedElementTags, ()); |
| 440 if (allowedElementTags.isEmpty()) { |
| 441 allowedElementTags.add(SVGNames::aTag); |
| 442 allowedElementTags.add(SVGNames::circleTag); |
| 443 allowedElementTags.add(SVGNames::defsTag); |
| 444 allowedElementTags.add(SVGNames::descTag); |
| 445 allowedElementTags.add(SVGNames::ellipseTag); |
| 446 allowedElementTags.add(SVGNames::gTag); |
| 447 allowedElementTags.add(SVGNames::imageTag); |
| 448 allowedElementTags.add(SVGNames::lineTag); |
| 449 allowedElementTags.add(SVGNames::metadataTag); |
| 450 allowedElementTags.add(SVGNames::pathTag); |
| 451 allowedElementTags.add(SVGNames::polygonTag); |
| 452 allowedElementTags.add(SVGNames::polylineTag); |
| 453 allowedElementTags.add(SVGNames::rectTag); |
| 454 allowedElementTags.add(SVGNames::svgTag); |
| 455 allowedElementTags.add(SVGNames::switchTag); |
| 456 allowedElementTags.add(SVGNames::symbolTag); |
| 457 allowedElementTags.add(SVGNames::textTag); |
| 458 allowedElementTags.add(SVGNames::textPathTag); |
| 459 allowedElementTags.add(SVGNames::titleTag); |
| 460 allowedElementTags.add(SVGNames::trefTag); |
| 461 allowedElementTags.add(SVGNames::tspanTag); |
| 462 allowedElementTags.add(SVGNames::useTag); |
| 463 } |
| 464 return !allowedElementTags.contains<QualifiedName, SVGAttributeHashTranslato
r>(element->tagQName()); |
| 432 } | 465 } |
| 433 | 466 |
| 434 static bool subtreeContainsDisallowedElement(Node* start) | 467 static bool subtreeContainsDisallowedElement(Node* start) |
| 435 { | 468 { |
| 436 if (isDisallowedElement(start)) | 469 if (isDisallowedElement(start)) |
| 437 return true; | 470 return true; |
| 438 | 471 |
| 439 for (Node* cur = start->firstChild(); cur; cur = cur->nextSibling()) { | 472 for (Node* cur = start->firstChild(); cur; cur = cur->nextSibling()) { |
| 440 if (subtreeContainsDisallowedElement(cur)) | 473 if (subtreeContainsDisallowedElement(cur)) |
| 441 return true; | 474 return true; |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 SVGElement* element = m_targetElementInstance->correspondingElement(); | 1080 SVGElement* element = m_targetElementInstance->correspondingElement(); |
| 1048 if (!element || !element->isStyled()) | 1081 if (!element || !element->isStyled()) |
| 1049 return false; | 1082 return false; |
| 1050 | 1083 |
| 1051 return static_cast<SVGStyledElement*>(element)->hasRelativeLengths(); | 1084 return static_cast<SVGStyledElement*>(element)->hasRelativeLengths(); |
| 1052 } | 1085 } |
| 1053 | 1086 |
| 1054 } | 1087 } |
| 1055 | 1088 |
| 1056 #endif // ENABLE(SVG) | 1089 #endif // ENABLE(SVG) |
| OLD | NEW |