| 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 12 matching lines...) Expand all Loading... |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "core/svg/SVGUseElement.h" | 25 #include "core/svg/SVGUseElement.h" |
| 26 | 26 |
| 27 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 27 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 28 #include "core/SVGNames.h" | 28 #include "core/SVGNames.h" |
| 29 #include "core/XLinkNames.h" | 29 #include "core/XLinkNames.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/dom/ElementTraversal.h" | 31 #include "core/dom/ElementTraversal.h" |
| 32 #include "core/dom/StyleChangeReason.h" | 32 #include "core/dom/StyleChangeReason.h" |
| 33 #include "core/dom/TaskRunnerHelper.h" |
| 33 #include "core/dom/shadow/ElementShadow.h" | 34 #include "core/dom/shadow/ElementShadow.h" |
| 34 #include "core/dom/shadow/ShadowRoot.h" | 35 #include "core/dom/shadow/ShadowRoot.h" |
| 35 #include "core/events/Event.h" | 36 #include "core/events/Event.h" |
| 36 #include "core/fetch/FetchRequest.h" | 37 #include "core/fetch/FetchRequest.h" |
| 37 #include "core/fetch/ResourceFetcher.h" | 38 #include "core/fetch/ResourceFetcher.h" |
| 38 #include "core/layout/svg/LayoutSVGTransformableContainer.h" | 39 #include "core/layout/svg/LayoutSVGTransformableContainer.h" |
| 39 #include "core/svg/SVGDocumentExtensions.h" | 40 #include "core/svg/SVGDocumentExtensions.h" |
| 40 #include "core/svg/SVGGElement.h" | 41 #include "core/svg/SVGGElement.h" |
| 41 #include "core/svg/SVGLengthContext.h" | 42 #include "core/svg/SVGLengthContext.h" |
| 42 #include "core/svg/SVGSVGElement.h" | 43 #include "core/svg/SVGSVGElement.h" |
| 43 #include "core/svg/SVGSymbolElement.h" | 44 #include "core/svg/SVGSymbolElement.h" |
| 44 #include "core/xml/parser/XMLDocumentParser.h" | 45 #include "core/xml/parser/XMLDocumentParser.h" |
| 45 #include "wtf/Vector.h" | 46 #include "wtf/Vector.h" |
| 46 | 47 |
| 47 namespace blink { | 48 namespace blink { |
| 48 | 49 |
| 49 static SVGUseEventSender& svgUseLoadEventSender() { | |
| 50 DEFINE_STATIC_LOCAL(SVGUseEventSender, sharedLoadEventSender, | |
| 51 (SVGUseEventSender::create(EventTypeNames::load))); | |
| 52 return sharedLoadEventSender; | |
| 53 } | |
| 54 | |
| 55 inline SVGUseElement::SVGUseElement(Document& document) | 50 inline SVGUseElement::SVGUseElement(Document& document) |
| 56 : SVGGraphicsElement(SVGNames::useTag, document), | 51 : SVGGraphicsElement(SVGNames::useTag, document), |
| 57 SVGURIReference(this), | 52 SVGURIReference(this), |
| 58 m_x(SVGAnimatedLength::create(this, | 53 m_x(SVGAnimatedLength::create(this, |
| 59 SVGNames::xAttr, | 54 SVGNames::xAttr, |
| 60 SVGLength::create(SVGLengthMode::Width))), | 55 SVGLength::create(SVGLengthMode::Width))), |
| 61 m_y(SVGAnimatedLength::create(this, | 56 m_y(SVGAnimatedLength::create(this, |
| 62 SVGNames::yAttr, | 57 SVGNames::yAttr, |
| 63 SVGLength::create(SVGLengthMode::Height))), | 58 SVGLength::create(SVGLengthMode::Height))), |
| 64 m_width( | 59 m_width( |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 // don't need to override SVGGraphicsElement::getBBox at all) and be | 677 // don't need to override SVGGraphicsElement::getBBox at all) and be |
| 683 // correct without additional work. That will not work out ATM without | 678 // correct without additional work. That will not work out ATM without |
| 684 // additional quirks. The problem stems from including the additional | 679 // additional quirks. The problem stems from including the additional |
| 685 // translation directly on the LayoutObject corresponding to the | 680 // translation directly on the LayoutObject corresponding to the |
| 686 // SVGUseElement. | 681 // SVGUseElement. |
| 687 FloatRect bbox = transformableContainer.objectBoundingBox(); | 682 FloatRect bbox = transformableContainer.objectBoundingBox(); |
| 688 bbox.move(transformableContainer.additionalTranslation()); | 683 bbox.move(transformableContainer.additionalTranslation()); |
| 689 return bbox; | 684 return bbox; |
| 690 } | 685 } |
| 691 | 686 |
| 692 void SVGUseElement::dispatchPendingEvent(SVGUseEventSender* eventSender) { | 687 void SVGUseElement::dispatchPendingEvent() { |
| 693 ASSERT_UNUSED(eventSender, eventSender == &svgUseLoadEventSender()); | |
| 694 ASSERT(isStructurallyExternal() && m_haveFiredLoadEvent); | 688 ASSERT(isStructurallyExternal() && m_haveFiredLoadEvent); |
| 695 dispatchEvent(Event::create(EventTypeNames::load)); | 689 dispatchEvent(Event::create(EventTypeNames::load)); |
| 696 } | 690 } |
| 697 | 691 |
| 698 void SVGUseElement::notifyFinished(Resource* resource) { | 692 void SVGUseElement::notifyFinished(Resource* resource) { |
| 699 ASSERT(m_resource == resource); | 693 ASSERT(m_resource == resource); |
| 700 if (!isConnected()) | 694 if (!isConnected()) |
| 701 return; | 695 return; |
| 702 | 696 |
| 703 invalidateShadowTree(); | 697 invalidateShadowTree(); |
| 704 if (!resourceIsValid()) { | 698 if (!resourceIsValid()) { |
| 705 dispatchEvent(Event::create(EventTypeNames::error)); | 699 dispatchEvent(Event::create(EventTypeNames::error)); |
| 706 } else if (!resource->wasCanceled()) { | 700 } else if (!resource->wasCanceled()) { |
| 707 if (m_haveFiredLoadEvent) | 701 if (m_haveFiredLoadEvent) |
| 708 return; | 702 return; |
| 709 if (!isStructurallyExternal()) | 703 if (!isStructurallyExternal()) |
| 710 return; | 704 return; |
| 711 ASSERT(!m_haveFiredLoadEvent); | 705 ASSERT(!m_haveFiredLoadEvent); |
| 712 m_haveFiredLoadEvent = true; | 706 m_haveFiredLoadEvent = true; |
| 713 svgUseLoadEventSender().dispatchEventSoon(this); | 707 TaskRunnerHelper::get(TaskType::DOMManipulation, &document()) |
| 708 ->postTask(BLINK_FROM_HERE, |
| 709 WTF::bind(&SVGUseElement::dispatchPendingEvent, |
| 710 wrapPersistent(this))); |
| 714 } | 711 } |
| 715 } | 712 } |
| 716 | 713 |
| 717 bool SVGUseElement::resourceIsStillLoading() const { | 714 bool SVGUseElement::resourceIsStillLoading() const { |
| 718 return m_resource && m_resource->isLoading(); | 715 return m_resource && m_resource->isLoading(); |
| 719 } | 716 } |
| 720 | 717 |
| 721 bool SVGUseElement::resourceIsValid() const { | 718 bool SVGUseElement::resourceIsValid() const { |
| 722 return m_resource && m_resource->isLoaded() && !m_resource->errorOccurred() && | 719 return m_resource && m_resource->isLoaded() && !m_resource->errorOccurred() && |
| 723 m_resource->document(); | 720 m_resource->document(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 738 | 735 |
| 739 if (m_resource) | 736 if (m_resource) |
| 740 m_resource->removeClient(this); | 737 m_resource->removeClient(this); |
| 741 | 738 |
| 742 m_resource = resource; | 739 m_resource = resource; |
| 743 if (m_resource) | 740 if (m_resource) |
| 744 m_resource->addClient(this); | 741 m_resource->addClient(this); |
| 745 } | 742 } |
| 746 | 743 |
| 747 } // namespace blink | 744 } // namespace blink |
| OLD | NEW |