eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 1 | /* |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 2 | Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 | Copyright (C) 2001 Dirk Mueller <mueller@kde.org> |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 4 | Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
ddkilzer@apple.com | 6242b77 | 2009-01-02 21:10:30 +0000 | [diff] [blame] | 5 | Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 6 | |
| 7 | This library is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU Library General Public |
| 9 | License as published by the Free Software Foundation; either |
| 10 | version 2 of the License, or (at your option) any later version. |
| 11 | |
| 12 | This library is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | Library General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Library General Public License |
| 18 | along with this library; see the file COPYING.LIB. If not, write to |
ddkilzer | c8eccec | 2007-09-26 02:29:57 +0000 | [diff] [blame] | 19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | Boston, MA 02110-1301, USA. |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 21 | |
| 22 | This class provides all functionality needed for loading images, style sheets and html |
| 23 | pages from the web. It has a memory cache for these objects. |
| 24 | */ |
darin | bbe6466 | 2006-01-16 17:52:23 +0000 | [diff] [blame] | 25 | |
eseidel | 8eddecf | 2007-01-16 00:49:43 +0000 | [diff] [blame] | 26 | #ifndef CachedCSSStyleSheet_h |
| 27 | #define CachedCSSStyleSheet_h |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 28 | |
darin | e775cf7 | 2006-07-09 22:48:56 +0000 | [diff] [blame] | 29 | #include "CachedResource.h" |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 30 | #include <wtf/Vector.h> |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 31 | |
darin | b3547a3 | 2006-09-06 04:40:44 +0000 | [diff] [blame] | 32 | namespace WebCore { |
| 33 | |
tonyg@chromium.org | 4b0a55f | 2011-05-12 10:31:51 +0000 | [diff] [blame] | 34 | class CachedResourceClient; |
antti@apple.com | 384e66f | 2012-05-23 17:17:43 +0000 | [diff] [blame] | 35 | class StyleSheetContents; |
darin | 5b2cbe1 | 2006-10-30 00:57:20 +0000 | [diff] [blame] | 36 | class TextResourceDecoder; |
antti@apple.com | 52f660f | 2012-04-26 22:26:35 +0000 | [diff] [blame] | 37 | struct CSSParserContext; |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 38 | |
andersca@apple.com | 16d2dd4 | 2014-01-16 23:08:24 +0000 | [diff] [blame] | 39 | class CachedCSSStyleSheet final : public CachedResource { |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 40 | public: |
commit-queue@webkit.org | 9ab4d3e | 2014-03-05 20:11:03 +0000 | [diff] [blame] | 41 | CachedCSSStyleSheet(const ResourceRequest&, const String& charset, SessionID); |
darin | d7d82ce | 2006-01-13 10:07:39 +0000 | [diff] [blame] | 42 | virtual ~CachedCSSStyleSheet(); |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 43 | |
cdumez@apple.com | 090a5fb | 2015-07-28 17:24:26 +0000 | [diff] [blame] | 44 | enum class MIMETypeCheck { Strict, Lax }; |
| 45 | const String sheetText(MIMETypeCheck = MIMETypeCheck::Strict, bool* hasValidMIMEType = nullptr) const; |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 46 | |
antti@apple.com | 6e31387 | 2015-05-13 23:09:13 +0000 | [diff] [blame] | 47 | PassRefPtr<StyleSheetContents> restoreParsedStyleSheet(const CSSParserContext&, CachePolicy); |
akling@apple.com | 689f761 | 2014-12-14 08:21:05 +0000 | [diff] [blame] | 48 | void saveParsedStyleSheet(Ref<StyleSheetContents>&&); |
loislo@chromium.org | 7b6f5d9 | 2012-08-06 09:12:01 +0000 | [diff] [blame] | 49 | |
hyatt@apple.com | 2242c2e | 2008-02-11 20:17:36 +0000 | [diff] [blame] | 50 | private: |
cdumez@apple.com | 090a5fb | 2015-07-28 17:24:26 +0000 | [diff] [blame] | 51 | bool canUseSheet(MIMETypeCheck, bool* hasValidMIMEType) const; |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame^] | 52 | bool mayTryReplaceEncodedData() const override { return true; } |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 53 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame^] | 54 | void didAddClient(CachedResourceClient*) override; |
carlosgc@webkit.org | 80e15b4 | 2013-06-07 08:57:35 +0000 | [diff] [blame] | 55 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame^] | 56 | void setEncoding(const String&) override; |
| 57 | String encoding() const override; |
| 58 | void finishLoading(SharedBuffer*) override; |
| 59 | void destroyDecodedData() override; |
carlosgc@webkit.org | 80e15b4 | 2013-06-07 08:57:35 +0000 | [diff] [blame] | 60 | |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 61 | protected: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame^] | 62 | void checkNotify() override; |
japhet@chromium.org | 645dc1d | 2012-09-06 05:51:46 +0000 | [diff] [blame] | 63 | |
darin | 5b2cbe1 | 2006-10-30 00:57:20 +0000 | [diff] [blame] | 64 | RefPtr<TextResourceDecoder> m_decoder; |
antti@apple.com | da9077d | 2008-11-07 07:22:43 +0000 | [diff] [blame] | 65 | String m_decodedSheetText; |
antti@apple.com | 52f660f | 2012-04-26 22:26:35 +0000 | [diff] [blame] | 66 | |
antti@apple.com | 384e66f | 2012-05-23 17:17:43 +0000 | [diff] [blame] | 67 | RefPtr<StyleSheetContents> m_parsedStyleSheetCache; |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
cdumez@apple.com | c4a3af6 | 2014-10-06 00:31:05 +0000 | [diff] [blame] | 70 | } // namespace WebCore |
ddkilzer@apple.com | 4a0e451 | 2014-02-01 16:32:11 +0000 | [diff] [blame] | 71 | |
cdumez@apple.com | c4a3af6 | 2014-10-06 00:31:05 +0000 | [diff] [blame] | 72 | SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedCSSStyleSheet, CachedResource::CSSStyleSheet) |
eseidel | 94980f2 | 2006-01-09 09:29:48 +0000 | [diff] [blame] | 73 | |
cdumez@apple.com | c4a3af6 | 2014-10-06 00:31:05 +0000 | [diff] [blame] | 74 | #endif // CachedCSSStyleSheet_h |