| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/fetch/FetchRequest.h" | 30 #include "core/fetch/FetchRequest.h" |
| 31 #include "core/fetch/ResourceClientWalker.h" | 31 #include "core/fetch/ResourceClientWalker.h" |
| 32 #include "core/fetch/ResourceFetcher.h" | 32 #include "core/fetch/ResourceFetcher.h" |
| 33 #include "core/fetch/StyleSheetResourceClient.h" | 33 #include "core/fetch/StyleSheetResourceClient.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 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 PassRefPtrWillBeRawPtr<CSSStyleSheetResource> CSSStyleSheetResource::fetch(Fetch
Request& request, ResourceFetcher* fetcher) | 40 RawPtr<CSSStyleSheetResource> CSSStyleSheetResource::fetch(FetchRequest& request
, ResourceFetcher* fetcher) |
| 41 { | 41 { |
| 42 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone
); | 42 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone
); |
| 43 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon
textStyle); | 43 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon
textStyle); |
| 44 return toCSSStyleSheetResource(fetcher->requestResource(request, CSSStyleShe
etResourceFactory())); | 44 return toCSSStyleSheetResource(fetcher->requestResource(request, CSSStyleShe
etResourceFactory())); |
| 45 } | 45 } |
| 46 | 46 |
| 47 PassRefPtrWillBeRawPtr<CSSStyleSheetResource> CSSStyleSheetResource::createForTe
st(const ResourceRequest& request, const String& charset) | 47 RawPtr<CSSStyleSheetResource> CSSStyleSheetResource::createForTest(const Resourc
eRequest& request, const String& charset) |
| 48 { | 48 { |
| 49 return adoptRefWillBeNoop(new CSSStyleSheetResource(request, charset)); | 49 return (new CSSStyleSheetResource(request, charset)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 CSSStyleSheetResource::CSSStyleSheetResource(const ResourceRequest& resourceRequ
est, const String& charset) | 52 CSSStyleSheetResource::CSSStyleSheetResource(const ResourceRequest& resourceRequ
est, const String& charset) |
| 53 : StyleSheetResource(resourceRequest, CSSStyleSheet, "text/css", charset) | 53 : StyleSheetResource(resourceRequest, CSSStyleSheet, "text/css", charset) |
| 54 { | 54 { |
| 55 DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", At
omicString::ConstructFromLiteral)); | 55 DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", At
omicString::ConstructFromLiteral)); |
| 56 | 56 |
| 57 // Prefer text/css but accept any type (dell.com serves a stylesheet | 57 // Prefer text/css but accept any type (dell.com serves a stylesheet |
| 58 // as text/html; see <http://bugs.webkit.org/show_bug.cgi?id=11451>). | 58 // as text/html; see <http://bugs.webkit.org/show_bug.cgi?id=11451>). |
| 59 setAccept(acceptCSS); | 59 setAccept(acceptCSS); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // sniffing. Firefox does this by setting a "type hint" on the channel. | 149 // sniffing. Firefox does this by setting a "type hint" on the channel. |
| 150 // This implementation should be observationally equivalent. | 150 // This implementation should be observationally equivalent. |
| 151 // | 151 // |
| 152 // This code defaults to allowing the stylesheet for non-HTTP protocols so | 152 // This code defaults to allowing the stylesheet for non-HTTP protocols so |
| 153 // folks can use standards mode for local HTML documents. | 153 // folks can use standards mode for local HTML documents. |
| 154 if (mimeTypeCheck == MIMETypeCheck::Lax) | 154 if (mimeTypeCheck == MIMETypeCheck::Lax) |
| 155 return true; | 155 return true; |
| 156 return mimeType().isEmpty() || equalIgnoringCase(mimeType(), "text/css") ||
equalIgnoringCase(mimeType(), "application/x-unknown-content-type"); | 156 return mimeType().isEmpty() || equalIgnoringCase(mimeType(), "text/css") ||
equalIgnoringCase(mimeType(), "application/x-unknown-content-type"); |
| 157 } | 157 } |
| 158 | 158 |
| 159 PassRefPtrWillBeRawPtr<StyleSheetContents> CSSStyleSheetResource::restoreParsedS
tyleSheet(const CSSParserContext& context) | 159 RawPtr<StyleSheetContents> CSSStyleSheetResource::restoreParsedStyleSheet(const
CSSParserContext& context) |
| 160 { | 160 { |
| 161 if (!m_parsedStyleSheetCache) | 161 if (!m_parsedStyleSheetCache) |
| 162 return nullptr; | 162 return nullptr; |
| 163 if (m_parsedStyleSheetCache->hasFailedOrCanceledSubresources()) { | 163 if (m_parsedStyleSheetCache->hasFailedOrCanceledSubresources()) { |
| 164 m_parsedStyleSheetCache->removedFromMemoryCache(); | 164 m_parsedStyleSheetCache->removedFromMemoryCache(); |
| 165 m_parsedStyleSheetCache.clear(); | 165 m_parsedStyleSheetCache.clear(); |
| 166 return nullptr; | 166 return nullptr; |
| 167 } | 167 } |
| 168 | 168 |
| 169 ASSERT(m_parsedStyleSheetCache->isCacheable()); | 169 ASSERT(m_parsedStyleSheetCache->isCacheable()); |
| 170 ASSERT(m_parsedStyleSheetCache->isInMemoryCache()); | 170 ASSERT(m_parsedStyleSheetCache->isInMemoryCache()); |
| 171 | 171 |
| 172 // Contexts must be identical so we know we would get the same exact result
if we parsed again. | 172 // Contexts must be identical so we know we would get the same exact result
if we parsed again. |
| 173 if (m_parsedStyleSheetCache->parserContext() != context) | 173 if (m_parsedStyleSheetCache->parserContext() != context) |
| 174 return nullptr; | 174 return nullptr; |
| 175 | 175 |
| 176 didAccessDecodedData(); | 176 didAccessDecodedData(); |
| 177 | 177 |
| 178 return m_parsedStyleSheetCache; | 178 return m_parsedStyleSheetCache; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void CSSStyleSheetResource::saveParsedStyleSheet(PassRefPtrWillBeRawPtr<StyleShe
etContents> sheet) | 181 void CSSStyleSheetResource::saveParsedStyleSheet(RawPtr<StyleSheetContents> shee
t) |
| 182 { | 182 { |
| 183 ASSERT(sheet && sheet->isCacheable()); | 183 ASSERT(sheet && sheet->isCacheable()); |
| 184 | 184 |
| 185 if (m_parsedStyleSheetCache) | 185 if (m_parsedStyleSheetCache) |
| 186 m_parsedStyleSheetCache->removedFromMemoryCache(); | 186 m_parsedStyleSheetCache->removedFromMemoryCache(); |
| 187 m_parsedStyleSheetCache = sheet; | 187 m_parsedStyleSheetCache = sheet; |
| 188 m_parsedStyleSheetCache->addedToMemoryCache(); | 188 m_parsedStyleSheetCache->addedToMemoryCache(); |
| 189 | 189 |
| 190 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); | 190 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |