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

Unified Diff: Source/core/css/CSSDefaultStyleSheets.cpp

Issue 708713004: Improve logic in ensureDefaultStyleSheetsForElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSDefaultStyleSheets.cpp
diff --git a/Source/core/css/CSSDefaultStyleSheets.cpp b/Source/core/css/CSSDefaultStyleSheets.cpp
index 163b47f5916ab1285c9c448f4a58e3a8436d8af4..6e8e974898b2226225259b8fa493138e1b56e7bd 100644
--- a/Source/core/css/CSSDefaultStyleSheets.cpp
+++ b/Source/core/css/CSSDefaultStyleSheets.cpp
@@ -152,30 +152,31 @@ RuleSet* CSSDefaultStyleSheets::defaultXHTMLMobileProfileStyle()
void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element* element, bool& changedDefaultStyle)
{
- // FIXME: We should assert that the sheet only styles SVG elements.
- if (element->isSVGElement() && !m_svgStyleSheet) {
- m_svgStyleSheet = parseUASheet(svgCss, sizeof(svgCss));
- m_defaultStyle->addRulesFromSheet(svgStyleSheet(), screenEval());
- m_defaultPrintStyle->addRulesFromSheet(svgStyleSheet(), printEval());
- changedDefaultStyle = true;
- }
-
- // FIXME: We should assert that the sheet only styles MathML elements.
- if (element->namespaceURI() == MathMLNames::mathmlNamespaceURI
- && !m_mathmlStyleSheet) {
- m_mathmlStyleSheet = parseUASheet(mathmlCss, sizeof(mathmlCss));
- m_defaultStyle->addRulesFromSheet(mathmlStyleSheet(), screenEval());
- m_defaultPrintStyle->addRulesFromSheet(mathmlStyleSheet(), printEval());
- changedDefaultStyle = true;
- }
-
- // FIXME: We should assert that this sheet only contains rules for <video> and <audio>.
- if (!m_mediaControlsStyleSheet && (isHTMLVideoElement(*element) || isHTMLAudioElement(*element))) {
- String mediaRules = String(mediaControlsCss, sizeof(mediaControlsCss)) + RenderTheme::theme().extraMediaControlsStyleSheet();
- m_mediaControlsStyleSheet = parseUASheet(mediaRules);
- m_defaultStyle->addRulesFromSheet(mediaControlsStyleSheet(), screenEval());
- m_defaultPrintStyle->addRulesFromSheet(mediaControlsStyleSheet(), printEval());
- changedDefaultStyle = true;
+ if (element->isSVGElement()) {
+ // FIXME: We should assert that the sheet only styles SVG elements.
+ if (!m_svgStyleSheet) {
+ m_svgStyleSheet = parseUASheet(svgCss, sizeof(svgCss));
+ m_defaultStyle->addRulesFromSheet(svgStyleSheet(), screenEval());
+ m_defaultPrintStyle->addRulesFromSheet(svgStyleSheet(), printEval());
+ changedDefaultStyle = true;
+ }
+ } else if (element->namespaceURI() == MathMLNames::mathmlNamespaceURI) {
+ // FIXME: We should assert that the sheet only styles MathML elements.
+ if (!m_mathmlStyleSheet) {
+ m_mathmlStyleSheet = parseUASheet(mathmlCss, sizeof(mathmlCss));
+ m_defaultStyle->addRulesFromSheet(mathmlStyleSheet(), screenEval());
+ m_defaultPrintStyle->addRulesFromSheet(mathmlStyleSheet(), printEval());
+ changedDefaultStyle = true;
+ }
+ } else if (isHTMLVideoElement(*element) || isHTMLAudioElement(*element)) {
+ // FIXME: We should assert that this sheet only contains rules for <video> and <audio>.
+ if (!m_mediaControlsStyleSheet) {
+ String mediaRules = String(mediaControlsCss, sizeof(mediaControlsCss)) + RenderTheme::theme().extraMediaControlsStyleSheet();
+ m_mediaControlsStyleSheet = parseUASheet(mediaRules);
+ m_defaultStyle->addRulesFromSheet(mediaControlsStyleSheet(), screenEval());
+ m_defaultPrintStyle->addRulesFromSheet(mediaControlsStyleSheet(), printEval());
+ changedDefaultStyle = true;
+ }
}
// FIXME: This only works because we Force recalc the entire document so the new sheet
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698