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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 7683 matching lines...) Expand 10 before | Expand all | Expand 10 after
7694 return true; 7694 return true;
7695 } 7695 }
7696 7696
7697 return false; 7697 return false;
7698 } 7698 }
7699 7699
7700 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent() 7700 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent()
7701 { 7701 {
7702 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7702 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7703 7703
7704 // <length> | <percentage> | inherit 7704 bool hasLengthOrPercentage = false;
7705 if (m_valueList->size() == 1) { 7705 bool hasEachLine = false;
7706 CSSParserValue* value = m_valueList->current(); 7706 bool hasHanging = false;
7707 if (!value->id && validUnit(value, FLength | FPercent)) { 7707
7708 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
7709 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te xtEnabled() returns false
7710 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent)) {
7708 list->append(createPrimitiveNumericValue(value)); 7711 list->append(createPrimitiveNumericValue(value));
7709 m_valueList->next(); 7712 hasLengthOrPercentage = true;
7710 return list.release(); 7713 continue;
7711 } 7714 }
7715
7716 // [ <length> | <percentage> ] && hanging? && each-line? | inherit
7717 // when RuntimeEnabledFeatures::css3TextEnabled() returns true
7718 if (RuntimeEnabledFeatures::css3TextEnabled()) {
7719 if (!hasEachLine && value->id == CSSValueEachLine) {
7720 list->append(cssValuePool().createIdentifierValue(CSSValueEachLi ne));
7721 hasEachLine = true;
7722 continue;
7723 }
7724 if (!hasHanging && value->id == CSSValueHanging) {
7725 list->append(cssValuePool().createIdentifierValue(CSSValueHangin g));
7726 hasHanging = true;
7727 continue;
7728 }
7729 }
7730 return nullptr;
7712 } 7731 }
7713 7732
7714 if (!RuntimeEnabledFeatures::css3TextEnabled()) 7733 if (!hasLengthOrPercentage)
7715 return nullptr; 7734 return nullptr;
7716 7735
7717 // The case where text-indent has only <length>(or <percentage>) value 7736 return list.release();
7718 // is handled above if statement even though css3TextEnabled() returns true.
7719
7720 // [ [ <length> | <percentage> ] && each-line ] | inherit
7721 if (m_valueList->size() != 2)
7722 return nullptr;
7723
7724 CSSParserValue* firstValue = m_valueList->current();
7725 CSSParserValue* secondValue = m_valueList->next();
7726 CSSParserValue* lengthOrPercentageValue = 0;
7727
7728 // [ <length> | <percentage> ] each-line
7729 if (validUnit(firstValue, FLength | FPercent) && secondValue->id == CSSValue EachLine)
7730 lengthOrPercentageValue = firstValue;
7731 // each-line [ <length> | <percentage> ]
7732 else if (firstValue->id == CSSValueEachLine && validUnit(secondValue, FLengt h | FPercent))
7733 lengthOrPercentageValue = secondValue;
7734
7735 if (lengthOrPercentageValue) {
7736 list->append(createPrimitiveNumericValue(lengthOrPercentageValue));
7737 list->append(cssValuePool().createIdentifierValue(CSSValueEachLine));
7738 m_valueList->next();
7739 return list.release();
7740 }
7741
7742 return nullptr;
7743 } 7737 }
7744 7738
7745 bool CSSPropertyParser::parseLineBoxContain(bool important) 7739 bool CSSPropertyParser::parseLineBoxContain(bool important)
7746 { 7740 {
7747 LineBoxContain lineBoxContain = LineBoxContainNone; 7741 LineBoxContain lineBoxContain = LineBoxContainNone;
7748 7742
7749 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 7743 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
7750 if (value->id == CSSValueBlock) { 7744 if (value->id == CSSValueBlock) {
7751 if (lineBoxContain & LineBoxContainBlock) 7745 if (lineBoxContain & LineBoxContainBlock)
7752 return false; 7746 return false;
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
8455 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8449 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8456 if (!seenStroke) 8450 if (!seenStroke)
8457 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8451 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8458 if (!seenMarkers) 8452 if (!seenMarkers)
8459 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8453 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8460 8454
8461 return parsedValues.release(); 8455 return parsedValues.release();
8462 } 8456 }
8463 8457
8464 } // namespace WebCore 8458 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698