diff options
Diffstat (limited to 'WebCore/css')
55 files changed, 1352 insertions, 613 deletions
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp index f5a5216..8a91140 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -28,6 +28,7 @@ #include "CSSMutableStyleDeclaration.h" #include "CSSPrimitiveValue.h" #include "CSSPrimitiveValueMappings.h" +#include "CSSProperty.h" #include "CSSPropertyNames.h" #include "CSSReflectValue.h" #include "CSSTimingFunctionValue.h" @@ -55,11 +56,15 @@ namespace WebCore { // List of all properties we know how to compute, omitting shorthands. static const int computedProperties[] = { CSSPropertyBackgroundAttachment, + CSSPropertyBackgroundClip, CSSPropertyBackgroundColor, CSSPropertyBackgroundImage, + CSSPropertyBackgroundOrigin, CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard CSSPropertyBackgroundRepeat, CSSPropertyBorderBottomColor, + CSSPropertyBorderBottomLeftRadius, + CSSPropertyBorderBottomRightRadius, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomWidth, CSSPropertyBorderCollapse, @@ -70,9 +75,12 @@ static const int computedProperties[] = { CSSPropertyBorderRightStyle, CSSPropertyBorderRightWidth, CSSPropertyBorderTopColor, + CSSPropertyBorderTopLeftRadius, + CSSPropertyBorderTopRightRadius, CSSPropertyBorderTopStyle, CSSPropertyBorderTopWidth, CSSPropertyBottom, + CSSPropertyBoxShadow, CSSPropertyCaptionSide, CSSPropertyClear, CSSPropertyClip, @@ -125,6 +133,7 @@ static const int computedProperties[] = { CSSPropertyTextDecoration, CSSPropertyTextIndent, CSSPropertyTextShadow, + CSSPropertyTextOverflow, CSSPropertyTextTransform, CSSPropertyTop, CSSPropertyUnicodeBidi, @@ -144,6 +153,7 @@ static const int computedProperties[] = { CSSPropertyWebkitAnimationDuration, CSSPropertyWebkitAnimationIterationCount, CSSPropertyWebkitAnimationName, + CSSPropertyWebkitAnimationPlayState, CSSPropertyWebkitAnimationTimingFunction, CSSPropertyWebkitAppearance, CSSPropertyWebkitBackfaceVisibility, @@ -151,13 +161,9 @@ static const int computedProperties[] = { CSSPropertyWebkitBackgroundComposite, CSSPropertyWebkitBackgroundOrigin, CSSPropertyWebkitBackgroundSize, - CSSPropertyWebkitBorderBottomLeftRadius, - CSSPropertyWebkitBorderBottomRightRadius, CSSPropertyWebkitBorderFit, CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyWebkitBorderImage, - CSSPropertyWebkitBorderTopLeftRadius, - CSSPropertyWebkitBorderTopRightRadius, CSSPropertyWebkitBorderVerticalSpacing, CSSPropertyWebkitBoxAlign, CSSPropertyWebkitBoxDirection, @@ -168,7 +174,6 @@ static const int computedProperties[] = { CSSPropertyWebkitBoxOrient, CSSPropertyWebkitBoxPack, CSSPropertyWebkitBoxReflect, - CSSPropertyWebkitBoxShadow, CSSPropertyWebkitBoxSizing, CSSPropertyWebkitColumnBreakAfter, CSSPropertyWebkitColumnBreakBefore, @@ -268,7 +273,7 @@ static const int computedProperties[] = { const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]); -static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow) +static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID) { if (!shadow) return CSSPrimitiveValue::createIdentifier(CSSValueNone); @@ -278,8 +283,10 @@ static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow) RefPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(s->x, CSSPrimitiveValue::CSS_PX); RefPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(s->y, CSSPrimitiveValue::CSS_PX); RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(s->blur, CSSPrimitiveValue::CSS_PX); + RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? 0 : CSSPrimitiveValue::create(s->spread, CSSPrimitiveValue::CSS_PX); + RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset); RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(s->color.rgb()); - list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), color.release())); + list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release())); } return list.release(); } @@ -603,6 +610,23 @@ static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family) return CSSPrimitiveValue::create(family.string(), CSSPrimitiveValue::CSS_STRING); } +static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration) +{ + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + if (textDecoration & UNDERLINE) + list->append(CSSPrimitiveValue::createIdentifier(CSSValueUnderline)); + if (textDecoration & OVERLINE) + list->append(CSSPrimitiveValue::createIdentifier(CSSValueOverline)); + if (textDecoration & LINE_THROUGH) + list->append(CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)); + if (textDecoration & BLINK) + list->append(CSSPrimitiveValue::createIdentifier(CSSValueBlink)); + + if (!list->length()) + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + return list; +} + PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const { Node* node = m_node.get(); @@ -648,12 +672,12 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyWebkitBackgroundComposite: return CSSPrimitiveValue::create(style->backgroundComposite()); case CSSPropertyBackgroundAttachment: - if (style->backgroundAttachment()) - return CSSPrimitiveValue::createIdentifier(CSSValueScroll); - return CSSPrimitiveValue::createIdentifier(CSSValueFixed); + return CSSPrimitiveValue::create(style->backgroundAttachment()); + case CSSPropertyBackgroundClip: + case CSSPropertyBackgroundOrigin: case CSSPropertyWebkitBackgroundClip: case CSSPropertyWebkitBackgroundOrigin: { - EFillBox box = (propertyID == CSSPropertyWebkitBackgroundClip ? style->backgroundClip() : style->backgroundOrigin()); + EFillBox box = (propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyBackgroundClip) ? style->backgroundClip() : style->backgroundOrigin(); return CSSPrimitiveValue::create(box); } case CSSPropertyBackgroundPosition: { @@ -732,8 +756,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper } case CSSPropertyWebkitBoxReflect: return valueForReflection(style->boxReflect()); - case CSSPropertyWebkitBoxShadow: - return valueForShadow(style->boxShadow()); + case CSSPropertyBoxShadow: + return valueForShadow(style->boxShadow(), static_cast<CSSPropertyID>(propertyID)); case CSSPropertyCaptionSide: return CSSPrimitiveValue::create(style->captionSide()); case CSSPropertyClear: @@ -920,9 +944,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyWebkitMaskRepeat: return CSSPrimitiveValue::create(style->maskRepeat()); case CSSPropertyWebkitMaskAttachment: - if (style->maskAttachment()) - return CSSPrimitiveValue::createIdentifier(CSSValueScroll); - return CSSPrimitiveValue::createIdentifier(CSSValueFixed); + return CSSPrimitiveValue::create(style->maskAttachment()); case CSSPropertyWebkitMaskComposite: return CSSPrimitiveValue::create(style->maskComposite()); case CSSPropertyWebkitMaskClip: @@ -1021,58 +1043,20 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return CSSPrimitiveValue::create(style->tableLayout()); case CSSPropertyTextAlign: return CSSPrimitiveValue::create(style->textAlign()); - case CSSPropertyTextDecoration: { - String string; - if (style->textDecoration() & UNDERLINE) - string += "underline"; - if (style->textDecoration() & OVERLINE) { - if (string.length()) - string += " "; - string += "overline"; - } - if (style->textDecoration() & LINE_THROUGH) { - if (string.length()) - string += " "; - string += "line-through"; - } - if (style->textDecoration() & BLINK) { - if (string.length()) - string += " "; - string += "blink"; - } - if (!string.length()) - return CSSPrimitiveValue::createIdentifier(CSSValueNone); - return CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_STRING); - } - case CSSPropertyWebkitTextDecorationsInEffect: { - String string; - if (style->textDecorationsInEffect() & UNDERLINE) - string += "underline"; - if (style->textDecorationsInEffect() & OVERLINE) { - if (string.length()) - string += " "; - string += "overline"; - } - if (style->textDecorationsInEffect() & LINE_THROUGH) { - if (string.length()) - string += " "; - string += "line-through"; - } - if (style->textDecorationsInEffect() & BLINK) { - if (string.length()) - string += " "; - string += "blink"; - } - if (!string.length()) - return CSSPrimitiveValue::createIdentifier(CSSValueNone); - return CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_STRING); - } + case CSSPropertyTextDecoration: + return renderTextDecorationFlagsToCSSValue(style->textDecoration()); + case CSSPropertyWebkitTextDecorationsInEffect: + return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect()); case CSSPropertyWebkitTextFillColor: return currentColorOrValidColor(style.get(), style->textFillColor()); case CSSPropertyTextIndent: return CSSPrimitiveValue::create(style->textIndent()); case CSSPropertyTextShadow: - return valueForShadow(style->textShadow()); + return valueForShadow(style->textShadow(), static_cast<CSSPropertyID>(propertyID)); + case CSSPropertyTextOverflow: + if (style->textOverflow()) + return CSSPrimitiveValue::createIdentifier(CSSValueEllipsis); + return CSSPrimitiveValue::createIdentifier(CSSValueClip); case CSSPropertyWebkitTextSecurity: return CSSPrimitiveValue::create(style->textSecurity()); case CSSPropertyWebkitTextSizeAdjust: @@ -1243,6 +1227,21 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone)); return list.release(); } + case CSSPropertyWebkitAnimationPlayState: { + RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); + const AnimationList* t = style->animations(); + if (t) { + for (size_t i = 0; i < t->size(); ++i) { + int prop = t->animation(i)->playState(); + if (prop == AnimPlayStatePlaying) + list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning)); + else + list->append(CSSPrimitiveValue::createIdentifier(CSSValuePaused)); + } + } else + list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning)); + return list.release(); + } case CSSPropertyWebkitAnimationTimingFunction: return getTimingFunctionValue(style->animations()); case CSSPropertyWebkitAppearance: @@ -1285,13 +1284,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return CSSPrimitiveValue::create(style->userDrag()); case CSSPropertyWebkitUserSelect: return CSSPrimitiveValue::create(style->userSelect()); - case CSSPropertyWebkitBorderBottomLeftRadius: + case CSSPropertyBorderBottomLeftRadius: return getBorderRadiusCornerValue(style->borderBottomLeftRadius()); - case CSSPropertyWebkitBorderBottomRightRadius: + case CSSPropertyBorderBottomRightRadius: return getBorderRadiusCornerValue(style->borderBottomRightRadius()); - case CSSPropertyWebkitBorderTopLeftRadius: + case CSSPropertyBorderTopLeftRadius: return getBorderRadiusCornerValue(style->borderTopLeftRadius()); - case CSSPropertyWebkitBorderTopRightRadius: + case CSSPropertyBorderTopRightRadius: return getBorderRadiusCornerValue(style->borderTopRightRadius()); case CSSPropertyClip: { if (!style->hasClip()) @@ -1357,6 +1356,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyBorderBottom: case CSSPropertyBorderColor: case CSSPropertyBorderLeft: + case CSSPropertyBorderRadius: case CSSPropertyBorderRight: case CSSPropertyBorderStyle: case CSSPropertyBorderTop: @@ -1373,7 +1373,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyTextLineThroughMode: case CSSPropertyTextLineThroughStyle: case CSSPropertyTextLineThroughWidth: - case CSSPropertyTextOverflow: case CSSPropertyTextOverline: case CSSPropertyTextOverlineColor: case CSSPropertyTextOverlineMode: @@ -1486,62 +1485,20 @@ String CSSComputedStyleDeclaration::item(unsigned i) const return getPropertyName(static_cast<CSSPropertyID>(computedProperties[i])); } -// This is the list of properties we want to copy in the copyInheritableProperties() function. -// It is the intersection of the list of inherited CSS properties and the -// properties for which we have a computed implementation in this file. -static const int inheritableProperties[] = { - CSSPropertyBorderCollapse, - CSSPropertyColor, - CSSPropertyFontFamily, - CSSPropertyFontSize, - CSSPropertyFontStyle, - CSSPropertyFontVariant, - CSSPropertyFontWeight, - CSSPropertyLetterSpacing, - CSSPropertyLineHeight, - CSSPropertyOrphans, - CSSPropertyTextAlign, - CSSPropertyTextIndent, - CSSPropertyTextTransform, - CSSPropertyWhiteSpace, - CSSPropertyWidows, - CSSPropertyWordSpacing, - CSSPropertyWebkitBorderHorizontalSpacing, - CSSPropertyWebkitBorderVerticalSpacing, - CSSPropertyWebkitTextDecorationsInEffect, - CSSPropertyWebkitTextFillColor, - CSSPropertyWebkitTextSizeAdjust, - CSSPropertyWebkitTextStrokeColor, - CSSPropertyWebkitTextStrokeWidth, -#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR - CSSPropertyWebkitTapHighlightColor, -#endif -}; - -static const unsigned numInheritableProperties = sizeof(inheritableProperties) / sizeof(inheritableProperties[0]); - -void CSSComputedStyleDeclaration::removeComputedInheritablePropertiesFrom(CSSMutableStyleDeclaration* declaration) -{ - declaration->removePropertiesInSet(inheritableProperties, numInheritableProperties); -} - -PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyInheritableProperties() const +bool CSSComputedStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const { - RefPtr<CSSMutableStyleDeclaration> style = copyPropertiesInSet(inheritableProperties, numInheritableProperties); - if (style && m_node && m_node->computedStyle()) { - // If a node's text fill color is invalid, then its children use - // their font-color as their text fill color (they don't - // inherit it). Likewise for stroke color. - ExceptionCode ec = 0; - if (!m_node->computedStyle()->textFillColor().isValid()) - style->removeProperty(CSSPropertyWebkitTextFillColor, ec); - if (!m_node->computedStyle()->textStrokeColor().isValid()) - style->removeProperty(CSSPropertyWebkitTextStrokeColor, ec); - ASSERT(ec == 0); - if (int keywordSize = m_node->computedStyle()->fontDescription().keywordSize()) - style->setProperty(CSSPropertyFontSize, cssIdentifierForFontSizeKeyword(keywordSize)); + if (property->id() == CSSPropertyFontSize && property->value()->isPrimitiveValue() && m_node) { + m_node->document()->updateLayoutIgnorePendingStylesheets(); + RenderStyle* style = m_node->computedStyle(); + if (style && style->fontDescription().keywordSize()) { + int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize()); + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(property->value()); + if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_IDENT && primitiveValue->getIdent() == sizeValue) + return true; + } } - return style.release(); + + return CSSStyleDeclaration::cssPropertyMatches(property); } PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copy() const diff --git a/WebCore/css/CSSComputedStyleDeclaration.h b/WebCore/css/CSSComputedStyleDeclaration.h index 23244e2..c1f34c3 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.h +++ b/WebCore/css/CSSComputedStyleDeclaration.h @@ -55,9 +55,8 @@ public: PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const; #endif - PassRefPtr<CSSMutableStyleDeclaration> copyInheritableProperties() const; - - static void removeComputedInheritablePropertiesFrom(CSSMutableStyleDeclaration*); +protected: + virtual bool cssPropertyMatches(const CSSProperty*) const; private: CSSComputedStyleDeclaration(PassRefPtr<Node>); diff --git a/WebCore/css/CSSCursorImageValue.cpp b/WebCore/css/CSSCursorImageValue.cpp index 84ac565..13c55a8 100644 --- a/WebCore/css/CSSCursorImageValue.cpp +++ b/WebCore/css/CSSCursorImageValue.cpp @@ -40,7 +40,7 @@ namespace WebCore { static inline bool isSVGCursorIdentifier(const String& url) { KURL kurl(url); - return kurl.hasRef(); + return kurl.hasFragmentIdentifier(); } static inline SVGCursorElement* resourceReferencedByCursorElement(const String& fragmentId, Document* document) diff --git a/WebCore/css/CSSFunctionValue.cpp b/WebCore/css/CSSFunctionValue.cpp index cb938ed..0fc260d 100644 --- a/WebCore/css/CSSFunctionValue.cpp +++ b/WebCore/css/CSSFunctionValue.cpp @@ -53,6 +53,7 @@ CSSParserValue CSSFunctionValue::parserValue() const { CSSParserValue val; val.id = 0; + val.isInt = false; val.unit = CSSParserValue::Function; val.function = new CSSParserFunction; val.function->name.characters = const_cast<UChar*>(m_name.characters()); diff --git a/WebCore/css/CSSGrammar.y b/WebCore/css/CSSGrammar.y index 4706521..1c1f7b4 100644 --- a/WebCore/css/CSSGrammar.y +++ b/WebCore/css/CSSGrammar.y @@ -36,12 +36,16 @@ #include "MediaList.h" #include "WebKitCSSKeyframeRule.h" #include "WebKitCSSKeyframesRule.h" +#include <wtf/FastMalloc.h> #include <stdlib.h> #include <string.h> using namespace WebCore; using namespace HTMLNames; +#define YYMALLOC fastMalloc +#define YYFREE fastFree + #define YYENABLE_NLS 0 #define YYLTYPE_IS_TRIVIAL 1 #define YYMAXDEPTH 10000 @@ -93,7 +97,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser) %} -%expect 49 +%expect 50 %nonassoc LOWEST_PREC @@ -145,6 +149,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser) %token MEDIA_NOT %token MEDIA_AND +%token <number> REMS %token <number> QEMS %token <number> EMS %token <number> EXS @@ -735,9 +740,9 @@ key: | IDENT { $$.id = 0; $$.isInt = false; $$.unit = CSSPrimitiveValue::CSS_NUMBER; CSSParserString& str = $1; - if (equalIgnoringCase(static_cast<const String&>(str), "from")) + if (equalIgnoringCase("from", str.characters, str.length)) $$.fValue = 0; - else if (equalIgnoringCase(static_cast<const String&>(str), "to")) + else if (equalIgnoringCase("to", str.characters, str.length)) $$.fValue = 100; else YYERROR; @@ -1407,7 +1412,15 @@ unary_term: | EMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EMS; } | QEMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSParserValue::Q_EMS; } | EXS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EXS; } - ; + | REMS maybe_space { + $$.id = 0; + $$.fValue = $1; + $$.unit = CSSPrimitiveValue::CSS_REMS; + CSSParser* p = static_cast<CSSParser*>(parser); + if (Document* doc = p->document()) + doc->setUsesRemUnits(true); + } + ; variable_reference: VARCALL { diff --git a/WebCore/css/CSSHelper.cpp b/WebCore/css/CSSHelper.cpp index aa1186c..8e6f3a0 100644 --- a/WebCore/css/CSSHelper.cpp +++ b/WebCore/css/CSSHelper.cpp @@ -27,7 +27,7 @@ namespace WebCore { -String parseURL(const String& url) +String deprecatedParseURL(const String& url) { StringImpl* i = url.impl(); if (!i) diff --git a/WebCore/css/CSSHelper.h b/WebCore/css/CSSHelper.h index 7f32d88..2e33377 100644 --- a/WebCore/css/CSSHelper.h +++ b/WebCore/css/CSSHelper.h @@ -1,7 +1,6 @@ /* - * This file is part of the CSS implementation for KDE. - * * Copyright (C) 1999 Lars Knoll (knoll@kde.org) + * Copyright (C) 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -27,15 +26,17 @@ namespace WebCore { class String; - /* - * mostly just removes the url("...") brace - */ - String parseURL(const String& url); + // Used in many inappropriate contexts throughout WebCore. We'll have to examine and test + // each call site to find out whether it needs the various things this function does. That + // includes trimming leading and trailing control characters (including whitespace), removing + // url() or URL() if it surrounds the entire string, removing matching quote marks if present, + // and stripping all characters in the range U+0000-U+000C. Probably no caller needs this. + String deprecatedParseURL(const String&); // We always assume 96 CSS pixels in a CSS inch. This is the cold hard truth of the Web. // At high DPI, we may scale a CSS pixel, but the ratio of the CSS pixel to the so-called // "absolute" CSS length units like inch and pt is always fixed and never changes. - const float cssPixelsPerInch = 96.0f; + const float cssPixelsPerInch = 96; } // namespace WebCore diff --git a/WebCore/css/CSSMutableStyleDeclaration.cpp b/WebCore/css/CSSMutableStyleDeclaration.cpp index 67b7da1..8ff5300 100644 --- a/WebCore/css/CSSMutableStyleDeclaration.cpp +++ b/WebCore/css/CSSMutableStyleDeclaration.cpp @@ -116,8 +116,8 @@ String CSSMutableStyleDeclaration::getPropertyValue(int propertyID) const } case CSSPropertyBackground: { const int properties[7] = { CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat, - CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition, CSSPropertyWebkitBackgroundClip, - CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundColor }; + CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition, CSSPropertyBackgroundClip, + CSSPropertyBackgroundOrigin, CSSPropertyBackgroundColor }; return getLayeredShorthandValue(properties, 7); } case CSSPropertyBorder: { diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index 75f62c5..b79992f 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2003 Lars Knoll (knoll@kde.org) * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> * Copyright (C) 2008 Eric Seidel <eric@webkit.org> * @@ -311,7 +311,7 @@ bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) CSSValue* value = parser.m_parsedProperties[0]->value(); if (value->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE) { CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - color = primitiveValue->getRGBColorValue(); + color = primitiveValue->getRGBA32Value(); } } else return false; @@ -396,7 +396,7 @@ bool CSSParser::parseMediaQuery(MediaList* queries, const String& string) m_mediaQuery = 0; // can't use { because tokenizer state switches from mediaquery to initial state when it sees { token. // instead insert one " " (which is WHITESPACE in CSSGrammar.y) - setupParser ("@-webkit-mediaquery ", string, "} "); + setupParser("@-webkit-mediaquery ", string, "} "); cssyyparse(this); bool ok = false; @@ -460,7 +460,7 @@ bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict) return false; bool b = false; - switch(value->unit) { + switch (value->unit) { case CSSPrimitiveValue::CSS_NUMBER: b = (unitflags & FNumber); if (!b && ((unitflags & (FLength | FAngle | FTime)) && (value->fValue == 0 || !strict))) { @@ -476,6 +476,7 @@ bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict) break; case CSSParserValue::Q_EMS: case CSSPrimitiveValue::CSS_EMS: + case CSSPrimitiveValue::CSS_REMS: case CSSPrimitiveValue::CSS_EXS: case CSSPrimitiveValue::CSS_PX: case CSSPrimitiveValue::CSS_CM: @@ -511,6 +512,8 @@ static int unitFromString(CSSParserValue* value) if (equal(value->string, "em")) return CSSPrimitiveValue::CSS_EMS; + if (equal(value->string, "rem")) + return CSSPrimitiveValue::CSS_REMS; if (equal(value->string, "ex")) return CSSPrimitiveValue::CSS_EXS; if (equal(value->string, "px")) @@ -862,7 +865,7 @@ bool CSSParser::parseValue(int propId, bool important) while (value && value->unit == CSSPrimitiveValue::CSS_URI) { if (!list) list = CSSValueList::createCommaSeparated(); - String uri = parseURL(value->string); + String uri = value->string; Vector<int> coords; value = m_valueList->next(); while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) { @@ -871,15 +874,17 @@ bool CSSParser::parseValue(int propId, bool important) } IntPoint hotspot; int nrcoords = coords.size(); - if (nrcoords > 0 && nrcoords != 2) { - if (m_strict) // only support hotspot pairs in strict mode - return false; - } else if (m_strict && nrcoords == 2) + if (nrcoords > 0 && nrcoords != 2) + return false; + if (nrcoords == 2) hotspot = IntPoint(coords[0], coords[1]); - if (m_strict || coords.size() == 0) { - if (!uri.isNull() && m_styleSheet) - list->append(CSSCursorImageValue::create(m_styleSheet->completeURL(uri), hotspot)); + + if (!uri.isNull() && m_styleSheet) { + // FIXME: The completeURL call should be done when using the CSSCursorImageValue, + // not when creating it. + list->append(CSSCursorImageValue::create(m_styleSheet->completeURL(uri), hotspot)); } + if ((m_strict && !value) || (value && !(value->unit == CSSParserValue::Operator && value->iValue == ','))) return false; value = m_valueList->next(); // comma @@ -906,9 +911,11 @@ bool CSSParser::parseValue(int propId, bool important) } case CSSPropertyBackgroundAttachment: + case CSSPropertyBackgroundClip: case CSSPropertyWebkitBackgroundClip: case CSSPropertyWebkitBackgroundComposite: case CSSPropertyBackgroundImage: + case CSSPropertyBackgroundOrigin: case CSSPropertyWebkitBackgroundOrigin: case CSSPropertyBackgroundPosition: case CSSPropertyBackgroundPositionX: @@ -941,10 +948,10 @@ bool CSSParser::parseValue(int propId, bool important) parsedValue = CSSImageValue::create(); m_valueList->next(); } else if (value->unit == CSSPrimitiveValue::CSS_URI) { - // ### allow string in non strict mode? - String uri = parseURL(value->string); - if (!uri.isNull() && m_styleSheet) { - parsedValue = CSSImageValue::create(m_styleSheet->completeURL(uri)); + if (m_styleSheet) { + // FIXME: The completeURL call should be done when using the CSSImageValue, + // not when creating it. + parsedValue = CSSImageValue::create(m_styleSheet->completeURL(value->string)); m_valueList->next(); } } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-gradient(")) { @@ -1099,9 +1106,9 @@ bool CSSParser::parseValue(int propId, bool important) if (id == CSSValueNone) { valid_primitive = true; } else { - RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); bool is_valid = true; - while(is_valid && value) { + while (is_valid && value) { switch (value->id) { case CSSValueBlink: break; @@ -1156,8 +1163,9 @@ bool CSSParser::parseValue(int propId, bool important) RefPtr<CSSValue> parsedValue; while ((val = m_valueList->current())) { if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) { - String value = parseURL(val->string); - parsedValue = CSSPrimitiveValue::create(m_styleSheet->completeURL(value), CSSPrimitiveValue::CSS_URI); + // FIXME: The completeURL call should be done when using the CSSPrimitiveValue, + // not when creating it. + parsedValue = CSSPrimitiveValue::create(m_styleSheet->completeURL(val->string), CSSPrimitiveValue::CSS_URI); } if (!parsedValue) break; @@ -1191,11 +1199,10 @@ bool CSSParser::parseValue(int propId, bool important) } } break; - case CSSPropertyWebkitBorderTopRightRadius: - case CSSPropertyWebkitBorderTopLeftRadius: - case CSSPropertyWebkitBorderBottomLeftRadius: - case CSSPropertyWebkitBorderBottomRightRadius: - case CSSPropertyWebkitBorderRadius: { + case CSSPropertyBorderTopRightRadius: + case CSSPropertyBorderTopLeftRadius: + case CSSPropertyBorderBottomLeftRadius: + case CSSPropertyBorderBottomRightRadius: { if (num != 1 && num != 2) return false; valid_primitive = validUnit(value, FLength, m_strict); @@ -1211,25 +1218,20 @@ bool CSSParser::parseValue(int propId, bool important) parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit); } else parsedValue2 = parsedValue1; - + RefPtr<Pair> pair = Pair::create(parsedValue1.release(), parsedValue2.release()); RefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(pair.release()); - if (propId == CSSPropertyWebkitBorderRadius) { - const int properties[4] = { CSSPropertyWebkitBorderTopRightRadius, - CSSPropertyWebkitBorderTopLeftRadius, - CSSPropertyWebkitBorderBottomLeftRadius, - CSSPropertyWebkitBorderBottomRightRadius }; - for (int i = 0; i < 4; i++) - addProperty(properties[i], val.get(), important); - } else - addProperty(propId, val.release(), important); + addProperty(propId, val.release(), important); return true; } + case CSSPropertyBorderRadius: + case CSSPropertyWebkitBorderRadius: + return parseBorderRadius(propId, important); case CSSPropertyOutlineOffset: valid_primitive = validUnit(value, FLength, m_strict); break; case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS3, so treat as CSS3 - case CSSPropertyWebkitBoxShadow: + case CSSPropertyBoxShadow: if (id == CSSValueNone) valid_primitive = true; else @@ -1369,7 +1371,8 @@ bool CSSParser::parseValue(int propId, bool important) if (id == CSSValueNone) valid_primitive = true; else { - if (validUnit(value, FNumber|FNonNeg, m_strict)) { + // Accepting valueless numbers is a quirk of the -webkit prefixed version of the property. + if (validUnit(value, FNumber|FLength|FNonNeg, m_strict)) { RefPtr<CSSValue> val = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit); if (val) { addProperty(propId, val.release(), important); @@ -1397,6 +1400,7 @@ bool CSSParser::parseValue(int propId, bool important) case CSSPropertyWebkitAnimationDirection: case CSSPropertyWebkitAnimationDuration: case CSSPropertyWebkitAnimationName: + case CSSPropertyWebkitAnimationPlayState: case CSSPropertyWebkitAnimationIterationCount: case CSSPropertyWebkitAnimationTimingFunction: case CSSPropertyWebkitTransitionDelay: @@ -1552,15 +1556,15 @@ bool CSSParser::parseValue(int propId, bool important) // in quirks mode but it's usually the X coordinate of a position. // FIXME: Add CSSPropertyWebkitBackgroundSize to the shorthand. const int properties[] = { CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat, - CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition, CSSPropertyWebkitBackgroundClip, - CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundColor }; - return parseFillShorthand(propId, properties, 7, important); + CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition, CSSPropertyBackgroundOrigin, + CSSPropertyBackgroundColor }; + return parseFillShorthand(propId, properties, 6, important); } case CSSPropertyWebkitMask: { const int properties[] = { CSSPropertyWebkitMaskImage, CSSPropertyWebkitMaskRepeat, - CSSPropertyWebkitMaskAttachment, CSSPropertyWebkitMaskPosition, CSSPropertyWebkitMaskClip, + CSSPropertyWebkitMaskAttachment, CSSPropertyWebkitMaskPosition, CSSPropertyWebkitMaskOrigin }; - return parseFillShorthand(propId, properties, 6, important); + return parseFillShorthand(propId, properties, 5, important); } case CSSPropertyBorder: // [ 'border-width' || 'border-style' || <color> ] | inherit @@ -1700,6 +1704,8 @@ bool CSSParser::parseValue(int propId, bool important) parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit); else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit); + else if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS) + parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit); else if (value->unit >= CSSParserValue::Q_EMS) parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS); m_valueList->next(); @@ -1742,6 +1748,7 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro bool parsedProperty[cMaxFillProperties] = { false }; RefPtr<CSSValue> values[cMaxFillProperties]; + RefPtr<CSSValue> clipValue; RefPtr<CSSValue> positionYValue; int i; @@ -1760,6 +1767,10 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro addFillValue(values[i], CSSInitialValue::createImplicit()); if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition) addFillValue(positionYValue, CSSInitialValue::createImplicit()); + if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) && !parsedProperty[i]) { + // If background-origin wasn't present, then reset background-clip also. + addFillValue(clipValue, CSSInitialValue::createImplicit()); + } } parsedProperty[i] = false; } @@ -1778,6 +1789,13 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro addFillValue(values[i], val1.release()); if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition) addFillValue(positionYValue, val2.release()); + if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) { + // Reparse the value as a clip, and see if we succeed. + if (parseFillProperty(CSSPropertyBackgroundClip, propId1, propId2, val1, val2)) + addFillValue(clipValue, val1.release()); // The property parsed successfully. + else + addFillValue(clipValue, CSSInitialValue::createImplicit()); // Some value was used for origin that is not supported by clip. Just reset clip instead. + } } } } @@ -1794,6 +1812,10 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro addFillValue(values[i], CSSInitialValue::createImplicit()); if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition) addFillValue(positionYValue, CSSInitialValue::createImplicit()); + if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) && !parsedProperty[i]) { + // If background-origin wasn't present, then reset background-clip also. + addFillValue(clipValue, CSSInitialValue::createImplicit()); + } } } @@ -1809,8 +1831,14 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro addProperty(CSSPropertyWebkitMaskPositionY, positionYValue.release(), important); } else addProperty(properties[i], values[i].release(), important); + + // Add in clip values when we hit the corresponding origin property. + if (properties[i] == CSSPropertyBackgroundOrigin) + addProperty(CSSPropertyBackgroundClip, clipValue.release(), important); + else if (properties[i] == CSSPropertyWebkitMaskOrigin) + addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), important); } - + return true; } @@ -2059,8 +2087,9 @@ bool CSSParser::parseContent(int propId, bool important) RefPtr<CSSValue> parsedValue; if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) { // url - String value = parseURL(val->string); - parsedValue = CSSImageValue::create(m_styleSheet->completeURL(value)); + // FIXME: The completeURL call should be done when using the CSSImageValue, + // not when creating it. + parsedValue = CSSImageValue::create(m_styleSheet->completeURL(val->string)); } else if (val->unit == CSSParserValue::Function) { // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradient(...) CSSParserValueList* args = val->function->args; @@ -2149,9 +2178,10 @@ bool CSSParser::parseFillImage(RefPtr<CSSValue>& value) return true; } if (m_valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { - String uri = parseURL(m_valueList->current()->string); - if (!uri.isNull() && m_styleSheet) - value = CSSImageValue::create(m_styleSheet->completeURL(uri)); + // FIXME: The completeURL call should be done when using the CSSImageValue, + // not when creating it. + if (m_styleSheet) + value = CSSImageValue::create(m_styleSheet->completeURL(m_valueList->current()->string)); return true; } @@ -2161,6 +2191,7 @@ bool CSSParser::parseFillImage(RefPtr<CSSValue>& value) if (equalIgnoringCase(m_valueList->current()->function->name, "-webkit-canvas(")) return parseCanvas(value); } + return false; } @@ -2305,7 +2336,7 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, break; case CSSPropertyBackgroundAttachment: case CSSPropertyWebkitMaskAttachment: - if (val->id == CSSValueScroll || val->id == CSSValueFixed) { + if (val->id == CSSValueScroll || val->id == CSSValueFixed || val->id == CSSValueLocal) { currValue = CSSPrimitiveValue::createIdentifier(val->id); m_valueList->next(); } @@ -2319,10 +2350,24 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, case CSSPropertyWebkitBackgroundOrigin: case CSSPropertyWebkitMaskClip: case CSSPropertyWebkitMaskOrigin: - // The first three values here are deprecated and should not be allowed to apply when we drop the -webkit- - // from the property names. + // The first three values here are deprecated and do not apply to the version of the property that has + // the -webkit- prefix removed. if (val->id == CSSValueBorder || val->id == CSSValuePadding || val->id == CSSValueContent || - val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueContentBox || val->id == CSSValueText) { + val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueContentBox || + ((propId == CSSPropertyWebkitBackgroundClip || propId == CSSPropertyWebkitMaskClip) && + (val->id == CSSValueText || val->id == CSSValueWebkitText))) { + currValue = CSSPrimitiveValue::createIdentifier(val->id); + m_valueList->next(); + } + break; + case CSSPropertyBackgroundClip: + if (val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueWebkitText) { + currValue = CSSPrimitiveValue::createIdentifier(val->id); + m_valueList->next(); + } + break; + case CSSPropertyBackgroundOrigin: + if (val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueContentBox) { currValue = CSSPrimitiveValue::createIdentifier(val->id); m_valueList->next(); } @@ -2462,6 +2507,14 @@ PassRefPtr<CSSValue> CSSParser::parseAnimationName() return 0; } +PassRefPtr<CSSValue> CSSParser::parseAnimationPlayState() +{ + CSSParserValue* value = m_valueList->current(); + if (value->id == CSSValueRunning || value->id == CSSValuePaused) + return CSSPrimitiveValue::createIdentifier(value->id); + return 0; +} + PassRefPtr<CSSValue> CSSParser::parseAnimationProperty() { CSSParserValue* value = m_valueList->current(); @@ -2583,6 +2636,11 @@ bool CSSParser::parseAnimationProperty(int propId, RefPtr<CSSValue>& result) if (currValue) m_valueList->next(); break; + case CSSPropertyWebkitAnimationPlayState: + currValue = parseAnimationPlayState(); + if (currValue) + m_valueList->next(); + break; case CSSPropertyWebkitTransitionProperty: currValue = parseAnimationProperty(); if (currValue) @@ -2636,7 +2694,7 @@ bool CSSParser::parseAnimationProperty(int propId, RefPtr<CSSValue>& result) #define DASHBOARD_REGION_NUM_PARAMETERS 6 #define DASHBOARD_REGION_SHORT_NUM_PARAMETERS 2 -static CSSParserValue* skipCommaInDashboardRegion (CSSParserValueList *args) +static CSSParserValue* skipCommaInDashboardRegion(CSSParserValueList *args) { if (args->size() == (DASHBOARD_REGION_NUM_PARAMETERS*2-1) || args->size() == (DASHBOARD_REGION_SHORT_NUM_PARAMETERS*2-1)) { @@ -2691,7 +2749,7 @@ bool CSSParser::parseDashboardRegions(int propId, bool important) int numArgs = args->size(); if ((numArgs != DASHBOARD_REGION_NUM_PARAMETERS && numArgs != (DASHBOARD_REGION_NUM_PARAMETERS*2-1)) && - (numArgs != DASHBOARD_REGION_SHORT_NUM_PARAMETERS && numArgs != (DASHBOARD_REGION_SHORT_NUM_PARAMETERS*2-1))){ + (numArgs != DASHBOARD_REGION_SHORT_NUM_PARAMETERS && numArgs != (DASHBOARD_REGION_SHORT_NUM_PARAMETERS*2-1))) { valid = false; break; } @@ -2707,7 +2765,7 @@ bool CSSParser::parseDashboardRegions(int propId, bool important) // Second arg is a type. arg = args->next(); - arg = skipCommaInDashboardRegion (args); + arg = skipCommaInDashboardRegion(args); if (arg->unit != CSSPrimitiveValue::CSS_IDENT) { valid = false; break; @@ -2737,7 +2795,7 @@ bool CSSParser::parseDashboardRegions(int propId, bool important) int i; for (i = 0; i < 4; i++) { arg = args->next(); - arg = skipCommaInDashboardRegion (args); + arg = skipCommaInDashboardRegion(args); valid = arg->id == CSSValueAuto || validUnit(arg, FLength, m_strict); if (!valid) @@ -3202,8 +3260,9 @@ bool CSSParser::parseFontFaceSrc() while ((val = m_valueList->current())) { RefPtr<CSSFontFaceSrcValue> parsedValue; if (val->unit == CSSPrimitiveValue::CSS_URI && !expectComma && m_styleSheet) { - String value = parseURL(val->string); - parsedValue = CSSFontFaceSrcValue::create(m_styleSheet->completeURL(value)); + // FIXME: The completeURL call should be done when using the CSSFontFaceSrcValue, + // not when creating it. + parsedValue = CSSFontFaceSrcValue::create(m_styleSheet->completeURL(val->string)); uriValue = parsedValue; allowFormat = true; expectComma = true; @@ -3488,74 +3547,125 @@ bool CSSParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bool svg) // This class tracks parsing state for shadow values. If it goes out of scope (e.g., due to an early return) // without the allowBreak bit being set, then it will clean up all of the objects and destroy them. struct ShadowParseContext { - ShadowParseContext() - : allowX(true) - , allowY(false) - , allowBlur(false) - , allowColor(true) - , allowBreak(true) - {} + ShadowParseContext(CSSPropertyID prop) + : property(prop) + , allowX(true) + , allowY(false) + , allowBlur(false) + , allowSpread(false) + , allowColor(true) + , allowStyle(prop == CSSPropertyBoxShadow) + , allowBreak(true) + { + } - bool allowLength() { return allowX || allowY || allowBlur; } + bool allowLength() { return allowX || allowY || allowBlur || allowSpread; } - void commitValue() { + void commitValue() + { // Handle the ,, case gracefully by doing nothing. - if (x || y || blur || color) { + if (x || y || blur || spread || color || style) { if (!values) values = CSSValueList::createCommaSeparated(); - + // Construct the current shadow value and add it to the list. - values->append(ShadowValue::create(x.release(), y.release(), blur.release(), color.release())); + values->append(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release())); } - - // Now reset for the next shadow value. - x = y = blur = color = 0; - allowX = allowColor = allowBreak = true; - allowY = allowBlur = false; - } - void commitLength(CSSParserValue* v) { + // Now reset for the next shadow value. + x = 0; + y = 0; + blur = 0; + spread = 0; + style = 0; + color = 0; + + allowX = true; + allowColor = true; + allowBreak = true; + allowY = false; + allowBlur = false; + allowSpread = false; + allowStyle = property == CSSPropertyBoxShadow; + } + + void commitLength(CSSParserValue* v) + { RefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit); if (allowX) { x = val.release(); - allowX = false; allowY = true; allowColor = false; allowBreak = false; - } - else if (allowY) { + allowX = false; + allowY = true; + allowColor = false; + allowStyle = false; + allowBreak = false; + } else if (allowY) { y = val.release(); - allowY = false; allowBlur = true; allowColor = true; allowBreak = true; - } - else if (allowBlur) { + allowY = false; + allowBlur = true; + allowColor = true; + allowStyle = property == CSSPropertyBoxShadow; + allowBreak = true; + } else if (allowBlur) { blur = val.release(); allowBlur = false; + allowSpread = property == CSSPropertyBoxShadow; + } else if (allowSpread) { + spread = val.release(); + allowSpread = false; } } - void commitColor(PassRefPtr<CSSPrimitiveValue> val) { + void commitColor(PassRefPtr<CSSPrimitiveValue> val) + { color = val; allowColor = false; + if (allowX) { + allowStyle = false; + allowBreak = false; + } else { + allowBlur = false; + allowSpread = false; + allowStyle = property == CSSPropertyBoxShadow; + } + } + + void commitStyle(CSSParserValue* v) + { + style = CSSPrimitiveValue::createIdentifier(v->id); + allowStyle = false; if (allowX) allowBreak = false; - else + else { allowBlur = false; + allowSpread = false; + allowColor = false; + } } - + + CSSPropertyID property; + RefPtr<CSSValueList> values; RefPtr<CSSPrimitiveValue> x; RefPtr<CSSPrimitiveValue> y; RefPtr<CSSPrimitiveValue> blur; + RefPtr<CSSPrimitiveValue> spread; + RefPtr<CSSPrimitiveValue> style; RefPtr<CSSPrimitiveValue> color; bool allowX; bool allowY; bool allowBlur; + bool allowSpread; bool allowColor; + bool allowStyle; bool allowBreak; }; bool CSSParser::parseShadow(int propId, bool important) { - ShadowParseContext context; + ShadowParseContext context(static_cast<CSSPropertyID>(propId)); CSSParserValue* val; while ((val = m_valueList->current())) { // Check for a comma break first. @@ -3567,17 +3677,19 @@ bool CSSParser::parseShadow(int propId, bool important) // The value is good. Commit it. context.commitValue(); - } - // Check to see if we're a length. - else if (validUnit(val, FLength, true)) { + } else if (validUnit(val, FLength, true)) { // We required a length and didn't get one. Invalid. if (!context.allowLength()) return false; // A length is allowed here. Construct the value and add it. context.commitLength(val); - } - else { + } else if (val->id == CSSValueInset) { + if (!context.allowStyle) + return false; + + context.commitStyle(val); + } else { // The only other type of value that's ok is a color value. RefPtr<CSSPrimitiveValue> parsedColor; bool isColor = ((val->id >= CSSValueAqua && val->id <= CSSValueWindowtext) || val->id == CSSValueMenu || @@ -3598,7 +3710,7 @@ bool CSSParser::parseShadow(int propId, bool important) context.commitColor(parsedColor.release()); } - + m_valueList->next(); } @@ -3610,7 +3722,7 @@ bool CSSParser::parseShadow(int propId, bool important) return true; } } - + return false; } @@ -3663,8 +3775,7 @@ bool CSSParser::parseReflect(int propId, bool important) return true; } -struct BorderImageParseContext -{ +struct BorderImageParseContext { BorderImageParseContext() : m_allowBreak(false) , m_allowNumber(false) @@ -3686,7 +3797,8 @@ struct BorderImageParseContext bool allowRule() const { return m_allowRule; } void commitImage(PassRefPtr<CSSValue> image) { m_image = image; m_allowNumber = true; } - void commitNumber(CSSParserValue* v) { + void commitNumber(CSSParserValue* v) + { PassRefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit); if (!m_top) m_top = val; @@ -3703,7 +3815,8 @@ struct BorderImageParseContext m_allowNumber = !m_left; } void commitSlash() { m_allowBreak = m_allowSlash = m_allowNumber = false; m_allowWidth = true; } - void commitWidth(CSSParserValue* val) { + void commitWidth(CSSParserValue* val) + { if (!m_borderTop) m_borderTop = val; else if (!m_borderRight) @@ -3718,14 +3831,16 @@ struct BorderImageParseContext m_allowBreak = m_allowRule = true; m_allowWidth = !m_borderLeft; } - void commitRule(int keyword) { + void commitRule(int keyword) + { if (!m_horizontalRule) m_horizontalRule = keyword; else if (!m_verticalRule) m_verticalRule = keyword; m_allowRule = !m_verticalRule; } - PassRefPtr<CSSValue> commitBorderImage(CSSParser* p, bool important) { + PassRefPtr<CSSValue> commitBorderImage(CSSParser* p, bool important) + { // We need to clone and repeat values for any omissions. if (!m_right) { m_right = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType()); @@ -3802,11 +3917,10 @@ bool CSSParser::parseBorderImage(int propId, bool important, RefPtr<CSSValue>& r // Look for an image initially. If the first value is not a URI, then we're done. BorderImageParseContext context; CSSParserValue* val = m_valueList->current(); - if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) { - String uri = parseURL(val->string); - if (uri.isNull()) - return false; - context.commitImage(CSSImageValue::create(m_styleSheet->completeURL(uri))); + if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) { + // FIXME: The completeURL call should be done when using the CSSImageValue, + // not when creating it. + context.commitImage(CSSImageValue::create(m_styleSheet->completeURL(val->string))); } else if (val->unit == CSSParserValue::Function) { RefPtr<CSSValue> value; if ((equalIgnoringCase(val->function->name, "-webkit-gradient(") && parseGradient(value)) || @@ -3849,6 +3963,75 @@ bool CSSParser::parseBorderImage(int propId, bool important, RefPtr<CSSValue>& r return false; } +static void completeBorderRadii(RefPtr<CSSPrimitiveValue> radii[4]) +{ + if (radii[3]) + return; + if (!radii[2]) { + if (!radii[1]) + radii[1] = radii[0]; + radii[2] = radii[0]; + } + radii[3] = radii[1]; +} + +bool CSSParser::parseBorderRadius(int propId, bool important) +{ + unsigned num = m_valueList->size(); + if (num > 9) + return false; + + RefPtr<CSSPrimitiveValue> radii[2][4]; + + unsigned indexAfterSlash = 0; + for (unsigned i = 0; i < num; ++i) { + CSSParserValue* value = m_valueList->valueAt(i); + if (value->unit == CSSParserValue::Operator) { + if (value->iValue != '/') + return false; + + if (!i || indexAfterSlash || i + 1 == num || num > i + 5) + return false; + + indexAfterSlash = i + 1; + completeBorderRadii(radii[0]); + continue; + } + + if (i - indexAfterSlash >= 4) + return false; + + if (!validUnit(value, FLength, m_strict)) + return false; + + RefPtr<CSSPrimitiveValue> radius = CSSPrimitiveValue::create(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit)); + + if (!indexAfterSlash) { + radii[0][i] = radius; + + // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to border-radius: l1 / l2; + if (num == 2 && propId == CSSPropertyWebkitBorderRadius) { + indexAfterSlash = 1; + completeBorderRadii(radii[0]); + } + } else + radii[1][i - indexAfterSlash] = radius.release(); + } + + if (!indexAfterSlash) { + completeBorderRadii(radii[0]); + for (unsigned i = 0; i < 4; ++i) + radii[1][i] = radii[0][i]; + } else + completeBorderRadii(radii[1]); + + addProperty(CSSPropertyBorderTopLeftRadius, CSSPrimitiveValue::create(Pair::create(radii[0][0].release(), radii[1][0].release())), important); + addProperty(CSSPropertyBorderTopRightRadius, CSSPrimitiveValue::create(Pair::create(radii[0][1].release(), radii[1][1].release())), important); + addProperty(CSSPropertyBorderBottomRightRadius, CSSPrimitiveValue::create(Pair::create(radii[0][2].release(), radii[1][2].release())), important); + addProperty(CSSPropertyBorderBottomLeftRadius, CSSPrimitiveValue::create(Pair::create(radii[0][3].release(), radii[1][3].release())), important); + return true; +} + bool CSSParser::parseCounter(int propId, int defaultValue, bool important) { enum { ID, VAL } state = ID; @@ -4351,7 +4534,7 @@ int CSSParser::lex(void* yylvalWithoutType) int length; UChar* t = text(&length); - switch(token) { + switch (token) { case WHITESPACE: case SGML_CD: case INCLUDES: @@ -4392,6 +4575,7 @@ int CSSParser::lex(void* yylvalWithoutType) case DEGS: case RADS: case KHERZ: + case REMS: length--; case MSECS: case HERZ: @@ -4419,22 +4603,16 @@ int CSSParser::lex(void* yylvalWithoutType) return token; } -static inline int toHex(char c) +static inline bool isCSSWhitespace(UChar c) { - if ('0' <= c && c <= '9') - return c - '0'; - if ('a' <= c && c <= 'f') - return c - 'a' + 10; - if ('A' <= c && c<= 'F') - return c - 'A' + 10; - return 0; + return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f'; } UChar* CSSParser::text(int *length) { UChar* start = yytext; int l = yyleng; - switch(yyTok) { + switch (yyTok) { case STRING: l--; /* nobreak */ @@ -4446,27 +4624,21 @@ UChar* CSSParser::text(int *length) case URI: // "url("{w}{string}{w}")" // "url("{w}{url}{w}")" - // strip "url(" and ")" start += 4; l -= 5; // strip {w} - while (l && - (*start == ' ' || *start == '\t' || *start == '\r' || - *start == '\n' || *start == '\f')) { - start++; l--; - } - if (*start == '"' || *start == '\'') { - start++; l--; + while (l && isCSSWhitespace(*start)) { + ++start; + --l; } - while (l && - (start[l-1] == ' ' || start[l-1] == '\t' || start[l-1] == '\r' || - start[l-1] == '\n' || start[l-1] == '\f')) { - l--; + while (l && isCSSWhitespace(start[l - 1])) + --l; + if (l && (*start == '"' || *start == '\'')) { + ASSERT(l >= 2 && start[l - 1] == *start); + ++start; + l -= 2; } - if (l && (start[l-1] == '\"' || start[l-1] == '\'')) - l--; - break; case VARCALL: // "-webkit-var("{w}{ident}{w}")" @@ -4474,16 +4646,13 @@ UChar* CSSParser::text(int *length) start += 12; l -= 13; // strip {w} - while (l && - (*start == ' ' || *start == '\t' || *start == '\r' || - *start == '\n' || *start == '\f')) { - start++; l--; - } - while (l && - (start[l-1] == ' ' || start[l-1] == '\t' || start[l-1] == '\r' || - start[l-1] == '\n' || start[l-1] == '\f')) { - l--; + while (l && isCSSWhitespace(*start)) { + ++start; + --l; } + while (l && isCSSWhitespace(start[l - 1])) + --l; + break; default: break; } @@ -4495,9 +4664,7 @@ UChar* CSSParser::text(int *length) for (int i = 0; i < l; i++) { UChar* current = start + i; if (escape == current - 1) { - if ((*current >= '0' && *current <= '9') || - (*current >= 'a' && *current <= 'f') || - (*current >= 'A' && *current <= 'F')) + if (isASCIIHexDigit(*current)) continue; if (yyTok == STRING && (*current == '\n' || *current == '\r' || *current == '\f')) { @@ -4517,10 +4684,7 @@ UChar* CSSParser::text(int *length) escape = 0; continue; } - if (escape > current - 7 && - ((*current >= '0' && *current <= '9') || - (*current >= 'a' && *current <= 'f') || - (*current >= 'A' && *current <= 'F'))) + if (escape > current - 7 && isASCIIHexDigit(*current)) continue; if (escape) { // add escaped char @@ -4528,7 +4692,7 @@ UChar* CSSParser::text(int *length) escape++; while (escape < current) { uc *= 16; - uc += toHex(*escape); + uc += toASCIIHexValue(*escape); escape++; } // can't handle chars outside ucs2 @@ -4536,11 +4700,7 @@ UChar* CSSParser::text(int *length) uc = 0xfffd; *out++ = uc; escape = 0; - if (*current == ' ' || - *current == '\t' || - *current == '\r' || - *current == '\n' || - *current == '\f') + if (isCSSWhitespace(*current)) continue; } if (!escape && *current == '\\') { @@ -4555,7 +4715,7 @@ UChar* CSSParser::text(int *length) escape++; while (escape < start+l) { uc *= 16; - uc += toHex(*escape); + uc += toASCIIHexValue(*escape); escape++; } // can't handle chars outside ucs2 @@ -4959,12 +5119,29 @@ static int cssPropertyID(const UChar* propertyName, unsigned length) ++length; } - // Honor -webkit-opacity as a synonym for opacity. - // This was the only syntax that worked in Safari 1.1, and may be in use on some websites and widgets. - if (strcmp(buffer, "-webkit-opacity") == 0) { - const char * const opacity = "opacity"; - name = opacity; - length = strlen(opacity); + if (hasPrefix(buffer, length, "-webkit")) { + if (strcmp(buffer, "-webkit-opacity") == 0) { + // Honor -webkit-opacity as a synonym for opacity. + // This was the only syntax that worked in Safari 1.1, and may be in use on some websites and widgets. + const char* const opacity = "opacity"; + name = opacity; + length = strlen(opacity); + } else if (strcmp(buffer, "-webkit-box-shadow") == 0) { + // CSS Backgrounds/Borders. -webkit-box-shadow worked in Safari 4 and earlier. + const char* const boxShadow = "box-shadow"; + name = boxShadow; + length = strlen(boxShadow); + } else if (hasPrefix(buffer + 7, length - 7, "-border-")) { + // -webkit-border-*-*-radius worked in Safari 4 and earlier. -webkit-border-radius syntax + // differs from border-radius, so it is remains as a distinct property. + if (!strcmp(buffer + 15, "top-left-radius") + || !strcmp(buffer + 15, "top-right-radius") + || !strcmp(buffer + 15, "bottom-right-radius") + || !strcmp(buffer + 15, "bottom-left-radius")) { + name = buffer + 8; + length -= 8; + } + } } } diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h index d47720f..5a2b283 100644 --- a/WebCore/css/CSSParser.h +++ b/WebCore/css/CSSParser.h @@ -96,6 +96,7 @@ namespace WebCore { PassRefPtr<CSSValue> parseAnimationDuration(); PassRefPtr<CSSValue> parseAnimationIterationCount(); PassRefPtr<CSSValue> parseAnimationName(); + PassRefPtr<CSSValue> parseAnimationPlayState(); PassRefPtr<CSSValue> parseAnimationProperty(); PassRefPtr<CSSValue> parseAnimationTimingFunction(); @@ -139,6 +140,7 @@ namespace WebCore { // CSS3 Parsing Routines (for properties specific to CSS3) bool parseShadow(int propId, bool important); bool parseBorderImage(int propId, bool important, RefPtr<CSSValue>&); + bool parseBorderRadius(int propId, bool important); bool parseReflect(int propId, bool important); @@ -191,7 +193,6 @@ namespace WebCore { Vector<CSSSelector*>* reusableSelectorVector() { return &m_reusableSelectorVector; } - public: bool m_strict; bool m_important; int m_id; @@ -217,7 +218,6 @@ namespace WebCore { AtomicString m_defaultNamespace; // tokenizer methods and data - public: int lex(void* yylval); int token() { return yyTok; } UChar* text(int* length); diff --git a/WebCore/css/CSSParserValues.cpp b/WebCore/css/CSSParserValues.cpp index dbfae78..55ecb7f 100644 --- a/WebCore/css/CSSParserValues.cpp +++ b/WebCore/css/CSSParserValues.cpp @@ -73,6 +73,8 @@ PassRefPtr<CSSValue> CSSParserValue::createCSSValue() parsedValue = CSSPrimitiveValue::create(string, (CSSPrimitiveValue::UnitTypes)unit); else if (unit >= CSSPrimitiveValue::CSS_NUMBER && unit <= CSSPrimitiveValue::CSS_KHZ) parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit); + else if (unit >= CSSPrimitiveValue::CSS_TURN && unit <= CSSPrimitiveValue::CSS_REMS) // CSS3 Values and Units + parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit); else if (unit >= CSSParserValue::Q_EMS) parsedValue = CSSQuirkPrimitiveValue::create(fValue, CSSPrimitiveValue::CSS_EMS); return parsedValue; diff --git a/WebCore/css/CSSPrimitiveValue.cpp b/WebCore/css/CSSPrimitiveValue.cpp index 15c5a01..6343dac 100644 --- a/WebCore/css/CSSPrimitiveValue.cpp +++ b/WebCore/css/CSSPrimitiveValue.cpp @@ -30,6 +30,7 @@ #include "ExceptionCode.h" #include "Node.h" #include "Pair.h" +#include "RGBColor.h" #include "Rect.h" #include "RenderStyle.h" #include <wtf/ASCIICType.h> @@ -318,9 +319,9 @@ void CSSPrimitiveValue::cleanup() m_type = 0; } -int CSSPrimitiveValue::computeLengthInt(RenderStyle* style) +int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle) { - double result = computeLengthDouble(style); + double result = computeLengthDouble(style, rootStyle); // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We // need to go ahead and round if we're really close to the next integer value. @@ -331,9 +332,9 @@ int CSSPrimitiveValue::computeLengthInt(RenderStyle* style) return static_cast<int>(result); } -int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, double multiplier) +int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle, double multiplier) { - double result = computeLengthDouble(style, multiplier); + double result = computeLengthDouble(style, rootStyle, multiplier); // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We // need to go ahead and round if we're really close to the next integer value. @@ -348,9 +349,9 @@ const int intMaxForLength = 0x7ffffff; // max value for a 28-bit int const int intMinForLength = (-0x7ffffff - 1); // min value for a 28-bit int // Lengths expect an int that is only 28-bits, so we have to check for a different overflow. -int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style) +int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle) { - double result = computeLengthDouble(style); + double result = computeLengthDouble(style, rootStyle); // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We // need to go ahead and round if we're really close to the next integer value. @@ -362,9 +363,9 @@ int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style) } // Lengths expect an int that is only 28-bits, so we have to check for a different overflow. -int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, double multiplier) +int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier) { - double result = computeLengthDouble(style, multiplier); + double result = computeLengthDouble(style, rootStyle, multiplier); // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We // need to go ahead and round if we're really close to the next integer value. @@ -375,9 +376,9 @@ int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, double mult return static_cast<int>(result); } -short CSSPrimitiveValue::computeLengthShort(RenderStyle* style) +short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle) { - double result = computeLengthDouble(style); + double result = computeLengthDouble(style, rootStyle); // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We // need to go ahead and round if we're really close to the next integer value. @@ -388,9 +389,9 @@ short CSSPrimitiveValue::computeLengthShort(RenderStyle* style) return static_cast<short>(result); } -short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, double multiplier) +short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle, double multiplier) { - double result = computeLengthDouble(style, multiplier); + double result = computeLengthDouble(style, rootStyle, multiplier); // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We // need to go ahead and round if we're really close to the next integer value. @@ -401,17 +402,17 @@ short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, double multiplie return static_cast<short>(result); } -float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, bool computingFontSize) +float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, bool computingFontSize) { - return static_cast<float>(computeLengthDouble(style, 1.0, computingFontSize)); + return static_cast<float>(computeLengthDouble(style, rootStyle, 1.0, computingFontSize)); } -float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, double multiplier, bool computingFontSize) +float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize) { - return static_cast<float>(computeLengthDouble(style, multiplier, computingFontSize)); + return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)); } -double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, double multiplier, bool computingFontSize) +double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize) { unsigned short type = primitiveType(); @@ -434,6 +435,10 @@ double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, double multipl applyZoomMultiplier = false; factor = style->font().xHeight(); break; + case CSS_REMS: + applyZoomMultiplier = false; + factor = computingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize(); + break; case CSS_PX: break; case CSS_CM: @@ -638,7 +643,7 @@ Rect* CSSPrimitiveValue::getRectValue(ExceptionCode& ec) const return m_value.rect; } -unsigned CSSPrimitiveValue::getRGBColorValue(ExceptionCode& ec) const +RGBColor* CSSPrimitiveValue::getRGBColorValue(ExceptionCode& ec) const { ec = 0; if (m_type != CSS_RGBCOLOR) { @@ -646,7 +651,8 @@ unsigned CSSPrimitiveValue::getRGBColorValue(ExceptionCode& ec) const return 0; } - return m_value.rgbcolor; + // FIMXE: This should not return a new object for each invocation. + return RGBColor::create(m_value.rgbcolor).releaseRef(); } Pair* CSSPrimitiveValue::getPairValue(ExceptionCode& ec) const @@ -700,6 +706,9 @@ String CSSPrimitiveValue::cssText() const case CSS_EXS: text = String::format("%.6lgex", m_value.num); break; + case CSS_REMS: + text = String::format("%.6lgrem", m_value.num); + break; case CSS_PX: text = String::format("%.6lgpx", m_value.num); break; @@ -892,6 +901,7 @@ CSSParserValue CSSPrimitiveValue::parserValue() const case CSS_PERCENTAGE: case CSS_EMS: case CSS_EXS: + case CSS_REMS: case CSS_PX: case CSS_CM: case CSS_MM: diff --git a/WebCore/css/CSSPrimitiveValue.h b/WebCore/css/CSSPrimitiveValue.h index ece9fc5..85a0ba3 100644 --- a/WebCore/css/CSSPrimitiveValue.h +++ b/WebCore/css/CSSPrimitiveValue.h @@ -23,6 +23,7 @@ #define CSSPrimitiveValue_h #include "CSSValue.h" +#include "Color.h" #include <wtf/PassRefPtr.h> namespace WebCore { @@ -30,6 +31,7 @@ namespace WebCore { class Counter; class DashboardRegion; class Pair; +class RGBColor; class Rect; class RenderStyle; class StringImpl; @@ -78,11 +80,13 @@ public: // This is used internally for unknown identifiers CSS_PARSER_IDENTIFIER = 107, - // This unit is in CSS 3, but that isn't a finished standard yet - CSS_TURN = 108 + // These are from CSS3 Values and Units, but that isn't a finished standard yet + CSS_TURN = 108, + CSS_REMS = 109 }; - static bool isUnitTypeLength(int type) { return type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG; } + static bool isUnitTypeLength(int type) { return (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) || + type == CSSPrimitiveValue::CSS_REMS; } static PassRefPtr<CSSPrimitiveValue> createIdentifier(int ident); static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue); @@ -112,15 +116,15 @@ public: * this is screen/printer dependent, so we probably need a config option for this, * and some tool to calibrate. */ - int computeLengthInt(RenderStyle*); - int computeLengthInt(RenderStyle*, double multiplier); - int computeLengthIntForLength(RenderStyle*); - int computeLengthIntForLength(RenderStyle*, double multiplier); - short computeLengthShort(RenderStyle*); - short computeLengthShort(RenderStyle*, double multiplier); - float computeLengthFloat(RenderStyle*, bool computingFontSize = false); - float computeLengthFloat(RenderStyle*, double multiplier, bool computingFontSize = false); - double computeLengthDouble(RenderStyle*, double multiplier = 1.0, bool computingFontSize = false); + int computeLengthInt(RenderStyle* currStyle, RenderStyle* rootStyle); + int computeLengthInt(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier); + int computeLengthIntForLength(RenderStyle* currStyle, RenderStyle* rootStyle); + int computeLengthIntForLength(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier); + short computeLengthShort(RenderStyle* currStyle, RenderStyle* rootStyle); + short computeLengthShort(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier); + float computeLengthFloat(RenderStyle* currStyle, RenderStyle* rootStyle, bool computingFontSize = false); + float computeLengthFloat(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize = false); + double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false); // use with care!!! void setPrimitiveType(unsigned short type) { m_type = type; } @@ -148,8 +152,8 @@ public: Rect* getRectValue(ExceptionCode&) const; Rect* getRectValue() const { return m_type != CSS_RECT ? 0 : m_value.rect; } - unsigned getRGBColorValue(ExceptionCode&) const; - unsigned getRGBColorValue() const { return m_type != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; } + RGBColor* getRGBColorValue(ExceptionCode&) const; + RGBA32 getRGBA32Value() const { return m_type != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; } Pair* getPairValue(ExceptionCode&) const; Pair* getPairValue() const { return m_type != CSS_PAIR ? 0 : m_value.pair; } @@ -157,7 +161,7 @@ public: DashboardRegion* getDashboardRegionValue() const { return m_type != CSS_DASHBOARD_REGION ? 0 : m_value.region; } int getIdent(); - template<typename T> operator T() const; // Defined in CSSPrimitiveValueMappings.h + template<typename T> inline operator T() const; // Defined in CSSPrimitiveValueMappings.h virtual bool parseString(const String&, bool = false); virtual String cssText() const; diff --git a/WebCore/css/CSSPrimitiveValueMappings.h b/WebCore/css/CSSPrimitiveValueMappings.h index fd1d203..69cfbb1 100644 --- a/WebCore/css/CSSPrimitiveValueMappings.h +++ b/WebCore/css/CSSPrimitiveValueMappings.h @@ -215,14 +215,20 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e) case MediaSeekForwardButtonPart: m_value.ident = CSSValueMediaSeekForwardButton; break; + case MediaRewindButtonPart: + m_value.ident = CSSValueMediaRewindButton; + break; + case MediaReturnToRealtimeButtonPart: + m_value.ident = CSSValueMediaReturnToRealtimeButton; + break; case MediaSliderPart: m_value.ident = CSSValueMediaSlider; break; case MediaSliderThumbPart: m_value.ident = CSSValueMediaSliderthumb; break; - case MediaTimelineContainerPart: - m_value.ident = CSSValueMediaTimelineContainer; + case MediaControlsBackgroundPart: + m_value.ident = CSSValueMediaControlsBackground; break; case MediaCurrentTimePart: m_value.ident = CSSValueMediaCurrentTimeDisplay; @@ -292,6 +298,37 @@ template<> inline CSSPrimitiveValue::operator ControlPart() const return ControlPart(m_value.ident - CSSValueCheckbox + 1); } +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillAttachment e) + : m_type(CSS_IDENT) +{ + switch (e) { + case ScrollBackgroundAttachment: + m_value.ident = CSSValueScroll; + break; + case LocalBackgroundAttachment: + m_value.ident = CSSValueLocal; + break; + case FixedBackgroundAttachment: + m_value.ident = CSSValueFixed; + break; + } +} + +template<> inline CSSPrimitiveValue::operator EFillAttachment() const +{ + switch (m_value.ident) { + case CSSValueScroll: + return ScrollBackgroundAttachment; + case CSSValueLocal: + return LocalBackgroundAttachment; + case CSSValueFixed: + return FixedBackgroundAttachment; + default: + ASSERT_NOT_REACHED(); + return ScrollBackgroundAttachment; + } +} + template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillBox e) : m_type(CSS_IDENT) { diff --git a/WebCore/css/CSSPropertyLonghand.cpp b/WebCore/css/CSSPropertyLonghand.cpp index 310f90e..b15f31e 100644 --- a/WebCore/css/CSSPropertyLonghand.cpp +++ b/WebCore/css/CSSPropertyLonghand.cpp @@ -128,10 +128,10 @@ static void initShorthandMap(ShorthandMap& shorthandMap) static const int backgroundProperties[] = { CSSPropertyBackgroundAttachment, - CSSPropertyWebkitBackgroundClip, + CSSPropertyBackgroundClip, CSSPropertyBackgroundColor, CSSPropertyBackgroundImage, - CSSPropertyWebkitBackgroundOrigin, + CSSPropertyBackgroundOrigin, CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY, CSSPropertyBackgroundRepeat, @@ -152,11 +152,12 @@ static void initShorthandMap(ShorthandMap& shorthandMap) SET_SHORTHAND_MAP_ENTRY(shorthandMap, CSSPropertyOverflow, overflowProperties); static const int borderRadiusProperties[] = { - CSSPropertyWebkitBorderTopRightRadius, - CSSPropertyWebkitBorderTopLeftRadius, - CSSPropertyWebkitBorderBottomLeftRadius, - CSSPropertyWebkitBorderBottomRightRadius + CSSPropertyBorderTopRightRadius, + CSSPropertyBorderTopLeftRadius, + CSSPropertyBorderBottomLeftRadius, + CSSPropertyBorderBottomRightRadius }; + SET_SHORTHAND_MAP_ENTRY(shorthandMap, CSSPropertyBorderRadius, borderRadiusProperties); SET_SHORTHAND_MAP_ENTRY(shorthandMap, CSSPropertyWebkitBorderRadius, borderRadiusProperties); static const int maskPositionProperties[] = { CSSPropertyWebkitMaskPositionX, CSSPropertyWebkitMaskPositionY }; diff --git a/WebCore/css/CSSPropertyNames.in b/WebCore/css/CSSPropertyNames.in index fd101e4..40e456f 100644 --- a/WebCore/css/CSSPropertyNames.in +++ b/WebCore/css/CSSPropertyNames.in @@ -10,8 +10,10 @@ background background-attachment +background-clip background-color background-image +background-origin background-position background-position-x background-position-y @@ -19,6 +21,8 @@ background-repeat border border-bottom border-bottom-color +border-bottom-left-radius +border-bottom-right-radius border-bottom-style border-bottom-width border-collapse @@ -27,6 +31,7 @@ border-left border-left-color border-left-style border-left-width +border-radius border-right border-right-color border-right-style @@ -35,10 +40,13 @@ border-spacing border-style border-top border-top-color +border-top-left-radius +border-top-right-radius border-top-style border-top-width border-width bottom +box-shadow caption-side clear clip @@ -142,6 +150,7 @@ zoom -webkit-animation-duration -webkit-animation-iteration-count -webkit-animation-name +-webkit-animation-play-state -webkit-animation-timing-function -webkit-appearance -webkit-backface-visibility @@ -150,14 +159,14 @@ zoom -webkit-background-origin -webkit-background-size -webkit-binding --webkit-border-bottom-left-radius --webkit-border-bottom-right-radius -webkit-border-fit -webkit-border-horizontal-spacing -webkit-border-image + +# -webkit-border-radius differs from border-radius only in the interpretation of +# a value consisting of two lengths: "-webkit-border-radius: l1 l2;" is equivalent +# to "border-radius: l1 / l2;" -webkit-border-radius --webkit-border-top-left-radius --webkit-border-top-right-radius -webkit-border-vertical-spacing -webkit-box-align -webkit-box-direction @@ -168,7 +177,6 @@ zoom -webkit-box-orient -webkit-box-pack -webkit-box-reflect --webkit-box-shadow -webkit-box-sizing -webkit-column-break-after -webkit-column-break-before diff --git a/WebCore/css/CSSRule.idl b/WebCore/css/CSSRule.idl index f13f293..bc57e55 100644 --- a/WebCore/css/CSSRule.idl +++ b/WebCore/css/CSSRule.idl @@ -22,6 +22,7 @@ module css { // Introduced in DOM Level 2: interface [ + CustomToJS, GenerateConstructor, Polymorphic, InterfaceUUID=548139b4-31ab-4978-b1d5-cfcfdfbaea0e, diff --git a/WebCore/css/CSSSelector.cpp b/WebCore/css/CSSSelector.cpp index 17fbd64..80910a7 100644 --- a/WebCore/css/CSSSelector.cpp +++ b/WebCore/css/CSSSelector.cpp @@ -107,6 +107,9 @@ void CSSSelector::extractPseudoType() const DEFINE_STATIC_LOCAL(AtomicString, mediaControlsTimeline, ("-webkit-media-controls-timeline")); DEFINE_STATIC_LOCAL(AtomicString, mediaControlsSeekBackButton, ("-webkit-media-controls-seek-back-button")); DEFINE_STATIC_LOCAL(AtomicString, mediaControlsSeekForwardButton, ("-webkit-media-controls-seek-forward-button")); + DEFINE_STATIC_LOCAL(AtomicString, mediaControlsRewindButton, ("-webkit-media-controls-rewind-button")); + DEFINE_STATIC_LOCAL(AtomicString, mediaControlsReturnToRealtimeButton, ("-webkit-media-controls-return-to-realtime-button")); + DEFINE_STATIC_LOCAL(AtomicString, mediaControlsStatusDisplay, ("-webkit-media-controls-status-display")); DEFINE_STATIC_LOCAL(AtomicString, mediaControlsFullscreenButton, ("-webkit-media-controls-fullscreen-button")); DEFINE_STATIC_LOCAL(AtomicString, mediaControlsTimelineContainer, ("-webkit-media-controls-timeline-container")); DEFINE_STATIC_LOCAL(AtomicString, mediaControlsCurrentTimeDisplay, ("-webkit-media-controls-current-time-display")); @@ -114,6 +117,8 @@ void CSSSelector::extractPseudoType() const DEFINE_STATIC_LOCAL(AtomicString, notStr, ("not(")); DEFINE_STATIC_LOCAL(AtomicString, onlyChild, ("only-child")); DEFINE_STATIC_LOCAL(AtomicString, onlyOfType, ("only-of-type")); + DEFINE_STATIC_LOCAL(AtomicString, optional, ("optional")); + DEFINE_STATIC_LOCAL(AtomicString, required, ("required")); DEFINE_STATIC_LOCAL(AtomicString, resizer, ("-webkit-resizer")); DEFINE_STATIC_LOCAL(AtomicString, root, ("root")); DEFINE_STATIC_LOCAL(AtomicString, scrollbar, ("-webkit-scrollbar")); @@ -236,6 +241,15 @@ void CSSSelector::extractPseudoType() const } else if (m_value == mediaControlsSeekForwardButton) { m_pseudoType = PseudoMediaControlsSeekForwardButton; element = true; + } else if (m_value == mediaControlsRewindButton) { + m_pseudoType = PseudoMediaControlsRewindButton; + element = true; + } else if (m_value == mediaControlsReturnToRealtimeButton) { + m_pseudoType = PseudoMediaControlsReturnToRealtimeButton; + element = true; + } else if (m_value == mediaControlsStatusDisplay) { + m_pseudoType = PseudoMediaControlsStatusDisplay; + element = true; } else if (m_value == mediaControlsFullscreenButton) { m_pseudoType = PseudoMediaControlsFullscreenButton; element = true; @@ -274,6 +288,10 @@ void CSSSelector::extractPseudoType() const m_pseudoType = PseudoSingleButton; else if (m_value == noButton) m_pseudoType = PseudoNoButton; + else if (m_value == optional) + m_pseudoType = PseudoOptional; + else if (m_value == required) + m_pseudoType = PseudoRequired; else if (m_value == scrollbarCorner) { element = true; m_pseudoType = PseudoScrollbarCorner; diff --git a/WebCore/css/CSSSelector.h b/WebCore/css/CSSSelector.h index 728c34d..18251fd 100644 --- a/WebCore/css/CSSSelector.h +++ b/WebCore/css/CSSSelector.h @@ -31,7 +31,7 @@ namespace WebCore { // this class represents a selector for a StyleRule - class CSSSelector : Noncopyable { + class CSSSelector : public Noncopyable { public: CSSSelector() : m_tag(anyQName()) @@ -128,6 +128,8 @@ namespace WebCore { PseudoFullPageMedia, PseudoDisabled, PseudoInputPlaceholder, + PseudoOptional, + PseudoRequired, PseudoReadOnly, PseudoReadWrite, PseudoIndeterminate, @@ -173,6 +175,9 @@ namespace WebCore { PseudoMediaControlsTimeline, PseudoMediaControlsSeekBackButton, PseudoMediaControlsSeekForwardButton, + PseudoMediaControlsRewindButton, + PseudoMediaControlsReturnToRealtimeButton, + PseudoMediaControlsStatusDisplay, PseudoMediaControlsFullscreenButton }; diff --git a/WebCore/css/CSSSelectorList.h b/WebCore/css/CSSSelectorList.h index 7a41fcf..3518139 100644 --- a/WebCore/css/CSSSelectorList.h +++ b/WebCore/css/CSSSelectorList.h @@ -31,7 +31,7 @@ namespace WebCore { - class CSSSelectorList : Noncopyable { + class CSSSelectorList : public Noncopyable { public: CSSSelectorList() : m_selectorArray(0) { } ~CSSSelectorList(); diff --git a/WebCore/css/CSSStyleDeclaration.cpp b/WebCore/css/CSSStyleDeclaration.cpp index a35f817..404a978 100644 --- a/WebCore/css/CSSStyleDeclaration.cpp +++ b/WebCore/css/CSSStyleDeclaration.cpp @@ -118,6 +118,12 @@ CSSRule* CSSStyleDeclaration::parentRule() const return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) : 0; } +bool CSSStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const +{ + RefPtr<CSSValue> value = getPropertyCSSValue(property->id()); + return value && value->cssText() == property->value()->cssText(); +} + void CSSStyleDeclaration::diff(CSSMutableStyleDeclaration* style) const { if (!style) @@ -128,8 +134,7 @@ void CSSStyleDeclaration::diff(CSSMutableStyleDeclaration* style) const CSSMutableStyleDeclaration::const_iterator end = style->end(); for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != end; ++it) { const CSSProperty& property = *it; - RefPtr<CSSValue> value = getPropertyCSSValue(property.id()); - if (value && (value->cssText() == property.value()->cssText())) + if (cssPropertyMatches(&property)) propertiesToRemove.append(property.id()); } } diff --git a/WebCore/css/CSSStyleDeclaration.h b/WebCore/css/CSSStyleDeclaration.h index ef4cc21..18493df 100644 --- a/WebCore/css/CSSStyleDeclaration.h +++ b/WebCore/css/CSSStyleDeclaration.h @@ -27,6 +27,7 @@ namespace WebCore { class CSSMutableStyleDeclaration; +class CSSProperty; class CSSRule; class CSSValue; @@ -72,6 +73,9 @@ public: protected: CSSStyleDeclaration(CSSRule* parentRule = 0); + + virtual bool cssPropertyMatches(const CSSProperty*) const; + }; } // namespace WebCore diff --git a/WebCore/css/CSSStyleDeclaration.idl b/WebCore/css/CSSStyleDeclaration.idl index 60020d9..f7ce37f 100644 --- a/WebCore/css/CSSStyleDeclaration.idl +++ b/WebCore/css/CSSStyleDeclaration.idl @@ -23,7 +23,7 @@ module css { // Introduced in DOM Level 2: interface [ GenerateConstructor, - CustomPutFunction, + DelegatingPutFunction, HasNameGetter, HasIndexGetter, InterfaceUUID=9989b2c3-a2b6-449b-abf9-c60d2260b1d7, diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp index 146b1ee..9074476 100644 --- a/WebCore/css/CSSStyleSelector.cpp +++ b/WebCore/css/CSSStyleSelector.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) - * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) @@ -526,13 +526,13 @@ static void loadFullDefaultStyle() } // Strict-mode rules. - String defaultRules = String(html4UserAgentStyleSheet, sizeof(html4UserAgentStyleSheet)) + theme()->extraDefaultStyleSheet(); + String defaultRules = String(htmlUserAgentStyleSheet, sizeof(htmlUserAgentStyleSheet)) + RenderTheme::defaultTheme()->extraDefaultStyleSheet(); CSSStyleSheet* defaultSheet = parseUASheet(defaultRules); defaultStyle->addRulesFromSheet(defaultSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(defaultSheet, printEval()); // Quirks-mode rules. - String quirksRules = String(quirksUserAgentStyleSheet, sizeof(quirksUserAgentStyleSheet)) + theme()->extraQuirksStyleSheet(); + String quirksRules = String(quirksUserAgentStyleSheet, sizeof(quirksUserAgentStyleSheet)) + RenderTheme::defaultTheme()->extraQuirksStyleSheet(); CSSStyleSheet* quirksSheet = parseUASheet(quirksRules); defaultQuirksStyle->addRulesFromSheet(quirksSheet, screenEval()); } @@ -822,6 +822,10 @@ void CSSStyleSelector::initForStyleResolve(Element* e, RenderStyle* parentStyle, else m_parentStyle = m_parentNode ? m_parentNode->renderStyle() : 0; + Node* docElement = e ? e->document()->documentElement() : 0; + RenderStyle* docStyle = m_checker.m_document->renderStyle(); + m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle; + m_style = 0; m_matchedDecls.clear(); @@ -1138,7 +1142,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl static bool loadedMediaStyleSheet; if (!loadedMediaStyleSheet && (e->hasTagName(videoTag) || e->hasTagName(audioTag))) { loadedMediaStyleSheet = true; - String mediaRules = String(mediaControlsUserAgentStyleSheet, sizeof(mediaControlsUserAgentStyleSheet)) + theme()->extraMediaControlsStyleSheet(); + String mediaRules = String(mediaControlsUserAgentStyleSheet, sizeof(mediaControlsUserAgentStyleSheet)) + RenderTheme::defaultTheme()->extraMediaControlsStyleSheet(); CSSStyleSheet* mediaControlsSheet = parseUASheet(mediaRules); defaultStyle->addRulesFromSheet(mediaControlsSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(mediaControlsSheet, printEval()); @@ -1314,8 +1318,13 @@ void CSSStyleSelector::keyframeStylesForAnimation(Element* e, const RenderStyle* // Add all the animating properties to the list CSSMutableStyleDeclaration::const_iterator end = kf->style()->end(); - for (CSSMutableStyleDeclaration::const_iterator it = kf->style()->begin(); it != end; ++it) - list.addProperty((*it).id()); + for (CSSMutableStyleDeclaration::const_iterator it = kf->style()->begin(); it != end; ++it) { + int property = (*it).id(); + // Timing-function within keyframes is special, because it is not animated; it just + // describes the timing function between this keyframe and the next. + if (property != CSSPropertyWebkitAnimationTimingFunction) + list.addProperty(property); + } // Add this keyframe style to all the indicated key times Vector<float> keys; @@ -1405,6 +1414,22 @@ PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo, return m_style.release(); } +#if ENABLE(DATAGRID) + +PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForDataGridColumn(DataGridColumn*, RenderStyle*) +{ + // FIXME: Implement + return 0; +} + +PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForDataGridColumnHeader(DataGridColumn*, RenderStyle*) +{ + // FIXME: Implement + return 0; +} + +#endif + static void addIntrinsicMargins(RenderStyle* style) { // Intrinsic margin value. @@ -1520,7 +1545,7 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e) // Button, legend, input, select and textarea all consider width values of 'auto' to be 'intrinsic'. // This will be important when we use block flows for all form controls. if (e && (e->hasTagName(legendTag) || e->hasTagName(buttonTag) || e->hasTagName(inputTag) || - e->hasTagName(selectTag) || e->hasTagName(textareaTag) + e->hasTagName(selectTag) || e->hasTagName(textareaTag) || e->hasTagName(datagridTag) #if ENABLE(WML) || e->hasTagName(WMLNames::insertedLegendTag) || e->hasTagName(WMLNames::inputTag) @@ -1589,7 +1614,7 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e) // Let the theme also have a crack at adjusting the style. if (style->hasAppearance()) - theme()->adjustStyle(this, style, e, m_hasUAAppearance, m_borderData, m_backgroundData, m_backgroundColor); + RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_hasUAAppearance, m_borderData, m_backgroundData, m_backgroundColor); #if ENABLE(SVG) if (e && e->isSVGElement()) { @@ -2355,6 +2380,10 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme return false; return e->isTextFormControl() && !e->isReadOnlyFormControl(); } + case CSSSelector::PseudoOptional: + return e && e->isOptionalFormControl(); + case CSSSelector::PseudoRequired: + return e && e->isRequiredFormControl(); case CSSSelector::PseudoChecked: { if (!e || !e->isFormControlElement()) break; @@ -2481,6 +2510,15 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme case CSSSelector::PseudoMediaControlsSeekForwardButton: dynamicPseudo = MEDIA_CONTROLS_SEEK_FORWARD_BUTTON; return true; + case CSSSelector::PseudoMediaControlsRewindButton: + dynamicPseudo = MEDIA_CONTROLS_REWIND_BUTTON; + return true; + case CSSSelector::PseudoMediaControlsReturnToRealtimeButton: + dynamicPseudo = MEDIA_CONTROLS_RETURN_TO_REALTIME_BUTTON; + return true; + case CSSSelector::PseudoMediaControlsStatusDisplay: + dynamicPseudo = MEDIA_CONTROLS_STATUS_DISPLAY; + return true; case CSSSelector::PseudoMediaControlsFullscreenButton: dynamicPseudo = MEDIA_CONTROLS_FULLSCREEN_BUTTON; return true; @@ -2728,7 +2766,7 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat // ------------------------------------------------------------------------------------- // this is mostly boring stuff on how to apply a certain rule to the renderstyle... -static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *style, double multiplier = 1, bool *ok = 0) +static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0) { // This function is tolerant of a null style value. The only place style is used is in // length measurements, like 'ems' and 'px'. And in those cases style is only used @@ -2740,11 +2778,11 @@ static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *st } else { int type = primitiveValue->primitiveType(); - if (!style && (type == CSSPrimitiveValue::CSS_EMS || type == CSSPrimitiveValue::CSS_EXS)) { + if (!style && (type == CSSPrimitiveValue::CSS_EMS || type == CSSPrimitiveValue::CSS_EXS || type == CSSPrimitiveValue::CSS_REMS)) { if (ok) *ok = false; } else if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style, multiplier), Fixed); + l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else if (type == CSSPrimitiveValue::CSS_NUMBER) @@ -2871,12 +2909,14 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) case CSSPropertyBackgroundAttachment: HANDLE_BACKGROUND_VALUE(attachment, Attachment, value) return; + case CSSPropertyBackgroundClip: case CSSPropertyWebkitBackgroundClip: HANDLE_BACKGROUND_VALUE(clip, Clip, value) return; case CSSPropertyWebkitBackgroundComposite: HANDLE_BACKGROUND_VALUE(composite, Composite, value) return; + case CSSPropertyBackgroundOrigin: case CSSPropertyWebkitBackgroundOrigin: HANDLE_BACKGROUND_VALUE(origin, Origin, value) return; @@ -3182,7 +3222,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) HANDLE_INHERIT_AND_INITIAL(horizontalBorderSpacing, HorizontalBorderSpacing) if (!primitiveValue) return; - short spacing = primitiveValue->computeLengthShort(style(), zoomFactor); + short spacing = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor); m_style->setHorizontalBorderSpacing(spacing); return; } @@ -3190,7 +3230,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) HANDLE_INHERIT_AND_INITIAL(verticalBorderSpacing, VerticalBorderSpacing) if (!primitiveValue) return; - short spacing = primitiveValue->computeLengthShort(style(), zoomFactor); + short spacing = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor); m_style->setVerticalBorderSpacing(spacing); return; } @@ -3365,7 +3405,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) width = 5; break; case CSSValueInvalid: - width = primitiveValue->computeLengthShort(style(), zoomFactor); + width = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor); break; default: return; @@ -3413,12 +3453,12 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) } int width = 0; - if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal){ + if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) { width = 0; } else { if (!primitiveValue) return; - width = primitiveValue->computeLengthInt(style(), zoomFactor); + width = primitiveValue->computeLengthInt(style(), m_rootElementStyle, zoomFactor); } switch (id) { case CSSPropertyLetterSpacing: @@ -3545,7 +3585,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) int type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) // Handle our quirky margin units if we have them. - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed, + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed, primitiveValue->isQuirkValue()); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); @@ -3645,7 +3685,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) if (primitiveValue && !apply) { unsigned short type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else @@ -3701,7 +3741,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) int type = primitiveValue->primitiveType(); Length l; if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); @@ -3763,9 +3803,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || (type != CSSPrimitiveValue::CSS_PERCENTAGE && type != CSSPrimitiveValue::CSS_EMS && - type != CSSPrimitiveValue::CSS_EXS)); + type != CSSPrimitiveValue::CSS_EXS && + type != CSSPrimitiveValue::CSS_REMS)); if (CSSPrimitiveValue::isUnitTypeLength(type)) - size = primitiveValue->computeLengthFloat(m_parentStyle, true); + size = primitiveValue->computeLengthFloat(m_parentStyle, m_rootElementStyle, true); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) size = (primitiveValue->getFloatValue() * oldSize) / 100.0f; else @@ -3831,7 +3872,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) double multiplier = m_style->effectiveZoom(); if (m_style->textSizeAdjust() && m_checker.m_document->frame() && m_checker.m_document->frame()->shouldApplyTextZoom()) multiplier *= m_checker.m_document->frame()->textZoomFactor(); - lineHeight = Length(primitiveValue->computeLengthIntForLength(style(), multiplier), Fixed); + lineHeight = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, multiplier), Fixed); } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) lineHeight = Length((m_style->fontSize() * primitiveValue->getIntValue()) / 100, Fixed); else if (type == CSSPrimitiveValue::CSS_NUMBER) @@ -3885,10 +3926,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) Rect* rect = primitiveValue->getRectValue(); if (!rect) return; - top = convertToLength(rect->top(), style(), zoomFactor); - right = convertToLength(rect->right(), style(), zoomFactor); - bottom = convertToLength(rect->bottom(), style(), zoomFactor); - left = convertToLength(rect->left(), style(), zoomFactor); + top = convertToLength(rect->top(), style(), m_rootElementStyle, zoomFactor); + right = convertToLength(rect->right(), style(), m_rootElementStyle, zoomFactor); + bottom = convertToLength(rect->bottom(), style(), m_rootElementStyle, zoomFactor); + left = convertToLength(rect->left(), style(), m_rootElementStyle, zoomFactor); } else if (primitiveValue->getIdent() != CSSValueAuto) { return; } @@ -4292,7 +4333,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) m_lineHeightValue = 0; FontDescription fontDescription; - theme()->systemFont(primitiveValue->getIdent(), fontDescription); + RenderTheme::defaultTheme()->systemFont(primitiveValue->getIdent(), fontDescription); // Double-check and see if the theme did anything. If not, don't bother updating the font. if (fontDescription.isAbsoluteSize()) { @@ -4409,6 +4450,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) return; } + case CSSPropertyBorderRadius: case CSSPropertyWebkitBorderRadius: if (isInherit) { m_style->setBorderTopLeftRadius(m_parentStyle->borderTopLeftRadius()); @@ -4422,23 +4464,23 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) return; } // Fall through - case CSSPropertyWebkitBorderTopLeftRadius: - case CSSPropertyWebkitBorderTopRightRadius: - case CSSPropertyWebkitBorderBottomLeftRadius: - case CSSPropertyWebkitBorderBottomRightRadius: { + case CSSPropertyBorderTopLeftRadius: + case CSSPropertyBorderTopRightRadius: + case CSSPropertyBorderBottomLeftRadius: + case CSSPropertyBorderBottomRightRadius: { if (isInherit) { - HANDLE_INHERIT_COND(CSSPropertyWebkitBorderTopLeftRadius, borderTopLeftRadius, BorderTopLeftRadius) - HANDLE_INHERIT_COND(CSSPropertyWebkitBorderTopRightRadius, borderTopRightRadius, BorderTopRightRadius) - HANDLE_INHERIT_COND(CSSPropertyWebkitBorderBottomLeftRadius, borderBottomLeftRadius, BorderBottomLeftRadius) - HANDLE_INHERIT_COND(CSSPropertyWebkitBorderBottomRightRadius, borderBottomRightRadius, BorderBottomRightRadius) + HANDLE_INHERIT_COND(CSSPropertyBorderTopLeftRadius, borderTopLeftRadius, BorderTopLeftRadius) + HANDLE_INHERIT_COND(CSSPropertyBorderTopRightRadius, borderTopRightRadius, BorderTopRightRadius) + HANDLE_INHERIT_COND(CSSPropertyBorderBottomLeftRadius, borderBottomLeftRadius, BorderBottomLeftRadius) + HANDLE_INHERIT_COND(CSSPropertyBorderBottomRightRadius, borderBottomRightRadius, BorderBottomRightRadius) return; } if (isInitial) { - HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyWebkitBorderTopLeftRadius, BorderTopLeftRadius, BorderRadius) - HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyWebkitBorderTopRightRadius, BorderTopRightRadius, BorderRadius) - HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyWebkitBorderBottomLeftRadius, BorderBottomLeftRadius, BorderRadius) - HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyWebkitBorderBottomRightRadius, BorderBottomRightRadius, BorderRadius) + HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderTopLeftRadius, BorderTopLeftRadius, BorderRadius) + HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderTopRightRadius, BorderTopRightRadius, BorderRadius) + HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderBottomLeftRadius, BorderBottomLeftRadius, BorderRadius) + HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderBottomRightRadius, BorderBottomRightRadius, BorderRadius) return; } @@ -4449,8 +4491,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) if (!pair) return; - int width = pair->first()->computeLengthInt(style(), zoomFactor); - int height = pair->second()->computeLengthInt(style(), zoomFactor); + int width = pair->first()->computeLengthInt(style(), m_rootElementStyle, zoomFactor); + int height = pair->second()->computeLengthInt(style(), m_rootElementStyle, zoomFactor); if (width < 0 || height < 0) return; @@ -4461,16 +4503,16 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) IntSize size(width, height); switch (id) { - case CSSPropertyWebkitBorderTopLeftRadius: + case CSSPropertyBorderTopLeftRadius: m_style->setBorderTopLeftRadius(size); break; - case CSSPropertyWebkitBorderTopRightRadius: + case CSSPropertyBorderTopRightRadius: m_style->setBorderTopRightRadius(size); break; - case CSSPropertyWebkitBorderBottomLeftRadius: + case CSSPropertyBorderBottomLeftRadius: m_style->setBorderBottomLeftRadius(size); break; - case CSSPropertyWebkitBorderBottomRightRadius: + case CSSPropertyBorderBottomRightRadius: m_style->setBorderBottomRightRadius(size); break; default: @@ -4482,11 +4524,11 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) case CSSPropertyOutlineOffset: HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset) - m_style->setOutlineOffset(primitiveValue->computeLengthInt(style(), zoomFactor)); + m_style->setOutlineOffset(primitiveValue->computeLengthInt(style(), m_rootElementStyle, zoomFactor)); return; case CSSPropertyTextShadow: - case CSSPropertyWebkitBoxShadow: { + case CSSPropertyBoxShadow: { if (isInherit) { if (id == CSSPropertyTextShadow) return m_style->setTextShadow(m_parentStyle->textShadow() ? new ShadowData(*m_parentStyle->textShadow()) : 0); @@ -4502,13 +4544,15 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) int len = list->length(); for (int i = 0; i < len; i++) { ShadowValue* item = static_cast<ShadowValue*>(list->itemWithoutBoundsCheck(i)); - int x = item->x->computeLengthInt(style(), zoomFactor); - int y = item->y->computeLengthInt(style(), zoomFactor); - int blur = item->blur ? item->blur->computeLengthInt(style(), zoomFactor) : 0; + int x = item->x->computeLengthInt(style(), m_rootElementStyle, zoomFactor); + int y = item->y->computeLengthInt(style(), m_rootElementStyle, zoomFactor); + int blur = item->blur ? item->blur->computeLengthInt(style(), m_rootElementStyle, zoomFactor) : 0; + int spread = item->spread ? item->spread->computeLengthInt(style(), m_rootElementStyle, zoomFactor) : 0; + ShadowStyle shadowStyle = item->style && item->style->getIdent() == CSSValueInset ? Inset : Normal; Color color; if (item->color) color = getColorFromPrimitiveValue(item->color.get()); - ShadowData* shadowData = new ShadowData(x, y, blur, color.isValid() ? color : Color::transparent); + ShadowData* shadowData = new ShadowData(x, y, blur, spread, shadowStyle, color.isValid() ? color : Color::transparent); if (id == CSSPropertyTextShadow) m_style->setTextShadow(shadowData, i != 0); else @@ -4530,7 +4574,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) if (type == CSSPrimitiveValue::CSS_PERCENTAGE) reflection->setOffset(Length(reflectValue->offset()->getDoubleValue(), Percent)); else - reflection->setOffset(Length(reflectValue->offset()->computeLengthIntForLength(style(), zoomFactor), Fixed)); + reflection->setOffset(Length(reflectValue->offset()->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed)); } NinePieceImage mask; mapNinePieceImage(reflectValue->mask(), mask); @@ -4636,7 +4680,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) m_style->setHasNormalColumnGap(); return; } - m_style->setColumnGap(primitiveValue->computeLengthFloat(style(), zoomFactor)); + m_style->setColumnGap(primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor)); return; } case CSSPropertyWebkitColumnWidth: { @@ -4650,7 +4694,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) m_style->setHasAutoColumnWidth(); return; } - m_style->setColumnWidth(primitiveValue->computeLengthFloat(style(), zoomFactor)); + m_style->setColumnWidth(primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor)); return; } case CSSPropertyWebkitColumnRuleStyle: @@ -4752,7 +4796,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) } else { bool ok = true; - Length l = convertToLength(primitiveValue, style(), 1, &ok); + Length l = convertToLength(primitiveValue, style(), m_rootElementStyle, 1, &ok); if (ok) m_style->setMarqueeIncrement(l); } @@ -4854,10 +4898,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) DashboardRegion *first = region; while (region) { - Length top = convertToLength(region->top(), style()); - Length right = convertToLength(region->right(), style()); - Length bottom = convertToLength(region->bottom(), style()); - Length left = convertToLength(region->left(), style()); + Length top = convertToLength(region->top(), style(), m_rootElementStyle); + Length right = convertToLength(region->right(), style(), m_rootElementStyle); + Length bottom = convertToLength(region->bottom(), style(), m_rootElementStyle); + Length left = convertToLength(region->left(), style(), m_rootElementStyle); if (region->m_isCircle) m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true); else if (region->m_isRectangle) @@ -4888,11 +4932,11 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) result *= 3; else if (primitiveValue->getIdent() == CSSValueThick) result *= 5; - width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLengthFloat(style(), zoomFactor); + width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLengthFloat(style(), m_rootElementStyle, zoomFactor); break; } default: - width = primitiveValue->computeLengthFloat(style(), zoomFactor); + width = primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor); break; } m_style->setTextStrokeWidth(width); @@ -4901,7 +4945,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) case CSSPropertyWebkitTransform: { HANDLE_INHERIT_AND_INITIAL(transform, Transform); TransformOperations operations; - createTransformOperations(value, style(), operations); + createTransformOperations(value, style(), m_rootElementStyle, operations); m_style->setTransform(operations); return; } @@ -4916,7 +4960,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) Length l; int type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else @@ -4930,8 +4974,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) Length l; int type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); - else if(type == CSSPrimitiveValue::CSS_PERCENTAGE) + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); + else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else return; @@ -4944,7 +4988,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) float f; int type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) - f = static_cast<float>(primitiveValue->computeLengthIntForLength(style())); + f = static_cast<float>(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle)); else return; m_style->setTransformOriginZ(f); @@ -4961,10 +5005,17 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) m_style->setPerspective(0); return; } - - if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER) + + float perspectiveValue; + int type = primitiveValue->primitiveType(); + if (CSSPrimitiveValue::isUnitTypeLength(type)) + perspectiveValue = static_cast<float>(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor)); + else if (type == CSSPrimitiveValue::CSS_NUMBER) { + // For backward compatibility, treat valueless numbers as px. + perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLengthFloat(style(), m_rootElementStyle, zoomFactor); + } else return; - float perspectiveValue = static_cast<float>(primitiveValue->getDoubleValue()); + if (perspectiveValue >= 0.0f) m_style->setPerspective(perspectiveValue); return; @@ -4979,7 +5030,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) Length l; int type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else @@ -4993,8 +5044,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) Length l; int type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); - else if(type == CSSPrimitiveValue::CSS_PERCENTAGE) + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); + else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else return; @@ -5022,6 +5073,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) case CSSPropertyWebkitAnimationName: HANDLE_ANIMATION_VALUE(name, Name, value) return; + case CSSPropertyWebkitAnimationPlayState: + HANDLE_ANIMATION_VALUE(playState, PlayState, value) + return; case CSSPropertyWebkitAnimationTimingFunction: HANDLE_ANIMATION_VALUE(timingFunction, TimingFunction, value) return; @@ -5118,10 +5172,13 @@ void CSSStyleSelector::mapFillAttachment(FillLayer* layer, CSSValue* value) CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); switch (primitiveValue->getIdent()) { case CSSValueFixed: - layer->setAttachment(false); + layer->setAttachment(FixedBackgroundAttachment); break; case CSSValueScroll: - layer->setAttachment(true); + layer->setAttachment(ScrollBackgroundAttachment); + break; + case CSSValueLocal: + layer->setAttachment(LocalBackgroundAttachment); break; default: return; @@ -5235,7 +5292,7 @@ void CSSStyleSelector::mapFillSize(FillLayer* layer, CSSValue* value) if (firstType == CSSPrimitiveValue::CSS_UNKNOWN) firstLength = Length(Auto); else if (CSSPrimitiveValue::isUnitTypeLength(firstType)) - firstLength = Length(first->computeLengthIntForLength(style(), zoomFactor), Fixed); + firstLength = Length(first->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE) firstLength = Length(first->getDoubleValue(), Percent); else @@ -5244,7 +5301,7 @@ void CSSStyleSelector::mapFillSize(FillLayer* layer, CSSValue* value) if (secondType == CSSPrimitiveValue::CSS_UNKNOWN) secondLength = Length(Auto); else if (CSSPrimitiveValue::isUnitTypeLength(secondType)) - secondLength = Length(second->computeLengthIntForLength(style(), zoomFactor), Fixed); + secondLength = Length(second->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE) secondLength = Length(second->getDoubleValue(), Percent); else @@ -5271,7 +5328,7 @@ void CSSStyleSelector::mapFillXPosition(FillLayer* layer, CSSValue* value) Length l; int type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else @@ -5295,7 +5352,7 @@ void CSSStyleSelector::mapFillYPosition(FillLayer* layer, CSSValue* value) Length l; int type = primitiveValue->primitiveType(); if (CSSPrimitiveValue::isUnitTypeLength(type)) - l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); + l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else @@ -5377,6 +5434,18 @@ void CSSStyleSelector::mapAnimationName(Animation* layer, CSSValue* value) layer->setName(primitiveValue->getStringValue()); } +void CSSStyleSelector::mapAnimationPlayState(Animation* layer, CSSValue* value) +{ + if (value->cssValueType() == CSSValue::CSS_INITIAL) { + layer->setPlayState(Animation::initialAnimationPlayState()); + return; + } + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + EAnimPlayState playState = (primitiveValue->getIdent() == CSSValuePaused) ? AnimPlayStatePaused : AnimPlayStatePlaying; + layer->setPlayState(playState); +} + void CSSStyleSelector::mapAnimationProperty(Animation* animation, CSSValue* value) { if (value->cssValueType() == CSSValue::CSS_INITIAL) { @@ -5706,7 +5775,7 @@ static Color colorForCSSValue(int cssValueId) if (col->cssValueId == cssValueId) return col->color; } - return theme()->systemColor(cssValueId); + return RenderTheme::defaultTheme()->systemColor(cssValueId); } Color CSSStyleSelector::getColorFromPrimitiveValue(CSSPrimitiveValue* primitiveValue) @@ -5729,13 +5798,13 @@ Color CSSStyleSelector::getColorFromPrimitiveValue(CSSPrimitiveValue* primitiveV } else if (ident == CSSValueWebkitActivelink) col = m_element->document()->activeLinkColor(); else if (ident == CSSValueWebkitFocusRingColor) - col = focusRingColor(); + col = RenderTheme::focusRingColor(); else if (ident == CSSValueCurrentcolor) col = m_style->color(); else col = colorForCSSValue(ident); } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR) - col.setRGB(primitiveValue->getRGBColorValue()); + col.setRGB(primitiveValue->getRGBA32Value()); return col; } @@ -5809,7 +5878,7 @@ static TransformOperation::OperationType getTransformOperationType(WebKitCSSTran return TransformOperation::NONE; } -bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* style, TransformOperations& outOperations) +bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations) { float zoomFactor = style ? style->effectiveZoom() : 1; @@ -5876,13 +5945,13 @@ bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* Length tx = Length(0, Fixed); Length ty = Length(0, Fixed); if (val->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) - ty = convertToLength(firstValue, style, zoomFactor, &ok); + ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); else { - tx = convertToLength(firstValue, style, zoomFactor, &ok); + tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); if (val->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { if (val->length() > 1) { CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1)); - ty = convertToLength(secondValue, style, zoomFactor, &ok); + ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok); } } } @@ -5900,19 +5969,19 @@ bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* Length ty = Length(0, Fixed); Length tz = Length(0, Fixed); if (val->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation) - tz = convertToLength(firstValue, style, zoomFactor, &ok); + tz = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); else if (val->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) - ty = convertToLength(firstValue, style, zoomFactor, &ok); + ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); else { - tx = convertToLength(firstValue, style, zoomFactor, &ok); + tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); if (val->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { if (val->length() > 2) { CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2)); - tz = convertToLength(thirdValue, style, zoomFactor, &ok); + tz = convertToLength(thirdValue, style, rootStyle, zoomFactor, &ok); } if (val->length() > 1) { CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1)); - ty = convertToLength(secondValue, style, zoomFactor, &ok); + ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok); } } } diff --git a/WebCore/css/CSSStyleSelector.h b/WebCore/css/CSSStyleSelector.h index 8dd36d7..668c6c3 100644 --- a/WebCore/css/CSSStyleSelector.h +++ b/WebCore/css/CSSStyleSelector.h @@ -50,6 +50,7 @@ class CSSStyleSheet; class CSSValue; class CSSVariableDependentValue; class CSSVariablesRule; +class DataGridColumn; class Document; class Element; class Frame; @@ -77,7 +78,7 @@ public: }; // This class selects a RenderStyle for a given element based on a collection of stylesheets. - class CSSStyleSelector : Noncopyable { + class CSSStyleSelector : public Noncopyable { public: CSSStyleSelector(Document*, const String& userStyleSheet, StyleSheetList*, CSSStyleSheet*, bool strictParsing, bool matchAuthorAndUserStyles); ~CSSStyleSelector(); @@ -89,6 +90,12 @@ public: PassRefPtr<RenderStyle> pseudoStyleForElement(PseudoId, Element*, RenderStyle* parentStyle = 0); +#if ENABLE(DATAGRID) + // Datagrid style computation (uses unique pseudo elements and structures) + PassRefPtr<RenderStyle> pseudoStyleForDataGridColumn(DataGridColumn*, RenderStyle* parentStyle); + PassRefPtr<RenderStyle> pseudoStyleForDataGridColumnHeader(DataGridColumn*, RenderStyle* parentStyle); +#endif + private: RenderStyle* locateSharedStyle(); Node* locateCousinList(Element* parent, unsigned depth = 1); @@ -145,7 +152,7 @@ public: void addKeyframeStyle(PassRefPtr<WebKitCSSKeyframesRule> rule); - static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, TransformOperations& outOperations); + static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations); private: enum SelectorMatch { SelectorMatches, SelectorFailsLocally, SelectorFailsCompletely }; @@ -226,6 +233,7 @@ public: void mapAnimationDuration(Animation*, CSSValue*); void mapAnimationIterationCount(Animation*, CSSValue*); void mapAnimationName(Animation*, CSSValue*); + void mapAnimationPlayState(Animation*, CSSValue*); void mapAnimationProperty(Animation*, CSSValue*); void mapAnimationTimingFunction(Animation*, CSSValue*); @@ -259,6 +267,7 @@ public: RefPtr<RenderStyle> m_style; RenderStyle* m_parentStyle; + RenderStyle* m_rootElementStyle; Element* m_element; StyledElement* m_styledElement; Node* m_parentNode; @@ -287,7 +296,9 @@ public: prev->m_next = this; } - ~CSSRuleData() { delete m_next; } + ~CSSRuleData() + { + } unsigned position() { return m_position; } CSSStyleRule* rule() { return m_rule; } @@ -309,7 +320,17 @@ public: { } - ~CSSRuleDataList() { delete m_first; } + ~CSSRuleDataList() + { + CSSRuleData* ptr; + CSSRuleData* next; + ptr = m_first; + while (ptr) { + next = ptr->next(); + delete ptr; + ptr = next; + } + } CSSRuleData* first() { return m_first; } CSSRuleData* last() { return m_last; } diff --git a/WebCore/css/CSSValue.idl b/WebCore/css/CSSValue.idl index 875d12e..ee82b0c 100644 --- a/WebCore/css/CSSValue.idl +++ b/WebCore/css/CSSValue.idl @@ -21,6 +21,7 @@ module css { interface [ + CustomToJS, GenerateConstructor, Polymorphic, InterfaceUUID=9fd62a7b-539d-4500-bd6c-ec075abbc404, diff --git a/WebCore/css/CSSValueKeywords.in b/WebCore/css/CSSValueKeywords.in index 698dffe..c0b52f2 100644 --- a/WebCore/css/CSSValueKeywords.in +++ b/WebCore/css/CSSValueKeywords.in @@ -341,6 +341,7 @@ invert landscape level line-through +local loud lower -webkit-marquee @@ -504,9 +505,11 @@ media-mute-button media-play-button media-seek-back-button media-seek-forward-button +media-rewind-button +media-return-to-realtime-button media-slider media-sliderthumb -media-timeline-container +media-controls-background media-current-time-display media-time-remaining-display menulist @@ -541,17 +544,13 @@ round # border-box/content-box/padding-box should be used instead. # border +border-box content +content-box padding padding-box # -# CSS_PROP_BOX_SIZING -# -border-box -content-box - -# # CSS_PROP__KHTML_RTL_ORDERING # logical diff --git a/WebCore/css/CSSValueList.cpp b/WebCore/css/CSSValueList.cpp index b547768..4928026 100644 --- a/WebCore/css/CSSValueList.cpp +++ b/WebCore/css/CSSValueList.cpp @@ -70,6 +70,32 @@ void CSSValueList::prepend(PassRefPtr<CSSValue> val) m_values.prepend(val); } +bool CSSValueList::removeAll(CSSValue* val) +{ + bool found = false; + // FIXME: we should be implementing operator== to CSSValue and its derived classes + // to make comparison more flexible and fast. + for (size_t index = 0; index < m_values.size(); index++) { + if (m_values.at(index)->cssText() == val->cssText()) { + m_values.remove(index); + found = true; + } + } + + return found; +} + +bool CSSValueList::hasValue(CSSValue* val) +{ + // FIXME: we should be implementing operator== to CSSValue and its derived classes + // to make comparison more flexible and fast. + for (size_t index = 0; index < m_values.size(); index++) { + if (m_values.at(index)->cssText() == val->cssText()) + return true; + } + return false; +} + String CSSValueList::cssText() const { String result = ""; diff --git a/WebCore/css/CSSValueList.h b/WebCore/css/CSSValueList.h index d34f445..0d531de 100644 --- a/WebCore/css/CSSValueList.h +++ b/WebCore/css/CSSValueList.h @@ -52,6 +52,8 @@ public: void append(PassRefPtr<CSSValue>); void prepend(PassRefPtr<CSSValue>); + bool removeAll(CSSValue*); + bool hasValue(CSSValue*); virtual String cssText() const; diff --git a/WebCore/css/Media.cpp b/WebCore/css/Media.cpp new file mode 100644 index 0000000..57c4aac --- /dev/null +++ b/WebCore/css/Media.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2009 Apple 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#include "config.h" + +#include "Media.h" +#include "CSSStyleSelector.h" +#include "Frame.h" +#include "FrameView.h" +#include "MediaList.h" +#include "MediaQueryEvaluator.h" + +namespace WebCore { + +Media::Media(DOMWindow* window) + : m_window(window) +{ +} + +String Media::type() const +{ + Frame* frame = m_window->frame(); + FrameView* view = frame ? frame->view() : 0; + if (view) + return view->mediaType(); + + return String(); +} + +bool Media::matchMedium(const String& query) const +{ + Document* document = m_window->document(); + Frame* frame = m_window->frame(); + + CSSStyleSelector* styleSelector = document->styleSelector(); + Element* docElement = document->documentElement(); + if (!styleSelector || !docElement || !frame) + return false; + + RefPtr<RenderStyle> rootStyle = styleSelector->styleForElement(docElement, 0 /*defaultParent*/, false /*allowSharing*/, true /*resolveForRootDefault*/); + RefPtr<MediaList> media = MediaList::create(); + + ExceptionCode ec = 0; + media->setMediaText(query, ec); + if (ec) + return false; + + MediaQueryEvaluator screenEval(type(), frame, rootStyle.get()); + return screenEval.eval(media.get()); +} + +} // namespace WebCore diff --git a/WebCore/css/Media.h b/WebCore/css/Media.h new file mode 100644 index 0000000..0d7b504 --- /dev/null +++ b/WebCore/css/Media.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Apple 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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 Media_h +#define Media_h + +#include "DOMWindow.h" + +namespace WebCore { + +class Media : public RefCounted<Media> { +public: + static PassRefPtr<Media> create(DOMWindow* window) + { + return adoptRef(new Media(window)); + } + + Document* document() const { return m_window->document(); } + + String type() const; + + bool matchMedium(const String&) const; + +private: + Media(DOMWindow*); + + RefPtr<DOMWindow> m_window; +}; + +} // namespace + +#endif // Media_h diff --git a/WebCore/css/Media.idl b/WebCore/css/Media.idl new file mode 100644 index 0000000..b01d712 --- /dev/null +++ b/WebCore/css/Media.idl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2009 Apple 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +module view { + interface [ + GenerateConstructor, + ] Media { + readonly attribute DOMString type; + boolean matchMedium(in DOMString mediaquery); + }; +} diff --git a/WebCore/css/MediaList.cpp b/WebCore/css/MediaList.cpp index 452345f..85cf590 100644 --- a/WebCore/css/MediaList.cpp +++ b/WebCore/css/MediaList.cpp @@ -139,7 +139,7 @@ void MediaList::deleteMedium(const String& oldMedium, ExceptionCode& ec) ec = NOT_FOUND_ERR; if (oldQuery) { - for(size_t i = 0; i < m_queries.size(); ++i) { + for (size_t i = 0; i < m_queries.size(); ++i) { MediaQuery* a = m_queries[i]; if (*a == *oldQuery) { m_queries.remove(i); diff --git a/WebCore/css/MediaQuery.h b/WebCore/css/MediaQuery.h index 0aa0da1..ff22d9a 100644 --- a/WebCore/css/MediaQuery.h +++ b/WebCore/css/MediaQuery.h @@ -34,8 +34,7 @@ namespace WebCore { class MediaQueryExp; -class MediaQuery -{ +class MediaQuery { public: enum Restrictor { Only, Not, None diff --git a/WebCore/css/MediaQueryEvaluator.cpp b/WebCore/css/MediaQueryEvaluator.cpp index c641dfd..4963ed4 100644 --- a/WebCore/css/MediaQueryEvaluator.cpp +++ b/WebCore/css/MediaQueryEvaluator.cpp @@ -40,11 +40,17 @@ #include "MediaList.h" #include "MediaQuery.h" #include "MediaQueryExp.h" +#include "NodeRenderStyle.h" #include "Page.h" +#include "RenderView.h" #include "RenderStyle.h" #include "PlatformScreen.h" #include <wtf/HashMap.h> +#if ENABLE(3D_RENDERING) +#include "RenderLayerCompositor.h" +#endif + namespace WebCore { using namespace MediaFeatureNames; @@ -162,7 +168,7 @@ bool MediaQueryEvaluator::eval(const MediaList* mediaList, CSSStyleSelector* sty static bool parseAspectRatio(CSSValue* value, int& h, int& v) { - if (value->isValueList()){ + if (value->isValueList()) { CSSValueList* valueList = static_cast<CSSValueList*>(value); if (valueList->length() == 3) { CSSValue* i0 = valueList->itemWithoutBoundsCheck(0); @@ -300,7 +306,8 @@ static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, F { if (value) { FloatRect sg = screenRect(frame->page()->mainFrame()->view()); - return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op); + RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle(); + return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op); } // ({,min-,max-}device-height) // assume if we have a device, assume non-zero @@ -311,7 +318,8 @@ static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Fr { if (value) { FloatRect sg = screenRect(frame->page()->mainFrame()->view()); - return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op); + RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle(); + return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op); } // ({,min-,max-}device-width) // assume if we have a device, assume non-zero @@ -321,9 +329,10 @@ static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Fr static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op) { FrameView* view = frame->view(); - + RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle(); + if (value) - return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op); + return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op); return view->layoutHeight() != 0; } @@ -331,9 +340,10 @@ static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op) { FrameView* view = frame->view(); - + RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle(); + if (value) - return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op); + return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op); return view->layoutWidth() != 0; } @@ -457,15 +467,20 @@ static bool transform_2dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, return true; } -static bool transform_3dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op) +static bool transform_3dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op) { bool returnValueIfNoParameter; int have3dRendering; #if ENABLE(3D_RENDERING) - returnValueIfNoParameter = true; - have3dRendering = 1; + bool threeDEnabled = false; + if (RenderView* view = frame->contentRenderer()) + threeDEnabled = view->compositor()->hasAcceleratedCompositing(); + + returnValueIfNoParameter = threeDEnabled; + have3dRendering = threeDEnabled ? 1 : 0; #else + UNUSED_PARAM(frame); returnValueIfNoParameter = false; have3dRendering = 0; #endif diff --git a/WebCore/css/MediaQueryEvaluator.h b/WebCore/css/MediaQueryEvaluator.h index 5ae8fec..404504b 100644 --- a/WebCore/css/MediaQueryEvaluator.h +++ b/WebCore/css/MediaQueryEvaluator.h @@ -49,8 +49,7 @@ class MediaQueryExp; * the device characteristics are not known. This can be used to prune the loading * of stylesheets to only those which are probable to match. */ -class MediaQueryEvaluator -{ +class MediaQueryEvaluator { public: /** Creates evaluator which evaluates only simple media queries * Evaluator returns true for "all", and returns value of \mediaFeatureResult diff --git a/WebCore/css/MediaQueryExp.h b/WebCore/css/MediaQueryExp.h index 3036d04..5ff4af3 100644 --- a/WebCore/css/MediaQueryExp.h +++ b/WebCore/css/MediaQueryExp.h @@ -36,8 +36,7 @@ namespace WebCore { class CSSParserValueList; -class MediaQueryExp -{ +class MediaQueryExp { public: MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* values); ~MediaQueryExp(); @@ -46,7 +45,8 @@ public: CSSValue* value() const { return m_value.get(); } - bool operator==(const MediaQueryExp& other) const { + bool operator==(const MediaQueryExp& other) const + { return (other.m_mediaFeature == m_mediaFeature) && ((!other.m_value && !m_value) || (other.m_value && m_value && other.m_value->cssText() == m_value->cssText())); diff --git a/WebCore/css/RGBColor.cpp b/WebCore/css/RGBColor.cpp new file mode 100644 index 0000000..5c8c104 --- /dev/null +++ b/WebCore/css/RGBColor.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2008, 2009 Google, Inc. All rights reserved. + * Copyright (C) 2009 Apple 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#include "config.h" +#include "RGBColor.h" + +namespace WebCore { + +PassRefPtr<RGBColor> RGBColor::create(unsigned rgbColor) +{ + return adoptRef(new RGBColor(rgbColor)); +} + +PassRefPtr<CSSPrimitiveValue> RGBColor::red() +{ + unsigned value = (m_rgbColor >> 16) & 0xFF; + return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER); +} + +PassRefPtr<CSSPrimitiveValue> RGBColor::green() +{ + unsigned value = (m_rgbColor >> 8) & 0xFF; + return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER); +} + +PassRefPtr<CSSPrimitiveValue> RGBColor::blue() +{ + unsigned value = m_rgbColor & 0xFF; + return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER); +} + +PassRefPtr<CSSPrimitiveValue> RGBColor::alpha() +{ + float value = static_cast<float>((m_rgbColor >> 24) & 0xFF) / 0xFF; + return WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER); +} + +} // namespace WebCore + diff --git a/WebCore/css/RGBColor.h b/WebCore/css/RGBColor.h new file mode 100644 index 0000000..7937a08 --- /dev/null +++ b/WebCore/css/RGBColor.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2006, 2007, 2008, 2009 Google, Inc. All rights reserved. + * Copyright (C) 2009 Apple 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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 RGBColor_h +#define RGBColor_h + +#include "CSSPrimitiveValue.h" +#include "Color.h" +#include <wtf/RefCounted.h> + +namespace WebCore { + + class RGBColor : public RefCounted<RGBColor> { + public: + static PassRefPtr<RGBColor> create(unsigned rgbColor); + + PassRefPtr<CSSPrimitiveValue> red(); + PassRefPtr<CSSPrimitiveValue> green(); + PassRefPtr<CSSPrimitiveValue> blue(); + PassRefPtr<CSSPrimitiveValue> alpha(); + + Color color() const { return Color(m_rgbColor); } + + private: + RGBColor(unsigned rgbColor) + : m_rgbColor(rgbColor) + { + } + + RGBA32 m_rgbColor; + }; + +} // namespace WebCore + +#endif // RGBColor_h diff --git a/WebCore/css/RGBColor.idl b/WebCore/css/RGBColor.idl index f76b6a2..d29f811 100644 --- a/WebCore/css/RGBColor.idl +++ b/WebCore/css/RGBColor.idl @@ -22,9 +22,7 @@ module css { // Introduced in DOM Level 2: interface [ - ObjCCustomImplementation, GenerateConstructor, - PODType=RGBA32, InterfaceUUID=2e3b1501-2cf7-4a4a-bbf7-d8843d1c3be7, ImplementationUUID=cf779953-4898-4800-aa31-6c9e3f4711be ] RGBColor { diff --git a/WebCore/css/ShadowValue.cpp b/WebCore/css/ShadowValue.cpp index 5794405..27be86c 100644 --- a/WebCore/css/ShadowValue.cpp +++ b/WebCore/css/ShadowValue.cpp @@ -2,7 +2,7 @@ * This file is part of the DOM implementation for KDE. * * (C) 1999-2003 Lars Knoll (knoll@kde.org) - * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2004, 2005, 2006, 2009 Apple Computer, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -31,10 +31,14 @@ namespace WebCore { ShadowValue::ShadowValue(PassRefPtr<CSSPrimitiveValue> _x, PassRefPtr<CSSPrimitiveValue> _y, PassRefPtr<CSSPrimitiveValue> _blur, + PassRefPtr<CSSPrimitiveValue> _spread, + PassRefPtr<CSSPrimitiveValue> _style, PassRefPtr<CSSPrimitiveValue> _color) : x(_x) , y(_y) , blur(_blur) + , spread(_spread) + , style(_style) , color(_color) { } @@ -60,6 +64,16 @@ String ShadowValue::cssText() const text += " "; text += blur->cssText(); } + if (spread) { + if (!text.isEmpty()) + text += " "; + text += spread->cssText(); + } + if (style) { + if (!text.isEmpty()) + text += " "; + text += style->cssText(); + } return text; } diff --git a/WebCore/css/ShadowValue.h b/WebCore/css/ShadowValue.h index 179531e..a88a0e7 100644 --- a/WebCore/css/ShadowValue.h +++ b/WebCore/css/ShadowValue.h @@ -1,6 +1,6 @@ /* * (C) 1999-2003 Lars Knoll (knoll@kde.org) - * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -35,9 +35,11 @@ public: static PassRefPtr<ShadowValue> create(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveValue> y, PassRefPtr<CSSPrimitiveValue> blur, + PassRefPtr<CSSPrimitiveValue> spread, + PassRefPtr<CSSPrimitiveValue> style, PassRefPtr<CSSPrimitiveValue> color) { - return adoptRef(new ShadowValue(x, y, blur, color)); + return adoptRef(new ShadowValue(x, y, blur, spread, style, color)); } virtual String cssText() const; @@ -45,12 +47,16 @@ public: RefPtr<CSSPrimitiveValue> x; RefPtr<CSSPrimitiveValue> y; RefPtr<CSSPrimitiveValue> blur; + RefPtr<CSSPrimitiveValue> spread; + RefPtr<CSSPrimitiveValue> style; RefPtr<CSSPrimitiveValue> color; private: ShadowValue(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveValue> y, PassRefPtr<CSSPrimitiveValue> blur, + PassRefPtr<CSSPrimitiveValue> spread, + PassRefPtr<CSSPrimitiveValue> style, PassRefPtr<CSSPrimitiveValue> color); }; diff --git a/WebCore/css/StyleSheet.idl b/WebCore/css/StyleSheet.idl index 3a26f20..e4f4090 100644 --- a/WebCore/css/StyleSheet.idl +++ b/WebCore/css/StyleSheet.idl @@ -23,6 +23,7 @@ module stylesheets { // Introduced in DOM Level 2: interface [ CustomMarkFunction, + CustomToJS, GenerateConstructor, Polymorphic, InterfaceUUID=2bd2db5f-aaab-4422-96a0-e05455313f35, diff --git a/WebCore/css/WebKitCSSMatrix.cpp b/WebCore/css/WebKitCSSMatrix.cpp index 574a01a..aaf5c3d 100644 --- a/WebCore/css/WebKitCSSMatrix.cpp +++ b/WebCore/css/WebKitCSSMatrix.cpp @@ -72,7 +72,7 @@ void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec) // requires style (i.e., param uses 'ems' or 'exs') PassRefPtr<CSSValue> val = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform); TransformOperations operations; - if (!CSSStyleSelector::createTransformOperations(val.get(), 0, operations)) { + if (!CSSStyleSelector::createTransformOperations(val.get(), 0, 0, operations)) { ec = SYNTAX_ERR; return; } diff --git a/WebCore/css/WebKitCSSMatrix.h b/WebCore/css/WebKitCSSMatrix.h index 67ba113..56bf76b 100644 --- a/WebCore/css/WebKitCSSMatrix.h +++ b/WebCore/css/WebKitCSSMatrix.h @@ -149,7 +149,7 @@ protected: WebKitCSSMatrix(); WebKitCSSMatrix(const WebKitCSSMatrix&); WebKitCSSMatrix(const TransformationMatrix&); - WebKitCSSMatrix(const String&, ExceptionCode& ); + WebKitCSSMatrix(const String&, ExceptionCode&); TransformationMatrix m_matrix; }; diff --git a/WebCore/css/html4.css b/WebCore/css/html.css index 59a08eb..6b03390 100644 --- a/WebCore/css/html4.css +++ b/WebCore/css/html.css @@ -297,7 +297,7 @@ button { -webkit-appearance: button; } -input, textarea, keygen, select, button, isindex { +input, textarea, keygen, select, button, isindex, datagrid { margin: 0__qem; font: -webkit-small-control; color: initial; @@ -360,6 +360,8 @@ textarea { resize: auto; cursor: auto; padding: 2px; + white-space: pre-wrap; + word-wrap: break-word; } input::-webkit-input-placeholder, isindex::-webkit-input-placeholder { @@ -421,7 +423,9 @@ input[type="range"]::-webkit-slider-thumb { -webkit-appearance: sliderthumb-horizontal; } -input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, input[type="file"]:disabled::-webkit-file-upload-button, button:disabled, select:disabled, keygen:disabled, optgroup:disabled, option:disabled { +input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, +input[type="file"]:disabled::-webkit-file-upload-button, button:disabled, +select:disabled, keygen:disabled, optgroup:disabled, option:disabled, datagrid:disabled { color: GrayText } @@ -487,6 +491,20 @@ option { font-weight: normal; } +/* datagrid */ + +datagrid { + height: 150px; /* We don't use width:300px in CSS, since we want width:intrinsic and width:min-intrinsic to reset to 300 properly. */ + -webkit-appearance: datagrid; + -webkit-box-sizing: border-box; + -webkit-rtl-ordering: logical; + color: black; + background-color: white; + cursor: default; + border: 1px inset gray; + white-space: initial; +} + /* inline elements */ u, ins { @@ -541,13 +559,7 @@ nobr { /* states */ :focus { -/* ANDROID specific change - * Android does not use the webkit-supplied focus ring, so - * remove the definition for outline to prevent setting or losing - * focus from triggering a dom rebuild. - */ -// outline: auto 5px -webkit-focus-ring-color - outline: none + outline: auto 5px -webkit-focus-ring-color } /* Read-only text fields do not show a focus ring but do still receive focus */ @@ -600,8 +612,4 @@ iframe { border: 2px inset } -img, input[type=image], video, iframe, object, embed, applet { - overflow: hidden; /* Default to overflow:hidden so that border-radius clipping works on the foreground of these elements. */ -} - /* noscript is handled internally, as it depends on settings */ diff --git a/WebCore/css/makeprop.pl b/WebCore/css/makeprop.pl index bc979f9..115969f 100644 --- a/WebCore/css/makeprop.pl +++ b/WebCore/css/makeprop.pl @@ -26,9 +26,9 @@ use warnings; open NAMES, "<CSSPropertyNames.in" || die "Could not find CSSPropertyNames.in"; my @names = (); while (<NAMES>) { - next if (m/#/); - chomp $_; - next if ($_ eq ""); + next if (m/(^#)|(^\s*$)/); + # Input may use a different EOL sequence than $/, so avoid chomp. + $_ =~ s/[\r\n]+$//g; push @names, $_; } close(NAMES); diff --git a/WebCore/css/makevalues.pl b/WebCore/css/makevalues.pl index 5d4e8ac..3f52e64 100644 --- a/WebCore/css/makevalues.pl +++ b/WebCore/css/makevalues.pl @@ -26,9 +26,9 @@ use warnings; open NAMES, "<CSSValueKeywords.in" || die "Could not open CSSValueKeywords.in"; my @names = (); while (<NAMES>) { - next if (m/#/); - chomp $_; - next if ($_ eq ""); + next if (m/(^#)|(^\s*$)/); + # Input may use a different EOL sequence than $/, so avoid chomp. + $_ =~ s/[\r\n]+$//g; push @names, $_; } close(NAMES); diff --git a/WebCore/css/mediaControls.css b/WebCore/css/mediaControls.css index b94abbf..f9694f8 100644 --- a/WebCore/css/mediaControls.css +++ b/WebCore/css/mediaControls.css @@ -30,12 +30,17 @@ audio { } audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { + display: -webkit-box; + -webkit-box-orient: horizontal; + -webkit-box-align: center; + -webkit-user-select: none; position: absolute; bottom: 0; width: 100%; - height: 100%; - -webkit-user-select: none; z-index: 0; + overflow: hidden; + height: 16px; + text-align: right; } video:-webkit-full-page-media::-webkit-media-controls-panel { @@ -44,32 +49,26 @@ video:-webkit-full-page-media::-webkit-media-controls-panel { audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { -webkit-appearance: media-mute-button; - position: absolute; - top: auto; - bottom: 0; - left: 0; - width: 17px; + display: -webkit-box; + width: 16px; height: 16px; } audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { -webkit-appearance: media-play-button; - position: absolute; - top: auto; - bottom: 0; - left: 16px; - width: 17px; + display: -webkit-box; + width: 16px; height: 16px; } audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls-timeline-container { + -webkit-appearance: media-controls-background; + display: -webkit-box; + -webkit-box-orient: horizontal; + -webkit-box-align: center; + -webkit-box-pack: end; + -webkit-box-flex: 1; -webkit-user-select: none; - position: absolute; - padding: 0px 16px 0px 0px; - top: auto; - bottom: 0; - left: 32px; - right: 32px; height: 16px; } @@ -83,35 +82,37 @@ audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-contr audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { -webkit-appearance: media-slider; - position: absolute; - top: auto; - bottom: 0; - left: 0px; - right: 0px; + display: -webkit-box; + -webkit-box-flex: 1; height: 16px; padding: 0px 2px; } audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { -webkit-appearance: media-seek-back-button; - position: absolute; - top: auto; - bottom: 0; - right: 16px; - width: 17px; + display: -webkit-box; + width: 16px; height: 16px; } audio::-webkit-media-controls-seek-forward-button, video::-webkit-media-controls-seek-forward-button { -webkit-appearance: media-seek-forward-button; - position: absolute; - top: auto; - bottom: 0; - right: 0; - width: 17px; + display: -webkit-box; + width: 16px; height: 16px; } audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button { + -webkit-appearance: media-fullscreen-button; + display: -webkit-box; + width: 16px; + height: 16px; +} + +audio::-webkit-media-controls-rewind-button, video::-webkit-media-controls-rewind-button { + display: none; +} + +audio::-webkit-media-controls-return-to-realtime-button, video::-webkit-media-controls-return-to-realtime-button { display: none; } diff --git a/WebCore/css/mediaControlsChromium.css b/WebCore/css/mediaControlsChromium.css index 63eca4b..6fda61c 100644 --- a/WebCore/css/mediaControlsChromium.css +++ b/WebCore/css/mediaControlsChromium.css @@ -26,7 +26,7 @@ /* Chromium default media controls */ audio { - width: 200px; + width: 300px; height: 32px; } @@ -35,12 +35,13 @@ audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { position: absolute; bottom: 0; width: 100%; - height: 100%; + height: 32px; z-index: 0; + background-color: rgba(0, 0, 0, 0.6); } video:-webkit-full-page-media::-webkit-media-controls-panel { - bottom: -16px; + bottom: -32px; } audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { @@ -54,8 +55,6 @@ audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-bu width: 34px; height: 32px; - - background: rgba(123, 0, 0, 0.6); } audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { @@ -63,14 +62,12 @@ audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-bu position: absolute; top: auto; - bottom: 0; - left: 0px; - right: auto; + bottom: 7px; + left: 7px; + right: 6px; - width: 30px; - height: 32px; - - background: rgba(0, 221, 0, 0.6); + width: 18px; + height: 19px; } audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls-timeline-container { @@ -86,7 +83,8 @@ audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls- width: auto; height: 32px; - background: rgba(0, 0, 0, 0.6); + border-left-color: rgba(255, 255, 255, 0.2); + border-right-color: rgba(255, 255, 255, 0.2); } audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display { @@ -105,10 +103,11 @@ audio::-webkit-media-controls-current-time-display, video::-webkit-media-control right: 0px; height: 20px; - width: 48px; + width: 58px; text-align: center; font-family: Arial; + font-size: 16px; font-weight: bold; color: white; } @@ -129,24 +128,29 @@ audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-contr right: 0px; height: 20px; - width: 48px; + width: 58px; text-align: center; font-family: Arial; + font-size: 16px; font-weight: bold; color: white; } audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { - -webkit-appearance: slider-horizontal; + -webkit-appearance: media-slider; position: absolute; top: auto; - bottom: 9px; - left: 0px; - right: 50px; - height: 13px; - - background: rgba(0, 0, 0, 0.6); + bottom: 8px; + left: 6px; + right: 65px; + height: 16px; + + border-color: rgba(255, 255, 255, 0.2); + border-width: 1px; + border-radius: 2px; + background-color: rgba(255, 255, 255, 0.08); + color: rgb(50, 140, 223); } audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { diff --git a/WebCore/css/mediaControlsQT.css b/WebCore/css/mediaControlsQT.css index 918c9bf..5cf48ae 100644 --- a/WebCore/css/mediaControlsQT.css +++ b/WebCore/css/mediaControlsQT.css @@ -22,7 +22,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* alternate media controls */ +/* alternate media controls - Extend mediaControls.css */ audio { width: 200px; @@ -30,104 +30,148 @@ audio { } audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { - -webkit-user-select: none; - position: absolute; - bottom: 0; - width: 100%; - height: 100%; - z-index: 0; + /* In mediaControls.css */ + -webkit-appearance: media-controls-background; + height: 25px; } video:-webkit-full-page-media::-webkit-media-controls-panel { - bottom: -16px; + bottom: -25px; } audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { - -webkit-appearance: media-mute-button; - position: absolute; - top: auto; - bottom: 0; - right: 0; - left: auto; - width: 30px; - height: 25px; + -webkit-box-ordinal-group: 2; /* Before the fullscreen button */ + width: 15px; + height: 14px; + margin-left: 2px; + margin-right: 8px; } audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { - -webkit-appearance: media-play-button; - position: absolute; - top: auto; - bottom: 0; - left: 0px; - width: 30px; - height: 25px; + width: 16px; + height: 16px; + margin-left: 6px; + margin-right: 1px; } audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls-timeline-container { - -webkit-appearance: media-timeline-container; - -webkit-user-select: none; - position: absolute; - top: auto; - bottom: 0; - left: 30px; - right: 30px; - height: 25px; + -webkit-appearance: none; + -webkit-box-orient: horizontal; + -webkit-box-align: center; + -webkit-box-pack: center; + -webkit-box-flex: 1; + text-align: right; + height: auto; } audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display { - -webkit-appearance: media-current-time-display; -webkit-user-select: none; - display: inline-block; - position: absolute; + display: -webkit-box; + -webkit-box-flex: 0; + -webkit-box-pack: center; + -webkit-box-align: center; cursor: default; font: -webkit-small-control; - font-size: .09em; - text-align: center; + font-size: 9px; overflow: hidden; - line-height: 13px; - top: auto; - bottom: 6px; - left: 0px; - height: 13px; width: 45px; + color: white; + text-shadow: black 0px 1px 1px; + + letter-spacing: normal; + word-spacing: normal; + line-height: normal; + text-transform: none; + text-indent: 0; + text-decoration: none; } audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display { - -webkit-appearance: media-time-remaining-display; -webkit-user-select: none; - display: inline-block; - position: absolute; + display: -webkit-box; + -webkit-box-flex: 0; + -webkit-box-pack: center; + -webkit-box-align: center; cursor: default; font: -webkit-small-control; - font-size: .09em; - text-align: center; + font-size: 9px; overflow: hidden; - line-height: 13px; - top: auto; - bottom: 6px; - right: 0px; - height: 13px; width: 45px; + color: white; + text-shadow: black 0px 1px 1px; + + letter-spacing: normal; + word-spacing: normal; + line-height: normal; + text-transform: none; + text-indent: 0; + text-decoration: none; } audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { - -webkit-appearance: media-slider; - position: absolute; - top: auto; - bottom: 6px; - left: 45px; - right: 45px; + display: -webkit-box; + -webkit-box-flex: 1; height: 13px; + padding: 0px; + margin: 0px; + margin-top: 2px; } audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { display: none; + width: 0px; } audio::-webkit-media-controls-seek-forward-button, video::-webkit-media-controls-seek-forward-button { display: none; + width: 0px; } audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button { + width: 16px; + height: 16px; + margin-left: 7px; + margin-right: 7px; + -webkit-box-ordinal-group: 3; /* At the very end */ +} + +audio::-webkit-media-controls-rewind-button, video::-webkit-media-controls-rewind-button { + display: -webkit-box; + -webkit-appearance: media-rewind-button; + width: 18px; + height: 18px; + margin-bottom: 1px; + margin-left: 6px; + margin-right: 2px; +} + +audio::-webkit-media-controls-return-to-realtime-button, video::-webkit-media-controls-return-to-realtime-button { display: none; + -webkit-appearance: media-return-to-realtime-button; + width: 16px; + height: 11px; + margin-left: 6px; + margin-right: 2px; +} + +audio::-webkit-media-controls-status-display, video::-webkit-media-controls-status-display { + -webkit-user-select: none; + cursor: default; + display: -webkit-box; + -webkit-box-flex: 1; + font: -webkit-small-control; + color: white; + font-size: 10px; + line-height: 13px; + overflow: hidden; + text-shadow: black 0px 1px 1px; + margin-left: 10px; + margin-right: 10px; + + letter-spacing: normal; + word-spacing: normal; + line-height: normal; + text-transform: none; + text-indent: 0; + text-decoration: none; } diff --git a/WebCore/css/themeWin.css b/WebCore/css/themeWin.css index 421fed0..a0170ac 100644 --- a/WebCore/css/themeWin.css +++ b/WebCore/css/themeWin.css @@ -29,7 +29,7 @@ */ /* These styles override the default styling for HTML elements as defined in - WebCore/css/html4.css. So far we have used this file exclusively for + WebCore/css/html.css. So far we have used this file exclusively for making our form elements match Firefox's. */ input:not([type]), diff --git a/WebCore/css/tokenizer.flex b/WebCore/css/tokenizer.flex index e800bae..1569ee2 100644 --- a/WebCore/css/tokenizer.flex +++ b/WebCore/css/tokenizer.flex @@ -73,6 +73,7 @@ nth (-?[0-9]*n[\+-][0-9]+)|(-?[0-9]*n) "!"{w}"important" {yyTok = IMPORTANT_SYM; return yyTok;} {num}em {yyTok = EMS; return yyTok;} +{num}rem {yyTok = REMS; return yyTok;} {num}__qem {yyTok = QEMS; return yyTok;} /* quirky ems */ {num}ex {yyTok = EXS; return yyTok;} {num}px {yyTok = PXS; return yyTok;} diff --git a/WebCore/css/view-source.css b/WebCore/css/view-source.css index 20722ee..f898565 100644 --- a/WebCore/css/view-source.css +++ b/WebCore/css/view-source.css @@ -33,8 +33,8 @@ table { white-space: pre-wrap !important; margin: 0; word-break: break-word; - font-size: 10px; - font-family: Monaco, Lucida Console, monospace; + font-size: initial; + font-family: monospace; } td { diff --git a/WebCore/css/wml.css b/WebCore/css/wml.css index 9c938dd..54e5a97 100644 --- a/WebCore/css/wml.css +++ b/WebCore/css/wml.css @@ -223,6 +223,13 @@ small { font-size: smaller } +pre { + display: block; + font-family: monospace; + white-space: pre; + margin: 1__qem 0 +} + /* states */ :focus { |