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 17 matching lines...) Expand all Loading... | |
28 #include "core/fetch/CSSStyleSheetResource.h" | 28 #include "core/fetch/CSSStyleSheetResource.h" |
29 | 29 |
30 #include "core/css/StyleSheetContents.h" | 30 #include "core/css/StyleSheetContents.h" |
31 #include "core/fetch/ResourceClientWalker.h" | 31 #include "core/fetch/ResourceClientWalker.h" |
32 #include "core/fetch/StyleSheetResourceClient.h" | 32 #include "core/fetch/StyleSheetResourceClient.h" |
33 #include "core/fetch/TextResourceDecoder.h" | 33 #include "core/fetch/TextResourceDecoder.h" |
34 #include "platform/SharedBuffer.h" | 34 #include "platform/SharedBuffer.h" |
35 #include "platform/network/HTTPParsers.h" | 35 #include "platform/network/HTTPParsers.h" |
36 #include "wtf/CurrentTime.h" | 36 #include "wtf/CurrentTime.h" |
37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
38 #include "wtf/text/StringBuilder.h" | |
38 | 39 |
39 namespace WebCore { | 40 namespace WebCore { |
40 | 41 |
41 CSSStyleSheetResource::CSSStyleSheetResource(const ResourceRequest& resourceRequ est, const String& charset) | 42 CSSStyleSheetResource::CSSStyleSheetResource(const ResourceRequest& resourceRequ est, const String& charset) |
42 : StyleSheetResource(resourceRequest, CSSStyleSheet) | 43 : StyleSheetResource(resourceRequest, CSSStyleSheet) |
43 , m_decoder(TextResourceDecoder::create("text/css", charset)) | 44 , m_decoder(TextResourceDecoder::create("text/css", charset)) |
44 { | 45 { |
45 DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", At omicString::ConstructFromLiteral)); | 46 DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", At omicString::ConstructFromLiteral)); |
46 | 47 |
47 // Prefer text/css but accept any type (dell.com serves a stylesheet | 48 // Prefer text/css but accept any type (dell.com serves a stylesheet |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 { | 82 { |
82 ASSERT(!isPurgeable()); | 83 ASSERT(!isPurgeable()); |
83 | 84 |
84 if (!m_data || m_data->isEmpty() || !canUseSheet(enforceMIMEType, hasValidMI METype)) | 85 if (!m_data || m_data->isEmpty() || !canUseSheet(enforceMIMEType, hasValidMI METype)) |
85 return String(); | 86 return String(); |
86 | 87 |
87 if (!m_decodedSheetText.isNull()) | 88 if (!m_decodedSheetText.isNull()) |
88 return m_decodedSheetText; | 89 return m_decodedSheetText; |
89 | 90 |
90 // 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 |
91 String sheetText = m_decoder->decode(m_data->data(), m_data->size()); | 92 StringBuilder sheetText; |
93 sheetText.append(m_decoder->decode(m_data->data(), m_data->size())); | |
92 sheetText.append(m_decoder->flush()); | 94 sheetText.append(m_decoder->flush()); |
gnana
2014/01/08 16:01:42
I m not sure if this change adds value. I will be
abarth-chromium
2014/01/08 16:35:23
This isn't great either... Maybe
String sheetTex
gnana
2014/01/09 08:06:44
This looks better. Modified as you suggested.
Don
| |
93 return sheetText; | 95 return sheetText.toString(); |
94 } | 96 } |
95 | 97 |
96 void CSSStyleSheetResource::checkNotify() | 98 void CSSStyleSheetResource::checkNotify() |
97 { | 99 { |
98 // Decode the data to find out the encoding and keep the sheet text around d uring checkNotify() | 100 // Decode the data to find out the encoding and keep the sheet text around d uring checkNotify() |
99 if (m_data) { | 101 if (m_data) { |
100 m_decodedSheetText = m_decoder->decode(m_data->data(), m_data->size()); | 102 m_decodedSheetText = m_decoder->decode(m_data->data(), m_data->size()); |
101 m_decodedSheetText.append(m_decoder->flush()); | 103 m_decodedSheetText.append(m_decoder->flush()); |
102 } | 104 } |
103 | 105 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 | 176 |
175 if (m_parsedStyleSheetCache) | 177 if (m_parsedStyleSheetCache) |
176 m_parsedStyleSheetCache->removedFromMemoryCache(); | 178 m_parsedStyleSheetCache->removedFromMemoryCache(); |
177 m_parsedStyleSheetCache = sheet; | 179 m_parsedStyleSheetCache = sheet; |
178 m_parsedStyleSheetCache->addedToMemoryCache(); | 180 m_parsedStyleSheetCache->addedToMemoryCache(); |
179 | 181 |
180 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); | 182 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); |
181 } | 183 } |
182 | 184 |
183 } | 185 } |
OLD | NEW |