| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/fetch/ResourceClientWalker.h" | 32 #include "core/fetch/ResourceClientWalker.h" |
| 33 #include "core/fetch/ResourceFetcher.h" | 33 #include "core/fetch/ResourceFetcher.h" |
| 34 #include "core/fetch/StyleSheetResourceClient.h" | 34 #include "core/fetch/StyleSheetResourceClient.h" |
| 35 #include "platform/SharedBuffer.h" | 35 #include "platform/SharedBuffer.h" |
| 36 #include "wtf/CurrentTime.h" | 36 #include "wtf/CurrentTime.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 CSSStyleSheetResource* CSSStyleSheetResource::fetch(FetchRequest& request, Resou
rceFetcher* fetcher) | 40 CSSStyleSheetResource* CSSStyleSheetResource::fetch(FetchRequest& request, Resou
rceFetcher* fetcher) |
| 41 { | 41 { |
| 42 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone
); | 42 DCHECK(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 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) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 DEFINE_TRACE(CSSStyleSheetResource) | 71 DEFINE_TRACE(CSSStyleSheetResource) |
| 72 { | 72 { |
| 73 visitor->trace(m_parsedStyleSheetCache); | 73 visitor->trace(m_parsedStyleSheetCache); |
| 74 StyleSheetResource::trace(visitor); | 74 StyleSheetResource::trace(visitor); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void CSSStyleSheetResource::didAddClient(ResourceClient* c) | 77 void CSSStyleSheetResource::didAddClient(ResourceClient* c) |
| 78 { | 78 { |
| 79 ASSERT(StyleSheetResourceClient::isExpectedType(c)); | 79 DCHECK(StyleSheetResourceClient::isExpectedType(c)); |
| 80 // Resource::didAddClient() must be before setCSSStyleSheet(), | 80 // Resource::didAddClient() must be before setCSSStyleSheet(), |
| 81 // because setCSSStyleSheet() may cause scripts to be executed, which could
destroy 'c' if it is an instance of HTMLLinkElement. | 81 // because setCSSStyleSheet() may cause scripts to be executed, which could
destroy 'c' if it is an instance of HTMLLinkElement. |
| 82 // see the comment of HTMLLinkElement::setCSSStyleSheet. | 82 // see the comment of HTMLLinkElement::setCSSStyleSheet. |
| 83 Resource::didAddClient(c); | 83 Resource::didAddClient(c); |
| 84 if (m_didNotifyFirstData) | 84 if (m_didNotifyFirstData) |
| 85 static_cast<StyleSheetResourceClient*>(c)->didAppendFirstData(this); | 85 static_cast<StyleSheetResourceClient*>(c)->didAppendFirstData(this); |
| 86 | 86 |
| 87 // |c| might be removed in didAppendFirstData, so ensure it is still a | 87 // |c| might be removed in didAppendFirstData, so ensure it is still a |
| 88 // client. | 88 // client. |
| 89 if (hasClient(c) && !isLoading()) | 89 if (hasClient(c) && !isLoading()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 StyleSheetContents* CSSStyleSheetResource::restoreParsedStyleSheet(const CSSPars
erContext& context) | 156 StyleSheetContents* CSSStyleSheetResource::restoreParsedStyleSheet(const CSSPars
erContext& context) |
| 157 { | 157 { |
| 158 if (!m_parsedStyleSheetCache) | 158 if (!m_parsedStyleSheetCache) |
| 159 return nullptr; | 159 return nullptr; |
| 160 if (m_parsedStyleSheetCache->hasFailedOrCanceledSubresources()) { | 160 if (m_parsedStyleSheetCache->hasFailedOrCanceledSubresources()) { |
| 161 setParsedStyleSheetCache(nullptr); | 161 setParsedStyleSheetCache(nullptr); |
| 162 return nullptr; | 162 return nullptr; |
| 163 } | 163 } |
| 164 | 164 |
| 165 ASSERT(m_parsedStyleSheetCache->isCacheableForResource()); | 165 DCHECK(m_parsedStyleSheetCache->isCacheableForResource()); |
| 166 ASSERT(m_parsedStyleSheetCache->isReferencedFromResource()); | 166 DCHECK(m_parsedStyleSheetCache->isReferencedFromResource()); |
| 167 | 167 |
| 168 // Contexts must be identical so we know we would get the same exact result
if we parsed again. | 168 // Contexts must be identical so we know we would get the same exact result
if we parsed again. |
| 169 if (m_parsedStyleSheetCache->parserContext() != context) | 169 if (m_parsedStyleSheetCache->parserContext() != context) |
| 170 return nullptr; | 170 return nullptr; |
| 171 | 171 |
| 172 didAccessDecodedData(); | 172 didAccessDecodedData(); |
| 173 | 173 |
| 174 return m_parsedStyleSheetCache; | 174 return m_parsedStyleSheetCache; |
| 175 } | 175 } |
| 176 | 176 |
| 177 void CSSStyleSheetResource::saveParsedStyleSheet(StyleSheetContents* sheet) | 177 void CSSStyleSheetResource::saveParsedStyleSheet(StyleSheetContents* sheet) |
| 178 { | 178 { |
| 179 ASSERT(sheet && sheet->isCacheableForResource()); | 179 DCHECK(sheet && sheet->isCacheableForResource()); |
| 180 | 180 |
| 181 if (!memoryCache()->contains(this)) { | 181 if (!memoryCache()->contains(this)) { |
| 182 // This stylesheet resource did conflict with another resource and was | 182 // This stylesheet resource did conflict with another resource and was |
| 183 // not added to the cache. | 183 // not added to the cache. |
| 184 setParsedStyleSheetCache(nullptr); | 184 setParsedStyleSheetCache(nullptr); |
| 185 return; | 185 return; |
| 186 } | 186 } |
| 187 setParsedStyleSheetCache(sheet); | 187 setParsedStyleSheetCache(sheet); |
| 188 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); | 188 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace blink | 191 } // namespace blink |
| OLD | NEW |