Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 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/html/parser/TextResourceDecoder.h" | 33 #include "core/html/parser/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 "platform/text/SegmentedString.h" | |
| 36 #include "wtf/CurrentTime.h" | 37 #include "wtf/CurrentTime.h" |
| 37 #include "wtf/Vector.h" | 38 #include "wtf/Vector.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, Document* document) |
| 42 : StyleSheetResource(resourceRequest, CSSStyleSheet) | 43 : StyleSheetResource(resourceRequest, CSSStyleSheet) |
| 43 , m_decoder(TextResourceDecoder::create("text/css", charset)) | 44 , m_decoder(TextResourceDecoder::create("text/css", charset)) |
| 45 , m_preloadScanner(adoptPtr(new CSSPreloadScanner)) | |
| 46 , m_preloader(adoptPtr(new HTMLResourcePreloader(document))) | |
|
abarth-chromium
2014/02/26 19:13:36
Why do we create these objects in the case where w
| |
| 47 , m_prescan(document ? true : false) | |
|
abarth-chromium
2014/02/26 19:13:36
There's no reason to write foo ? true : false. If
| |
| 44 { | 48 { |
| 45 DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", At omicString::ConstructFromLiteral)); | 49 DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", At omicString::ConstructFromLiteral)); |
| 46 | 50 |
| 47 // Prefer text/css but accept any type (dell.com serves a stylesheet | 51 // Prefer text/css but accept any type (dell.com serves a stylesheet |
| 48 // as text/html; see <http://bugs.webkit.org/show_bug.cgi?id=11451>). | 52 // as text/html; see <http://bugs.webkit.org/show_bug.cgi?id=11451>). |
| 49 setAccept(acceptCSS); | 53 setAccept(acceptCSS); |
| 50 } | 54 } |
| 51 | 55 |
| 52 CSSStyleSheetResource::~CSSStyleSheetResource() | 56 CSSStyleSheetResource::~CSSStyleSheetResource() |
| 53 { | 57 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 { | 121 { |
| 118 if (!isSafeToUnlock()) | 122 if (!isSafeToUnlock()) |
| 119 return; | 123 return; |
| 120 | 124 |
| 121 m_parsedStyleSheetCache->removedFromMemoryCache(); | 125 m_parsedStyleSheetCache->removedFromMemoryCache(); |
| 122 m_parsedStyleSheetCache.clear(); | 126 m_parsedStyleSheetCache.clear(); |
| 123 | 127 |
| 124 setDecodedSize(0); | 128 setDecodedSize(0); |
| 125 } | 129 } |
| 126 | 130 |
| 131 void CSSStyleSheetResource::appendData(const char* data, int length) | |
| 132 { | |
| 133 Resource::appendData(data, length); | |
| 134 if (m_prescan) { | |
| 135 m_prescan = false; | |
| 136 PreloadRequestStream pendingPreloads; | |
| 137 m_preloadScanner->scan(data, SegmentedString(data), pendingPreloads); | |
| 138 m_preloader->takeAndPreload(pendingPreloads); | |
|
abarth-chromium
2014/02/26 19:13:36
Whey don't we destroy these objects when we're don
| |
| 139 } | |
| 140 } | |
| 141 | |
| 127 bool CSSStyleSheetResource::canUseSheet(bool enforceMIMEType, bool* hasValidMIME Type) const | 142 bool CSSStyleSheetResource::canUseSheet(bool enforceMIMEType, bool* hasValidMIME Type) const |
| 128 { | 143 { |
| 129 if (errorOccurred()) | 144 if (errorOccurred()) |
| 130 return false; | 145 return false; |
| 131 | 146 |
| 132 if (!enforceMIMEType && !hasValidMIMEType) | 147 if (!enforceMIMEType && !hasValidMIMEType) |
| 133 return true; | 148 return true; |
| 134 | 149 |
| 135 // This check exactly matches Firefox. Note that we grab the Content-Type | 150 // This check exactly matches Firefox. Note that we grab the Content-Type |
| 136 // header directly because we want to see what the value is BEFORE content | 151 // header directly because we want to see what the value is BEFORE content |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 | 191 |
| 177 if (m_parsedStyleSheetCache) | 192 if (m_parsedStyleSheetCache) |
| 178 m_parsedStyleSheetCache->removedFromMemoryCache(); | 193 m_parsedStyleSheetCache->removedFromMemoryCache(); |
| 179 m_parsedStyleSheetCache = sheet; | 194 m_parsedStyleSheetCache = sheet; |
| 180 m_parsedStyleSheetCache->addedToMemoryCache(); | 195 m_parsedStyleSheetCache->addedToMemoryCache(); |
| 181 | 196 |
| 182 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); | 197 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); |
| 183 } | 198 } |
| 184 | 199 |
| 185 } | 200 } |
| OLD | NEW |