diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
commit | 49233e234e5c787396cadb2cea33b31ae0cd65c1 (patch) | |
tree | 5410cb9a8fd53168bb60d62c54b654d86f03c38d /Source/WebCore/css | |
parent | b211c645d8ab690f713515dfdc84d80b11c27d2c (diff) | |
download | qtwebkit-49233e234e5c787396cadb2cea33b31ae0cd65c1.tar.gz |
Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813)
New snapshot with Windows build fixes
Diffstat (limited to 'Source/WebCore/css')
36 files changed, 1255 insertions, 432 deletions
diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp index 89d84597e..6082a2380 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -125,6 +125,9 @@ static const CSSPropertyID computedProperties[] = { CSSPropertyFontWeight, CSSPropertyHeight, CSSPropertyImageRendering, +#if ENABLE(CSS_IMAGE_RESOLUTION) + CSSPropertyImageResolution, +#endif CSSPropertyLeft, CSSPropertyLetterSpacing, CSSPropertyLineHeight, @@ -199,7 +202,9 @@ static const CSSPropertyID computedProperties[] = { CSSPropertyWebkitBorderImage, CSSPropertyWebkitBorderVerticalSpacing, CSSPropertyWebkitBoxAlign, +#if ENABLE(CSS_BOX_DECORATION_BREAK) CSSPropertyWebkitBoxDecorationBreak, +#endif CSSPropertyWebkitBoxDirection, CSSPropertyWebkitBoxFlex, CSSPropertyWebkitBoxFlexGroup, @@ -216,6 +221,7 @@ static const CSSPropertyID computedProperties[] = { CSSPropertyWebkitColumnAxis, CSSPropertyWebkitColumnCount, CSSPropertyWebkitColumnGap, + CSSPropertyWebkitColumnProgression, CSSPropertyWebkitColumnRuleColor, CSSPropertyWebkitColumnRuleStyle, CSSPropertyWebkitColumnRuleWidth, @@ -228,14 +234,14 @@ static const CSSPropertyID computedProperties[] = { CSSPropertyWebkitFilter, #endif #if ENABLE(CSS3_FLEXBOX) + CSSPropertyWebkitAlignContent, CSSPropertyWebkitAlignItems, CSSPropertyWebkitAlignSelf, CSSPropertyWebkitFlex, - CSSPropertyWebkitFlexPack, CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexFlow, - CSSPropertyWebkitFlexLinePack, CSSPropertyWebkitFlexWrap, + CSSPropertyWebkitJustifyContent, #endif CSSPropertyWebkitFontKerning, CSSPropertyWebkitFontSmoothing, @@ -278,7 +284,9 @@ static const CSSPropertyID computedProperties[] = { CSSPropertyWebkitMaskRepeat, CSSPropertyWebkitMaskSize, CSSPropertyWebkitNbspMode, +#if ENABLE(CSS3_FLEXBOX) CSSPropertyWebkitOrder, +#endif #if ENABLE(OVERFLOW_SCROLLING) CSSPropertyWebkitOverflowScrolling, #endif @@ -1355,6 +1363,9 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert switch (propertyID) { case CSSPropertyInvalid: +#if ENABLE(CSS_VARIABLES) + case CSSPropertyVariable: +#endif break; case CSSPropertyBackgroundColor: @@ -1541,10 +1552,12 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document()->renderView()); case CSSPropertyWebkitBoxAlign: return cssValuePool().createValue(style->boxAlign()); +#if ENABLE(CSS_BOX_DECORATION_BREAK) case CSSPropertyWebkitBoxDecorationBreak: if (style->boxDecorationBreak() == DSLICE) return cssValuePool().createIdentifierValue(CSSValueSlice); return cssValuePool().createIdentifierValue(CSSValueClone); +#endif case CSSPropertyWebkitBoxDirection: return cssValuePool().createValue(style->boxDirection()); case CSSPropertyWebkitBoxFlex: @@ -1582,6 +1595,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert if (style->hasNormalColumnGap()) return cssValuePool().createIdentifierValue(CSSValueNormal); return zoomAdjustedPixelValue(style->columnGap(), style.get()); + case CSSPropertyWebkitColumnProgression: + return cssValuePool().createValue(style->columnProgression()); case CSSPropertyWebkitColumnRuleColor: return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor()); case CSSPropertyWebkitColumnRuleStyle: @@ -1637,23 +1652,23 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert #if ENABLE(CSS3_FLEXBOX) case CSSPropertyWebkitFlex: { RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); - list->append(cssValuePool().createValue(style->positiveFlex())); - list->append(cssValuePool().createValue(style->negativeFlex())); + list->append(cssValuePool().createValue(style->flexGrow())); + list->append(cssValuePool().createValue(style->flexShrink())); - Length preferredSize = style->flexPreferredSize(); - if (preferredSize.isAuto()) + Length flexBasis = style->flexBasis(); + if (flexBasis.isAuto()) list->append(cssValuePool().createIdentifierValue(CSSValueAuto)); - else if (preferredSize.isPercent()) - list->append(cssValuePool().createValue(preferredSize.value(), CSSPrimitiveValue::CSS_PERCENTAGE)); + else if (flexBasis.isPercent()) + list->append(cssValuePool().createValue(flexBasis.value(), CSSPrimitiveValue::CSS_PERCENTAGE)); else - list->append(cssValuePool().createValue(preferredSize.value(), CSSPrimitiveValue::CSS_PX)); + list->append(cssValuePool().createValue(flexBasis.value(), CSSPrimitiveValue::CSS_PX)); return list.release(); } case CSSPropertyWebkitOrder: - return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER); - case CSSPropertyWebkitFlexPack: - return cssValuePool().createValue(style->flexPack()); + return cssValuePool().createValue(style->order()); + case CSSPropertyWebkitJustifyContent: + return cssValuePool().createValue(style->justifyContent()); case CSSPropertyWebkitAlignItems: return cssValuePool().createValue(style->alignItems()); case CSSPropertyWebkitAlignSelf: @@ -1667,8 +1682,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert return cssValuePool().createValue(style->flexDirection()); case CSSPropertyWebkitFlexWrap: return cssValuePool().createValue(style->flexWrap()); - case CSSPropertyWebkitFlexLinePack: - return cssValuePool().createValue(style->flexLinePack()); + case CSSPropertyWebkitAlignContent: + return cssValuePool().createValue(style->alignContent()); case CSSPropertyWebkitFlexFlow: { RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); list->append(cssValuePool().createValue(style->flexDirection())); @@ -1765,6 +1780,10 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert return cssValuePool().createIdentifierValue(CSSValueLines); case CSSPropertyImageRendering: return CSSPrimitiveValue::create(style->imageRendering()); +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSSPropertyImageResolution: + return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX); +#endif case CSSPropertyLeft: return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document()->renderView()); case CSSPropertyLetterSpacing: @@ -2010,8 +2029,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert return cssValuePool().createValue(style->khtmlLineBreak()); case CSSPropertyWebkitNbspMode: return cssValuePool().createValue(style->nbspMode()); - case CSSPropertyWebkitMatchNearestMailBlockquoteColor: - return cssValuePool().createValue(style->matchNearestMailBlockquoteColor()); case CSSPropertyResize: return cssValuePool().createValue(style->resize()); case CSSPropertyWebkitFontKerning: diff --git a/Source/WebCore/css/CSSGrammar.y b/Source/WebCore/css/CSSGrammar.y index 9eddc17a1..7adcc37bc 100644 --- a/Source/WebCore/css/CSSGrammar.y +++ b/Source/WebCore/css/CSSGrammar.y @@ -101,7 +101,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser) %} -%expect 58 +%expect 63 %nonassoc LOWEST_PREC @@ -135,6 +135,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser) %token FONT_FACE_SYM %token CHARSET_SYM %token NAMESPACE_SYM +%token VARFUNCTION %token WEBKIT_RULE_SYM %token WEBKIT_DECLS_SYM %token WEBKIT_KEYFRAME_RULE_SYM @@ -193,6 +194,9 @@ static int cssyylex(YYSTYPE* yylval, void* parser) %token <number> VW %token <number> VH %token <number> VMIN +%token <number> DPPX +%token <number> DPI +%token <number> DPCM %token <string> URI %token <string> FUNCTION @@ -201,6 +205,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser) %token <string> CALCFUNCTION %token <string> MINFUNCTION %token <string> MAXFUNCTION +%token <string> VAR_DEFINITION %token <string> UNICODERANGE @@ -410,9 +415,7 @@ rule_list: ; valid_rule: - before_ruleset ruleset { - $$ = $2; - } + ruleset | media | page | font_face @@ -840,7 +843,7 @@ maybe_space_before_declaration: } ; -before_ruleset: +before_selector_list: /* empty */ { CSSParser* p = static_cast<CSSParser*>(parser); p->markSelectorListStart(); @@ -855,9 +858,9 @@ before_rule_opening_brace: ; ruleset: - selector_list before_rule_opening_brace '{' maybe_space_before_declaration declaration_list closing_brace { + before_selector_list selector_list before_rule_opening_brace '{' maybe_space_before_declaration declaration_list closing_brace { CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createStyleRule($1); + $$ = p->createStyleRule($2); } ; @@ -1296,6 +1299,17 @@ decl_list: ; declaration: + VAR_DEFINITION ':' maybe_space expr prio { +#if ENABLE(CSS_VARIABLES) + CSSParser* p = static_cast<CSSParser*>(parser); + p->storeVariableDeclaration($1, p->sinkFloatingValueList($4), $5); + $$ = true; + p->markPropertyEnd($5, $$); +#else + $$ = false; +#endif + } + | property ':' maybe_space expr prio { $$ = false; CSSParser* p = static_cast<CSSParser*>(parser); @@ -1428,6 +1442,13 @@ term: | UNICODERANGE maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_UNICODE_RANGE; } | HEX maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; } | '#' maybe_space { $$.id = 0; $$.string = CSSParserString(); $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; } /* Handle error case: "color: #;" */ + | VARFUNCTION maybe_space IDENT ')' maybe_space { +#if ENABLE(CSS_VARIABLES) + $$.id = 0; + $$.string = $3; + $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME; +#endif + } /* FIXME: according to the specs a function can have a unary_operator in front. I know no case where this makes sense */ | function { $$ = $1; @@ -1475,6 +1496,9 @@ unary_term: | VW maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VW; } | VH maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VH; } | VMIN maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMIN; } + | DPPX maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPPX; } + | DPI maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPI; } + | DPCM maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPCM; } ; function: diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index 380765b24..39fb630ed 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -51,6 +51,9 @@ #include "CSSValueKeywords.h" #include "CSSValueList.h" #include "CSSValuePool.h" +#if ENABLE(CSS_VARIABLES) +#include "CSSVariableValue.h" +#endif #include "CSSWrapShapes.h" #include "Counter.h" #include "Document.h" @@ -235,12 +238,12 @@ CSSParser::CSSParser(const CSSParserContext& context) , m_hasFontFaceOnlyValues(false) , m_hadSyntacticallyValidCSSRule(false) , m_defaultNamespace(starAtom) + , m_parsedTextPrefixLength(0) , m_inStyleRuleOrDeclaration(false) , m_selectorListRange(0, 0) , m_ruleBodyRange(0, 0) , m_propertyRange(UINT_MAX, UINT_MAX) - , m_ruleRangeMap(0) - , m_currentRuleData(0) + , m_ruleSourceDataResult(0) , m_parsingMode(NormalMode) , m_currentCharacter(0) , m_tokenStart(0) @@ -285,15 +288,16 @@ void CSSParserString::lower() void CSSParser::setupParser(const char* prefix, const String& string, const char* suffix) { - int length = string.length() + strlen(prefix) + strlen(suffix) + 1; + m_parsedTextPrefixLength = strlen(prefix); + int length = string.length() + m_parsedTextPrefixLength + strlen(suffix) + 1; m_dataStart = adoptArrayPtr(new UChar[length]); - for (unsigned i = 0; i < strlen(prefix); i++) + for (unsigned i = 0; i < m_parsedTextPrefixLength; i++) m_dataStart[i] = prefix[i]; - memcpy(m_dataStart.get() + strlen(prefix), string.characters(), string.length() * sizeof(UChar)); + memcpy(m_dataStart.get() + m_parsedTextPrefixLength, string.characters(), string.length() * sizeof(UChar)); - unsigned start = strlen(prefix) + string.length(); + unsigned start = m_parsedTextPrefixLength + string.length(); unsigned end = start + strlen(suffix); for (unsigned i = start; i < end; i++) m_dataStart[i] = suffix[i - start]; @@ -304,21 +308,19 @@ void CSSParser::setupParser(const char* prefix, const String& string, const char resetRuleBodyMarks(); } -void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap) +void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, int startLineNumber, RuleSourceDataList* ruleSourceDataResult) { setStyleSheet(sheet); m_defaultNamespace = starAtom; // Reset the default namespace. - m_ruleRangeMap = ruleRangeMap; - if (ruleRangeMap) { - m_currentRuleData = CSSRuleSourceData::create(); - m_currentRuleData->styleSourceData = CSSStyleSourceData::create(); - } + if (ruleSourceDataResult) + m_currentRuleDataStack = adoptPtr(new RuleSourceDataList()); + m_ruleSourceDataResult = ruleSourceDataResult; m_lineNumber = startLineNumber; setupParser("", string, ""); cssyyparse(this); - m_ruleRangeMap = 0; - m_currentRuleData = 0; + m_currentRuleDataStack.clear(); + m_ruleSourceDataResult = 0; m_rule = 0; } @@ -664,10 +666,12 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int if (valueID == CSSValueStretch || valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline) return true; break; +#if ENABLE(CSS_BOX_DECORATION_BREAK) case CSSPropertyWebkitBoxDecorationBreak: if (valueID == CSSValueClone || valueID == CSSValueSlice) return true; break; +#endif case CSSPropertyWebkitBoxDirection: if (valueID == CSSValueNormal || valueID == CSSValueReverse) return true; @@ -689,30 +693,30 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int return true; break; #if ENABLE(CSS3_FLEXBOX) + case CSSPropertyWebkitAlignContent: + if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround || valueID == CSSValueStretch) + return true; + break; case CSSPropertyWebkitAlignItems: - if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) + if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) return true; break; case CSSPropertyWebkitAlignSelf: - if (valueID == CSSValueAuto || valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) + if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) return true; break; case CSSPropertyWebkitFlexDirection: if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID == CSSValueColumn || valueID == CSSValueColumnReverse) return true; break; - case CSSPropertyWebkitFlexLinePack: - if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround || valueID == CSSValueStretch) - return true; - break; - case CSSPropertyWebkitFlexPack: - if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround) - return true; - break; case CSSPropertyWebkitFlexWrap: if (valueID == CSSValueNone || valueID == CSSValueWrap || valueID == CSSValueWrapReverse) return true; break; + case CSSPropertyWebkitJustifyContent: + if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround) + return true; + break; #endif case CSSPropertyWebkitFontKerning: if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == CSSValueNone) @@ -754,10 +758,6 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int if (valueID == CSSValueNone || valueID == CSSValueSlide || valueID == CSSValueScroll || valueID == CSSValueAlternate) return true; break; - case CSSPropertyWebkitMatchNearestMailBlockquoteColor: // normal | match - if (valueID == CSSValueNormal || valueID == CSSValueMatch) - return true; - break; case CSSPropertyWebkitNbspMode: // normal | space if (valueID == CSSValueNormal || valueID == CSSValueSpace) return true; @@ -909,7 +909,9 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId) case CSSPropertyWebkitBorderFit: case CSSPropertyWebkitBorderStartStyle: case CSSPropertyWebkitBoxAlign: +#if ENABLE(CSS_BOX_DECORATION_BREAK) case CSSPropertyWebkitBoxDecorationBreak: +#endif case CSSPropertyWebkitBoxDirection: case CSSPropertyWebkitBoxLines: case CSSPropertyWebkitBoxOrient: @@ -920,12 +922,12 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId) case CSSPropertyWebkitColumnBreakInside: case CSSPropertyWebkitColumnRuleStyle: #if ENABLE(CSS3_FLEXBOX) + case CSSPropertyWebkitAlignContent: case CSSPropertyWebkitAlignItems: case CSSPropertyWebkitAlignSelf: case CSSPropertyWebkitFlexDirection: - case CSSPropertyWebkitFlexLinePack: - case CSSPropertyWebkitFlexPack: case CSSPropertyWebkitFlexWrap: + case CSSPropertyWebkitJustifyContent: #endif case CSSPropertyWebkitFontKerning: case CSSPropertyWebkitFontSmoothing: @@ -939,7 +941,6 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId) case CSSPropertyWebkitMarginTopCollapse: case CSSPropertyWebkitMarqueeDirection: case CSSPropertyWebkitMarqueeStyle: - case CSSPropertyWebkitMatchNearestMailBlockquoteColor: case CSSPropertyWebkitNbspMode: #if ENABLE(OVERFLOW_SCROLLING) case CSSPropertyWebkitOverflowScrolling: @@ -1119,16 +1120,19 @@ void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorLis m_selectorListForParseSelector = 0; } -bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData, StyleSheetContents* contextStyleSheet) +bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, PassRefPtr<CSSStyleSourceData> prpStyleSourceData, StyleSheetContents* contextStyleSheet) { // Length of the "@-webkit-decls{" prefix. static const unsigned prefixLength = 15; setStyleSheet(contextStyleSheet); + RefPtr<CSSStyleSourceData> styleSourceData = prpStyleSourceData; if (styleSourceData) { - m_currentRuleData = CSSRuleSourceData::create(); - m_currentRuleData->styleSourceData = CSSStyleSourceData::create(); + m_currentRuleDataStack = adoptPtr(new RuleSourceDataList()); + RefPtr<CSSRuleSourceData> data = CSSRuleSourceData::create(); + data->styleSourceData = styleSourceData; + m_currentRuleDataStack->append(data); m_inStyleRuleOrDeclaration = true; } @@ -1145,20 +1149,22 @@ bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& st clearProperties(); } - if (m_currentRuleData) { - m_currentRuleData->styleSourceData->styleBodyRange.start = 0; - m_currentRuleData->styleSourceData->styleBodyRange.end = string.length(); - for (Vector<CSSPropertySourceData>::iterator it = m_currentRuleData->styleSourceData->propertyData.begin(), endIt = m_currentRuleData->styleSourceData->propertyData.end(); it != endIt; ++it) { - (*it).range.start -= prefixLength; - (*it).range.end -= prefixLength; - } - } - if (styleSourceData) { - *styleSourceData = m_currentRuleData->styleSourceData.release(); - m_currentRuleData = 0; + ASSERT(!m_currentRuleDataStack->isEmpty()); + CSSRuleSourceData* ruleData = m_currentRuleDataStack->last().get(); + ruleData->styleSourceData->styleBodyRange.start = 0; + ruleData->styleSourceData->styleBodyRange.end = string.length(); + for (size_t i = 0, size = ruleData->styleSourceData->propertyData.size(); i < size; ++i) { + CSSPropertySourceData& propertyData = ruleData->styleSourceData->propertyData.at(i); + propertyData.range.start -= prefixLength; + propertyData.range.end -= prefixLength; + } + fixUnparsedPropertyRanges(ruleData); + + m_currentRuleDataStack.clear(); m_inStyleRuleOrDeclaration = false; } + return ok; } @@ -1177,13 +1183,27 @@ PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string) return m_mediaQuery.release(); } +#if ENABLE(CSS_VARIABLES) +static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables) +#else static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties) +#endif { // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found. for (int i = input.size() - 1; i >= 0; --i) { const CSSProperty& property = input[i]; if (property.isImportant() != important) continue; +#if ENABLE(CSS_VARIABLES) + if (property.id() == CSSPropertyVariable) { + const AtomicString& name = static_cast<CSSVariableValue*>(property.value())->name(); + if (seenVariables.contains(name)) + continue; + seenVariables.add(name); + output[--unusedEntries] = property; + continue; + } +#endif const unsigned propertyIDIndex = property.id() - firstCSSProperty; if (seenProperties.get(propertyIDIndex)) continue; @@ -1199,9 +1219,14 @@ PassRefPtr<StylePropertySet> CSSParser::createStylePropertySet() Vector<CSSProperty, 256> results(unusedEntries); // Important properties have higher priority, so add them first. Duplicate definitions can then be ignored when found. +#if ENABLE(CSS_VARIABLES) + HashSet<AtomicString> seenVariables; + filterProperties(true, m_parsedProperties, results, unusedEntries, seenProperties, seenVariables); + filterProperties(false, m_parsedProperties, results, unusedEntries, seenProperties, seenVariables); +#else filterProperties(true, m_parsedProperties, results, unusedEntries, seenProperties); filterProperties(false, m_parsedProperties, results, unusedEntries, seenProperties); - +#endif if (unusedEntries) results.remove(0, unusedEntries); @@ -1297,6 +1322,12 @@ bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, CSSParserMode bool b = false; switch (value->unit) { +#if ENABLE(CSS_VARIABLES) + case CSSPrimitiveValue::CSS_VARIABLE_NAME: + // Variables are checked at the point they are dereferenced because unit type is not available here. + b = true; + break; +#endif case CSSPrimitiveValue::CSS_NUMBER: b = (unitflags & FNumber); if (!b && shouldAcceptUnitLessValues(value, unitflags, cssParserMode)) { @@ -1335,6 +1366,13 @@ bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, CSSParserMode case CSSPrimitiveValue::CSS_TURN: b = (unitflags & FAngle); break; +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSSPrimitiveValue::CSS_DPPX: + case CSSPrimitiveValue::CSS_DPI: + case CSSPrimitiveValue::CSS_DPCM: + b = (unitflags & FResolution); + break; +#endif case CSSPrimitiveValue::CSS_HZ: case CSSPrimitiveValue::CSS_KHZ: case CSSPrimitiveValue::CSS_DIMENSION: @@ -1348,14 +1386,26 @@ bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, CSSParserMode inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveNumericValue(CSSParserValue* value) { +#if ENABLE(CSS_VARIABLES) + if (value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) + return CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_VARIABLE_NAME); +#endif + if (m_parsedCalculation) { ASSERT(isCalculation(value)); return CSSPrimitiveValue::create(m_parsedCalculation.release()); } +#if ENABLE(CSS_IMAGE_RESOLUTION) + ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) + || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS) + || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMIN) + || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiveValue::CSS_DPCM)); +#else ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS) || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMIN)); +#endif return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit)); } @@ -1410,6 +1460,14 @@ static int unitFromString(CSSParserValue* value) return CSSPrimitiveValue::CSS_VH; if (equal(value->string, "vmin")) return CSSPrimitiveValue::CSS_VMIN; +#if ENABLE(CSS_IMAGE_RESOLUTION) + if (equal(value->string, "dppx")) + return CSSPrimitiveValue::CSS_DPPX; + if (equal(value->string, "dpi")) + return CSSPrimitiveValue::CSS_DPI; + if (equal(value->string, "dpcm")) + return CSSPrimitiveValue::CSS_DPCM; +#endif return 0; } @@ -1463,6 +1521,10 @@ inline PassRefPtr<CSSPrimitiveValue> CSSParser::parseValidPrimitive(int identifi return createPrimitiveNumericValue(value); if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMIN) return createPrimitiveNumericValue(value); +#if ENABLE(CSS_IMAGE_RESOLUTION) + if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiveValue::CSS_DPCM) + return createPrimitiveNumericValue(value); +#endif if (value->unit >= CSSParserValue::Q_EMS) return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS); if (isCalculation(value)) @@ -1506,6 +1568,14 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) return true; } +#if ENABLE(CSS_VARIABLES) + if (!id && value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME && num == 1) { + addProperty(propId, CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_VARIABLE_NAME), important); + m_valueList->next(); + return true; + } +#endif + if (isKeywordPropertyID(propId)) { if (!isValidKeywordPropertyAndValue(propId, id, m_context)) return false; @@ -1578,8 +1648,8 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) } case CSSPropertyTextAlign: - // left | right | center | justify | webkit_left | webkit_right | webkit_center | webkit_match_parent | - // start | end | <string> | inherit + // left | right | center | justify | -webkit-left | -webkit-right | -webkit-center | -webkit-match-parent + // | start | end | <string> | inherit | -webkit-auto (converted to start) if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd || value->unit == CSSPrimitiveValue::CSS_STRING) validPrimitive = true; @@ -2071,9 +2141,11 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) validPrimitive = validUnit(value, FNumber); break; case CSSPropertyWebkitBoxFlexGroup: - case CSSPropertyWebkitBoxOrdinalGroup: validPrimitive = validUnit(value, FInteger | FNonNeg, CSSStrictMode); break; + case CSSPropertyWebkitBoxOrdinalGroup: + validPrimitive = validUnit(value, FInteger | FNonNeg, CSSStrictMode) && value->fValue; + break; #if ENABLE(CSS_FILTERS) case CSSPropertyWebkitFilter: if (id == CSSValueNone) @@ -2096,12 +2168,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) parsedValue = parseFlex(m_valueList.get()); break; case CSSPropertyWebkitOrder: - if (validUnit(value, FInteger, CSSStrictMode)) { - // We restrict the smallest value to int min + 2 because we use int min and int min + 1 as special values in a hash set. - parsedValue = cssValuePool().createValue(max(static_cast<double>(std::numeric_limits<int>::min() + 2), value->fValue), - static_cast<CSSPrimitiveValue::UnitTypes>(value->unit)); - m_valueList->next(); - } + validPrimitive = validUnit(value, FNumber); break; #endif case CSSPropertyWebkitMarquee: @@ -2268,6 +2335,10 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) if (id == CSSValueHorizontal || id == CSSValueVertical || id == CSSValueAuto) validPrimitive = true; break; + case CSSPropertyWebkitColumnProgression: + if (id == CSSValueNormal || id == CSSValueReverse) + validPrimitive = true; + break; case CSSPropertyWebkitColumnSpan: // all | 1 if (id == CSSValueAll) validPrimitive = true; @@ -2498,6 +2569,14 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) case CSSPropertyWebkitWrap: return RuntimeEnabledFeatures::cssExclusionsEnabled() && parseShorthand(propId, webkitWrapShorthand(), important); #endif +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSSPropertyImageResolution: + parsedValue = parseImageResolution(m_valueList.get()); + if (!parsedValue) + return false; + m_valueList->next(); + break; +#endif case CSSPropertyBorderBottomStyle: case CSSPropertyBorderCollapse: case CSSPropertyBorderLeftStyle: @@ -2543,7 +2622,9 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) case CSSPropertyWebkitBorderFit: case CSSPropertyWebkitBorderStartStyle: case CSSPropertyWebkitBoxAlign: +#if ENABLE(CSS_BOX_DECORATION_BREAK) case CSSPropertyWebkitBoxDecorationBreak: +#endif case CSSPropertyWebkitBoxDirection: case CSSPropertyWebkitBoxLines: case CSSPropertyWebkitBoxOrient: @@ -2554,12 +2635,12 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) case CSSPropertyWebkitColumnBreakInside: case CSSPropertyWebkitColumnRuleStyle: #if ENABLE(CSS3_FLEXBOX) + case CSSPropertyWebkitAlignContent: case CSSPropertyWebkitAlignItems: case CSSPropertyWebkitAlignSelf: case CSSPropertyWebkitFlexDirection: - case CSSPropertyWebkitFlexLinePack: - case CSSPropertyWebkitFlexPack: case CSSPropertyWebkitFlexWrap: + case CSSPropertyWebkitJustifyContent: #endif case CSSPropertyWebkitFontKerning: case CSSPropertyWebkitFontSmoothing: @@ -2573,7 +2654,6 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) case CSSPropertyWebkitMarginTopCollapse: case CSSPropertyWebkitMarqueeDirection: case CSSPropertyWebkitMarqueeStyle: - case CSSPropertyWebkitMatchNearestMailBlockquoteColor: case CSSPropertyWebkitNbspMode: #if ENABLE(OVERFLOW_SCROLLING) case CSSPropertyWebkitOverflowScrolling: @@ -2796,6 +2876,19 @@ bool CSSParser::parseFillShorthand(CSSPropertyID propId, const CSSPropertyID* pr return true; } +#if ENABLE(CSS_VARIABLES) +void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr<CSSParserValueList> value, bool important) +{ + StringBuilder builder; + for (unsigned i = 0, size = value->size(); i < size; i++) { + if (i) + builder.append(' '); + builder.append(value->valueAt(i)->createCSSValue()->cssText()); + } + addProperty(CSSPropertyVariable, CSSVariableValue::create(name, builder.toString()), important, false); +} +#endif + void CSSParser::addAnimationValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval) { if (lval) { @@ -5595,9 +5688,9 @@ PassRefPtr<CSSValue> CSSParser::parseFlex(CSSParserValueList* args) } if (positiveFlex == unsetValue) - positiveFlex = 1; + positiveFlex = 0; if (negativeFlex == unsetValue) - negativeFlex = positiveFlex ? 1 : 0; + negativeFlex = 1; if (!preferredSize) preferredSize = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); @@ -5845,7 +5938,7 @@ public: BorderImageSliceParseContext(CSSParser* parser) : m_parser(parser) , m_allowNumber(true) - , m_allowFill(false) + , m_allowFill(true) , m_allowFinalCommit(false) , m_fill(false) { } @@ -5870,14 +5963,10 @@ public: } m_allowNumber = !m_left; - m_allowFill = true; m_allowFinalCommit = true; } - void commitFill() { m_fill = true; m_allowFill = false; m_allowNumber = false; } - - void setAllowFinalCommit() { m_allowFinalCommit = true; } - void setTop(PassRefPtr<CSSPrimitiveValue> val) { m_top = val; } + void commitFill() { m_fill = true; m_allowFill = false; m_allowNumber = !m_top; } PassRefPtr<CSSBorderImageSliceValue> commitBorderImageSlice() { @@ -6793,6 +6882,31 @@ bool CSSParser::parseCanvas(CSSParserValueList* valueList, RefPtr<CSSValue>& can return true; } +#if ENABLE(CSS_IMAGE_RESOLUTION) +PassRefPtr<CSSValue> CSSParser::parseImageResolution(CSSParserValueList* valueList) +{ + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + bool haveResolution = false; + bool haveFromImage = false; + + CSSParserValue* value = valueList->current(); + while (value) { + if (!haveFromImage && value->id == CSSValueFromImage) { + list->append(cssValuePool().createIdentifierValue(value->id)); + haveFromImage = true; + } else if (!haveResolution && validUnit(value, FResolution | FNonNeg) && value->fValue > 0) { + list->append(createPrimitiveNumericValue(value)); + haveResolution = true; + } else + return 0; + value = m_valueList->next(); + } + if (!list->length()) + return 0; + return list; +} +#endif + #if ENABLE(CSS_IMAGE_SET) PassRefPtr<CSSValue> CSSParser::parseImageSet(CSSParserValueList* valueList) { @@ -8270,6 +8384,20 @@ inline void CSSParser::detectNumberToken(UChar* type, int length) case 'd': if (length == 3 && isASCIIAlphaCaselessEqual(type[1], 'e') && isASCIIAlphaCaselessEqual(type[2], 'g')) m_token = DEGS; +#if ENABLE(CSS_IMAGE_RESOLUTION) + else if (length > 2 && isASCIIAlphaCaselessEqual(type[1], 'p')) { + if (length == 4) { + // There is a discussion about the name of this unit on www-style. + // Keep this compile time guard in place until that is resolved. + // http://lists.w3.org/Archives/Public/www-style/2012May/0915.html + if (isASCIIAlphaCaselessEqual(type[2], 'p') && isASCIIAlphaCaselessEqual(type[3], 'x')) + m_token = DPPX; + else if (isASCIIAlphaCaselessEqual(type[2], 'c') && isASCIIAlphaCaselessEqual(type[3], 'm')) + m_token = DPCM; + } else if (length == 3 && isASCIIAlphaCaselessEqual(type[2], 'i')) + m_token = DPI; + } +#endif return; case 'e': @@ -8371,6 +8499,10 @@ inline void CSSParser::detectDashToken(int length) m_token = MINFUNCTION; else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentifier(name + 1, "webkit-ma")) m_token = MAXFUNCTION; +#if ENABLE(CSS_VARIABLES) + else if (isASCIIAlphaCaselessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va")) + m_token = VARFUNCTION; +#endif } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) m_token = CALCFUNCTION; } @@ -8709,6 +8841,16 @@ restartAfterComment: } case CharacterDash: +#if ENABLE(CSS_VARIABLES) + if (m_currentCharacter[10] == '-' && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && isIdentifierStartAfterDash(m_currentCharacter + 11)) { + // handle variable declarations + m_currentCharacter += 11; + parseIdentifier(result, hasEscape); + m_token = VAR_DEFINITION; + yylval->string.characters = m_tokenStart; + yylval->string.length = result - m_tokenStart; + } else +#endif if (isIdentifierStartAfterDash(m_currentCharacter)) { --m_currentCharacter; parseIdentifier(result, hasEscape); @@ -9121,6 +9263,27 @@ CSSParser::RuleList* CSSParser::createRuleList() return listPtr; } +void CSSParser::addNewRuleToSourceTree(PassRefPtr<CSSRuleSourceData> rule) +{ + // Precondition: (isExtractingSourceData()). + if (!m_ruleSourceDataResult) + return; + + // FIXME: This temporarily builds a flat style rule data list, to avoid the client code breakage. + m_ruleSourceDataResult->append(rule); +} + +PassRefPtr<CSSRuleSourceData> CSSParser::popRuleData() +{ + if (!m_ruleSourceDataResult) + return 0; + + ASSERT(!m_currentRuleDataStack->isEmpty()); + RefPtr<CSSRuleSourceData> data = m_currentRuleDataStack->last(); + m_currentRuleDataStack->removeLast(); + return data.release(); +} + StyleRuleKeyframes* CSSParser::createKeyframesRule() { m_allowImportRules = m_allowNamespaceDeclarations = false; @@ -9143,18 +9306,19 @@ StyleRuleBase* CSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* se rule->setProperties(createStylePropertySet()); result = rule.get(); m_parsedRules.append(rule.release()); - if (m_ruleRangeMap) { - ASSERT(m_currentRuleData); - m_currentRuleData->styleSourceData->styleBodyRange = m_ruleBodyRange; - m_currentRuleData->selectorListRange = m_selectorListRange; - m_ruleRangeMap->set(result, m_currentRuleData.release()); - m_currentRuleData = CSSRuleSourceData::create(); - m_currentRuleData->styleSourceData = CSSStyleSourceData::create(); + if (isExtractingSourceData()) { + RefPtr<CSSRuleSourceData> currentRuleData = popRuleData(); + currentRuleData->styleSourceData->styleBodyRange = m_ruleBodyRange; + currentRuleData->selectorListRange = m_selectorListRange; + fixUnparsedPropertyRanges(currentRuleData.get()); + addNewRuleToSourceTree(currentRuleData.release()); m_inStyleRuleOrDeclaration = false; } } - resetSelectorListMarks(); - resetRuleBodyMarks(); + if (isExtractingSourceData()) { + resetSelectorListMarks(); + resetRuleBodyMarks(); + } clearProperties(); return result; } @@ -9213,7 +9377,7 @@ void CSSParser::updateSpecifiersWithElementName(const AtomicString& namespacePre CSSParserSelector* history = specifiers; while (history->tagHistory()) { history = history->tagHistory(); - if (history->hasShadowDescendant()) + if (history->isUnknownPseudoElement() || history->hasShadowDescendant()) lastShadowDescendant = history; } @@ -9360,14 +9524,61 @@ void CSSParser::updateLastMediaLine(MediaQuerySet* media) media->setLastLine(m_lineNumber); } +void CSSParser::fixUnparsedPropertyRanges(CSSRuleSourceData* ruleData) +{ + Vector<CSSPropertySourceData>& propertyData = ruleData->styleSourceData->propertyData; + unsigned size = propertyData.size(); + if (!size) + return; + + unsigned styleStart = ruleData->styleSourceData->styleBodyRange.start; + const UChar* characters = m_dataStart.get() + m_parsedTextPrefixLength; + CSSPropertySourceData* nextData = &(propertyData.at(0)); + for (unsigned i = 0; i < size; ++i) { + CSSPropertySourceData* currentData = nextData; + nextData = i < size - 1 ? &(propertyData.at(i + 1)) : 0; + + if (currentData->parsedOk) + continue; + if (currentData->range.end > 0 && characters[styleStart + currentData->range.end - 1] == ';') + continue; + + unsigned propertyEndInStyleSheet; + if (!nextData) + propertyEndInStyleSheet = ruleData->styleSourceData->styleBodyRange.end - 1; + else + propertyEndInStyleSheet = styleStart + nextData->range.start - 1; + + while (isHTMLSpace(characters[propertyEndInStyleSheet])) + --propertyEndInStyleSheet; + + // propertyEndInStyleSheet points at the last property text character. + unsigned newPropertyEnd = propertyEndInStyleSheet - styleStart + 1; // Exclusive of the last property text character. + if (currentData->range.end != newPropertyEnd) { + currentData->range.end = newPropertyEnd; + unsigned valueStartInStyleSheet = styleStart + currentData->range.start + currentData->name.length(); + while (valueStartInStyleSheet < propertyEndInStyleSheet && characters[valueStartInStyleSheet] != ':') + ++valueStartInStyleSheet; + if (valueStartInStyleSheet < propertyEndInStyleSheet) + ++valueStartInStyleSheet; // Shift past the ':'. + while (valueStartInStyleSheet < propertyEndInStyleSheet && isHTMLSpace(characters[valueStartInStyleSheet])) + ++valueStartInStyleSheet; + // Need to exclude the trailing ';' from the property value. + currentData->value = String(characters + valueStartInStyleSheet, propertyEndInStyleSheet - valueStartInStyleSheet + (characters[propertyEndInStyleSheet] == ';' ? 0 : 1)); + } + } +} + void CSSParser::markSelectorListStart() { + if (!isExtractingSourceData()) + return; m_selectorListRange.start = m_tokenStart - m_dataStart.get(); } void CSSParser::markSelectorListEnd() { - if (!m_currentRuleData) + if (!isExtractingSourceData()) return; UChar* listEnd = m_tokenStart; while (listEnd > m_dataStart.get() + 1) { @@ -9377,10 +9588,15 @@ void CSSParser::markSelectorListEnd() break; } m_selectorListRange.end = listEnd - m_dataStart.get(); + RefPtr<CSSRuleSourceData> data = CSSRuleSourceData::create(); + data->styleSourceData = CSSStyleSourceData::create(); + m_currentRuleDataStack->append(data); } void CSSParser::markRuleBodyStart() { + if (!isExtractingSourceData()) + return; unsigned offset = m_tokenStart - m_dataStart.get(); if (*m_tokenStart == '{') ++offset; // Skip the rule body opening brace. @@ -9391,6 +9607,8 @@ void CSSParser::markRuleBodyStart() void CSSParser::markRuleBodyEnd() { + if (!isExtractingSourceData()) + return; unsigned offset = m_tokenStart - m_dataStart.get(); if (offset > m_ruleBodyRange.end) m_ruleBodyRange.end = offset; @@ -9407,11 +9625,12 @@ void CSSParser::markPropertyEnd(bool isImportantFound, bool isPropertyParsed) { if (!m_inStyleRuleOrDeclaration) return; + unsigned offset = m_tokenStart - m_dataStart.get(); if (*m_tokenStart == ';') // Include semicolon into the property text. ++offset; m_propertyRange.end = offset; - if (m_propertyRange.start != UINT_MAX && m_currentRuleData) { + if (m_propertyRange.start != UINT_MAX && !m_currentRuleDataStack->isEmpty()) { // This stuff is only executed when the style data retrieval is requested by client. const unsigned start = m_propertyRange.start; const unsigned end = m_propertyRange.end; @@ -9425,10 +9644,10 @@ void CSSParser::markPropertyEnd(bool isImportantFound, bool isPropertyParsed) String name = propertyString.left(colonIndex).stripWhiteSpace(); String value = propertyString.substring(colonIndex + 1, propertyString.length()).stripWhiteSpace(); // The property range is relative to the declaration start offset. - m_currentRuleData->styleSourceData->propertyData.append( + m_currentRuleDataStack->last()->styleSourceData->propertyData.append( CSSPropertySourceData(name, value, isImportantFound, isPropertyParsed, SourceRange(start - m_ruleBodyRange.start, end - m_ruleBodyRange.start))); } - resetPropertyMarks(); + resetPropertyRange(); } static CSSPropertyID cssPropertyID(const UChar* propertyName, unsigned length) diff --git a/Source/WebCore/css/CSSParser.h b/Source/WebCore/css/CSSParser.h index 7c5a62377..b037f03a4 100644 --- a/Source/WebCore/css/CSSParser.h +++ b/Source/WebCore/css/CSSParser.h @@ -70,7 +70,7 @@ public: ~CSSParser(); - void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0, StyleRuleRangeMap* = 0); + void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0, RuleSourceDataList* = 0); PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&); PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const String&); static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*); @@ -78,7 +78,7 @@ public: static bool parseSystemColor(RGBA32& color, const String&, Document*); static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&); PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int ident, CSSParserValue*); - bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>*, StyleSheetContents* contextStyleSheet); + bool parseDeclaration(StylePropertySet*, const String&, PassRefPtr<CSSStyleSourceData>, StyleSheetContents* contextStyleSheet); PassOwnPtr<MediaQuery> parseMediaQuery(const String&); void addProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false); @@ -91,6 +91,10 @@ public: bool parseContent(CSSPropertyID, bool important); bool parseQuotes(CSSPropertyID, bool important); +#if ENABLE(CSS_VARIABLES) + void storeVariableDeclaration(const CSSParserString&, PassOwnPtr<CSSParserValueList>, bool important); +#endif + PassRefPtr<CSSValue> parseAttr(CSSParserValueList* args); PassRefPtr<CSSValue> parseBackgroundColor(); @@ -195,6 +199,10 @@ public: bool parseCrossfade(CSSParserValueList*, RefPtr<CSSValue>&); +#if ENABLE(CSS_IMAGE_RESOLUTION) + PassRefPtr<CSSValue> parseImageResolution(CSSParserValueList*); +#endif + #if ENABLE(CSS_IMAGE_SET) PassRefPtr<CSSValue> parseImageSet(CSSParserValueList*); #endif @@ -310,21 +318,30 @@ public: AtomicString m_defaultNamespace; // tokenizer methods and data + size_t m_parsedTextPrefixLength; bool m_inStyleRuleOrDeclaration; SourceRange m_selectorListRange; SourceRange m_ruleBodyRange; SourceRange m_propertyRange; - StyleRuleRangeMap* m_ruleRangeMap; - RefPtr<CSSRuleSourceData> m_currentRuleData; + OwnPtr<RuleSourceDataList> m_currentRuleDataStack; + RuleSourceDataList* m_ruleSourceDataResult; + + void fixUnparsedPropertyRanges(CSSRuleSourceData*); + void markStyleRuleHeaderStart(); + void markRuleHeaderEnd(); + void markSelectorListStart(); void markSelectorListEnd(); void markRuleBodyStart(); void markRuleBodyEnd(); void markPropertyStart(); void markPropertyEnd(bool isImportantFound, bool isPropertyParsed); + void addNewRuleToSourceTree(PassRefPtr<CSSRuleSourceData>); + PassRefPtr<CSSRuleSourceData> popRuleData(); void resetSelectorListMarks() { m_selectorListRange.start = m_selectorListRange.end = 0; } void resetRuleBodyMarks() { m_ruleBodyRange.start = m_ruleBodyRange.end = 0; } - void resetPropertyMarks() { m_propertyRange.start = m_propertyRange.end = UINT_MAX; } + void resetPropertyRange() { m_propertyRange.start = m_propertyRange.end = UINT_MAX; } + bool isExtractingSourceData() const { return !!m_currentRuleDataStack; } int lex(void* yylval); int token() { return m_token; } @@ -436,7 +453,10 @@ private: FTime = 0x0020, FFrequency = 0x0040, FRelative = 0x0100, - FNonNeg = 0x0200 +#if ENABLE(CSS_IMAGE_RESOLUTION) + FResolution= 0x0200, +#endif + FNonNeg = 0x0400 }; friend inline Units operator|(Units a, Units b) diff --git a/Source/WebCore/css/CSSParserValues.cpp b/Source/WebCore/css/CSSParserValues.cpp index 5af2a9a16..37a0d452c 100644 --- a/Source/WebCore/css/CSSParserValues.cpp +++ b/Source/WebCore/css/CSSParserValues.cpp @@ -25,6 +25,9 @@ #include "CSSFunctionValue.h" #include "CSSSelector.h" #include "CSSSelectorList.h" +#if ENABLE(CSS_VARIABLES) +#include "CSSVariableValue.h" +#endif namespace WebCore { @@ -75,7 +78,12 @@ PassRefPtr<CSSValue> CSSParserValue::createCSSValue() parsedValue = primitiveValue; } else if (unit == CSSParserValue::Function) parsedValue = CSSFunctionValue::create(function); - else if (unit == CSSPrimitiveValue::CSS_STRING || unit == CSSPrimitiveValue::CSS_URI || unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR) + else if (unit == CSSPrimitiveValue::CSS_STRING + || unit == CSSPrimitiveValue::CSS_URI +#if ENABLE(CSS_VARIABLES) + || unit == CSSPrimitiveValue::CSS_VARIABLE_NAME +#endif + || unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR) parsedValue = CSSPrimitiveValue::create(string, (CSSPrimitiveValue::UnitTypes)unit); else if (unit >= CSSPrimitiveValue::CSS_NUMBER && unit <= CSSPrimitiveValue::CSS_KHZ) parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit); diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp index 592494a0e..51d535eb9 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.cpp +++ b/Source/WebCore/css/CSSPrimitiveValue.cpp @@ -60,6 +60,11 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit case CSSPrimitiveValue:: CSS_CM: case CSSPrimitiveValue:: CSS_DEG: case CSSPrimitiveValue:: CSS_DIMENSION: +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSSPrimitiveValue:: CSS_DPPX: + case CSSPrimitiveValue:: CSS_DPI: + case CSSPrimitiveValue:: CSS_DPCM: +#endif case CSSPrimitiveValue:: CSS_EMS: case CSSPrimitiveValue:: CSS_EXS: case CSSPrimitiveValue:: CSS_GRAD: @@ -85,6 +90,11 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit case CSSPrimitiveValue:: CSS_COUNTER: case CSSPrimitiveValue:: CSS_COUNTER_NAME: case CSSPrimitiveValue:: CSS_DASHBOARD_REGION: +#if !ENABLE(CSS_IMAGE_RESOLUTION) + case CSSPrimitiveValue:: CSS_DPPX: + case CSSPrimitiveValue:: CSS_DPI: + case CSSPrimitiveValue:: CSS_DPCM: +#endif case CSSPrimitiveValue:: CSS_IDENT: case CSSPrimitiveValue:: CSS_PAIR: case CSSPrimitiveValue:: CSS_PARSER_HEXCOLOR: @@ -99,6 +109,9 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit case CSSPrimitiveValue:: CSS_UNICODE_RANGE: case CSSPrimitiveValue:: CSS_UNKNOWN: case CSSPrimitiveValue:: CSS_URI: +#if ENABLE(CSS_VARIABLES) + case CSSPrimitiveValue:: CSS_VARIABLE_NAME: +#endif return false; } @@ -137,6 +150,12 @@ static CSSPrimitiveValue::UnitCategory unitCategory(CSSPrimitiveValue::UnitTypes case CSSPrimitiveValue::CSS_VH: case CSSPrimitiveValue::CSS_VMIN: return CSSPrimitiveValue::UViewportPercentageLength; +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSSPrimitiveValue:: CSS_DPPX: + case CSSPrimitiveValue:: CSS_DPI: + case CSSPrimitiveValue:: CSS_DPCM: + return CSSPrimitiveValue::UResolution; +#endif default: return CSSPrimitiveValue::UOther; } @@ -551,12 +570,18 @@ static double conversionToCanonicalUnitsScaleFactor(unsigned short unitType) case CSSPrimitiveValue::CSS_CM: factor = cssPixelsPerInch / 2.54; // (2.54 cm/in) break; + case CSSPrimitiveValue::CSS_DPCM: + factor = 2.54 / cssPixelsPerInch; // (2.54 cm/in) + break; case CSSPrimitiveValue::CSS_MM: factor = cssPixelsPerInch / 25.4; break; case CSSPrimitiveValue::CSS_IN: factor = cssPixelsPerInch; break; + case CSSPrimitiveValue::CSS_DPI: + factor = 1 / cssPixelsPerInch; + break; case CSSPrimitiveValue::CSS_PT: factor = cssPixelsPerInch / 72.0; break; @@ -627,6 +652,10 @@ CSSPrimitiveValue::UnitTypes CSSPrimitiveValue::canonicalUnitTypeForCategory(Uni return CSS_HZ; case UViewportPercentageLength: return CSS_UNKNOWN; // Cannot convert between numbers and relative lengths. +#if ENABLE(CSS_IMAGE_RESOLUTION) + case UResolution: + return CSS_DPPX; +#endif default: return CSS_UNKNOWN; } @@ -697,6 +726,9 @@ String CSSPrimitiveValue::getStringValue(ExceptionCode& ec) const case CSS_STRING: case CSS_ATTR: case CSS_URI: +#if ENABLE(CSS_VARIABLES) + case CSS_VARIABLE_NAME: +#endif return m_value.string; case CSS_IDENT: return valueOrPropertyName(m_value.ident); @@ -714,7 +746,10 @@ String CSSPrimitiveValue::getStringValue() const case CSS_STRING: case CSS_ATTR: case CSS_URI: - return m_value.string; +#if ENABLE(CSS_VARIABLES) + case CSS_VARIABLE_NAME: +#endif + return m_value.string; case CSS_IDENT: return valueOrPropertyName(m_value.ident); default: @@ -828,6 +863,17 @@ String CSSPrimitiveValue::customCssText() const case CSS_CM: text = formatNumber(m_value.num) + "cm"; break; +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSS_DPPX: + text = formatNumber(m_value.num) + "dppx"; + break; + case CSS_DPI: + text = formatNumber(m_value.num) + "dpi"; + break; + case CSS_DPCM: + text = formatNumber(m_value.num) + "dpcm"; + break; +#endif case CSS_MM: text = formatNumber(m_value.num) + "mm"; break; @@ -1056,6 +1102,13 @@ String CSSPrimitiveValue::customCssText() const case CSS_VMIN: text = formatNumber(m_value.num) + "vmin"; break; +#if ENABLE(CSS_VARIABLES) + case CSS_VARIABLE_NAME: + text = "-webkit-var("; + text += m_value.string; + text += ")"; + break; +#endif } ASSERT(!cssTextCache().contains(this)); @@ -1064,6 +1117,15 @@ String CSSPrimitiveValue::customCssText() const return text; } +#if ENABLE(CSS_VARIABLES) +String CSSPrimitiveValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const +{ + if (m_primitiveUnitType == CSS_VARIABLE_NAME && variables.contains(m_value.string)) + return variables.get(m_value.string); + return customCssText(); +} +#endif + void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const { if (m_primitiveUnitType == CSS_URI) @@ -1151,6 +1213,11 @@ PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const case CSS_VW: case CSS_VH: case CSS_VMIN: +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSS_DPPX: + case CSS_DPI: + case CSS_DPCM: +#endif result = CSSPrimitiveValue::create(m_value.num, static_cast<UnitTypes>(m_primitiveUnitType)); break; case CSS_IDENT: diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h index ccd187be7..87069c043 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.h +++ b/Source/WebCore/css/CSSPrimitiveValue.h @@ -95,6 +95,9 @@ public: CSS_VW = 26, CSS_VH = 27, CSS_VMIN = 28, + CSS_DPPX = 29, + CSS_DPI = 30, + CSS_DPCM = 31, CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.) CSS_DASHBOARD_REGION = 101, // FIXME: Dashboard region should not be a primitive value. CSS_UNICODE_RANGE = 102, @@ -122,7 +125,11 @@ public: CSS_CALC = 112, CSS_CALC_PERCENTAGE_WITH_NUMBER = 113, - CSS_CALC_PERCENTAGE_WITH_LENGTH = 114 + CSS_CALC_PERCENTAGE_WITH_LENGTH = 114, + +#if ENABLE(CSS_VARIABLES) + CSS_VARIABLE_NAME = 115, +#endif }; // This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY for frequencies. @@ -134,6 +141,9 @@ public: UTime, UFrequency, UViewportPercentageLength, +#if ENABLE(CSS_IMAGE_RESOLUTION) + UResolution, +#endif UOther }; @@ -169,6 +179,9 @@ public: bool isCalculated() const { return m_primitiveUnitType == CSS_CALC; } bool isCalculatedPercentageWithNumber() const { return primitiveType() == CSS_CALC_PERCENTAGE_WITH_NUMBER; } bool isCalculatedPercentageWithLength() const { return primitiveType() == CSS_CALC_PERCENTAGE_WITH_LENGTH; } +#if ENABLE(CSS_VARIABLES) + bool isVariableName() const { return primitiveType() == CSS_VARIABLE_NAME; } +#endif bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VMIN; } static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); } @@ -280,6 +293,9 @@ public: template<typename T> inline operator T() const; // Defined in CSSPrimitiveValueMappings.h String customCssText() const; +#if ENABLE(CSS_VARIABLES) + String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const; +#endif bool isQuirkValue() { return m_isQuirkValue; } diff --git a/Source/WebCore/css/CSSPrimitiveValueMappings.h b/Source/WebCore/css/CSSPrimitiveValueMappings.h index f206b3f35..4855ec381 100644 --- a/Source/WebCore/css/CSSPrimitiveValueMappings.h +++ b/Source/WebCore/css/CSSPrimitiveValueMappings.h @@ -743,6 +743,7 @@ template<> inline CSSPrimitiveValue::operator EBoxAlignment() const } } +#if ENABLE(CSS_BOX_DECORATION_BREAK) template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxDecorationBreak e) : CSSValue(PrimitiveClass) { @@ -769,6 +770,7 @@ template<> inline CSSPrimitiveValue::operator EBoxDecorationBreak() const return DSLICE; } } +#endif template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxSizing e) : CSSValue(PrimitiveClass) @@ -1205,11 +1207,11 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignItems e) case AlignAuto: m_value.ident = CSSValueAuto; break; - case AlignStart: - m_value.ident = CSSValueStart; + case AlignFlexStart: + m_value.ident = CSSValueFlexStart; break; - case AlignEnd: - m_value.ident = CSSValueEnd; + case AlignFlexEnd: + m_value.ident = CSSValueFlexEnd; break; case AlignCenter: m_value.ident = CSSValueCenter; @@ -1228,10 +1230,10 @@ template<> inline CSSPrimitiveValue::operator EAlignItems() const switch (m_value.ident) { case CSSValueAuto: return AlignAuto; - case CSSValueStart: - return AlignStart; - case CSSValueEnd: - return AlignEnd; + case CSSValueFlexStart: + return AlignFlexStart; + case CSSValueFlexEnd: + return AlignFlexEnd; case CSSValueCenter: return AlignCenter; case CSSValueStretch: @@ -1240,49 +1242,49 @@ template<> inline CSSPrimitiveValue::operator EAlignItems() const return AlignBaseline; default: ASSERT_NOT_REACHED(); - return AlignStart; + return AlignFlexStart; } } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFlexPack e) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EJustifyContent e) : CSSValue(PrimitiveClass) { m_primitiveUnitType = CSS_IDENT; switch (e) { - case PackStart: - m_value.ident = CSSValueStart; + case JustifyFlexStart: + m_value.ident = CSSValueFlexStart; break; - case PackEnd: - m_value.ident = CSSValueEnd; + case JustifyFlexEnd: + m_value.ident = CSSValueFlexEnd; break; - case PackCenter: + case JustifyCenter: m_value.ident = CSSValueCenter; break; - case PackSpaceBetween: + case JustifySpaceBetween: m_value.ident = CSSValueSpaceBetween; break; - case PackSpaceAround: + case JustifySpaceAround: m_value.ident = CSSValueSpaceAround; break; } } -template<> inline CSSPrimitiveValue::operator EFlexPack() const +template<> inline CSSPrimitiveValue::operator EJustifyContent() const { switch (m_value.ident) { - case CSSValueStart: - return PackStart; - case CSSValueEnd: - return PackEnd; + case CSSValueFlexStart: + return JustifyFlexStart; + case CSSValueFlexEnd: + return JustifyFlexEnd; case CSSValueCenter: - return PackCenter; + return JustifyCenter; case CSSValueSpaceBetween: - return PackSpaceBetween; + return JustifySpaceBetween; case CSSValueSpaceAround: - return PackSpaceAround; + return JustifySpaceAround; default: ASSERT_NOT_REACHED(); - return PackStart; + return JustifyFlexStart; } } @@ -1323,50 +1325,50 @@ template<> inline CSSPrimitiveValue::operator EFlexDirection() const } } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFlexLinePack e) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignContent e) : CSSValue(PrimitiveClass) { m_primitiveUnitType = CSS_IDENT; switch (e) { - case LinePackStart: - m_value.ident = CSSValueStart; + case AlignContentFlexStart: + m_value.ident = CSSValueFlexStart; break; - case LinePackEnd: - m_value.ident = CSSValueEnd; + case AlignContentFlexEnd: + m_value.ident = CSSValueFlexEnd; break; - case LinePackCenter: + case AlignContentCenter: m_value.ident = CSSValueCenter; break; - case LinePackSpaceBetween: + case AlignContentSpaceBetween: m_value.ident = CSSValueSpaceBetween; break; - case LinePackSpaceAround: + case AlignContentSpaceAround: m_value.ident = CSSValueSpaceAround; break; - case LinePackStretch: + case AlignContentStretch: m_value.ident = CSSValueStretch; break; } } -template<> inline CSSPrimitiveValue::operator EFlexLinePack() const +template<> inline CSSPrimitiveValue::operator EAlignContent() const { switch (m_value.ident) { - case CSSValueStart: - return LinePackStart; - case CSSValueEnd: - return LinePackEnd; + case CSSValueFlexStart: + return AlignContentFlexStart; + case CSSValueFlexEnd: + return AlignContentFlexEnd; case CSSValueCenter: - return LinePackCenter; + return AlignContentCenter; case CSSValueSpaceBetween: - return LinePackSpaceBetween; + return AlignContentSpaceBetween; case CSSValueSpaceAround: - return LinePackSpaceAround; + return AlignContentSpaceAround; case CSSValueStretch: - return LinePackStretch; + return AlignContentStretch; default: ASSERT_NOT_REACHED(); - return LinePackStretch; + return AlignContentStretch; } } @@ -1902,33 +1904,6 @@ template<> inline CSSPrimitiveValue::operator EMarqueeDirection() const } } -template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMatchNearestMailBlockquoteColor e) - : CSSValue(PrimitiveClass) -{ - m_primitiveUnitType = CSS_IDENT; - switch (e) { - case BCNORMAL: - m_value.ident = CSSValueNormal; - break; - case MATCH: - m_value.ident = CSSValueMatch; - break; - } -} - -template<> inline CSSPrimitiveValue::operator EMatchNearestMailBlockquoteColor() const -{ - switch (m_value.ident) { - case CSSValueNormal: - return BCNORMAL; - case CSSValueMatch: - return MATCH; - default: - ASSERT_NOT_REACHED(); - return BCNORMAL; - } -} - template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ENBSPMode e) : CSSValue(PrimitiveClass) { @@ -2146,9 +2121,6 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAlign e) { m_primitiveUnitType = CSS_IDENT; switch (e) { - case TAAUTO: - m_value.ident = CSSValueWebkitAuto; - break; case TASTART: m_value.ident = CSSValueStart; break; @@ -2182,12 +2154,13 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextAlign e) template<> inline CSSPrimitiveValue::operator ETextAlign() const { switch (m_value.ident) { - case CSSValueStart: - return TASTART; - case CSSValueEnd: - return TAEND; - default: - return static_cast<ETextAlign>(m_value.ident - CSSValueWebkitAuto); + case CSSValueWebkitAuto: // Legacy -webkit-auto. Eqiuvalent to start. + case CSSValueStart: + return TASTART; + case CSSValueEnd: + return TAEND; + default: + return static_cast<ETextAlign>(m_value.ident - CSSValueLeft); } } @@ -3714,6 +3687,33 @@ template<> inline CSSPrimitiveValue::operator ColumnAxis() const } } +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColumnProgression e) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_IDENT; + switch (e) { + case NormalColumnProgression: + m_value.ident = CSSValueNormal; + break; + case ReverseColumnProgression: + m_value.ident = CSSValueReverse; + break; + } +} + +template<> inline CSSPrimitiveValue::operator ColumnProgression() const +{ + switch (m_value.ident) { + case CSSValueNormal: + return NormalColumnProgression; + case CSSValueReverse: + return ReverseColumnProgression; + default: + ASSERT_NOT_REACHED(); + return NormalColumnProgression; + } +} + template<> inline CSSPrimitiveValue::CSSPrimitiveValue(WrapFlow wrapFlow) : CSSValue(PrimitiveClass) { diff --git a/Source/WebCore/css/CSSProperty.cpp b/Source/WebCore/css/CSSProperty.cpp index a392cfacd..7a3d7154d 100644 --- a/Source/WebCore/css/CSSProperty.cpp +++ b/Source/WebCore/css/CSSProperty.cpp @@ -268,6 +268,9 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) case CSSPropertyFontVariant: case CSSPropertyFontWeight: case CSSPropertyImageRendering: +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSSPropertyImageResolution: +#endif case CSSPropertyLetterSpacing: case CSSPropertyLineHeight: case CSSPropertyListStyle: @@ -286,6 +289,9 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) case CSSPropertyTextRendering: case CSSPropertyTextShadow: case CSSPropertyTextTransform: +#if ENABLE(CSS_VARIABLES) + case CSSPropertyVariable: +#endif case CSSPropertyVisibility: case CSSPropertyWebkitAspectRatio: case CSSPropertyWebkitBorderHorizontalSpacing: @@ -513,7 +519,9 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) case CSSPropertyWebkitBorderStartStyle: case CSSPropertyWebkitBorderStartWidth: case CSSPropertyWebkitBoxAlign: +#if ENABLE(CSS_BOX_DECORATION_BREAK) case CSSPropertyWebkitBoxDecorationBreak: +#endif case CSSPropertyWebkitBoxFlex: case CSSPropertyWebkitBoxFlexGroup: case CSSPropertyWebkitBoxLines: @@ -528,6 +536,7 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) case CSSPropertyWebkitColumnBreakInside: case CSSPropertyWebkitColumnCount: case CSSPropertyWebkitColumnGap: + case CSSPropertyWebkitColumnProgression: case CSSPropertyWebkitColumnRule: case CSSPropertyWebkitColumnRuleColor: case CSSPropertyWebkitColumnRuleStyle: @@ -539,14 +548,15 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) case CSSPropertyWebkitFilter: #endif #if ENABLE(CSS3_FLEXBOX) + case CSSPropertyWebkitAlignContent: case CSSPropertyWebkitAlignItems: case CSSPropertyWebkitAlignSelf: case CSSPropertyWebkitFlex: - case CSSPropertyWebkitFlexPack: case CSSPropertyWebkitFlexDirection: case CSSPropertyWebkitFlexFlow: - case CSSPropertyWebkitFlexLinePack: case CSSPropertyWebkitFlexWrap: + case CSSPropertyWebkitJustifyContent: + case CSSPropertyWebkitOrder: #endif case CSSPropertyWebkitFontSizeDelta: case CSSPropertyWebkitGridColumns: @@ -590,12 +600,10 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) case CSSPropertyWebkitMaskRepeatX: case CSSPropertyWebkitMaskRepeatY: case CSSPropertyWebkitMaskSize: - case CSSPropertyWebkitMatchNearestMailBlockquoteColor: case CSSPropertyWebkitMaxLogicalWidth: case CSSPropertyWebkitMaxLogicalHeight: case CSSPropertyWebkitMinLogicalWidth: case CSSPropertyWebkitMinLogicalHeight: - case CSSPropertyWebkitOrder: case CSSPropertyWebkitPaddingAfter: case CSSPropertyWebkitPaddingBefore: case CSSPropertyWebkitPaddingEnd: diff --git a/Source/WebCore/css/CSSPropertyNames.in b/Source/WebCore/css/CSSPropertyNames.in index 633e10967..caaaf0eca 100644 --- a/Source/WebCore/css/CSSPropertyNames.in +++ b/Source/WebCore/css/CSSPropertyNames.in @@ -104,6 +104,9 @@ float font-stretch height image-rendering +#if defined(ENABLE_CSS_IMAGE_RESOLUTION) && ENABLE_CSS_IMAGE_RESOLUTION +image-resolution +#endif left letter-spacing list-style @@ -246,6 +249,7 @@ z-index -webkit-column-break-inside -webkit-column-count -webkit-column-gap +-webkit-column-progression -webkit-column-rule -webkit-column-rule-color -webkit-column-rule-style @@ -253,19 +257,21 @@ z-index -webkit-column-span -webkit-column-width -webkit-columns +#if defined(ENABLE_CSS_BOX_DECORATION_BREAK) && ENABLE_CSS_BOX_DECORATION_BREAK -webkit-box-decoration-break +#endif #if defined(ENABLE_CSS_FILTERS) && ENABLE_CSS_FILTERS -webkit-filter #endif #if defined(ENABLE_CSS3_FLEXBOX) && ENABLE_CSS3_FLEXBOX +-webkit-align-content -webkit-align-items -webkit-align-self -webkit-flex -webkit-flex-direction -webkit-flex-flow --webkit-flex-line-pack --webkit-flex-pack -webkit-flex-wrap +-webkit-justify-content #endif -webkit-font-size-delta -webkit-grid-columns @@ -321,7 +327,6 @@ z-index -webkit-mask-repeat-x -webkit-mask-repeat-y -webkit-mask-size --webkit-match-nearest-mail-blockquote-color -webkit-max-logical-width -webkit-max-logical-height -webkit-min-logical-width @@ -390,6 +395,6 @@ z-index #if defined(ENABLE_DASHBOARD_SUPPORT) && ENABLE_DASHBOARD_SUPPORT -webkit-dashboard-region #endif -#if defined(ENABLE_OVERFLOW_SCROLLING) +#if defined(ENABLE_OVERFLOW_SCROLLING) && ENABLE_OVERFLOW_SCROLLING -webkit-overflow-scrolling #endif diff --git a/Source/WebCore/css/CSSPropertySourceData.h b/Source/WebCore/css/CSSPropertySourceData.h index 5803f94b1..ba676ee33 100644 --- a/Source/WebCore/css/CSSPropertySourceData.h +++ b/Source/WebCore/css/CSSPropertySourceData.h @@ -83,6 +83,9 @@ struct CSSStyleSourceData : public RefCounted<CSSStyleSourceData> { Vector<CSSPropertySourceData> propertyData; }; +struct CSSRuleSourceData; +typedef Vector<RefPtr<CSSRuleSourceData> > RuleSourceDataList; + struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> { static PassRefPtr<CSSRuleSourceData> create() { diff --git a/Source/WebCore/css/CSSValue.cpp b/Source/WebCore/css/CSSValue.cpp index f568cc5f4..40a1bc09e 100644 --- a/Source/WebCore/css/CSSValue.cpp +++ b/Source/WebCore/css/CSSValue.cpp @@ -47,6 +47,9 @@ #include "CSSTimingFunctionValue.h" #include "CSSUnicodeRangeValue.h" #include "CSSValueList.h" +#if ENABLE(CSS_VARIABLES) +#include "CSSVariableValue.h" +#endif #include "FontValue.h" #include "FontFeatureValue.h" #include "ShadowValue.h" @@ -58,7 +61,7 @@ namespace WebCore { -class SameSizeAsCSSValue : public RefCounted<SameSizeAsCSSValue> { +struct SameSizeAsCSSValue : public RefCounted<SameSizeAsCSSValue> { uint32_t bitfields; }; @@ -185,6 +188,10 @@ String CSSValue::cssText() const return static_cast<const WebKitCSSShaderValue*>(this)->customCssText(); #endif #endif +#if ENABLE(CSS_VARIABLES) + case VariableClass: + return static_cast<const CSSVariableValue*>(this)->value(); +#endif #if ENABLE(SVG) case SVGColorClass: return static_cast<const SVGColor*>(this)->customCssText(); @@ -196,6 +203,22 @@ String CSSValue::cssText() const return String(); } +#if ENABLE(CSS_VARIABLES) +String CSSValue::serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const +{ + switch (classType()) { + case PrimitiveClass: + return static_cast<const CSSPrimitiveValue*>(this)->customSerializeResolvingVariables(variables); + case ValueListClass: + return static_cast<const CSSValueList*>(this)->customSerializeResolvingVariables(variables); + case WebKitCSSTransformClass: + return static_cast<const WebKitCSSTransformValue*>(this)->customSerializeResolvingVariables(variables); + default: + return cssText(); + } +} +#endif + void CSSValue::destroy() { if (m_isTextClone) { @@ -296,6 +319,11 @@ void CSSValue::destroy() return; #endif #endif +#if ENABLE(CSS_VARIABLES) + case VariableClass: + delete static_cast<CSSVariableValue*>(this); + return; +#endif #if ENABLE(SVG) case SVGColorClass: delete static_cast<SVGColor*>(this); diff --git a/Source/WebCore/css/CSSValue.h b/Source/WebCore/css/CSSValue.h index fe56428a1..b4e8a89e7 100644 --- a/Source/WebCore/css/CSSValue.h +++ b/Source/WebCore/css/CSSValue.h @@ -59,6 +59,9 @@ public: String cssText() const; void setCssText(const String&, ExceptionCode&) { } // FIXME: Not implemented. +#if ENABLE(CSS_VARIABLES) + String serializeResolvingVariables(const HashMap<AtomicString, String>&) const; +#endif bool isPrimitiveValue() const { return m_classType == PrimitiveClass; } bool isValueList() const { return m_classType >= ValueListClass; } @@ -90,6 +93,9 @@ public: bool isWebKitCSSShaderValue() const { return m_classType == WebKitCSSShaderClass; } #endif #endif // ENABLE(CSS_FILTERS) +#if ENABLE(CSS_VARIABLES) + bool isVariableValue() const { return m_classType == VariableClass; } +#endif #if ENABLE(SVG) bool isSVGColor() const { return m_classType == SVGColorClass || m_classType == SVGPaintClass; } bool isSVGPaint() const { return m_classType == SVGPaintClass; } @@ -149,6 +155,9 @@ protected: #if ENABLE(CSS_FILTERS) && ENABLE(CSS_SHADERS) WebKitCSSShaderClass, #endif +#if ENABLE(CSS_VARIABLES) + VariableClass, +#endif #if ENABLE(SVG) SVGColorClass, SVGPaintClass, diff --git a/Source/WebCore/css/CSSValueKeywords.in b/Source/WebCore/css/CSSValueKeywords.in index e39b0166d..e82a532fb 100644 --- a/Source/WebCore/css/CSSValueKeywords.in +++ b/Source/WebCore/css/CSSValueKeywords.in @@ -151,7 +151,6 @@ inactivecaption inactivecaptiontext infobackground infotext -match menutext scrollbar threeddarkshadow @@ -463,9 +462,11 @@ end //center //baseline +#if defined(ENABLE_CSS_BOX_DECORATION_BREAK) && ENABLE_CSS_BOX_DECORATION_BREAK // CSS_PROP_BOX_DECORATION_BREAK clone slice +#endif // CSS_PROP_BOX_DIRECTION // normal @@ -488,19 +489,27 @@ single multiple #if defined(ENABLE_CSS3_FLEXBOX) && ENABLE_CSS3_FLEXBOX -// CSS_PROP_FLEX_ALIGN -// start -// end +// CSS_PROP_ALIGN_CONTENT +flex-start +flex-end +// center +space-between +space-around +// stretch + +// CSS_PROP_ALIGN_ITEMS / CSS_PROP_ALIGN_SELF +// flex-start +// flex-end // center // baseline // stretch -// CSS_PROP_FLEX_PACK -// start -// end +// CSS_PROP_JUSTIFY_CONTENT +// flex-start +// flex-end // center -space-between -space-around +// space-between +// space-around // CSS_PROP_FLEX_FLOW row @@ -511,13 +520,6 @@ column-reverse // wrap wrap-reverse -// CSS_PROP_FLEX_LINE_PACK -// start -// end -// center -// space-between -// space-around -// stretch #endif // CSS_PROP_MARQUEE_DIRECTION @@ -819,7 +821,7 @@ no-limit manual // auto -#if defined(ENABLE_OVERFLOW_SCROLLING) +#if defined(ENABLE_OVERFLOW_SCROLLING) && ENABLE_OVERFLOW_SCROLLING // -webkit-overflow-scrolling // auto touch @@ -921,3 +923,7 @@ filter-box detached #endif // CSS_SHADERS #endif // CSS_FILTERS + +#if defined(ENABLE_CSS_IMAGE_RESOLUTION) && ENABLE_CSS_IMAGE_RESOLUTION +from-image +#endif diff --git a/Source/WebCore/css/CSSValueList.cpp b/Source/WebCore/css/CSSValueList.cpp index 3ab7f9411..06f093e1f 100644 --- a/Source/WebCore/css/CSSValueList.cpp +++ b/Source/WebCore/css/CSSValueList.cpp @@ -136,6 +136,36 @@ String CSSValueList::customCssText() const return result.toString(); } +#if ENABLE(CSS_VARIABLES) +String CSSValueList::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const +{ + StringBuilder result; + String separator; + switch (m_valueListSeparator) { + case SpaceSeparator: + separator = " "; + break; + case CommaSeparator: + separator = ", "; + break; + case SlashSeparator: + separator = " / "; + break; + default: + ASSERT_NOT_REACHED(); + } + + unsigned size = m_values.size(); + for (unsigned i = 0; i < size; i++) { + if (!result.isEmpty()) + result.append(separator); + result.append(m_values[i]->serializeResolvingVariables(variables)); + } + + return result.toString(); +} +#endif + void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const { size_t size = m_values.size(); diff --git a/Source/WebCore/css/CSSValueList.h b/Source/WebCore/css/CSSValueList.h index a4c59b4b0..94643daad 100644 --- a/Source/WebCore/css/CSSValueList.h +++ b/Source/WebCore/css/CSSValueList.h @@ -59,6 +59,9 @@ public: PassRefPtr<CSSValueList> copy(); String customCssText() const; +#if ENABLE(CSS_VARIABLES) + String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const; +#endif void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const; diff --git a/Source/WebCore/css/CSSVariableValue.h b/Source/WebCore/css/CSSVariableValue.h new file mode 100644 index 000000000..2c5b66a6b --- /dev/null +++ b/Source/WebCore/css/CSSVariableValue.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CSSVariableValue_h +#define CSSVariableValue_h + +#if ENABLE(CSS_VARIABLES) + +#include "CSSParserValues.h" +#include "CSSPropertyNames.h" +#include "CSSValue.h" + +namespace WebCore { + +class CSSVariableValue : public CSSValue { +public: + static PassRefPtr<CSSVariableValue> create(const AtomicString& name, const String& value) + { + return adoptRef(new CSSVariableValue(name, value)); + } + + const AtomicString& name() const { return m_name; } + const String& value() const { return m_value; } + +private: + CSSVariableValue(const AtomicString& name, const String& value) + : CSSValue(VariableClass) + , m_name(name) + , m_value(value) + { + } + + const AtomicString m_name; + const String m_value; +}; + +} + +#endif /* ENABLE(CSS_VARIABLES) */ +#endif /* CSSVariableValue_h */ diff --git a/Source/WebCore/css/CSSWrapShapes.h b/Source/WebCore/css/CSSWrapShapes.h index ca37289e5..c877a270f 100644 --- a/Source/WebCore/css/CSSWrapShapes.h +++ b/Source/WebCore/css/CSSWrapShapes.h @@ -44,8 +44,7 @@ public: CSS_WRAP_SHAPE_RECTANGLE = 1, CSS_WRAP_SHAPE_CIRCLE = 2, CSS_WRAP_SHAPE_ELLIPSE = 3, - CSS_WRAP_SHAPE_POLYGON = 4, - CSS_WRAP_SHAPE_PATH = 5 + CSS_WRAP_SHAPE_POLYGON = 4 }; virtual Type type() = 0; diff --git a/Source/WebCore/css/MediaQueryListListener.h b/Source/WebCore/css/MediaQueryListListener.h index de62683c0..da167dbfd 100644 --- a/Source/WebCore/css/MediaQueryListListener.h +++ b/Source/WebCore/css/MediaQueryListListener.h @@ -34,7 +34,7 @@ class MediaQueryList; class MediaQueryListListener : public RefCounted<MediaQueryListListener> { public: - static PassRefPtr<MediaQueryListListener> create(ScriptValue value) + static PassRefPtr<MediaQueryListListener> create(const ScriptValue& value) { if (!value.isFunction()) return 0; @@ -45,7 +45,7 @@ public: bool operator==(const MediaQueryListListener& other) const { return m_value == other.m_value; } private: - MediaQueryListListener(ScriptValue value) : m_value(value) { } + MediaQueryListListener(const ScriptValue& value) : m_value(value) { } ScriptValue m_value; }; diff --git a/Source/WebCore/css/SVGCSSPropertyNames.in b/Source/WebCore/css/SVGCSSPropertyNames.in index 142094e84..34e4ca33c 100644 --- a/Source/WebCore/css/SVGCSSPropertyNames.in +++ b/Source/WebCore/css/SVGCSSPropertyNames.in @@ -2,6 +2,8 @@ // SVG CSS property names // +#if defined(ENABLE_SVG) && ENABLE_SVG + // SVG style props clip-path clip-rule @@ -49,3 +51,6 @@ vector-effect writing-mode -webkit-svg-shadow + +#endif + diff --git a/Source/WebCore/css/SelectorChecker.cpp b/Source/WebCore/css/SelectorChecker.cpp index 50fed4808..d959f6715 100644 --- a/Source/WebCore/css/SelectorChecker.cpp +++ b/Source/WebCore/css/SelectorChecker.cpp @@ -1177,14 +1177,14 @@ bool SelectorChecker::checkOneSelector(const SelectorCheckingContext& context, P return false; } if (selector->m_match == CSSSelector::PseudoElement) { - if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules) - return false; - if (selector->isUnknownPseudoElement()) { m_hasUnknownPseudoElements = true; return element->shadowPseudoId() == selector->value(); } + if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules) + return false; + PseudoId pseudoId = CSSSelector::pseudoId(selector->pseudoType()); if (pseudoId == FIRST_LETTER) { if (Document* document = element->document()) diff --git a/Source/WebCore/css/StyleBuilder.cpp b/Source/WebCore/css/StyleBuilder.cpp index 1492e04c7..304db7cdf 100644 --- a/Source/WebCore/css/StyleBuilder.cpp +++ b/Source/WebCore/css/StyleBuilder.cpp @@ -1707,16 +1707,16 @@ class ApplyPropertyFlex { public: static void applyInheritValue(StyleResolver* styleResolver) { - ApplyPropertyDefaultBase<float, &RenderStyle::positiveFlex, float, &RenderStyle::setPositiveFlex, float, &RenderStyle::initialNegativeFlex>::applyInheritValue(styleResolver); - ApplyPropertyDefaultBase<float, &RenderStyle::negativeFlex, float, &RenderStyle::setNegativeFlex, float, &RenderStyle::initialPositiveFlex>::applyInheritValue(styleResolver); - ApplyPropertyDefaultBase<Length, &RenderStyle::flexPreferredSize, Length, &RenderStyle::setFlexPreferredSize, Length, &RenderStyle::initialFlexPreferredSize>::applyInheritValue(styleResolver); + ApplyPropertyDefaultBase<float, &RenderStyle::flexGrow, float, &RenderStyle::setFlexGrow, float, &RenderStyle::initialFlexGrow>::applyInheritValue(styleResolver); + ApplyPropertyDefaultBase<float, &RenderStyle::flexShrink, float, &RenderStyle::setFlexShrink, float, &RenderStyle::initialFlexShrink>::applyInheritValue(styleResolver); + ApplyPropertyDefaultBase<Length, &RenderStyle::flexBasis, Length, &RenderStyle::setFlexBasis, Length, &RenderStyle::initialFlexBasis>::applyInheritValue(styleResolver); } static void applyInitialValue(StyleResolver* styleResolver) { - styleResolver->style()->setPositiveFlex(RenderStyle::initialPositiveFlex()); - styleResolver->style()->setNegativeFlex(RenderStyle::initialNegativeFlex()); - styleResolver->style()->setFlexPreferredSize(RenderStyle::initialFlexPreferredSize()); + styleResolver->style()->setFlexGrow(RenderStyle::initialFlexGrow()); + styleResolver->style()->setFlexShrink(RenderStyle::initialFlexShrink()); + styleResolver->style()->setFlexBasis(RenderStyle::initialFlexBasis()); } static void applyValue(StyleResolver* styleResolver, CSSValue* value) @@ -1724,9 +1724,9 @@ public: if (value->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); if (primitiveValue->getIdent() == CSSValueNone) { - styleResolver->style()->setPositiveFlex(0); - styleResolver->style()->setNegativeFlex(0); - styleResolver->style()->setFlexPreferredSize(Length(Auto)); + styleResolver->style()->setFlexGrow(0); + styleResolver->style()->setFlexShrink(0); + styleResolver->style()->setFlexBasis(Length(Auto)); } return; } @@ -1740,13 +1740,13 @@ public: float flexValue = 0; if (!getFlexValue(valueList->itemWithoutBoundsCheck(0), flexValue)) return; - styleResolver->style()->setPositiveFlex(flexValue); + styleResolver->style()->setFlexGrow(flexValue); if (!getFlexValue(valueList->itemWithoutBoundsCheck(1), flexValue)) return; - styleResolver->style()->setNegativeFlex(flexValue); + styleResolver->style()->setFlexShrink(flexValue); - ApplyPropertyLength<&RenderStyle::flexPreferredSize, &RenderStyle::setFlexPreferredSize, &RenderStyle::initialFlexPreferredSize, AutoEnabled>::applyValue(styleResolver, valueList->itemWithoutBoundsCheck(2)); + ApplyPropertyLength<&RenderStyle::flexBasis, &RenderStyle::setFlexBasis, &RenderStyle::initialFlexBasis, AutoEnabled>::applyValue(styleResolver, valueList->itemWithoutBoundsCheck(2)); } static PropertyHandler createHandler() @@ -1767,6 +1767,49 @@ private: }; +#if ENABLE(CSS_IMAGE_RESOLUTION) +class ApplyPropertyImageResolution { +public: + static void applyInheritValue(StyleResolver* styleResolver) + { + ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInheritValue(styleResolver); + ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInheritValue(styleResolver); + } + + static void applyInitialValue(StyleResolver* styleResolver) + { + ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInitialValue(styleResolver); + ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInitialValue(styleResolver); + } + + static void applyValue(StyleResolver* styleResolver, CSSValue* value) + { + if (!value->isValueList()) + return; + CSSValueList* valueList = static_cast<CSSValueList*>(value); + ImageResolutionSource source = RenderStyle::initialImageResolutionSource(); + double resolution = RenderStyle::initialImageResolution(); + for (size_t i = 0; i < valueList->length(); i++) { + CSSValue* item = valueList->itemWithoutBoundsCheck(i); + if (!item->isPrimitiveValue()) + continue; + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item); + if (primitiveValue->getIdent() == CSSValueFromImage) + source = ImageResolutionFromImage; + else + resolution = primitiveValue->getDoubleValue(CSSPrimitiveValue::CSS_DPPX); + } + styleResolver->style()->setImageResolutionSource(source); + styleResolver->style()->setImageResolution(resolution); + } + + static PropertyHandler createHandler() + { + return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); + } +}; +#endif + const StyleBuilder& StyleBuilder::sharedStyleBuilder() { DEFINE_STATIC_LOCAL(StyleBuilder, styleBuilderInstance, ()); @@ -1843,6 +1886,9 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler()); setPropertyHandler(CSSPropertyHeight, ApplyPropertyLength<&RenderStyle::height, &RenderStyle::setHeight, &RenderStyle::initialSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneDisabled, UndefinedDisabled>::createHandler()); setPropertyHandler(CSSPropertyImageRendering, ApplyPropertyDefault<EImageRendering, &RenderStyle::imageRendering, EImageRendering, &RenderStyle::setImageRendering, EImageRendering, &RenderStyle::initialImageRendering>::createHandler()); +#if ENABLE(CSS_IMAGE_RESOLUTION) + setPropertyHandler(CSSPropertyImageResolution, ApplyPropertyImageResolution::createHandler()); +#endif setPropertyHandler(CSSPropertyLeft, ApplyPropertyLength<&RenderStyle::left, &RenderStyle::setLeft, &RenderStyle::initialOffset, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyLetterSpacing, ApplyPropertyComputeLength<int, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing, &RenderStyle::initialLetterWordSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler()); setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeight::createHandler()); @@ -1914,7 +1960,9 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyWebkitBorderRadius, CSSPropertyBorderRadius); setPropertyHandler(CSSPropertyWebkitBorderVerticalSpacing, ApplyPropertyComputeLength<short, &RenderStyle::verticalBorderSpacing, &RenderStyle::setVerticalBorderSpacing, &RenderStyle::initialVerticalBorderSpacing>::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxAlign, ApplyPropertyDefault<EBoxAlignment, &RenderStyle::boxAlign, EBoxAlignment, &RenderStyle::setBoxAlign, EBoxAlignment, &RenderStyle::initialBoxAlign>::createHandler()); +#if ENABLE(CSS_BOX_DECORATION_BREAK) setPropertyHandler(CSSPropertyWebkitBoxDecorationBreak, ApplyPropertyDefault<EBoxDecorationBreak, &RenderStyle::boxDecorationBreak, EBoxDecorationBreak, &RenderStyle::setBoxDecorationBreak, EBoxDecorationBreak, &RenderStyle::initialBoxDecorationBreak>::createHandler()); +#endif setPropertyHandler(CSSPropertyWebkitBoxDirection, ApplyPropertyDefault<EBoxDirection, &RenderStyle::boxDirection, EBoxDirection, &RenderStyle::setBoxDirection, EBoxDirection, &RenderStyle::initialBoxDirection>::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxFlex, ApplyPropertyDefault<float, &RenderStyle::boxFlex, float, &RenderStyle::setBoxFlex, float, &RenderStyle::initialBoxFlex>::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxFlexGroup, ApplyPropertyDefault<unsigned int, &RenderStyle::boxFlexGroup, unsigned int, &RenderStyle::setBoxFlexGroup, unsigned int, &RenderStyle::initialBoxFlexGroup>::createHandler()); @@ -1929,6 +1977,7 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyWebkitColumnBreakInside, ApplyPropertyDefault<EPageBreak, &RenderStyle::columnBreakInside, EPageBreak, &RenderStyle::setColumnBreakInside, EPageBreak, &RenderStyle::initialPageBreak>::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnCount, ApplyPropertyAuto<unsigned short, &RenderStyle::columnCount, &RenderStyle::setColumnCount, &RenderStyle::hasAutoColumnCount, &RenderStyle::setHasAutoColumnCount>::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnGap, ApplyPropertyAuto<float, &RenderStyle::columnGap, &RenderStyle::setColumnGap, &RenderStyle::hasNormalColumnGap, &RenderStyle::setHasNormalColumnGap, ComputeLength, CSSValueNormal>::createHandler()); + setPropertyHandler(CSSPropertyWebkitColumnProgression, ApplyPropertyDefault<ColumnProgression, &RenderStyle::columnProgression, ColumnProgression, &RenderStyle::setColumnProgression, ColumnProgression, &RenderStyle::initialColumnProgression>::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnRuleColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor, &RenderStyle::setVisitedLinkColumnRuleColor, &RenderStyle::color>::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnRuleWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth, &RenderStyle::initialColumnRuleWidth, NormalDisabled, ThicknessEnabled>::createHandler()); setPropertyHandler(CSSPropertyWebkitColumns, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitColumnWidth, CSSPropertyWebkitColumnCount>::createHandler()); @@ -1936,14 +1985,15 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyWebkitColumnRuleStyle, ApplyPropertyDefault<EBorderStyle, &RenderStyle::columnRuleStyle, EBorderStyle, &RenderStyle::setColumnRuleStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnWidth, ApplyPropertyAuto<float, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth, &RenderStyle::hasAutoColumnWidth, &RenderStyle::setHasAutoColumnWidth, ComputeLength>::createHandler()); #if ENABLE(CSS3_FLEXBOX) + setPropertyHandler(CSSPropertyWebkitAlignContent, ApplyPropertyDefault<EAlignContent, &RenderStyle::alignContent, EAlignContent, &RenderStyle::setAlignContent, EAlignContent, &RenderStyle::initialAlignContent>::createHandler()); setPropertyHandler(CSSPropertyWebkitAlignItems, ApplyPropertyDefault<EAlignItems, &RenderStyle::alignItems, EAlignItems, &RenderStyle::setAlignItems, EAlignItems, &RenderStyle::initialAlignItems>::createHandler()); setPropertyHandler(CSSPropertyWebkitAlignSelf, ApplyPropertyDefault<EAlignItems, &RenderStyle::alignSelf, EAlignItems, &RenderStyle::setAlignSelf, EAlignItems, &RenderStyle::initialAlignSelf>::createHandler()); setPropertyHandler(CSSPropertyWebkitFlex, ApplyPropertyFlex::createHandler()); setPropertyHandler(CSSPropertyWebkitFlexDirection, ApplyPropertyDefault<EFlexDirection, &RenderStyle::flexDirection, EFlexDirection, &RenderStyle::setFlexDirection, EFlexDirection, &RenderStyle::initialFlexDirection>::createHandler()); setPropertyHandler(CSSPropertyWebkitFlexFlow, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap>::createHandler()); - setPropertyHandler(CSSPropertyWebkitFlexLinePack, ApplyPropertyDefault<EFlexLinePack, &RenderStyle::flexLinePack, EFlexLinePack, &RenderStyle::setFlexLinePack, EFlexLinePack, &RenderStyle::initialFlexLinePack>::createHandler()); - setPropertyHandler(CSSPropertyWebkitFlexPack, ApplyPropertyDefault<EFlexPack, &RenderStyle::flexPack, EFlexPack, &RenderStyle::setFlexPack, EFlexPack, &RenderStyle::initialFlexPack>::createHandler()); setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault<EFlexWrap, &RenderStyle::flexWrap, EFlexWrap, &RenderStyle::setFlexWrap, EFlexWrap, &RenderStyle::initialFlexWrap>::createHandler()); + setPropertyHandler(CSSPropertyWebkitJustifyContent, ApplyPropertyDefault<EJustifyContent, &RenderStyle::justifyContent, EJustifyContent, &RenderStyle::setJustifyContent, EJustifyContent, &RenderStyle::initialJustifyContent>::createHandler()); + setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<float, &RenderStyle::order, float, &RenderStyle::setOrder, float, &RenderStyle::initialOrder>::createHandler()); #endif #if ENABLE(CSS_REGIONS) setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString<MapNoneToNull, &RenderStyle::regionThread, &RenderStyle::setRegionThread, &RenderStyle::initialRegionThread>::createHandler()); @@ -1987,9 +2037,7 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyWebkitMaskRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &StyleResolver::mapFillRepeatX>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &StyleResolver::mapFillRepeatY>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskSize, ApplyPropertyFillLayer<FillSize, CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &StyleResolver::mapFillSize>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMatchNearestMailBlockquoteColor, ApplyPropertyDefault<EMatchNearestMailBlockquoteColor, &RenderStyle::matchNearestMailBlockquoteColor, EMatchNearestMailBlockquoteColor, &RenderStyle::setMatchNearestMailBlockquoteColor, EMatchNearestMailBlockquoteColor, &RenderStyle::initialMatchNearestMailBlockquoteColor>::createHandler()); setPropertyHandler(CSSPropertyWebkitNbspMode, ApplyPropertyDefault<ENBSPMode, &RenderStyle::nbspMode, ENBSPMode, &RenderStyle::setNBSPMode, ENBSPMode, &RenderStyle::initialNBSPMode>::createHandler()); - setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<int, &RenderStyle::order, int, &RenderStyle::setOrder, int, &RenderStyle::initialOrder>::createHandler()); setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitPerspectiveOriginX, CSSPropertyWebkitPerspectiveOriginY>::createHandler()); setPropertyHandler(CSSPropertyWebkitPerspectiveOriginX, ApplyPropertyLength<&RenderStyle::perspectiveOriginX, &RenderStyle::setPerspectiveOriginX, &RenderStyle::initialPerspectiveOriginX>::createHandler()); setPropertyHandler(CSSPropertyWebkitPerspectiveOriginY, ApplyPropertyLength<&RenderStyle::perspectiveOriginY, &RenderStyle::setPerspectiveOriginY, &RenderStyle::initialPerspectiveOriginY>::createHandler()); diff --git a/Source/WebCore/css/StylePropertySet.cpp b/Source/WebCore/css/StylePropertySet.cpp index cbe92c4b5..60afd5e70 100644 --- a/Source/WebCore/css/StylePropertySet.cpp +++ b/Source/WebCore/css/StylePropertySet.cpp @@ -861,18 +861,16 @@ String StylePropertySet::asText() const return result.toString(); } -void StylePropertySet::merge(const StylePropertySet* other, bool argOverridesOnConflict) +void StylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) { ASSERT(isMutable()); unsigned size = other->propertyCount(); for (unsigned n = 0; n < size; ++n) { const CSSProperty& toMerge = other->propertyAt(n); CSSProperty* old = findPropertyWithId(toMerge.id()); - if (old) { - if (!argOverridesOnConflict && old->value()) - continue; + if (old) setProperty(toMerge, old); - } else + else append(toMerge); } } @@ -1066,7 +1064,7 @@ unsigned StylePropertySet::averageSizeInBytes() } // See the function above if you need to update this. -class SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet> { +struct SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet> { unsigned bitfield; void* properties; }; diff --git a/Source/WebCore/css/StylePropertySet.h b/Source/WebCore/css/StylePropertySet.h index e7992ed35..74ce079a4 100644 --- a/Source/WebCore/css/StylePropertySet.h +++ b/Source/WebCore/css/StylePropertySet.h @@ -83,7 +83,7 @@ public: void removeBlockProperties(); bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); - void merge(const StylePropertySet*, bool argOverridesOnConflict = true); + void mergeAndOverrideOnConflict(const StylePropertySet*); void setCSSParserMode(CSSParserMode); CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); } diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp index abbaff1c2..93dff2ba5 100644 --- a/Source/WebCore/css/StyleResolver.cpp +++ b/Source/WebCore/css/StyleResolver.cpp @@ -49,10 +49,13 @@ #include "CSSStyleSheet.h" #include "CSSTimingFunctionValue.h" #include "CSSValueList.h" +#if ENABLE(CSS_VARIABLES) +#include "CSSVariableValue.h" +#endif #include "CachedImage.h" #include "CalculationValue.h" #include "ContentData.h" -#include "ContextEnabledFeatures.h" +#include "ContextFeatures.h" #include "Counter.h" #include "CounterContent.h" #include "CursorList.h" @@ -73,11 +76,13 @@ #include "KeyframeList.h" #include "LinkHash.h" #include "LocaleToScriptMapping.h" +#include "MathMLNames.h" #include "Matrix3DTransformOperation.h" #include "MatrixTransformOperation.h" #include "MediaList.h" #include "MediaQueryEvaluator.h" #include "NodeRenderStyle.h" +#include "NodeRenderingContext.h" #include "Page.h" #include "PageGroup.h" #include "Pair.h" @@ -490,7 +495,7 @@ const ContainerNode* StyleResolver::determineScope(const CSSStyleSheet* sheet) { ASSERT(sheet); - if (!ContextEnabledFeatures::styleScopedEnabled(document())) + if (!ContextFeatures::styleScopedEnabled(document())) return 0; Node* ownerNode = sheet->ownerNode(); @@ -499,7 +504,7 @@ const ContainerNode* StyleResolver::determineScope(const CSSStyleSheet* sheet) HTMLStyleElement* styleElement = static_cast<HTMLStyleElement*>(ownerNode); if (!styleElement->scoped()) - return 0; + return styleElement->isInShadowTree()? styleElement->shadowRoot() : 0; ContainerNode* parent = styleElement->parentNode(); if (!parent) @@ -559,10 +564,10 @@ void StyleResolver::setupScopeStack(const ContainerNode* parent) ASSERT(!m_scopedAuthorStyles.isEmpty()); m_scopeStack.shrink(0); - for (; parent; parent = parent->parentOrHostNode()) { - RuleSet* ruleSet = ruleSetForScope(parent); + for (const ContainerNode* scope = parent; scope; scope = scope->parentOrHostNode()) { + RuleSet* ruleSet = ruleSetForScope(scope); if (ruleSet) - m_scopeStack.append(ScopeStackFrame(parent, ruleSet)); + m_scopeStack.append(ScopeStackFrame(scope, ruleSet)); } m_scopeStack.reverse(); m_scopeStackParent = parent; @@ -593,7 +598,8 @@ void StyleResolver::popScope(const ContainerNode* scope) { // Only bother to update the scoping element stack if it is consistent. if (scopeStackIsConsistent(scope)) { - m_scopeStack.removeLast(); + if (!m_scopeStack.isEmpty() && m_scopeStack.last().m_scope == scope) + m_scopeStack.removeLast(); m_scopeStackParent = scope->parentOrHostNode(); } } @@ -1140,6 +1146,8 @@ void StyleResolver::matchAllRules(MatchResult& result, bool includeSMILPropertie // Now check SMIL animation override style. if (includeSMILProperties && m_matchAuthorAndUserStyles && m_styledElement && m_styledElement->isSVGElement()) addElementStyleProperties(result, static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties(), false /* isCacheable */); +#else + UNUSED_PARAM(includeSMILProperties); #endif } @@ -1160,12 +1168,16 @@ inline void StyleResolver::initForStyleResolve(Element* e, RenderStyle* parentSt { m_checker.setPseudoStyle(pseudoID); - m_parentNode = e ? e->parentNodeForRenderingAndStyle() : 0; - - if (parentStyle) + if (e) { + NodeRenderingContext context(e); + m_parentNode = context.parentNodeForRenderingAndStyle(); + m_parentStyle = context.resetStyleInheritance()? 0 : + parentStyle ? parentStyle : + m_parentNode ? m_parentNode->renderStyle() : 0; + } else { + m_parentNode = 0; m_parentStyle = parentStyle; - else - m_parentStyle = m_parentNode ? m_parentNode->renderStyle() : 0; + } Node* docElement = e ? e->document()->documentElement() : 0; RenderStyle* docStyle = m_checker.document()->renderStyle(); @@ -1389,10 +1401,10 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const } #endif - if (element->hasTagName(optionTag)) - return false; - - if (element->hasTagName(optgroupTag) && m_element->disabled() != element->disabled()) + // FIXME: We should share style for option and optgroup whenever possible. + // Before doing so, we need to resolve issues in HTMLSelectElement::recalcListItems + // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cgi?id=88405 + if (element->hasTagName(optionTag) || element->hasTagName(optgroupTag)) return false; bool isControl = element->isFormControlElement(); @@ -1577,7 +1589,40 @@ PassRefPtr<RenderStyle> StyleResolver::styleForDocument(Document* document, CSSF if (Page* page = frame->page()) { const Page::Pagination& pagination = page->pagination(); if (pagination.mode != Page::Pagination::Unpaginated) { - documentStyle->setColumnAxis(pagination.mode == Page::Pagination::HorizontallyPaginated ? HorizontalColumnAxis : VerticalColumnAxis); + switch (pagination.mode) { + case Page::Pagination::LeftToRightPaginated: + documentStyle->setColumnAxis(HorizontalColumnAxis); + if (documentStyle->isHorizontalWritingMode()) + documentStyle->setColumnProgression(documentStyle->isLeftToRightDirection() ? NormalColumnProgression : ReverseColumnProgression); + else + documentStyle->setColumnProgression(documentStyle->isFlippedBlocksWritingMode() ? ReverseColumnProgression : NormalColumnProgression); + break; + case Page::Pagination::RightToLeftPaginated: + documentStyle->setColumnAxis(HorizontalColumnAxis); + if (documentStyle->isHorizontalWritingMode()) + documentStyle->setColumnProgression(documentStyle->isLeftToRightDirection() ? ReverseColumnProgression : NormalColumnProgression); + else + documentStyle->setColumnProgression(documentStyle->isFlippedBlocksWritingMode() ? NormalColumnProgression : ReverseColumnProgression); + break; + case Page::Pagination::TopToBottomPaginated: + documentStyle->setColumnAxis(VerticalColumnAxis); + if (documentStyle->isHorizontalWritingMode()) + documentStyle->setColumnProgression(documentStyle->isFlippedBlocksWritingMode() ? ReverseColumnProgression : NormalColumnProgression); + else + documentStyle->setColumnProgression(documentStyle->isLeftToRightDirection() ? NormalColumnProgression : ReverseColumnProgression); + break; + case Page::Pagination::BottomToTopPaginated: + documentStyle->setColumnAxis(VerticalColumnAxis); + if (documentStyle->isHorizontalWritingMode()) + documentStyle->setColumnProgression(documentStyle->isFlippedBlocksWritingMode() ? NormalColumnProgression : ReverseColumnProgression); + else + documentStyle->setColumnProgression(documentStyle->isLeftToRightDirection() ? ReverseColumnProgression : NormalColumnProgression); + break; + case Page::Pagination::Unpaginated: + ASSERT_NOT_REACHED(); + break; + } + documentStyle->setColumnGap(pagination.gap); } } @@ -1611,7 +1656,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForDocument(Document* document, CSSF return documentStyle.release(); } -static inline bool isAtShadowBoundary(Element* element) +static inline bool isAtShadowBoundary(const Element* element) { if (!element) return false; @@ -1645,18 +1690,21 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS m_style = RenderStyle::create(); + RefPtr<RenderStyle> cloneForParent; + if (m_parentStyle) - m_style->inheritFrom(m_parentStyle); + m_style->inheritFrom(m_parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); else { - m_parentStyle = style(); // Make sure our fonts are initialized if we don't inherit them from our parent style. - m_style->font().update(0); + if (Settings* settings = documentSettings()) { + initializeFontStyle(settings); + m_style->font().update(fontSelector()); + } else + m_style->font().update(0); + cloneForParent = RenderStyle::clone(style()); + m_parentStyle = cloneForParent.get(); } - // Even if surrounding content is user-editable, shadow DOM should act as a single unit, and not necessarily be editable - if (isAtShadowBoundary(element)) - m_style->setUserModify(RenderStyle::initialUserModify()); - if (element->isLink()) { m_style->setIsLink(true); m_style->setInsideLink(m_elementLinkState); @@ -1670,13 +1718,16 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS else matchAllRules(matchResult, matchingBehavior != MatchAllRulesExcludingSMIL); - applyMatchedProperties(matchResult); + applyMatchedProperties(matchResult, element); // Clean up our style object's display and text decorations (among other fixups). adjustRenderStyle(style(), m_parentStyle, element); initElement(0); // Clear out for the next resolve. + if (cloneForParent) + m_parentStyle = 0; + // Now return the style. return m_style.release(); } @@ -1831,7 +1882,7 @@ PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(PseudoId pseudo, El m_style->setStyleType(pseudo); - applyMatchedProperties(matchResult); + applyMatchedProperties(matchResult, e); // Clean up our style object's display and text decorations (among other fixups). adjustRenderStyle(style(), parentStyle, 0); @@ -1866,6 +1917,9 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) matchPageRules(result, m_authorStyle.get(), isLeft, isFirst, page); m_lineHeightValue = 0; bool inheritedOnly = false; +#if ENABLE(CSS_VARIABLES) + applyMatchedProperties<VariableDefinitions>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); +#endif applyMatchedProperties<HighPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); // If our font got dirtied, go ahead and update it now. @@ -1911,6 +1965,36 @@ static void addIntrinsicMargins(RenderStyle* style) } } +static bool shouldBecomeBlockWhenParentIsFlexbox(const Element* element) +{ + return element->hasTagName(imgTag) + || element->hasTagName(canvasTag) +#if ENABLE(SVG) + || element->hasTagName(SVGNames::svgTag) +#endif +#if ENABLE(MATHML) + || element->hasTagName(MathMLNames::mathTag) +#endif +#if ENABLE(VIDEO) + || element->hasTagName(audioTag) + || element->hasTagName(videoTag) +#endif + || element->hasTagName(iframeTag) + || element->hasTagName(objectTag) + || element->hasTagName(embedTag) + || element->hasTagName(appletTag) +#if ENABLE(PROGRESS_TAG) + || element->hasTagName(progressTag) +#endif +#if ENABLE(METER_TAG) + || element->hasTagName(meterTag) +#endif + || element->hasTagName(inputTag) + || element->hasTagName(buttonTag) + || element->hasTagName(selectTag) + || element->hasTagName(textareaTag); +} + static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool strictParsing) { switch (display) { @@ -2002,7 +2086,7 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty // Tables never support the -webkit-* values for text-align and will reset back to the default. if (e && e->hasTagName(tableTag) && (style->textAlign() == WEBKIT_LEFT || style->textAlign() == WEBKIT_CENTER || style->textAlign() == WEBKIT_RIGHT)) - style->setTextAlign(TAAUTO); + style->setTextAlign(TASTART); // Frames and framesets never honor position:relative or position:absolute. This is necessary to // fix a crash where a site tries to position these objects. They also never honor display. @@ -2017,8 +2101,9 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty style->setFloating(NoFloat); } - // Table headers with a text-align of auto will change the text-align to center. - if (e && e->hasTagName(thTag) && style->textAlign() == TAAUTO) + // FIXME: We shouldn't be overriding start/-webkit-auto like this. Do it in html.css instead. + // Table headers with a text-align of -webkit-auto will change the text-align to center. + if (e && e->hasTagName(thTag) && style->textAlign() == TASTART) style->setTextAlign(CENTER); if (e && e->hasTagName(legendTag)) @@ -2053,6 +2138,13 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support. if (style->writingMode() != TopToBottomWritingMode && (style->display() == BOX || style->display() == INLINE_BOX)) style->setWritingMode(TopToBottomWritingMode); + + if (e && e->parentNode() && e->parentNode()->renderer() && e->parentNode()->renderer()->isFlexibleBox()) { + if (shouldBecomeBlockWhenParentIsFlexbox(e)) + style->setDisplay(BLOCK); + else if (style->display() != INLINE) + style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), m_checker.strictParsing())); + } } // Make sure our z-index value is only applied if the object is positioned. @@ -2067,11 +2159,11 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty #ifdef FIXED_POSITION_CREATES_STACKING_CONTEXT || style->position() == FixedPosition #else - || (style->position() == FixedPosition && e && e->document()->page()->settings()->fixedPositionCreatesStackingContext()) + || (style->position() == FixedPosition && e && e->document()->page() && e->document()->page()->settings()->fixedPositionCreatesStackingContext()) #endif #if ENABLE(OVERFLOW_SCROLLING) // Touch overflow scrolling creates a stacking context. - || style->useTouchOverflowScrolling() + || ((style->overflowX() != OHIDDEN || style->overflowY() != OHIDDEN) && style->useTouchOverflowScrolling()) #endif )) style->setZIndex(0); @@ -2671,23 +2763,33 @@ void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRul if (filterRegionProperties && !StyleResolver::isValidRegionStyleProperty(property)) continue; - if (pass == HighPriorityProperties) { + switch (pass) { +#if ENABLE(CSS_VARIABLES) + case VariableDefinitions: + COMPILE_ASSERT(CSSPropertyVariable < firstCSSProperty, CSS_variable_is_before_first_property); + if (property == CSSPropertyVariable) + applyProperty(current.id(), current.value()); + break; +#endif + case HighPriorityProperties: COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_first_property); COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 18, CSS_zoom_is_end_of_first_prop_range); COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_line_height_is_after_zoom); - // give special priority to font-xxx, color properties, etc - if (property > CSSPropertyLineHeight) +#if ENABLE(CSS_VARIABLES) + if (property == CSSPropertyVariable) continue; +#endif + // give special priority to font-xxx, color properties, etc + if (property < CSSPropertyLineHeight) + applyProperty(current.id(), current.value()); // we apply line-height later - if (property == CSSPropertyLineHeight) { + else if (property == CSSPropertyLineHeight) m_lineHeightValue = current.value(); - continue; - } - applyProperty(current.id(), current.value()); - continue; + break; + case LowPriorityProperties: + if (property > CSSPropertyLineHeight) + applyProperty(current.id(), current.value()); } - if (property > CSSPropertyLineHeight) - applyProperty(current.id(), current.value()); } InspectorInstrumentation::didProcessRule(cookie); } @@ -2811,8 +2913,9 @@ static bool isCacheableInMatchedPropertiesCache(const Element* element, const Re return true; } -void StyleResolver::applyMatchedProperties(const MatchResult& matchResult) +void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element* element) { + ASSERT(element); unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; bool applyInheritedOnly = false; const MatchedPropertiesCacheItem* cacheItem = 0; @@ -2825,13 +2928,22 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult) EInsideLink linkStatus = m_style->insideLink(); // If the cache item parent style has identical inherited properties to the current parent style then the // resulting style will be identical too. We copy the inherited properties over from the cache and are done. - m_style->inheritFrom(cacheItem->renderStyle.get()); + m_style->inheritFrom(cacheItem->renderStyle.get(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); // Unfortunately the link status is treated like an inherited property. We need to explicitly restore it. m_style->setInsideLink(linkStatus); return; } applyInheritedOnly = true; } + +#if ENABLE(CSS_VARIABLES) + // First apply all variable definitions, as they may be used during application of later properties. + applyMatchedProperties<VariableDefinitions>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); + applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); + applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); + applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); +#endif + // Now we have all of the matched rules in the appropriate order. Walk the rules and apply // high-priority properties first, i.e., those properties that other properties depend on. // The order is (1) high-priority not important, (2) high-priority important, (3) normal not important @@ -2993,6 +3105,20 @@ static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra collectCSSOMWrappers(wrapperMap, static_cast<CSSStyleSheet*>(styleSheet)); } collectCSSOMWrappers(wrapperMap, document->pageUserSheet()); + { + const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets = document->pageGroupUserSheets(); + if (pageGroupUserSheets) { + for (size_t i = 0, size = pageGroupUserSheets->size(); i < size; ++i) + collectCSSOMWrappers(wrapperMap, pageGroupUserSheets->at(i).get()); + } + } + { + const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets = document->documentUserSheets(); + if (documentUserSheets) { + for (size_t i = 0, size = documentUserSheets->size(); i < size; ++i) + collectCSSOMWrappers(wrapperMap, documentUserSheets->at(i).get()); + } + } } CSSStyleRule* StyleResolver::ensureFullCSSOMWrapperForInspector(StyleRule* rule) @@ -3146,8 +3272,54 @@ static bool createGridPosition(CSSValue* value, Length& position) return true; } -void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) +#if ENABLE(CSS_VARIABLES) +static bool hasVariableReference(CSSValue* value) +{ + if (value->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(value)->isVariableName()) + return true; + + for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { + if (hasVariableReference(i.value())) + return true; + } + + return false; +} + +void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions) { + std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*style()->variables())); + + if (knownExpressions.contains(expression)) + return; // cycle detected. + + knownExpressions.append(expression); + + // FIXME: It would be faster not to re-parse from strings, but for now CSS property validation lives inside the parser so we do it there. + RefPtr<StylePropertySet> resultSet = StylePropertySet::create(); + if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, CSSStrictMode, 0)) + return; // expression failed to parse. + + for (unsigned i = 0; i < resultSet->propertyCount(); i++) { + const CSSProperty& property = resultSet->propertyAt(i); + if (property.id() != CSSPropertyVariable && hasVariableReference(property.value())) + resolveVariables(property.id(), property.value(), knownExpressions); + else + applyProperty(property.id(), property.value()); + } +} +#endif + +void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) +{ +#if ENABLE(CSS_VARIABLES) + if (id != CSSPropertyVariable && hasVariableReference(value)) { + Vector<std::pair<CSSPropertyID, String> > knownExpressions; + resolveVariables(id, value, knownExpressions); + return; + } +#endif + bool isInherit = m_parentNode && value->isInheritedValue(); bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue()); @@ -3161,7 +3333,18 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) if (isInherit && m_parentStyle && !m_parentStyle->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id)) m_parentStyle->setHasExplicitlyInheritedProperties(); - // check lookup table for implementations and use when available +#if ENABLE(CSS_VARIABLES) + if (id == CSSPropertyVariable) { + ASSERT(value->isVariableValue()); + CSSVariableValue* variable = static_cast<CSSVariableValue*>(value); + ASSERT(!variable->name().isEmpty()); + ASSERT(!variable->value().isEmpty()); + m_style->setVariable(variable->name(), variable->value()); + return; + } +#endif + + // Check lookup table for implementations and use when available. const PropertyHandler& handler = m_styleBuilder.propertyHandler(id); if (handler.isValid()) { if (isInherit) @@ -3344,7 +3527,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) continue; CSSPrimitiveValue* contentValue = static_cast<CSSPrimitiveValue*>(item); AtomicString face; - Settings* settings = m_checker.document()->settings(); + Settings* settings = documentSettings(); if (contentValue->isString()) face = contentValue->getStringValue(); else if (settings) { @@ -3428,24 +3611,11 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) m_lineHeightValue = 0; setFontDescription(fontDescription); } else if (isInitial) { - Settings* settings = m_checker.document()->settings(); + Settings* settings = documentSettings(); ASSERT(settings); // If we're doing style resolution, this document should always be in a frame and thus have settings if (!settings) return; - FontDescription fontDescription; - fontDescription.setGenericFamily(FontDescription::StandardFamily); - fontDescription.setRenderingMode(settings->fontRenderingMode()); - fontDescription.setUsePrinterFont(m_checker.document()->printing()); - const AtomicString& standardFontFamily = m_checker.document()->settings()->standardFontFamily(); - if (!standardFontFamily.isEmpty()) { - fontDescription.firstFamily().setFamily(standardFontFamily); - fontDescription.firstFamily().appendFamily(0); - } - fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); - setFontSize(fontDescription, fontSizeForKeyword(m_checker.document(), CSSValueMedium, false)); - m_style->setLineHeight(RenderStyle::initialLineHeight()); - m_lineHeightValue = 0; - setFontDescription(fontDescription); + initializeFontStyle(settings); } else if (primitiveValue) { m_style->setLineHeight(RenderStyle::initialLineHeight()); m_lineHeightValue = 0; @@ -3456,7 +3626,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) // Double-check and see if the theme did anything. If not, don't bother updating the font. if (fontDescription.isAbsoluteSize()) { // Make sure the rendering mode and printer font settings are updated. - Settings* settings = m_checker.document()->settings(); + Settings* settings = documentSettings(); ASSERT(settings); // If we're doing style resolution, this document should always be in a frame and thus have settings if (!settings) return; @@ -4028,6 +4198,9 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) case CSSPropertyFontWeight: case CSSPropertyHeight: case CSSPropertyImageRendering: +#if ENABLE(CSS_IMAGE_RESOLUTION) + case CSSPropertyImageResolution: +#endif case CSSPropertyLeft: case CSSPropertyLetterSpacing: case CSSPropertyLineHeight: @@ -4099,7 +4272,9 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) case CSSPropertyWebkitBorderRadius: case CSSPropertyWebkitBorderVerticalSpacing: case CSSPropertyWebkitBoxAlign: +#if ENABLE(CSS_BOX_DECORATION_BREAK) case CSSPropertyWebkitBoxDecorationBreak: +#endif case CSSPropertyWebkitBoxDirection: case CSSPropertyWebkitBoxFlex: case CSSPropertyWebkitBoxFlexGroup: @@ -4114,6 +4289,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) case CSSPropertyWebkitColumnBreakInside: case CSSPropertyWebkitColumnCount: case CSSPropertyWebkitColumnGap: + case CSSPropertyWebkitColumnProgression: case CSSPropertyWebkitColumnRuleColor: case CSSPropertyWebkitColumnRuleStyle: case CSSPropertyWebkitColumnRuleWidth: @@ -4121,14 +4297,15 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) case CSSPropertyWebkitColumnSpan: case CSSPropertyWebkitColumnWidth: #if ENABLE(CSS3_FLEXBOX) + case CSSPropertyWebkitAlignContent: case CSSPropertyWebkitAlignItems: case CSSPropertyWebkitAlignSelf: case CSSPropertyWebkitFlex: case CSSPropertyWebkitFlexDirection: case CSSPropertyWebkitFlexFlow: - case CSSPropertyWebkitFlexLinePack: - case CSSPropertyWebkitFlexPack: case CSSPropertyWebkitFlexWrap: + case CSSPropertyWebkitJustifyContent: + case CSSPropertyWebkitOrder: #endif #if ENABLE(CSS_REGIONS) case CSSPropertyWebkitFlowFrom: @@ -4167,9 +4344,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) case CSSPropertyWebkitMaskRepeatX: case CSSPropertyWebkitMaskRepeatY: case CSSPropertyWebkitMaskSize: - case CSSPropertyWebkitMatchNearestMailBlockquoteColor: case CSSPropertyWebkitNbspMode: - case CSSPropertyWebkitOrder: case CSSPropertyWebkitPerspectiveOrigin: case CSSPropertyWebkitPerspectiveOriginX: case CSSPropertyWebkitPerspectiveOriginY: @@ -4909,7 +5084,7 @@ void StyleResolver::checkForGenericFamilyChange(RenderStyle* style, RenderStyle* if (childFont.keywordSize()) size = fontSizeForKeyword(m_checker.document(), CSSValueXxSmall + childFont.keywordSize() - 1, childFont.useFixedDefaultSize()); else { - Settings* settings = m_checker.document()->settings(); + Settings* settings = documentSettings(); float fixedScaleFactor = settings ? static_cast<float>(settings->defaultFixedFontSize()) / settings->defaultFontSize() : 1; @@ -4923,6 +5098,24 @@ void StyleResolver::checkForGenericFamilyChange(RenderStyle* style, RenderStyle* style->setFontDescription(newFontDescription); } +void StyleResolver::initializeFontStyle(Settings* settings) +{ + FontDescription fontDescription; + fontDescription.setGenericFamily(FontDescription::StandardFamily); + fontDescription.setRenderingMode(settings->fontRenderingMode()); + fontDescription.setUsePrinterFont(m_checker.document()->printing()); + const AtomicString& standardFontFamily = documentSettings()->standardFontFamily(); + if (!standardFontFamily.isEmpty()) { + fontDescription.firstFamily().setFamily(standardFontFamily); + fontDescription.firstFamily().appendFamily(0); + } + fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); + setFontSize(fontDescription, fontSizeForKeyword(m_checker.document(), CSSValueMedium, false)); + m_style->setLineHeight(RenderStyle::initialLineHeight()); + m_lineHeightValue = 0; + setFontDescription(fontDescription); +} + void StyleResolver::setFontSize(FontDescription& fontDescription, float size) { fontDescription.setSpecifiedSize(size); @@ -5194,6 +5387,7 @@ bool StyleResolver::createTransformOperations(CSSValue* inValue, RenderStyle* st TransformOperations operations; for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) { CSSValue* currValue = i.value(); + if (!currValue->isWebKitCSSTransformValue()) continue; diff --git a/Source/WebCore/css/StyleResolver.h b/Source/WebCore/css/StyleResolver.h index 539dd6356..9f9cc2ca4 100644 --- a/Source/WebCore/css/StyleResolver.h +++ b/Source/WebCore/css/StyleResolver.h @@ -32,6 +32,7 @@ #include <wtf/HashSet.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> +#include <wtf/text/AtomicStringHash.h> #include <wtf/text/StringHash.h> namespace WebCore { @@ -208,6 +209,7 @@ public: void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*); void updateFont(); + void initializeFontStyle(Settings*); static float getComputedSizeFromSpecifiedSize(Document*, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize = UseSmartMinimumForFontFize); @@ -352,8 +354,11 @@ private: bool checkSelector(const RuleData&, const ContainerNode* scope = 0); bool checkRegionSelector(CSSSelector* regionSelector, Element* regionElement); - void applyMatchedProperties(const MatchResult&); + void applyMatchedProperties(const MatchResult&, const Element*); enum StyleApplicationPass { +#if ENABLE(CSS_VARIABLES) + VariableDefinitions, +#endif HighPriorityProperties, LowPriorityProperties }; @@ -361,11 +366,15 @@ private: void applyMatchedProperties(const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly); template <StyleApplicationPass pass> void applyProperties(const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, bool filterRegionProperties); - +#if ENABLE(CSS_VARIABLES) + void resolveVariables(CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions); +#endif static bool isValidRegionStyleProperty(CSSPropertyID); void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPage, const String& pageName); void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vector<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName); + Settings* documentSettings() { return m_checker.document()->settings(); } + bool isLeftPage(int pageIndex) const; bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } bool isFirstPage(int pageIndex) const; diff --git a/Source/WebCore/css/WebKitCSSTransformValue.cpp b/Source/WebCore/css/WebKitCSSTransformValue.cpp index f85319015..87ded7da6 100644 --- a/Source/WebCore/css/WebKitCSSTransformValue.cpp +++ b/Source/WebCore/css/WebKitCSSTransformValue.cpp @@ -78,6 +78,21 @@ String WebKitCSSTransformValue::customCssText() const return result.toString(); } +#if ENABLE(CSS_VARIABLES) +String WebKitCSSTransformValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const +{ + StringBuilder result; + if (m_type != UnknownTransformOperation) { + ASSERT(static_cast<size_t>(m_type) < WTF_ARRAY_LENGTH(transformName)); + result.append(transformName[m_type]); + result.append('('); + result.append(CSSValueList::customSerializeResolvingVariables(variables)); + result.append(')'); + } + return result.toString(); +} +#endif + WebKitCSSTransformValue::WebKitCSSTransformValue(const WebKitCSSTransformValue& cloneFrom) : CSSValueList(cloneFrom) , m_type(cloneFrom.m_type) diff --git a/Source/WebCore/css/WebKitCSSTransformValue.h b/Source/WebCore/css/WebKitCSSTransformValue.h index 647428bf7..5fc4f7d6b 100644 --- a/Source/WebCore/css/WebKitCSSTransformValue.h +++ b/Source/WebCore/css/WebKitCSSTransformValue.h @@ -66,6 +66,9 @@ public: } String customCssText() const; +#if ENABLE(CSS_VARIABLES) + String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const; +#endif TransformOperationType operationType() const { return m_type; } diff --git a/Source/WebCore/css/fullscreen.css b/Source/WebCore/css/fullscreen.css index 8e7c87360..135acb169 100644 --- a/Source/WebCore/css/fullscreen.css +++ b/Source/WebCore/css/fullscreen.css @@ -20,7 +20,7 @@ -webkit-transform-style: flat !important; } -video:-webkit-full-screen { +video:-webkit-full-screen, audio:-webkit-full-screen { background-color: transparent !important; position: static !important; margin: 0 !important; diff --git a/Source/WebCore/css/html.css b/Source/WebCore/css/html.css index d1e373bf6..1769d49f1 100644 --- a/Source/WebCore/css/html.css +++ b/Source/WebCore/css/html.css @@ -570,9 +570,10 @@ input[type="range"] { padding: initial; border: initial; margin: 2px; + color: #909090; } -input[type="range"]::-webkit-slider-container { +input[type="range"]::-webkit-slider-container, input[type="range"]::-webkit-media-slider-container { -webkit-box-align: center; -webkit-box-orient: horizontal; /* This property is updated by C++ code. */ -webkit-box-sizing: border-box; @@ -587,7 +588,7 @@ input[type="range"]::-webkit-slider-runnable-track { display: block; } -input[type="range"]::-webkit-slider-thumb { +input[type="range"]::-webkit-slider-thumb, input[type="range"]::-webkit-media-slider-thumb { -webkit-appearance: sliderthumb-horizontal; -webkit-box-sizing: border-box; display: block; diff --git a/Source/WebCore/css/makeprop.pl b/Source/WebCore/css/makeprop.pl index 9bc0290d3..a5bfb0649 100644 --- a/Source/WebCore/css/makeprop.pl +++ b/Source/WebCore/css/makeprop.pl @@ -164,6 +164,9 @@ namespace WebCore { enum CSSPropertyID { CSSPropertyInvalid = 0, +#if ENABLE(CSS_VARIABLES) + CSSPropertyVariable = 1, +#endif EOF my $first = 1001; diff --git a/Source/WebCore/css/mediaControls.css b/Source/WebCore/css/mediaControls.css index 1b2057f02..da1e6c832 100644 --- a/Source/WebCore/css/mediaControls.css +++ b/Source/WebCore/css/mediaControls.css @@ -225,10 +225,24 @@ video::-webkit-media-text-track-container { -webkit-box-flex: 1; } -video::-webkit-media-text-track-background { +video::-webkit-media-text-track-past-nodes { display: inline; + background-color: rgba(0, 0, 0, 0.8); padding: 2px 2px; + + white-space: pre-wrap; +} + +video::-webkit-media-text-track-future-nodes { + visibility: hidden; + display: inline; + + background-color: rgba(0, 0, 0, 0.8); + + margin-left: -2px; + padding: 2px 2px 2px 0px; + white-space: pre-wrap; } diff --git a/Source/WebCore/css/mediaControlsBlackBerry.css b/Source/WebCore/css/mediaControlsBlackBerry.css index b7f486e8d..4c00a725c 100644 --- a/Source/WebCore/css/mediaControlsBlackBerry.css +++ b/Source/WebCore/css/mediaControlsBlackBerry.css @@ -42,7 +42,7 @@ audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { width: 100%; z-index: 0; overflow: visible; - height: 32px; + height: auto; text-align: center; background-color: rgba(0, 0, 0, 0.6); } @@ -54,8 +54,6 @@ video:-webkit-full-page-media::-webkit-media-controls-panel { audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { -webkit-appearance: media-play-button; display: -webkit-box; - width: 32px; - height: 32px; } audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls-timeline-container { @@ -66,7 +64,7 @@ audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls- -webkit-box-pack: end; -webkit-box-flex: 1; -webkit-user-select: none; - height: 32px; + height: auto; } audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display { @@ -77,10 +75,7 @@ audio::-webkit-media-controls-current-time-display, video::-webkit-media-control -webkit-box-pack: end; -webkit-box-flex: 0; -webkit-user-select: none; - width: 48px; - height: 32px; color: white; - padding-right: 2px; } audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display { @@ -91,31 +86,23 @@ audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-contr -webkit-box-pack: end; -webkit-box-flex: 0; -webkit-user-select: none; - width: 56px; - height: 32px; color: white; - padding-right: 2px; } audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { -webkit-appearance: media-slider; display: -webkit-box; -webkit-box-flex: 1; - height: 32px; } audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button { -webkit-appearance: media-fullscreen-button; display: -webkit-box; - width: 32px; - height: 32px; } audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { -webkit-appearance: media-mute-button; display: -webkit-box; - width: 32px; - height: 32px; } audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-controls-volume-slider-container { @@ -126,8 +113,6 @@ audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-cont -webkit-box-pack: end; -webkit-box-flex: 1; -webkit-user-select: none; - height: 128px; - width: 32px; position: absolute; right: 0px; background-color: rgba(0, 0, 0, 0.6); @@ -137,8 +122,6 @@ audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volum -webkit-appearance: media-volume-slider; display: -webkit-box; -webkit-box-flex: 1; - height: 128px; - width: 32px; } audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { diff --git a/Source/WebCore/css/mediaControlsChromium.css b/Source/WebCore/css/mediaControlsChromium.css index 409398c5d..b3931016e 100644 --- a/Source/WebCore/css/mediaControlsChromium.css +++ b/Source/WebCore/css/mediaControlsChromium.css @@ -31,7 +31,7 @@ body:-webkit-full-page-media { audio { width: 300px; - height: 32px; + height: 30px; } audio:-webkit-full-page-media, video:-webkit-full-page-media { @@ -39,90 +39,84 @@ audio:-webkit-full-page-media, video:-webkit-full-page-media { max-width: 100%; } -audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { - -webkit-user-select: none; - -webkit-box-pack: end; - position: relative; - overflow: visible; - bottom: 0; - width: 100%; - height: 32px; - z-index: 0; - background-color: rgba(0, 0, 0, 0.6); -} - +audio:-webkit-full-page-media::-webkit-media-controls-panel, video:-webkit-full-page-media::-webkit-media-controls-panel { bottom: 0px; } -audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { - -webkit-box-align: end; +::-webkit-media-controls { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-box-pack: end; + -webkit-box-align: center; } -audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { - -webkit-appearance: media-mute-button; - position: relative; - top: auto; +audio::-webkit-media-controls-enclosure, video::-webkit-media-controls-enclosure { + width: 100%; + max-width: 800px; + height: 30px; bottom: 0; - right: 0; - left: auto; - - width: 34px; - height: 32px; + text-indent: 0; + padding: 0; + box-sizing: border-box; } -audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { - -webkit-appearance: media-play-button; - - position: absolute; - top: auto; - bottom: 7px; - left: 7px; - right: 6px; - - width: 18px; - height: 19px; +video::-webkit-media-controls-enclosure { + padding: 0px 5px 5px 5px; + height: 35px; } -audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls-timeline-container { - -webkit-appearance: media-timeline-container; - -webkit-user-select: none; +audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { + display: -webkit-box; -webkit-box-orient: horizontal; -webkit-box-align: center; -webkit-box-pack: center; - -webkit-box-flex: 1; - - position: absolute; - top: auto; - bottom: 0; - left: 30px; - right: 34px; + bottom: auto; + height: 30px; + background-color: rgba(20, 20, 20, 0.8); + border-radius: 5px; +} - width: auto; - height: 32px; +audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { + -webkit-appearance: media-mute-button; + display: inline; + border: none; + box-sizing: border-box; + width: 35px; + height: 30px; + line-height: 30px; + margin: 0 6px 0 0; + padding: 0; +} - border-left: 1px solid rgba(255, 255, 255, 0.2); - border-right: 1px solid rgba(255, 255, 255, 0.2); +audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { + -webkit-appearance: media-play-button; + display: inline; + border: none; + box-sizing: border-box; + width: 30px; + height: 30px; + line-height: 30px; + margin-left: 9px; + margin-right: 9px; + padding: 0; } -audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display { +audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display, +audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display { -webkit-appearance: media-current-time-display; -webkit-user-select: none; - display: -webkit-box; - -webkit-box-flex: 0; - -webkit-box-pack: center; - -webkit-box-align: center; - - overflow: hidden; + display: block; + border: none; cursor: default; - line-height: 21px; - height: 20px; - width: 58px; + height: 30px; + margin: 0 9px 0 0; + padding: 0; - text-align: center; - font-family: Arial; - font-size: 16px; + line-height: 30px; + font-family: Arial, Helvetica, sans-serif; + font-size: 13px; font-weight: bold; color: white; @@ -137,40 +131,61 @@ audio::-webkit-media-controls-current-time-display, video::-webkit-media-control audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { -webkit-appearance: media-slider; display: -webkit-box; - box-sizing: border-box; -webkit-box-flex: 1; - - padding: 0px; - margin: 0px 6px; - height: 18px; - - border-color: rgba(255, 255, 255, 0.2); - border-style: solid; - border-width: 1px; - border-radius: 2px; - background-color: rgba(255, 255, 255, 0.08); - color: rgb(50, 140, 223); + height: 8px; + margin: 0 15px 0 0; + padding: 0; + background-color: transparent; + min-width: 25px; } -audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-controls-volume-slider-container { - -webkit-appearance: media-volume-slider-container; - position: absolute; - bottom: 32px; +audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volume-slider { + -webkit-appearance: media-volume-slider; + display: -webkit-box; + -webkit-box-flex: 1; + height: 8px; + max-width: 70px; + margin: 0 15px 0 0; + padding: 0; + background-color: transparent; + min-width: 15px; +} - width: 34px; - height: 100px; +/* FIXME these shouldn't use special pseudoShadowIds, but nicer rules. + https://code.google.com/p/chromium/issues/detail?id=112508 + https://bugs.webkit.org/show_bug.cgi?id=62218 +*/ +input[type="range"]::-webkit-media-slider-container { + display: -webkit-box; + -webkit-box-align: center; + -webkit-box-orient: horizontal; /* This property is updated by C++ code. */ + -webkit-box-sizing: border-box; + height: 100%; + width: 100%; + border: 1px solid rgb(130, 130, 130); + border-radius: 4px; + background-color: transparent; /* Background drawing is managed by C++ code to draw ranges. */ +} - background-color: rgba(0, 0, 0, 0.6); +input[type="range"]::-webkit-media-slider-thumb { + display: block; + -webkit-appearance: sliderthumb-horizontal; + -webkit-box-sizing: border-box; + position: relative; + bottom: 1px; + margin-left: -7px; + margin-right: -7px; } -audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volume-slider { - -webkit-appearance: media-volume-slider; +audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button { + -webkit-appearance: media-enter-fullscreen-button; display: inline; - position: absolute; - - top: 10px; - left: 12px; - - width: 10px; - height: 80px; + border: none; + box-sizing: border-box; + width: 30px; + height: 30px; + line-height: 30px; + margin-left: -5px; + margin-right: 9px; + padding: 0; } diff --git a/Source/WebCore/css/themeChromiumLinux.css b/Source/WebCore/css/themeChromiumLinux.css index a6a88284d..dee84368a 100644 --- a/Source/WebCore/css/themeChromiumLinux.css +++ b/Source/WebCore/css/themeChromiumLinux.css @@ -39,3 +39,7 @@ select[size="0"] option, select[size="1"] option { background-color: #f7f7f7; } + +input[type=range] { + color: #9d968E; +} diff --git a/Source/WebCore/css/themeWin.css b/Source/WebCore/css/themeWin.css index 0838b1126..52be43eed 100644 --- a/Source/WebCore/css/themeWin.css +++ b/Source/WebCore/css/themeWin.css @@ -61,6 +61,10 @@ input[type="radio"] { margin:3px 3px 0 5px; } +input[type="range"] { + color: #c4c4c4; +} + /* Not sure this is the right color. #EBEBE4 is what Firefox uses. FIXME: Figure out how to support legacy input rendering. FIXME: Add input[type="file"] once we figure out our file inputs. |