Source/WebCore/ChangeLog

 12012-04-10 Andreas Kling <kling@webkit.org>
 2
 3 REGRESSION(r113588): 15-30% perf. regression on CSS/CSSPropertySetterGetter.
 4 <http://webkit.org/b/83540>
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Avoid constructing "safe" CSSValue objects in the bindings layer, for the cases where
 9 we only want to extract the cssText or numeric value. The safe objects are only needed
 10 when exposing fully-fledged CSSValues to the web.
 11
 12 Added CSSStyleDeclaration::getUnsafePropertyCSSValueInternal() for this purpose.
 13 There is already an assertion in the CSSValue bindings that will catch anyone trying
 14 to expose these values to the web.
 15
 16 * bindings/js/JSCSSStyleDeclarationCustom.cpp:
 17 (WebCore::cssPropertyGetterPixelOrPosPrefix):
 18 (WebCore::cssPropertyGetter):
 19 * bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp:
 20 (WebCore::V8CSSStyleDeclaration::namedPropertyGetter):
 21 * css/CSSComputedStyleDeclaration.cpp:
 22 (WebCore):
 23 (WebCore::CSSComputedStyleDeclaration::getUnsafePropertyCSSValueInternal):
 24 * css/CSSComputedStyleDeclaration.h:
 25 (CSSComputedStyleDeclaration):
 26 * css/CSSStyleDeclaration.h:
 27 (CSSStyleDeclaration):
 28 * css/PropertySetCSSStyleDeclaration.cpp:
 29 (WebCore::PropertySetCSSStyleDeclaration::getUnsafePropertyCSSValueInternal):
 30 (WebCore):
 31 * css/PropertySetCSSStyleDeclaration.h:
 32
1332012-04-09 Andreas Kling <kling@webkit.org>
234
335 Make CSSValuePool share values globally.

Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp

@@static inline JSValue cssPropertyGetterPixelOrPosPrefix(ExecState* exec, JSCSSSt
280280 // posTop returns "CSS top" as number value in unit pixels _if_ its a
281281 // positioned element. if it is not a positioned element, return 0
282282 // from MSIE documentation FIXME: IMPLEMENT THAT (Dirk)
283  RefPtr<CSSValue> v = thisObj->impl()->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propertyID));
 283 RefPtr<CSSValue> v = thisObj->impl()->getUnsafePropertyCSSValueInternal(static_cast<CSSPropertyID>(propertyID));
284284 if (v) {
285285 if (v->isPrimitiveValue())
286286 return jsNumber(static_pointer_cast<CSSPrimitiveValue>(v)->getFloatValue(CSSPrimitiveValue::CSS_PX));

@@static JSValue cssPropertyGetterPixelOrPosPrefixCallback(ExecState* exec, JSValu
297297
298298static inline JSValue cssPropertyGetter(ExecState* exec, JSCSSStyleDeclaration* thisObj, unsigned propertyID)
299299{
300  RefPtr<CSSValue> v = thisObj->impl()->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propertyID));
 300 RefPtr<CSSValue> v = thisObj->impl()->getUnsafePropertyCSSValueInternal(static_cast<CSSPropertyID>(propertyID));
301301 if (v)
302302 return jsStringOrNull(exec, v->cssText());
303303

Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp

@@v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertyGetter(v8::Local<v8::S
202202 return notHandledByInterceptor();
203203
204204 CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder());
205  RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
 205 RefPtr<CSSValue> cssValue = imp->getUnsafePropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
206206 if (cssValue) {
207207 if (propInfo->hadPixelOrPosPrefix &&
208208 cssValue->isPrimitiveValue()) {

Source/WebCore/css/CSSComputedStyleDeclaration.cpp

@@String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode&
26852685 ec = NO_MODIFICATION_ALLOWED_ERR;
26862686 return String();
26872687}
2688 
 2688
 2689PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getUnsafePropertyCSSValueInternal(CSSPropertyID propertyID)
 2690{
 2691 return getPropertyCSSValue(propertyID);
 2692}
 2693
26892694PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
26902695{
26912696 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);

Source/WebCore/css/CSSComputedStyleDeclaration.h

@@private:
9191 virtual PassRefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID);
9292 virtual String getPropertyValueInternal(CSSPropertyID);
9393 virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&);
 94 virtual PassRefPtr<CSSValue> getUnsafePropertyCSSValueInternal(CSSPropertyID) OVERRIDE;
9495
9596 virtual bool cssPropertyMatches(const CSSProperty*) const;
9697

Source/WebCore/css/CSSStyleDeclaration.h

@@public:
6262 virtual String getPropertyValueInternal(CSSPropertyID) = 0;
6363 virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&) = 0;
6464
 65 // This function peeks at the internal CSSValue, which must not be exposed to bindings,
 66 // as they may be shared between multiple documents.
 67 virtual PassRefPtr<CSSValue> getUnsafePropertyCSSValueInternal(CSSPropertyID) = 0;
 68
6569 virtual PassRefPtr<StylePropertySet> copy() const = 0;
6670 virtual PassRefPtr<StylePropertySet> makeMutable() = 0;
6771

Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

@@String PropertySetCSSStyleDeclaration::removeProperty(const String& propertyName
245245 return result;
246246}
247247
 248PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getUnsafePropertyCSSValueInternal(CSSPropertyID propertyID)
 249{
 250 return m_propertySet->getPropertyCSSValue(propertyID);
 251}
 252
248253PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
249254{
250255 return cloneAndCacheForCSSOM(m_propertySet->getPropertyCSSValue(propertyID).get());

Source/WebCore/css/PropertySetCSSStyleDeclaration.h

@@private:
6464 virtual PassRefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) OVERRIDE;
6565 virtual String getPropertyValueInternal(CSSPropertyID) OVERRIDE;
6666 virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&) OVERRIDE;
 67 virtual PassRefPtr<CSSValue> getUnsafePropertyCSSValueInternal(CSSPropertyID) OVERRIDE;
6768
6869 virtual bool cssPropertyMatches(const CSSProperty*) const OVERRIDE;
6970 virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;