OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 6 Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return toCSSStyleSheetResource(fetcher->requestResource(request, CSSStyleShe
etResourceFactory())); | 44 return toCSSStyleSheetResource(fetcher->requestResource(request, CSSStyleShe
etResourceFactory())); |
45 } | 45 } |
46 | 46 |
47 CSSStyleSheetResource* CSSStyleSheetResource::createForTest(const ResourceReques
t& request, const String& charset) | 47 CSSStyleSheetResource* CSSStyleSheetResource::createForTest(const ResourceReques
t& request, const String& charset) |
48 { | 48 { |
49 return new CSSStyleSheetResource(request, ResourceLoaderOptions(), charset); | 49 return new CSSStyleSheetResource(request, ResourceLoaderOptions(), charset); |
50 } | 50 } |
51 | 51 |
52 CSSStyleSheetResource::CSSStyleSheetResource(const ResourceRequest& resourceRequ
est, const ResourceLoaderOptions& options, const String& charset) | 52 CSSStyleSheetResource::CSSStyleSheetResource(const ResourceRequest& resourceRequ
est, const ResourceLoaderOptions& options, const String& charset) |
53 : StyleSheetResource(resourceRequest, CSSStyleSheet, options, "text/css", ch
arset) | 53 : StyleSheetResource(resourceRequest, CSSStyleSheet, options, "text/css", ch
arset) |
| 54 , m_didNotifyFirstData(false) |
54 { | 55 { |
55 } | 56 } |
56 | 57 |
57 CSSStyleSheetResource::~CSSStyleSheetResource() | 58 CSSStyleSheetResource::~CSSStyleSheetResource() |
58 { | 59 { |
59 } | 60 } |
60 | 61 |
61 void CSSStyleSheetResource::removedFromMemoryCache() | 62 void CSSStyleSheetResource::removedFromMemoryCache() |
62 { | 63 { |
63 if (m_parsedStyleSheetCache) | 64 if (m_parsedStyleSheetCache) |
(...skipping 27 matching lines...) Expand all Loading... |
91 if (!m_data || m_data->isEmpty() || !canUseSheet(mimeTypeCheck)) | 92 if (!m_data || m_data->isEmpty() || !canUseSheet(mimeTypeCheck)) |
92 return String(); | 93 return String(); |
93 | 94 |
94 if (!m_decodedSheetText.isNull()) | 95 if (!m_decodedSheetText.isNull()) |
95 return m_decodedSheetText; | 96 return m_decodedSheetText; |
96 | 97 |
97 // Don't cache the decoded text, regenerating is cheap and it can use quite
a bit of memory | 98 // Don't cache the decoded text, regenerating is cheap and it can use quite
a bit of memory |
98 return decodedText(); | 99 return decodedText(); |
99 } | 100 } |
100 | 101 |
| 102 void CSSStyleSheetResource::appendData(const char* data, size_t length) |
| 103 { |
| 104 Resource::appendData(data, length); |
| 105 if (m_didNotifyFirstData) |
| 106 return; |
| 107 ResourceClientWalker<StyleSheetResourceClient> w(m_clients); |
| 108 while (StyleSheetResourceClient* c = w.next()) |
| 109 c->didAppendFirstData(this); |
| 110 m_didNotifyFirstData = true; |
| 111 } |
| 112 |
101 void CSSStyleSheetResource::checkNotify() | 113 void CSSStyleSheetResource::checkNotify() |
102 { | 114 { |
103 // Decode the data to find out the encoding and keep the sheet text around d
uring checkNotify() | 115 // Decode the data to find out the encoding and keep the sheet text around d
uring checkNotify() |
104 if (m_data) | 116 if (m_data) |
105 m_decodedSheetText = decodedText(); | 117 m_decodedSheetText = decodedText(); |
106 | 118 |
107 ResourceClientWalker<StyleSheetResourceClient> w(m_clients); | 119 ResourceClientWalker<StyleSheetResourceClient> w(m_clients); |
108 while (StyleSheetResourceClient* c = w.next()) | 120 while (StyleSheetResourceClient* c = w.next()) |
109 c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), encoding(
), this); | 121 c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), encoding(
), this); |
110 // Clear the decoded text as it is unlikely to be needed immediately again a
nd is cheap to regenerate. | 122 // Clear the decoded text as it is unlikely to be needed immediately again a
nd is cheap to regenerate. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 189 |
178 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); | 190 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); |
179 | 191 |
180 // Check if this stylesheet resource didn't conflict with | 192 // Check if this stylesheet resource didn't conflict with |
181 // another resource and has indeed been added to the cache. | 193 // another resource and has indeed been added to the cache. |
182 if (memoryCache()->contains(this)) | 194 if (memoryCache()->contains(this)) |
183 m_parsedStyleSheetCache->addedToMemoryCache(); | 195 m_parsedStyleSheetCache->addedToMemoryCache(); |
184 } | 196 } |
185 | 197 |
186 } // namespace blink | 198 } // namespace blink |
OLD | NEW |