| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 addToPropertyMap(m_x); | 60 addToPropertyMap(m_x); |
| 61 addToPropertyMap(m_y); | 61 addToPropertyMap(m_y); |
| 62 addToPropertyMap(m_width); | 62 addToPropertyMap(m_width); |
| 63 addToPropertyMap(m_height); | 63 addToPropertyMap(m_height); |
| 64 } | 64 } |
| 65 | 65 |
| 66 PassRefPtrWillBeRawPtr<SVGUseElement> SVGUseElement::create(Document& document) | 66 PassRefPtrWillBeRawPtr<SVGUseElement> SVGUseElement::create(Document& document) |
| 67 { | 67 { |
| 68 // Always build a user agent #shadow-root for SVGUseElement. | 68 // Always build a user agent #shadow-root for SVGUseElement. |
| 69 RefPtrWillBeRawPtr<SVGUseElement> use = adoptRefWillBeNoop(new SVGUseElement
(document)); | 69 RefPtrWillBeRawPtr<SVGUseElement> use = adoptRefWillBeNoop(new SVGUseElement
(document)); |
| 70 use->ensureUserAgentShadowRoot(); | 70 use->ensureClosedShadowRoot(); |
| 71 return use.release(); | 71 return use.release(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 SVGUseElement::~SVGUseElement() | 74 SVGUseElement::~SVGUseElement() |
| 75 { | 75 { |
| 76 setDocumentResource(0); | 76 setDocumentResource(0); |
| 77 #if !ENABLE(OILPAN) | 77 #if !ENABLE(OILPAN) |
| 78 clearResourceReferences(); | 78 clearResourceReferences(); |
| 79 #endif | 79 #endif |
| 80 } | 80 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 m_needsShadowTreeRecreation = true; | 322 m_needsShadowTreeRecreation = true; |
| 323 document().scheduleUseShadowTreeUpdate(*this); | 323 document().scheduleUseShadowTreeUpdate(*this); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void SVGUseElement::clearResourceReferences() | 326 void SVGUseElement::clearResourceReferences() |
| 327 { | 327 { |
| 328 if (m_targetElementInstance) | 328 if (m_targetElementInstance) |
| 329 m_targetElementInstance = nullptr; | 329 m_targetElementInstance = nullptr; |
| 330 | 330 |
| 331 // FIXME: We should try to optimize this, to at least allow partial reclones
. | 331 // FIXME: We should try to optimize this, to at least allow partial reclones
. |
| 332 if (ShadowRoot* shadowTreeRootElement = userAgentShadowRoot()) | 332 if (ShadowRoot* shadowTreeRootElement = closedShadowRoot()) |
| 333 shadowTreeRootElement->removeChildren(OmitSubtreeModifiedEvent); | 333 shadowTreeRootElement->removeChildren(OmitSubtreeModifiedEvent); |
| 334 | 334 |
| 335 m_needsShadowTreeRecreation = false; | 335 m_needsShadowTreeRecreation = false; |
| 336 document().unscheduleUseShadowTreeUpdate(*this); | 336 document().unscheduleUseShadowTreeUpdate(*this); |
| 337 | 337 |
| 338 removeAllOutgoingReferences(); | 338 removeAllOutgoingReferences(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void SVGUseElement::buildPendingResource() | 341 void SVGUseElement::buildPendingResource() |
| 342 { | 342 { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 return; | 397 return; |
| 398 | 398 |
| 399 // Do not allow self-referencing. | 399 // Do not allow self-referencing. |
| 400 // 'target' may be null, if it's a non SVG namespaced element. | 400 // 'target' may be null, if it's a non SVG namespaced element. |
| 401 if (!target || target == this) | 401 if (!target || target == this) |
| 402 return; | 402 return; |
| 403 | 403 |
| 404 // Set up root SVG element in shadow tree. | 404 // Set up root SVG element in shadow tree. |
| 405 RefPtrWillBeRawPtr<Element> newChild = target->cloneElementWithoutChildren()
; | 405 RefPtrWillBeRawPtr<Element> newChild = target->cloneElementWithoutChildren()
; |
| 406 m_targetElementInstance = toSVGElement(newChild.get()); | 406 m_targetElementInstance = toSVGElement(newChild.get()); |
| 407 ShadowRoot* shadowTreeRootElement = userAgentShadowRoot(); | 407 ShadowRoot* shadowTreeRootElement = closedShadowRoot(); |
| 408 shadowTreeRootElement->appendChild(newChild.release()); | 408 shadowTreeRootElement->appendChild(newChild.release()); |
| 409 | 409 |
| 410 // Clone the target subtree into the shadow tree, not handling <use> and <sy
mbol> yet. | 410 // Clone the target subtree into the shadow tree, not handling <use> and <sy
mbol> yet. |
| 411 | 411 |
| 412 // SVG specification does not say a word about <use> & cycles. My view on th
is is: just ignore it! | 412 // SVG specification does not say a word about <use> & cycles. My view on th
is is: just ignore it! |
| 413 // Non-appearing <use> content is easier to debug, then half-appearing conte
nt. | 413 // Non-appearing <use> content is easier to debug, then half-appearing conte
nt. |
| 414 if (!buildShadowTree(target, m_targetElementInstance.get(), false)) { | 414 if (!buildShadowTree(target, m_targetElementInstance.get(), false)) { |
| 415 clearResourceReferences(); | 415 clearResourceReferences(); |
| 416 return; | 416 return; |
| 417 } | 417 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 || isSVGEllipseElement(element) | 457 || isSVGEllipseElement(element) |
| 458 || isSVGPolygonElement(element) | 458 || isSVGPolygonElement(element) |
| 459 || isSVGPolylineElement(element) | 459 || isSVGPolylineElement(element) |
| 460 || isSVGTextElement(element); | 460 || isSVGTextElement(element); |
| 461 } | 461 } |
| 462 | 462 |
| 463 void SVGUseElement::toClipPath(Path& path) | 463 void SVGUseElement::toClipPath(Path& path) |
| 464 { | 464 { |
| 465 ASSERT(path.isEmpty()); | 465 ASSERT(path.isEmpty()); |
| 466 | 466 |
| 467 Node* n = userAgentShadowRoot()->firstChild(); | 467 Node* n = closedShadowRoot()->firstChild(); |
| 468 if (!n || !n->isSVGElement()) | 468 if (!n || !n->isSVGElement()) |
| 469 return; | 469 return; |
| 470 SVGElement& element = toSVGElement(*n); | 470 SVGElement& element = toSVGElement(*n); |
| 471 | 471 |
| 472 if (element.isSVGGraphicsElement()) { | 472 if (element.isSVGGraphicsElement()) { |
| 473 if (!isDirectReference(element)) { | 473 if (!isDirectReference(element)) { |
| 474 // Spec: Indirect references are an error (14.3.5) | 474 // Spec: Indirect references are an error (14.3.5) |
| 475 document().accessSVGExtensions().reportError("Not allowed to use ind
irect reference in <clip-path>"); | 475 document().accessSVGExtensions().reportError("Not allowed to use ind
irect reference in <clip-path>"); |
| 476 } else { | 476 } else { |
| 477 toSVGGraphicsElement(element).toClipPath(path); | 477 toSVGGraphicsElement(element).toClipPath(path); |
| 478 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf
ul. | 478 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf
ul. |
| 479 SVGLengthContext lengthContext(this); | 479 SVGLengthContext lengthContext(this); |
| 480 path.translate(FloatSize(m_x->currentValue()->value(lengthContext),
m_y->currentValue()->value(lengthContext))); | 480 path.translate(FloatSize(m_x->currentValue()->value(lengthContext),
m_y->currentValue()->value(lengthContext))); |
| 481 path.transform(calculateAnimatedLocalTransform()); | 481 path.transform(calculateAnimatedLocalTransform()); |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 | 485 |
| 486 LayoutObject* SVGUseElement::rendererClipChild() const | 486 LayoutObject* SVGUseElement::rendererClipChild() const |
| 487 { | 487 { |
| 488 if (Node* n = userAgentShadowRoot()->firstChild()) { | 488 if (Node* n = closedShadowRoot()->firstChild()) { |
| 489 if (n->isSVGElement() && isDirectReference(toSVGElement(*n))) | 489 if (n->isSVGElement() && isDirectReference(toSVGElement(*n))) |
| 490 return n->renderer(); | 490 return n->renderer(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 return 0; | 493 return 0; |
| 494 } | 494 } |
| 495 | 495 |
| 496 bool SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstan
ce, bool foundUse) | 496 bool SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstan
ce, bool foundUse) |
| 497 { | 497 { |
| 498 ASSERT(target); | 498 ASSERT(target); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 | 787 |
| 788 if (m_resource) | 788 if (m_resource) |
| 789 m_resource->removeClient(this); | 789 m_resource->removeClient(this); |
| 790 | 790 |
| 791 m_resource = resource; | 791 m_resource = resource; |
| 792 if (m_resource) | 792 if (m_resource) |
| 793 m_resource->addClient(this); | 793 m_resource->addClient(this); |
| 794 } | 794 } |
| 795 | 795 |
| 796 } | 796 } |
| OLD | NEW |