diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
commit | 1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch) | |
tree | 4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/css/CSSComputedStyleDeclaration.cpp | |
parent | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff) | |
download | external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/css/CSSComputedStyleDeclaration.cpp')
-rw-r--r-- | WebCore/css/CSSComputedStyleDeclaration.cpp | 1532 |
1 files changed, 901 insertions, 631 deletions
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp index a92301f..83d662a 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -1,8 +1,8 @@ -/** - * +/* * Copyright (C) 2004 Zack Rusin <zack@kde.org> - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> + * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -23,205 +23,234 @@ #include "config.h" #include "CSSComputedStyleDeclaration.h" +#include "CSSBorderImageValue.h" #include "CSSMutableStyleDeclaration.h" #include "CSSPrimitiveValue.h" #include "CSSPrimitiveValueMappings.h" #include "CSSPropertyNames.h" +#include "CSSReflectValue.h" +#include "CSSTimingFunctionValue.h" #include "CSSValueList.h" #include "CachedImage.h" -#include "DashboardRegion.h" #include "Document.h" #include "ExceptionCode.h" #include "Pair.h" +#include "Rect.h" #include "RenderObject.h" #include "ShadowValue.h" #ifdef ANDROID_LAYOUT #include "Frame.h" #include "Settings.h" #endif +#include "WebKitCSSTransformValue.h" + +#if ENABLE(DASHBOARD_SUPPORT) +#include "DashboardRegion.h" +#endif namespace WebCore { // List of all properties we know how to compute, omitting shorthands. static const int computedProperties[] = { - CSS_PROP_BACKGROUND_ATTACHMENT, - CSS_PROP_BACKGROUND_COLOR, - CSS_PROP_BACKGROUND_IMAGE, + CSSPropertyBackgroundAttachment, + CSSPropertyBackgroundColor, + CSSPropertyBackgroundImage, // more specific background-position-x/y are non-standard - CSS_PROP_BACKGROUND_POSITION, - CSS_PROP_BACKGROUND_REPEAT, - CSS_PROP_BORDER_BOTTOM_COLOR, - CSS_PROP_BORDER_BOTTOM_STYLE, - CSS_PROP_BORDER_BOTTOM_WIDTH, - CSS_PROP_BORDER_COLLAPSE, - CSS_PROP_BORDER_LEFT_COLOR, - CSS_PROP_BORDER_LEFT_STYLE, - CSS_PROP_BORDER_LEFT_WIDTH, - CSS_PROP_BORDER_RIGHT_COLOR, - CSS_PROP_BORDER_RIGHT_STYLE, - CSS_PROP_BORDER_RIGHT_WIDTH, - CSS_PROP_BORDER_TOP_COLOR, - CSS_PROP_BORDER_TOP_STYLE, - CSS_PROP_BORDER_TOP_WIDTH, - CSS_PROP_BOTTOM, - CSS_PROP_CAPTION_SIDE, - CSS_PROP_CLEAR, - CSS_PROP_COLOR, - CSS_PROP_CURSOR, - CSS_PROP_DIRECTION, - CSS_PROP_DISPLAY, - CSS_PROP_EMPTY_CELLS, - CSS_PROP_FLOAT, - CSS_PROP_FONT_FAMILY, - CSS_PROP_FONT_SIZE, - CSS_PROP_FONT_STYLE, - CSS_PROP_FONT_VARIANT, - CSS_PROP_FONT_WEIGHT, - CSS_PROP_HEIGHT, - CSS_PROP_LEFT, - CSS_PROP_LETTER_SPACING, - CSS_PROP_LINE_HEIGHT, - CSS_PROP_LIST_STYLE_IMAGE, - CSS_PROP_LIST_STYLE_POSITION, - CSS_PROP_LIST_STYLE_TYPE, - CSS_PROP_MARGIN_BOTTOM, - CSS_PROP_MARGIN_LEFT, - CSS_PROP_MARGIN_RIGHT, - CSS_PROP_MARGIN_TOP, - CSS_PROP_MAX_HEIGHT, - CSS_PROP_MAX_WIDTH, - CSS_PROP_MIN_HEIGHT, - CSS_PROP_MIN_WIDTH, - CSS_PROP_OPACITY, - CSS_PROP_ORPHANS, - CSS_PROP_OUTLINE_COLOR, - CSS_PROP_OUTLINE_STYLE, - CSS_PROP_OUTLINE_WIDTH, - CSS_PROP_OVERFLOW_X, - CSS_PROP_OVERFLOW_Y, - CSS_PROP_PADDING_BOTTOM, - CSS_PROP_PADDING_LEFT, - CSS_PROP_PADDING_RIGHT, - CSS_PROP_PADDING_TOP, - CSS_PROP_PAGE_BREAK_AFTER, - CSS_PROP_PAGE_BREAK_BEFORE, - CSS_PROP_PAGE_BREAK_INSIDE, - CSS_PROP_POSITION, - CSS_PROP_RESIZE, - CSS_PROP_RIGHT, - CSS_PROP_TABLE_LAYOUT, - CSS_PROP_TEXT_ALIGN, - CSS_PROP_TEXT_DECORATION, - CSS_PROP_TEXT_INDENT, - CSS_PROP_TEXT_SHADOW, - CSS_PROP_TEXT_TRANSFORM, - CSS_PROP_TOP, - CSS_PROP_UNICODE_BIDI, - CSS_PROP_VERTICAL_ALIGN, - CSS_PROP_VISIBILITY, - CSS_PROP_WHITE_SPACE, - CSS_PROP_WIDOWS, - CSS_PROP_WIDTH, - CSS_PROP_WORD_SPACING, - CSS_PROP_WORD_WRAP, - CSS_PROP_Z_INDEX, - - CSS_PROP__WEBKIT_APPEARANCE, - CSS_PROP__WEBKIT_BACKGROUND_CLIP, - CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE, - CSS_PROP__WEBKIT_BACKGROUND_ORIGIN, - CSS_PROP__WEBKIT_BACKGROUND_SIZE, - CSS_PROP__WEBKIT_BORDER_FIT, - CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING, - CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING, - CSS_PROP__WEBKIT_BOX_ALIGN, - CSS_PROP__WEBKIT_BOX_DIRECTION, - CSS_PROP__WEBKIT_BOX_FLEX, - CSS_PROP__WEBKIT_BOX_FLEX_GROUP, - CSS_PROP__WEBKIT_BOX_LINES, - CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP, - CSS_PROP__WEBKIT_BOX_ORIENT, - CSS_PROP__WEBKIT_BOX_PACK, - CSS_PROP__WEBKIT_BOX_SHADOW, - CSS_PROP__WEBKIT_BOX_SIZING, - CSS_PROP__WEBKIT_COLUMN_BREAK_AFTER, - CSS_PROP__WEBKIT_COLUMN_BREAK_BEFORE, - CSS_PROP__WEBKIT_COLUMN_BREAK_INSIDE, - CSS_PROP__WEBKIT_COLUMN_COUNT, - CSS_PROP__WEBKIT_COLUMN_GAP, - CSS_PROP__WEBKIT_COLUMN_RULE_COLOR, - CSS_PROP__WEBKIT_COLUMN_RULE_STYLE, - CSS_PROP__WEBKIT_COLUMN_RULE_WIDTH, - CSS_PROP__WEBKIT_COLUMN_WIDTH, - CSS_PROP__WEBKIT_HIGHLIGHT, - CSS_PROP__WEBKIT_LINE_BREAK, - CSS_PROP__WEBKIT_LINE_CLAMP, - CSS_PROP__WEBKIT_MARGIN_BOTTOM_COLLAPSE, - CSS_PROP__WEBKIT_MARGIN_TOP_COLLAPSE, - CSS_PROP__WEBKIT_MARQUEE_DIRECTION, - CSS_PROP__WEBKIT_MARQUEE_INCREMENT, - CSS_PROP__WEBKIT_MARQUEE_REPETITION, - CSS_PROP__WEBKIT_MARQUEE_STYLE, - CSS_PROP__WEBKIT_NBSP_MODE, - CSS_PROP__WEBKIT_RTL_ORDERING, - CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, - CSS_PROP__WEBKIT_TEXT_FILL_COLOR, - CSS_PROP__WEBKIT_TEXT_SECURITY, - CSS_PROP__WEBKIT_TEXT_STROKE_COLOR, - CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH, - CSS_PROP__WEBKIT_USER_DRAG, - CSS_PROP__WEBKIT_USER_MODIFY, - CSS_PROP__WEBKIT_USER_SELECT, - CSS_PROP__WEBKIT_DASHBOARD_REGION, - CSS_PROP__WEBKIT_BORDER_BOTTOM_LEFT_RADIUS, - CSS_PROP__WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS, - CSS_PROP__WEBKIT_BORDER_TOP_LEFT_RADIUS, - CSS_PROP__WEBKIT_BORDER_TOP_RIGHT_RADIUS + CSSPropertyBackgroundPosition, + CSSPropertyBackgroundRepeat, + CSSPropertyBorderBottomColor, + CSSPropertyBorderBottomStyle, + CSSPropertyBorderBottomWidth, + CSSPropertyBorderCollapse, + CSSPropertyBorderLeftColor, + CSSPropertyBorderLeftStyle, + CSSPropertyBorderLeftWidth, + CSSPropertyBorderRightColor, + CSSPropertyBorderRightStyle, + CSSPropertyBorderRightWidth, + CSSPropertyBorderTopColor, + CSSPropertyBorderTopStyle, + CSSPropertyBorderTopWidth, + CSSPropertyBottom, + CSSPropertyCaptionSide, + CSSPropertyClear, + CSSPropertyColor, + CSSPropertyCursor, + CSSPropertyDirection, + CSSPropertyDisplay, + CSSPropertyEmptyCells, + CSSPropertyFloat, + CSSPropertyFontFamily, + CSSPropertyFontSize, + CSSPropertyFontStyle, + CSSPropertyFontVariant, + CSSPropertyFontWeight, + CSSPropertyHeight, + CSSPropertyLeft, + CSSPropertyLetterSpacing, + CSSPropertyLineHeight, + CSSPropertyListStyleImage, + CSSPropertyListStylePosition, + CSSPropertyListStyleType, + CSSPropertyMarginBottom, + CSSPropertyMarginLeft, + CSSPropertyMarginRight, + CSSPropertyMarginTop, + CSSPropertyMaxHeight, + CSSPropertyMaxWidth, + CSSPropertyMinHeight, + CSSPropertyMinWidth, + CSSPropertyOpacity, + CSSPropertyOrphans, + CSSPropertyOutlineColor, + CSSPropertyOutlineStyle, + CSSPropertyOutlineWidth, + CSSPropertyOverflowX, + CSSPropertyOverflowY, + CSSPropertyPaddingBottom, + CSSPropertyPaddingLeft, + CSSPropertyPaddingRight, + CSSPropertyPaddingTop, + CSSPropertyPageBreakAfter, + CSSPropertyPageBreakBefore, + CSSPropertyPageBreakInside, + CSSPropertyPosition, + CSSPropertyResize, + CSSPropertyRight, + CSSPropertyTableLayout, + CSSPropertyTextAlign, + CSSPropertyTextDecoration, + CSSPropertyTextIndent, + CSSPropertyTextShadow, + CSSPropertyTextTransform, + CSSPropertyTop, + CSSPropertyUnicodeBidi, + CSSPropertyVerticalAlign, + CSSPropertyVisibility, + CSSPropertyWhiteSpace, + CSSPropertyWidows, + CSSPropertyWidth, + CSSPropertyWordSpacing, + CSSPropertyWordWrap, + CSSPropertyZIndex, + CSSPropertyZoom, + + CSSPropertyWebkitAppearance, + CSSPropertyWebkitBackgroundClip, + CSSPropertyWebkitBackgroundComposite, + CSSPropertyWebkitBackgroundOrigin, + CSSPropertyWebkitBackgroundSize, + CSSPropertyWebkitBorderFit, + CSSPropertyWebkitBorderImage, + CSSPropertyWebkitBorderHorizontalSpacing, + CSSPropertyWebkitBorderVerticalSpacing, + CSSPropertyWebkitBoxAlign, + CSSPropertyWebkitBoxDirection, + CSSPropertyWebkitBoxFlex, + CSSPropertyWebkitBoxFlexGroup, + CSSPropertyWebkitBoxLines, + CSSPropertyWebkitBoxOrdinalGroup, + CSSPropertyWebkitBoxOrient, + CSSPropertyWebkitBoxPack, + CSSPropertyWebkitBoxReflect, + CSSPropertyWebkitBoxShadow, + CSSPropertyWebkitBoxSizing, + CSSPropertyWebkitColumnBreakAfter, + CSSPropertyWebkitColumnBreakBefore, + CSSPropertyWebkitColumnBreakInside, + CSSPropertyWebkitColumnCount, + CSSPropertyWebkitColumnGap, + CSSPropertyWebkitColumnRuleColor, + CSSPropertyWebkitColumnRuleStyle, + CSSPropertyWebkitColumnRuleWidth, + CSSPropertyWebkitColumnWidth, + CSSPropertyWebkitHighlight, + CSSPropertyWebkitLineBreak, + CSSPropertyWebkitLineClamp, + CSSPropertyWebkitMarginBottomCollapse, + CSSPropertyWebkitMarginTopCollapse, + CSSPropertyWebkitMarqueeDirection, + CSSPropertyWebkitMarqueeIncrement, + CSSPropertyWebkitMarqueeRepetition, + CSSPropertyWebkitMarqueeStyle, + CSSPropertyWebkitMaskAttachment, + CSSPropertyWebkitMaskBoxImage, + CSSPropertyWebkitMaskImage, + CSSPropertyWebkitMaskPosition, + CSSPropertyWebkitMaskRepeat, + CSSPropertyWebkitMaskClip, + CSSPropertyWebkitMaskComposite, + CSSPropertyWebkitMaskOrigin, + CSSPropertyWebkitMaskSize, + CSSPropertyWebkitNbspMode, + CSSPropertyWebkitRtlOrdering, + CSSPropertyWebkitTextDecorationsInEffect, + CSSPropertyWebkitTextFillColor, + CSSPropertyWebkitTextSecurity, + CSSPropertyWebkitTextStrokeColor, + CSSPropertyWebkitTextStrokeWidth, + CSSPropertyWebkitTransform, + CSSPropertyWebkitTransformOriginX, + CSSPropertyWebkitTransformOriginY, + CSSPropertyWebkitTransitionDelay, + CSSPropertyWebkitTransitionDuration, + CSSPropertyWebkitTransitionProperty, + CSSPropertyWebkitTransitionTimingFunction, + CSSPropertyWebkitUserDrag, + CSSPropertyWebkitUserModify, + CSSPropertyWebkitUserSelect, +#if ENABLE(DASHBOARD_SUPPORT) + CSSPropertyWebkitDashboardRegion, +#endif + CSSPropertyWebkitBorderBottomLeftRadius, + CSSPropertyWebkitBorderBottomRightRadius, + CSSPropertyWebkitBorderTopLeftRadius, + CSSPropertyWebkitBorderTopRightRadius #if ENABLE(SVG) , - CSS_PROP_CLIP_PATH, - CSS_PROP_CLIP_RULE, - CSS_PROP_MASK, - CSS_PROP_FILTER, - CSS_PROP_FLOOD_COLOR, - CSS_PROP_FLOOD_OPACITY, - CSS_PROP_LIGHTING_COLOR, - CSS_PROP_STOP_COLOR, - CSS_PROP_STOP_OPACITY, - CSS_PROP_POINTER_EVENTS, - CSS_PROP_COLOR_INTERPOLATION, - CSS_PROP_COLOR_INTERPOLATION_FILTERS, - CSS_PROP_COLOR_RENDERING, - CSS_PROP_FILL, - CSS_PROP_FILL_OPACITY, - CSS_PROP_FILL_RULE, - CSS_PROP_IMAGE_RENDERING, - CSS_PROP_MARKER_END, - CSS_PROP_MARKER_MID, - CSS_PROP_MARKER_START, - CSS_PROP_SHAPE_RENDERING, - CSS_PROP_STROKE, - CSS_PROP_STROKE_DASHARRAY, - CSS_PROP_STROKE_DASHOFFSET, - CSS_PROP_STROKE_LINECAP, - CSS_PROP_STROKE_LINEJOIN, - CSS_PROP_STROKE_MITERLIMIT, - CSS_PROP_STROKE_OPACITY, - CSS_PROP_STROKE_WIDTH, - CSS_PROP_TEXT_RENDERING, - CSS_PROP_ALIGNMENT_BASELINE, - CSS_PROP_BASELINE_SHIFT, - CSS_PROP_DOMINANT_BASELINE, - CSS_PROP_KERNING, - CSS_PROP_TEXT_ANCHOR, - CSS_PROP_WRITING_MODE, - CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL, - CSS_PROP_GLYPH_ORIENTATION_VERTICAL + CSSPropertyClipPath, + CSSPropertyClipRule, + CSSPropertyMask, + CSSPropertyFilter, + CSSPropertyFloodColor, + CSSPropertyFloodOpacity, + CSSPropertyLightingColor, + CSSPropertyStopColor, + CSSPropertyStopOpacity, + CSSPropertyPointerEvents, + CSSPropertyColorInterpolation, + CSSPropertyColorInterpolationFilters, + CSSPropertyColorRendering, + CSSPropertyFill, + CSSPropertyFillOpacity, + CSSPropertyFillRule, + CSSPropertyImageRendering, + CSSPropertyMarkerEnd, + CSSPropertyMarkerMid, + CSSPropertyMarkerStart, + CSSPropertyShapeRendering, + CSSPropertyStroke, + CSSPropertyStrokeDasharray, + CSSPropertyStrokeDashoffset, + CSSPropertyStrokeLinecap, + CSSPropertyStrokeLinejoin, + CSSPropertyStrokeMiterlimit, + CSSPropertyStrokeOpacity, + CSSPropertyStrokeWidth, + CSSPropertyTextRendering, + CSSPropertyAlignmentBaseline, + CSSPropertyBaselineShift, + CSSPropertyDominantBaseline, + CSSPropertyKerning, + CSSPropertyTextAnchor, + CSSPropertyWritingMode, + CSSPropertyGlyphOrientationHorizontal, + CSSPropertyGlyphOrientationVertical #endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR , - CSS_PROP__WEBKIT_TAP_HIGHLIGHT_COLOR + CSSPropertyWebkitTapHighlightColor #endif }; @@ -230,19 +259,89 @@ const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(compu static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow) { if (!shadow) - return new CSSPrimitiveValue(CSS_VAL_NONE); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); - RefPtr<CSSValueList> list = new CSSValueList; + RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); for (const ShadowData* s = shadow; s; s = s->next) { - RefPtr<CSSPrimitiveValue> x = new CSSPrimitiveValue(s->x, CSSPrimitiveValue::CSS_PX); - RefPtr<CSSPrimitiveValue> y = new CSSPrimitiveValue(s->y, CSSPrimitiveValue::CSS_PX); - RefPtr<CSSPrimitiveValue> blur = new CSSPrimitiveValue(s->blur, CSSPrimitiveValue::CSS_PX); - RefPtr<CSSPrimitiveValue> color = new CSSPrimitiveValue(s->color.rgb()); - list->append(new ShadowValue(x.release(), y.release(), blur.release(), color.release())); + 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> color = CSSPrimitiveValue::createColor(s->color.rgb()); + list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), color.release())); } return list.release(); } +static int valueForRepeatRule(int rule) +{ + switch (rule) { + case RepeatImageRule: + return CSSValueRepeat; + case RoundImageRule: + return CSSValueRound; + default: + return CSSValueStretch; + } +} + +static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image) +{ + if (!image.hasImage()) + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + + // Image first. + RefPtr<CSSValue> imageValue; + if (image.image()) + imageValue = image.image()->cssValue(); + + // Create the slices. + RefPtr<CSSPrimitiveValue> top; + if (image.m_slices.top().isPercent()) + top = CSSPrimitiveValue::create(image.m_slices.top().value(), CSSPrimitiveValue::CSS_PERCENTAGE); + else + top = CSSPrimitiveValue::create(image.m_slices.top().value(), CSSPrimitiveValue::CSS_NUMBER); + + RefPtr<CSSPrimitiveValue> right; + if (image.m_slices.right().isPercent()) + right = CSSPrimitiveValue::create(image.m_slices.right().value(), CSSPrimitiveValue::CSS_PERCENTAGE); + else + right = CSSPrimitiveValue::create(image.m_slices.right().value(), CSSPrimitiveValue::CSS_NUMBER); + + RefPtr<CSSPrimitiveValue> bottom; + if (image.m_slices.bottom().isPercent()) + bottom = CSSPrimitiveValue::create(image.m_slices.bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE); + else + bottom = CSSPrimitiveValue::create(image.m_slices.bottom().value(), CSSPrimitiveValue::CSS_NUMBER); + + RefPtr<CSSPrimitiveValue> left; + if (image.m_slices.left().isPercent()) + left = CSSPrimitiveValue::create(image.m_slices.left().value(), CSSPrimitiveValue::CSS_PERCENTAGE); + else + left = CSSPrimitiveValue::create(image.m_slices.left().value(), CSSPrimitiveValue::CSS_NUMBER); + + RefPtr<Rect> rect = Rect::create(); + rect->setTop(top); + rect->setRight(right); + rect->setBottom(bottom); + rect->setLeft(left); + + return CSSBorderImageValue::create(imageValue, rect, valueForRepeatRule(image.m_horizontalRule), valueForRepeatRule(image.m_verticalRule)); +} + +static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection) +{ + if (!reflection) + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + + RefPtr<CSSPrimitiveValue> offset; + if (reflection->offset().isPercent()) + offset = CSSPrimitiveValue::create(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE); + else + offset = CSSPrimitiveValue::create(reflection->offset().value(), CSSPrimitiveValue::CSS_PX); + + return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask())); +} + static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID) { if (!style) @@ -250,16 +349,16 @@ static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int prope Length l; switch (propertyID) { - case CSS_PROP_LEFT: + case CSSPropertyLeft: l = style->left(); break; - case CSS_PROP_RIGHT: + case CSSPropertyRight: l = style->right(); break; - case CSS_PROP_TOP: + case CSSPropertyTop: l = style->top(); break; - case CSS_PROP_BOTTOM: + case CSSPropertyBottom: l = style->bottom(); break; default: @@ -267,32 +366,32 @@ static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int prope } if (style->position() == AbsolutePosition || style->position() == FixedPosition) - return new CSSPrimitiveValue(l); + return CSSPrimitiveValue::create(l); if (style->position() == RelativePosition) // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined. - // In other words if left is auto and right is not auto, then left's computed value is negative right. + // In other words if left is auto and right is not auto, then left's computed value is negative right(). // So we should get the opposite length unit and see if it is auto. - return new CSSPrimitiveValue(l); + return CSSPrimitiveValue::create(l); - return new CSSPrimitiveValue(CSS_VAL_AUTO); + return CSSPrimitiveValue::createIdentifier(CSSValueAuto); } static PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle* style, const Color& color) { if (!color.isValid()) - return new CSSPrimitiveValue(style->color().rgb()); - return new CSSPrimitiveValue(color.rgb()); + return CSSPrimitiveValue::createColor(style->color().rgb()); + return CSSPrimitiveValue::createColor(color.rgb()); } static PassRefPtr<CSSValue> getBorderRadiusCornerValue(IntSize radius) { if (radius.width() == radius.height()) - return new CSSPrimitiveValue(radius.width(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(radius.width(), CSSPrimitiveValue::CSS_PX); - RefPtr<CSSValueList> list = new CSSValueList(true); - list->append(new CSSPrimitiveValue(radius.width(), CSSPrimitiveValue::CSS_PX)); - list->append(new CSSPrimitiveValue(radius.height(), CSSPrimitiveValue::CSS_PX)); + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + list->append(CSSPrimitiveValue::create(radius.width(), CSSPrimitiveValue::CSS_PX)); + list->append(CSSPrimitiveValue::create(radius.height(), CSSPrimitiveValue::CSS_PX)); return list.release(); } @@ -301,6 +400,31 @@ static IntRect sizingBox(RenderObject* renderer) return renderer->style()->boxSizing() == CONTENT_BOX ? renderer->contentBox() : renderer->borderBox(); } +static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer) +{ + if (!renderer || renderer->style()->transform().operations().isEmpty()) + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + + IntRect box = sizingBox(renderer); + + AffineTransform transform; + renderer->style()->applyTransform(transform, box.size(), false); + + RefPtr<WebKitCSSTransformValue> transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation); + + transformVal->append(CSSPrimitiveValue::create(transform.a(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.b(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.c(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.d(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.e(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.f(), CSSPrimitiveValue::CSS_NUMBER)); + + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + list->append(transformVal); + + return list.release(); +} + CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n) : m_node(n) { @@ -357,340 +481,394 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper #endif switch (static_cast<CSSPropertyID>(propertyID)) { - case CSS_PROP_INVALID: + case CSSPropertyInvalid: break; - case CSS_PROP_BACKGROUND_COLOR: - return new CSSPrimitiveValue(style->backgroundColor().rgb()); - case CSS_PROP_BACKGROUND_IMAGE: + case CSSPropertyBackgroundColor: + return CSSPrimitiveValue::createColor(style->backgroundColor().rgb()); + case CSSPropertyBackgroundImage: if (style->backgroundImage()) - return new CSSPrimitiveValue(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI); - return new CSSPrimitiveValue(CSS_VAL_NONE); - case CSS_PROP__WEBKIT_BACKGROUND_SIZE: { - RefPtr<CSSValueList> list = new CSSValueList(true); - list->append(new CSSPrimitiveValue(style->backgroundSize().width)); - list->append(new CSSPrimitiveValue(style->backgroundSize().height)); + return style->backgroundImage()->cssValue(); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + case CSSPropertyWebkitBackgroundSize: { + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + list->append(CSSPrimitiveValue::create(style->backgroundSize().width())); + list->append(CSSPrimitiveValue::create(style->backgroundSize().height())); return list.release(); } - case CSS_PROP_BACKGROUND_REPEAT: - return new CSSPrimitiveValue(style->backgroundRepeat()); - case CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE: - return new CSSPrimitiveValue(style->backgroundComposite()); - case CSS_PROP_BACKGROUND_ATTACHMENT: + case CSSPropertyBackgroundRepeat: + return CSSPrimitiveValue::create(style->backgroundRepeat()); + case CSSPropertyWebkitBackgroundComposite: + return CSSPrimitiveValue::create(style->backgroundComposite()); + case CSSPropertyBackgroundAttachment: if (style->backgroundAttachment()) - return new CSSPrimitiveValue(CSS_VAL_SCROLL); - return new CSSPrimitiveValue(CSS_VAL_FIXED); - case CSS_PROP__WEBKIT_BACKGROUND_CLIP: - case CSS_PROP__WEBKIT_BACKGROUND_ORIGIN: { - EBackgroundBox box = (propertyID == CSS_PROP__WEBKIT_BACKGROUND_CLIP ? style->backgroundClip() : style->backgroundOrigin()); - return new CSSPrimitiveValue(box); + return CSSPrimitiveValue::createIdentifier(CSSValueScroll); + return CSSPrimitiveValue::createIdentifier(CSSValueFixed); + case CSSPropertyWebkitBackgroundClip: + case CSSPropertyWebkitBackgroundOrigin: { + EFillBox box = (propertyID == CSSPropertyWebkitBackgroundClip ? style->backgroundClip() : style->backgroundOrigin()); + return CSSPrimitiveValue::create(box); } - case CSS_PROP_BACKGROUND_POSITION: { - RefPtr<CSSValueList> list = new CSSValueList(true); + case CSSPropertyBackgroundPosition: { + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); - list->append(new CSSPrimitiveValue(style->backgroundXPosition())); - list->append(new CSSPrimitiveValue(style->backgroundYPosition())); + list->append(CSSPrimitiveValue::create(style->backgroundXPosition())); + list->append(CSSPrimitiveValue::create(style->backgroundYPosition())); return list.release(); } - case CSS_PROP_BACKGROUND_POSITION_X: - return new CSSPrimitiveValue(style->backgroundXPosition()); - case CSS_PROP_BACKGROUND_POSITION_Y: - return new CSSPrimitiveValue(style->backgroundYPosition()); - case CSS_PROP_BORDER_COLLAPSE: + case CSSPropertyBackgroundPositionX: + return CSSPrimitiveValue::create(style->backgroundXPosition()); + case CSSPropertyBackgroundPositionY: + return CSSPrimitiveValue::create(style->backgroundYPosition()); + case CSSPropertyBorderCollapse: if (style->borderCollapse()) - return new CSSPrimitiveValue(CSS_VAL_COLLAPSE); - return new CSSPrimitiveValue(CSS_VAL_SEPARATE); - case CSS_PROP_BORDER_SPACING: { - RefPtr<CSSValueList> list = new CSSValueList(true); - list->append(new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX)); - list->append(new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX)); + return CSSPrimitiveValue::createIdentifier(CSSValueCollapse); + return CSSPrimitiveValue::createIdentifier(CSSValueSeparate); + case CSSPropertyBorderSpacing: { + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + list->append(CSSPrimitiveValue::create(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX)); + list->append(CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX)); return list.release(); } - case CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING: - return new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING: - return new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP_BORDER_TOP_COLOR: + case CSSPropertyWebkitBorderHorizontalSpacing: + return CSSPrimitiveValue::create(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyWebkitBorderVerticalSpacing: + return CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyBorderTopColor: return currentColorOrValidColor(style, style->borderTopColor()); - case CSS_PROP_BORDER_RIGHT_COLOR: + case CSSPropertyBorderRightColor: return currentColorOrValidColor(style, style->borderRightColor()); - case CSS_PROP_BORDER_BOTTOM_COLOR: + case CSSPropertyBorderBottomColor: return currentColorOrValidColor(style, style->borderBottomColor()); - case CSS_PROP_BORDER_LEFT_COLOR: + case CSSPropertyBorderLeftColor: return currentColorOrValidColor(style, style->borderLeftColor()); - case CSS_PROP_BORDER_TOP_STYLE: - return new CSSPrimitiveValue(style->borderTopStyle()); - case CSS_PROP_BORDER_RIGHT_STYLE: - return new CSSPrimitiveValue(style->borderRightStyle()); - case CSS_PROP_BORDER_BOTTOM_STYLE: - return new CSSPrimitiveValue(style->borderBottomStyle()); - case CSS_PROP_BORDER_LEFT_STYLE: - return new CSSPrimitiveValue(style->borderLeftStyle()); - case CSS_PROP_BORDER_TOP_WIDTH: - return new CSSPrimitiveValue(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP_BORDER_RIGHT_WIDTH: - return new CSSPrimitiveValue(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP_BORDER_BOTTOM_WIDTH: - return new CSSPrimitiveValue(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP_BORDER_LEFT_WIDTH: - return new CSSPrimitiveValue(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP_BOTTOM: - return getPositionOffsetValue(style, CSS_PROP_BOTTOM); - case CSS_PROP__WEBKIT_BOX_ALIGN: - return new CSSPrimitiveValue(style->boxAlign()); - case CSS_PROP__WEBKIT_BOX_DIRECTION: - return new CSSPrimitiveValue(style->boxDirection()); - case CSS_PROP__WEBKIT_BOX_FLEX: - return new CSSPrimitiveValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP__WEBKIT_BOX_FLEX_GROUP: - return new CSSPrimitiveValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP__WEBKIT_BOX_LINES: - return new CSSPrimitiveValue(style->boxLines()); - case CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP: - return new CSSPrimitiveValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP__WEBKIT_BOX_ORIENT: - return new CSSPrimitiveValue(style->boxOrient()); - case CSS_PROP__WEBKIT_BOX_PACK: { + case CSSPropertyBorderTopStyle: + return CSSPrimitiveValue::create(style->borderTopStyle()); + case CSSPropertyBorderRightStyle: + return CSSPrimitiveValue::create(style->borderRightStyle()); + case CSSPropertyBorderBottomStyle: + return CSSPrimitiveValue::create(style->borderBottomStyle()); + case CSSPropertyBorderLeftStyle: + return CSSPrimitiveValue::create(style->borderLeftStyle()); + case CSSPropertyBorderTopWidth: + return CSSPrimitiveValue::create(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyBorderRightWidth: + return CSSPrimitiveValue::create(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyBorderBottomWidth: + return CSSPrimitiveValue::create(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyBorderLeftWidth: + return CSSPrimitiveValue::create(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyBottom: + return getPositionOffsetValue(style, CSSPropertyBottom); + case CSSPropertyWebkitBoxAlign: + return CSSPrimitiveValue::create(style->boxAlign()); + case CSSPropertyWebkitBoxDirection: + return CSSPrimitiveValue::create(style->boxDirection()); + case CSSPropertyWebkitBoxFlex: + return CSSPrimitiveValue::create(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWebkitBoxFlexGroup: + return CSSPrimitiveValue::create(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWebkitBoxLines: + return CSSPrimitiveValue::create(style->boxLines()); + case CSSPropertyWebkitBoxOrdinalGroup: + return CSSPrimitiveValue::create(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWebkitBoxOrient: + return CSSPrimitiveValue::create(style->boxOrient()); + case CSSPropertyWebkitBoxPack: { EBoxAlignment boxPack = style->boxPack(); ASSERT(boxPack != BSTRETCH); ASSERT(boxPack != BBASELINE); if (boxPack == BJUSTIFY || boxPack== BBASELINE) return 0; - return new CSSPrimitiveValue(boxPack); + return CSSPrimitiveValue::create(boxPack); } - case CSS_PROP__WEBKIT_BOX_SHADOW: + case CSSPropertyWebkitBoxReflect: + return valueForReflection(style->boxReflect()); + case CSSPropertyWebkitBoxShadow: return valueForShadow(style->boxShadow()); - case CSS_PROP_CAPTION_SIDE: - return new CSSPrimitiveValue(style->captionSide()); - case CSS_PROP_CLEAR: - return new CSSPrimitiveValue(style->clear()); - case CSS_PROP_COLOR: - return new CSSPrimitiveValue(style->color().rgb()); - case CSS_PROP__WEBKIT_COLUMN_COUNT: + case CSSPropertyCaptionSide: + return CSSPrimitiveValue::create(style->captionSide()); + case CSSPropertyClear: + return CSSPrimitiveValue::create(style->clear()); + case CSSPropertyColor: + return CSSPrimitiveValue::createColor(style->color().rgb()); + case CSSPropertyWebkitColumnCount: if (style->hasAutoColumnCount()) - return new CSSPrimitiveValue(CSS_VAL_AUTO); - return new CSSPrimitiveValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP__WEBKIT_COLUMN_GAP: + return CSSPrimitiveValue::createIdentifier(CSSValueAuto); + return CSSPrimitiveValue::create(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWebkitColumnGap: if (style->hasNormalColumnGap()) - return new CSSPrimitiveValue(CSS_VAL_NORMAL); - return new CSSPrimitiveValue(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP__WEBKIT_COLUMN_RULE_COLOR: + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); + return CSSPrimitiveValue::create(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWebkitColumnRuleColor: return currentColorOrValidColor(style, style->columnRuleColor()); - case CSS_PROP__WEBKIT_COLUMN_RULE_STYLE: - return new CSSPrimitiveValue(style->columnRuleStyle()); - case CSS_PROP__WEBKIT_COLUMN_RULE_WIDTH: - return new CSSPrimitiveValue(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP__WEBKIT_COLUMN_BREAK_AFTER: - return new CSSPrimitiveValue(style->columnBreakAfter()); - case CSS_PROP__WEBKIT_COLUMN_BREAK_BEFORE: - return new CSSPrimitiveValue(style->columnBreakBefore()); - case CSS_PROP__WEBKIT_COLUMN_BREAK_INSIDE: - return new CSSPrimitiveValue(style->columnBreakInside()); - case CSS_PROP__WEBKIT_COLUMN_WIDTH: + case CSSPropertyWebkitColumnRuleStyle: + return CSSPrimitiveValue::create(style->columnRuleStyle()); + case CSSPropertyWebkitColumnRuleWidth: + return CSSPrimitiveValue::create(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyWebkitColumnBreakAfter: + return CSSPrimitiveValue::create(style->columnBreakAfter()); + case CSSPropertyWebkitColumnBreakBefore: + return CSSPrimitiveValue::create(style->columnBreakBefore()); + case CSSPropertyWebkitColumnBreakInside: + return CSSPrimitiveValue::create(style->columnBreakInside()); + case CSSPropertyWebkitColumnWidth: if (style->hasAutoColumnWidth()) - return new CSSPrimitiveValue(CSS_VAL_AUTO); - return new CSSPrimitiveValue(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP_CURSOR: { + return CSSPrimitiveValue::createIdentifier(CSSValueAuto); + return CSSPrimitiveValue::create(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyCursor: { RefPtr<CSSValueList> list; CursorList* cursors = style->cursors(); if (cursors && cursors->size() > 0) { - list = new CSSValueList; + list = CSSValueList::createCommaSeparated(); for (unsigned i = 0; i < cursors->size(); ++i) - list->append(new CSSPrimitiveValue((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI)); + list->append(CSSPrimitiveValue::create((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI)); } - RefPtr<CSSValue> value = new CSSPrimitiveValue(style->cursor()); + RefPtr<CSSValue> value = CSSPrimitiveValue::create(style->cursor()); if (list) { list->append(value); return list.release(); } return value.release(); } - case CSS_PROP_DIRECTION: - return new CSSPrimitiveValue(style->direction()); - case CSS_PROP_DISPLAY: - return new CSSPrimitiveValue(style->display()); - case CSS_PROP_EMPTY_CELLS: - return new CSSPrimitiveValue(style->emptyCells()); - case CSS_PROP_FLOAT: + case CSSPropertyDirection: + return CSSPrimitiveValue::create(style->direction()); + case CSSPropertyDisplay: + return CSSPrimitiveValue::create(style->display()); + case CSSPropertyEmptyCells: + return CSSPrimitiveValue::create(style->emptyCells()); + case CSSPropertyFloat: #ifdef ANDROID_LAYOUT if (settings && settings->layoutAlgorithm() == Settings::kLayoutSSR) - return new CSSPrimitiveValue(CSS_VAL_NONE); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); #endif - return new CSSPrimitiveValue(style->floating()); - case CSS_PROP_FONT_FAMILY: + return CSSPrimitiveValue::create(style->floating()); + case CSSPropertyFontFamily: // FIXME: This only returns the first family. - return new CSSPrimitiveValue(style->fontDescription().family().family().domString(), CSSPrimitiveValue::CSS_STRING); - case CSS_PROP_FONT_SIZE: - return new CSSPrimitiveValue(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP__WEBKIT_BINDING: + return CSSPrimitiveValue::create(style->fontDescription().family().family().string(), CSSPrimitiveValue::CSS_STRING); + case CSSPropertyFontSize: + return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyWebkitBinding: break; - case CSS_PROP_FONT_STYLE: + case CSSPropertyFontStyle: if (style->fontDescription().italic()) - return new CSSPrimitiveValue(CSS_VAL_ITALIC); - return new CSSPrimitiveValue(CSS_VAL_NORMAL); - case CSS_PROP_FONT_VARIANT: + return CSSPrimitiveValue::createIdentifier(CSSValueItalic); + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); + case CSSPropertyFontVariant: if (style->fontDescription().smallCaps()) - return new CSSPrimitiveValue(CSS_VAL_SMALL_CAPS); - return new CSSPrimitiveValue(CSS_VAL_NORMAL); - case CSS_PROP_FONT_WEIGHT: - // FIXME: this does not reflect the full range of weights - // that can be expressed with CSS - if (style->fontDescription().weight() == cBoldWeight) - return new CSSPrimitiveValue(CSS_VAL_BOLD); - return new CSSPrimitiveValue(CSS_VAL_NORMAL); - case CSS_PROP_HEIGHT: + return CSSPrimitiveValue::createIdentifier(CSSValueSmallCaps); + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); + case CSSPropertyFontWeight: + switch (style->fontDescription().weight()) { + case FontWeight100: + return CSSPrimitiveValue::createIdentifier(CSSValue100); + case FontWeight200: + return CSSPrimitiveValue::createIdentifier(CSSValue200); + case FontWeight300: + return CSSPrimitiveValue::createIdentifier(CSSValue300); + case FontWeightNormal: + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); + case FontWeight500: + return CSSPrimitiveValue::createIdentifier(CSSValue500); + case FontWeight600: + return CSSPrimitiveValue::createIdentifier(CSSValue600); + case FontWeightBold: + return CSSPrimitiveValue::createIdentifier(CSSValueBold); + case FontWeight800: + return CSSPrimitiveValue::createIdentifier(CSSValue800); + case FontWeight900: + return CSSPrimitiveValue::createIdentifier(CSSValue900); + } + ASSERT_NOT_REACHED(); + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); + case CSSPropertyHeight: if (renderer) - return new CSSPrimitiveValue(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->height()); - case CSS_PROP__WEBKIT_HIGHLIGHT: + return CSSPrimitiveValue::create(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->height()); + case CSSPropertyWebkitHighlight: if (style->highlight() == nullAtom) - return new CSSPrimitiveValue(CSS_VAL_NONE); - return new CSSPrimitiveValue(style->highlight(), CSSPrimitiveValue::CSS_STRING); - case CSS_PROP__WEBKIT_BORDER_FIT: + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + return CSSPrimitiveValue::create(style->highlight(), CSSPrimitiveValue::CSS_STRING); + case CSSPropertyWebkitBorderFit: if (style->borderFit() == BorderFitBorder) - return new CSSPrimitiveValue(CSS_VAL_BORDER); - return new CSSPrimitiveValue(CSS_VAL_LINES); - case CSS_PROP_LEFT: - return getPositionOffsetValue(style, CSS_PROP_LEFT); - case CSS_PROP_LETTER_SPACING: + return CSSPrimitiveValue::createIdentifier(CSSValueBorder); + return CSSPrimitiveValue::createIdentifier(CSSValueLines); + case CSSPropertyLeft: + return getPositionOffsetValue(style, CSSPropertyLeft); + case CSSPropertyLetterSpacing: if (!style->letterSpacing()) - return new CSSPrimitiveValue(CSS_VAL_NORMAL); - return new CSSPrimitiveValue(style->letterSpacing(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP__WEBKIT_LINE_CLAMP: + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); + return CSSPrimitiveValue::create(style->letterSpacing(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyWebkitLineClamp: if (style->lineClamp() == -1) - return new CSSPrimitiveValue(CSS_VAL_NONE); - return new CSSPrimitiveValue(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE); - case CSS_PROP_LINE_HEIGHT: { + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + return CSSPrimitiveValue::create(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE); + case CSSPropertyLineHeight: { Length length = style->lineHeight(); if (length.isNegative()) - return new CSSPrimitiveValue(CSS_VAL_NORMAL); + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); if (length.isPercent()) // This is imperfect, because it doesn't include the zoom factor and the real computation // 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 new CSSPrimitiveValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::CSS_PX); } - case CSS_PROP_LIST_STYLE_IMAGE: + case CSSPropertyListStyleImage: if (style->listStyleImage()) - return new CSSPrimitiveValue(style->listStyleImage()->url(), CSSPrimitiveValue::CSS_URI); - return new CSSPrimitiveValue(CSS_VAL_NONE); - case CSS_PROP_LIST_STYLE_POSITION: - return new CSSPrimitiveValue(style->listStylePosition()); - case CSS_PROP_LIST_STYLE_TYPE: - return new CSSPrimitiveValue(style->listStyleType()); - case CSS_PROP_MARGIN_TOP: + return style->listStyleImage()->cssValue(); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + case CSSPropertyListStylePosition: + return CSSPrimitiveValue::create(style->listStylePosition()); + case CSSPropertyListStyleType: + return CSSPrimitiveValue::create(style->listStyleType()); + case CSSPropertyMarginTop: if (renderer) // FIXME: Supposed to return the percentage if percentage was specified. - return new CSSPrimitiveValue(renderer->marginTop(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->marginTop()); - case CSS_PROP_MARGIN_RIGHT: + return CSSPrimitiveValue::create(renderer->marginTop(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->marginTop()); + case CSSPropertyMarginRight: if (renderer) // FIXME: Supposed to return the percentage if percentage was specified. - return new CSSPrimitiveValue(renderer->marginRight(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->marginRight()); - case CSS_PROP_MARGIN_BOTTOM: + return CSSPrimitiveValue::create(renderer->marginRight(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->marginRight()); + case CSSPropertyMarginBottom: if (renderer) // FIXME: Supposed to return the percentage if percentage was specified. - return new CSSPrimitiveValue(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->marginBottom()); - case CSS_PROP_MARGIN_LEFT: + return CSSPrimitiveValue::create(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->marginBottom()); + case CSSPropertyMarginLeft: if (renderer) // FIXME: Supposed to return the percentage if percentage was specified. - return new CSSPrimitiveValue(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->marginLeft()); - case CSS_PROP__WEBKIT_MARQUEE_DIRECTION: - return new CSSPrimitiveValue(style->marqueeDirection()); - case CSS_PROP__WEBKIT_MARQUEE_INCREMENT: - return new CSSPrimitiveValue(style->marqueeIncrement()); - case CSS_PROP__WEBKIT_MARQUEE_REPETITION: + return CSSPrimitiveValue::create(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->marginLeft()); + case CSSPropertyWebkitMarqueeDirection: + return CSSPrimitiveValue::create(style->marqueeDirection()); + case CSSPropertyWebkitMarqueeIncrement: + return CSSPrimitiveValue::create(style->marqueeIncrement()); + case CSSPropertyWebkitMarqueeRepetition: if (style->marqueeLoopCount() < 0) - return new CSSPrimitiveValue(CSS_VAL_INFINITE); - return new CSSPrimitiveValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP__WEBKIT_MARQUEE_STYLE: - return new CSSPrimitiveValue(style->marqueeBehavior()); - case CSS_PROP__WEBKIT_USER_MODIFY: - return new CSSPrimitiveValue(style->userModify()); - case CSS_PROP_MAX_HEIGHT: { + return CSSPrimitiveValue::createIdentifier(CSSValueInfinite); + return CSSPrimitiveValue::create(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWebkitMarqueeStyle: + return CSSPrimitiveValue::create(style->marqueeBehavior()); + case CSSPropertyWebkitMaskImage: + if (style->maskImage()) + return style->maskImage()->cssValue(); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + case CSSPropertyWebkitMaskSize: { + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + list->append(CSSPrimitiveValue::create(style->maskSize().width())); + list->append(CSSPrimitiveValue::create(style->maskSize().height())); + return list.release(); + } + case CSSPropertyWebkitMaskRepeat: + return CSSPrimitiveValue::create(style->maskRepeat()); + case CSSPropertyWebkitMaskAttachment: + if (style->maskAttachment()) + return CSSPrimitiveValue::createIdentifier(CSSValueScroll); + return CSSPrimitiveValue::createIdentifier(CSSValueFixed); + case CSSPropertyWebkitMaskComposite: + return CSSPrimitiveValue::create(style->maskComposite()); + case CSSPropertyWebkitMaskClip: + case CSSPropertyWebkitMaskOrigin: { + EFillBox box = (propertyID == CSSPropertyWebkitMaskClip ? style->maskClip() : style->maskOrigin()); + return CSSPrimitiveValue::create(box); + } + case CSSPropertyWebkitMaskPosition: { + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + + list->append(CSSPrimitiveValue::create(style->maskXPosition())); + list->append(CSSPrimitiveValue::create(style->maskYPosition())); + + return list.release(); + } + case CSSPropertyWebkitMaskPositionX: + return CSSPrimitiveValue::create(style->maskXPosition()); + case CSSPropertyWebkitMaskPositionY: + return CSSPrimitiveValue::create(style->maskYPosition()); + case CSSPropertyWebkitUserModify: + return CSSPrimitiveValue::create(style->userModify()); + case CSSPropertyMaxHeight: { const Length& maxHeight = style->maxHeight(); if (maxHeight.isFixed() && maxHeight.value() == undefinedLength) - return new CSSPrimitiveValue(CSS_VAL_NONE); - return new CSSPrimitiveValue(maxHeight); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + return CSSPrimitiveValue::create(maxHeight); } - case CSS_PROP_MAX_WIDTH: { - const Length& maxWidth = style->maxHeight(); + case CSSPropertyMaxWidth: { + const Length& maxWidth = style->maxWidth(); if (maxWidth.isFixed() && maxWidth.value() == undefinedLength) - return new CSSPrimitiveValue(CSS_VAL_NONE); - return new CSSPrimitiveValue(maxWidth); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + return CSSPrimitiveValue::create(maxWidth); } - case CSS_PROP_MIN_HEIGHT: - return new CSSPrimitiveValue(style->minHeight()); - case CSS_PROP_MIN_WIDTH: - return new CSSPrimitiveValue(style->minWidth()); - case CSS_PROP_OPACITY: - return new CSSPrimitiveValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP_ORPHANS: - return new CSSPrimitiveValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP_OUTLINE_COLOR: + case CSSPropertyMinHeight: + return CSSPrimitiveValue::create(style->minHeight()); + case CSSPropertyMinWidth: + return CSSPrimitiveValue::create(style->minWidth()); + case CSSPropertyOpacity: + return CSSPrimitiveValue::create(style->opacity(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyOrphans: + return CSSPrimitiveValue::create(style->orphans(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyOutlineColor: return currentColorOrValidColor(style, style->outlineColor()); - case CSS_PROP_OUTLINE_STYLE: + case CSSPropertyOutlineStyle: if (style->outlineStyleIsAuto()) - return new CSSPrimitiveValue(CSS_VAL_AUTO); - return new CSSPrimitiveValue(style->outlineStyle()); - case CSS_PROP_OUTLINE_WIDTH: - return new CSSPrimitiveValue(style->outlineWidth(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP_OVERFLOW: - return new CSSPrimitiveValue(max(style->overflowX(), style->overflowY())); - case CSS_PROP_OVERFLOW_X: - return new CSSPrimitiveValue(style->overflowX()); - case CSS_PROP_OVERFLOW_Y: + return CSSPrimitiveValue::createIdentifier(CSSValueAuto); + return CSSPrimitiveValue::create(style->outlineStyle()); + case CSSPropertyOutlineWidth: + return CSSPrimitiveValue::create(style->outlineWidth(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyOverflow: + return CSSPrimitiveValue::create(max(style->overflowX(), style->overflowY())); + case CSSPropertyOverflowX: + return CSSPrimitiveValue::create(style->overflowX()); + case CSSPropertyOverflowY: #ifdef ANDROID_LAYOUT if (settings && settings->layoutAlgorithm() == Settings::kLayoutSSR) - return new CSSPrimitiveValue(CSS_VAL_VISIBLE); + return CSSPrimitiveValue::createIdentifier(CSSValueVisible); #endif - return new CSSPrimitiveValue(style->overflowY()); - case CSS_PROP_PADDING_TOP: + return CSSPrimitiveValue::create(style->overflowY()); + case CSSPropertyPaddingTop: if (renderer) - return new CSSPrimitiveValue(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->paddingTop()); - case CSS_PROP_PADDING_RIGHT: + return CSSPrimitiveValue::create(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->paddingTop()); + case CSSPropertyPaddingRight: if (renderer) - return new CSSPrimitiveValue(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->paddingRight()); - case CSS_PROP_PADDING_BOTTOM: + return CSSPrimitiveValue::create(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->paddingRight()); + case CSSPropertyPaddingBottom: if (renderer) - return new CSSPrimitiveValue(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->paddingBottom()); - case CSS_PROP_PADDING_LEFT: + return CSSPrimitiveValue::create(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->paddingBottom()); + case CSSPropertyPaddingLeft: if (renderer) - return new CSSPrimitiveValue(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->paddingLeft()); - case CSS_PROP_PAGE_BREAK_AFTER: - return new CSSPrimitiveValue(style->pageBreakAfter()); - case CSS_PROP_PAGE_BREAK_BEFORE: - return new CSSPrimitiveValue(style->pageBreakBefore()); - case CSS_PROP_PAGE_BREAK_INSIDE: { + return CSSPrimitiveValue::create(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->paddingLeft()); + case CSSPropertyPageBreakAfter: + return CSSPrimitiveValue::create(style->pageBreakAfter()); + case CSSPropertyPageBreakBefore: + return CSSPrimitiveValue::create(style->pageBreakBefore()); + case CSSPropertyPageBreakInside: { EPageBreak pageBreak = style->pageBreakInside(); ASSERT(pageBreak != PBALWAYS); if (pageBreak == PBALWAYS) return 0; - return new CSSPrimitiveValue(style->pageBreakInside()); + return CSSPrimitiveValue::create(style->pageBreakInside()); } - case CSS_PROP_POSITION: + case CSSPropertyPosition: #ifdef ANDROID_LAYOUT if (settings && settings->layoutAlgorithm() == Settings::kLayoutSSR) - return new CSSPrimitiveValue(CSS_VAL_STATIC); + return CSSPrimitiveValue::createIdentifier(CSSValueStatic); #endif - return new CSSPrimitiveValue(style->position()); - case CSS_PROP_RIGHT: - return getPositionOffsetValue(style, CSS_PROP_RIGHT); - case CSS_PROP_TABLE_LAYOUT: - return new CSSPrimitiveValue(style->tableLayout()); - case CSS_PROP_TEXT_ALIGN: - return new CSSPrimitiveValue(style->textAlign()); - case CSS_PROP_TEXT_DECORATION: { + return CSSPrimitiveValue::create(style->position()); + case CSSPropertyRight: + return getPositionOffsetValue(style, CSSPropertyRight); + case CSSPropertyTableLayout: + return CSSPrimitiveValue::create(style->tableLayout()); + case CSSPropertyTextAlign: + return CSSPrimitiveValue::create(style->textAlign()); + case CSSPropertyTextDecoration: { String string; if (style->textDecoration() & UNDERLINE) string += "underline"; @@ -710,10 +888,10 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper string += "blink"; } if (!string.length()) - return new CSSPrimitiveValue(CSS_VAL_NONE); - return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + return CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_STRING); } - case CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT: { + case CSSPropertyWebkitTextDecorationsInEffect: { String string; if (style->textDecorationsInEffect() & UNDERLINE) string += "underline"; @@ -733,126 +911,129 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper string += "blink"; } if (!string.length()) - return new CSSPrimitiveValue(CSS_VAL_NONE); - return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + return CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_STRING); } - case CSS_PROP__WEBKIT_TEXT_FILL_COLOR: + case CSSPropertyWebkitTextFillColor: return currentColorOrValidColor(style, style->textFillColor()); - case CSS_PROP_TEXT_INDENT: - return new CSSPrimitiveValue(style->textIndent()); - case CSS_PROP_TEXT_SHADOW: + case CSSPropertyTextIndent: + return CSSPrimitiveValue::create(style->textIndent()); + case CSSPropertyTextShadow: return valueForShadow(style->textShadow()); - case CSS_PROP__WEBKIT_TEXT_SECURITY: - return new CSSPrimitiveValue(style->textSecurity()); - case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST: + case CSSPropertyWebkitTextSecurity: + return CSSPrimitiveValue::create(style->textSecurity()); + case CSSPropertyWebkitTextSizeAdjust: if (style->textSizeAdjust()) - return new CSSPrimitiveValue(CSS_VAL_AUTO); - return new CSSPrimitiveValue(CSS_VAL_NONE); - case CSS_PROP__WEBKIT_TEXT_STROKE_COLOR: + return CSSPrimitiveValue::createIdentifier(CSSValueAuto); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + case CSSPropertyWebkitTextStrokeColor: return currentColorOrValidColor(style, style->textStrokeColor()); - case CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH: - return new CSSPrimitiveValue(style->textStrokeWidth(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP_TEXT_TRANSFORM: - return new CSSPrimitiveValue(style->textTransform()); - case CSS_PROP_TOP: - return getPositionOffsetValue(style, CSS_PROP_TOP); - case CSS_PROP_UNICODE_BIDI: - return new CSSPrimitiveValue(style->unicodeBidi()); - case CSS_PROP_VERTICAL_ALIGN: + case CSSPropertyWebkitTextStrokeWidth: + return CSSPrimitiveValue::create(style->textStrokeWidth(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyTextTransform: + return CSSPrimitiveValue::create(style->textTransform()); + case CSSPropertyTop: + return getPositionOffsetValue(style, CSSPropertyTop); + case CSSPropertyUnicodeBidi: + return CSSPrimitiveValue::create(style->unicodeBidi()); + case CSSPropertyVerticalAlign: switch (style->verticalAlign()) { case BASELINE: - return new CSSPrimitiveValue(CSS_VAL_BASELINE); + return CSSPrimitiveValue::createIdentifier(CSSValueBaseline); case MIDDLE: - return new CSSPrimitiveValue(CSS_VAL_MIDDLE); + return CSSPrimitiveValue::createIdentifier(CSSValueMiddle); case SUB: - return new CSSPrimitiveValue(CSS_VAL_SUB); + return CSSPrimitiveValue::createIdentifier(CSSValueSub); case SUPER: - return new CSSPrimitiveValue(CSS_VAL_SUPER); + return CSSPrimitiveValue::createIdentifier(CSSValueSuper); case TEXT_TOP: - return new CSSPrimitiveValue(CSS_VAL_TEXT_TOP); + return CSSPrimitiveValue::createIdentifier(CSSValueTextTop); case TEXT_BOTTOM: - return new CSSPrimitiveValue(CSS_VAL_TEXT_BOTTOM); + return CSSPrimitiveValue::createIdentifier(CSSValueTextBottom); case TOP: - return new CSSPrimitiveValue(CSS_VAL_TOP); + return CSSPrimitiveValue::createIdentifier(CSSValueTop); case BOTTOM: - return new CSSPrimitiveValue(CSS_VAL_BOTTOM); + return CSSPrimitiveValue::createIdentifier(CSSValueBottom); case BASELINE_MIDDLE: - return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BASELINE_MIDDLE); + return CSSPrimitiveValue::createIdentifier(CSSValueWebkitBaselineMiddle); case LENGTH: - return new CSSPrimitiveValue(style->verticalAlignLength()); + return CSSPrimitiveValue::create(style->verticalAlignLength()); } ASSERT_NOT_REACHED(); return 0; - case CSS_PROP_VISIBILITY: + case CSSPropertyVisibility: #ifdef ANDROID_LAYOUT if (settings && settings->layoutAlgorithm() == Settings::kLayoutSSR) - return new CSSPrimitiveValue(CSS_VAL_VISIBLE); + return CSSPrimitiveValue::createIdentifier(CSSValueVisible); #endif - return new CSSPrimitiveValue(style->visibility()); - case CSS_PROP_WHITE_SPACE: + return CSSPrimitiveValue::create(style->visibility()); + case CSSPropertyWhiteSpace: #ifdef ANDROID_LAYOUT if (settings && settings->layoutAlgorithm() == Settings::kLayoutSSR) switch (style->whiteSpace()) { case NORMAL: case NOWRAP: case KHTML_NOWRAP: - return new CSSPrimitiveValue(CSS_VAL_NORMAL); + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); case PRE: case PRE_WRAP: - return new CSSPrimitiveValue(CSS_VAL_PRE_WRAP); + return CSSPrimitiveValue::createIdentifier(CSSValuePreWrap); case PRE_LINE: - return new CSSPrimitiveValue(CSS_VAL_PRE_LINE); + return CSSPrimitiveValue::createIdentifier(CSSValuePreLine); } else #endif - return new CSSPrimitiveValue(style->whiteSpace()); - case CSS_PROP_WIDOWS: - return new CSSPrimitiveValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP_WIDTH: + return CSSPrimitiveValue::create(style->whiteSpace()); + case CSSPropertyWidows: + return CSSPrimitiveValue::create(style->widows(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWidth: if (renderer) - return new CSSPrimitiveValue(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX); - return new CSSPrimitiveValue(style->width()); - case CSS_PROP_WORD_BREAK: - return new CSSPrimitiveValue(style->wordBreak()); - case CSS_PROP_WORD_SPACING: - return new CSSPrimitiveValue(style->wordSpacing(), CSSPrimitiveValue::CSS_PX); - case CSS_PROP_WORD_WRAP: - return new CSSPrimitiveValue(style->wordWrap()); - case CSS_PROP__WEBKIT_LINE_BREAK: - return new CSSPrimitiveValue(style->khtmlLineBreak()); - case CSS_PROP__WEBKIT_NBSP_MODE: - return new CSSPrimitiveValue(style->nbspMode()); - case CSS_PROP__WEBKIT_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR: - return new CSSPrimitiveValue(style->matchNearestMailBlockquoteColor()); - case CSS_PROP_RESIZE: - return new CSSPrimitiveValue(style->resize()); - case CSS_PROP_Z_INDEX: + return CSSPrimitiveValue::create(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX); + return CSSPrimitiveValue::create(style->width()); + case CSSPropertyWordBreak: + return CSSPrimitiveValue::create(style->wordBreak()); + case CSSPropertyWordSpacing: + return CSSPrimitiveValue::create(style->wordSpacing(), CSSPrimitiveValue::CSS_PX); + case CSSPropertyWordWrap: + return CSSPrimitiveValue::create(style->wordWrap()); + case CSSPropertyWebkitLineBreak: + return CSSPrimitiveValue::create(style->khtmlLineBreak()); + case CSSPropertyWebkitNbspMode: + return CSSPrimitiveValue::create(style->nbspMode()); + case CSSPropertyWebkitMatchNearestMailBlockquoteColor: + return CSSPrimitiveValue::create(style->matchNearestMailBlockquoteColor()); + case CSSPropertyResize: + return CSSPrimitiveValue::create(style->resize()); + case CSSPropertyZIndex: if (style->hasAutoZIndex()) - return new CSSPrimitiveValue(CSS_VAL_AUTO); - return new CSSPrimitiveValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER); - case CSS_PROP__WEBKIT_BOX_SIZING: + return CSSPrimitiveValue::createIdentifier(CSSValueAuto); + return CSSPrimitiveValue::create(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyZoom: + return CSSPrimitiveValue::create(style->zoom(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWebkitBoxSizing: if (style->boxSizing() == CONTENT_BOX) - return new CSSPrimitiveValue(CSS_VAL_CONTENT_BOX); - return new CSSPrimitiveValue(CSS_VAL_BORDER_BOX); - case CSS_PROP__WEBKIT_DASHBOARD_REGION: + return CSSPrimitiveValue::createIdentifier(CSSValueContentBox); + return CSSPrimitiveValue::createIdentifier(CSSValueBorderBox); +#if ENABLE(DASHBOARD_SUPPORT) + case CSSPropertyWebkitDashboardRegion: { const Vector<StyleDashboardRegion>& regions = style->dashboardRegions(); unsigned count = regions.size(); if (count == 1 && regions[0].type == StyleDashboardRegion::None) - return new CSSPrimitiveValue(CSS_VAL_NONE); + return CSSPrimitiveValue::createIdentifier(CSSValueNone); RefPtr<DashboardRegion> firstRegion; DashboardRegion* previousRegion = 0; for (unsigned i = 0; i < count; i++) { - RefPtr<DashboardRegion> region = new DashboardRegion; + RefPtr<DashboardRegion> region = DashboardRegion::create(); StyleDashboardRegion styleRegion = regions[i]; region->m_label = styleRegion.label; LengthBox offset = styleRegion.offset; - region->setTop(new CSSPrimitiveValue(offset.top.value(), CSSPrimitiveValue::CSS_PX)); - region->setRight(new CSSPrimitiveValue(offset.right.value(), CSSPrimitiveValue::CSS_PX)); - region->setBottom(new CSSPrimitiveValue(offset.bottom.value(), CSSPrimitiveValue::CSS_PX)); - region->setLeft(new CSSPrimitiveValue(offset.left.value(), CSSPrimitiveValue::CSS_PX)); + region->setTop(CSSPrimitiveValue::create(offset.top().value(), CSSPrimitiveValue::CSS_PX)); + region->setRight(CSSPrimitiveValue::create(offset.right().value(), CSSPrimitiveValue::CSS_PX)); + region->setBottom(CSSPrimitiveValue::create(offset.bottom().value(), CSSPrimitiveValue::CSS_PX)); + region->setLeft(CSSPrimitiveValue::create(offset.left().value(), CSSPrimitiveValue::CSS_PX)); region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle); region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle); @@ -862,107 +1043,201 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper firstRegion = region; previousRegion = region.get(); } - return new CSSPrimitiveValue(firstRegion.release()); + return CSSPrimitiveValue::create(firstRegion.release()); } - case CSS_PROP__WEBKIT_APPEARANCE: - return new CSSPrimitiveValue(style->appearance()); - case CSS_PROP__WEBKIT_FONT_SIZE_DELTA: +#endif + case CSSPropertyWebkitAppearance: + return CSSPrimitiveValue::create(style->appearance()); + case CSSPropertyWebkitBorderImage: + return valueForNinePieceImage(style->borderImage()); + case CSSPropertyWebkitMaskBoxImage: + return valueForNinePieceImage(style->maskBoxImage()); + case CSSPropertyWebkitFontSizeDelta: // Not a real style property -- used by the editing engine -- so has no computed value. break; - case CSS_PROP__WEBKIT_MARGIN_BOTTOM_COLLAPSE: - return new CSSPrimitiveValue(style->marginBottomCollapse()); - case CSS_PROP__WEBKIT_MARGIN_TOP_COLLAPSE: - return new CSSPrimitiveValue(style->marginTopCollapse()); - case CSS_PROP__WEBKIT_RTL_ORDERING: + case CSSPropertyWebkitMarginBottomCollapse: + return CSSPrimitiveValue::create(style->marginBottomCollapse()); + case CSSPropertyWebkitMarginTopCollapse: + return CSSPrimitiveValue::create(style->marginTopCollapse()); + case CSSPropertyWebkitRtlOrdering: if (style->visuallyOrdered()) - return new CSSPrimitiveValue(CSS_VAL_VISUAL); - return new CSSPrimitiveValue(CSS_VAL_LOGICAL); - case CSS_PROP__WEBKIT_USER_DRAG: - return new CSSPrimitiveValue(style->userDrag()); - case CSS_PROP__WEBKIT_USER_SELECT: - return new CSSPrimitiveValue(style->userSelect()); - case CSS_PROP__WEBKIT_BORDER_BOTTOM_LEFT_RADIUS: + return CSSPrimitiveValue::createIdentifier(CSSValueVisual); + return CSSPrimitiveValue::createIdentifier(CSSValueLogical); + case CSSPropertyWebkitUserDrag: + return CSSPrimitiveValue::create(style->userDrag()); + case CSSPropertyWebkitUserSelect: + return CSSPrimitiveValue::create(style->userSelect()); + case CSSPropertyWebkitBorderBottomLeftRadius: return getBorderRadiusCornerValue(style->borderBottomLeftRadius()); - case CSS_PROP__WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS: + case CSSPropertyWebkitBorderBottomRightRadius: return getBorderRadiusCornerValue(style->borderBottomRightRadius()); - case CSS_PROP__WEBKIT_BORDER_TOP_LEFT_RADIUS: + case CSSPropertyWebkitBorderTopLeftRadius: return getBorderRadiusCornerValue(style->borderTopLeftRadius()); - case CSS_PROP__WEBKIT_BORDER_TOP_RIGHT_RADIUS: + case CSSPropertyWebkitBorderTopRightRadius: return getBorderRadiusCornerValue(style->borderTopRightRadius()); - case CSS_PROP_BACKGROUND: - case CSS_PROP_BORDER: - case CSS_PROP_BORDER_BOTTOM: - case CSS_PROP_BORDER_COLOR: - case CSS_PROP_BORDER_LEFT: - case CSS_PROP_BORDER_RIGHT: - case CSS_PROP_BORDER_STYLE: - case CSS_PROP_BORDER_TOP: - case CSS_PROP_BORDER_WIDTH: - case CSS_PROP_CLIP: - case CSS_PROP_CONTENT: - case CSS_PROP_COUNTER_INCREMENT: - case CSS_PROP_COUNTER_RESET: - case CSS_PROP_FONT: - case CSS_PROP_FONT_STRETCH: - case CSS_PROP_LIST_STYLE: - case CSS_PROP_MARGIN: - case CSS_PROP_OUTLINE: - case CSS_PROP_OUTLINE_OFFSET: - case CSS_PROP_PADDING: - case CSS_PROP_PAGE: - case CSS_PROP_QUOTES: - case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR: - case CSS_PROP_SCROLLBAR_ARROW_COLOR: - case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR: - case CSS_PROP_SCROLLBAR_FACE_COLOR: - case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR: - case CSS_PROP_SCROLLBAR_SHADOW_COLOR: - case CSS_PROP_SCROLLBAR_TRACK_COLOR: - case CSS_PROP_SRC: // Only used in @font-face rules. - case CSS_PROP_SIZE: - case CSS_PROP_TEXT_LINE_THROUGH: - case CSS_PROP_TEXT_LINE_THROUGH_COLOR: - case CSS_PROP_TEXT_LINE_THROUGH_MODE: - case CSS_PROP_TEXT_LINE_THROUGH_STYLE: - case CSS_PROP_TEXT_LINE_THROUGH_WIDTH: - case CSS_PROP_TEXT_OVERFLOW: - case CSS_PROP_TEXT_OVERLINE: - case CSS_PROP_TEXT_OVERLINE_COLOR: - case CSS_PROP_TEXT_OVERLINE_MODE: - case CSS_PROP_TEXT_OVERLINE_STYLE: - case CSS_PROP_TEXT_OVERLINE_WIDTH: - case CSS_PROP_TEXT_UNDERLINE: - case CSS_PROP_TEXT_UNDERLINE_COLOR: - case CSS_PROP_TEXT_UNDERLINE_MODE: - case CSS_PROP_TEXT_UNDERLINE_STYLE: - case CSS_PROP_TEXT_UNDERLINE_WIDTH: - case CSS_PROP_UNICODE_RANGE: // Only used in @font-face rules. - case CSS_PROP__WEBKIT_BORDER_IMAGE: - case CSS_PROP__WEBKIT_BORDER_RADIUS: - case CSS_PROP__WEBKIT_COLUMNS: - case CSS_PROP__WEBKIT_COLUMN_RULE: - case CSS_PROP__WEBKIT_MARGIN_COLLAPSE: - case CSS_PROP__WEBKIT_MARGIN_START: - case CSS_PROP__WEBKIT_MARQUEE: - case CSS_PROP__WEBKIT_MARQUEE_SPEED: - case CSS_PROP__WEBKIT_PADDING_START: - case CSS_PROP__WEBKIT_TEXT_STROKE: - case CSS_PROP__WEBKIT_TRANSFORM: - case CSS_PROP__WEBKIT_TRANSFORM_ORIGIN: - case CSS_PROP__WEBKIT_TRANSFORM_ORIGIN_X: - case CSS_PROP__WEBKIT_TRANSFORM_ORIGIN_Y: - case CSS_PROP__WEBKIT_TRANSITION: - case CSS_PROP__WEBKIT_TRANSITION_DURATION: - case CSS_PROP__WEBKIT_TRANSITION_PROPERTY: - case CSS_PROP__WEBKIT_TRANSITION_REPEAT_COUNT: - case CSS_PROP__WEBKIT_TRANSITION_TIMING_FUNCTION: + case CSSPropertyClip: + { + if (style->hasClip()) { + RefPtr<Rect> rect = Rect::create(); + rect->setTop(CSSPrimitiveValue::create(style->clip().top().value(), CSSPrimitiveValue::CSS_PX)); + rect->setRight(CSSPrimitiveValue::create(style->clip().right().value(), CSSPrimitiveValue::CSS_PX)); + rect->setBottom(CSSPrimitiveValue::create(style->clip().bottom().value(), CSSPrimitiveValue::CSS_PX)); + rect->setLeft(CSSPrimitiveValue::create(style->clip().left().value(), CSSPrimitiveValue::CSS_PX)); + return CSSPrimitiveValue::create(rect.release()); + } + return 0; + } + case CSSPropertyWebkitTransform: + return computedTransform(renderer); + case CSSPropertyWebkitTransformOriginX: + if (renderer) { + IntRect box = sizingBox(renderer); + return CSSPrimitiveValue::create(style->transformOriginX().calcMinValue(box.width()), CSSPrimitiveValue::CSS_PX); + } + else + return CSSPrimitiveValue::create(style->transformOriginX()); + case CSSPropertyWebkitTransformOriginY: + if (renderer) { + IntRect box = sizingBox(renderer); + return CSSPrimitiveValue::create(style->transformOriginY().calcMinValue(box.height()), CSSPrimitiveValue::CSS_PX); + } + else + return CSSPrimitiveValue::create(style->transformOriginY()); + case CSSPropertyWebkitTransitionDelay: { + RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); + const AnimationList* t = style->transitions(); + if (t) { + for (size_t i = 0; i < t->size(); ++i) + list->append(CSSPrimitiveValue::create(t->animation(i)->delay(), CSSPrimitiveValue::CSS_S)); + } + else + list->append(CSSPrimitiveValue::create(RenderStyle::initialAnimationDelay(), CSSPrimitiveValue::CSS_S)); + return list.release(); + } + case CSSPropertyWebkitTransitionDuration: { + RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); + const AnimationList* t = style->transitions(); + if (t) { + for (size_t i = 0; i < t->size(); ++i) + list->append(CSSPrimitiveValue::create(t->animation(i)->duration(), CSSPrimitiveValue::CSS_S)); + } + else + list->append(CSSPrimitiveValue::create(RenderStyle::initialAnimationDuration(), CSSPrimitiveValue::CSS_S)); + return list.release(); + } + case CSSPropertyWebkitTransitionTimingFunction: { + RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); + const AnimationList* t = style->transitions(); + if (t) { + for (size_t i = 0; i < t->size(); ++i) { + const TimingFunction& tf = t->animation(i)->timingFunction(); + list->append(CSSTimingFunctionValue::create(tf.x1(), tf.y1(), tf.x2(), tf.y2())); + } + } + else { + const TimingFunction& tf = RenderStyle::initialAnimationTimingFunction(); + list->append(CSSTimingFunctionValue::create(tf.x1(), tf.y1(), tf.x2(), tf.y2())); + } + return list.release(); + } + case CSSPropertyWebkitTransitionProperty: { + RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); + const AnimationList* t = style->transitions(); + if (t) { + for (size_t i = 0; i < t->size(); ++i) { + int prop = t->animation(i)->property(); + const char* name; + if (prop == cAnimateNone) + name = "none"; + else if (prop == cAnimateAll) + name = "all"; + else + name = getPropertyName(static_cast<CSSPropertyID>(prop)); + list->append(CSSPrimitiveValue::create(name, CSSPrimitiveValue::CSS_STRING)); + } + } + else + list->append(CSSPrimitiveValue::create("all", CSSPrimitiveValue::CSS_STRING)); + return list.release(); + } + case CSSPropertyBackground: + case CSSPropertyBorder: + case CSSPropertyBorderBottom: + case CSSPropertyBorderColor: + case CSSPropertyBorderLeft: + case CSSPropertyBorderRight: + case CSSPropertyBorderStyle: + case CSSPropertyBorderTop: + case CSSPropertyBorderWidth: + case CSSPropertyContent: + case CSSPropertyCounterIncrement: + case CSSPropertyCounterReset: + case CSSPropertyFont: + case CSSPropertyFontStretch: + case CSSPropertyListStyle: + case CSSPropertyMargin: + case CSSPropertyOutline: + case CSSPropertyOutlineOffset: + case CSSPropertyPadding: + case CSSPropertyPage: + case CSSPropertyQuotes: + case CSSPropertyScrollbar3dlightColor: + case CSSPropertyScrollbarArrowColor: + case CSSPropertyScrollbarDarkshadowColor: + case CSSPropertyScrollbarFaceColor: + case CSSPropertyScrollbarHighlightColor: + case CSSPropertyScrollbarShadowColor: + case CSSPropertyScrollbarTrackColor: + case CSSPropertySrc: // Only used in @font-face rules. + case CSSPropertySize: + case CSSPropertyTextLineThrough: + case CSSPropertyTextLineThroughColor: + case CSSPropertyTextLineThroughMode: + case CSSPropertyTextLineThroughStyle: + case CSSPropertyTextLineThroughWidth: + case CSSPropertyTextOverflow: + case CSSPropertyTextOverline: + case CSSPropertyTextOverlineColor: + case CSSPropertyTextOverlineMode: + case CSSPropertyTextOverlineStyle: + case CSSPropertyTextOverlineWidth: + case CSSPropertyTextUnderline: + case CSSPropertyTextUnderlineColor: + case CSSPropertyTextUnderlineMode: + case CSSPropertyTextUnderlineStyle: + case CSSPropertyTextUnderlineWidth: + case CSSPropertyUnicodeRange: // Only used in @font-face rules. + case CSSPropertyWebkitAnimation: + case CSSPropertyWebkitAnimationDelay: + case CSSPropertyWebkitAnimationDirection: + case CSSPropertyWebkitAnimationDuration: + case CSSPropertyWebkitAnimationIterationCount: + case CSSPropertyWebkitAnimationName: + case CSSPropertyWebkitAnimationPlayState: + case CSSPropertyWebkitAnimationTimingFunction: + case CSSPropertyWebkitBorderRadius: + case CSSPropertyWebkitColumns: + case CSSPropertyWebkitColumnRule: + case CSSPropertyWebkitMarginCollapse: + case CSSPropertyWebkitMarginStart: + case CSSPropertyWebkitMarquee: + case CSSPropertyWebkitMarqueeSpeed: + case CSSPropertyWebkitMask: + case CSSPropertyWebkitPaddingStart: + case CSSPropertyWebkitTextStroke: + case CSSPropertyWebkitTransformOrigin: + case CSSPropertyWebkitTransition: + case CSSPropertyWebkitVariableDeclarationBlock: // FIXME: The above are unimplemented. break; #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR - case CSS_PROP__WEBKIT_TAP_HIGHLIGHT_COLOR: - return new CSSPrimitiveValue(style->tapHighlightColor().rgb()); + case CSSPropertyWebkitTapHighlightColor: + return CSSPrimitiveValue::createColor(style->tapHighlightColor().rgb()); #endif #if ENABLE(SVG) + // FIXME: This default case ruins the point of using an enum for + // properties -- it prevents us from getting a warning when we + // forget to list a property above. default: return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout); #endif @@ -1022,31 +1297,31 @@ String CSSComputedStyleDeclaration::item(unsigned i) const // It is the intersection of the list of inherited CSS properties and the // properties for which we have a computed implementation in this file. const int inheritableProperties[] = { - CSS_PROP_BORDER_COLLAPSE, - CSS_PROP_COLOR, - CSS_PROP_FONT_FAMILY, - CSS_PROP_FONT_SIZE, - CSS_PROP_FONT_STYLE, - CSS_PROP_FONT_VARIANT, - CSS_PROP_FONT_WEIGHT, - CSS_PROP_LETTER_SPACING, - CSS_PROP_LINE_HEIGHT, - CSS_PROP_ORPHANS, - CSS_PROP_TEXT_ALIGN, - CSS_PROP_TEXT_INDENT, - CSS_PROP_TEXT_TRANSFORM, - CSS_PROP_WHITE_SPACE, - CSS_PROP_WIDOWS, - CSS_PROP_WORD_SPACING, - CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING, - CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING, - CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, - CSS_PROP__WEBKIT_TEXT_FILL_COLOR, - CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST, - CSS_PROP__WEBKIT_TEXT_STROKE_COLOR, - CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH, + 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 - CSS_PROP__WEBKIT_TAP_HIGHLIGHT_COLOR, + CSSPropertyWebkitTapHighlightColor, #endif }; @@ -1066,9 +1341,9 @@ PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyInherita // inherit it). Likewise for stroke color. ExceptionCode ec = 0; if (!m_node->computedStyle()->textFillColor().isValid()) - style->removeProperty(CSS_PROP__WEBKIT_TEXT_FILL_COLOR, ec); + style->removeProperty(CSSPropertyWebkitTextFillColor, ec); if (!m_node->computedStyle()->textStrokeColor().isValid()) - style->removeProperty(CSS_PROP__WEBKIT_TEXT_STROKE_COLOR, ec); + style->removeProperty(CSSPropertyWebkitTextStrokeColor, ec); ASSERT(ec == 0); } return style.release(); @@ -1084,9 +1359,4 @@ PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::makeMutable( return copy(); } -PassRefPtr<CSSComputedStyleDeclaration> computedStyle(Node* node) -{ - return new CSSComputedStyleDeclaration(node); -} - } // namespace WebCore |