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::setParsedStyleSheetCache(StyleSheetContents* newShee
t) | 62 void CSSStyleSheetResource::setParsedStyleSheetCache(StyleSheetContents* newShee
t) |
62 { | 63 { |
63 if (m_parsedStyleSheetCache) | 64 if (m_parsedStyleSheetCache) |
(...skipping 28 matching lines...) Expand all Loading... |
92 if (!m_data || m_data->isEmpty() || !canUseSheet(mimeTypeCheck)) | 93 if (!m_data || m_data->isEmpty() || !canUseSheet(mimeTypeCheck)) |
93 return String(); | 94 return String(); |
94 | 95 |
95 if (!m_decodedSheetText.isNull()) | 96 if (!m_decodedSheetText.isNull()) |
96 return m_decodedSheetText; | 97 return m_decodedSheetText; |
97 | 98 |
98 // Don't cache the decoded text, regenerating is cheap and it can use quite
a bit of memory | 99 // Don't cache the decoded text, regenerating is cheap and it can use quite
a bit of memory |
99 return decodedText(); | 100 return decodedText(); |
100 } | 101 } |
101 | 102 |
| 103 void CSSStyleSheetResource::appendData(const char* data, size_t length) |
| 104 { |
| 105 Resource::appendData(data, length); |
| 106 if (m_didNotifyFirstData) |
| 107 return; |
| 108 ResourceClientWalker<StyleSheetResourceClient> w(m_clients); |
| 109 while (StyleSheetResourceClient* c = w.next()) |
| 110 c->didAppendFirstData(this); |
| 111 m_didNotifyFirstData = true; |
| 112 } |
| 113 |
102 void CSSStyleSheetResource::checkNotify() | 114 void CSSStyleSheetResource::checkNotify() |
103 { | 115 { |
104 // Decode the data to find out the encoding and keep the sheet text around d
uring checkNotify() | 116 // Decode the data to find out the encoding and keep the sheet text around d
uring checkNotify() |
105 if (m_data) | 117 if (m_data) |
106 m_decodedSheetText = decodedText(); | 118 m_decodedSheetText = decodedText(); |
107 | 119 |
108 ResourceClientWalker<StyleSheetResourceClient> w(m_clients); | 120 ResourceClientWalker<StyleSheetResourceClient> w(m_clients); |
109 while (StyleSheetResourceClient* c = w.next()) | 121 while (StyleSheetResourceClient* c = w.next()) |
110 c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), encoding(
), this); | 122 c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), encoding(
), this); |
111 // Clear the decoded text as it is unlikely to be needed immediately again a
nd is cheap to regenerate. | 123 // Clear the decoded text as it is unlikely to be needed immediately again a
nd is cheap to regenerate. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // This stylesheet resource did conflict with another resource and was | 185 // This stylesheet resource did conflict with another resource and was |
174 // not added to the cache. | 186 // not added to the cache. |
175 setParsedStyleSheetCache(nullptr); | 187 setParsedStyleSheetCache(nullptr); |
176 return; | 188 return; |
177 } | 189 } |
178 setParsedStyleSheetCache(sheet); | 190 setParsedStyleSheetCache(sheet); |
179 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); | 191 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); |
180 } | 192 } |
181 | 193 |
182 } // namespace blink | 194 } // namespace blink |
OLD | NEW |