| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights
reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef SKY_ENGINE_CORE_CSS_CSSSTYLESHEET_H_ | 21 #ifndef SKY_ENGINE_CORE_CSS_CSSSTYLESHEET_H_ |
| 22 #define SKY_ENGINE_CORE_CSS_CSSSTYLESHEET_H_ | 22 #define SKY_ENGINE_CORE_CSS_CSSSTYLESHEET_H_ |
| 23 | 23 |
| 24 #include "sky/engine/core/css/CSSRule.h" | |
| 25 #include "sky/engine/core/css/StyleSheet.h" | 24 #include "sky/engine/core/css/StyleSheet.h" |
| 26 #include "sky/engine/platform/heap/Handle.h" | 25 #include "sky/engine/platform/heap/Handle.h" |
| 27 #include "sky/engine/wtf/Noncopyable.h" | 26 #include "sky/engine/wtf/Noncopyable.h" |
| 28 #include "sky/engine/wtf/text/TextPosition.h" | 27 #include "sky/engine/wtf/text/TextPosition.h" |
| 29 | 28 |
| 30 namespace blink { | 29 namespace blink { |
| 31 | 30 |
| 32 class BisonCSSParser; | 31 class BisonCSSParser; |
| 33 class CSSRule; | |
| 34 class CSSRuleList; | |
| 35 class CSSStyleSheet; | 32 class CSSStyleSheet; |
| 36 class Document; | 33 class Document; |
| 37 class ExceptionState; | 34 class ExceptionState; |
| 38 class MediaQuerySet; | 35 class MediaQuerySet; |
| 39 class StyleSheetContents; | 36 class StyleSheetContents; |
| 40 | 37 |
| 41 enum StyleSheetUpdateType { | 38 enum StyleSheetUpdateType { |
| 42 PartialRuleUpdate, | 39 PartialRuleUpdate, |
| 43 EntireStyleSheetUpdate | 40 EntireStyleSheetUpdate |
| 44 }; | 41 }; |
| 45 | 42 |
| 46 class CSSStyleSheet final : public StyleSheet { | 43 class CSSStyleSheet final : public StyleSheet { |
| 47 DEFINE_WRAPPERTYPEINFO(); | |
| 48 public: | 44 public: |
| 49 static PassRefPtr<CSSStyleSheet> createInline(Node*, const KURL&, const Text
Position& startPosition = TextPosition::minimumPosition()); | 45 static PassRefPtr<CSSStyleSheet> createInline(Node*, const KURL&, const Text
Position& startPosition = TextPosition::minimumPosition()); |
| 50 static PassRefPtr<CSSStyleSheet> createInline(PassRefPtr<StyleSheetContents>
, Node* ownerNode, const TextPosition& startPosition = TextPosition::minimumPosi
tion()); | 46 static PassRefPtr<CSSStyleSheet> createInline(PassRefPtr<StyleSheetContents>
, Node* ownerNode, const TextPosition& startPosition = TextPosition::minimumPosi
tion()); |
| 51 | 47 |
| 52 virtual ~CSSStyleSheet(); | 48 virtual ~CSSStyleSheet(); |
| 53 | 49 |
| 54 virtual Node* ownerNode() const override { return m_ownerNode; } | 50 virtual Node* ownerNode() const override { return m_ownerNode; } |
| 55 virtual MediaList* media() const override; | |
| 56 | 51 |
| 57 PassRefPtr<CSSRuleList> cssRules(); | |
| 58 unsigned insertRule(const String& rule, unsigned index, ExceptionState&); | |
| 59 unsigned insertRule(const String& rule, ExceptionState&); // Deprecated. | |
| 60 void deleteRule(unsigned index, ExceptionState&); | |
| 61 | |
| 62 // IE Extensions | |
| 63 PassRefPtr<CSSRuleList> rules(); | |
| 64 int addRule(const String& selector, const String& style, int index, Exceptio
nState&); | |
| 65 int addRule(const String& selector, const String& style, ExceptionState&); | |
| 66 void removeRule(unsigned index, ExceptionState& exceptionState) { deleteRule
(index, exceptionState); } | |
| 67 | |
| 68 // For CSSRuleList. | |
| 69 unsigned length() const; | 52 unsigned length() const; |
| 70 CSSRule* item(unsigned index); | |
| 71 | 53 |
| 72 virtual void clearOwnerNode() override; | 54 virtual void clearOwnerNode() override; |
| 73 | 55 |
| 74 virtual KURL baseURL() const override; | 56 virtual KURL baseURL() const override; |
| 75 | 57 |
| 76 Document* ownerDocument() const; | 58 Document* ownerDocument() const; |
| 77 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } | 59 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } |
| 78 void setMediaQueries(PassRefPtr<MediaQuerySet>); | 60 void setMediaQueries(PassRefPtr<MediaQuerySet>); |
| 79 | 61 |
| 80 class RuleMutationScope { | 62 class RuleMutationScope { |
| 81 WTF_MAKE_NONCOPYABLE(RuleMutationScope); | 63 WTF_MAKE_NONCOPYABLE(RuleMutationScope); |
| 82 STACK_ALLOCATED(); | 64 STACK_ALLOCATED(); |
| 83 public: | 65 public: |
| 84 explicit RuleMutationScope(CSSStyleSheet*); | 66 explicit RuleMutationScope(CSSStyleSheet*); |
| 85 explicit RuleMutationScope(CSSRule*); | |
| 86 ~RuleMutationScope(); | 67 ~RuleMutationScope(); |
| 87 | 68 |
| 88 private: | 69 private: |
| 89 RawPtr<CSSStyleSheet> m_styleSheet; | 70 RawPtr<CSSStyleSheet> m_styleSheet; |
| 90 }; | 71 }; |
| 91 | 72 |
| 92 void willMutateRules(); | 73 void willMutateRules(); |
| 93 void didMutateRules(); | 74 void didMutateRules(); |
| 94 void didMutate(StyleSheetUpdateType = PartialRuleUpdate); | 75 void didMutate(StyleSheetUpdateType = PartialRuleUpdate); |
| 95 | 76 |
| 96 void clearChildRuleCSSOMWrappers(); | |
| 97 | |
| 98 StyleSheetContents* contents() const { return m_contents.get(); } | 77 StyleSheetContents* contents() const { return m_contents.get(); } |
| 99 | 78 |
| 100 bool isInline() const { return m_isInlineStylesheet; } | 79 bool isInline() const { return m_isInlineStylesheet; } |
| 101 TextPosition startPositionInSource() const { return m_startPosition; } | 80 TextPosition startPositionInSource() const { return m_startPosition; } |
| 102 | 81 |
| 103 private: | 82 private: |
| 104 CSSStyleSheet(PassRefPtr<StyleSheetContents>); | 83 CSSStyleSheet(PassRefPtr<StyleSheetContents>); |
| 105 CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode, bool isInline
Stylesheet, const TextPosition& startPosition); | 84 CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode, bool isInline
Stylesheet, const TextPosition& startPosition); |
| 106 | 85 |
| 107 virtual bool isCSSStyleSheet() const override { return true; } | 86 virtual bool isCSSStyleSheet() const override { return true; } |
| 108 virtual String type() const override { return "text/css"; } | 87 virtual String type() const override { return "text/css"; } |
| 109 | 88 |
| 110 void reattachChildRuleCSSOMWrappers(); | |
| 111 | |
| 112 RefPtr<StyleSheetContents> m_contents; | 89 RefPtr<StyleSheetContents> m_contents; |
| 113 bool m_isInlineStylesheet; | 90 bool m_isInlineStylesheet; |
| 114 RefPtr<MediaQuerySet> m_mediaQueries; | 91 RefPtr<MediaQuerySet> m_mediaQueries; |
| 115 | 92 |
| 116 RawPtr<Node> m_ownerNode; | 93 RawPtr<Node> m_ownerNode; |
| 117 | 94 |
| 118 TextPosition m_startPosition; | 95 TextPosition m_startPosition; |
| 119 mutable RefPtr<MediaList> m_mediaCSSOMWrapper; | |
| 120 mutable Vector<RefPtr<CSSRule> > m_childRuleCSSOMWrappers; | |
| 121 mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper; | |
| 122 }; | 96 }; |
| 123 | 97 |
| 124 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet) | 98 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet) |
| 125 : m_styleSheet(sheet) | 99 : m_styleSheet(sheet) |
| 126 { | 100 { |
| 127 if (m_styleSheet) | 101 if (m_styleSheet) |
| 128 m_styleSheet->willMutateRules(); | 102 m_styleSheet->willMutateRules(); |
| 129 } | 103 } |
| 130 | 104 |
| 131 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSRule* rule) | |
| 132 : m_styleSheet(rule ? rule->parentStyleSheet() : 0) | |
| 133 { | |
| 134 if (m_styleSheet) | |
| 135 m_styleSheet->willMutateRules(); | |
| 136 } | |
| 137 | |
| 138 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope() | 105 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope() |
| 139 { | 106 { |
| 140 if (m_styleSheet) | 107 if (m_styleSheet) |
| 141 m_styleSheet->didMutateRules(); | 108 m_styleSheet->didMutateRules(); |
| 142 } | 109 } |
| 143 | 110 |
| 144 DEFINE_TYPE_CASTS(CSSStyleSheet, StyleSheet, sheet, sheet->isCSSStyleSheet(), sh
eet.isCSSStyleSheet()); | 111 DEFINE_TYPE_CASTS(CSSStyleSheet, StyleSheet, sheet, sheet->isCSSStyleSheet(), sh
eet.isCSSStyleSheet()); |
| 145 | 112 |
| 146 } // namespace blink | 113 } // namespace blink |
| 147 | 114 |
| 148 #endif // SKY_ENGINE_CORE_CSS_CSSSTYLESHEET_H_ | 115 #endif // SKY_ENGINE_CORE_CSS_CSSSTYLESHEET_H_ |
| OLD | NEW |