| 1 | /* |
| 2 | * Copyright (C) 2006, 2007 Rob Buis |
| 3 | * Copyright (C) 2013 Apple, Inc. All rights reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Library General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Library General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Library General Public License |
| 16 | * along with this library; see the file COPYING.LIB. If not, write to |
| 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | * Boston, MA 02110-1301, USA. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #pragma once |
| 23 | |
| 24 | #include "CSSStyleSheet.h" |
| 25 | #include <wtf/text/TextPosition.h> |
| 26 | |
| 27 | namespace WebCore { |
| 28 | |
| 29 | class Document; |
| 30 | class Element; |
| 31 | |
| 32 | class InlineStyleSheetOwner { |
| 33 | public: |
| 34 | InlineStyleSheetOwner(Document&, bool createdByParser); |
| 35 | ~InlineStyleSheetOwner(); |
| 36 | |
| 37 | void setContentType(const AtomicString& contentType) { m_contentType = contentType; } |
| 38 | void setMedia(const AtomicString& media) { m_media = media; } |
| 39 | |
| 40 | CSSStyleSheet* sheet() const { return m_sheet.get(); } |
| 41 | |
| 42 | bool isLoading() const; |
| 43 | bool sheetLoaded(Element&); |
| 44 | void startLoadingDynamicSheet(Element&); |
| 45 | |
| 46 | void insertedIntoDocument(Element&); |
| 47 | void removedFromDocument(Element&); |
| 48 | void clearDocumentData(Element&); |
| 49 | void childrenChanged(Element&); |
| 50 | void finishParsingChildren(Element&); |
| 51 | |
| 52 | Style::Scope* styleScope() { return m_styleScope; } |
| 53 | |
| 54 | static void clearCache(); |
| 55 | |
| 56 | private: |
| 57 | void createSheet(Element&, const String& text); |
| 58 | void createSheetFromTextContents(Element&); |
| 59 | void clearSheet(); |
| 60 | |
| 61 | bool m_isParsingChildren; |
| 62 | bool m_loading; |
| 63 | WTF::TextPosition m_startTextPosition; |
| 64 | AtomicString m_contentType; |
| 65 | AtomicString m_media; |
| 66 | RefPtr<CSSStyleSheet> m_sheet; |
| 67 | Style::Scope* m_styleScope { nullptr }; |
| 68 | }; |
| 69 | |
| 70 | } // namespace WebCore |
| 71 | |