| 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 | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All |
| 6 * rights reserved. | 6 * rights reserved. |
| 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 static StyleSheetContents* parseUASheet(const String& str) { | 66 static StyleSheetContents* parseUASheet(const String& str) { |
| 67 StyleSheetContents* sheet = | 67 StyleSheetContents* sheet = |
| 68 StyleSheetContents::create(CSSParserContext(UASheetMode, nullptr)); | 68 StyleSheetContents::create(CSSParserContext(UASheetMode, nullptr)); |
| 69 sheet->parseString(str); | 69 sheet->parseString(str); |
| 70 // User Agent stylesheets are parsed once for the lifetime of the renderer | 70 // User Agent stylesheets are parsed once for the lifetime of the renderer |
| 71 // process and are intentionally leaked. | 71 // process and are intentionally leaked. |
| 72 LEAK_SANITIZER_IGNORE_OBJECT(sheet); | 72 LEAK_SANITIZER_IGNORE_OBJECT(sheet); |
| 73 return sheet; | 73 return sheet; |
| 74 } | 74 } |
| 75 | 75 |
| 76 CSSDefaultStyleSheets::CSSDefaultStyleSheets() | 76 CSSDefaultStyleSheets::CSSDefaultStyleSheets() { |
| 77 : m_defaultStyle(nullptr), | |
| 78 m_defaultMobileViewportStyle(nullptr), | |
| 79 m_defaultTelevisionViewportStyle(nullptr), | |
| 80 m_defaultQuirksStyle(nullptr), | |
| 81 m_defaultPrintStyle(nullptr), | |
| 82 m_defaultViewSourceStyle(nullptr), | |
| 83 m_defaultXHTMLMobileProfileStyle(nullptr), | |
| 84 m_defaultStyleSheet(nullptr), | |
| 85 m_mobileViewportStyleSheet(nullptr), | |
| 86 m_televisionViewportStyleSheet(nullptr), | |
| 87 m_quirksStyleSheet(nullptr), | |
| 88 m_svgStyleSheet(nullptr), | |
| 89 m_mathmlStyleSheet(nullptr), | |
| 90 m_mediaControlsStyleSheet(nullptr), | |
| 91 m_fullscreenStyleSheet(nullptr) { | |
| 92 m_defaultStyle = RuleSet::create(); | 77 m_defaultStyle = RuleSet::create(); |
| 93 m_defaultPrintStyle = RuleSet::create(); | 78 m_defaultPrintStyle = RuleSet::create(); |
| 94 m_defaultQuirksStyle = RuleSet::create(); | 79 m_defaultQuirksStyle = RuleSet::create(); |
| 95 | 80 |
| 96 // Strict-mode rules. | 81 // Strict-mode rules. |
| 97 String defaultRules = loadResourceAsASCIIString("html.css") + | 82 String defaultRules = loadResourceAsASCIIString("html.css") + |
| 98 LayoutTheme::theme().extraDefaultStyleSheet(); | 83 LayoutTheme::theme().extraDefaultStyleSheet(); |
| 99 m_defaultStyleSheet = parseUASheet(defaultRules); | 84 m_defaultStyleSheet = parseUASheet(defaultRules); |
| 100 m_defaultStyle->addRulesFromSheet(defaultStyleSheet(), screenEval()); | 85 m_defaultStyle->addRulesFromSheet(defaultStyleSheet(), screenEval()); |
| 101 m_defaultPrintStyle->addRulesFromSheet(defaultStyleSheet(), printEval()); | 86 m_defaultPrintStyle->addRulesFromSheet(defaultStyleSheet(), printEval()); |
| 102 | 87 |
| 103 // Quirks-mode rules. | 88 // Quirks-mode rules. |
| 104 String quirksRules = loadResourceAsASCIIString("quirks.css") + | 89 String quirksRules = loadResourceAsASCIIString("quirks.css") + |
| 105 LayoutTheme::theme().extraQuirksStyleSheet(); | 90 LayoutTheme::theme().extraQuirksStyleSheet(); |
| 106 m_quirksStyleSheet = parseUASheet(quirksRules); | 91 m_quirksStyleSheet = parseUASheet(quirksRules); |
| 107 m_defaultQuirksStyle->addRulesFromSheet(quirksStyleSheet(), screenEval()); | 92 m_defaultQuirksStyle->addRulesFromSheet(quirksStyleSheet(), screenEval()); |
| 108 } | 93 } |
| 109 | 94 |
| 110 RuleSet* CSSDefaultStyleSheets::defaultViewSourceStyle() { | 95 RuleSet* CSSDefaultStyleSheets::defaultViewSourceStyle() { |
| 111 if (!m_defaultViewSourceStyle) { | 96 if (!m_defaultViewSourceStyle) { |
| 112 m_defaultViewSourceStyle = RuleSet::create(); | 97 m_defaultViewSourceStyle = RuleSet::create(); |
| 113 // Loaded stylesheet is leaked on purpose. | 98 // Loaded stylesheet is leaked on purpose. |
| 114 StyleSheetContents* stylesheet = | 99 StyleSheetContents* stylesheet = |
| 115 parseUASheet(loadResourceAsASCIIString("view-source.css")); | 100 parseUASheet(loadResourceAsASCIIString("view-source.css")); |
| 116 m_defaultViewSourceStyle->addRulesFromSheet(stylesheet, screenEval()); | 101 m_defaultViewSourceStyle->addRulesFromSheet(stylesheet, screenEval()); |
| 117 } | 102 } |
| 118 return m_defaultViewSourceStyle.get(); | 103 return m_defaultViewSourceStyle.get(); |
| 119 } | 104 } |
| 120 | 105 |
| 121 RuleSet* CSSDefaultStyleSheets::defaultXHTMLMobileProfileStyle() { | 106 StyleSheetContents* |
| 122 if (!m_defaultXHTMLMobileProfileStyle) { | 107 CSSDefaultStyleSheets::ensureXHTMLMobileProfileStyleSheet() { |
| 123 m_defaultXHTMLMobileProfileStyle = RuleSet::create(); | 108 if (!m_xhtmlMobileProfileStyleSheet) |
| 124 // Loaded stylesheet is leaked on purpose. | 109 m_xhtmlMobileProfileStyleSheet = |
| 125 StyleSheetContents* stylesheet = | |
| 126 parseUASheet(loadResourceAsASCIIString("xhtmlmp.css")); | 110 parseUASheet(loadResourceAsASCIIString("xhtmlmp.css")); |
| 127 m_defaultXHTMLMobileProfileStyle->addRulesFromSheet(stylesheet, | 111 return m_xhtmlMobileProfileStyleSheet.get(); |
| 128 screenEval()); | |
| 129 } | |
| 130 return m_defaultXHTMLMobileProfileStyle.get(); | |
| 131 } | 112 } |
| 132 | 113 |
| 133 RuleSet* CSSDefaultStyleSheets::defaultMobileViewportStyle() { | 114 StyleSheetContents* CSSDefaultStyleSheets::ensureMobileViewportStyleSheet() { |
| 134 if (!m_defaultMobileViewportStyle) { | 115 if (!m_mobileViewportStyleSheet) |
| 135 m_defaultMobileViewportStyle = RuleSet::create(); | |
| 136 m_mobileViewportStyleSheet = | 116 m_mobileViewportStyleSheet = |
| 137 parseUASheet(loadResourceAsASCIIString("viewportAndroid.css")); | 117 parseUASheet(loadResourceAsASCIIString("viewportAndroid.css")); |
| 138 m_defaultMobileViewportStyle->addRulesFromSheet( | 118 return m_mobileViewportStyleSheet.get(); |
| 139 m_mobileViewportStyleSheet.get(), screenEval()); | |
| 140 } | |
| 141 return m_defaultMobileViewportStyle.get(); | |
| 142 } | 119 } |
| 143 | 120 |
| 144 RuleSet* CSSDefaultStyleSheets::defaultTelevisionViewportStyle() { | 121 StyleSheetContents* |
| 145 if (!m_defaultTelevisionViewportStyle) { | 122 CSSDefaultStyleSheets::ensureTelevisionViewportStyleSheet() { |
| 146 m_defaultTelevisionViewportStyle = RuleSet::create(); | 123 if (!m_televisionViewportStyleSheet) |
| 147 m_televisionViewportStyleSheet = | 124 m_televisionViewportStyleSheet = |
| 148 parseUASheet(loadResourceAsASCIIString("viewportTelevision.css")); | 125 parseUASheet(loadResourceAsASCIIString("viewportTelevision.css")); |
| 149 m_defaultTelevisionViewportStyle->addRulesFromSheet( | 126 return m_televisionViewportStyleSheet.get(); |
| 150 m_televisionViewportStyleSheet.get(), screenEval()); | |
| 151 } | |
| 152 return m_defaultTelevisionViewportStyle.get(); | |
| 153 } | 127 } |
| 154 | 128 |
| 155 void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement( | 129 void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement( |
| 156 const Element& element, | 130 const Element& element, |
| 157 bool& changedDefaultStyle) { | 131 bool& changedDefaultStyle) { |
| 158 // FIXME: We should assert that the sheet only styles SVG elements. | 132 // FIXME: We should assert that the sheet only styles SVG elements. |
| 159 if (element.isSVGElement() && !m_svgStyleSheet) { | 133 if (element.isSVGElement() && !m_svgStyleSheet) { |
| 160 m_svgStyleSheet = parseUASheet(loadResourceAsASCIIString("svg.css")); | 134 m_svgStyleSheet = parseUASheet(loadResourceAsASCIIString("svg.css")); |
| 161 m_defaultStyle->addRulesFromSheet(svgStyleSheet(), screenEval()); | 135 m_defaultStyle->addRulesFromSheet(svgStyleSheet(), screenEval()); |
| 162 m_defaultPrintStyle->addRulesFromSheet(svgStyleSheet(), printEval()); | 136 m_defaultPrintStyle->addRulesFromSheet(svgStyleSheet(), printEval()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 172 |
| 199 String fullscreenRules = loadResourceAsASCIIString("fullscreen.css") + | 173 String fullscreenRules = loadResourceAsASCIIString("fullscreen.css") + |
| 200 LayoutTheme::theme().extraFullscreenStyleSheet(); | 174 LayoutTheme::theme().extraFullscreenStyleSheet(); |
| 201 m_fullscreenStyleSheet = parseUASheet(fullscreenRules); | 175 m_fullscreenStyleSheet = parseUASheet(fullscreenRules); |
| 202 m_defaultStyle->addRulesFromSheet(fullscreenStyleSheet(), screenEval()); | 176 m_defaultStyle->addRulesFromSheet(fullscreenStyleSheet(), screenEval()); |
| 203 m_defaultQuirksStyle->addRulesFromSheet(fullscreenStyleSheet(), screenEval()); | 177 m_defaultQuirksStyle->addRulesFromSheet(fullscreenStyleSheet(), screenEval()); |
| 204 } | 178 } |
| 205 | 179 |
| 206 DEFINE_TRACE(CSSDefaultStyleSheets) { | 180 DEFINE_TRACE(CSSDefaultStyleSheets) { |
| 207 visitor->trace(m_defaultStyle); | 181 visitor->trace(m_defaultStyle); |
| 208 visitor->trace(m_defaultMobileViewportStyle); | |
| 209 visitor->trace(m_defaultTelevisionViewportStyle); | |
| 210 visitor->trace(m_defaultQuirksStyle); | 182 visitor->trace(m_defaultQuirksStyle); |
| 211 visitor->trace(m_defaultPrintStyle); | 183 visitor->trace(m_defaultPrintStyle); |
| 212 visitor->trace(m_defaultViewSourceStyle); | 184 visitor->trace(m_defaultViewSourceStyle); |
| 213 visitor->trace(m_defaultXHTMLMobileProfileStyle); | |
| 214 visitor->trace(m_defaultStyleSheet); | 185 visitor->trace(m_defaultStyleSheet); |
| 215 visitor->trace(m_mobileViewportStyleSheet); | 186 visitor->trace(m_mobileViewportStyleSheet); |
| 216 visitor->trace(m_televisionViewportStyleSheet); | 187 visitor->trace(m_televisionViewportStyleSheet); |
| 188 visitor->trace(m_xhtmlMobileProfileStyleSheet); |
| 217 visitor->trace(m_quirksStyleSheet); | 189 visitor->trace(m_quirksStyleSheet); |
| 218 visitor->trace(m_svgStyleSheet); | 190 visitor->trace(m_svgStyleSheet); |
| 219 visitor->trace(m_mathmlStyleSheet); | 191 visitor->trace(m_mathmlStyleSheet); |
| 220 visitor->trace(m_mediaControlsStyleSheet); | 192 visitor->trace(m_mediaControlsStyleSheet); |
| 221 visitor->trace(m_fullscreenStyleSheet); | 193 visitor->trace(m_fullscreenStyleSheet); |
| 222 } | 194 } |
| 223 | 195 |
| 224 } // namespace blink | 196 } // namespace blink |
| OLD | NEW |