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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 static PassRefPtrWillBeRawPtr<Node> cloneNodeAndAssociate(Node& toClone) | 371 static PassRefPtrWillBeRawPtr<Node> cloneNodeAndAssociate(Node& toClone) |
372 { | 372 { |
373 RefPtrWillBeRawPtr<Node> clone = toClone.cloneNode(false); | 373 RefPtrWillBeRawPtr<Node> clone = toClone.cloneNode(false); |
374 if (!clone->isSVGElement()) | 374 if (!clone->isSVGElement()) |
375 return clone.release(); | 375 return clone.release(); |
376 | 376 |
377 SVGElement& svgElement = toSVGElement(toClone); | 377 SVGElement& svgElement = toSVGElement(toClone); |
378 ASSERT(!svgElement.correspondingElement()); | 378 ASSERT(!svgElement.correspondingElement()); |
379 toSVGElement(clone.get())->setCorrespondingElement(&svgElement); | 379 toSVGElement(clone.get())->setCorrespondingElement(&svgElement); |
380 if (EventTargetData* data = toClone.eventTargetData()) | |
381 data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(cl
one.get()); | |
382 TrackExceptionState exceptionState; | 380 TrackExceptionState exceptionState; |
383 for (RefPtrWillBeRawPtr<Node> node = toClone.firstChild(); node && !exceptio
nState.hadException(); node = node->nextSibling()) | 381 for (RefPtrWillBeRawPtr<Node> node = toClone.firstChild(); node && !exceptio
nState.hadException(); node = node->nextSibling()) |
384 clone->appendChild(cloneNodeAndAssociate(*node), exceptionState); | 382 clone->appendChild(cloneNodeAndAssociate(*node), exceptionState); |
385 return clone.release(); | 383 return clone.release(); |
386 } | 384 } |
387 | 385 |
388 void SVGUseElement::buildShadowAndInstanceTree(SVGElement* target) | 386 void SVGUseElement::buildShadowAndInstanceTree(SVGElement* target) |
389 { | 387 { |
390 ASSERT(!m_targetElementInstance); | 388 ASSERT(!m_targetElementInstance); |
391 ASSERT(!m_needsShadowTreeRecreation); | 389 ASSERT(!m_needsShadowTreeRecreation); |
(...skipping 14 matching lines...) Expand all Loading... |
406 m_targetElementInstance = toSVGElement(newChild.get()); | 404 m_targetElementInstance = toSVGElement(newChild.get()); |
407 ShadowRoot* shadowTreeRootElement = userAgentShadowRoot(); | 405 ShadowRoot* shadowTreeRootElement = userAgentShadowRoot(); |
408 shadowTreeRootElement->appendChild(newChild.release()); | 406 shadowTreeRootElement->appendChild(newChild.release()); |
409 | 407 |
410 // Clone the target subtree into the shadow tree, not handling <use> and <sy
mbol> yet. | 408 // Clone the target subtree into the shadow tree, not handling <use> and <sy
mbol> yet. |
411 | 409 |
412 // SVG specification does not say a word about <use> & cycles. My view on th
is is: just ignore it! | 410 // 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. | 411 // Non-appearing <use> content is easier to debug, then half-appearing conte
nt. |
414 buildShadowTree(target, m_targetElementInstance.get(), false); | 412 buildShadowTree(target, m_targetElementInstance.get(), false); |
415 | 413 |
416 if (instanceTreeIsLoading(m_targetElementInstance.get())) | 414 if (instanceTreeIsLoading(m_targetElementInstance.get())) { |
| 415 cloneNonMarkupEventListeners(); |
417 return; | 416 return; |
| 417 } |
418 | 418 |
419 // Assure shadow tree building was successful. | 419 // Assure shadow tree building was successful. |
420 ASSERT(m_targetElementInstance); | 420 ASSERT(m_targetElementInstance); |
421 ASSERT(m_targetElementInstance->correspondingUseElement() == this); | 421 ASSERT(m_targetElementInstance->correspondingUseElement() == this); |
422 ASSERT(m_targetElementInstance->correspondingElement() == target); | 422 ASSERT(m_targetElementInstance->correspondingElement() == target); |
423 | 423 |
424 // Expand all <use> elements in the shadow tree. | 424 // Expand all <use> elements in the shadow tree. |
425 // Expand means: replace the actual <use> element by what it references. | 425 // Expand means: replace the actual <use> element by what it references. |
426 if (!expandUseElementsInShadowTree(m_targetElementInstance.get())) { | 426 if (!expandUseElementsInShadowTree(m_targetElementInstance.get())) { |
427 clearShadowTree(); | 427 clearShadowTree(); |
428 return; | 428 return; |
429 } | 429 } |
430 | 430 |
431 // Expand all <symbol> elements in the shadow tree. | 431 // Expand all <symbol> elements in the shadow tree. |
432 // Expand means: replace the actual <symbol> element by the <svg> element. | 432 // Expand means: replace the actual <symbol> element by the <svg> element. |
433 expandSymbolElementsInShadowTree(toSVGElement(shadowTreeRootElement->firstCh
ild())); | 433 expandSymbolElementsInShadowTree(toSVGElement(shadowTreeRootElement->firstCh
ild())); |
434 | 434 |
435 m_targetElementInstance = toSVGElement(shadowTreeRootElement->firstChild()); | 435 m_targetElementInstance = toSVGElement(shadowTreeRootElement->firstChild()); |
436 transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance.get(), *m_t
argetElementInstance->correspondingElement()); | 436 transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance.get(), *m_t
argetElementInstance->correspondingElement()); |
| 437 cloneNonMarkupEventListeners(); |
437 | 438 |
438 ASSERT(m_targetElementInstance->parentNode() == shadowTreeRootElement); | 439 ASSERT(m_targetElementInstance->parentNode() == shadowTreeRootElement); |
439 | 440 |
440 // Update relative length information. | 441 // Update relative length information. |
441 updateRelativeLengthsInformation(); | 442 updateRelativeLengthsInformation(); |
442 } | 443 } |
443 | 444 |
444 LayoutObject* SVGUseElement::createLayoutObject(const ComputedStyle&) | 445 LayoutObject* SVGUseElement::createLayoutObject(const ComputedStyle&) |
445 { | 446 { |
446 return new LayoutSVGTransformableContainer(this); | 447 return new LayoutSVGTransformableContainer(this); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 if (isSVGUseElement(*target)) { | 511 if (isSVGUseElement(*target)) { |
511 // We only need to track first degree <use> dependencies. Indirect refer
ences are handled | 512 // We only need to track first degree <use> dependencies. Indirect refer
ences are handled |
512 // as the invalidation bubbles up the dependency chain. | 513 // as the invalidation bubbles up the dependency chain. |
513 if (!foundUse && !isStructurallyExternal()) { | 514 if (!foundUse && !isStructurallyExternal()) { |
514 addReferenceTo(target); | 515 addReferenceTo(target); |
515 foundUse = true; | 516 foundUse = true; |
516 } | 517 } |
517 } | 518 } |
518 | 519 |
519 targetInstance->setCorrespondingElement(target); | 520 targetInstance->setCorrespondingElement(target); |
520 if (EventTargetData* data = target->eventTargetData()) | |
521 data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(ta
rgetInstance); | |
522 | 521 |
523 for (RefPtrWillBeRawPtr<Node> child = target->firstChild(); child; child = c
hild->nextSibling()) { | 522 for (RefPtrWillBeRawPtr<Node> child = target->firstChild(); child; child = c
hild->nextSibling()) { |
524 // Skip any disallowed element. | 523 // Skip any disallowed element. |
525 if (isDisallowedElement(child.get())) | 524 if (isDisallowedElement(child.get())) |
526 continue; | 525 continue; |
527 | 526 |
528 RefPtrWillBeRawPtr<Node> newChild = child->cloneNode(false); | 527 RefPtrWillBeRawPtr<Node> newChild = child->cloneNode(false); |
529 targetInstance->appendChild(newChild.get()); | 528 targetInstance->appendChild(newChild.get()); |
530 if (newChild->isSVGElement()) { | 529 if (newChild->isSVGElement()) { |
531 // Enter recursion, appending new instance tree nodes to the "instan
ce" object. | 530 // Enter recursion, appending new instance tree nodes to the "instan
ce" object. |
532 buildShadowTree(toSVGElement(child), toSVGElement(newChild), foundUs
e); | 531 buildShadowTree(toSVGElement(child), toSVGElement(newChild), foundUs
e); |
533 } | 532 } |
534 } | 533 } |
535 } | 534 } |
536 | 535 |
| 536 void SVGUseElement::cloneNonMarkupEventListeners() |
| 537 { |
| 538 for (SVGElement& element : Traversal<SVGElement>::descendantsOf(*userAgentSh
adowRoot())) { |
| 539 if (EventTargetData* data = element.correspondingElement()->eventTargetD
ata()) |
| 540 data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarge
t(&element); |
| 541 } |
| 542 } |
| 543 |
537 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, ContainerNode* ta
rgetInstance, SVGElement*& newTarget) | 544 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, ContainerNode* ta
rgetInstance, SVGElement*& newTarget) |
538 { | 545 { |
539 ASSERT(referencedScope()); | 546 ASSERT(referencedScope()); |
540 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr
efString(), *referencedScope()); | 547 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr
efString(), *referencedScope()); |
541 newTarget = 0; | 548 newTarget = 0; |
542 if (targetElement && targetElement->isSVGElement()) | 549 if (targetElement && targetElement->isSVGElement()) |
543 newTarget = toSVGElement(targetElement); | 550 newTarget = toSVGElement(targetElement); |
544 | 551 |
545 if (!newTarget) | 552 if (!newTarget) |
546 return false; | 553 return false; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 | 836 |
830 if (m_resource) | 837 if (m_resource) |
831 m_resource->removeClient(this); | 838 m_resource->removeClient(this); |
832 | 839 |
833 m_resource = resource; | 840 m_resource = resource; |
834 if (m_resource) | 841 if (m_resource) |
835 m_resource->addClient(this); | 842 m_resource->addClient(this); |
836 } | 843 } |
837 | 844 |
838 } // namespace blink | 845 } // namespace blink |
OLD | NEW |