| 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 15 matching lines...) Expand all Loading... |
| 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 "UserAgentStyleSheets.h" | 32 #include "UserAgentStyleSheets.h" |
| 33 #include "core/css/MediaQueryEvaluator.h" | 33 #include "core/css/MediaQueryEvaluator.h" |
| 34 #include "core/css/RuleSet.h" | 34 #include "core/css/RuleSet.h" |
| 35 #include "core/css/StyleSheetContents.h" | 35 #include "core/css/StyleSheetContents.h" |
| 36 #include "core/css/ViewportStyle.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/html/HTMLVideoElement.h" | 40 #include "core/html/HTMLVideoElement.h" |
| 40 #include "core/rendering/RenderTheme.h" | 41 #include "core/rendering/RenderTheme.h" |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 using namespace HTMLNames; | 45 using namespace HTMLNames; |
| 45 | 46 |
| 46 RuleSet* CSSDefaultStyleSheets::defaultStyle; | 47 RuleSet* CSSDefaultStyleSheets::defaultStyle; |
| 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::simpleDefaultStyleSheet; | 53 StyleSheetContents* CSSDefaultStyleSheets::simpleDefaultStyleSheet; |
| 53 StyleSheetContents* CSSDefaultStyleSheets::defaultStyleSheet; | 54 StyleSheetContents* CSSDefaultStyleSheets::defaultStyleSheet; |
| 54 StyleSheetContents* CSSDefaultStyleSheets::quirksStyleSheet; | 55 StyleSheetContents* CSSDefaultStyleSheets::quirksStyleSheet; |
| 55 StyleSheetContents* CSSDefaultStyleSheets::svgStyleSheet; | 56 StyleSheetContents* CSSDefaultStyleSheets::svgStyleSheet; |
| 56 StyleSheetContents* CSSDefaultStyleSheets::mediaControlsStyleSheet; | 57 StyleSheetContents* CSSDefaultStyleSheets::mediaControlsStyleSheet; |
| 57 StyleSheetContents* CSSDefaultStyleSheets::fullscreenStyleSheet; | 58 StyleSheetContents* CSSDefaultStyleSheets::fullscreenStyleSheet; |
| 58 | 59 |
| 59 // FIXME: It would be nice to use some mechanism that guarantees this is in sync
with the real UA stylesheet. | 60 // FIXME: It would be nice to use some mechanism that guarantees this is in sync
with the real UA stylesheet. |
| 60 static const char simpleUserAgentStyleSheet[] = "html,body,div{display:block}hea
d{display:none}body{margin:8px}div:focus,span:focus,a:focus{outline:auto 5px -we
bkit-focus-ring-color}a:-webkit-any-link{color:-webkit-link;text-decoration:unde
rline}a:-webkit-any-link:active{color:-webkit-activelink}body:-webkit-seamless-d
ocument{margin:0}body:-webkit-full-page-media{background-color:black}@viewport{m
in-width:980px}@page{size:auto;margin:auto;padding:0;border-width:0}"; | 61 static const char simpleUserAgentStyleSheet[] = "html,body,div{display:block}hea
d{display:none}body{margin:8px}div:focus,span:focus,a:focus{outline:auto 5px -we
bkit-focus-ring-color}a:-webkit-any-link{color:-webkit-link;text-decoration:unde
rline}a:-webkit-any-link:active{color:-webkit-activelink}body:-webkit-seamless-d
ocument{margin:0}body:-webkit-full-page-media{background-color:black}@page{size:
auto;margin:auto;padding:0;border-width:0}"; |
| 61 | 62 |
| 62 static inline bool elementCanUseSimpleDefaultStyle(Element* e) | 63 static inline bool elementCanUseSimpleDefaultStyle(Element* e) |
| 63 { | 64 { |
| 64 return isHTMLHtmlElement(e) || e->hasTagName(headTag) || e->hasTagName(bodyT
ag) || e->hasTagName(divTag) || e->hasTagName(spanTag) || e->hasTagName(brTag) |
| isHTMLAnchorElement(e); | 65 return isHTMLHtmlElement(e) || e->hasTagName(headTag) || e->hasTagName(bodyT
ag) || e->hasTagName(divTag) || e->hasTagName(spanTag) || e->hasTagName(brTag) |
| isHTMLAnchorElement(e); |
| 65 } | 66 } |
| 66 | 67 |
| 67 static const MediaQueryEvaluator& screenEval() | 68 static const MediaQueryEvaluator& screenEval() |
| 68 { | 69 { |
| 69 DEFINE_STATIC_LOCAL(const MediaQueryEvaluator, staticScreenEval, ("screen"))
; | 70 DEFINE_STATIC_LOCAL(const MediaQueryEvaluator, staticScreenEval, ("screen"))
; |
| 70 return staticScreenEval; | 71 return staticScreenEval; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ASSERT(!defaultStyle); | 113 ASSERT(!defaultStyle); |
| 113 defaultStyle = RuleSet::create().leakPtr(); | 114 defaultStyle = RuleSet::create().leakPtr(); |
| 114 defaultPrintStyle = RuleSet::create().leakPtr(); | 115 defaultPrintStyle = RuleSet::create().leakPtr(); |
| 115 defaultQuirksStyle = RuleSet::create().leakPtr(); | 116 defaultQuirksStyle = RuleSet::create().leakPtr(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 // Strict-mode rules. | 119 // Strict-mode rules. |
| 119 String defaultRules = String(htmlUserAgentStyleSheet, sizeof(htmlUserAgentSt
yleSheet)) + RenderTheme::theme().extraDefaultStyleSheet(); | 120 String defaultRules = String(htmlUserAgentStyleSheet, sizeof(htmlUserAgentSt
yleSheet)) + RenderTheme::theme().extraDefaultStyleSheet(); |
| 120 defaultStyleSheet = parseUASheet(defaultRules); | 121 defaultStyleSheet = parseUASheet(defaultRules); |
| 121 defaultStyle->addRulesFromSheet(defaultStyleSheet, screenEval()); | 122 defaultStyle->addRulesFromSheet(defaultStyleSheet, screenEval()); |
| 123 defaultStyle->addRulesFromSheet(parseUASheet(ViewportStyle::viewportStyleShe
et()), screenEval()); |
| 122 defaultPrintStyle->addRulesFromSheet(defaultStyleSheet, printEval()); | 124 defaultPrintStyle->addRulesFromSheet(defaultStyleSheet, printEval()); |
| 123 | 125 |
| 124 // Quirks-mode rules. | 126 // Quirks-mode rules. |
| 125 String quirksRules = String(quirksUserAgentStyleSheet, sizeof(quirksUserAgen
tStyleSheet)) + RenderTheme::theme().extraQuirksStyleSheet(); | 127 String quirksRules = String(quirksUserAgentStyleSheet, sizeof(quirksUserAgen
tStyleSheet)) + RenderTheme::theme().extraQuirksStyleSheet(); |
| 126 quirksStyleSheet = parseUASheet(quirksRules); | 128 quirksStyleSheet = parseUASheet(quirksRules); |
| 127 defaultQuirksStyle->addRulesFromSheet(quirksStyleSheet, screenEval()); | 129 defaultQuirksStyle->addRulesFromSheet(quirksStyleSheet, screenEval()); |
| 128 } | 130 } |
| 129 | 131 |
| 130 void CSSDefaultStyleSheets::loadSimpleDefaultStyle() | 132 void CSSDefaultStyleSheets::loadSimpleDefaultStyle() |
| 131 { | 133 { |
| 132 ASSERT(!defaultStyle); | 134 ASSERT(!defaultStyle); |
| 133 ASSERT(!simpleDefaultStyleSheet); | 135 ASSERT(!simpleDefaultStyleSheet); |
| 134 | 136 |
| 135 defaultStyle = RuleSet::create().leakPtr(); | 137 defaultStyle = RuleSet::create().leakPtr(); |
| 136 // There are no media-specific rules in the simple default style. | 138 // There are no media-specific rules in the simple default style. |
| 137 defaultPrintStyle = defaultStyle; | 139 defaultPrintStyle = defaultStyle; |
| 138 defaultQuirksStyle = RuleSet::create().leakPtr(); | 140 defaultQuirksStyle = RuleSet::create().leakPtr(); |
| 139 | 141 |
| 140 simpleDefaultStyleSheet = parseUASheet(simpleUserAgentStyleSheet, strlen(sim
pleUserAgentStyleSheet)); | 142 simpleDefaultStyleSheet = parseUASheet(simpleUserAgentStyleSheet, strlen(sim
pleUserAgentStyleSheet)); |
| 141 defaultStyle->addRulesFromSheet(simpleDefaultStyleSheet, screenEval()); | 143 defaultStyle->addRulesFromSheet(simpleDefaultStyleSheet, screenEval()); |
| 144 defaultStyle->addRulesFromSheet(parseUASheet(ViewportStyle::viewportStyleShe
et()), screenEval()); |
| 142 | 145 |
| 143 // No need to initialize quirks sheet yet as there are no quirk rules for el
ements allowed in simple default style. | 146 // No need to initialize quirks sheet yet as there are no quirk rules for el
ements allowed in simple default style. |
| 144 } | 147 } |
| 145 | 148 |
| 146 RuleSet* CSSDefaultStyleSheets::viewSourceStyle() | 149 RuleSet* CSSDefaultStyleSheets::viewSourceStyle() |
| 147 { | 150 { |
| 148 if (!defaultViewSourceStyle) { | 151 if (!defaultViewSourceStyle) { |
| 149 defaultViewSourceStyle = RuleSet::create().leakPtr(); | 152 defaultViewSourceStyle = RuleSet::create().leakPtr(); |
| 150 defaultViewSourceStyle->addRulesFromSheet(parseUASheet(sourceUserAgentSt
yleSheet, sizeof(sourceUserAgentStyleSheet)), screenEval()); | 153 defaultViewSourceStyle->addRulesFromSheet(parseUASheet(sourceUserAgentSt
yleSheet, sizeof(sourceUserAgentStyleSheet)), screenEval()); |
| 151 } | 154 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 defaultStyle->addRulesFromSheet(fullscreenStyleSheet, screenEval()); | 196 defaultStyle->addRulesFromSheet(fullscreenStyleSheet, screenEval()); |
| 194 defaultQuirksStyle->addRulesFromSheet(fullscreenStyleSheet, screenEval()
); | 197 defaultQuirksStyle->addRulesFromSheet(fullscreenStyleSheet, screenEval()
); |
| 195 changedDefaultStyle = true; | 198 changedDefaultStyle = true; |
| 196 } | 199 } |
| 197 | 200 |
| 198 ASSERT(defaultStyle->features().idsInRules.isEmpty()); | 201 ASSERT(defaultStyle->features().idsInRules.isEmpty()); |
| 199 ASSERT(defaultStyle->features().siblingRules.isEmpty()); | 202 ASSERT(defaultStyle->features().siblingRules.isEmpty()); |
| 200 } | 203 } |
| 201 | 204 |
| 202 } // namespace WebCore | 205 } // namespace WebCore |
| OLD | NEW |