Diff
Modified: trunk/LayoutTests/ChangeLog (101934 => 101935)
--- trunk/LayoutTests/ChangeLog 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/LayoutTests/ChangeLog 2011-12-03 21:53:29 UTC (rev 101935)
@@ -1,3 +1,16 @@
+2011-12-03 Andreas Kling <[email protected]>
+
+ Cache CSSInitialValue instances per-document.
+ <http://webkit.org/b/73745>
+
+ Reviewed by Oliver Hunt.
+
+ Test that 'initial' and 'inherit' values are cached per-document.
+
+ * http/tests/security/cross-origin-css-primitive-expected.txt:
+ * http/tests/security/cross-origin-css-primitive.html:
+ * http/tests/security/resources/cross-origin-css-primitive-iframe.html:
+
2011-12-03 Philippe Normand <[email protected]>
Unreviewed, skip new failing tests on GTK.
Modified: trunk/LayoutTests/http/tests/security/cross-origin-css-primitive-expected.txt (101934 => 101935)
--- trunk/LayoutTests/http/tests/security/cross-origin-css-primitive-expected.txt 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/LayoutTests/http/tests/security/cross-origin-css-primitive-expected.txt 2011-12-03 21:53:29 UTC (rev 101935)
@@ -13,4 +13,6 @@
PASSED
PASSED
PASSED
+PASSED
+PASSED
Modified: trunk/LayoutTests/http/tests/security/cross-origin-css-primitive.html (101934 => 101935)
--- trunk/LayoutTests/http/tests/security/cross-origin-css-primitive.html 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/LayoutTests/http/tests/security/cross-origin-css-primitive.html 2011-12-03 21:53:29 UTC (rev 101935)
@@ -15,15 +15,17 @@
.a { color: rgb(255,255,255); }
.a { color: rgba(0,0,0,255); }
.a { color: rgba(0,0,0,0); }
+.a { color: inherit; }
+.a { color: initial; }
</style>
<script>
-primitives = new Array();
+values = new Array();
var rules = document.getElementsByTagName('style')[0].sheet.cssRules;
for(i = 0 ; i < rules.length; ++i) {
var val = rules[i].style.getPropertyCSSValue('color');
if (!val)
val = rules[i].style.getPropertyCSSValue('width');
- primitives.push(val);
+ values.push(val);
val.foo = 1;
}
</script>
Modified: trunk/LayoutTests/http/tests/security/resources/cross-origin-css-primitive-iframe.html (101934 => 101935)
--- trunk/LayoutTests/http/tests/security/resources/cross-origin-css-primitive-iframe.html 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/LayoutTests/http/tests/security/resources/cross-origin-css-primitive-iframe.html 2011-12-03 21:53:29 UTC (rev 101935)
@@ -9,15 +9,17 @@
.a { color: rgb(255,255,255); }
.a { color: rgba(0,0,0,255); }
.a { color: rgba(0,0,0,0); }
+.a { color: inherit; }
+.a { color: initial; }
</style>
<script>
-primitives = new Array();
+values = new Array();
var rules = document.getElementsByTagName('style')[0].sheet.cssRules;
for(i = 0 ; i < rules.length; ++i) {
var val = rules[i].style.getPropertyCSSValue('color');
if (!val)
val = rules[i].style.getPropertyCSSValue('width');
- primitives.push(val);
+ values.push(val);
document.write(val.foo ? "FAILED<br>" : "PASSED<br>");
}
if (window.layoutTestController)
Modified: trunk/Source/WebCore/ChangeLog (101934 => 101935)
--- trunk/Source/WebCore/ChangeLog 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/Source/WebCore/ChangeLog 2011-12-03 21:53:29 UTC (rev 101935)
@@ -1,5 +1,32 @@
2011-12-03 Andreas Kling <[email protected]>
+ Cache CSSInitialValue instances per-document.
+ <http://webkit.org/b/73745>
+
+ Reviewed by Oliver Hunt.
+
+ Test: http/tests/security/cross-origin-css-primitive.html
+
+ Have CSSValuePool manage the caching of CSSInitialValue objects.
+
+ * css/CSSInitialValue.h:
+ (WebCore::CSSInitialValue::createExplicit):
+ (WebCore::CSSInitialValue::createImplicit):
+ (WebCore::CSSInitialValue::CSSInitialValue):
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseValue):
+ (WebCore::CSSParser::parseFillShorthand):
+ (WebCore::CSSParser::parseAnimationShorthand):
+ (WebCore::CSSParser::parseTransitionShorthand):
+ (WebCore::CSSParser::parseShorthand):
+ * css/CSSValuePool.cpp:
+ (WebCore::CSSValuePool::CSSValuePool):
+ (WebCore::CSSValuePool::createImplicitInitialValue):
+ (WebCore::CSSValuePool::createExplicitInitialValue):
+ * css/CSSValuePool.h:
+
+2011-12-03 Andreas Kling <[email protected]>
+
Keep CSSInheritedValue in the CSS value pool.
<http://webkit.org/b/73747>
Modified: trunk/Source/WebCore/css/CSSInitialValue.h (101934 => 101935)
--- trunk/Source/WebCore/css/CSSInitialValue.h 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/Source/WebCore/css/CSSInitialValue.h 2011-12-03 21:53:29 UTC (rev 101935)
@@ -30,13 +30,11 @@
public:
static PassRefPtr<CSSInitialValue> createExplicit()
{
- static CSSInitialValue* explicitValue = create(false).leakRef();
- return explicitValue;
+ return adoptRef(new CSSInitialValue(/* implicit */ false));
}
static PassRefPtr<CSSInitialValue> createImplicit()
{
- static CSSInitialValue* explicitValue = create(true).leakRef();
- return explicitValue;
+ return adoptRef(new CSSInitialValue(/* implicit */ true));
}
String customCssText() const;
@@ -47,11 +45,6 @@
{
m_isImplicitInitialValue = implicit;
}
-
- static PassRefPtr<CSSInitialValue> create(bool implicit)
- {
- return adoptRef(new CSSInitialValue(implicit));
- }
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSParser.cpp (101934 => 101935)
--- trunk/Source/WebCore/css/CSSParser.cpp 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2011-12-03 21:53:29 UTC (rev 101935)
@@ -850,7 +850,7 @@
else if (id == CSSValueInitial) {
if (num != 1)
return false;
- addProperty(propId, CSSInitialValue::createExplicit(), important);
+ addProperty(propId, cssValuePool()->createExplicitInitialValue(), important);
return true;
}
@@ -2019,7 +2019,7 @@
if (parseShorthand(propId, properties, 3, important)) {
// The CSS3 Borders and Backgrounds specification says that border also resets border-image. It's as
// though a value of none was specified for the image.
- addProperty(CSSPropertyBorderImage, CSSInitialValue::createImplicit(), important);
+ addProperty(CSSPropertyBorderImage, cssValuePool()->createImplicitInitialValue(), important);
return true;
}
return false;
@@ -2301,14 +2301,14 @@
return false;
if (!parsedProperty[i] && properties[i] != CSSPropertyBackgroundColor) {
- addFillValue(values[i], CSSInitialValue::createImplicit());
+ addFillValue(values[i], cssValuePool()->createImplicitInitialValue());
if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
- addFillValue(positionYValue, CSSInitialValue::createImplicit());
+ addFillValue(positionYValue, cssValuePool()->createImplicitInitialValue());
if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
- addFillValue(repeatYValue, CSSInitialValue::createImplicit());
+ addFillValue(repeatYValue, cssValuePool()->createImplicitInitialValue());
if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) && !parsedProperty[i]) {
// If background-origin wasn't present, then reset background-clip also.
- addFillValue(clipValue, CSSInitialValue::createImplicit());
+ addFillValue(clipValue, cssValuePool()->createImplicitInitialValue());
}
}
parsedProperty[i] = false;
@@ -2336,7 +2336,7 @@
if (parseBackgroundClip(parserValue, val1, cssValuePool()))
addFillValue(clipValue, val1.release()); // The property parsed successfully.
else
- addFillValue(clipValue, CSSInitialValue::createImplicit()); // Some value was used for origin that is not supported by clip. Just reset clip instead.
+ addFillValue(clipValue, cssValuePool()->createImplicitInitialValue()); // Some value was used for origin that is not supported by clip. Just reset clip instead.
}
if (properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) {
// Update clipValue
@@ -2356,14 +2356,14 @@
// Fill in any remaining properties with the initial value.
for (i = 0; i < numProperties; ++i) {
if (!parsedProperty[i]) {
- addFillValue(values[i], CSSInitialValue::createImplicit());
+ addFillValue(values[i], cssValuePool()->createImplicitInitialValue());
if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
- addFillValue(positionYValue, CSSInitialValue::createImplicit());
+ addFillValue(positionYValue, cssValuePool()->createImplicitInitialValue());
if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
- addFillValue(repeatYValue, CSSInitialValue::createImplicit());
+ addFillValue(repeatYValue, cssValuePool()->createImplicitInitialValue());
if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) && !parsedProperty[i]) {
// If background-origin wasn't present, then reset background-clip also.
- addFillValue(clipValue, CSSInitialValue::createImplicit());
+ addFillValue(clipValue, cssValuePool()->createImplicitInitialValue());
}
}
}
@@ -2443,7 +2443,7 @@
m_valueList->next();
for (i = 0; i < numProperties; ++i) {
if (!parsedProperty[i])
- addAnimationValue(values[i], CSSInitialValue::createImplicit());
+ addAnimationValue(values[i], cssValuePool()->createImplicitInitialValue());
parsedProperty[i] = false;
}
if (!m_valueList->current())
@@ -2470,7 +2470,7 @@
// Fill in any remaining properties with the initial value.
for (i = 0; i < numProperties; ++i) {
if (!parsedProperty[i])
- addAnimationValue(values[i], CSSInitialValue::createImplicit());
+ addAnimationValue(values[i], cssValuePool()->createImplicitInitialValue());
}
// Now add all of the properties we found.
@@ -2501,7 +2501,7 @@
m_valueList->next();
for (i = 0; i < numProperties; ++i) {
if (!parsedProperty[i])
- addAnimationValue(values[i], CSSInitialValue::createImplicit());
+ addAnimationValue(values[i], cssValuePool()->createImplicitInitialValue());
parsedProperty[i] = false;
}
if (!m_valueList->current())
@@ -2528,7 +2528,7 @@
// Fill in any remaining properties with the initial value.
for (i = 0; i < numProperties; ++i) {
if (!parsedProperty[i])
- addAnimationValue(values[i], CSSInitialValue::createImplicit());
+ addAnimationValue(values[i], cssValuePool()->createImplicitInitialValue());
}
// Now add all of the properties we found.
@@ -2569,7 +2569,7 @@
ImplicitScope implicitScope(this, PropertyImplicit);
for (int i = 0; i < numProperties; ++i) {
if (!fnd[i])
- addProperty(properties[i], CSSInitialValue::createImplicit(), important);
+ addProperty(properties[i], cssValuePool()->createImplicitInitialValue(), important);
}
return true;
Modified: trunk/Source/WebCore/css/CSSValuePool.cpp (101934 => 101935)
--- trunk/Source/WebCore/css/CSSValuePool.cpp 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/Source/WebCore/css/CSSValuePool.cpp 2011-12-03 21:53:29 UTC (rev 101935)
@@ -31,6 +31,8 @@
CSSValuePool::CSSValuePool()
: m_inheritedValue(CSSInheritedValue::create())
+ , m_implicitInitialValue(CSSInitialValue::createImplicit())
+ , m_explicitInitialValue(CSSInitialValue::createExplicit())
, m_colorTransparent(CSSPrimitiveValue::createColor(Color::transparent))
, m_colorWhite(CSSPrimitiveValue::createColor(Color::white))
, m_colorBlack(CSSPrimitiveValue::createColor(Color::black))
@@ -49,6 +51,16 @@
return m_inheritedValue;
}
+PassRefPtr<CSSInitialValue> CSSValuePool::createImplicitInitialValue()
+{
+ return m_implicitInitialValue;
+}
+
+PassRefPtr<CSSInitialValue> CSSValuePool::createExplicitInitialValue()
+{
+ return m_explicitInitialValue;
+}
+
PassRefPtr<CSSPrimitiveValue> CSSValuePool::createIdentifierValue(int ident)
{
if (ident <= 0 || ident >= numCSSValueKeywords)
Modified: trunk/Source/WebCore/css/CSSValuePool.h (101934 => 101935)
--- trunk/Source/WebCore/css/CSSValuePool.h 2011-12-03 21:45:35 UTC (rev 101934)
+++ trunk/Source/WebCore/css/CSSValuePool.h 2011-12-03 21:53:29 UTC (rev 101935)
@@ -27,6 +27,7 @@
#define CSSValuePool_h
#include "CSSInheritedValue.h"
+#include "CSSInitialValue.h"
#include "CSSPrimitiveValue.h"
#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
@@ -39,6 +40,8 @@
~CSSValuePool();
PassRefPtr<CSSInheritedValue> createInheritedValue();
+ PassRefPtr<CSSInitialValue> createImplicitInitialValue();
+ PassRefPtr<CSSInitialValue> createExplicitInitialValue();
PassRefPtr<CSSPrimitiveValue> createIdentifierValue(int identifier);
PassRefPtr<CSSPrimitiveValue> createColorValue(unsigned rgbValue);
PassRefPtr<CSSPrimitiveValue> createValue(double value, CSSPrimitiveValue::UnitTypes);
@@ -49,6 +52,8 @@
CSSValuePool();
RefPtr<CSSInheritedValue> m_inheritedValue;
+ RefPtr<CSSInitialValue> m_implicitInitialValue;
+ RefPtr<CSSInitialValue> m_explicitInitialValue;
typedef HashMap<int, RefPtr<CSSPrimitiveValue> > IdentifierValueCache;
IdentifierValueCache m_identifierValueCache;