| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 TreeScope* SVGUseElement::referencedScope() const | 140 TreeScope* SVGUseElement::referencedScope() const |
| 141 { | 141 { |
| 142 if (isStructurallyExternal()) | 142 if (isStructurallyExternal()) |
| 143 return externalDocument(); | 143 return externalDocument(); |
| 144 return &treeScope(); | 144 return &treeScope(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 Document* SVGUseElement::externalDocument() const | 147 Document* SVGUseElement::externalDocument() const |
| 148 { | 148 { |
| 149 if (m_resource && m_resource->isLoaded()) { | 149 // Gracefully handle error condition. |
| 150 // Gracefully handle error condition. | 150 if (!resourceIsValid()) |
| 151 if (m_resource->errorOccurred()) | 151 return nullptr; |
| 152 return nullptr; | 152 ASSERT(m_resource->document()); |
| 153 ASSERT(m_resource->document()); | 153 return m_resource->document(); |
| 154 return m_resource->document(); | |
| 155 } | |
| 156 return nullptr; | |
| 157 } | 154 } |
| 158 | 155 |
| 159 void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGElement* sha
dowElement, const SVGElement& originalElement) | 156 void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGElement* sha
dowElement, const SVGElement& originalElement) |
| 160 { | 157 { |
| 161 DEFINE_STATIC_LOCAL(const AtomicString, hundredPercentString, ("100%", Atomi
cString::ConstructFromLiteral)); | 158 DEFINE_STATIC_LOCAL(const AtomicString, hundredPercentString, ("100%", Atomi
cString::ConstructFromLiteral)); |
| 162 ASSERT(shadowElement); | 159 ASSERT(shadowElement); |
| 163 if (isSVGSymbolElement(*shadowElement)) { | 160 if (isSVGSymbolElement(*shadowElement)) { |
| 164 // Spec (<use> on <symbol>): This generated 'svg' will always have expli
cit values for attributes width and height. | 161 // Spec (<use> on <symbol>): This generated 'svg' will always have expli
cit values for attributes width and height. |
| 165 // If attributes width and/or height are provided on the 'use' element,
then these attributes | 162 // If attributes width and/or height are provided on the 'use' element,
then these attributes |
| 166 // will be transferred to the generated 'svg'. If attributes width and/o
r height are not specified, | 163 // will be transferred to the generated 'svg'. If attributes width and/o
r height are not specified, |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 779 |
| 783 void SVGUseElement::dispatchPendingEvent(SVGUseEventSender* eventSender) | 780 void SVGUseElement::dispatchPendingEvent(SVGUseEventSender* eventSender) |
| 784 { | 781 { |
| 785 ASSERT_UNUSED(eventSender, eventSender == &svgUseLoadEventSender()); | 782 ASSERT_UNUSED(eventSender, eventSender == &svgUseLoadEventSender()); |
| 786 ASSERT(isStructurallyExternal() && m_haveFiredLoadEvent); | 783 ASSERT(isStructurallyExternal() && m_haveFiredLoadEvent); |
| 787 dispatchEvent(Event::create(EventTypeNames::load)); | 784 dispatchEvent(Event::create(EventTypeNames::load)); |
| 788 } | 785 } |
| 789 | 786 |
| 790 void SVGUseElement::notifyFinished(Resource* resource) | 787 void SVGUseElement::notifyFinished(Resource* resource) |
| 791 { | 788 { |
| 789 ASSERT(m_resource == resource); |
| 792 if (!inDocument()) | 790 if (!inDocument()) |
| 793 return; | 791 return; |
| 794 | 792 |
| 795 invalidateShadowTree(); | 793 invalidateShadowTree(); |
| 796 if (resource->errorOccurred()) { | 794 if (!resourceIsValid()) { |
| 797 dispatchEvent(Event::create(EventTypeNames::error)); | 795 dispatchEvent(Event::create(EventTypeNames::error)); |
| 798 } else if (!resource->wasCanceled()) { | 796 } else if (!resource->wasCanceled()) { |
| 799 if (m_haveFiredLoadEvent) | 797 if (m_haveFiredLoadEvent) |
| 800 return; | 798 return; |
| 801 if (!isStructurallyExternal()) | 799 if (!isStructurallyExternal()) |
| 802 return; | 800 return; |
| 803 ASSERT(!m_haveFiredLoadEvent); | 801 ASSERT(!m_haveFiredLoadEvent); |
| 804 m_haveFiredLoadEvent = true; | 802 m_haveFiredLoadEvent = true; |
| 805 svgUseLoadEventSender().dispatchEventSoon(this); | 803 svgUseLoadEventSender().dispatchEventSoon(this); |
| 806 } | 804 } |
| 807 } | 805 } |
| 808 | 806 |
| 809 bool SVGUseElement::resourceIsStillLoading() const | 807 bool SVGUseElement::resourceIsStillLoading() const |
| 810 { | 808 { |
| 811 return m_resource && m_resource->isLoading(); | 809 return m_resource && m_resource->isLoading(); |
| 812 } | 810 } |
| 813 | 811 |
| 812 bool SVGUseElement::resourceIsValid() const |
| 813 { |
| 814 return m_resource |
| 815 && m_resource->isLoaded() |
| 816 && !m_resource->errorOccurred() |
| 817 && m_resource->document(); |
| 818 } |
| 819 |
| 814 bool SVGUseElement::instanceTreeIsLoading(const SVGElement* targetInstance) | 820 bool SVGUseElement::instanceTreeIsLoading(const SVGElement* targetInstance) |
| 815 { | 821 { |
| 816 for (const SVGElement* element = targetInstance; element; element = Traversa
l<SVGElement>::next(*element, targetInstance)) { | 822 for (const SVGElement* element = targetInstance; element; element = Traversa
l<SVGElement>::next(*element, targetInstance)) { |
| 817 if (isSVGUseElement(*element) && toSVGUseElement(*element).resourceIsSti
llLoading()) | 823 if (isSVGUseElement(*element) && toSVGUseElement(*element).resourceIsSti
llLoading()) |
| 818 return true; | 824 return true; |
| 819 } | 825 } |
| 820 return false; | 826 return false; |
| 821 } | 827 } |
| 822 | 828 |
| 823 void SVGUseElement::setDocumentResource(PassRefPtrWillBeRawPtr<DocumentResource>
resource) | 829 void SVGUseElement::setDocumentResource(PassRefPtrWillBeRawPtr<DocumentResource>
resource) |
| 824 { | 830 { |
| 825 if (m_resource == resource) | 831 if (m_resource == resource) |
| 826 return; | 832 return; |
| 827 | 833 |
| 828 if (m_resource) | 834 if (m_resource) |
| 829 m_resource->removeClient(this); | 835 m_resource->removeClient(this); |
| 830 | 836 |
| 831 m_resource = resource; | 837 m_resource = resource; |
| 832 if (m_resource) | 838 if (m_resource) |
| 833 m_resource->addClient(this); | 839 m_resource->addClient(this); |
| 834 } | 840 } |
| 835 | 841 |
| 836 } // namespace blink | 842 } // namespace blink |
| OLD | NEW |