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 11 matching lines...) Expand all Loading... |
22 * | 22 * |
23 * You should have received a copy of the GNU Library General Public License | 23 * You should have received a copy of the GNU Library General Public License |
24 * along with this library; see the file COPYING.LIB. If not, write to | 24 * along with this library; see the file COPYING.LIB. If not, write to |
25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "core/css/CSSDefaultStyleSheets.h" | 30 #include "core/css/CSSDefaultStyleSheets.h" |
31 | 31 |
| 32 #include "MathMLNames.h" |
32 #include "UserAgentStyleSheets.h" | 33 #include "UserAgentStyleSheets.h" |
33 #include "core/css/MediaQueryEvaluator.h" | 34 #include "core/css/MediaQueryEvaluator.h" |
34 #include "core/css/RuleSet.h" | 35 #include "core/css/RuleSet.h" |
35 #include "core/css/StyleSheetContents.h" | 36 #include "core/css/StyleSheetContents.h" |
36 #include "core/dom/FullscreenElementStack.h" | 37 #include "core/dom/FullscreenElementStack.h" |
37 #include "core/html/HTMLAnchorElement.h" | 38 #include "core/html/HTMLAnchorElement.h" |
38 #include "core/html/HTMLHtmlElement.h" | 39 #include "core/html/HTMLHtmlElement.h" |
39 #include "core/rendering/RenderTheme.h" | 40 #include "core/rendering/RenderTheme.h" |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 using namespace HTMLNames; | 44 using namespace HTMLNames; |
44 | 45 |
45 RuleSet* CSSDefaultStyleSheets::defaultStyle; | 46 RuleSet* CSSDefaultStyleSheets::defaultStyle; |
46 RuleSet* CSSDefaultStyleSheets::defaultViewportStyle; | 47 RuleSet* CSSDefaultStyleSheets::defaultViewportStyle; |
47 RuleSet* CSSDefaultStyleSheets::defaultQuirksStyle; | 48 RuleSet* CSSDefaultStyleSheets::defaultQuirksStyle; |
48 RuleSet* CSSDefaultStyleSheets::defaultPrintStyle; | 49 RuleSet* CSSDefaultStyleSheets::defaultPrintStyle; |
49 RuleSet* CSSDefaultStyleSheets::defaultViewSourceStyle; | 50 RuleSet* CSSDefaultStyleSheets::defaultViewSourceStyle; |
50 RuleSet* CSSDefaultStyleSheets::defaultXHTMLMobileProfileStyle; | 51 RuleSet* CSSDefaultStyleSheets::defaultXHTMLMobileProfileStyle; |
51 | 52 |
52 StyleSheetContents* CSSDefaultStyleSheets::defaultStyleSheet; | 53 StyleSheetContents* CSSDefaultStyleSheets::defaultStyleSheet; |
53 StyleSheetContents* CSSDefaultStyleSheets::viewportStyleSheet; | 54 StyleSheetContents* CSSDefaultStyleSheets::viewportStyleSheet; |
54 StyleSheetContents* CSSDefaultStyleSheets::quirksStyleSheet; | 55 StyleSheetContents* CSSDefaultStyleSheets::quirksStyleSheet; |
55 StyleSheetContents* CSSDefaultStyleSheets::svgStyleSheet; | 56 StyleSheetContents* CSSDefaultStyleSheets::svgStyleSheet; |
| 57 StyleSheetContents* CSSDefaultStyleSheets::mathmlStyleSheet; |
56 StyleSheetContents* CSSDefaultStyleSheets::mediaControlsStyleSheet; | 58 StyleSheetContents* CSSDefaultStyleSheets::mediaControlsStyleSheet; |
57 StyleSheetContents* CSSDefaultStyleSheets::fullscreenStyleSheet; | 59 StyleSheetContents* CSSDefaultStyleSheets::fullscreenStyleSheet; |
58 | 60 |
59 static const MediaQueryEvaluator& screenEval() | 61 static const MediaQueryEvaluator& screenEval() |
60 { | 62 { |
61 DEFINE_STATIC_LOCAL(const MediaQueryEvaluator, staticScreenEval, ("screen"))
; | 63 DEFINE_STATIC_LOCAL(const MediaQueryEvaluator, staticScreenEval, ("screen"))
; |
62 return staticScreenEval; | 64 return staticScreenEval; |
63 } | 65 } |
64 | 66 |
65 static const MediaQueryEvaluator& printEval() | 67 static const MediaQueryEvaluator& printEval() |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element* element,
bool& changedDefaultStyle) | 136 void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element* element,
bool& changedDefaultStyle) |
135 { | 137 { |
136 // FIXME: We should assert that the sheet only styles SVG elements. | 138 // FIXME: We should assert that the sheet only styles SVG elements. |
137 if (element->isSVGElement() && !svgStyleSheet) { | 139 if (element->isSVGElement() && !svgStyleSheet) { |
138 svgStyleSheet = parseUASheet(svgUserAgentStyleSheet, sizeof(svgUserAgent
StyleSheet)); | 140 svgStyleSheet = parseUASheet(svgUserAgentStyleSheet, sizeof(svgUserAgent
StyleSheet)); |
139 defaultStyle->addRulesFromSheet(svgStyleSheet, screenEval()); | 141 defaultStyle->addRulesFromSheet(svgStyleSheet, screenEval()); |
140 defaultPrintStyle->addRulesFromSheet(svgStyleSheet, printEval()); | 142 defaultPrintStyle->addRulesFromSheet(svgStyleSheet, printEval()); |
141 changedDefaultStyle = true; | 143 changedDefaultStyle = true; |
142 } | 144 } |
143 | 145 |
| 146 // FIXME: We should assert that the sheet only styles MathML elements. |
| 147 if (element->namespaceURI() == MathMLNames::mathmlNamespaceURI |
| 148 && !mathmlStyleSheet) { |
| 149 mathmlStyleSheet = parseUASheet(mathmlUserAgentStyleSheet, |
| 150 sizeof(mathmlUserAgentStyleSheet)); |
| 151 defaultStyle->addRulesFromSheet(mathmlStyleSheet, screenEval()); |
| 152 defaultPrintStyle->addRulesFromSheet(mathmlStyleSheet, printEval()); |
| 153 changedDefaultStyle = true; |
| 154 } |
| 155 |
144 // FIXME: We should assert that this sheet only contains rules for <video> a
nd <audio>. | 156 // FIXME: We should assert that this sheet only contains rules for <video> a
nd <audio>. |
145 if (!mediaControlsStyleSheet && (element->hasTagName(videoTag) || element->h
asTagName(audioTag))) { | 157 if (!mediaControlsStyleSheet && (element->hasTagName(videoTag) || element->h
asTagName(audioTag))) { |
146 String mediaRules = String(mediaControlsUserAgentStyleSheet, sizeof(medi
aControlsUserAgentStyleSheet)) + RenderTheme::theme().extraMediaControlsStyleShe
et(); | 158 String mediaRules = String(mediaControlsUserAgentStyleSheet, sizeof(medi
aControlsUserAgentStyleSheet)) + RenderTheme::theme().extraMediaControlsStyleShe
et(); |
147 mediaControlsStyleSheet = parseUASheet(mediaRules); | 159 mediaControlsStyleSheet = parseUASheet(mediaRules); |
148 defaultStyle->addRulesFromSheet(mediaControlsStyleSheet, screenEval()); | 160 defaultStyle->addRulesFromSheet(mediaControlsStyleSheet, screenEval()); |
149 defaultPrintStyle->addRulesFromSheet(mediaControlsStyleSheet, printEval(
)); | 161 defaultPrintStyle->addRulesFromSheet(mediaControlsStyleSheet, printEval(
)); |
150 changedDefaultStyle = true; | 162 changedDefaultStyle = true; |
151 } | 163 } |
152 | 164 |
153 // FIXME: This only works because we Force recalc the entire document so the
new sheet | 165 // FIXME: This only works because we Force recalc the entire document so the
new sheet |
154 // is loaded for <html> and the correct styles apply to everyone. | 166 // is loaded for <html> and the correct styles apply to everyone. |
155 if (!fullscreenStyleSheet && FullscreenElementStack::isFullScreen(&element->
document())) { | 167 if (!fullscreenStyleSheet && FullscreenElementStack::isFullScreen(&element->
document())) { |
156 String fullscreenRules = String(fullscreenUserAgentStyleSheet, sizeof(fu
llscreenUserAgentStyleSheet)) + RenderTheme::theme().extraFullScreenStyleSheet()
; | 168 String fullscreenRules = String(fullscreenUserAgentStyleSheet, sizeof(fu
llscreenUserAgentStyleSheet)) + RenderTheme::theme().extraFullScreenStyleSheet()
; |
157 fullscreenStyleSheet = parseUASheet(fullscreenRules); | 169 fullscreenStyleSheet = parseUASheet(fullscreenRules); |
158 defaultStyle->addRulesFromSheet(fullscreenStyleSheet, screenEval()); | 170 defaultStyle->addRulesFromSheet(fullscreenStyleSheet, screenEval()); |
159 defaultQuirksStyle->addRulesFromSheet(fullscreenStyleSheet, screenEval()
); | 171 defaultQuirksStyle->addRulesFromSheet(fullscreenStyleSheet, screenEval()
); |
160 changedDefaultStyle = true; | 172 changedDefaultStyle = true; |
161 } | 173 } |
162 | 174 |
163 ASSERT(defaultStyle->features().idsInRules.isEmpty()); | 175 ASSERT(defaultStyle->features().idsInRules.isEmpty()); |
164 ASSERT(defaultStyle->features().siblingRules.isEmpty()); | 176 ASSERT(defaultStyle->features().siblingRules.isEmpty()); |
165 } | 177 } |
166 | 178 |
167 } // namespace WebCore | 179 } // namespace WebCore |
OLD | NEW |