OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 RefPtrWillBeRawPtr<StyleSheetContents> sheet = StyleSheetContents::create(CS
SParserContext(UASheetMode, 0)); | 67 RefPtrWillBeRawPtr<StyleSheetContents> sheet = StyleSheetContents::create(CS
SParserContext(UASheetMode, 0)); |
68 sheet->parseString(str); | 68 sheet->parseString(str); |
69 // User Agent stylesheets are parsed once for the lifetime of the renderer | 69 // User Agent stylesheets are parsed once for the lifetime of the renderer |
70 // and are intentionally leaked. | 70 // and are intentionally leaked. |
71 WTF_ANNOTATE_LEAKING_OBJECT_PTR(sheet.get()); | 71 WTF_ANNOTATE_LEAKING_OBJECT_PTR(sheet.get()); |
72 return sheet.release(); | 72 return sheet.release(); |
73 } | 73 } |
74 | 74 |
75 CSSDefaultStyleSheets::CSSDefaultStyleSheets() | 75 CSSDefaultStyleSheets::CSSDefaultStyleSheets() |
76 : m_defaultStyle(nullptr) | 76 : m_defaultStyle(nullptr) |
77 , m_defaultViewportStyle(nullptr) | 77 , m_defaultMobileViewportStyle(nullptr) |
78 , m_defaultQuirksStyle(nullptr) | 78 , m_defaultQuirksStyle(nullptr) |
79 , m_defaultPrintStyle(nullptr) | 79 , m_defaultPrintStyle(nullptr) |
80 , m_defaultViewSourceStyle(nullptr) | 80 , m_defaultViewSourceStyle(nullptr) |
81 , m_defaultXHTMLMobileProfileStyle(nullptr) | 81 , m_defaultXHTMLMobileProfileStyle(nullptr) |
82 , m_defaultTransitionStyle(nullptr) | 82 , m_defaultTransitionStyle(nullptr) |
83 , m_defaultStyleSheet(nullptr) | 83 , m_defaultStyleSheet(nullptr) |
84 , m_viewportStyleSheet(nullptr) | 84 , m_mobileViewportStyleSheet(nullptr) |
85 , m_quirksStyleSheet(nullptr) | 85 , m_quirksStyleSheet(nullptr) |
86 , m_svgStyleSheet(nullptr) | 86 , m_svgStyleSheet(nullptr) |
87 , m_mathmlStyleSheet(nullptr) | 87 , m_mathmlStyleSheet(nullptr) |
88 , m_mediaControlsStyleSheet(nullptr) | 88 , m_mediaControlsStyleSheet(nullptr) |
89 , m_fullscreenStyleSheet(nullptr) | 89 , m_fullscreenStyleSheet(nullptr) |
90 { | 90 { |
91 m_defaultStyle = RuleSet::create(); | 91 m_defaultStyle = RuleSet::create(); |
92 m_defaultViewportStyle = RuleSet::create(); | |
93 m_defaultPrintStyle = RuleSet::create(); | 92 m_defaultPrintStyle = RuleSet::create(); |
94 m_defaultQuirksStyle = RuleSet::create(); | 93 m_defaultQuirksStyle = RuleSet::create(); |
95 | 94 |
96 // Strict-mode rules. | 95 // Strict-mode rules. |
97 String defaultRules = loadResourceAsASCIIString("html.css") + LayoutTheme::t
heme().extraDefaultStyleSheet(); | 96 String defaultRules = loadResourceAsASCIIString("html.css") + LayoutTheme::t
heme().extraDefaultStyleSheet(); |
98 m_defaultStyleSheet = parseUASheet(defaultRules); | 97 m_defaultStyleSheet = parseUASheet(defaultRules); |
99 m_defaultStyle->addRulesFromSheet(defaultStyleSheet(), screenEval()); | 98 m_defaultStyle->addRulesFromSheet(defaultStyleSheet(), screenEval()); |
100 #if OS(ANDROID) | |
101 String viewportRules = loadResourceAsASCIIString("viewportAndroid.css"); | |
102 #else | |
103 String viewportRules; | |
104 #endif | |
105 m_viewportStyleSheet = parseUASheet(viewportRules); | |
106 m_defaultViewportStyle->addRulesFromSheet(viewportStyleSheet(), screenEval()
); | |
107 m_defaultPrintStyle->addRulesFromSheet(defaultStyleSheet(), printEval()); | 99 m_defaultPrintStyle->addRulesFromSheet(defaultStyleSheet(), printEval()); |
108 | 100 |
109 // Quirks-mode rules. | 101 // Quirks-mode rules. |
110 String quirksRules = loadResourceAsASCIIString("quirks.css") + LayoutTheme::
theme().extraQuirksStyleSheet(); | 102 String quirksRules = loadResourceAsASCIIString("quirks.css") + LayoutTheme::
theme().extraQuirksStyleSheet(); |
111 m_quirksStyleSheet = parseUASheet(quirksRules); | 103 m_quirksStyleSheet = parseUASheet(quirksRules); |
112 m_defaultQuirksStyle->addRulesFromSheet(quirksStyleSheet(), screenEval()); | 104 m_defaultQuirksStyle->addRulesFromSheet(quirksStyleSheet(), screenEval()); |
113 } | 105 } |
114 | 106 |
115 RuleSet* CSSDefaultStyleSheets::defaultViewSourceStyle() | 107 RuleSet* CSSDefaultStyleSheets::defaultViewSourceStyle() |
116 { | 108 { |
(...skipping 21 matching lines...) Expand all Loading... |
138 { | 130 { |
139 if (!m_defaultXHTMLMobileProfileStyle) { | 131 if (!m_defaultXHTMLMobileProfileStyle) { |
140 m_defaultXHTMLMobileProfileStyle = RuleSet::create(); | 132 m_defaultXHTMLMobileProfileStyle = RuleSet::create(); |
141 // Loaded stylesheet is leaked on purpose. | 133 // Loaded stylesheet is leaked on purpose. |
142 RefPtrWillBeRawPtr<StyleSheetContents> stylesheet = parseUASheet(loadRes
ourceAsASCIIString("xhtmlmp.css")); | 134 RefPtrWillBeRawPtr<StyleSheetContents> stylesheet = parseUASheet(loadRes
ourceAsASCIIString("xhtmlmp.css")); |
143 m_defaultXHTMLMobileProfileStyle->addRulesFromSheet(stylesheet.release()
.leakRef(), screenEval()); | 135 m_defaultXHTMLMobileProfileStyle->addRulesFromSheet(stylesheet.release()
.leakRef(), screenEval()); |
144 } | 136 } |
145 return m_defaultXHTMLMobileProfileStyle.get(); | 137 return m_defaultXHTMLMobileProfileStyle.get(); |
146 } | 138 } |
147 | 139 |
| 140 RuleSet* CSSDefaultStyleSheets::defaultMobileViewportStyle() |
| 141 { |
| 142 if (!m_defaultMobileViewportStyle) { |
| 143 m_defaultMobileViewportStyle = RuleSet::create(); |
| 144 m_mobileViewportStyleSheet = parseUASheet(loadResourceAsASCIIString("vie
wportAndroid.css")); |
| 145 m_defaultMobileViewportStyle->addRulesFromSheet(m_mobileViewportStyleShe
et.get(), screenEval()); |
| 146 } |
| 147 return m_defaultMobileViewportStyle.get(); |
| 148 } |
| 149 |
148 void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element* element,
bool& changedDefaultStyle) | 150 void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element* element,
bool& changedDefaultStyle) |
149 { | 151 { |
150 // FIXME: We should assert that the sheet only styles SVG elements. | 152 // FIXME: We should assert that the sheet only styles SVG elements. |
151 if (element->isSVGElement() && !m_svgStyleSheet) { | 153 if (element->isSVGElement() && !m_svgStyleSheet) { |
152 m_svgStyleSheet = parseUASheet(loadResourceAsASCIIString("svg.css")); | 154 m_svgStyleSheet = parseUASheet(loadResourceAsASCIIString("svg.css")); |
153 m_defaultStyle->addRulesFromSheet(svgStyleSheet(), screenEval()); | 155 m_defaultStyle->addRulesFromSheet(svgStyleSheet(), screenEval()); |
154 m_defaultPrintStyle->addRulesFromSheet(svgStyleSheet(), printEval()); | 156 m_defaultPrintStyle->addRulesFromSheet(svgStyleSheet(), printEval()); |
155 changedDefaultStyle = true; | 157 changedDefaultStyle = true; |
156 } | 158 } |
157 | 159 |
(...skipping 25 matching lines...) Expand all Loading... |
183 changedDefaultStyle = true; | 185 changedDefaultStyle = true; |
184 } | 186 } |
185 | 187 |
186 ASSERT(!m_defaultStyle->features().hasIdsInSelectors()); | 188 ASSERT(!m_defaultStyle->features().hasIdsInSelectors()); |
187 ASSERT(m_defaultStyle->features().siblingRules.isEmpty()); | 189 ASSERT(m_defaultStyle->features().siblingRules.isEmpty()); |
188 } | 190 } |
189 | 191 |
190 DEFINE_TRACE(CSSDefaultStyleSheets) | 192 DEFINE_TRACE(CSSDefaultStyleSheets) |
191 { | 193 { |
192 visitor->trace(m_defaultStyle); | 194 visitor->trace(m_defaultStyle); |
193 visitor->trace(m_defaultViewportStyle); | 195 visitor->trace(m_defaultMobileViewportStyle); |
194 visitor->trace(m_defaultQuirksStyle); | 196 visitor->trace(m_defaultQuirksStyle); |
195 visitor->trace(m_defaultPrintStyle); | 197 visitor->trace(m_defaultPrintStyle); |
196 visitor->trace(m_defaultViewSourceStyle); | 198 visitor->trace(m_defaultViewSourceStyle); |
197 visitor->trace(m_defaultXHTMLMobileProfileStyle); | 199 visitor->trace(m_defaultXHTMLMobileProfileStyle); |
198 visitor->trace(m_defaultTransitionStyle); | 200 visitor->trace(m_defaultTransitionStyle); |
199 visitor->trace(m_defaultStyleSheet); | 201 visitor->trace(m_defaultStyleSheet); |
200 visitor->trace(m_viewportStyleSheet); | |
201 visitor->trace(m_quirksStyleSheet); | 202 visitor->trace(m_quirksStyleSheet); |
202 visitor->trace(m_svgStyleSheet); | 203 visitor->trace(m_svgStyleSheet); |
203 visitor->trace(m_mathmlStyleSheet); | 204 visitor->trace(m_mathmlStyleSheet); |
204 visitor->trace(m_mediaControlsStyleSheet); | 205 visitor->trace(m_mediaControlsStyleSheet); |
205 visitor->trace(m_fullscreenStyleSheet); | 206 visitor->trace(m_fullscreenStyleSheet); |
206 } | 207 } |
207 | 208 |
208 } // namespace blink | 209 } // namespace blink |
OLD | NEW |