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

Side by Side Diff: Source/core/css/parser/CSSParserImpl.cpp

Issue 1116593003: Move font-family check to CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: move check into CSSPropertyParser and add test Created 5 years, 7 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSParserImpl.h" 6 #include "core/css/parser/CSSParserImpl.h"
7 7
8 #include "core/css/CSSKeyframesRule.h" 8 #include "core/css/CSSKeyframesRule.h"
9 #include "core/css/CSSStyleSheet.h" 9 #include "core/css/CSSStyleSheet.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 if (m_observerWrapper) { 458 if (m_observerWrapper) {
459 unsigned endOffset = m_observerWrapper->endOffset(prelude); 459 unsigned endOffset = m_observerWrapper->endOffset(prelude);
460 m_observerWrapper->observer().startRuleHeader(StyleRule::FontFace, m_obs erverWrapper->startOffset(prelude)); 460 m_observerWrapper->observer().startRuleHeader(StyleRule::FontFace, m_obs erverWrapper->startOffset(prelude));
461 m_observerWrapper->observer().endRuleHeader(endOffset); 461 m_observerWrapper->observer().endRuleHeader(endOffset);
462 m_observerWrapper->observer().startRuleBody(endOffset); 462 m_observerWrapper->observer().startRuleBody(endOffset);
463 m_observerWrapper->observer().endRuleBody(endOffset, false); 463 m_observerWrapper->observer().endRuleBody(endOffset, false);
464 } 464 }
465 465
466 consumeDeclarationList(block, StyleRule::FontFace); 466 consumeDeclarationList(block, StyleRule::FontFace);
467 467
468 // FIXME: This logic should be in CSSPropertyParser
469 // FIXME: Shouldn't we fail if font-family or src aren't specified?
470 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
471 CSSProperty& property = m_parsedProperties[i];
472 if (property.id() == CSSPropertyFontFamily && (!property.value()->isValu eList() || toCSSValueList(property.value())->length() != 1)) {
473 m_parsedProperties.clear();
474 return nullptr;
475 }
476 }
477
478 RefPtrWillBeRawPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create(); 468 RefPtrWillBeRawPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create();
479 rule->setProperties(createStylePropertySet(m_parsedProperties, m_context.mod e())); 469 rule->setProperties(createStylePropertySet(m_parsedProperties, m_context.mod e()));
480 m_parsedProperties.clear(); 470 m_parsedProperties.clear();
481 if (m_styleSheet) 471 if (m_styleSheet)
482 m_styleSheet->setHasFontFaceRule(true); 472 m_styleSheet->setHasFontFaceRule(true);
483 return rule.release(); 473 return rule.release();
484 } 474 }
485 475
486 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> CSSParserImpl::consumeKeyframesRule(b ool webkitPrefixed, CSSParserTokenRange prelude, CSSParserTokenRange block) 476 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> CSSParserImpl::consumeKeyframesRule(b ool webkitPrefixed, CSSParserTokenRange prelude, CSSParserTokenRange block)
487 { 477 {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 else 736 else
747 return nullptr; // Parser error, invalid value in keyframe selector 737 return nullptr; // Parser error, invalid value in keyframe selector
748 if (range.atEnd()) 738 if (range.atEnd())
749 return result.release(); 739 return result.release();
750 if (range.consume().type() != CommaToken) 740 if (range.consume().type() != CommaToken)
751 return nullptr; // Parser error 741 return nullptr; // Parser error
752 } 742 }
753 } 743 }
754 744
755 } // namespace blink 745 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/fontface-single-font-family-expected.txt ('k') | Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698