summaryrefslogtreecommitdiffstats
path: root/WebCore/css/CSSComputedStyleDeclaration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/css/CSSComputedStyleDeclaration.cpp')
-rw-r--r--WebCore/css/CSSComputedStyleDeclaration.cpp120
1 files changed, 80 insertions, 40 deletions
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp
index 7ed9385..d7f585f 100644
--- a/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -31,6 +31,7 @@
#include "CSSProperty.h"
#include "CSSPropertyNames.h"
#include "CSSReflectValue.h"
+#include "CSSSelector.h"
#include "CSSTimingFunctionValue.h"
#include "CSSValueList.h"
#include "Document.h"
@@ -150,6 +151,7 @@ static const int computedProperties[] = {
CSSPropertyWebkitAnimationDelay,
CSSPropertyWebkitAnimationDirection,
CSSPropertyWebkitAnimationDuration,
+ CSSPropertyWebkitAnimationFillMode,
CSSPropertyWebkitAnimationIterationCount,
CSSPropertyWebkitAnimationName,
CSSPropertyWebkitAnimationPlayState,
@@ -299,28 +301,28 @@ static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
// Create the slices.
RefPtr<CSSPrimitiveValue> top;
- if (image.m_slices.top().isPercent())
- top = CSSPrimitiveValue::create(image.m_slices.top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+ if (image.slices().top().isPercent())
+ top = CSSPrimitiveValue::create(image.slices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
else
- top = CSSPrimitiveValue::create(image.m_slices.top().value(), CSSPrimitiveValue::CSS_NUMBER);
+ top = CSSPrimitiveValue::create(image.slices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
RefPtr<CSSPrimitiveValue> right;
- if (image.m_slices.right().isPercent())
- right = CSSPrimitiveValue::create(image.m_slices.right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+ if (image.slices().right().isPercent())
+ right = CSSPrimitiveValue::create(image.slices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
else
- right = CSSPrimitiveValue::create(image.m_slices.right().value(), CSSPrimitiveValue::CSS_NUMBER);
+ right = CSSPrimitiveValue::create(image.slices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
RefPtr<CSSPrimitiveValue> bottom;
- if (image.m_slices.bottom().isPercent())
- bottom = CSSPrimitiveValue::create(image.m_slices.bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+ if (image.slices().bottom().isPercent())
+ bottom = CSSPrimitiveValue::create(image.slices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
else
- bottom = CSSPrimitiveValue::create(image.m_slices.bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
+ bottom = CSSPrimitiveValue::create(image.slices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
RefPtr<CSSPrimitiveValue> left;
- if (image.m_slices.left().isPercent())
- left = CSSPrimitiveValue::create(image.m_slices.left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+ if (image.slices().left().isPercent())
+ left = CSSPrimitiveValue::create(image.slices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
else
- left = CSSPrimitiveValue::create(image.m_slices.left().value(), CSSPrimitiveValue::CSS_NUMBER);
+ left = CSSPrimitiveValue::create(image.slices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
RefPtr<Rect> rect = Rect::create();
rect->setTop(top);
@@ -328,7 +330,7 @@ static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
rect->setBottom(bottom);
rect->setLeft(left);
- return CSSBorderImageValue::create(imageValue, rect, valueForRepeatRule(image.m_horizontalRule), valueForRepeatRule(image.m_verticalRule));
+ return CSSBorderImageValue::create(imageValue, rect, valueForRepeatRule(image.horizontalRule()), valueForRepeatRule(image.verticalRule()));
}
static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection)
@@ -507,9 +509,13 @@ static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList
return list.release();
}
-CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n)
+CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
: m_node(n)
+ , m_allowVisitedStyle(allowVisitedStyle)
{
+ unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
+ m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
+ AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
}
CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
@@ -552,7 +558,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringK
node->document()->updateLayoutIgnorePendingStylesheets();
- RefPtr<RenderStyle> style = node->computedStyle();
+ RefPtr<RenderStyle> style = node->computedStyle(m_pseudoElementSpecifier);
if (!style)
return 0;
@@ -570,13 +576,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowDat
CSSPropertyID propertyID = static_cast<CSSPropertyID>(id);
RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
- for (const ShadowData* s = shadow; s; s = s->next) {
- RefPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(s->x, CSSPrimitiveValue::CSS_PX);
- RefPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(s->y, CSSPrimitiveValue::CSS_PX);
- RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(s->blur, CSSPrimitiveValue::CSS_PX);
- RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? 0 : CSSPrimitiveValue::create(s->spread, CSSPrimitiveValue::CSS_PX);
- RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset);
- RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(s->color.rgb());
+ for (const ShadowData* s = shadow; s; s = s->next()) {
+ RefPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(s->x(), CSSPrimitiveValue::CSS_PX);
+ RefPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(s->y(), CSSPrimitiveValue::CSS_PX);
+ RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(s->blur(), CSSPrimitiveValue::CSS_PX);
+ RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? 0 : CSSPrimitiveValue::create(s->spread(), CSSPrimitiveValue::CSS_PX);
+ RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset);
+ RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(s->color().rgb());
list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
}
return list.release();
@@ -637,9 +643,9 @@ static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepea
// if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
if (xRepeat == yRepeat)
return CSSPrimitiveValue::create(xRepeat);
- if (xRepeat == CSSValueRepeat && yRepeat == CSSValueNoRepeat)
+ if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
return CSSPrimitiveValue::createIdentifier(CSSValueRepeatX);
- if (xRepeat == CSSValueNoRepeat && yRepeat == CSSValueRepeat)
+ if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
return CSSPrimitiveValue::createIdentifier(CSSValueRepeatY);
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
@@ -670,10 +676,15 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
RenderObject* renderer = node->renderer();
RefPtr<RenderStyle> style;
- if (renderer && hasCompositedLayer(renderer) && AnimationController::supportsAcceleratedAnimationOfProperty(static_cast<CSSPropertyID>(propertyID)))
+ if (renderer && hasCompositedLayer(renderer) && AnimationController::supportsAcceleratedAnimationOfProperty(static_cast<CSSPropertyID>(propertyID))) {
style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
- else
- style = node->computedStyle();
+ if (m_pseudoElementSpecifier) {
+ // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
+ style = style->getCachedPseudoStyle(m_pseudoElementSpecifier);
+ }
+ } else
+ style = node->computedStyle(m_pseudoElementSpecifier);
+
if (!style)
return 0;
@@ -686,7 +697,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
break;
case CSSPropertyBackgroundColor:
- return CSSPrimitiveValue::createColor(style->backgroundColor().rgb());
+ return CSSPrimitiveValue::createColor(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
case CSSPropertyBackgroundImage:
if (style->backgroundImage())
return style->backgroundImage()->cssValue();
@@ -743,13 +754,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
case CSSPropertyWebkitBorderVerticalSpacing:
return CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
case CSSPropertyBorderTopColor:
- return currentColorOrValidColor(style.get(), style->borderTopColor());
+ return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
case CSSPropertyBorderRightColor:
- return currentColorOrValidColor(style.get(), style->borderRightColor());
+ return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
case CSSPropertyBorderBottomColor:
- return currentColorOrValidColor(style.get(), style->borderBottomColor());
+ return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
case CSSPropertyBorderLeftColor:
- return currentColorOrValidColor(style.get(), style->borderLeftColor());
+ return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
case CSSPropertyBorderTopStyle:
return CSSPrimitiveValue::create(style->borderTopStyle());
case CSSPropertyBorderRightStyle:
@@ -799,7 +810,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
case CSSPropertyClear:
return CSSPrimitiveValue::create(style->clear());
case CSSPropertyColor:
- return CSSPrimitiveValue::createColor(style->color().rgb());
+ return CSSPrimitiveValue::createColor(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
case CSSPropertyWebkitColumnCount:
if (style->hasAutoColumnCount())
return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
@@ -809,7 +820,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
return CSSPrimitiveValue::create(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyWebkitColumnRuleColor:
- return currentColorOrValidColor(style.get(), style->columnRuleColor());
+ return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
case CSSPropertyWebkitColumnRuleStyle:
return CSSPrimitiveValue::create(style->columnRuleStyle());
case CSSPropertyWebkitColumnRuleWidth:
@@ -830,7 +841,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
if (cursors && cursors->size() > 0) {
list = CSSValueList::createCommaSeparated();
for (unsigned i = 0; i < cursors->size(); ++i)
- list->append(CSSPrimitiveValue::create((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI));
+ list->append(CSSPrimitiveValue::create((*cursors)[i].image()->url(), CSSPrimitiveValue::CSS_URI));
}
RefPtr<CSSValue> value = CSSPrimitiveValue::create(style->cursor());
if (list) {
@@ -972,9 +983,14 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
return style->maskImage()->cssValue();
return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyWebkitMaskSize: {
+ EFillSizeType size = style->maskSizeType();
+ if (size == Contain)
+ return CSSPrimitiveValue::createIdentifier(CSSValueContain);
+ if (size == Cover)
+ return CSSPrimitiveValue::createIdentifier(CSSValueCover);
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- list->append(CSSPrimitiveValue::create(style->maskSize().width()));
- list->append(CSSPrimitiveValue::create(style->maskSize().height()));
+ list->append(CSSPrimitiveValue::create(style->maskSizeLength().width()));
+ list->append(CSSPrimitiveValue::create(style->maskSizeLength().height()));
return list.release();
}
case CSSPropertyWebkitMaskRepeat:
@@ -1023,7 +1039,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
case CSSPropertyOrphans:
return CSSPrimitiveValue::create(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyOutlineColor:
- return currentColorOrValidColor(style.get(), style->outlineColor());
+ return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
case CSSPropertyOutlineStyle:
if (style->outlineStyleIsAuto())
return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
@@ -1241,6 +1257,30 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
}
case CSSPropertyWebkitAnimationDuration:
return getDurationValue(style->animations());
+ case CSSPropertyWebkitAnimationFillMode: {
+ RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
+ const AnimationList* t = style->animations();
+ if (t) {
+ for (size_t i = 0; i < t->size(); ++i) {
+ switch (t->animation(i)->fillMode()) {
+ case AnimationFillModeNone:
+ list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
+ break;
+ case AnimationFillModeForwards:
+ list->append(CSSPrimitiveValue::createIdentifier(CSSValueForwards));
+ break;
+ case AnimationFillModeBackwards:
+ list->append(CSSPrimitiveValue::createIdentifier(CSSValueBackwards));
+ break;
+ case AnimationFillModeBoth:
+ list->append(CSSPrimitiveValue::createIdentifier(CSSValueBoth));
+ break;
+ }
+ }
+ } else
+ list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
+ return list.release();
+ }
case CSSPropertyWebkitAnimationIterationCount: {
RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
const AnimationList* t = style->animations();
@@ -1512,7 +1552,7 @@ unsigned CSSComputedStyleDeclaration::length() const
if (!node)
return 0;
- RenderStyle* style = node->computedStyle();
+ RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
if (!style)
return 0;
@@ -1531,7 +1571,7 @@ bool CSSComputedStyleDeclaration::cssPropertyMatches(const CSSProperty* property
{
if (property->id() == CSSPropertyFontSize && property->value()->isPrimitiveValue() && m_node) {
m_node->document()->updateLayoutIgnorePendingStylesheets();
- RenderStyle* style = m_node->computedStyle();
+ RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
if (style && style->fontDescription().keywordSize()) {
int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(property->value());