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

Unified Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 224723023: Implements hanging property for text-indent from CSS3 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update description Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSValueKeywords.in ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index bf2a501045d8705d5860434c367726a2b808b861..4b3b4acb72fba29fb124eb6843920f22f6f6e976 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -7741,45 +7741,39 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent()
{
RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- // <length> | <percentage> | inherit
- if (m_valueList->size() == 1) {
- CSSParserValue* value = m_valueList->current();
- if (!value->id && validUnit(value, FLength | FPercent)) {
+ bool hasLengthOrPercentage = false;
+ bool hasEachLine = false;
+ bool hasHanging = false;
+
+ for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) {
+ // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3TextEnabled() returns false
+ if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent)) {
list->append(createPrimitiveNumericValue(value));
- m_valueList->next();
- return list.release();
+ hasLengthOrPercentage = true;
+ continue;
}
- }
- if (!RuntimeEnabledFeatures::css3TextEnabled())
+ // [ <length> | <percentage> ] && hanging? && each-line? | inherit
+ // when RuntimeEnabledFeatures::css3TextEnabled() returns true
+ if (RuntimeEnabledFeatures::css3TextEnabled()) {
+ if (!hasEachLine && value->id == CSSValueEachLine) {
+ list->append(cssValuePool().createIdentifierValue(CSSValueEachLine));
+ hasEachLine = true;
+ continue;
+ }
+ if (!hasHanging && value->id == CSSValueHanging) {
+ list->append(cssValuePool().createIdentifierValue(CSSValueHanging));
+ hasHanging = true;
+ continue;
+ }
+ }
return nullptr;
+ }
- // The case where text-indent has only <length>(or <percentage>) value
- // is handled above if statement even though css3TextEnabled() returns true.
-
- // [ [ <length> | <percentage> ] && each-line ] | inherit
- if (m_valueList->size() != 2)
+ if (!hasLengthOrPercentage)
return nullptr;
- CSSParserValue* firstValue = m_valueList->current();
- CSSParserValue* secondValue = m_valueList->next();
- CSSParserValue* lengthOrPercentageValue = 0;
-
- // [ <length> | <percentage> ] each-line
- if (validUnit(firstValue, FLength | FPercent) && secondValue->id == CSSValueEachLine)
- lengthOrPercentageValue = firstValue;
- // each-line [ <length> | <percentage> ]
- else if (firstValue->id == CSSValueEachLine && validUnit(secondValue, FLength | FPercent))
- lengthOrPercentageValue = secondValue;
-
- if (lengthOrPercentageValue) {
- list->append(createPrimitiveNumericValue(lengthOrPercentageValue));
- list->append(cssValuePool().createIdentifierValue(CSSValueEachLine));
- m_valueList->next();
- return list.release();
- }
-
- return nullptr;
+ return list.release();
}
bool CSSPropertyParser::parseLineBoxContain(bool important)
« no previous file with comments | « Source/core/css/CSSValueKeywords.in ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698