diff options
author | Feng Qian <> | 2009-04-10 18:11:29 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-10 18:11:29 -0700 |
commit | 8f72e70a9fd78eec56623b3a62e68f16b7b27e28 (patch) | |
tree | 181bf9a400c30a1bf34ea6d72560e8d00111d549 /WebCore/css | |
parent | 7ed56f225e0ade046e1c2178977f72b2d896f196 (diff) | |
download | external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.zip external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.gz external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.bz2 |
AI 145796: Land the WebKit merge @r42026.
Automated import of CL 145796
Diffstat (limited to 'WebCore/css')
30 files changed, 1106 insertions, 455 deletions
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp index 73e0165..6103b2c 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -23,6 +23,7 @@ #include "config.h" #include "CSSComputedStyleDeclaration.h" +#include "AnimationController.h" #include "CSSBorderImageValue.h" #include "CSSMutableStyleDeclaration.h" #include "CSSPrimitiveValue.h" @@ -37,6 +38,7 @@ #include "Pair.h" #include "Rect.h" #include "RenderBox.h" +#include "RenderLayer.h" #include "ShadowValue.h" #ifdef ANDROID_LAYOUT #include "Frame.h" @@ -44,6 +46,7 @@ #endif #include "WebKitCSSTransformValue.h" + #if ENABLE(DASHBOARD_SUPPORT) #include "DashboardRegion.h" #endif @@ -141,9 +144,9 @@ static const int computedProperties[] = { CSSPropertyWebkitAnimationDuration, CSSPropertyWebkitAnimationIterationCount, CSSPropertyWebkitAnimationName, - CSSPropertyWebkitAnimationPlayState, CSSPropertyWebkitAnimationTimingFunction, CSSPropertyWebkitAppearance, + CSSPropertyWebkitBackfaceVisibility, CSSPropertyWebkitBackgroundClip, CSSPropertyWebkitBackgroundComposite, CSSPropertyWebkitBackgroundOrigin, @@ -191,6 +194,8 @@ static const int computedProperties[] = { CSSPropertyWebkitMaskOrigin, CSSPropertyWebkitMaskSize, CSSPropertyWebkitNbspMode, + CSSPropertyWebkitPerspective, + CSSPropertyWebkitPerspectiveOrigin, CSSPropertyWebkitRtlOrdering, CSSPropertyWebkitTextDecorationsInEffect, CSSPropertyWebkitTextFillColor, @@ -199,6 +204,7 @@ static const int computedProperties[] = { CSSPropertyWebkitTextStrokeWidth, CSSPropertyWebkitTransform, CSSPropertyWebkitTransformOrigin, + CSSPropertyWebkitTransformStyle, CSSPropertyWebkitTransitionDelay, CSSPropertyWebkitTransitionDuration, CSSPropertyWebkitTransitionProperty, @@ -410,24 +416,57 @@ static IntRect sizingBox(RenderObject* renderer) return box->style()->boxSizing() == CONTENT_BOX ? box->contentBoxRect() : box->borderBoxRect(); } -static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer) +static inline bool hasCompositedLayer(RenderObject* renderer) +{ + return renderer && renderer->hasLayer() && toRenderBoxModelObject(renderer)->layer()->isComposited(); +} + +static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style) { - if (!renderer || renderer->style()->transform().operations().isEmpty()) + if (!renderer || style->transform().operations().isEmpty()) return CSSPrimitiveValue::createIdentifier(CSSValueNone); IntRect box = sizingBox(renderer); TransformationMatrix transform; - renderer->style()->applyTransform(transform, box.size(), false); + style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin); + // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design. - RefPtr<WebKitCSSTransformValue> transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation); + RefPtr<WebKitCSSTransformValue> transformVal; - 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)); + // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924) + if (transform.isAffine()) { + 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)); + } else { + transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation); + + transformVal->append(CSSPrimitiveValue::create(transform.m11(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m12(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m13(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m14(), CSSPrimitiveValue::CSS_NUMBER)); + + transformVal->append(CSSPrimitiveValue::create(transform.m21(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m22(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m23(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m24(), CSSPrimitiveValue::CSS_NUMBER)); + + transformVal->append(CSSPrimitiveValue::create(transform.m31(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m32(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m33(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m34(), CSSPrimitiveValue::CSS_NUMBER)); + + transformVal->append(CSSPrimitiveValue::create(transform.m41(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m42(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m43(), CSSPrimitiveValue::CSS_NUMBER)); + transformVal->append(CSSPrimitiveValue::create(transform.m44(), CSSPrimitiveValue::CSS_NUMBER)); + } RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); list->append(transformVal); @@ -524,7 +563,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper RenderObject* renderer = node->renderer(); - RenderStyle* style = node->computedStyle(); + RefPtr<RenderStyle> style; + if (renderer && hasCompositedLayer(renderer) && AnimationController::supportsAcceleratedAnimationOfProperty(static_cast<CSSPropertyID>(propertyID))) + style = renderer->animation()->getAnimatedStyleForRenderer(renderer); + else + style = node->computedStyle(); if (!style) return 0; @@ -588,13 +631,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyWebkitBorderVerticalSpacing: return CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX); case CSSPropertyBorderTopColor: - return currentColorOrValidColor(style, style->borderTopColor()); + return currentColorOrValidColor(style.get(), style->borderTopColor()); case CSSPropertyBorderRightColor: - return currentColorOrValidColor(style, style->borderRightColor()); + return currentColorOrValidColor(style.get(), style->borderRightColor()); case CSSPropertyBorderBottomColor: - return currentColorOrValidColor(style, style->borderBottomColor()); + return currentColorOrValidColor(style.get(), style->borderBottomColor()); case CSSPropertyBorderLeftColor: - return currentColorOrValidColor(style, style->borderLeftColor()); + return currentColorOrValidColor(style.get(), style->borderLeftColor()); case CSSPropertyBorderTopStyle: return CSSPrimitiveValue::create(style->borderTopStyle()); case CSSPropertyBorderRightStyle: @@ -612,7 +655,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyBorderLeftWidth: return CSSPrimitiveValue::create(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX); case CSSPropertyBottom: - return getPositionOffsetValue(style, CSSPropertyBottom); + return getPositionOffsetValue(style.get(), CSSPropertyBottom); case CSSPropertyWebkitBoxAlign: return CSSPrimitiveValue::create(style->boxAlign()); case CSSPropertyWebkitBoxDirection: @@ -654,7 +697,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return CSSPrimitiveValue::createIdentifier(CSSValueNormal); return CSSPrimitiveValue::create(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyWebkitColumnRuleColor: - return currentColorOrValidColor(style, style->columnRuleColor()); + return currentColorOrValidColor(style.get(), style->columnRuleColor()); case CSSPropertyWebkitColumnRuleStyle: return CSSPrimitiveValue::create(style->columnRuleStyle()); case CSSPropertyWebkitColumnRuleWidth: @@ -747,7 +790,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return CSSPrimitiveValue::createIdentifier(CSSValueBorder); return CSSPrimitiveValue::createIdentifier(CSSValueLines); case CSSPropertyLeft: - return getPositionOffsetValue(style, CSSPropertyLeft); + return getPositionOffsetValue(style.get(), CSSPropertyLeft); case CSSPropertyLetterSpacing: if (!style->letterSpacing()) return CSSPrimitiveValue::createIdentifier(CSSValueNormal); @@ -864,7 +907,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyOrphans: return CSSPrimitiveValue::create(style->orphans(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyOutlineColor: - return currentColorOrValidColor(style, style->outlineColor()); + return currentColorOrValidColor(style.get(), style->outlineColor()); case CSSPropertyOutlineStyle: if (style->outlineStyleIsAuto()) return CSSPrimitiveValue::createIdentifier(CSSValueAuto); @@ -915,7 +958,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper #endif return CSSPrimitiveValue::create(style->position()); case CSSPropertyRight: - return getPositionOffsetValue(style, CSSPropertyRight); + return getPositionOffsetValue(style.get(), CSSPropertyRight); case CSSPropertyTableLayout: return CSSPrimitiveValue::create(style->tableLayout()); case CSSPropertyTextAlign: @@ -967,7 +1010,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_STRING); } case CSSPropertyWebkitTextFillColor: - return currentColorOrValidColor(style, style->textFillColor()); + return currentColorOrValidColor(style.get(), style->textFillColor()); case CSSPropertyTextIndent: return CSSPrimitiveValue::create(style->textIndent()); case CSSPropertyTextShadow: @@ -979,13 +1022,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return CSSPrimitiveValue::createIdentifier(CSSValueAuto); return CSSPrimitiveValue::createIdentifier(CSSValueNone); case CSSPropertyWebkitTextStrokeColor: - return currentColorOrValidColor(style, style->textStrokeColor()); + return currentColorOrValidColor(style.get(), style->textStrokeColor()); case CSSPropertyWebkitTextStrokeWidth: return CSSPrimitiveValue::create(style->textStrokeWidth(), CSSPrimitiveValue::CSS_PX); case CSSPropertyTextTransform: return CSSPrimitiveValue::create(style->textTransform()); case CSSPropertyTop: - return getPositionOffsetValue(style, CSSPropertyTop); + return getPositionOffsetValue(style.get(), CSSPropertyTop); case CSSPropertyUnicodeBidi: return CSSPrimitiveValue::create(style->unicodeBidi()); case CSSPropertyVerticalAlign: @@ -1122,7 +1165,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper if (t) { for (size_t i = 0; i < t->size(); ++i) { int iterationCount = t->animation(i)->iterationCount(); - if (iterationCount < 0) + if (iterationCount == Animation::IterationCountInfinite) list->append(CSSPrimitiveValue::createIdentifier(CSSValueInfinite)); else list->append(CSSPrimitiveValue::create(iterationCount, CSSPrimitiveValue::CSS_NUMBER)); @@ -1142,25 +1185,12 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone)); return list.release(); } - case CSSPropertyWebkitAnimationPlayState: { - RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); - const AnimationList* t = style->animations(); - if (t) { - for (size_t i = 0; i < t->size(); ++i) { - int prop = t->animation(i)->playState(); - if (prop == AnimPlayStatePlaying) - list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning)); - else - list->append(CSSPrimitiveValue::createIdentifier(CSSValuePaused)); - } - } else - list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning)); - return list.release(); - } case CSSPropertyWebkitAnimationTimingFunction: return getTimingFunctionValue(style->animations()); case CSSPropertyWebkitAppearance: return CSSPrimitiveValue::create(style->appearance()); + case CSSPropertyWebkitBackfaceVisibility: + return CSSPrimitiveValue::createIdentifier((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible); case CSSPropertyWebkitBorderImage: return valueForNinePieceImage(style->borderImage()); case CSSPropertyWebkitMaskBoxImage: @@ -1172,6 +1202,23 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return CSSPrimitiveValue::create(style->marginBottomCollapse()); case CSSPropertyWebkitMarginTopCollapse: return CSSPrimitiveValue::create(style->marginTopCollapse()); + case CSSPropertyWebkitPerspective: + if (!style->hasPerspective()) + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + return CSSPrimitiveValue::create(style->perspective(), CSSPrimitiveValue::CSS_NUMBER); + case CSSPropertyWebkitPerspectiveOrigin: { + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + if (renderer) { + IntRect box = sizingBox(renderer); + list->append(CSSPrimitiveValue::create(style->perspectiveOriginX().calcMinValue(box.width()), CSSPrimitiveValue::CSS_PX)); + list->append(CSSPrimitiveValue::create(style->perspectiveOriginY().calcMinValue(box.height()), CSSPrimitiveValue::CSS_PX)); + } + else { + list->append(CSSPrimitiveValue::create(style->perspectiveOriginX())); + list->append(CSSPrimitiveValue::create(style->perspectiveOriginY())); + } + return list.release(); + } case CSSPropertyWebkitRtlOrdering: if (style->visuallyOrdered()) return CSSPrimitiveValue::createIdentifier(CSSValueVisual); @@ -1201,19 +1248,25 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return 0; } case CSSPropertyWebkitTransform: - return computedTransform(renderer); + return computedTransform(renderer, style.get()); case CSSPropertyWebkitTransformOrigin: { RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); if (renderer) { IntRect box = sizingBox(renderer); list->append(CSSPrimitiveValue::create(style->transformOriginX().calcMinValue(box.width()), CSSPrimitiveValue::CSS_PX)); list->append(CSSPrimitiveValue::create(style->transformOriginY().calcMinValue(box.height()), CSSPrimitiveValue::CSS_PX)); + if (style->transformOriginZ() != 0) + list->append(CSSPrimitiveValue::create(style->transformOriginZ(), CSSPrimitiveValue::CSS_PX)); } else { list->append(CSSPrimitiveValue::create(style->transformOriginX())); list->append(CSSPrimitiveValue::create(style->transformOriginY())); + if (style->transformOriginZ() != 0) + list->append(CSSPrimitiveValue::create(style->transformOriginZ(), CSSPrimitiveValue::CSS_PX)); } return list.release(); } + case CSSPropertyWebkitTransformStyle: + return CSSPrimitiveValue::createIdentifier((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat); case CSSPropertyWebkitTransitionDelay: return getDelayValue(style->transitions()); case CSSPropertyWebkitTransitionDuration: @@ -1241,6 +1294,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper return getTimingFunctionValue(style->transitions()); case CSSPropertyPointerEvents: return CSSPrimitiveValue::create(style->pointerEvents()); + + /* Shorthand properties, currently not supported see bug 13658*/ case CSSPropertyBackground: case CSSPropertyBorder: case CSSPropertyBorderBottom: @@ -1250,27 +1305,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper 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: + break; + + /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */ case CSSPropertyTextLineThrough: case CSSPropertyTextLineThroughColor: case CSSPropertyTextLineThroughMode: @@ -1287,7 +1328,26 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyTextUnderlineMode: case CSSPropertyTextUnderlineStyle: case CSSPropertyTextUnderlineWidth: - case CSSPropertyUnicodeRange: // Only used in @font-face rules. + break; + + /* Unimplemented @font-face properties */ + case CSSPropertyFontStretch: + case CSSPropertySrc: + case CSSPropertyUnicodeRange: + break; + + /* Other unimplemented properties */ + case CSSPropertyContent: // FIXME: needs implementation, bug 23668 + case CSSPropertyCounterIncrement: + case CSSPropertyCounterReset: + case CSSPropertyOutline: // FIXME: needs implementation + case CSSPropertyOutlineOffset: // FIXME: needs implementation + case CSSPropertyPage: // for @page + case CSSPropertyQuotes: // FIXME: needs implementation + case CSSPropertySize: // for @page + break; + + /* Unimplemented -webkit- properties */ case CSSPropertyWebkitAnimation: case CSSPropertyWebkitBorderRadius: case CSSPropertyWebkitColumns: @@ -1301,7 +1361,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyWebkitTextStroke: case CSSPropertyWebkitTransition: case CSSPropertyWebkitVariableDeclarationBlock: - // FIXME: The above are unimplemented. break; #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR case CSSPropertyWebkitTapHighlightColor: diff --git a/WebCore/css/CSSFontSelector.cpp b/WebCore/css/CSSFontSelector.cpp index 5005c39..0e26f4e 100644 --- a/WebCore/css/CSSFontSelector.cpp +++ b/WebCore/css/CSSFontSelector.cpp @@ -93,7 +93,7 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule) RefPtr<CSSValue> fontFamily = style->getPropertyCSSValue(CSSPropertyFontFamily); RefPtr<CSSValue> src = style->getPropertyCSSValue(CSSPropertySrc); RefPtr<CSSValue> unicodeRange = style->getPropertyCSSValue(CSSPropertyUnicodeRange); - if (!fontFamily || !src || !fontFamily->isValueList() || !src->isValueList() || unicodeRange && !unicodeRange->isValueList()) + if (!fontFamily || !src || !fontFamily->isValueList() || !src->isValueList() || (unicodeRange && !unicodeRange->isValueList())) return; CSSValueList* familyList = static_cast<CSSValueList*>(fontFamily.get()); @@ -433,7 +433,9 @@ static inline bool compareFontFaces(CSSFontFace* first, CSSFontFace* second) // or the next darker otherwise." // For '400', we made up our own rule (which then '500' follows). - static const FontTraitsMask weightFallbackRules[9][8] = { + static const unsigned fallbackRuleSets = 9; + static const unsigned rulesPerSet = 8; + static const FontTraitsMask weightFallbackRuleSets[fallbackRuleSets][rulesPerSet] = { { FontWeight200Mask, FontWeight300Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask }, { FontWeight100Mask, FontWeight300Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask }, { FontWeight200Mask, FontWeight100Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask }, @@ -445,14 +447,16 @@ static inline bool compareFontFaces(CSSFontFace* first, CSSFontFace* second) { FontWeight800Mask, FontWeight700Mask, FontWeight600Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask } }; - const FontTraitsMask* weightFallbackRule = weightFallbackRules[0]; + unsigned ruleSetIndex = 0; unsigned w = FontWeight100Bit; while (!(desiredTraitsMaskForComparison & (1 << w))) { w++; - weightFallbackRule += 8; + ruleSetIndex++; } - for (unsigned i = 0; i < 8; ++i) { + ASSERT(ruleSetIndex < fallbackRuleSets); + const FontTraitsMask* weightFallbackRule = weightFallbackRuleSets[ruleSetIndex]; + for (unsigned i = 0; i < rulesPerSet; ++i) { if (secondTraitsMask & weightFallbackRule[i]) return false; if (firstTraitsMask & weightFallbackRule[i]) diff --git a/WebCore/css/CSSGrammar.y b/WebCore/css/CSSGrammar.y index 1ff48bb..451591d 100644 --- a/WebCore/css/CSSGrammar.y +++ b/WebCore/css/CSSGrammar.y @@ -1180,7 +1180,7 @@ pseudo: } // used by :not | ':' NOTFUNCTION maybe_space simple_selector maybe_space ')' { - if (!$4) + if (!$4 || $4->simpleSelector() || $4->tagHistory()) $$ = 0; else { CSSParser* p = static_cast<CSSParser*>(parser); diff --git a/WebCore/css/CSSMutableStyleDeclaration.cpp b/WebCore/css/CSSMutableStyleDeclaration.cpp index 2e2064a..cf50306 100644 --- a/WebCore/css/CSSMutableStyleDeclaration.cpp +++ b/WebCore/css/CSSMutableStyleDeclaration.cpp @@ -81,7 +81,7 @@ CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const CS , m_iteratorCount(0) #endif { - m_properties.reserveCapacity(numProperties); + m_properties.reserveInitialCapacity(numProperties); for (int i = 0; i < numProperties; ++i) { ASSERT(properties[i]); m_properties.append(*properties[i]); @@ -217,9 +217,10 @@ String CSSMutableStyleDeclaration::getPropertyValue(int propertyID) const return getLayeredShorthandValue(properties, 6); } case CSSPropertyWebkitTransformOrigin: { - const int properties[2] = { CSSPropertyWebkitTransformOriginX, - CSSPropertyWebkitTransformOriginY }; - return getShorthandValue(properties, 2); + const int properties[3] = { CSSPropertyWebkitTransformOriginX, + CSSPropertyWebkitTransformOriginY, + CSSPropertyWebkitTransformOriginZ }; + return getShorthandValue(properties, 3); } case CSSPropertyWebkitTransition: { const int properties[4] = { CSSPropertyWebkitTransitionProperty, CSSPropertyWebkitTransitionDuration, @@ -701,8 +702,8 @@ void CSSMutableStyleDeclaration::removePropertiesInSet(const int* set, unsigned for (unsigned i = 0; i < length; ++i) toRemove.add(set[i]); - Vector<CSSProperty> newProperties; - newProperties.reserveCapacity(m_properties.size()); + Vector<CSSProperty, 4> newProperties; + newProperties.reserveInitialCapacity(m_properties.size()); unsigned size = m_properties.size(); for (unsigned n = 0; n < size; ++n) { diff --git a/WebCore/css/CSSMutableStyleDeclaration.h b/WebCore/css/CSSMutableStyleDeclaration.h index 9c84916..7951388 100644 --- a/WebCore/css/CSSMutableStyleDeclaration.h +++ b/WebCore/css/CSSMutableStyleDeclaration.h @@ -157,7 +157,7 @@ private: Vector<CSSProperty>::const_iterator findPropertyWithId(int propertyId) const; Vector<CSSProperty>::iterator findPropertyWithId(int propertyId); - Vector<CSSProperty> m_properties; + Vector<CSSProperty, 4> m_properties; Node* m_node; unsigned m_variableDependentValueCount : 24; diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index e420a5f..98d670b 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -366,6 +366,8 @@ void CSSParser::addProperty(int propId, PassRefPtr<CSSValue> value, bool importa CSSProperty* prop = new CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand); if (m_numParsedProperties >= m_maxParsedProperties) { m_maxParsedProperties += 32; + if (m_maxParsedProperties > UINT_MAX / sizeof(CSSProperty*)) + return; m_parsedProperties = static_cast<CSSProperty**>(fastRealloc(m_parsedProperties, m_maxParsedProperties * sizeof(CSSProperty*))); } @@ -375,7 +377,7 @@ void CSSParser::addProperty(int propId, PassRefPtr<CSSValue> value, bool importa void CSSParser::rollbackLastProperties(int num) { ASSERT(num >= 0); - ASSERT(m_numParsedProperties >= num); + ASSERT(m_numParsedProperties >= static_cast<unsigned>(num)); for (int i = 0; i < num; ++i) delete m_parsedProperties[--m_numParsedProperties]; @@ -383,7 +385,7 @@ void CSSParser::rollbackLastProperties(int num) void CSSParser::clearProperties() { - for (int i = 0; i < m_numParsedProperties; i++) + for (unsigned i = 0; i < m_numParsedProperties; i++) delete m_parsedProperties[i]; m_numParsedProperties = 0; m_hasFontFaceOnlyValues = false; @@ -764,16 +766,6 @@ bool CSSParser::parseValue(int propId, bool important) case CSSPropertyWebkitBorderVerticalSpacing: valid_primitive = validUnit(value, FLength|FNonNeg, m_strict); break; - case CSSPropertyScrollbarFaceColor: // IE5.5 - case CSSPropertyScrollbarShadowColor: // IE5.5 - case CSSPropertyScrollbarHighlightColor: // IE5.5 - case CSSPropertyScrollbar3dlightColor: // IE5.5 - case CSSPropertyScrollbarDarkshadowColor: // IE5.5 - case CSSPropertyScrollbarTrackColor: // IE5.5 - case CSSPropertyScrollbarArrowColor: // IE5.5 - if (m_strict) - break; - /* nobreak */ case CSSPropertyOutlineColor: // <color> | invert | inherit // Outline color has "invert" as additional keyword. // Also, we want to allow the special focus color even in strict parsing mode. @@ -799,7 +791,7 @@ bool CSSParser::parseValue(int propId, bool important) // since we use this in our UA sheets. else if (id == CSSValueCurrentcolor) valid_primitive = true; - else if (id >= CSSValueAqua && id <= CSSValueWindowtext || id == CSSValueMenu || + else if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu || (id >= CSSValueWebkitFocusRingColor && id < CSSValueWebkitText && !m_strict)) { valid_primitive = true; } else { @@ -834,7 +826,7 @@ bool CSSParser::parseValue(int propId, bool important) } else if (m_strict && nrcoords == 2) hotspot = IntPoint(coords[0], coords[1]); if (m_strict || coords.size() == 0) { - if (!uri.isNull()) + if (!uri.isNull() && m_styleSheet) list->append(CSSCursorImageValue::create(m_styleSheet->completeURL(uri), hotspot)); } if ((m_strict && !value) || (value && !(value->unit == CSSParserValue::Operator && value->iValue == ','))) @@ -900,7 +892,7 @@ bool CSSParser::parseValue(int propId, bool important) } else if (value->unit == CSSPrimitiveValue::CSS_URI) { // ### allow string in non strict mode? String uri = parseURL(value->string); - if (!uri.isNull()) { + if (!uri.isNull() && m_styleSheet) { parsedValue = CSSImageValue::create(m_styleSheet->completeURL(uri)); m_valueList->next(); } @@ -1112,7 +1104,7 @@ bool CSSParser::parseValue(int propId, bool important) CSSParserValue* val; RefPtr<CSSValue> parsedValue; while ((val = m_valueList->current())) { - if (val->unit == CSSPrimitiveValue::CSS_URI) { + if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) { String value = parseURL(val->string); parsedValue = CSSPrimitiveValue::create(m_styleSheet->completeURL(value), CSSPrimitiveValue::CSS_URI); } @@ -1298,11 +1290,51 @@ bool CSSParser::parseValue(int propId, bool important) break; case CSSPropertyWebkitTransformOrigin: case CSSPropertyWebkitTransformOriginX: - case CSSPropertyWebkitTransformOriginY: { + case CSSPropertyWebkitTransformOriginY: + case CSSPropertyWebkitTransformOriginZ: { + RefPtr<CSSValue> val1; + RefPtr<CSSValue> val2; + RefPtr<CSSValue> val3; + int propId1, propId2, propId3; + if (parseTransformOrigin(propId, propId1, propId2, propId3, val1, val2, val3)) { + addProperty(propId1, val1.release(), important); + if (val2) + addProperty(propId2, val2.release(), important); + if (val3) + addProperty(propId3, val3.release(), important); + return true; + } + return false; + } + case CSSPropertyWebkitTransformStyle: + if (value->id == CSSValueFlat || value->id == CSSValuePreserve3d) + valid_primitive = true; + break; + case CSSPropertyWebkitBackfaceVisibility: + if (value->id == CSSValueVisible || value->id == CSSValueHidden) + valid_primitive = true; + break; + case CSSPropertyWebkitPerspective: + if (id == CSSValueNone) + valid_primitive = true; + else { + if (validUnit(value, FNumber|FNonNeg, m_strict)) { + RefPtr<CSSValue> val = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit); + if (val) { + addProperty(propId, val.release(), important); + return true; + } + return false; + } + } + break; + case CSSPropertyWebkitPerspectiveOrigin: + case CSSPropertyWebkitPerspectiveOriginX: + case CSSPropertyWebkitPerspectiveOriginY: { RefPtr<CSSValue> val1; RefPtr<CSSValue> val2; int propId1, propId2; - if (parseTransformOrigin(propId, propId1, propId2, val1, val2)) { + if (parsePerspectiveOrigin(propId, propId1, propId2, val1, val2)) { addProperty(propId1, val1.release(), important); if (val2) addProperty(propId2, val2.release(), important); @@ -1314,7 +1346,6 @@ bool CSSParser::parseValue(int propId, bool important) case CSSPropertyWebkitAnimationDirection: case CSSPropertyWebkitAnimationDuration: case CSSPropertyWebkitAnimationName: - case CSSPropertyWebkitAnimationPlayState: case CSSPropertyWebkitAnimationIterationCount: case CSSPropertyWebkitAnimationTimingFunction: case CSSPropertyWebkitTransitionDelay: @@ -1974,7 +2005,7 @@ bool CSSParser::parseContent(int propId, bool important) while (CSSParserValue* val = m_valueList->current()) { RefPtr<CSSValue> parsedValue; - if (val->unit == CSSPrimitiveValue::CSS_URI) { + if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) { // url String value = parseURL(val->string); parsedValue = CSSImageValue::create(m_styleSheet->completeURL(value)); @@ -2047,7 +2078,7 @@ bool CSSParser::parseFillImage(RefPtr<CSSValue>& value) } if (m_valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { String uri = parseURL(m_valueList->current()->string); - if (!uri.isNull()) + if (!uri.isNull() && m_styleSheet) value = CSSImageValue::create(m_styleSheet->completeURL(uri)); return true; } @@ -2216,7 +2247,10 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, case CSSPropertyWebkitBackgroundOrigin: case CSSPropertyWebkitMaskClip: case CSSPropertyWebkitMaskOrigin: - if (val->id == CSSValueBorder || val->id == CSSValuePadding || val->id == CSSValueContent || val->id == CSSValueText) { + // The first three values here are deprecated and should not be allowed to apply when we drop the -webkit- + // from the property names. + if (val->id == CSSValueBorder || val->id == CSSValuePadding || val->id == CSSValueContent || + val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueContentBox || val->id == CSSValueText) { currValue = CSSPrimitiveValue::createIdentifier(val->id); m_valueList->next(); } @@ -2224,7 +2258,7 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, case CSSPropertyBackgroundPosition: case CSSPropertyWebkitMaskPosition: parseFillPosition(currValue, currValue2); - // unlike the other functions, parseFillPosition advances the m_valueList pointer + // parseFillPosition advances the m_valueList pointer break; case CSSPropertyBackgroundPositionX: case CSSPropertyWebkitMaskPositionX: { @@ -2356,14 +2390,6 @@ PassRefPtr<CSSValue> CSSParser::parseAnimationName() return 0; } -PassRefPtr<CSSValue> CSSParser::parseAnimationPlayState() -{ - CSSParserValue* value = m_valueList->current(); - if (value->id == CSSValueRunning || value->id == CSSValuePaused) - return CSSPrimitiveValue::createIdentifier(value->id); - return 0; -} - PassRefPtr<CSSValue> CSSParser::parseAnimationProperty() { CSSParserValue* value = m_valueList->current(); @@ -2379,6 +2405,18 @@ PassRefPtr<CSSValue> CSSParser::parseAnimationProperty() return 0; } +void CSSParser::parseTransformOriginShorthand(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3) +{ + parseFillPosition(value1, value2); + + // now get z + if (m_valueList->current() && validUnit(m_valueList->current(), FLength, m_strict)) + value3 = CSSPrimitiveValue::create(m_valueList->current()->fValue, + (CSSPrimitiveValue::UnitTypes)m_valueList->current()->unit); + if (value3) + m_valueList->next(); +} + bool CSSParser::parseTimingFunctionValue(CSSParserValueList*& args, double& result) { CSSParserValue* v = args->current(); @@ -2473,11 +2511,6 @@ bool CSSParser::parseAnimationProperty(int propId, RefPtr<CSSValue>& result) if (currValue) m_valueList->next(); break; - case CSSPropertyWebkitAnimationPlayState: - currValue = parseAnimationPlayState(); - if (currValue) - m_valueList->next(); - break; case CSSPropertyWebkitTransitionProperty: currValue = parseAnimationProperty(); if (currValue) @@ -3096,7 +3129,7 @@ bool CSSParser::parseFontFaceSrc() RefPtr<CSSFontFaceSrcValue> uriValue; while ((val = m_valueList->current())) { RefPtr<CSSFontFaceSrcValue> parsedValue; - if (val->unit == CSSPrimitiveValue::CSS_URI && !expectComma) { + if (val->unit == CSSPrimitiveValue::CSS_URI && !expectComma && m_styleSheet) { String value = parseURL(val->string); parsedValue = CSSFontFaceSrcValue::create(m_styleSheet->completeURL(value)); uriValue = parsedValue; @@ -3475,7 +3508,7 @@ bool CSSParser::parseShadow(int propId, bool important) else { // The only other type of value that's ok is a color value. RefPtr<CSSPrimitiveValue> parsedColor; - bool isColor = (val->id >= CSSValueAqua && val->id <= CSSValueWindowtext || val->id == CSSValueMenu || + bool isColor = ((val->id >= CSSValueAqua && val->id <= CSSValueWindowtext) || val->id == CSSValueMenu || (val->id >= CSSValueWebkitFocusRingColor && val->id <= CSSValueWebkitText && !m_strict)); if (isColor) { if (!context.allowColor) @@ -3697,7 +3730,7 @@ bool CSSParser::parseBorderImage(int propId, bool important, RefPtr<CSSValue>& r // Look for an image initially. If the first value is not a URI, then we're done. BorderImageParseContext context; CSSParserValue* val = m_valueList->current(); - if (val->unit == CSSPrimitiveValue::CSS_URI) { + if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) { String uri = parseURL(val->string); if (uri.isNull()) return false; @@ -4014,17 +4047,37 @@ public: , m_allowSingleArgument(false) , m_unit(CSSParser::FUnknown) { - if (equalIgnoringCase(name, "scale(") || equalIgnoringCase(name, "scalex(") || equalIgnoringCase(name, "scaley(")) { + if (equalIgnoringCase(name, "scale(") || equalIgnoringCase(name, "scalex(") || equalIgnoringCase(name, "scaley(") || equalIgnoringCase(name, "scalez(")) { m_unit = CSSParser::FNumber; if (equalIgnoringCase(name, "scale(")) m_type = WebKitCSSTransformValue::ScaleTransformOperation; else if (equalIgnoringCase(name, "scalex(")) m_type = WebKitCSSTransformValue::ScaleXTransformOperation; - else + else if (equalIgnoringCase(name, "scaley(")) m_type = WebKitCSSTransformValue::ScaleYTransformOperation; + else + m_type = WebKitCSSTransformValue::ScaleZTransformOperation; + } else if (equalIgnoringCase(name, "scale3d(")) { + m_type = WebKitCSSTransformValue::Scale3DTransformOperation; + m_argCount = 5; + m_unit = CSSParser::FNumber; } else if (equalIgnoringCase(name, "rotate(")) { m_type = WebKitCSSTransformValue::RotateTransformOperation; m_unit = CSSParser::FAngle; + } else if (equalIgnoringCase(name, "rotatex(") || + equalIgnoringCase(name, "rotatey(") || + equalIgnoringCase(name, "rotatez(")) { + m_unit = CSSParser::FAngle; + if (equalIgnoringCase(name, "rotatex(")) + m_type = WebKitCSSTransformValue::RotateXTransformOperation; + else if (equalIgnoringCase(name, "rotatey(")) + m_type = WebKitCSSTransformValue::RotateYTransformOperation; + else + m_type = WebKitCSSTransformValue::RotateZTransformOperation; + } else if (equalIgnoringCase(name, "rotate3d(")) { + m_type = WebKitCSSTransformValue::Rotate3DTransformOperation; + m_argCount = 7; + m_unit = CSSParser::FNumber; } else if (equalIgnoringCase(name, "skew(") || equalIgnoringCase(name, "skewx(") || equalIgnoringCase(name, "skewy(")) { m_unit = CSSParser::FAngle; if (equalIgnoringCase(name, "skew(")) @@ -4033,20 +4086,33 @@ public: m_type = WebKitCSSTransformValue::SkewXTransformOperation; else m_type = WebKitCSSTransformValue::SkewYTransformOperation; - } else if (equalIgnoringCase(name, "translate(") || equalIgnoringCase(name, "translatex(") || equalIgnoringCase(name, "translatey(")) { + } else if (equalIgnoringCase(name, "translate(") || equalIgnoringCase(name, "translatex(") || equalIgnoringCase(name, "translatey(") || equalIgnoringCase(name, "translatez(")) { m_unit = CSSParser::FLength | CSSParser::FPercent; if (equalIgnoringCase(name, "translate(")) m_type = WebKitCSSTransformValue::TranslateTransformOperation; else if (equalIgnoringCase(name, "translatex(")) m_type = WebKitCSSTransformValue::TranslateXTransformOperation; - else + else if (equalIgnoringCase(name, "translatey(")) m_type = WebKitCSSTransformValue::TranslateYTransformOperation; + else + m_type = WebKitCSSTransformValue::TranslateZTransformOperation; + } else if (equalIgnoringCase(name, "translate3d(")) { + m_type = WebKitCSSTransformValue::Translate3DTransformOperation; + m_argCount = 5; + m_unit = CSSParser::FLength | CSSParser::FPercent; } else if (equalIgnoringCase(name, "matrix(")) { m_type = WebKitCSSTransformValue::MatrixTransformOperation; m_argCount = 11; m_unit = CSSParser::FNumber; + } else if (equalIgnoringCase(name, "matrix3d(")) { + m_type = WebKitCSSTransformValue::Matrix3DTransformOperation; + m_argCount = 31; + m_unit = CSSParser::FNumber; + } else if (equalIgnoringCase(name, "perspective(")) { + m_type = WebKitCSSTransformValue::PerspectiveTransformOperation; + m_unit = CSSParser::FNumber; } - + if (equalIgnoringCase(name, "scale(") || equalIgnoringCase(name, "skew(") || equalIgnoringCase(name, "translate(")) { m_allowSingleArgument = true; m_argCount = 3; @@ -4102,7 +4168,11 @@ PassRefPtr<CSSValueList> CSSParser::parseTransform() while (a) { CSSParser::Units unit = info.unit(); - if (!validUnit(a, unit, true)) + // 4th param of rotate3d() is an angle rather than a bare number, validate it as such + if (info.type() == WebKitCSSTransformValue::Rotate3DTransformOperation && argNumber == 3) { + if (!validUnit(a, FAngle, true)) + return 0; + } else if (!validUnit(a, unit, true)) return 0; // Add the value to the current transform operation. @@ -4122,19 +4192,21 @@ PassRefPtr<CSSValueList> CSSParser::parseTransform() return list.release(); } -bool CSSParser::parseTransformOrigin(int propId, int& propId1, int& propId2, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2) +bool CSSParser::parseTransformOrigin(int propId, int& propId1, int& propId2, int& propId3, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3) { propId1 = propId; propId2 = propId; + propId3 = propId; if (propId == CSSPropertyWebkitTransformOrigin) { propId1 = CSSPropertyWebkitTransformOriginX; propId2 = CSSPropertyWebkitTransformOriginY; + propId3 = CSSPropertyWebkitTransformOriginZ; } switch (propId) { case CSSPropertyWebkitTransformOrigin: - parseFillPosition(value, value2); - // Unlike the other functions, parseFillPosition advances the m_valueList pointer + parseTransformOriginShorthand(value, value2, value3); + // parseTransformOriginShorthand advances the m_valueList pointer break; case CSSPropertyWebkitTransformOriginX: { bool xFound = false, yFound = true; @@ -4150,6 +4222,45 @@ bool CSSParser::parseTransformOrigin(int propId, int& propId1, int& propId2, Ref m_valueList->next(); break; } + case CSSPropertyWebkitTransformOriginZ: { + if (validUnit(m_valueList->current(), FLength, m_strict)) + value = CSSPrimitiveValue::create(m_valueList->current()->fValue, (CSSPrimitiveValue::UnitTypes)m_valueList->current()->unit); + if (value) + m_valueList->next(); + break; + } + } + + return value; +} + +bool CSSParser::parsePerspectiveOrigin(int propId, int& propId1, int& propId2, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2) +{ + propId1 = propId; + propId2 = propId; + if (propId == CSSPropertyWebkitPerspectiveOrigin) { + propId1 = CSSPropertyWebkitPerspectiveOriginX; + propId2 = CSSPropertyWebkitPerspectiveOriginY; + } + + switch (propId) { + case CSSPropertyWebkitPerspectiveOrigin: + parseFillPosition(value, value2); + break; + case CSSPropertyWebkitPerspectiveOriginX: { + bool xFound = false, yFound = true; + value = parseFillPositionXY(xFound, yFound); + if (value) + m_valueList->next(); + break; + } + case CSSPropertyWebkitPerspectiveOriginY: { + bool xFound = true, yFound = false; + value = parseFillPositionXY(xFound, yFound); + if (value) + m_valueList->next(); + break; + } } return value; @@ -4566,7 +4677,7 @@ CSSRule* CSSParser::createStyleRule(Vector<CSSSelector*>* selectors) CSSRule* CSSParser::createFontFaceRule() { RefPtr<CSSFontFaceRule> rule = CSSFontFaceRule::create(m_styleSheet); - for (int i = 0; i < m_numParsedProperties; ++i) { + for (unsigned i = 0; i < m_numParsedProperties; ++i) { CSSProperty* property = m_parsedProperties[i]; int id = property->id(); if ((id == CSSPropertyFontWeight || id == CSSPropertyFontStyle || id == CSSPropertyFontVariant) && property->value()->isPrimitiveValue()) { @@ -4707,7 +4818,7 @@ void CSSParser::deleteFontFaceOnlyValues() ASSERT(m_hasFontFaceOnlyValues); int deletedProperties = 0; - for (int i = 0; i < m_numParsedProperties; ++i) { + for (unsigned i = 0; i < m_numParsedProperties; ++i) { CSSProperty* property = m_parsedProperties[i]; int id = property->id(); if ((id == CSSPropertyFontWeight || id == CSSPropertyFontStyle || id == CSSPropertyFontVariant) && property->value()->isValueList()) { diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h index 83aafa4..3b07ef9 100644 --- a/WebCore/css/CSSParser.h +++ b/WebCore/css/CSSParser.h @@ -94,10 +94,10 @@ namespace WebCore { PassRefPtr<CSSValue> parseAnimationDuration(); PassRefPtr<CSSValue> parseAnimationIterationCount(); PassRefPtr<CSSValue> parseAnimationName(); - PassRefPtr<CSSValue> parseAnimationPlayState(); PassRefPtr<CSSValue> parseAnimationProperty(); PassRefPtr<CSSValue> parseAnimationTimingFunction(); + void parseTransformOriginShorthand(RefPtr<CSSValue>&, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parseTimingFunctionValue(CSSParserValueList*& args, double& result); bool parseAnimationProperty(int propId, RefPtr<CSSValue>&); bool parseTransitionShorthand(bool important); @@ -145,8 +145,8 @@ namespace WebCore { bool parseGradient(RefPtr<CSSValue>&); PassRefPtr<CSSValueList> parseTransform(); - bool parseTransformOrigin(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&); - + bool parseTransformOrigin(int propId, int& propId1, int& propId2, int& propId3, RefPtr<CSSValue>&, RefPtr<CSSValue>&, RefPtr<CSSValue>&); + bool parsePerspectiveOrigin(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parseVariable(CSSVariablesDeclaration*, const String& variableName, const String& variableValue); void parsePropertyWithResolvedVariables(int propId, bool important, CSSMutableStyleDeclaration*, CSSParserValueList*); @@ -200,8 +200,8 @@ namespace WebCore { CSSParserValueList* m_valueList; CSSProperty** m_parsedProperties; CSSSelectorList* m_selectorListForParseSelector; - int m_numParsedProperties; - int m_maxParsedProperties; + unsigned m_numParsedProperties; + unsigned m_maxParsedProperties; int m_inParseShorthand; int m_currentShorthand; diff --git a/WebCore/css/CSSPrimitiveValue.cpp b/WebCore/css/CSSPrimitiveValue.cpp index 43fb70b..4bf6005 100644 --- a/WebCore/css/CSSPrimitiveValue.cpp +++ b/WebCore/css/CSSPrimitiveValue.cpp @@ -768,7 +768,7 @@ String CSSPrimitiveValue::cssText() const Rect* rectVal = getRectValue(); Vector<UChar> result; - result.reserveCapacity(32); + result.reserveInitialCapacity(32); append(result, rectParen); append(result, rectVal->top()->cssText()); @@ -797,7 +797,7 @@ String CSSPrimitiveValue::cssText() const Color color(rgbColor); Vector<UChar> result; - result.reserveCapacity(32); + result.reserveInitialCapacity(32); if (color.hasAlpha()) append(result, rgbaParen); else diff --git a/WebCore/css/CSSPrimitiveValue.h b/WebCore/css/CSSPrimitiveValue.h index d552ca0..ece9fc5 100644 --- a/WebCore/css/CSSPrimitiveValue.h +++ b/WebCore/css/CSSPrimitiveValue.h @@ -81,6 +81,8 @@ public: // This unit is in CSS 3, but that isn't a finished standard yet CSS_TURN = 108 }; + + static bool isUnitTypeLength(int type) { return type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG; } static PassRefPtr<CSSPrimitiveValue> createIdentifier(int ident); static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue); diff --git a/WebCore/css/CSSPrimitiveValueMappings.h b/WebCore/css/CSSPrimitiveValueMappings.h index 1712372..fd1d203 100644 --- a/WebCore/css/CSSPrimitiveValueMappings.h +++ b/WebCore/css/CSSPrimitiveValueMappings.h @@ -29,7 +29,12 @@ #include "CSSPrimitiveValue.h" #include "CSSValueKeywords.h" -#include "RenderStyle.h" +#include "GraphicsTypes.h" +#include "Path.h" +#include "RenderStyleConstants.h" +#include "SVGRenderStyleDefs.h" +#include "TextDirection.h" +#include "ThemeTypes.h" namespace WebCore { @@ -292,13 +297,13 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFillBox e) { switch (e) { case BorderFillBox: - m_value.ident = CSSValueBorder; + m_value.ident = CSSValueBorderBox; break; case PaddingFillBox: - m_value.ident = CSSValuePadding; + m_value.ident = CSSValuePaddingBox; break; case ContentFillBox: - m_value.ident = CSSValueContent; + m_value.ident = CSSValueContentBox; break; case TextFillBox: m_value.ident = CSSValueText; @@ -310,10 +315,13 @@ template<> inline CSSPrimitiveValue::operator EFillBox() const { switch (m_value.ident) { case CSSValueBorder: + case CSSValueBorderBox: return BorderFillBox; case CSSValuePadding: + case CSSValuePaddingBox: return PaddingFillBox; case CSSValueContent: + case CSSValueContentBox: return ContentFillBox; case CSSValueText: return TextFillBox; diff --git a/WebCore/css/CSSPropertyNames.in b/WebCore/css/CSSPropertyNames.in index 3ad83dc..fd101e4 100644 --- a/WebCore/css/CSSPropertyNames.in +++ b/WebCore/css/CSSPropertyNames.in @@ -99,13 +99,6 @@ position quotes resize right -scrollbar-3dlight-color -scrollbar-arrow-color -scrollbar-darkshadow-color -scrollbar-face-color -scrollbar-highlight-color -scrollbar-shadow-color -scrollbar-track-color size src table-layout @@ -149,9 +142,9 @@ zoom -webkit-animation-duration -webkit-animation-iteration-count -webkit-animation-name --webkit-animation-play-state -webkit-animation-timing-function -webkit-appearance +-webkit-backface-visibility -webkit-background-clip -webkit-background-composite -webkit-background-origin @@ -217,6 +210,10 @@ zoom -webkit-match-nearest-mail-blockquote-color -webkit-nbsp-mode -webkit-padding-start +-webkit-perspective +-webkit-perspective-origin +-webkit-perspective-origin-x +-webkit-perspective-origin-y -webkit-rtl-ordering # ANDROID_CSS_TAP_HIGHLIGHT_COLOR: added CSS property (also in iPhone) -webkit-tap-highlight-color @@ -232,6 +229,8 @@ zoom -webkit-transform-origin -webkit-transform-origin-x -webkit-transform-origin-y +-webkit-transform-origin-z +-webkit-transform-style -webkit-transition -webkit-transition-delay -webkit-transition-duration diff --git a/WebCore/css/CSSSelectorList.cpp b/WebCore/css/CSSSelectorList.cpp index 7276141..5ad3809 100644 --- a/WebCore/css/CSSSelectorList.cpp +++ b/WebCore/css/CSSSelectorList.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -54,7 +55,11 @@ void CSSSelectorList::adoptSelectorVector(Vector<CSSSelector*>& selectorVector) m_selectorArray = reinterpret_cast<CSSSelector*>(fastMalloc(sizeof(CSSSelector) * selectorVector.size())); for (size_t i = 0; i < size; ++i) { memcpy(&m_selectorArray[i], selectorVector[i], sizeof(CSSSelector)); - fastFree(selectorVector[i]); + // We want to free the memory (which was allocated with new), but we + // don't want the destructor to run since it will affect the copy + // we've just made. In theory this is undefined, but operator delete + // is only defined taking a void*, so in practice it should be ok. + delete reinterpret_cast<char*>(selectorVector[i]); ASSERT(!m_selectorArray[i].isLastInSelectorList()); } m_selectorArray[size - 1].setLastInSelectorList(); @@ -65,15 +70,25 @@ void CSSSelectorList::deleteSelectors() { if (!m_selectorArray) return; + + // We had two cases in adoptSelectVector. The fast case of a 1 element + // vector took the CSSSelector directly, which was allocated with new. + // The second case we allocated a new fastMalloc buffer, which should be + // freed with fastFree, and the destructors called manually. CSSSelector* s = m_selectorArray; - while (1) { - bool done = s->isLastInSelectorList(); - s->~CSSSelector(); - if (done) - break; - ++s; + bool done = s->isLastInSelectorList(); + if (done) + delete s; + else { + while (1) { + s->~CSSSelector(); + if (done) + break; + ++s; + done = s->isLastInSelectorList(); + } + fastFree(m_selectorArray); } - fastFree(m_selectorArray); } } diff --git a/WebCore/css/CSSStyleDeclaration.cpp b/WebCore/css/CSSStyleDeclaration.cpp index b840e07..a35f817 100644 --- a/WebCore/css/CSSStyleDeclaration.cpp +++ b/WebCore/css/CSSStyleDeclaration.cpp @@ -142,7 +142,7 @@ void CSSStyleDeclaration::diff(CSSMutableStyleDeclaration* style) const PassRefPtr<CSSMutableStyleDeclaration> CSSStyleDeclaration::copyPropertiesInSet(const int* set, unsigned length) const { Vector<CSSProperty> list; - list.reserveCapacity(length); + list.reserveInitialCapacity(length); unsigned variableDependentValueCount = 0; for (unsigned i = 0; i < length; i++) { RefPtr<CSSValue> value = getPropertyCSSValue(set[i]); diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp index bfe0315..42b07ef 100644 --- a/WebCore/css/CSSStyleSelector.cpp +++ b/WebCore/css/CSSStyleSelector.cpp @@ -5,7 +5,7 @@ * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> - * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) + * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -63,15 +63,18 @@ #include "HTMLTextAreaElement.h" #include "LinkHash.h" #include "MatrixTransformOperation.h" +#include "Matrix3DTransformOperation.h" #include "MediaList.h" #include "MediaQueryEvaluator.h" #include "NodeRenderStyle.h" #include "Page.h" #include "PageGroup.h" #include "Pair.h" +#include "PerspectiveTransformOperation.h" #include "Rect.h" #include "RenderScrollbar.h" #include "RenderScrollbarTheme.h" +#include "RenderStyleConstants.h" #include "RenderTheme.h" #include "RotateTransformOperation.h" #include "ScaleTransformOperation.h" @@ -83,6 +86,7 @@ #include "StyleGeneratedImage.h" #include "StyleSheetList.h" #include "Text.h" +#include "TransformationMatrix.h" #include "TranslateTransformOperation.h" #include "UserAgentStyleSheets.h" #include "WebKitCSSKeyframeRule.h" @@ -370,11 +374,11 @@ static PseudoState pseudoState; static void loadFullDefaultStyle(); static void loadSimpleDefaultStyle(); // FIXME: It would be nice to use some mechanism that guarantees this is in sync with the real UA stylesheet. -static const char* simpleUserAgentStyleSheet = "html,body,div{display:block}body{margin:8px}div:focus,span:focus{outline:auto 5px -webkit-focus-ring-color}"; +static const char* simpleUserAgentStyleSheet = "html,body,div{display:block}body{margin:8px}div:focus,span:focus{outline:auto 5px -webkit-focus-ring-color}a:-webkit-any-link{color:-webkit-link;text-decoration:underline}a:-webkit-any-link:active{color:-webkit-activelink}"; static bool elementCanUseSimpleDefaultStyle(Element* e) { - return e->hasTagName(htmlTag) || e->hasTagName(bodyTag) || e->hasTagName(divTag) || e->hasTagName(spanTag) || e->hasTagName(brTag); + return e->hasTagName(htmlTag) || e->hasTagName(bodyTag) || e->hasTagName(divTag) || e->hasTagName(spanTag) || e->hasTagName(brTag) || e->hasTagName(aTag); } static const MediaQueryEvaluator& screenEval() @@ -683,10 +687,10 @@ void CSSStyleSelector::matchRulesForList(CSSRuleDataList* rules, int& firstRuleI // If we're matching normal rules, set a pseudo bit if // we really just matched a pseudo-element. - if (m_dynamicPseudo != RenderStyle::NOPSEUDO && m_checker.m_pseudoStyle == RenderStyle::NOPSEUDO) { + if (m_dynamicPseudo != NOPSEUDO && m_checker.m_pseudoStyle == NOPSEUDO) { if (m_checker.m_collectRulesOnly) return; - if (m_dynamicPseudo < RenderStyle::FIRST_INTERNAL_PSEUDOID) + if (m_dynamicPseudo < FIRST_INTERNAL_PSEUDOID) m_style->setHasPseudoStyle(m_dynamicPseudo); } else { // Update our first/last rule indices in the matched rules array. @@ -753,7 +757,7 @@ void CSSStyleSelector::sortMatchedRules(unsigned start, unsigned end) // We have to merge sort. Ensure our merge buffer is big enough to hold // all the items. Vector<CSSRuleData*> rulesMergeBuffer; - rulesMergeBuffer.reserveCapacity(end - start); + rulesMergeBuffer.reserveInitialCapacity(end - start); unsigned i1 = start; unsigned i2 = mid; @@ -787,7 +791,7 @@ void CSSStyleSelector::initElementAndPseudoState(Element* e) pseudoState = PseudoUnknown; } -void CSSStyleSelector::initForStyleResolve(Element* e, RenderStyle* parentStyle, RenderStyle::PseudoId pseudoID) +void CSSStyleSelector::initForStyleResolve(Element* e, RenderStyle* parentStyle, PseudoId pseudoID) { m_checker.m_pseudoStyle = pseudoID; @@ -845,7 +849,7 @@ CSSStyleSelector::SelectorChecker::SelectorChecker(Document* document, bool stri : m_document(document) , m_strictParsing(strictParsing) , m_collectRulesOnly(false) - , m_pseudoStyle(RenderStyle::NOPSEUDO) + , m_pseudoStyle(NOPSEUDO) , m_documentIsHTML(document->isHTMLDocument()) { } @@ -878,7 +882,7 @@ PseudoState CSSStyleSelector::SelectorChecker::checkPseudoState(Element* element bool CSSStyleSelector::SelectorChecker::checkSelector(CSSSelector* sel, Element* element) const { pseudoState = PseudoUnknown; - RenderStyle::PseudoId dynamicPseudo = RenderStyle::NOPSEUDO; + PseudoId dynamicPseudo = NOPSEUDO; return checkSelector(sel, element, 0, dynamicPseudo, true, false) == SelectorMatches; } @@ -933,21 +937,35 @@ bool CSSStyleSelector::canShareStyleWithElement(Node* n) (s->hovered() == m_element->hovered()) && (s->active() == m_element->active()) && (s->focused() == m_element->focused()) && - (s != s->document()->getCSSTarget() && m_element != m_element->document()->getCSSTarget()) && + (s != s->document()->cssTarget() && m_element != m_element->document()->cssTarget()) && (s->getAttribute(typeAttr) == m_element->getAttribute(typeAttr)) && (s->getAttribute(XMLNames::langAttr) == m_element->getAttribute(XMLNames::langAttr)) && (s->getAttribute(langAttr) == m_element->getAttribute(langAttr)) && (s->getAttribute(readonlyAttr) == m_element->getAttribute(readonlyAttr)) && (s->getAttribute(cellpaddingAttr) == m_element->getAttribute(cellpaddingAttr))) { - bool isControl = s->isControl(); - if (isControl != m_element->isControl()) + bool isControl = s->isFormControlElement(); + if (isControl != m_element->isFormControlElement()) return false; - if (isControl && (s->isEnabled() != m_element->isEnabled()) || - (s->isIndeterminate() != m_element->isIndeterminate()) || - (s->isChecked() != m_element->isChecked()) || - (s->isAutofilled() != m_element->isAutofilled())) - return false; - + if (isControl) { + InputElement* thisInputElement = toInputElement(s); + InputElement* otherInputElement = toInputElement(m_element); + if (thisInputElement && otherInputElement) { + if ((thisInputElement->isAutofilled() != otherInputElement->isAutofilled()) || + (thisInputElement->isChecked() != otherInputElement->isChecked()) || + (thisInputElement->isIndeterminate() != otherInputElement->isIndeterminate())) + return false; + } else + return false; + + FormControlElement* thisFormControlElement = toFormControlElement(s); + FormControlElement* otherFormControlElement = toFormControlElement(m_element); + if (thisFormControlElement && otherFormControlElement) { + if (thisFormControlElement->isEnabled() != otherFormControlElement->isEnabled()) + return false; + } else + return false; + } + if (style->transitions() || style->animations()) return false; @@ -1211,7 +1229,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl m_style->setPseudoState(pseudoState); // If we have first-letter pseudo style, do not share this style - if (m_style->hasPseudoStyle(RenderStyle::FIRST_LETTER)) + if (m_style->hasPseudoStyle(FIRST_LETTER)) m_style->setUnique(); // Now return the style. @@ -1293,7 +1311,7 @@ void CSSStyleSelector::keyframeStylesForAnimation(Element* e, const RenderStyle* list.clear(); } -PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(RenderStyle::PseudoId pseudo, Element* e, RenderStyle* parentStyle) +PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle) { if (!e) return 0; @@ -1427,7 +1445,10 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e) // Table headers with a text-align of auto will change the text-align to center. if (e && e->hasTagName(thTag) && style->textAlign() == TAAUTO) style->setTextAlign(CENTER); - + + if (e && e->hasTagName(legendTag)) + style->setDisplay(BLOCK); + // Mutate the display to BLOCK or TABLE for certain cases, e.g., if someone attempts to // position or float an inline, compact, or run-in. Cache the original display, since it // may be needed for positioned elements that have to compute their static normal flow @@ -1466,7 +1487,7 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e) // cases where objects that should be blended as a single unit end up with a non-transparent // object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms/masks/reflections. if (style->hasAutoZIndex() && ((e && e->document()->documentElement() == e) || style->opacity() < 1.0f || - style->hasTransform() || style->hasMask() || style->boxReflect())) + style->hasTransformRelatedProperty() || style->hasMask() || style->boxReflect())) style->setZIndex(0); // Button, legend, input, select and textarea all consider width values of 'auto' to be 'intrinsic'. @@ -1480,6 +1501,12 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e) )) { if (style->width().isAuto()) style->setWidth(Length(Intrinsic)); + + // Textarea considers overflow visible as auto. + if (e && e->hasTagName(textareaTag)) { + style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->overflowX()); + style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->overflowY()); + } } // Finally update our text decorations in effect, but don't allow text-decoration to percolate through @@ -1526,7 +1553,7 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e) // Important: Intrinsic margins get added to controls before the theme has adjusted the style, since the theme will // alter fonts and heights/widths. - if (e && e->isControl() && style->fontSize() >= 11) { + if (e && e->isFormControlElement() && style->fontSize() >= 11) { // Don't apply intrinsic margins to image buttons. The designer knows how big the images are, // so we have to treat all image buttons as though they were explicitly sized. if (!e->hasTagName(inputTag) || static_cast<HTMLInputElement*>(e)->inputType() != HTMLInputElement::IMAGE) @@ -1617,14 +1644,14 @@ PassRefPtr<CSSRuleList> CSSStyleSelector::pseudoStyleRulesForElement(Element*, c bool CSSStyleSelector::checkSelector(CSSSelector* sel) { - m_dynamicPseudo = RenderStyle::NOPSEUDO; + m_dynamicPseudo = NOPSEUDO; // Check the selector SelectorMatch match = m_checker.checkSelector(sel, m_element, &m_selectorAttrs, m_dynamicPseudo, true, false, style(), m_parentStyle); if (match != SelectorMatches) return false; - if (m_checker.m_pseudoStyle != RenderStyle::NOPSEUDO && m_checker.m_pseudoStyle != m_dynamicPseudo) + if (m_checker.m_pseudoStyle != NOPSEUDO && m_checker.m_pseudoStyle != m_dynamicPseudo) return false; return true; @@ -1635,7 +1662,7 @@ bool CSSStyleSelector::checkSelector(CSSSelector* sel) // * SelectorMatches - the selector matches the element e // * SelectorFailsLocally - the selector fails for the element e // * SelectorFailsCompletely - the selector fails for e and any sibling or ancestor of e -CSSStyleSelector::SelectorMatch CSSStyleSelector::SelectorChecker::checkSelector(CSSSelector* sel, Element* e, HashSet<AtomicStringImpl*>* selectorAttrs, RenderStyle::PseudoId& dynamicPseudo, bool isAncestor, bool isSubSelector, RenderStyle* elementStyle, RenderStyle* elementParentStyle) const +CSSStyleSelector::SelectorMatch CSSStyleSelector::SelectorChecker::checkSelector(CSSSelector* sel, Element* e, HashSet<AtomicStringImpl*>* selectorAttrs, PseudoId& dynamicPseudo, bool isAncestor, bool isSubSelector, RenderStyle* elementStyle, RenderStyle* elementParentStyle) const { #if ENABLE(SVG) // Spec: CSS2 selectors cannot be applied to the (conceptually) cloned DOM tree @@ -1658,7 +1685,7 @@ CSSStyleSelector::SelectorMatch CSSStyleSelector::SelectorChecker::checkSelector if (relation != CSSSelector::SubSelector) // Bail-out if this selector is irrelevant for the pseudoStyle - if (m_pseudoStyle != RenderStyle::NOPSEUDO && m_pseudoStyle != dynamicPseudo) + if (m_pseudoStyle != NOPSEUDO && m_pseudoStyle != dynamicPseudo) return SelectorFailsCompletely; switch (relation) { @@ -1718,8 +1745,8 @@ CSSStyleSelector::SelectorMatch CSSStyleSelector::SelectorChecker::checkSelector // a selector is invalid if something follows a pseudo-element // We make an exception for scrollbar pseudo elements and allow a set of pseudo classes (but nothing else) // to follow the pseudo elements. - if (elementStyle && dynamicPseudo != RenderStyle::NOPSEUDO && - !((RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == RenderStyle::SCROLLBAR_CORNER || dynamicPseudo == RenderStyle::RESIZER) && sel->m_match == CSSSelector::PseudoClass)) + if (elementStyle && dynamicPseudo != NOPSEUDO && dynamicPseudo != SELECTION && + !((RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER) && sel->m_match == CSSSelector::PseudoClass)) return SelectorFailsCompletely; return checkSelector(sel, e, selectorAttrs, dynamicPseudo, isAncestor, true, elementStyle, elementParentStyle); } @@ -1794,7 +1821,7 @@ static bool htmlAttributeHasCaseInsensitiveValue(const QualifiedName& attr) return isPossibleHTMLAttr && htmlCaseInsensitiveAttributesSet->contains(attr.localName().impl()); } -bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Element* e, HashSet<AtomicStringImpl*>* selectorAttrs, RenderStyle::PseudoId& dynamicPseudo, bool isAncestor, bool isSubSelector, RenderStyle* elementStyle, RenderStyle* elementParentStyle) const +bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Element* e, HashSet<AtomicStringImpl*>* selectorAttrs, PseudoId& dynamicPseudo, bool isAncestor, bool isSubSelector, RenderStyle* elementStyle, RenderStyle* elementParentStyle) const { if (!e) return false; @@ -1892,15 +1919,19 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme for (CSSSelector* subSel = sel->simpleSelector(); subSel; subSel = subSel->tagHistory()) { // :not cannot nest. I don't really know why this is a // restriction in CSS3, but it is, so let's honor it. - if (subSel->simpleSelector()) - break; + // the parser enforces that this never occurs + ASSERT(!subSel->simpleSelector()); + if (!checkOneSelector(subSel, e, selectorAttrs, dynamicPseudo, isAncestor, true, elementStyle, elementParentStyle)) return true; } - } else if (dynamicPseudo != RenderStyle::NOPSEUDO && (RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == RenderStyle::SCROLLBAR_CORNER || dynamicPseudo == RenderStyle::RESIZER)) { + } else if (dynamicPseudo != NOPSEUDO && (RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER)) { // CSS scrollbars match a specific subset of pseudo classes, and they have specialized rules for each // (since there are no elements involved). return checkScrollbarPseudoClass(sel, dynamicPseudo); + } else if (dynamicPseudo == SELECTION) { + if (sel->pseudoType() == CSSSelector::PseudoWindowInactive) + return !m_document->page()->focusController()->isActive(); } // Normal element pseudo class checking. @@ -2195,7 +2226,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme break; } case CSSSelector::PseudoTarget: - if (e == e->document()->getCSSTarget()) + if (e == e->document()->cssTarget()) return true; break; case CSSSelector::PseudoAnyLink: @@ -2204,10 +2235,13 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme if (pseudoState == PseudoAnyLink || pseudoState == PseudoLink || pseudoState == PseudoVisited) return true; break; - case CSSSelector::PseudoAutofill: - if (e) - return e->isAutofilled(); + case CSSSelector::PseudoAutofill: { + if (!e || !e->isFormControlElement()) + break; + if (InputElement* inputElement = toInputElement(e)) + return inputElement->isAutofilled(); break; + } case CSSSelector::PseudoLink: if (pseudoState == PseudoUnknown || pseudoState == PseudoAnyLink) pseudoState = checkPseudoState(e); @@ -2259,37 +2293,62 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme } break; case CSSSelector::PseudoEnabled: - if (e && e->isControl() && !e->isInputTypeHidden()) + if (e && e->isFormControlElement()) { + InputElement* inputElement = toInputElement(e); + if (inputElement && inputElement->isInputTypeHidden()) + break; // The UI spec states that you can't match :enabled unless you are an object that can // "receive focus and be activated." We will limit matching of this pseudo-class to elements // that are non-"hidden" controls. - return e->isEnabled(); + return toFormControlElement(e)->isEnabled(); + } break; case CSSSelector::PseudoFullPageMedia: return e && e->document() && e->document()->isMediaDocument(); break; case CSSSelector::PseudoDisabled: - if (e && e->isControl() && !e->isInputTypeHidden()) + if (e && e->isFormControlElement()) { + InputElement* inputElement = toInputElement(e); + if (inputElement && inputElement->isInputTypeHidden()) + break; + // The UI spec states that you can't match :enabled unless you are an object that can // "receive focus and be activated." We will limit matching of this pseudo-class to elements // that are non-"hidden" controls. - return !e->isEnabled(); + return !toFormControlElement(e)->isEnabled(); + } break; - case CSSSelector::PseudoReadOnly: - return e && e->isTextControl() && e->isReadOnlyControl(); - case CSSSelector::PseudoReadWrite: - return e && e->isTextControl() && !e->isReadOnlyControl(); - case CSSSelector::PseudoChecked: + case CSSSelector::PseudoReadOnly: { + if (!e || !e->isFormControlElement()) + return false; + FormControlElement* formControlElement = toFormControlElement(e); + return formControlElement->isTextControl() && formControlElement->isReadOnlyControl(); + } + case CSSSelector::PseudoReadWrite: { + if (!e || !e->isFormControlElement()) + return false; + FormControlElement* formControlElement = toFormControlElement(e); + return formControlElement->isTextControl() && !formControlElement->isReadOnlyControl(); + } + case CSSSelector::PseudoChecked: { + if (!e || !e->isFormControlElement()) + break; // Even though WinIE allows checked and indeterminate to co-exist, the CSS selector spec says that // you can't be both checked and indeterminate. We will behave like WinIE behind the scenes and just // obey the CSS spec here in the test for matching the pseudo. - if (e && e->isChecked() && !e->isIndeterminate()) + InputElement* inputElement = toInputElement(e); + if (inputElement && inputElement->isChecked() && !inputElement->isIndeterminate()) return true; break; - case CSSSelector::PseudoIndeterminate: - if (e && e->isIndeterminate()) + } + case CSSSelector::PseudoIndeterminate: { + if (!e || !e->isFormControlElement()) + break; + InputElement* inputElement = toInputElement(e); + if (inputElement && inputElement->isIndeterminate()) return true; break; + } case CSSSelector::PseudoRoot: if (e == e->document()->documentElement()) return true; @@ -2333,93 +2392,93 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme switch (sel->pseudoType()) { // Pseudo-elements: case CSSSelector::PseudoFirstLine: - dynamicPseudo = RenderStyle::FIRST_LINE; + dynamicPseudo = FIRST_LINE; return true; case CSSSelector::PseudoFirstLetter: - dynamicPseudo = RenderStyle::FIRST_LETTER; + dynamicPseudo = FIRST_LETTER; if (Document* doc = e->document()) doc->setUsesFirstLetterRules(true); return true; case CSSSelector::PseudoSelection: - dynamicPseudo = RenderStyle::SELECTION; + dynamicPseudo = SELECTION; return true; case CSSSelector::PseudoBefore: - dynamicPseudo = RenderStyle::BEFORE; + dynamicPseudo = BEFORE; return true; case CSSSelector::PseudoAfter: - dynamicPseudo = RenderStyle::AFTER; + dynamicPseudo = AFTER; return true; case CSSSelector::PseudoFileUploadButton: - dynamicPseudo = RenderStyle::FILE_UPLOAD_BUTTON; + dynamicPseudo = FILE_UPLOAD_BUTTON; return true; case CSSSelector::PseudoInputPlaceholder: - dynamicPseudo = RenderStyle::INPUT_PLACEHOLDER; + dynamicPseudo = INPUT_PLACEHOLDER; return true; case CSSSelector::PseudoSliderThumb: - dynamicPseudo = RenderStyle::SLIDER_THUMB; + dynamicPseudo = SLIDER_THUMB; return true; case CSSSelector::PseudoSearchCancelButton: - dynamicPseudo = RenderStyle::SEARCH_CANCEL_BUTTON; + dynamicPseudo = SEARCH_CANCEL_BUTTON; return true; case CSSSelector::PseudoSearchDecoration: - dynamicPseudo = RenderStyle::SEARCH_DECORATION; + dynamicPseudo = SEARCH_DECORATION; return true; case CSSSelector::PseudoSearchResultsDecoration: - dynamicPseudo = RenderStyle::SEARCH_RESULTS_DECORATION; + dynamicPseudo = SEARCH_RESULTS_DECORATION; return true; case CSSSelector::PseudoSearchResultsButton: - dynamicPseudo = RenderStyle::SEARCH_RESULTS_BUTTON; + dynamicPseudo = SEARCH_RESULTS_BUTTON; return true; case CSSSelector::PseudoMediaControlsPanel: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_PANEL; + dynamicPseudo = MEDIA_CONTROLS_PANEL; return true; case CSSSelector::PseudoMediaControlsMuteButton: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_MUTE_BUTTON; + dynamicPseudo = MEDIA_CONTROLS_MUTE_BUTTON; return true; case CSSSelector::PseudoMediaControlsPlayButton: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_PLAY_BUTTON; + dynamicPseudo = MEDIA_CONTROLS_PLAY_BUTTON; return true; case CSSSelector::PseudoMediaControlsTimelineContainer: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_TIMELINE_CONTAINER; + dynamicPseudo = MEDIA_CONTROLS_TIMELINE_CONTAINER; return true; case CSSSelector::PseudoMediaControlsCurrentTimeDisplay: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_CURRENT_TIME_DISPLAY; + dynamicPseudo = MEDIA_CONTROLS_CURRENT_TIME_DISPLAY; return true; case CSSSelector::PseudoMediaControlsTimeRemainingDisplay: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_TIME_REMAINING_DISPLAY; + dynamicPseudo = MEDIA_CONTROLS_TIME_REMAINING_DISPLAY; return true; case CSSSelector::PseudoMediaControlsTimeline: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_TIMELINE; + dynamicPseudo = MEDIA_CONTROLS_TIMELINE; return true; case CSSSelector::PseudoMediaControlsSeekBackButton: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_SEEK_BACK_BUTTON; + dynamicPseudo = MEDIA_CONTROLS_SEEK_BACK_BUTTON; return true; case CSSSelector::PseudoMediaControlsSeekForwardButton: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_SEEK_FORWARD_BUTTON; + dynamicPseudo = MEDIA_CONTROLS_SEEK_FORWARD_BUTTON; return true; case CSSSelector::PseudoMediaControlsFullscreenButton: - dynamicPseudo = RenderStyle::MEDIA_CONTROLS_FULLSCREEN_BUTTON; + dynamicPseudo = MEDIA_CONTROLS_FULLSCREEN_BUTTON; return true; case CSSSelector::PseudoScrollbar: - dynamicPseudo = RenderStyle::SCROLLBAR; + dynamicPseudo = SCROLLBAR; return true; case CSSSelector::PseudoScrollbarButton: - dynamicPseudo = RenderStyle::SCROLLBAR_BUTTON; + dynamicPseudo = SCROLLBAR_BUTTON; return true; case CSSSelector::PseudoScrollbarCorner: - dynamicPseudo = RenderStyle::SCROLLBAR_CORNER; + dynamicPseudo = SCROLLBAR_CORNER; return true; case CSSSelector::PseudoScrollbarThumb: - dynamicPseudo = RenderStyle::SCROLLBAR_THUMB; + dynamicPseudo = SCROLLBAR_THUMB; return true; case CSSSelector::PseudoScrollbarTrack: - dynamicPseudo = RenderStyle::SCROLLBAR_TRACK; + dynamicPseudo = SCROLLBAR_TRACK; return true; case CSSSelector::PseudoScrollbarTrackPiece: - dynamicPseudo = RenderStyle::SCROLLBAR_TRACK_PIECE; + dynamicPseudo = SCROLLBAR_TRACK_PIECE; return true; case CSSSelector::PseudoResizer: - dynamicPseudo = RenderStyle::RESIZER; + dynamicPseudo = RESIZER; return true; case CSSSelector::PseudoUnknown: case CSSSelector::PseudoNotParsed: @@ -2433,7 +2492,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme return true; } -bool CSSStyleSelector::SelectorChecker::checkScrollbarPseudoClass(CSSSelector* sel, RenderStyle::PseudoId&) const +bool CSSStyleSelector::SelectorChecker::checkScrollbarPseudoClass(CSSSelector* sel, PseudoId&) const { RenderScrollbar* scrollbar = RenderScrollbar::scrollbarForStyleResolve(); ScrollbarPart part = RenderScrollbar::partForStyleResolve(); @@ -2644,7 +2703,7 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat // ------------------------------------------------------------------------------------- // this is mostly boring stuff on how to apply a certain rule to the renderstyle... -static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *style, bool *ok = 0) +static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *style, double multiplier = 1, bool *ok = 0) { // This function is tolerant of a null style value. The only place style is used is in // length measurements, like 'ems' and 'px'. And in those cases style is only used @@ -2659,8 +2718,8 @@ static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *st if (!style && (type == CSSPrimitiveValue::CSS_EMS || type == CSSPrimitiveValue::CSS_EXS)) { if (ok) *ok = false; - } else if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) - l = Length(primitiveValue->computeLengthIntForLength(style), Fixed); + } else if (CSSPrimitiveValue::isUnitTypeLength(type)) + l = Length(primitiveValue->computeLengthIntForLength(style, multiplier), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); else if (type == CSSPrimitiveValue::CSS_NUMBER) @@ -2957,7 +3016,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) } if (m_style->setFontDescription(fontDescription)) m_fontDirty = true; - return; + return; } case CSSPropertyFontWeight: @@ -3175,7 +3234,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) HANDLE_INHERIT_AND_INITIAL(horizontalBorderSpacing, HorizontalBorderSpacing) if (!primitiveValue) return; - short spacing = primitiveValue->computeLengthShort(style(), zoomFactor); + short spacing = primitiveValue->computeLengthShort(style(), zoomFactor); m_style->setHorizontalBorderSpacing(spacing); return; } @@ -3183,7 +3242,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) HANDLE_INHERIT_AND_INITIAL(verticalBorderSpacing, VerticalBorderSpacing) if (!primitiveValue) return; - short spacing = primitiveValue->computeLengthShort(style(), zoomFactor); + short spacing = primitiveValue->computeLengthShort(style(), zoomFactor); m_style->setVerticalBorderSpacing(spacing); return; } @@ -3553,7 +3612,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) if (primitiveValue && !apply) { int type = primitiveValue->primitiveType(); - if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) + if (CSSPrimitiveValue::isUnitTypeLength(type)) // Handle our quirky margin units if we have them. l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed, primitiveValue->isQuirkValue()); @@ -3654,7 +3713,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) if (primitiveValue && !apply) { unsigned short type = primitiveValue->primitiveType(); - if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) + if (CSSPrimitiveValue::isUnitTypeLength(type)) l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); @@ -3710,7 +3769,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) } else { int type = primitiveValue->primitiveType(); Length l; - if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) + if (CSSPrimitiveValue::isUnitTypeLength(type)) l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); @@ -3774,7 +3833,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) (type != CSSPrimitiveValue::CSS_PERCENTAGE && type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS)); - if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) + if (CSSPrimitiveValue::isUnitTypeLength(type)) size = primitiveValue->computeLengthFloat(m_parentStyle, true); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) size = (primitiveValue->getFloatValue() * oldSize) / 100.0f; @@ -3837,7 +3896,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) int type = primitiveValue->primitiveType(); if (primitiveValue->getIdent() == CSSValueNormal) lineHeight = Length(-100.0, Percent); - else if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) { + else if (CSSPrimitiveValue::isUnitTypeLength(type)) { double multiplier = m_style->effectiveZoom(); if (m_style->textSizeAdjust() && m_checker.m_document->frame() && m_checker.m_document->frame()->shouldApplyTextZoom()) multiplier *= m_checker.m_document->frame()->textZoomFactor(); @@ -3882,8 +3941,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) right = m_parentStyle->clipRight(); bottom = m_parentStyle->clipBottom(); left = m_parentStyle->clipLeft(); - } - else { + } else { hasClip = false; top = right = bottom = left = Length(); } @@ -3896,11 +3954,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) Rect* rect = primitiveValue->getRectValue(); if (!rect) return; - top = convertToLength(rect->top(), style()); - right = convertToLength(rect->right(), style()); - bottom = convertToLength(rect->bottom(), style()); - left = convertToLength(rect->left(), style()); - + top = convertToLength(rect->top(), style(), zoomFactor); + right = convertToLength(rect->right(), style(), zoomFactor); + bottom = convertToLength(rect->bottom(), style(), zoomFactor); + left = convertToLength(rect->left(), style(), zoomFactor); } else if (primitiveValue->getIdent() != CSSValueAuto) { return; } @@ -3948,7 +4005,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) break; case CSSPrimitiveValue::CSS_ATTR: { // FIXME: Can a namespace be specified for an attr(foo)? - if (m_style->styleType() == RenderStyle::NOPSEUDO) + if (m_style->styleType() == NOPSEUDO) m_style->setUnique(); else m_parentStyle->setUnique(); @@ -4281,6 +4338,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) m_fontDirty = true; } else if (isInitial) { Settings* settings = m_checker.m_document->settings(); + ASSERT(settings); // If we're doing style resolution, this document should always be in a frame and thus have settings + if (!settings) + return; FontDescription fontDescription; fontDescription.setGenericFamily(FontDescription::StandardFamily); fontDescription.setRenderingMode(settings->fontRenderingMode()); @@ -4307,6 +4367,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) if (fontDescription.isAbsoluteSize()) { // Make sure the rendering mode and printer font settings are updated. Settings* settings = m_checker.m_document->settings(); + ASSERT(settings); // If we're doing style resolution, this document should always be in a frame and thus have settings + if (!settings) + return; fontDescription.setRenderingMode(settings->fontRenderingMode()); fontDescription.setUsePrinterFont(m_checker.m_document->printing()); @@ -4566,21 +4629,26 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) return; case CSSPropertyUnicodeRange: // Only used in @font-face rules. return; + case CSSPropertyWebkitBackfaceVisibility: + HANDLE_INHERIT_AND_INITIAL(backfaceVisibility, BackfaceVisibility) + if (primitiveValue) + m_style->setBackfaceVisibility((primitiveValue->getIdent() == CSSValueVisible) ? BackfaceVisibilityVisible : BackfaceVisibilityHidden); + return; case CSSPropertyWebkitBoxDirection: HANDLE_INHERIT_AND_INITIAL(boxDirection, BoxDirection) if (primitiveValue) m_style->setBoxDirection(*primitiveValue); - return; + return; case CSSPropertyWebkitBoxLines: HANDLE_INHERIT_AND_INITIAL(boxLines, BoxLines) if (primitiveValue) m_style->setBoxLines(*primitiveValue); - return; + return; case CSSPropertyWebkitBoxOrient: HANDLE_INHERIT_AND_INITIAL(boxOrient, BoxOrient) if (primitiveValue) m_style->setBoxOrient(*primitiveValue); - return; + return; case CSSPropertyWebkitBoxPack: { HANDLE_INHERIT_AND_INITIAL(boxPack, BoxPack) @@ -4602,7 +4670,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER) return; // Error case. m_style->setBoxFlexGroup((unsigned int)(primitiveValue->getDoubleValue())); - return; + return; case CSSPropertyWebkitBoxOrdinalGroup: HANDLE_INHERIT_AND_INITIAL(boxOrdinalGroup, BoxOrdinalGroup) if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER) @@ -4764,7 +4832,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) } else { bool ok = true; - Length l = convertToLength(primitiveValue, style(), &ok); + Length l = convertToLength(primitiveValue, style(), 1, &ok); if (ok) m_style->setMarqueeIncrement(l); } @@ -4941,13 +5009,14 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) case CSSPropertyWebkitTransformOrigin: HANDLE_INHERIT_AND_INITIAL(transformOriginX, TransformOriginX) HANDLE_INHERIT_AND_INITIAL(transformOriginY, TransformOriginY) + HANDLE_INHERIT_AND_INITIAL(transformOriginZ, TransformOriginZ) return; case CSSPropertyWebkitTransformOriginX: { HANDLE_INHERIT_AND_INITIAL(transformOriginX, TransformOriginX) CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); Length l; int type = primitiveValue->primitiveType(); - if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) + if (CSSPrimitiveValue::isUnitTypeLength(type)) l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); @@ -4961,7 +5030,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); Length l; int type = primitiveValue->primitiveType(); - if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) + if (CSSPrimitiveValue::isUnitTypeLength(type)) l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); else if(type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); @@ -4970,6 +5039,69 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) m_style->setTransformOriginY(l); break; } + case CSSPropertyWebkitTransformOriginZ: { + HANDLE_INHERIT_AND_INITIAL(transformOriginZ, TransformOriginZ) + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + float f; + int type = primitiveValue->primitiveType(); + if (CSSPrimitiveValue::isUnitTypeLength(type)) + f = static_cast<float>(primitiveValue->computeLengthIntForLength(style())); + else + return; + m_style->setTransformOriginZ(f); + break; + } + case CSSPropertyWebkitTransformStyle: + HANDLE_INHERIT_AND_INITIAL(transformStyle3D, TransformStyle3D) + if (primitiveValue) + m_style->setTransformStyle3D((primitiveValue->getIdent() == CSSValuePreserve3d) ? TransformStyle3DPreserve3D : TransformStyle3DFlat); + return; + case CSSPropertyWebkitPerspective: { + HANDLE_INHERIT_AND_INITIAL(perspective, Perspective) + if (primitiveValue && primitiveValue->getIdent() == CSSValueNone) { + m_style->setPerspective(0); + return; + } + + if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER) + return; + float perspectiveValue = static_cast<float>(primitiveValue->getDoubleValue()); + if (perspectiveValue >= 0.0f) + m_style->setPerspective(perspectiveValue); + return; + } + case CSSPropertyWebkitPerspectiveOrigin: + HANDLE_INHERIT_AND_INITIAL(perspectiveOriginX, PerspectiveOriginX) + HANDLE_INHERIT_AND_INITIAL(perspectiveOriginY, PerspectiveOriginY) + return; + case CSSPropertyWebkitPerspectiveOriginX: { + HANDLE_INHERIT_AND_INITIAL(perspectiveOriginX, PerspectiveOriginX) + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Length l; + int type = primitiveValue->primitiveType(); + if (CSSPrimitiveValue::isUnitTypeLength(type)) + l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); + else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) + l = Length(primitiveValue->getDoubleValue(), Percent); + else + return; + m_style->setPerspectiveOriginX(l); + return; + } + case CSSPropertyWebkitPerspectiveOriginY: { + HANDLE_INHERIT_AND_INITIAL(perspectiveOriginY, PerspectiveOriginY) + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Length l; + int type = primitiveValue->primitiveType(); + if (CSSPrimitiveValue::isUnitTypeLength(type)) + l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); + else if(type == CSSPrimitiveValue::CSS_PERCENTAGE) + l = Length(primitiveValue->getDoubleValue(), Percent); + else + return; + m_style->setPerspectiveOriginY(l); + return; + } case CSSPropertyWebkitAnimation: if (isInitial) m_style->clearAnimations(); @@ -4991,9 +5123,6 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) case CSSPropertyWebkitAnimationName: HANDLE_ANIMATION_VALUE(name, Name, value) return; - case CSSPropertyWebkitAnimationPlayState: - HANDLE_ANIMATION_VALUE(playState, PlayState, value) - return; case CSSPropertyWebkitAnimationTimingFunction: HANDLE_ANIMATION_VALUE(timingFunction, TimingFunction, value) return; @@ -5035,13 +5164,6 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) case CSSPropertyFontStretch: case CSSPropertyPage: case CSSPropertyQuotes: - case CSSPropertyScrollbar3dlightColor: - case CSSPropertyScrollbarArrowColor: - case CSSPropertyScrollbarDarkshadowColor: - case CSSPropertyScrollbarFaceColor: - case CSSPropertyScrollbarHighlightColor: - case CSSPropertyScrollbarShadowColor: - case CSSPropertyScrollbarTrackColor: case CSSPropertySize: case CSSPropertyTextLineThrough: case CSSPropertyTextLineThroughColor: @@ -5212,7 +5334,7 @@ void CSSStyleSelector::mapFillSize(FillLayer* layer, CSSValue* value) if (firstType == CSSPrimitiveValue::CSS_UNKNOWN) firstLength = Length(Auto); - else if (firstType > CSSPrimitiveValue::CSS_PERCENTAGE && firstType < CSSPrimitiveValue::CSS_DEG) + else if (CSSPrimitiveValue::isUnitTypeLength(firstType)) firstLength = Length(first->computeLengthIntForLength(style(), zoomFactor), Fixed); else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE) firstLength = Length(first->getDoubleValue(), Percent); @@ -5221,7 +5343,7 @@ void CSSStyleSelector::mapFillSize(FillLayer* layer, CSSValue* value) if (secondType == CSSPrimitiveValue::CSS_UNKNOWN) secondLength = Length(Auto); - else if (secondType > CSSPrimitiveValue::CSS_PERCENTAGE && secondType < CSSPrimitiveValue::CSS_DEG) + else if (CSSPrimitiveValue::isUnitTypeLength(secondType)) secondLength = Length(second->computeLengthIntForLength(style(), zoomFactor), Fixed); else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE) secondLength = Length(second->getDoubleValue(), Percent); @@ -5248,7 +5370,7 @@ void CSSStyleSelector::mapFillXPosition(FillLayer* layer, CSSValue* value) CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); Length l; int type = primitiveValue->primitiveType(); - if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) + if (CSSPrimitiveValue::isUnitTypeLength(type)) l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); @@ -5272,7 +5394,7 @@ void CSSStyleSelector::mapFillYPosition(FillLayer* layer, CSSValue* value) CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); Length l; int type = primitiveValue->primitiveType(); - if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) + if (CSSPrimitiveValue::isUnitTypeLength(type)) l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed); else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) l = Length(primitiveValue->getDoubleValue(), Percent); @@ -5303,7 +5425,7 @@ void CSSStyleSelector::mapAnimationDirection(Animation* layer, CSSValue* value) } CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - layer->setDirection(primitiveValue->getIdent() == CSSValueAlternate); + layer->setDirection(primitiveValue->getIdent() == CSSValueAlternate ? Animation::AnimationDirectionAlternate : Animation::AnimationDirectionNormal); } void CSSStyleSelector::mapAnimationDuration(Animation* animation, CSSValue* value) @@ -5355,17 +5477,6 @@ void CSSStyleSelector::mapAnimationName(Animation* layer, CSSValue* value) layer->setName(primitiveValue->getStringValue()); } -void CSSStyleSelector::mapAnimationPlayState(Animation* layer, CSSValue* value) -{ - if (value->cssValueType() == CSSValue::CSS_INITIAL) { - layer->setPlayState(Animation::initialAnimationPlayState()); - return; - } - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - layer->setPlayState((primitiveValue->getIdent() == CSSValuePaused) ? AnimPlayStatePaused : AnimPlayStatePlaying); -} - void CSSStyleSelector::mapAnimationProperty(Animation* animation, CSSValue* value) { if (value->cssValueType() == CSSValue::CSS_INITIAL) { @@ -5775,21 +5886,33 @@ static TransformOperation::OperationType getTransformOperationType(WebKitCSSTran case WebKitCSSTransformValue::ScaleTransformOperation: return TransformOperation::SCALE; case WebKitCSSTransformValue::ScaleXTransformOperation: return TransformOperation::SCALE_X; case WebKitCSSTransformValue::ScaleYTransformOperation: return TransformOperation::SCALE_Y; + case WebKitCSSTransformValue::ScaleZTransformOperation: return TransformOperation::SCALE_Z; + case WebKitCSSTransformValue::Scale3DTransformOperation: return TransformOperation::SCALE_3D; case WebKitCSSTransformValue::TranslateTransformOperation: return TransformOperation::TRANSLATE; case WebKitCSSTransformValue::TranslateXTransformOperation: return TransformOperation::TRANSLATE_X; case WebKitCSSTransformValue::TranslateYTransformOperation: return TransformOperation::TRANSLATE_Y; + case WebKitCSSTransformValue::TranslateZTransformOperation: return TransformOperation::TRANSLATE_Z; + case WebKitCSSTransformValue::Translate3DTransformOperation: return TransformOperation::TRANSLATE_3D; case WebKitCSSTransformValue::RotateTransformOperation: return TransformOperation::ROTATE; + case WebKitCSSTransformValue::RotateXTransformOperation: return TransformOperation::ROTATE_X; + case WebKitCSSTransformValue::RotateYTransformOperation: return TransformOperation::ROTATE_Y; + case WebKitCSSTransformValue::RotateZTransformOperation: return TransformOperation::ROTATE_Z; + case WebKitCSSTransformValue::Rotate3DTransformOperation: return TransformOperation::ROTATE_3D; case WebKitCSSTransformValue::SkewTransformOperation: return TransformOperation::SKEW; case WebKitCSSTransformValue::SkewXTransformOperation: return TransformOperation::SKEW_X; case WebKitCSSTransformValue::SkewYTransformOperation: return TransformOperation::SKEW_Y; case WebKitCSSTransformValue::MatrixTransformOperation: return TransformOperation::MATRIX; + case WebKitCSSTransformValue::Matrix3DTransformOperation: return TransformOperation::MATRIX_3D; + case WebKitCSSTransformValue::PerspectiveTransformOperation: return TransformOperation::PERSPECTIVE; case WebKitCSSTransformValue::UnknownTransformOperation: return TransformOperation::NONE; } return TransformOperation::NONE; } -bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, TransformOperations& outOperations) +bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* style, TransformOperations& outOperations) { + float zoomFactor = style ? style->effectiveZoom() : 1; + TransformOperations operations; if (inValue && !inValue->isPrimitiveValue()) { CSSValueList* list = static_cast<CSSValueList*>(inValue); @@ -5817,7 +5940,33 @@ bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* sy = sx; } } - operations.operations().append(ScaleTransformOperation::create(sx, sy, getTransformOperationType(val->operationType()))); + operations.operations().append(ScaleTransformOperation::create(sx, sy, 1.0, getTransformOperationType(val->operationType()))); + break; + } + case WebKitCSSTransformValue::ScaleZTransformOperation: + case WebKitCSSTransformValue::Scale3DTransformOperation: { + double sx = 1.0; + double sy = 1.0; + double sz = 1.0; + if (val->operationType() == WebKitCSSTransformValue::ScaleZTransformOperation) + sz = firstValue->getDoubleValue(); + else if (val->operationType() == WebKitCSSTransformValue::ScaleYTransformOperation) + sy = firstValue->getDoubleValue(); + else { + sx = firstValue->getDoubleValue(); + if (val->operationType() != WebKitCSSTransformValue::ScaleXTransformOperation) { + if (val->length() > 2) { + CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2)); + sz = thirdValue->getDoubleValue(); + } + if (val->length() > 1) { + CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1)); + sy = secondValue->getDoubleValue(); + } else + sy = sx; + } + } + operations.operations().append(ScaleTransformOperation::create(sx, sy, sz, getTransformOperationType(val->operationType()))); break; } case WebKitCSSTransformValue::TranslateTransformOperation: @@ -5827,13 +5976,43 @@ bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* Length tx = Length(0, Fixed); Length ty = Length(0, Fixed); if (val->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) - ty = convertToLength(firstValue, inStyle, &ok); + ty = convertToLength(firstValue, style, zoomFactor, &ok); + else { + tx = convertToLength(firstValue, style, zoomFactor, &ok); + if (val->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { + if (val->length() > 1) { + CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1)); + ty = convertToLength(secondValue, style, zoomFactor, &ok); + } + } + } + + if (!ok) + return false; + + operations.operations().append(TranslateTransformOperation::create(tx, ty, Length(0, Fixed), getTransformOperationType(val->operationType()))); + break; + } + case WebKitCSSTransformValue::TranslateZTransformOperation: + case WebKitCSSTransformValue::Translate3DTransformOperation: { + bool ok = true; + Length tx = Length(0, Fixed); + Length ty = Length(0, Fixed); + Length tz = Length(0, Fixed); + if (val->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation) + tz = convertToLength(firstValue, style, zoomFactor, &ok); + else if (val->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) + ty = convertToLength(firstValue, style, zoomFactor, &ok); else { - tx = convertToLength(firstValue, inStyle, &ok); + tx = convertToLength(firstValue, style, zoomFactor, &ok); if (val->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { + if (val->length() > 2) { + CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2)); + tz = convertToLength(thirdValue, style, zoomFactor, &ok); + } if (val->length() > 1) { CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1)); - ty = convertToLength(secondValue, inStyle, &ok); + ty = convertToLength(secondValue, style, zoomFactor, &ok); } } } @@ -5841,7 +6020,7 @@ bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* if (!ok) return false; - operations.operations().append(TranslateTransformOperation::create(tx, ty, getTransformOperationType(val->operationType()))); + operations.operations().append(TranslateTransformOperation::create(tx, ty, tz, getTransformOperationType(val->operationType()))); break; } case WebKitCSSTransformValue::RotateTransformOperation: { @@ -5853,7 +6032,43 @@ bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* else if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_TURN) angle = turn2deg(angle); - operations.operations().append(RotateTransformOperation::create(angle, getTransformOperationType(val->operationType()))); + operations.operations().append(RotateTransformOperation::create(0, 0, 1, angle, getTransformOperationType(val->operationType()))); + break; + } + case WebKitCSSTransformValue::RotateXTransformOperation: + case WebKitCSSTransformValue::RotateYTransformOperation: + case WebKitCSSTransformValue::RotateZTransformOperation: { + double x = 0; + double y = 0; + double z = 0; + double angle = firstValue->getDoubleValue(); + if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_RAD) + angle = rad2deg(angle); + else if (firstValue->primitiveType() == CSSPrimitiveValue::CSS_GRAD) + angle = grad2deg(angle); + + if (val->operationType() == WebKitCSSTransformValue::RotateXTransformOperation) + x = 1; + else if (val->operationType() == WebKitCSSTransformValue::RotateYTransformOperation) + y = 1; + else + z = 1; + operations.operations().append(RotateTransformOperation::create(x, y, z, angle, getTransformOperationType(val->operationType()))); + break; + } + case WebKitCSSTransformValue::Rotate3DTransformOperation: { + CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1)); + CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2)); + CSSPrimitiveValue* fourthValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(3)); + double x = firstValue->getDoubleValue(); + double y = secondValue->getDoubleValue(); + double z = thirdValue->getDoubleValue(); + double angle = fourthValue->getDoubleValue(); + if (fourthValue->primitiveType() == CSSPrimitiveValue::CSS_RAD) + angle = rad2deg(angle); + else if (fourthValue->primitiveType() == CSSPrimitiveValue::CSS_GRAD) + angle = grad2deg(angle); + operations.operations().append(RotateTransformOperation::create(x, y, z, angle, getTransformOperationType(val->operationType()))); break; } case WebKitCSSTransformValue::SkewTransformOperation: @@ -5889,15 +6104,42 @@ bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* break; } case WebKitCSSTransformValue::MatrixTransformOperation: { - float a = firstValue->getFloatValue(); - float b = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1))->getFloatValue(); - float c = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2))->getFloatValue(); - float d = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(3))->getFloatValue(); - float e = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(4))->getFloatValue(); - float f = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(5))->getFloatValue(); + double a = firstValue->getDoubleValue(); + double b = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1))->getDoubleValue(); + double c = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2))->getDoubleValue(); + double d = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(3))->getDoubleValue(); + double e = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(4))->getDoubleValue(); + double f = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(5))->getDoubleValue(); operations.operations().append(MatrixTransformOperation::create(a, b, c, d, e, f)); break; } + case WebKitCSSTransformValue::Matrix3DTransformOperation: { + TransformationMatrix matrix(static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(0))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(3))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(4))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(5))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(6))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(7))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(8))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(9))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(10))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(11))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(12))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(13))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(14))->getDoubleValue(), + static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(15))->getDoubleValue()); + operations.operations().append(Matrix3DTransformOperation::create(matrix)); + break; + } + case WebKitCSSTransformValue::PerspectiveTransformOperation: { + double p = firstValue->getDoubleValue(); + if (p < 0.0) + return false; + operations.operations().append(PerspectiveTransformOperation::create(p)); + break; + } case WebKitCSSTransformValue::UnknownTransformOperation: ASSERT_NOT_REACHED(); break; diff --git a/WebCore/css/CSSStyleSelector.h b/WebCore/css/CSSStyleSelector.h index b925efc..8dd36d7 100644 --- a/WebCore/css/CSSStyleSelector.h +++ b/WebCore/css/CSSStyleSelector.h @@ -83,11 +83,11 @@ public: ~CSSStyleSelector(); void initElementAndPseudoState(Element*); - void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, RenderStyle::PseudoId = RenderStyle::NOPSEUDO); + void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO); PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, bool allowSharing = true, bool resolveForRootDefault = false); void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList& list); - PassRefPtr<RenderStyle> pseudoStyleForElement(RenderStyle::PseudoId, Element*, RenderStyle* parentStyle = 0); + PassRefPtr<RenderStyle> pseudoStyleForElement(PseudoId, Element*, RenderStyle* parentStyle = 0); private: RenderStyle* locateSharedStyle(); @@ -186,10 +186,10 @@ public: SelectorChecker(Document*, bool strictParsing); bool checkSelector(CSSSelector*, Element*) const; - SelectorMatch checkSelector(CSSSelector*, Element*, HashSet<AtomicStringImpl*>* selectorAttrs, RenderStyle::PseudoId& dynamicPseudo, bool isAncestor, bool isSubSelector, RenderStyle* = 0, RenderStyle* elementParentStyle = 0) const; - bool checkOneSelector(CSSSelector*, Element*, HashSet<AtomicStringImpl*>* selectorAttrs, RenderStyle::PseudoId& dynamicPseudo, bool isAncestor, bool isSubSelector, RenderStyle*, RenderStyle* elementParentStyle) const; + SelectorMatch checkSelector(CSSSelector*, Element*, HashSet<AtomicStringImpl*>* selectorAttrs, PseudoId& dynamicPseudo, bool isAncestor, bool isSubSelector, RenderStyle* = 0, RenderStyle* elementParentStyle = 0) const; + bool checkOneSelector(CSSSelector*, Element*, HashSet<AtomicStringImpl*>* selectorAttrs, PseudoId& dynamicPseudo, bool isAncestor, bool isSubSelector, RenderStyle*, RenderStyle* elementParentStyle) const; PseudoState checkPseudoState(Element*, bool checkVisited = true) const; - bool checkScrollbarPseudoClass(CSSSelector*, RenderStyle::PseudoId& dynamicPseudo) const; + bool checkScrollbarPseudoClass(CSSSelector*, PseudoId& dynamicPseudo) const; void allVisitedStateChanged(); void visitedStateChanged(LinkHash visitedHash); @@ -197,7 +197,7 @@ public: Document* m_document; bool m_strictParsing; bool m_collectRulesOnly; - RenderStyle::PseudoId m_pseudoStyle; + PseudoId m_pseudoStyle; bool m_documentIsHTML; mutable HashSet<LinkHash, LinkHashHash> m_linksCheckedForVisitedState; }; @@ -226,7 +226,6 @@ public: void mapAnimationDuration(Animation*, CSSValue*); void mapAnimationIterationCount(Animation*, CSSValue*); void mapAnimationName(Animation*, CSSValue*); - void mapAnimationPlayState(Animation*, CSSValue*); void mapAnimationProperty(Animation*, CSSValue*); void mapAnimationTimingFunction(Animation*, CSSValue*); @@ -254,7 +253,7 @@ public: MediaQueryEvaluator* m_medium; RefPtr<RenderStyle> m_rootDefaultStyle; - RenderStyle::PseudoId m_dynamicPseudo; + PseudoId m_dynamicPseudo; SelectorChecker m_checker; diff --git a/WebCore/css/CSSStyleSheet.cpp b/WebCore/css/CSSStyleSheet.cpp index 2e9255b..56305f3 100644 --- a/WebCore/css/CSSStyleSheet.cpp +++ b/WebCore/css/CSSStyleSheet.cpp @@ -192,6 +192,10 @@ void CSSStyleSheet::checkLoaded() return; if (parent()) parent()->checkLoaded(); + + // Avoid |this| being deleted by scripts that run via HTMLTokenizer::executeScriptsWaitingForStylesheets(). + // See <rdar://problem/6622300>. + RefPtr<CSSStyleSheet> protector(this); m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true; } @@ -200,7 +204,7 @@ void CSSStyleSheet::styleSheetChanged() StyleBase* root = this; while (StyleBase* parent = root->parent()) root = parent; - Document* documentToUpdate = (root && root->isCSSStyleSheet()) ? static_cast<CSSStyleSheet*>(root)->doc() : 0; + Document* documentToUpdate = root->isCSSStyleSheet() ? static_cast<CSSStyleSheet*>(root)->doc() : 0; /* FIXME: We don't need to do everything updateStyleSelector does, * basically we just need to recreate the document's selector with the diff --git a/WebCore/css/CSSValueKeywords.in b/WebCore/css/CSSValueKeywords.in index 936b635..698dffe 100644 --- a/WebCore/css/CSSValueKeywords.in +++ b/WebCore/css/CSSValueKeywords.in @@ -537,9 +537,13 @@ round # # CSS_PROP_BACKGROUND_CLIP/ORIGIN # +# border/content/padding are deprecated and ultimately will only apply to the -webkit- form of these properties. +# border-box/content-box/padding-box should be used instead. +# border content padding +padding-box # # CSS_PROP_BOX_SIZING @@ -575,6 +579,12 @@ running paused # +# CSS_PROP__WEBKIT_TRANSFORM_STYLE +# +flat +preserve-3d + +# # CSS_PROP__WEBKIT_TRANSITION_TIMING_FUNCTION # CSS_PROP__WEBKIT_ANIMATION_TIMING_FUNCTION # @@ -601,4 +611,4 @@ painted fill stroke #all -#none
\ No newline at end of file +#none diff --git a/WebCore/css/MediaQueryEvaluator.cpp b/WebCore/css/MediaQueryEvaluator.cpp index fa5a3e9..4268d8c 100644 --- a/WebCore/css/MediaQueryEvaluator.cpp +++ b/WebCore/css/MediaQueryEvaluator.cpp @@ -417,11 +417,22 @@ static bool transform_2dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, static bool transform_3dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op) { + bool returnValueIfNoParameter; + int have3dRendering; + +#if ENABLE(3D_RENDERING) + returnValueIfNoParameter = true; + have3dRendering = 1; +#else + returnValueIfNoParameter = false; + have3dRendering = 0; +#endif + if (value) { float number; - return numberValue(value, number) && compareValue(0, static_cast<int>(number), op); + return numberValue(value, number) && compareValue(have3dRendering, static_cast<int>(number), op); } - return false; + return returnValueIfNoParameter; } static void createFunctionMap() diff --git a/WebCore/css/SVGCSSComputedStyleDeclaration.cpp b/WebCore/css/SVGCSSComputedStyleDeclaration.cpp index 1375fc2..2cd90a9d 100644 --- a/WebCore/css/SVGCSSComputedStyleDeclaration.cpp +++ b/WebCore/css/SVGCSSComputedStyleDeclaration.cpp @@ -26,6 +26,7 @@ #include "CSSPrimitiveValueMappings.h" #include "CSSPropertyNames.h" #include "Document.h" +#include "RenderStyle.h" namespace WebCore { diff --git a/WebCore/css/SVGCSSStyleSelector.cpp b/WebCore/css/SVGCSSStyleSelector.cpp index 34d981c..d326dde 100644 --- a/WebCore/css/SVGCSSStyleSelector.cpp +++ b/WebCore/css/SVGCSSStyleSelector.cpp @@ -59,25 +59,6 @@ HANDLE_INHERIT(prop, Prop) \ else if (isInitial) \ svgstyle->set##Prop(SVGRenderStyle::initial##Prop()); -#define HANDLE_INHERIT_COND(propID, prop, Prop) \ -if (id == propID) \ -{\ - svgstyle->set##Prop(m_parentStyle->svgStyle()->prop());\ - return;\ -} - -#define HANDLE_INITIAL_COND(propID, Prop) \ -if (id == propID) \ -{\ - svgstyle->set##Prop(SVGRenderStyle::initial##Prop());\ - return;\ -} - -#define HANDLE_INITIAL_COND_WITH_VALUE(propID, Prop, Value) \ -if (id == propID) { \ - svgstyle->set##Prop(SVGRenderStyle::initial##Value()); \ - return; \ -} namespace WebCore { @@ -111,8 +92,21 @@ static int angleToGlyphOrientation(float angle) return -1; } +static Color colorFromSVGColorCSSValue(CSSValue* value, RenderStyle* style) +{ + ASSERT(value->isSVGColor()); + SVGColor* c = static_cast<SVGColor*>(value); + Color color; + if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR) + color = style->color(); + else + color = c->color(); + return color; +} + void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) { + ASSERT(value); CSSPrimitiveValue* primitiveValue = 0; if (value->isPrimitiveValue()) primitiveValue = static_cast<CSSPrimitiveValue*>(value); @@ -168,15 +162,7 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) } case CSSPropertyKerning: { - if (isInherit) { - HANDLE_INHERIT_COND(CSSPropertyKerning, kerning, Kerning) - return; - } - else if (isInitial) { - HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyKerning, Kerning, Kerning) - return; - } - + HANDLE_INHERIT_AND_INITIAL(kerning, Kerning); svgstyle->setKerning(primitiveValue); break; } @@ -254,52 +240,37 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) case CSSPropertyFill: { HANDLE_INHERIT_AND_INITIAL(fillPaint, FillPaint) - if (!primitiveValue && value) { - SVGPaint *paint = static_cast<SVGPaint*>(value); - if (paint) - svgstyle->setFillPaint(paint); - } - + if (value->isSVGPaint()) + svgstyle->setFillPaint(static_cast<SVGPaint*>(value)); break; } case CSSPropertyStroke: { HANDLE_INHERIT_AND_INITIAL(strokePaint, StrokePaint) - if (!primitiveValue && value) { - SVGPaint *paint = static_cast<SVGPaint*>(value); - if (paint) - svgstyle->setStrokePaint(paint); - } + if (value->isSVGPaint()) + svgstyle->setStrokePaint(static_cast<SVGPaint*>(value)); break; } case CSSPropertyStrokeWidth: { HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth) - if (!primitiveValue) - return; - - svgstyle->setStrokeWidth(primitiveValue); + if (primitiveValue) + svgstyle->setStrokeWidth(primitiveValue); break; } case CSSPropertyStrokeDasharray: { HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray) - if (!primitiveValue && value) { - CSSValueList* dashes = static_cast<CSSValueList*>(value); - if (dashes) - svgstyle->setStrokeDashArray(dashes); - } - + if (value->isValueList()) + svgstyle->setStrokeDashArray(static_cast<CSSValueList*>(value)); break; } case CSSPropertyStrokeDashoffset: { HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset) - if (!primitiveValue) - return; - - svgstyle->setStrokeDashOffset(primitiveValue); + if (primitiveValue) + svgstyle->setStrokeDashOffset(primitiveValue); break; } case CSSPropertyFillOpacity: @@ -491,35 +462,13 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) case CSSPropertyStopColor: { HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor); - - SVGColor* c = static_cast<SVGColor*>(value); - if (!c) - return CSSStyleSelector::applyProperty(id, value); - - Color col; - if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR) - col = m_style->color(); - else - col = c->color(); - - svgstyle->setStopColor(col); + svgstyle->setStopColor(colorFromSVGColorCSSValue(value, m_style.get())); break; } case CSSPropertyLightingColor: { HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor); - - SVGColor* c = static_cast<SVGColor*>(value); - if (!c) - return CSSStyleSelector::applyProperty(id, value); - - Color col; - if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR) - col = m_style->color(); - else - col = c->color(); - - svgstyle->setLightingColor(col); + svgstyle->setLightingColor(colorFromSVGColorCSSValue(value, m_style.get())); break; } case CSSPropertyFloodOpacity: @@ -542,21 +491,11 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) } case CSSPropertyFloodColor: { - Color col; - if (isInitial) - col = SVGRenderStyle::initialFloodColor(); - else { - SVGColor *c = static_cast<SVGColor*>(value); - if (!c) - return CSSStyleSelector::applyProperty(id, value); - - if (c->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR) - col = m_style->color(); - else - col = c->color(); + if (isInitial) { + svgstyle->setFloodColor(SVGRenderStyle::initialFloodColor()); + return; } - - svgstyle->setFloodColor(col); + svgstyle->setFloodColor(colorFromSVGColorCSSValue(value, m_style.get())); break; } case CSSPropertyGlyphOrientationHorizontal: diff --git a/WebCore/css/WebKitCSSMatrix.cpp b/WebCore/css/WebKitCSSMatrix.cpp index 2d97b85..574a01a 100644 --- a/WebCore/css/WebKitCSSMatrix.cpp +++ b/WebCore/css/WebKitCSSMatrix.cpp @@ -24,6 +24,7 @@ */ #include "config.h" +#include "WebKitCSSMatrix.h" #include "CSSParser.h" #include "CSSStyleSelector.h" @@ -31,7 +32,7 @@ #include "CSSPropertyNames.h" #include "ExceptionCode.h" #include "RenderStyle.h" -#include "WebKitCSSMatrix.h" +#include <wtf/MathExtras.h> namespace WebCore { @@ -93,14 +94,17 @@ void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec) } // This is a multRight (this = this * secondMatrix) -PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::multiply(WebKitCSSMatrix* secondMatrix) +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::multiply(WebKitCSSMatrix* secondMatrix) const { + if (!secondMatrix) + return 0; + TransformationMatrix tmp(m_matrix); tmp.multiply(secondMatrix->m_matrix); return WebKitCSSMatrix::create(tmp); } -PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::inverse(ExceptionCode& ec) +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::inverse(ExceptionCode& ec) const { if (!m_matrix.isInvertible()) { ec = NOT_SUPPORTED_ERR; @@ -110,35 +114,73 @@ PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::inverse(ExceptionCode& ec) return WebKitCSSMatrix::create(m_matrix.inverse()); } -PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::translate(float x, float y) +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::translate(double x, double y, double z) const { if (isnan(x)) - x = 0; + x = 0; if (isnan(y)) - y = 0; - return WebKitCSSMatrix::create(m_matrix.translate(x, y)); + y = 0; + if (isnan(z)) + z = 0; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).translate3d(x, y, z)); } -PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::scale(float scaleX, float scaleY) +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::scale(double scaleX, double scaleY, double scaleZ) const { if (isnan(scaleX)) - scaleX = 1; + scaleX = 1; if (isnan(scaleY)) - scaleY = scaleX; - return WebKitCSSMatrix::create(m_matrix.scale(scaleX,scaleY)); + scaleY = scaleX; + if (isnan(scaleZ)) + scaleZ = 1; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).scale3d(scaleX, scaleY, scaleZ)); } -PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotate(float rot) +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotate(double rotX, double rotY, double rotZ) const { - if (isnan(rot)) - rot = 0; - return WebKitCSSMatrix::create(m_matrix.rotate(rot)); + if (isnan(rotX)) + rotX = 0; + + if (isnan(rotY) && isnan(rotZ)) { + rotZ = rotX; + rotX = 0; + rotY = 0; + } + + if (isnan(rotY)) + rotY = 0; + if (isnan(rotZ)) + rotZ = 0; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(rotX, rotY, rotZ)); } -String WebKitCSSMatrix::toString() +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotateAxisAngle(double x, double y, double z, double angle) const +{ + if (isnan(x)) + x = 0; + if (isnan(y)) + y = 0; + if (isnan(z)) + z = 0; + if (isnan(angle)) + angle = 0; + if (x == 0 && y == 0 && z == 0) + z = 1; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(x, y, z, angle)); +} + + +String WebKitCSSMatrix::toString() const { - return String::format("matrix(%f, %f, %f, %f, %f, %f)", - m_matrix.a(), m_matrix.b(), m_matrix.c(), m_matrix.d(), m_matrix.e(), m_matrix.f()); + // FIXME - Need to ensure valid CSS floating point values (https://bugs.webkit.org/show_bug.cgi?id=20674) + if (m_matrix.isAffine()) + return String::format("matrix(%f, %f, %f, %f, %f, %f)", + m_matrix.a(), m_matrix.b(), m_matrix.c(), m_matrix.d(), m_matrix.e(), m_matrix.f()); + return String::format("matrix3d(%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f)", + m_matrix.m11(), m_matrix.m12(), m_matrix.m13(), m_matrix.m14(), + m_matrix.m21(), m_matrix.m22(), m_matrix.m23(), m_matrix.m24(), + m_matrix.m31(), m_matrix.m32(), m_matrix.m33(), m_matrix.m34(), + m_matrix.m41(), m_matrix.m42(), m_matrix.m43(), m_matrix.m44()); } } // namespace WebCore diff --git a/WebCore/css/WebKitCSSMatrix.h b/WebCore/css/WebKitCSSMatrix.h index 1c660bf..67ba113 100644 --- a/WebCore/css/WebKitCSSMatrix.h +++ b/WebCore/css/WebKitCSSMatrix.h @@ -26,8 +26,9 @@ #ifndef WebKitCSSMatrix_h #define WebKitCSSMatrix_h -#include "StyleBase.h" +#include "ExceptionCode.h" #include "PlatformString.h" +#include "StyleBase.h" #include "TransformationMatrix.h" #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> @@ -55,34 +56,94 @@ public: virtual ~WebKitCSSMatrix(); - float a() const { return static_cast<float>(m_matrix.a()); } - float b() const { return static_cast<float>(m_matrix.b()); } - float c() const { return static_cast<float>(m_matrix.c()); } - float d() const { return static_cast<float>(m_matrix.d()); } - float e() const { return static_cast<float>(m_matrix.e()); } - float f() const { return static_cast<float>(m_matrix.f()); } + double a() const { return m_matrix.a(); } + double b() const { return m_matrix.b(); } + double c() const { return m_matrix.c(); } + double d() const { return m_matrix.d(); } + double e() const { return m_matrix.e(); } + double f() const { return m_matrix.f(); } - void setA(float f) { m_matrix.setA(f); } - void setB(float f) { m_matrix.setB(f); } - void setC(float f) { m_matrix.setC(f); } - void setD(float f) { m_matrix.setD(f); } - void setE(float f) { m_matrix.setE(f); } - void setF(float f) { m_matrix.setF(f); } + void setA(double f) { m_matrix.setA(f); } + void setB(double f) { m_matrix.setB(f); } + void setC(double f) { m_matrix.setC(f); } + void setD(double f) { m_matrix.setD(f); } + void setE(double f) { m_matrix.setE(f); } + void setF(double f) { m_matrix.setF(f); } + + double m11() const { return m_matrix.m11(); } + double m12() const { return m_matrix.m12(); } + double m13() const { return m_matrix.m13(); } + double m14() const { return m_matrix.m14(); } + double m21() const { return m_matrix.m21(); } + double m22() const { return m_matrix.m22(); } + double m23() const { return m_matrix.m23(); } + double m24() const { return m_matrix.m24(); } + double m31() const { return m_matrix.m31(); } + double m32() const { return m_matrix.m32(); } + double m33() const { return m_matrix.m33(); } + double m34() const { return m_matrix.m34(); } + double m41() const { return m_matrix.m41(); } + double m42() const { return m_matrix.m42(); } + double m43() const { return m_matrix.m43(); } + double m44() const { return m_matrix.m44(); } + + void setM11(double f) { m_matrix.setM11(f); } + void setM12(double f) { m_matrix.setM12(f); } + void setM13(double f) { m_matrix.setM13(f); } + void setM14(double f) { m_matrix.setM14(f); } + void setM21(double f) { m_matrix.setM21(f); } + void setM22(double f) { m_matrix.setM22(f); } + void setM23(double f) { m_matrix.setM23(f); } + void setM24(double f) { m_matrix.setM24(f); } + void setM31(double f) { m_matrix.setM31(f); } + void setM32(double f) { m_matrix.setM32(f); } + void setM33(double f) { m_matrix.setM33(f); } + void setM34(double f) { m_matrix.setM34(f); } + void setM41(double f) { m_matrix.setM41(f); } + void setM42(double f) { m_matrix.setM42(f); } + void setM43(double f) { m_matrix.setM43(f); } + void setM44(double f) { m_matrix.setM44(f); } void setMatrixValue(const String& string, ExceptionCode&); - // this = this * secondMatrix - PassRefPtr<WebKitCSSMatrix> multiply(WebKitCSSMatrix* secondMatrix); + // The following math function return a new matrix with the + // specified operation applied. The this value is not modified. + + // Multiply this matrix by secondMatrix, on the right (result = this * secondMatrix) + PassRefPtr<WebKitCSSMatrix> multiply(WebKitCSSMatrix* secondMatrix) const; + + // Return the inverse of this matrix. Throw an exception if the matrix is not invertible + PassRefPtr<WebKitCSSMatrix> inverse(ExceptionCode&) const; + + // Return this matrix translated by the passed values. + // Passing a NaN will use a value of 0. This allows the 3D form to used for 2D operations + // Operation is performed as though the this matrix is multiplied by a matrix with + // the translation values on the left (result = translation(x,y,z) * this) + PassRefPtr<WebKitCSSMatrix> translate(double x, double y, double z) const; + + // Returns this matrix scaled by the passed values. + // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of NaN + // makes it the same as scaleX. This allows the 3D form to used for 2D operations + // Operation is performed as though the this matrix is multiplied by a matrix with + // the scale values on the left (result = scale(x,y,z) * this) + PassRefPtr<WebKitCSSMatrix> scale(double scaleX, double scaleY, double scaleZ) const; + + // Returns this matrix rotated by the passed values. + // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX). + // Otherwise use a rotation value of 0 for any passed NaN. + // Operation is performed as though the this matrix is multiplied by a matrix with + // the rotation values on the left (result = rotation(x,y,z) * this) + PassRefPtr<WebKitCSSMatrix> rotate(double rotX, double rotY, double rotZ) const; - // FIXME: we really should have an exception here, for when matrix is not invertible - PassRefPtr<WebKitCSSMatrix> inverse(ExceptionCode&); - PassRefPtr<WebKitCSSMatrix> translate(float x, float y); - PassRefPtr<WebKitCSSMatrix> scale(float scaleX, float scaleY); - PassRefPtr<WebKitCSSMatrix> rotate(float rot); + // Returns this matrix rotated about the passed axis by the passed angle. + // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value + // Operation is performed as though the this matrix is multiplied by a matrix with + // the rotation values on the left (result = rotation(x,y,z,angle) * this) + PassRefPtr<WebKitCSSMatrix> rotateAxisAngle(double x, double y, double z, double angle) const; - const TransformationMatrix& transform() { return m_matrix; } + const TransformationMatrix& transform() const { return m_matrix; } - String toString(); + String toString() const; protected: WebKitCSSMatrix(); diff --git a/WebCore/css/WebKitCSSMatrix.idl b/WebCore/css/WebKitCSSMatrix.idl index b1d5946..6b22da1 100644 --- a/WebCore/css/WebKitCSSMatrix.idl +++ b/WebCore/css/WebKitCSSMatrix.idl @@ -28,19 +28,57 @@ module css { // Introduced in DOM Level ?: interface WebKitCSSMatrix { - attribute float a; - attribute float b; - attribute float c; - attribute float d; - attribute float e; - attribute float f; + // These attributes are simple aliases for certain elements of the 4x4 matrix + attribute double a; // alias for m11 + attribute double b; // alias for m12 + attribute double c; // alias for m21 + attribute double d; // alias for m22 + attribute double e; // alias for m41 + attribute double f; // alias for m42 - void setMatrixValue(in DOMString string) raises (DOMException); - WebKitCSSMatrix multiply(in WebKitCSSMatrix secondMatrix); - WebKitCSSMatrix inverse() raises (DOMException); - WebKitCSSMatrix translate(in float x, in float y); - WebKitCSSMatrix scale(in float scaleX, in float scaleY); - WebKitCSSMatrix rotate(in float rot); + attribute double m11; + attribute double m12; + attribute double m13; + attribute double m14; + attribute double m21; + attribute double m22; + attribute double m23; + attribute double m24; + attribute double m31; + attribute double m32; + attribute double m33; + attribute double m34; + attribute double m41; + attribute double m42; + attribute double m43; + attribute double m44; + + void setMatrixValue(in DOMString string) raises (DOMException); + + // Multiply this matrix by secondMatrix, on the right (result = this * secondMatrix) + [Immutable] WebKitCSSMatrix multiply(in WebKitCSSMatrix secondMatrix); + + // Return the inverse of this matrix. Throw an exception if the matrix is not invertible + [Immutable] WebKitCSSMatrix inverse() raises (DOMException); + + // Return this matrix translated by the passed values. + // Passing a NaN will use a value of 0. This allows the 3D form to used for 2D operations + [Immutable] WebKitCSSMatrix translate(in double x, in double y, in double z); + + // Returns this matrix scaled by the passed values. + // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of NaN + // makes it the same as scaleX. This allows the 3D form to used for 2D operations + [Immutable] WebKitCSSMatrix scale(in double scaleX, in double scaleY, in double scaleZ); + + // Returns this matrix rotated by the passed values. + // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX). + // Otherwise use a rotation value of 0 for any passed NaN. + [Immutable] WebKitCSSMatrix rotate(in double rotX, in double rotY, in double rotZ); + + // Returns this matrix rotated about the passed axis by the passed angle. + // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value + // of (0,0,1). + [Immutable] WebKitCSSMatrix rotateAxisAngle(in double x, in double y, in double z, in double angle); [DontEnum] DOMString toString(); }; diff --git a/WebCore/css/WebKitCSSTransformValue.cpp b/WebCore/css/WebKitCSSTransformValue.cpp index e6af840..3b4286e 100644 --- a/WebCore/css/WebKitCSSTransformValue.cpp +++ b/WebCore/css/WebKitCSSTransformValue.cpp @@ -79,6 +79,36 @@ String WebKitCSSTransformValue::cssText() const case MatrixTransformOperation: result += "matrix("; break; + case TranslateZTransformOperation: + result += "translateZ("; + break; + case Translate3DTransformOperation: + result += "translate3d("; + break; + case RotateXTransformOperation: + result += "rotateX("; + break; + case RotateYTransformOperation: + result += "rotateY("; + break; + case RotateZTransformOperation: + result += "rotateZ("; + break; + case Rotate3DTransformOperation: + result += "rotate3d("; + break; + case ScaleZTransformOperation: + result += "scaleZ("; + break; + case Scale3DTransformOperation: + result += "scale3d("; + break; + case PerspectiveTransformOperation: + result += "perspective("; + break; + case Matrix3DTransformOperation: + result += "matrix3d("; + break; default: break; } diff --git a/WebCore/css/WebKitCSSTransformValue.h b/WebCore/css/WebKitCSSTransformValue.h index 2bb2631..0c3c038 100644 --- a/WebCore/css/WebKitCSSTransformValue.h +++ b/WebCore/css/WebKitCSSTransformValue.h @@ -47,7 +47,17 @@ public: SkewTransformOperation, SkewXTransformOperation, SkewYTransformOperation, - MatrixTransformOperation + MatrixTransformOperation, + TranslateZTransformOperation, + Translate3DTransformOperation, + RotateXTransformOperation, + RotateYTransformOperation, + RotateZTransformOperation, + Rotate3DTransformOperation, + ScaleZTransformOperation, + Scale3DTransformOperation, + PerspectiveTransformOperation, + Matrix3DTransformOperation }; static PassRefPtr<WebKitCSSTransformValue> create(TransformOperationType type) diff --git a/WebCore/css/WebKitCSSTransformValue.idl b/WebCore/css/WebKitCSSTransformValue.idl index 39e97a3..14a373f 100644 --- a/WebCore/css/WebKitCSSTransformValue.idl +++ b/WebCore/css/WebKitCSSTransformValue.idl @@ -48,6 +48,16 @@ module css { const unsigned short CSS_SKEWX = 9; const unsigned short CSS_SKEWY = 10; const unsigned short CSS_MATRIX = 11; + const unsigned short CSS_TRANSLATEZ = 12; + const unsigned short CSS_TRANSLATE3D = 13; + const unsigned short CSS_ROTATEX = 14; + const unsigned short CSS_ROTATEY = 15; + const unsigned short CSS_ROTATEZ = 16; + const unsigned short CSS_ROTATE3D = 17; + const unsigned short CSS_SCALEZ = 18; + const unsigned short CSS_SCALE3D = 19; + const unsigned short CSS_PERSPECTIVE = 20; + const unsigned short CSS_MATRIX3D = 21; readonly attribute unsigned short operationType; }; diff --git a/WebCore/css/html4.css b/WebCore/css/html4.css index 704e216..2b6d3fe 100644 --- a/WebCore/css/html4.css +++ b/WebCore/css/html4.css @@ -599,4 +599,8 @@ iframe { border: 2px inset } +img, input[type=image], video, iframe, object, embed, applet { + overflow: hidden; /* Default to overflow:hidden so that border-radius clipping works on the foreground of these elements. */ +} + /* noscript is handled internally, as it depends on settings */ diff --git a/WebCore/css/themeChromiumWin.css b/WebCore/css/themeChromiumWin.css new file mode 100644 index 0000000..e829373 --- /dev/null +++ b/WebCore/css/themeChromiumWin.css @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* These styles override the default styling for HTML elements as defined in + WebCore/css/themeWin.css. */ +#include "themeWin.css" + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-results-decoration, +input[type="search"]::-webkit-search-results-button { + margin: 0 0 0 0; +} diff --git a/WebCore/css/themeWin.css b/WebCore/css/themeWin.css index 8620536..6c582e9 100644 --- a/WebCore/css/themeWin.css +++ b/WebCore/css/themeWin.css @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Google Inc. All rights reserved. + * Copyright (C) 2008 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -34,12 +34,16 @@ input:not([type]), input[type="text"], -input[type="password"], -input[type="search"] { +input[type="password"] { margin:0; padding:1px 0; } +input[type="search"] { + margin:0; + padding:1px; +} + input[type="checkbox"] { margin:3px 3px 3px 4px; } @@ -63,6 +67,10 @@ input[type="search"]:disabled { background-color: #EBEBE4; } +input[type="search"] { + -webkit-appearance: textfield; +} + input[type="search"]::-webkit-search-cancel-button { margin-right: 3px; } @@ -89,6 +97,10 @@ select[size="1"] { -webkit-border-radius: 0; margin: 0; } +/* Options always use the selects' fonts */ +option { + font: inherit !important; +} textarea { font-family: monospace; diff --git a/WebCore/css/themeWinQuirks.css b/WebCore/css/themeWinQuirks.css index 688eabc..c69b74c 100644 --- a/WebCore/css/themeWinQuirks.css +++ b/WebCore/css/themeWinQuirks.css @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Google Inc. All rights reserved. + * Copyright (C) 2008 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are |