Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: sky/engine/core/css/CSSStyleSheet.h

Issue 778743003: Merge StyleSheet into CSSStyleSheet. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: sort headers. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/core.gni ('k') | sky/engine/core/css/CSSStyleSheet.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/StyleSheet.h"
25 #include "sky/engine/platform/heap/Handle.h"
26 #include "sky/engine/wtf/Noncopyable.h" 24 #include "sky/engine/wtf/Noncopyable.h"
25 #include "sky/engine/wtf/RefCounted.h"
27 #include "sky/engine/wtf/text/TextPosition.h" 26 #include "sky/engine/wtf/text/TextPosition.h"
28 27
29 namespace blink { 28 namespace blink {
30 29
31 class BisonCSSParser; 30 class BisonCSSParser;
32 class CSSStyleSheet; 31 class CSSStyleSheet;
33 class Document; 32 class Document;
34 class ExceptionState; 33 class ExceptionState;
34 class KURL;
35 class MediaQuerySet; 35 class MediaQuerySet;
36 class Node;
36 class StyleSheetContents; 37 class StyleSheetContents;
37 38
38 enum StyleSheetUpdateType { 39 enum StyleSheetUpdateType {
39 PartialRuleUpdate, 40 PartialRuleUpdate,
40 EntireStyleSheetUpdate 41 EntireStyleSheetUpdate
41 }; 42 };
42 43
43 class CSSStyleSheet final : public StyleSheet { 44 class CSSStyleSheet final : public RefCounted<CSSStyleSheet> {
44 public: 45 public:
45 static PassRefPtr<CSSStyleSheet> createInline(Node*, const KURL&, const Text Position& startPosition = TextPosition::minimumPosition()); 46 static PassRefPtr<CSSStyleSheet> createInline(Node*, const KURL&, const Text Position& startPosition = TextPosition::minimumPosition());
46 static PassRefPtr<CSSStyleSheet> createInline(PassRefPtr<StyleSheetContents> , Node* ownerNode, const TextPosition& startPosition = TextPosition::minimumPosi tion()); 47 static PassRefPtr<CSSStyleSheet> createInline(PassRefPtr<StyleSheetContents> , Node* ownerNode, const TextPosition& startPosition = TextPosition::minimumPosi tion());
47 48
48 virtual ~CSSStyleSheet(); 49 ~CSSStyleSheet();
49 50
50 virtual Node* ownerNode() const override { return m_ownerNode; } 51 Node* ownerNode() const { return m_ownerNode; }
51 52
52 unsigned length() const; 53 unsigned length() const;
53 54
54 virtual void clearOwnerNode() override; 55 void clearOwnerNode();
55 56
56 virtual KURL baseURL() const override; 57 KURL baseURL() const;
57 58
58 Document* ownerDocument() const; 59 Document* ownerDocument() const;
59 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } 60 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
60 void setMediaQueries(PassRefPtr<MediaQuerySet>); 61 void setMediaQueries(PassRefPtr<MediaQuerySet>);
61 62
62 class RuleMutationScope {
63 WTF_MAKE_NONCOPYABLE(RuleMutationScope);
64 STACK_ALLOCATED();
65 public:
66 explicit RuleMutationScope(CSSStyleSheet*);
67 ~RuleMutationScope();
68
69 private:
70 RawPtr<CSSStyleSheet> m_styleSheet;
71 };
72
73 void willMutateRules();
74 void didMutateRules();
75 void didMutate(StyleSheetUpdateType = PartialRuleUpdate);
76
77 StyleSheetContents* contents() const { return m_contents.get(); } 63 StyleSheetContents* contents() const { return m_contents.get(); }
78 64
79 bool isInline() const { return m_isInlineStylesheet; } 65 bool isInline() const { return m_isInlineStylesheet; }
80 TextPosition startPositionInSource() const { return m_startPosition; } 66 TextPosition startPositionInSource() const { return m_startPosition; }
81 67
68 // TODO(esprehn): Remove this.
69 String type() const { return "text/css"; }
70
82 private: 71 private:
83 CSSStyleSheet(PassRefPtr<StyleSheetContents>); 72 CSSStyleSheet(PassRefPtr<StyleSheetContents>);
84 CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode, bool isInline Stylesheet, const TextPosition& startPosition); 73 CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode, bool isInline Stylesheet, const TextPosition& startPosition);
85 74
86 virtual bool isCSSStyleSheet() const override { return true; }
87 virtual String type() const override { return "text/css"; }
88
89 RefPtr<StyleSheetContents> m_contents; 75 RefPtr<StyleSheetContents> m_contents;
90 bool m_isInlineStylesheet; 76 bool m_isInlineStylesheet;
91 RefPtr<MediaQuerySet> m_mediaQueries; 77 RefPtr<MediaQuerySet> m_mediaQueries;
92 78
93 RawPtr<Node> m_ownerNode; 79 Node* m_ownerNode;
94 80
95 TextPosition m_startPosition; 81 TextPosition m_startPosition;
96 }; 82 };
97 83
98 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet)
99 : m_styleSheet(sheet)
100 {
101 if (m_styleSheet)
102 m_styleSheet->willMutateRules();
103 }
104
105 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope()
106 {
107 if (m_styleSheet)
108 m_styleSheet->didMutateRules();
109 }
110
111 DEFINE_TYPE_CASTS(CSSStyleSheet, StyleSheet, sheet, sheet->isCSSStyleSheet(), sh eet.isCSSStyleSheet());
112
113 } // namespace blink 84 } // namespace blink
114 85
115 #endif // SKY_ENGINE_CORE_CSS_CSSSTYLESHEET_H_ 86 #endif // SKY_ENGINE_CORE_CSS_CSSSTYLESHEET_H_
OLDNEW
« no previous file with comments | « sky/engine/core/core.gni ('k') | sky/engine/core/css/CSSStyleSheet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698