diff options
author | Steve Block <steveblock@google.com> | 2009-11-05 09:23:40 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2009-11-10 22:41:12 +0000 |
commit | cac0f67c402d107cdb10971b95719e2ff9c7c76b (patch) | |
tree | d182c7f87211c6f201a5f038e332336493ebdbe7 /WebCore/css | |
parent | 4b2ef0f288e7c6c4602f621b7a0e9feed304b70e (diff) | |
download | external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.zip external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.gz external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.bz2 |
Merge webkit.org at r50258 : Initial merge by git.
Change-Id: I1a9e1dc4ed654b69174ad52a4f031a07240f37b0
Diffstat (limited to 'WebCore/css')
-rw-r--r-- | WebCore/css/CSSComputedStyleDeclaration.cpp | 52 | ||||
-rw-r--r-- | WebCore/css/CSSComputedStyleDeclaration.h | 3 | ||||
-rw-r--r-- | WebCore/css/CSSGrammar.y | 4 | ||||
-rw-r--r-- | WebCore/css/CSSParser.cpp | 60 | ||||
-rw-r--r-- | WebCore/css/CSSParser.h | 2 | ||||
-rw-r--r-- | WebCore/css/CSSParserValues.h | 4 | ||||
-rw-r--r-- | WebCore/css/CSSPrimitiveValue.cpp | 105 | ||||
-rw-r--r-- | WebCore/css/CSSPrimitiveValueMappings.h | 5 | ||||
-rw-r--r-- | WebCore/css/CSSProperty.h | 2 | ||||
-rw-r--r-- | WebCore/css/CSSPropertyNames.in | 4 | ||||
-rw-r--r-- | WebCore/css/CSSStyleSelector.cpp | 1 | ||||
-rw-r--r-- | WebCore/css/SVGCSSComputedStyleDeclaration.cpp | 2 | ||||
-rw-r--r-- | WebCore/css/SVGCSSParser.cpp | 5 | ||||
-rw-r--r-- | WebCore/css/SVGCSSPropertyNames.in | 2 | ||||
-rw-r--r-- | WebCore/css/SVGCSSStyleSelector.cpp | 30 | ||||
-rw-r--r-- | WebCore/css/makevalues.pl | 2 |
16 files changed, 213 insertions, 70 deletions
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp index 34b93c1..65a6ecf 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -161,6 +161,7 @@ static const int computedProperties[] = { CSSPropertyWebkitBackgroundClip, CSSPropertyWebkitBackgroundComposite, CSSPropertyWebkitBackgroundOrigin, + CSSPropertyWebkitBackgroundSize, CSSPropertyWebkitBorderFit, CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyWebkitBorderImage, @@ -264,7 +265,8 @@ static const int computedProperties[] = { CSSPropertyTextAnchor, CSSPropertyWritingMode, CSSPropertyGlyphOrientationHorizontal, - CSSPropertyGlyphOrientationVertical + CSSPropertyGlyphOrientationVertical, + CSSPropertyWebkitShadow #endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR , @@ -274,24 +276,6 @@ static const int computedProperties[] = { const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]); -static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID) -{ - if (!shadow) - return CSSPrimitiveValue::createIdentifier(CSSValueNone); - - RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); - for (const ShadowData* s = shadow; s; s = s->next) { - 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(), spread.release(), style.release(), color.release())); - } - return list.release(); -} - static int valueForRepeatRule(int rule) { switch (rule) { @@ -579,6 +563,26 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringK return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX); } +PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, int id) const +{ + if (!shadow) + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + + CSSPropertyID propertyID = static_cast<CSSPropertyID>(id); + + RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); + for (const ShadowData* s = shadow; s; s = s->next) { + 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(), spread.release(), style.release(), color.release())); + } + return list.release(); +} + PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const { return getPropertyCSSValue(propertyID, UpdateLayout); @@ -688,7 +692,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper if (style->backgroundImage()) return style->backgroundImage()->cssValue(); return CSSPrimitiveValue::createIdentifier(CSSValueNone); - case CSSPropertyBackgroundSize: { + case CSSPropertyBackgroundSize: + case CSSPropertyWebkitBackgroundSize: { EFillSizeType size = style->backgroundSizeType(); if (size == Contain) return CSSPrimitiveValue::createIdentifier(CSSValueContain); @@ -789,7 +794,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyWebkitBoxReflect: return valueForReflection(style->boxReflect()); case CSSPropertyWebkitBoxShadow: - return valueForShadow(style->boxShadow(), static_cast<CSSPropertyID>(propertyID)); + return valueForShadow(style->boxShadow(), propertyID); case CSSPropertyCaptionSide: return CSSPrimitiveValue::create(style->captionSide()); case CSSPropertyClear: @@ -922,7 +927,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper // for how high to be in pixels does include things like minimum font size and the zoom factor. // On the other hand, since font-size doesn't include the zoom factor, we really can't do // that here either. - return CSSPrimitiveValue::create(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX); + // The line height returned is rounded to the nearest integer. + return CSSPrimitiveValue::create(length.calcMinValue(style->fontDescription().specifiedSize(), true), CSSPrimitiveValue::CSS_PX); return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::CSS_PX); } case CSSPropertyListStyleImage: @@ -1084,7 +1090,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyTextIndent: return CSSPrimitiveValue::create(style->textIndent()); case CSSPropertyTextShadow: - return valueForShadow(style->textShadow(), static_cast<CSSPropertyID>(propertyID)); + return valueForShadow(style->textShadow(), propertyID); case CSSPropertyTextRendering: return CSSPrimitiveValue::create(style->fontDescription().textRenderingMode()); case CSSPropertyTextOverflow: diff --git a/WebCore/css/CSSComputedStyleDeclaration.h b/WebCore/css/CSSComputedStyleDeclaration.h index c1f34c3..842a995 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.h +++ b/WebCore/css/CSSComputedStyleDeclaration.h @@ -27,6 +27,7 @@ namespace WebCore { class CSSMutableStyleDeclaration; +class ShadowData; enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true }; @@ -66,6 +67,8 @@ private: virtual String removeProperty(int propertyID, ExceptionCode&); virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&); + PassRefPtr<CSSValue> valueForShadow(const ShadowData*, int) const; + RefPtr<Node> m_node; }; diff --git a/WebCore/css/CSSGrammar.y b/WebCore/css/CSSGrammar.y index 1c1f7b4..0530e91 100644 --- a/WebCore/css/CSSGrammar.y +++ b/WebCore/css/CSSGrammar.y @@ -97,7 +97,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser) %} -%expect 50 +%expect 51 %nonassoc LOWEST_PREC @@ -268,7 +268,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser) %% stylesheet: - maybe_charset maybe_sgml import_list variables_list namespace_list rule_list + maybe_space maybe_charset maybe_sgml import_list variables_list namespace_list rule_list | webkit_rule maybe_space | webkit_decls maybe_space | webkit_value maybe_space diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index b7155b3..0da1b85 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -457,9 +457,6 @@ Document* CSSParser::document() const bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict) { - if (unitflags & FNonNeg && value->fValue < 0) - return false; - bool b = false; switch (value->unit) { case CSSPrimitiveValue::CSS_NUMBER: @@ -503,6 +500,8 @@ bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict) default: break; } + if (b && unitflags & FNonNeg && value->fValue < 0) + b = false; return b; } @@ -926,6 +925,7 @@ bool CSSParser::parseValue(int propId, bool important) case CSSPropertyBackgroundPositionX: case CSSPropertyBackgroundPositionY: case CSSPropertyBackgroundSize: + case CSSPropertyWebkitBackgroundSize: case CSSPropertyBackgroundRepeat: case CSSPropertyBackgroundRepeatX: case CSSPropertyBackgroundRepeatY: @@ -946,6 +946,13 @@ bool CSSParser::parseValue(int propId, bool important) int propId1, propId2; bool result = false; if (parseFillProperty(propId, propId1, propId2, val1, val2)) { + OwnPtr<ShorthandScope> shorthandScope; + if (propId == CSSPropertyBackgroundPosition || + propId == CSSPropertyBackgroundRepeat || + propId == CSSPropertyWebkitMaskPosition || + propId == CSSPropertyWebkitMaskRepeat) { + shorthandScope.set(new ShorthandScope(this, propId)); + } addProperty(propId1, val1.release(), important); if (val2) addProperty(propId2, val2.release(), important); @@ -1780,6 +1787,15 @@ void CSSParser::addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval) lval = rval; } +static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr<CSSValue>& cssValue) +{ + if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddingBox || parserValue->id == CSSValueWebkitText) { + cssValue = CSSPrimitiveValue::createIdentifier(parserValue->id); + return true; + } + return false; +} + const int cMaxFillProperties = 9; bool CSSParser::parseFillShorthand(int propId, const int* properties, int numProperties, bool important) @@ -1831,6 +1847,7 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro RefPtr<CSSValue> val1; RefPtr<CSSValue> val2; int propId1, propId2; + CSSParserValue* parserValue = m_valueList->current(); if (parseFillProperty(properties[i], propId1, propId2, val1, val2)) { parsedProperty[i] = found = true; addFillValue(values[i], val1.release()); @@ -1840,7 +1857,7 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro addFillValue(repeatYValue, 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)) + if (parseBackgroundClip(parserValue, val1)) 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. @@ -2373,7 +2390,7 @@ void CSSParser::parseFillRepeat(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& valu } } -PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma) +PassRefPtr<CSSValue> CSSParser::parseFillSize(int propId, bool& allowComma) { allowComma = true; CSSParserValue* value = m_valueList->current(); @@ -2382,7 +2399,7 @@ PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma) return CSSPrimitiveValue::createIdentifier(value->id); RefPtr<CSSPrimitiveValue> parsedValue1; - + if (value->id == CSSValueAuto) parsedValue1 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN); else { @@ -2390,8 +2407,9 @@ PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma) return 0; parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit); } - - RefPtr<CSSPrimitiveValue> parsedValue2 = parsedValue1; + + CSSPropertyID property = static_cast<CSSPropertyID>(propId); + RefPtr<CSSPrimitiveValue> parsedValue2; if ((value = m_valueList->next())) { if (value->id == CSSValueAuto) parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN); @@ -2403,7 +2421,13 @@ PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma) parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit); } } - + if (!parsedValue2) { + if (property == CSSPropertyWebkitBackgroundSize || property == CSSPropertyWebkitMaskSize) + parsedValue2 = parsedValue1; + else + parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN); + } + return CSSPrimitiveValue::create(Pair::create(parsedValue1.release(), parsedValue2.release())); } @@ -2479,10 +2503,8 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, } break; case CSSPropertyBackgroundClip: - if (val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueWebkitText) { - currValue = CSSPrimitiveValue::createIdentifier(val->id); + if (parseBackgroundClip(val, currValue)) m_valueList->next(); - } break; case CSSPropertyBackgroundOrigin: if (val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueContentBox) { @@ -2524,8 +2546,9 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, // parseFillRepeat advances the m_valueList pointer break; case CSSPropertyBackgroundSize: + case CSSPropertyWebkitBackgroundSize: case CSSPropertyWebkitMaskSize: { - currValue = parseFillSize(allowComma); + currValue = parseFillSize(propId, allowComma); if (currValue) m_valueList->next(); break; @@ -3790,7 +3813,11 @@ bool CSSParser::parseShadow(int propId, bool important) // Other operators aren't legal or we aren't done with the current shadow // value. Treat as invalid. return false; - +#if ENABLE(SVG) + // -webkit-shadow does not support multiple values. + if (static_cast<CSSPropertyID>(propId) == CSSPropertyWebkitShadow) + return false; +#endif // The value is good. Commit it. context.commitValue(); } else if (validUnit(val, FLength, true)) { @@ -5242,11 +5269,6 @@ static int cssPropertyID(const UChar* propertyName, unsigned length) const char* const opacity = "opacity"; name = opacity; length = strlen(opacity); - } else if (strcmp(buffer, "-webkit-background-size") == 0) { - // CSS Backgrounds/Borders. -webkit-background-size worked in Safari 4 and earlier. - const char* const backgroundSize = "background-size"; - name = backgroundSize; - length = strlen(backgroundSize); } 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. diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h index 1a156da..6d1bb32 100644 --- a/WebCore/css/CSSParser.h +++ b/WebCore/css/CSSParser.h @@ -83,7 +83,7 @@ namespace WebCore { PassRefPtr<CSSValue> parseFillPositionXY(bool& xFound, bool& yFound); void parseFillPosition(RefPtr<CSSValue>&, RefPtr<CSSValue>&); void parseFillRepeat(RefPtr<CSSValue>&, RefPtr<CSSValue>&); - PassRefPtr<CSSValue> parseFillSize(bool &allowComma); + PassRefPtr<CSSValue> parseFillSize(int propId, bool &allowComma); bool parseFillProperty(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parseFillShorthand(int propId, const int* properties, int numProperties, bool important); diff --git a/WebCore/css/CSSParserValues.h b/WebCore/css/CSSParserValues.h index 24bd9b7..1e9767a 100644 --- a/WebCore/css/CSSParserValues.h +++ b/WebCore/css/CSSParserValues.h @@ -60,7 +60,7 @@ struct CSSParserValue { PassRefPtr<CSSValue> createCSSValue(); }; -class CSSParserValueList { +class CSSParserValueList : public FastAllocBase { public: CSSParserValueList() : m_current(0) @@ -88,7 +88,7 @@ private: unsigned m_variablesCount; }; -struct CSSParserFunction { +struct CSSParserFunction : FastAllocBase { CSSParserString name; CSSParserValueList* args; diff --git a/WebCore/css/CSSPrimitiveValue.cpp b/WebCore/css/CSSPrimitiveValue.cpp index 1f2c9ca..d2286bb 100644 --- a/WebCore/css/CSSPrimitiveValue.cpp +++ b/WebCore/css/CSSPrimitiveValue.cpp @@ -34,6 +34,8 @@ #include "Rect.h" #include "RenderStyle.h" #include <wtf/ASCIICType.h> +#include <wtf/MathExtras.h> +#include <wtf/StringExtras.h> #include <wtf/StdLibExtras.h> #if ENABLE(DASHBOARD_SUPPORT) @@ -684,6 +686,71 @@ int CSSPrimitiveValue::getIdent() return m_value.ident; } +static void appendCSSDouble(Vector<UChar>& vector, double value) +{ + // From the CSS specification section titled "Integers and real numbers", + // real numbers are only formatted as [sign] [digits] "." [digits]. + // This differs from printf-style formatting in that exponents (e.g. 1.3e06) + // are not allowed. Since NaN/inf are also not valid CSS values this + // function doesn't handle them. + + // For compatibility with what was returned by older versions of + // WebKit, we target 6 digits of precision. + const int digitsAfterDecimalPoint = 6; + long long rounded = llround(fabs(value) * 1000000.0); + if (rounded == 0) { + vector.append('0'); + return; + } + + char buf[24]; + int length = snprintf(buf, sizeof(buf), "%lld", rounded); + int decimalPoint = length - digitsAfterDecimalPoint; + + // We are matching printf("%g")'s behavior and must trim trailing zeros, + // regardless of whether they're significant. + while (length > 0 && length > decimalPoint && buf[length - 1] == '0') + length--; + + // Reserve an estimate of space for the number of digits we anticipate + // along with a minus sign/initial zero/decimal point. + vector.reserveCapacity(vector.size() + 3 + length); + + if (value < 0) + vector.append('-'); + + if (decimalPoint <= 0) { + // Only digits after the decimal point. + vector.append('0'); + vector.append('.'); + for (int i = decimalPoint; i < 0; i++) + vector.append('0'); + for (int i = 0; i < length; i++) + vector.append(buf[i]); + } else if (length <= decimalPoint) { + // Only digits before the decimal point. + for (int i = 0; i < length; i++) + vector.append(buf[i]); + } else { + // Digits before and after the decimal point. + for (int i = 0; i < decimalPoint; i++) + vector.append(buf[i]); + vector.append('.'); + for (int i = decimalPoint; i < length; i++) + vector.append(buf[i]); + } +} + +static String formatWithUnits(double value, const char* units) +{ + Vector<UChar> result; + appendCSSDouble(result, value); + result.reserveCapacity(result.size() + strlen(units)); + for (int i = 0; units[i]; i++) + result.append(units[i]); + return String::adopt(result); +} + String CSSPrimitiveValue::cssText() const { // FIXME: return the original value instead of a generated one (e.g. color @@ -695,61 +762,61 @@ String CSSPrimitiveValue::cssText() const break; case CSS_NUMBER: case CSS_PARSER_INTEGER: - text = String::number(m_value.num); + text = formatWithUnits(m_value.num, ""); break; case CSS_PERCENTAGE: - text = String::format("%.6lg%%", m_value.num); + text = formatWithUnits(m_value.num, "%"); break; case CSS_EMS: - text = String::format("%.6lgem", m_value.num); + text = formatWithUnits(m_value.num, "em"); break; case CSS_EXS: - text = String::format("%.6lgex", m_value.num); + text = formatWithUnits(m_value.num, "ex"); break; case CSS_REMS: - text = String::format("%.6lgrem", m_value.num); + text = formatWithUnits(m_value.num, "rem"); break; case CSS_PX: - text = String::format("%.6lgpx", m_value.num); + text = formatWithUnits(m_value.num, "px"); break; case CSS_CM: - text = String::format("%.6lgcm", m_value.num); + text = formatWithUnits(m_value.num, "cm"); break; case CSS_MM: - text = String::format("%.6lgmm", m_value.num); + text = formatWithUnits(m_value.num, "mm"); break; case CSS_IN: - text = String::format("%.6lgin", m_value.num); + text = formatWithUnits(m_value.num, "in"); break; case CSS_PT: - text = String::format("%.6lgpt", m_value.num); + text = formatWithUnits(m_value.num, "pt"); break; case CSS_PC: - text = String::format("%.6lgpc", m_value.num); + text = formatWithUnits(m_value.num, "pc"); break; case CSS_DEG: - text = String::format("%.6lgdeg", m_value.num); + text = formatWithUnits(m_value.num, "deg"); break; case CSS_RAD: - text = String::format("%.6lgrad", m_value.num); + text = formatWithUnits(m_value.num, "rad"); break; case CSS_GRAD: - text = String::format("%.6lggrad", m_value.num); + text = formatWithUnits(m_value.num, "grad"); break; case CSS_MS: - text = String::format("%.6lgms", m_value.num); + text = formatWithUnits(m_value.num, "ms"); break; case CSS_S: - text = String::format("%.6lgs", m_value.num); + text = formatWithUnits(m_value.num, "s"); break; case CSS_HZ: - text = String::format("%.6lghz", m_value.num); + text = formatWithUnits(m_value.num, "hz"); break; case CSS_KHZ: - text = String::format("%.6lgkhz", m_value.num); + text = formatWithUnits(m_value.num, "khz"); break; case CSS_TURN: - text = String::format("%.6lgturn", m_value.num); + text = formatWithUnits(m_value.num, "turn"); break; case CSS_DIMENSION: // FIXME diff --git a/WebCore/css/CSSPrimitiveValueMappings.h b/WebCore/css/CSSPrimitiveValueMappings.h index 3616aa5..6f89df9 100644 --- a/WebCore/css/CSSPrimitiveValueMappings.h +++ b/WebCore/css/CSSPrimitiveValueMappings.h @@ -200,11 +200,11 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e) case ListboxPart: m_value.ident = CSSValueListbox; break; -#if ENABLE(DATALIST) case ListButtonPart: +#if ENABLE(DATALIST) m_value.ident = CSSValueListButton; - break; #endif + break; case ListItemPart: m_value.ident = CSSValueListitem; break; @@ -378,6 +378,7 @@ template<> inline CSSPrimitiveValue::operator EFillBox() const case CSSValueContentBox: return ContentFillBox; case CSSValueText: + case CSSValueWebkitText: return TextFillBox; default: ASSERT_NOT_REACHED(); diff --git a/WebCore/css/CSSProperty.h b/WebCore/css/CSSProperty.h index 7af8348..b5635d0 100644 --- a/WebCore/css/CSSProperty.h +++ b/WebCore/css/CSSProperty.h @@ -29,7 +29,7 @@ namespace WebCore { -class CSSProperty { +class CSSProperty : public FastAllocBase { public: CSSProperty(int propID, PassRefPtr<CSSValue> value, bool important = false, int shorthandID = 0, bool implicit = false) : m_id(propID) diff --git a/WebCore/css/CSSPropertyNames.in b/WebCore/css/CSSPropertyNames.in index 7bed755..dff3a2b 100644 --- a/WebCore/css/CSSPropertyNames.in +++ b/WebCore/css/CSSPropertyNames.in @@ -160,6 +160,10 @@ zoom -webkit-background-clip -webkit-background-composite -webkit-background-origin +# -webkit-background-size differs from background-size only in the interpretation of +# a single value: -webkit-background-size: l; is equivalent to background-size: l l; +# whereas background-size: l; is equivalent to background-size: l auto; +-webkit-background-size -webkit-binding -webkit-border-fit -webkit-border-horizontal-spacing diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp index 69c5598..3276964 100644 --- a/WebCore/css/CSSStyleSelector.cpp +++ b/WebCore/css/CSSStyleSelector.cpp @@ -2961,6 +2961,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) HANDLE_BACKGROUND_VALUE(origin, Origin, value) return; case CSSPropertyBackgroundSize: + case CSSPropertyWebkitBackgroundSize: HANDLE_BACKGROUND_VALUE(size, Size, value) return; case CSSPropertyWebkitMaskAttachment: diff --git a/WebCore/css/SVGCSSComputedStyleDeclaration.cpp b/WebCore/css/SVGCSSComputedStyleDeclaration.cpp index e8492d4..1f19983 100644 --- a/WebCore/css/SVGCSSComputedStyleDeclaration.cpp +++ b/WebCore/css/SVGCSSComputedStyleDeclaration.cpp @@ -166,6 +166,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro return 0; } + case CSSPropertyWebkitShadow: + return valueForShadow(svgStyle->shadow(), propertyID); case CSSPropertyMarker: case CSSPropertyEnableBackground: case CSSPropertyColorProfile: diff --git a/WebCore/css/SVGCSSParser.cpp b/WebCore/css/SVGCSSParser.cpp index 0ae9fbc..8730e49 100644 --- a/WebCore/css/SVGCSSParser.cpp +++ b/WebCore/css/SVGCSSParser.cpp @@ -257,6 +257,11 @@ bool CSSParser::parseSVGValue(int propId, bool important) m_valueList->next(); } break; + case CSSPropertyWebkitShadow: + if (id == CSSValueNone) + valid_primitive = true; + else + return parseShadow(propId, important); /* shorthand properties */ case CSSPropertyMarker: diff --git a/WebCore/css/SVGCSSPropertyNames.in b/WebCore/css/SVGCSSPropertyNames.in index e400ffe..809eabe 100644 --- a/WebCore/css/SVGCSSPropertyNames.in +++ b/WebCore/css/SVGCSSPropertyNames.in @@ -46,3 +46,5 @@ glyph-orientation-vertical kerning text-anchor writing-mode + +-webkit-shadow diff --git a/WebCore/css/SVGCSSStyleSelector.cpp b/WebCore/css/SVGCSSStyleSelector.cpp index b81b4f2..7e4483f 100644 --- a/WebCore/css/SVGCSSStyleSelector.cpp +++ b/WebCore/css/SVGCSSStyleSelector.cpp @@ -37,6 +37,7 @@ #include "CSSPropertyNames.h" #include "CSSValueList.h" #include "Document.h" +#include "ShadowValue.h" #include "SVGColor.h" #include "SVGNames.h" #include "SVGPaint.h" @@ -526,6 +527,35 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) // Silently ignoring this property for now // http://bugs.webkit.org/show_bug.cgi?id=6022 break; + case CSSPropertyWebkitShadow: { + if (isInherit) + return svgstyle->setShadow(m_parentStyle->svgStyle()->shadow() ? new ShadowData(*m_parentStyle->svgStyle()->shadow()) : 0); + if (isInitial || primitiveValue) // initial | none + return svgstyle->setShadow(0); + + if (!value->isValueList()) + return; + + float zoomFactor = m_style->effectiveZoom(); + + CSSValueList *list = static_cast<CSSValueList*>(value); + ASSERT(list->length() == 1); + ShadowValue* item = static_cast<ShadowValue*>(list->itemWithoutBoundsCheck(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; + Color color; + if (item->color) + color = getColorFromPrimitiveValue(item->color.get()); + + // -webkit-shadow does should not have a spread or style + ASSERT(!item->spread); + ASSERT(!item->style); + + ShadowData* shadowData = new ShadowData(x, y, blur, 0, Normal, color.isValid() ? color : Color::transparent); + svgstyle->setShadow(shadowData); + return; + } default: // If you crash here, it's because you added a css property and are not handling it // in either this switch statement or the one in CSSStyleSelector::applyProperty diff --git a/WebCore/css/makevalues.pl b/WebCore/css/makevalues.pl index 3f52e64..e49981d 100644 --- a/WebCore/css/makevalues.pl +++ b/WebCore/css/makevalues.pl @@ -86,7 +86,7 @@ const char* getValueName(unsigned short id); EOF close HEADER; -system("gperf -L ANSI-C -E -C -n -o -t --key-positions=\"*\" -NfindValue -Hhash_val -Wwordlist_value -D CSSValueKeywords.gperf > CSSValueKeywords.c"); +system("gperf -L ANSI-C -E -C -n -o -t --key-positions=\"*\" -NfindValue -Hhash_val -Wwordlist_value -D CSSValueKeywords.gperf > CSSValueKeywords.c") == 0 || die "calling gperf failed: $?"; open C, ">>CSSValueKeywords.c" || die "Could not open CSSValueKeywords.c for writing"; print C "static const char * const valueList[] = {\n"; |