| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Torch Mobile, Inc. | 3 * Copyright (C) 2009 Torch Mobile, Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "core/fetch/ResourceClientWalker.h" | 30 #include "core/fetch/ResourceClientWalker.h" |
| 31 #include "core/html/parser/TextResourceDecoder.h" | 31 #include "core/html/parser/TextResourceDecoder.h" |
| 32 #include "platform/SharedBuffer.h" | 32 #include "platform/SharedBuffer.h" |
| 33 #include "platform/fonts/FontCustomPlatformData.h" | 33 #include "platform/fonts/FontCustomPlatformData.h" |
| 34 #include "platform/fonts/FontPlatformData.h" | 34 #include "platform/fonts/FontPlatformData.h" |
| 35 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
| 36 #include "wtf/CurrentTime.h" | 36 #include "wtf/CurrentTime.h" |
| 37 | 37 |
| 38 #if ENABLE(SVG_FONTS) | 38 #if ENABLE(SVG_FONTS) |
| 39 #include "SVGNames.h" | 39 #include "SVGNames.h" |
| 40 #include "core/dom/NodeList.h" | 40 #include "core/html/HTMLCollection.h" |
| 41 #include "core/svg/SVGDocument.h" | 41 #include "core/svg/SVGDocument.h" |
| 42 #include "core/svg/SVGFontElement.h" | 42 #include "core/svg/SVGFontElement.h" |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 namespace WebCore { | 45 namespace WebCore { |
| 46 | 46 |
| 47 FontResource::FontResource(const ResourceRequest& resourceRequest) | 47 FontResource::FontResource(const ResourceRequest& resourceRequest) |
| 48 : Resource(resourceRequest, Font) | 48 : Resource(resourceRequest, Font) |
| 49 , m_loadInitiated(false) | 49 , m_loadInitiated(false) |
| 50 { | 50 { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 if (!m_externalSVGDocument) | 121 if (!m_externalSVGDocument) |
| 122 setStatus(DecodeError); | 122 setStatus(DecodeError); |
| 123 } | 123 } |
| 124 | 124 |
| 125 return m_externalSVGDocument; | 125 return m_externalSVGDocument; |
| 126 } | 126 } |
| 127 | 127 |
| 128 SVGFontElement* FontResource::getSVGFontById(const String& fontName) const | 128 SVGFontElement* FontResource::getSVGFontById(const String& fontName) const |
| 129 { | 129 { |
| 130 RefPtr<NodeList> list = m_externalSVGDocument->getElementsByTagNameNS(SVGNam
es::fontTag.namespaceURI(), SVGNames::fontTag.localName()); | 130 RefPtr<HTMLCollection> collection = m_externalSVGDocument->getElementsByTagN
ameNS(SVGNames::fontTag.namespaceURI(), SVGNames::fontTag.localName()); |
| 131 if (!list) | 131 if (!collection) |
| 132 return 0; | 132 return 0; |
| 133 | 133 |
| 134 unsigned listLength = list->length(); | 134 unsigned collectionLength = collection->length(); |
| 135 if (!listLength) | 135 if (!collectionLength) |
| 136 return 0; | 136 return 0; |
| 137 | 137 |
| 138 #ifndef NDEBUG | 138 #ifndef NDEBUG |
| 139 for (unsigned i = 0; i < listLength; ++i) { | 139 for (unsigned i = 0; i < collectionLength; ++i) { |
| 140 ASSERT(list->item(i)); | 140 ASSERT(collection->item(i)); |
| 141 ASSERT(list->item(i)->hasTagName(SVGNames::fontTag)); | 141 ASSERT(collection->item(i)->hasTagName(SVGNames::fontTag)); |
| 142 } | 142 } |
| 143 #endif | 143 #endif |
| 144 | 144 |
| 145 if (fontName.isEmpty()) | 145 if (fontName.isEmpty()) |
| 146 return toSVGFontElement(list->item(0)); | 146 return toSVGFontElement(collection->item(0)); |
| 147 | 147 |
| 148 for (unsigned i = 0; i < listLength; ++i) { | 148 for (unsigned i = 0; i < collectionLength; ++i) { |
| 149 SVGFontElement* element = toSVGFontElement(list->item(i)); | 149 SVGFontElement* element = toSVGFontElement(collection->item(i)); |
| 150 if (element->getIdAttribute() == fontName) | 150 if (element->getIdAttribute() == fontName) |
| 151 return element; | 151 return element; |
| 152 } | 152 } |
| 153 | 153 |
| 154 return 0; | 154 return 0; |
| 155 } | 155 } |
| 156 #endif | 156 #endif |
| 157 | 157 |
| 158 void FontResource::allClientsRemoved() | 158 void FontResource::allClientsRemoved() |
| 159 { | 159 { |
| 160 m_fontData.clear(); | 160 m_fontData.clear(); |
| 161 Resource::allClientsRemoved(); | 161 Resource::allClientsRemoved(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void FontResource::checkNotify() | 164 void FontResource::checkNotify() |
| 165 { | 165 { |
| 166 ResourceClientWalker<FontResourceClient> w(m_clients); | 166 ResourceClientWalker<FontResourceClient> w(m_clients); |
| 167 while (FontResourceClient* c = w.next()) | 167 while (FontResourceClient* c = w.next()) |
| 168 c->fontLoaded(this); | 168 c->fontLoaded(this); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } | 171 } |
| OLD | NEW |