| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 if (!m_decodedSheetText.isNull()) | 88 if (!m_decodedSheetText.isNull()) |
| 89 return m_decodedSheetText; | 89 return m_decodedSheetText; |
| 90 | 90 |
| 91 // Don't cache the decoded text, regenerating is cheap and it can use quite
a bit of memory | 91 // Don't cache the decoded text, regenerating is cheap and it can use quite
a bit of memory |
| 92 String sheetText = m_decoder->decode(m_data->data(), m_data->size()); | 92 String sheetText = m_decoder->decode(m_data->data(), m_data->size()); |
| 93 sheetText.append(m_decoder->flush()); | 93 sheetText.append(m_decoder->flush()); |
| 94 return sheetText; | 94 return sheetText; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void CachedCSSStyleSheet::data(PassRefPtr<ResourceBuffer> data, bool allDataRece
ived) | 97 void CachedCSSStyleSheet::checkNotify() |
| 98 { | 98 { |
| 99 if (!allDataReceived) | |
| 100 return; | |
| 101 | |
| 102 m_data = data; | |
| 103 setEncodedSize(m_data.get() ? m_data->size() : 0); | |
| 104 // Decode the data to find out the encoding and keep the sheet text around d
uring checkNotify() | 99 // Decode the data to find out the encoding and keep the sheet text around d
uring checkNotify() |
| 105 if (m_data) { | 100 if (m_data) { |
| 106 m_decodedSheetText = m_decoder->decode(m_data->data(), m_data->size()); | 101 m_decodedSheetText = m_decoder->decode(m_data->data(), m_data->size()); |
| 107 m_decodedSheetText.append(m_decoder->flush()); | 102 m_decodedSheetText.append(m_decoder->flush()); |
| 108 } | 103 } |
| 109 setLoading(false); | 104 |
| 110 checkNotify(); | 105 CachedResourceClientWalker<CachedStyleSheetClient> w(m_clients); |
| 106 while (CachedStyleSheetClient* c = w.next()) |
| 107 c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder
->encoding().name(), this); |
| 111 // Clear the decoded text as it is unlikely to be needed immediately again a
nd is cheap to regenerate. | 108 // Clear the decoded text as it is unlikely to be needed immediately again a
nd is cheap to regenerate. |
| 112 m_decodedSheetText = String(); | 109 m_decodedSheetText = String(); |
| 113 } | 110 } |
| 114 | 111 |
| 115 void CachedCSSStyleSheet::checkNotify() | |
| 116 { | |
| 117 if (isLoading()) | |
| 118 return; | |
| 119 | |
| 120 CachedResourceClientWalker<CachedStyleSheetClient> w(m_clients); | |
| 121 while (CachedStyleSheetClient* c = w.next()) | |
| 122 c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder
->encoding().name(), this); | |
| 123 } | |
| 124 | |
| 125 bool CachedCSSStyleSheet::canUseSheet(bool enforceMIMEType, bool* hasValidMIMETy
pe) const | 112 bool CachedCSSStyleSheet::canUseSheet(bool enforceMIMEType, bool* hasValidMIMETy
pe) const |
| 126 { | 113 { |
| 127 if (errorOccurred()) | 114 if (errorOccurred()) |
| 128 return false; | 115 return false; |
| 129 | 116 |
| 130 if (!enforceMIMEType && !hasValidMIMEType) | 117 if (!enforceMIMEType && !hasValidMIMEType) |
| 131 return true; | 118 return true; |
| 132 | 119 |
| 133 // This check exactly matches Firefox. Note that we grab the Content-Type | 120 // This check exactly matches Firefox. Note that we grab the Content-Type |
| 134 // header directly because we want to see what the value is BEFORE content | 121 // header directly because we want to see what the value is BEFORE content |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void CachedCSSStyleSheet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo)
const | 184 void CachedCSSStyleSheet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo)
const |
| 198 { | 185 { |
| 199 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou
rceCSS); | 186 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou
rceCSS); |
| 200 CachedResource::reportMemoryUsage(memoryObjectInfo); | 187 CachedResource::reportMemoryUsage(memoryObjectInfo); |
| 201 info.addMember(m_decoder, "decoder"); | 188 info.addMember(m_decoder, "decoder"); |
| 202 info.addMember(m_parsedStyleSheetCache, "parsedStyleSheetCache"); | 189 info.addMember(m_parsedStyleSheetCache, "parsedStyleSheetCache"); |
| 203 info.addMember(m_decodedSheetText, "decodedSheetText"); | 190 info.addMember(m_decodedSheetText, "decodedSheetText"); |
| 204 } | 191 } |
| 205 | 192 |
| 206 } | 193 } |
| OLD | NEW |