summaryrefslogtreecommitdiff
path: root/Source/WebCore/css
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
commit284837daa07b29d6a63a748544a90b1f5842ac5c (patch)
treeecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebCore/css
parent2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff)
downloadqtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebCore/css')
-rw-r--r--Source/WebCore/css/BasicShapeFunctions.cpp (renamed from Source/WebCore/css/WrapShapeFunctions.cpp)86
-rw-r--r--Source/WebCore/css/BasicShapeFunctions.h (renamed from Source/WebCore/css/WrapShapeFunctions.h)12
-rw-r--r--Source/WebCore/css/CSSAllInOne.cpp2
-rw-r--r--Source/WebCore/css/CSSAspectRatioValue.cpp4
-rw-r--r--Source/WebCore/css/CSSBasicShapes.cpp (renamed from Source/WebCore/css/CSSWrapShapes.cpp)61
-rw-r--r--Source/WebCore/css/CSSBasicShapes.h (renamed from Source/WebCore/css/CSSWrapShapes.h)54
-rw-r--r--Source/WebCore/css/CSSBorderImageSliceValue.cpp8
-rwxr-xr-xSource/WebCore/css/CSSCalculationValue.cpp149
-rwxr-xr-xSource/WebCore/css/CSSCalculationValue.h11
-rw-r--r--Source/WebCore/css/CSSCanvasValue.cpp13
-rw-r--r--Source/WebCore/css/CSSCharsetRule.cpp4
-rw-r--r--Source/WebCore/css/CSSCharsetRule.h2
-rw-r--r--Source/WebCore/css/CSSComputedStyleDeclaration.cpp140
-rw-r--r--Source/WebCore/css/CSSComputedStyleDeclaration.h10
-rw-r--r--Source/WebCore/css/CSSCrossfadeValue.cpp20
-rw-r--r--Source/WebCore/css/CSSCursorImageValue.cpp6
-rw-r--r--Source/WebCore/css/CSSFontFaceRule.cpp18
-rw-r--r--Source/WebCore/css/CSSFontFaceSrcValue.cpp24
-rw-r--r--Source/WebCore/css/CSSFontFaceSrcValue.h2
-rw-r--r--Source/WebCore/css/CSSFunctionValue.cpp14
-rw-r--r--Source/WebCore/css/CSSGradientValue.cpp182
-rw-r--r--Source/WebCore/css/CSSGrammar.y31
-rw-r--r--Source/WebCore/css/CSSImageGeneratorValue.cpp4
-rw-r--r--Source/WebCore/css/CSSImageSetValue.cpp6
-rw-r--r--Source/WebCore/css/CSSImageValue.cpp4
-rw-r--r--Source/WebCore/css/CSSImportRule.cpp11
-rw-r--r--Source/WebCore/css/CSSImportRule.h2
-rw-r--r--Source/WebCore/css/CSSInheritedValue.cpp6
-rw-r--r--Source/WebCore/css/CSSInitialValue.cpp6
-rw-r--r--Source/WebCore/css/CSSLineBoxContainValue.cpp33
-rw-r--r--Source/WebCore/css/CSSMediaRule.cpp4
-rw-r--r--Source/WebCore/css/CSSMediaRule.h2
-rw-r--r--Source/WebCore/css/CSSPageRule.cpp29
-rw-r--r--Source/WebCore/css/CSSParser.cpp1235
-rw-r--r--Source/WebCore/css/CSSParser.h128
-rw-r--r--Source/WebCore/css/CSSParserValues.cpp92
-rw-r--r--Source/WebCore/css/CSSParserValues.h70
-rw-r--r--Source/WebCore/css/CSSPrimitiveValue.cpp104
-rw-r--r--Source/WebCore/css/CSSPrimitiveValue.h12
-rw-r--r--Source/WebCore/css/CSSPrimitiveValueMappings.h20
-rw-r--r--Source/WebCore/css/CSSProperty.cpp20
-rw-r--r--Source/WebCore/css/CSSPropertyNames.in4
-rw-r--r--Source/WebCore/css/CSSPropertySourceData.cpp19
-rw-r--r--Source/WebCore/css/CSSPropertySourceData.h2
-rw-r--r--Source/WebCore/css/CSSReflectValue.cpp23
-rw-r--r--Source/WebCore/css/CSSRule.cpp2
-rw-r--r--Source/WebCore/css/CSSRuleList.cpp2
-rw-r--r--Source/WebCore/css/CSSRuleList.h4
-rw-r--r--Source/WebCore/css/CSSSelector.cpp70
-rw-r--r--Source/WebCore/css/CSSSelectorList.cpp4
-rw-r--r--Source/WebCore/css/CSSStyleRule.cpp25
-rw-r--r--Source/WebCore/css/CSSStyleSheet.cpp37
-rw-r--r--Source/WebCore/css/CSSStyleSheet.h3
-rw-r--r--Source/WebCore/css/CSSTimingFunctionValue.cpp32
-rw-r--r--Source/WebCore/css/CSSToStyleMap.cpp2
-rw-r--r--Source/WebCore/css/CSSUnicodeRangeValue.cpp6
-rw-r--r--Source/WebCore/css/CSSUnknownRule.h4
-rw-r--r--Source/WebCore/css/CSSValue.cpp15
-rw-r--r--Source/WebCore/css/CSSValue.h5
-rw-r--r--Source/WebCore/css/CSSValueKeywords.in5
-rw-r--r--Source/WebCore/css/CSSValueList.cpp5
-rw-r--r--Source/WebCore/css/CSSVariableValue.h4
-rw-r--r--Source/WebCore/css/Counter.h2
-rw-r--r--Source/WebCore/css/FontFeatureValue.cpp10
-rw-r--r--Source/WebCore/css/FontFeatureValue.h2
-rw-r--r--Source/WebCore/css/FontValue.cpp5
-rw-r--r--Source/WebCore/css/LengthFunctions.cpp1
-rw-r--r--Source/WebCore/css/MediaList.cpp15
-rw-r--r--Source/WebCore/css/MediaQuery.cpp4
-rw-r--r--Source/WebCore/css/MediaQuery.h2
-rw-r--r--Source/WebCore/css/MediaQueryEvaluator.h2
-rw-r--r--Source/WebCore/css/MediaQueryExp.cpp4
-rw-r--r--Source/WebCore/css/MediaQueryListListener.h3
-rw-r--r--Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp8
-rw-r--r--Source/WebCore/css/ShadowValue.cpp33
-rw-r--r--Source/WebCore/css/StyleBuilder.cpp85
-rw-r--r--Source/WebCore/css/StyleMedia.h2
-rw-r--r--Source/WebCore/css/StylePropertySet.cpp172
-rw-r--r--Source/WebCore/css/StylePropertySet.h5
-rw-r--r--Source/WebCore/css/StylePropertyShorthand.cpp4
-rw-r--r--Source/WebCore/css/StylePropertyShorthand.h2
-rw-r--r--Source/WebCore/css/StyleResolver.cpp113
-rw-r--r--Source/WebCore/css/StyleResolver.h4
-rw-r--r--Source/WebCore/css/StyleRule.cpp16
-rw-r--r--Source/WebCore/css/StyleRuleImport.cpp132
-rw-r--r--Source/WebCore/css/StyleRuleImport.h42
-rw-r--r--Source/WebCore/css/StyleSheet.h2
-rw-r--r--Source/WebCore/css/StyleSheetContents.cpp155
-rw-r--r--Source/WebCore/css/StyleSheetContents.h32
-rw-r--r--Source/WebCore/css/StyleSheetList.cpp2
-rw-r--r--Source/WebCore/css/WebKitCSSArrayFunctionValue.cpp67
-rw-r--r--Source/WebCore/css/WebKitCSSArrayFunctionValue.h62
-rw-r--r--Source/WebCore/css/WebKitCSSFilterValue.cpp4
-rw-r--r--Source/WebCore/css/WebKitCSSKeyframeRule.cpp23
-rw-r--r--Source/WebCore/css/WebKitCSSKeyframesRule.cpp6
-rw-r--r--Source/WebCore/css/WebKitCSSMatrix.h2
-rw-r--r--Source/WebCore/css/WebKitCSSMixFunctionValue.cpp4
-rw-r--r--Source/WebCore/css/WebKitCSSMixFunctionValue.h4
-rw-r--r--Source/WebCore/css/WebKitCSSRegionRule.cpp2
-rw-r--r--Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp4
-rw-r--r--Source/WebCore/css/WebKitCSSShaderValue.cpp4
-rw-r--r--Source/WebCore/css/WebKitCSSTransformValue.cpp6
-rw-r--r--Source/WebCore/css/html.css4
-rw-r--r--Source/WebCore/css/mathml.css38
-rw-r--r--Source/WebCore/css/mediaControlsChromium.css13
105 files changed, 2446 insertions, 1570 deletions
diff --git a/Source/WebCore/css/WrapShapeFunctions.cpp b/Source/WebCore/css/BasicShapeFunctions.cpp
index 6ca634169..3a8f7953b 100644
--- a/Source/WebCore/css/WrapShapeFunctions.cpp
+++ b/Source/WebCore/css/BasicShapeFunctions.cpp
@@ -28,23 +28,23 @@
*/
#include "config.h"
-#include "WrapShapeFunctions.h"
+#include "BasicShapeFunctions.h"
+#include "BasicShapes.h"
+#include "CSSBasicShapes.h"
#include "CSSPrimitiveValueMappings.h"
#include "CSSValuePool.h"
-#include "CSSWrapShapes.h"
#include "StyleResolver.h"
-#include "WrapShapes.h"
namespace WebCore {
-PassRefPtr<CSSValue> valueForWrapShape(const WrapShape* wrapShape)
+PassRefPtr<CSSValue> valueForBasicShape(const BasicShape* basicShape)
{
- RefPtr<CSSWrapShape> wrapShapeValue;
- switch (wrapShape->type()) {
- case WrapShape::WRAP_SHAPE_RECTANGLE: {
- const WrapShapeRectangle* rectangle = static_cast<const WrapShapeRectangle*>(wrapShape);
- RefPtr<CSSWrapShapeRectangle> rectangleValue = CSSWrapShapeRectangle::create();
+ RefPtr<CSSBasicShape> basicShapeValue;
+ switch (basicShape->type()) {
+ case BasicShape::BASIC_SHAPE_RECTANGLE: {
+ const BasicShapeRectangle* rectangle = static_cast<const BasicShapeRectangle*>(basicShape);
+ RefPtr<CSSBasicShapeRectangle> rectangleValue = CSSBasicShapeRectangle::create();
rectangleValue->setX(cssValuePool().createValue(rectangle->x()));
rectangleValue->setY(cssValuePool().createValue(rectangle->y()));
@@ -56,48 +56,48 @@ PassRefPtr<CSSValue> valueForWrapShape(const WrapShape* wrapShape)
rectangleValue->setRadiusY(cssValuePool().createValue(rectangle->cornerRadiusY()));
}
- wrapShapeValue = rectangleValue.release();
+ basicShapeValue = rectangleValue.release();
break;
}
- case WrapShape::WRAP_SHAPE_CIRCLE: {
- const WrapShapeCircle* circle = static_cast<const WrapShapeCircle*>(wrapShape);
- RefPtr<CSSWrapShapeCircle> circleValue = CSSWrapShapeCircle::create();
+ case BasicShape::BASIC_SHAPE_CIRCLE: {
+ const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(basicShape);
+ RefPtr<CSSBasicShapeCircle> circleValue = CSSBasicShapeCircle::create();
circleValue->setCenterX(cssValuePool().createValue(circle->centerX()));
circleValue->setCenterY(cssValuePool().createValue(circle->centerY()));
circleValue->setRadius(cssValuePool().createValue(circle->radius()));
- wrapShapeValue = circleValue.release();
+ basicShapeValue = circleValue.release();
break;
}
- case WrapShape::WRAP_SHAPE_ELLIPSE: {
- const WrapShapeEllipse* ellipse = static_cast<const WrapShapeEllipse*>(wrapShape);
- RefPtr<CSSWrapShapeEllipse> ellipseValue = CSSWrapShapeEllipse::create();
+ case BasicShape::BASIC_SHAPE_ELLIPSE: {
+ const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*>(basicShape);
+ RefPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEllipse::create();
ellipseValue->setCenterX(cssValuePool().createValue(ellipse->centerX()));
ellipseValue->setCenterY(cssValuePool().createValue(ellipse->centerY()));
ellipseValue->setRadiusX(cssValuePool().createValue(ellipse->radiusX()));
ellipseValue->setRadiusY(cssValuePool().createValue(ellipse->radiusY()));
- wrapShapeValue = ellipseValue.release();
+ basicShapeValue = ellipseValue.release();
break;
}
- case WrapShape::WRAP_SHAPE_POLYGON: {
- const WrapShapePolygon* polygon = static_cast<const WrapShapePolygon*>(wrapShape);
- RefPtr<CSSWrapShapePolygon> polygonValue = CSSWrapShapePolygon::create();
+ case BasicShape::BASIC_SHAPE_POLYGON: {
+ const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*>(basicShape);
+ RefPtr<CSSBasicShapePolygon> polygonValue = CSSBasicShapePolygon::create();
polygonValue->setWindRule(polygon->windRule());
const Vector<Length>& values = polygon->values();
for (unsigned i = 0; i < values.size(); i += 2)
polygonValue->appendPoint(cssValuePool().createValue(values.at(i)), cssValuePool().createValue(values.at(i + 1)));
- wrapShapeValue = polygonValue.release();
+ basicShapeValue = polygonValue.release();
break;
}
default:
break;
}
- return cssValuePool().createValue<PassRefPtr<CSSWrapShape> >(wrapShapeValue.release());
+ return cssValuePool().createValue<PassRefPtr<CSSBasicShape> >(basicShapeValue.release());
}
static Length convertToLength(const StyleResolver* styleResolver, CSSPrimitiveValue* value)
@@ -105,14 +105,14 @@ static Length convertToLength(const StyleResolver* styleResolver, CSSPrimitiveVa
return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
}
-PassRefPtr<WrapShape> wrapShapeForValue(const StyleResolver* styleResolver, const CSSWrapShape* wrapShapeValue)
+PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver* styleResolver, const CSSBasicShape* basicShapeValue)
{
- RefPtr<WrapShape> wrapShape;
+ RefPtr<BasicShape> basicShape;
- switch (wrapShapeValue->type()) {
- case CSSWrapShape::CSS_WRAP_SHAPE_RECTANGLE: {
- const CSSWrapShapeRectangle* rectValue = static_cast<const CSSWrapShapeRectangle *>(wrapShapeValue);
- RefPtr<WrapShapeRectangle> rect = WrapShapeRectangle::create();
+ switch (basicShapeValue->type()) {
+ case CSSBasicShape::CSS_BASIC_SHAPE_RECTANGLE: {
+ const CSSBasicShapeRectangle* rectValue = static_cast<const CSSBasicShapeRectangle *>(basicShapeValue);
+ RefPtr<BasicShapeRectangle> rect = BasicShapeRectangle::create();
rect->setX(convertToLength(styleResolver, rectValue->x()));
rect->setY(convertToLength(styleResolver, rectValue->y()));
@@ -123,47 +123,47 @@ PassRefPtr<WrapShape> wrapShapeForValue(const StyleResolver* styleResolver, cons
if (rectValue->radiusY())
rect->setCornerRadiusY(convertToLength(styleResolver, rectValue->radiusY()));
}
- wrapShape = rect.release();
+ basicShape = rect.release();
break;
}
- case CSSWrapShape::CSS_WRAP_SHAPE_CIRCLE: {
- const CSSWrapShapeCircle* circleValue = static_cast<const CSSWrapShapeCircle *>(wrapShapeValue);
- RefPtr<WrapShapeCircle> circle = WrapShapeCircle::create();
+ case CSSBasicShape::CSS_BASIC_SHAPE_CIRCLE: {
+ const CSSBasicShapeCircle* circleValue = static_cast<const CSSBasicShapeCircle *>(basicShapeValue);
+ RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
circle->setCenterX(convertToLength(styleResolver, circleValue->centerX()));
circle->setCenterY(convertToLength(styleResolver, circleValue->centerY()));
circle->setRadius(convertToLength(styleResolver, circleValue->radius()));
- wrapShape = circle.release();
+ basicShape = circle.release();
break;
}
- case CSSWrapShape::CSS_WRAP_SHAPE_ELLIPSE: {
- const CSSWrapShapeEllipse* ellipseValue = static_cast<const CSSWrapShapeEllipse *>(wrapShapeValue);
- RefPtr<WrapShapeEllipse> ellipse = WrapShapeEllipse::create();
+ case CSSBasicShape::CSS_BASIC_SHAPE_ELLIPSE: {
+ const CSSBasicShapeEllipse* ellipseValue = static_cast<const CSSBasicShapeEllipse *>(basicShapeValue);
+ RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
ellipse->setCenterX(convertToLength(styleResolver, ellipseValue->centerX()));
ellipse->setCenterY(convertToLength(styleResolver, ellipseValue->centerY()));
ellipse->setRadiusX(convertToLength(styleResolver, ellipseValue->radiusX()));
ellipse->setRadiusY(convertToLength(styleResolver, ellipseValue->radiusY()));
- wrapShape = ellipse.release();
+ basicShape = ellipse.release();
break;
}
- case CSSWrapShape::CSS_WRAP_SHAPE_POLYGON: {
- const CSSWrapShapePolygon* polygonValue = static_cast<const CSSWrapShapePolygon *>(wrapShapeValue);
- RefPtr<WrapShapePolygon> polygon = WrapShapePolygon::create();
+ case CSSBasicShape::CSS_BASIC_SHAPE_POLYGON: {
+ const CSSBasicShapePolygon* polygonValue = static_cast<const CSSBasicShapePolygon *>(basicShapeValue);
+ RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
polygon->setWindRule(polygonValue->windRule());
const Vector<RefPtr<CSSPrimitiveValue> >& values = polygonValue->values();
for (unsigned i = 0; i < values.size(); i += 2)
polygon->appendPoint(convertToLength(styleResolver, values.at(i).get()), convertToLength(styleResolver, values.at(i + 1).get()));
- wrapShape = polygon.release();
+ basicShape = polygon.release();
break;
}
default:
break;
}
- return wrapShape.release();
+ return basicShape.release();
}
}
diff --git a/Source/WebCore/css/WrapShapeFunctions.h b/Source/WebCore/css/BasicShapeFunctions.h
index d3b953c61..d3607e909 100644
--- a/Source/WebCore/css/WrapShapeFunctions.h
+++ b/Source/WebCore/css/BasicShapeFunctions.h
@@ -27,20 +27,20 @@
* SUCH DAMAGE.
*/
-#ifndef WrapShapeFunctions_h
-#define WrapShapeFunctions_h
+#ifndef BasicShapeFunctions_h
+#define BasicShapeFunctions_h
#include <wtf/PassRefPtr.h>
namespace WebCore {
+class BasicShape;
+class CSSBasicShape;
class CSSValue;
-class CSSWrapShape;
class StyleResolver;
-class WrapShape;
-PassRefPtr<CSSValue> valueForWrapShape(const WrapShape*);
-PassRefPtr<WrapShape> wrapShapeForValue(const StyleResolver*, const CSSWrapShape*);
+PassRefPtr<CSSValue> valueForBasicShape(const BasicShape*);
+PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver*, const CSSBasicShape*);
}
#endif
diff --git a/Source/WebCore/css/CSSAllInOne.cpp b/Source/WebCore/css/CSSAllInOne.cpp
index 2ce1e36dd..193b7afc4 100644
--- a/Source/WebCore/css/CSSAllInOne.cpp
+++ b/Source/WebCore/css/CSSAllInOne.cpp
@@ -26,6 +26,7 @@
// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
#include "CSSAspectRatioValue.cpp"
+#include "CSSBasicShapes.cpp"
#include "CSSBorderImage.cpp"
#include "CSSBorderImageSliceValue.cpp"
#include "CSSCanvasValue.cpp"
@@ -65,7 +66,6 @@
#include "CSSValue.cpp"
#include "CSSValueList.cpp"
#include "CSSValuePool.cpp"
-#include "CSSWrapShapes.cpp"
#include "StyleBuilder.cpp"
#include "StylePropertySet.cpp"
#include "StylePropertyShorthand.cpp"
diff --git a/Source/WebCore/css/CSSAspectRatioValue.cpp b/Source/WebCore/css/CSSAspectRatioValue.cpp
index 5897f5111..15292be2e 100644
--- a/Source/WebCore/css/CSSAspectRatioValue.cpp
+++ b/Source/WebCore/css/CSSAspectRatioValue.cpp
@@ -29,7 +29,7 @@
#include "config.h"
#include "CSSAspectRatioValue.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -45,7 +45,7 @@ String CSSAspectRatioValue::customCssText() const
void CSSAspectRatioValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
}
diff --git a/Source/WebCore/css/CSSWrapShapes.cpp b/Source/WebCore/css/CSSBasicShapes.cpp
index 16ecc8021..c07d663c6 100644
--- a/Source/WebCore/css/CSSWrapShapes.cpp
+++ b/Source/WebCore/css/CSSBasicShapes.cpp
@@ -29,7 +29,7 @@
#include "config.h"
-#include "CSSWrapShapes.h"
+#include "CSSBasicShapes.h"
#include <wtf/text/StringBuilder.h>
@@ -37,32 +37,30 @@ using namespace WTF;
namespace WebCore {
-String CSSWrapShapeRectangle::cssText() const
+String CSSBasicShapeRectangle::cssText() const
{
- DEFINE_STATIC_LOCAL(const String, rectangleParen, ("rectangle("));
- DEFINE_STATIC_LOCAL(const String, comma, (", "));
-
StringBuilder result;
result.reserveCapacity(32);
- result.append(rectangleParen);
+
+ result.appendLiteral("rectangle(");
result.append(m_x->cssText());
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_y->cssText());
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_width->cssText());
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_height->cssText());
if (m_radiusX.get()) {
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_radiusX->cssText());
if (m_radiusY.get()) {
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_radiusY->cssText());
}
}
@@ -72,20 +70,18 @@ String CSSWrapShapeRectangle::cssText() const
return result.toString();
}
-String CSSWrapShapeCircle::cssText() const
+String CSSBasicShapeCircle::cssText() const
{
- DEFINE_STATIC_LOCAL(const String, circleParen, ("circle("));
- DEFINE_STATIC_LOCAL(const String, comma, (", "));
-
StringBuilder result;
result.reserveCapacity(32);
- result.append(circleParen);
+
+ result.appendLiteral("circle(");
result.append(m_centerX->cssText());
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_centerY->cssText());
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_radius->cssText());
result.append(')');
@@ -93,23 +89,20 @@ String CSSWrapShapeCircle::cssText() const
return result.toString();
}
-String CSSWrapShapeEllipse::cssText() const
+String CSSBasicShapeEllipse::cssText() const
{
- DEFINE_STATIC_LOCAL(const String, ellipseParen, ("ellipse("));
- DEFINE_STATIC_LOCAL(const String, comma, (", "));
-
StringBuilder result;
result.reserveCapacity(32);
- result.append(ellipseParen);
+ result.appendLiteral("ellipse(");
result.append(m_centerX->cssText());
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_centerY->cssText());
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_radiusX->cssText());
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_radiusY->cssText());
result.append(')');
@@ -117,27 +110,23 @@ String CSSWrapShapeEllipse::cssText() const
return result.toString();
}
-String CSSWrapShapePolygon::cssText() const
+String CSSBasicShapePolygon::cssText() const
{
- DEFINE_STATIC_LOCAL(const String, polygonParenEvenOdd, ("polygon(evenodd, "));
- DEFINE_STATIC_LOCAL(const String, polygonParenNonZero, ("polygon(nonzero, "));
- DEFINE_STATIC_LOCAL(const String, comma, (", "));
- DEFINE_STATIC_LOCAL(const String, space, (" "));
-
StringBuilder result;
result.reserveCapacity(32);
+
if (m_windRule == RULE_EVENODD)
- result.append(polygonParenEvenOdd);
+ result.appendLiteral("polygon(evenodd, ");
else
- result.append(polygonParenNonZero);
+ result.appendLiteral("polygon(nonzero, ");
ASSERT(!(m_values.size() % 2));
for (unsigned i = 0; i < m_values.size(); i += 2) {
if (i)
- result.append(comma);
+ result.appendLiteral(", ");
result.append(m_values.at(i)->cssText());
- result.append(space);
+ result.append(' ');
result.append(m_values.at(i + 1)->cssText());
}
diff --git a/Source/WebCore/css/CSSWrapShapes.h b/Source/WebCore/css/CSSBasicShapes.h
index 347bb3410..34e7ef0b2 100644
--- a/Source/WebCore/css/CSSWrapShapes.h
+++ b/Source/WebCore/css/CSSBasicShapes.h
@@ -27,39 +27,39 @@
* SUCH DAMAGE.
*/
-#ifndef CSSWrapShapes_h
-#define CSSWrapShapes_h
+#ifndef CSSBasicShapes_h
+#define CSSBasicShapes_h
#include "CSSPrimitiveValue.h"
-#include "PlatformString.h"
#include "WindRule.h"
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
-class CSSWrapShape : public RefCounted<CSSWrapShape> {
+class CSSBasicShape : public RefCounted<CSSBasicShape> {
public:
enum Type {
- CSS_WRAP_SHAPE_RECTANGLE = 1,
- CSS_WRAP_SHAPE_CIRCLE = 2,
- CSS_WRAP_SHAPE_ELLIPSE = 3,
- CSS_WRAP_SHAPE_POLYGON = 4
+ CSS_BASIC_SHAPE_RECTANGLE = 1,
+ CSS_BASIC_SHAPE_CIRCLE = 2,
+ CSS_BASIC_SHAPE_ELLIPSE = 3,
+ CSS_BASIC_SHAPE_POLYGON = 4
};
virtual Type type() const = 0;
virtual String cssText() const = 0;
public:
- virtual ~CSSWrapShape() { }
+ virtual ~CSSBasicShape() { }
protected:
- CSSWrapShape() { }
+ CSSBasicShape() { }
};
-class CSSWrapShapeRectangle : public CSSWrapShape {
+class CSSBasicShapeRectangle : public CSSBasicShape {
public:
- static PassRefPtr<CSSWrapShapeRectangle> create() { return adoptRef(new CSSWrapShapeRectangle); }
+ static PassRefPtr<CSSBasicShapeRectangle> create() { return adoptRef(new CSSBasicShapeRectangle); }
CSSPrimitiveValue* x() const { return m_x.get(); }
CSSPrimitiveValue* y() const { return m_y.get(); }
@@ -75,11 +75,11 @@ public:
void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
- virtual Type type() const { return CSS_WRAP_SHAPE_RECTANGLE; }
+ virtual Type type() const { return CSS_BASIC_SHAPE_RECTANGLE; }
virtual String cssText() const;
private:
- CSSWrapShapeRectangle() { }
+ CSSBasicShapeRectangle() { }
RefPtr<CSSPrimitiveValue> m_y;
RefPtr<CSSPrimitiveValue> m_x;
@@ -89,9 +89,9 @@ private:
RefPtr<CSSPrimitiveValue> m_radiusY;
};
-class CSSWrapShapeCircle : public CSSWrapShape {
+class CSSBasicShapeCircle : public CSSBasicShape {
public:
- static PassRefPtr<CSSWrapShapeCircle> create() { return adoptRef(new CSSWrapShapeCircle); }
+ static PassRefPtr<CSSBasicShapeCircle> create() { return adoptRef(new CSSBasicShapeCircle); }
CSSPrimitiveValue* centerX() const { return m_centerX.get(); }
CSSPrimitiveValue* centerY() const { return m_centerY.get(); }
@@ -101,20 +101,20 @@ public:
void setCenterY(PassRefPtr<CSSPrimitiveValue> centerY) { m_centerY = centerY; }
void setRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_radius = radius; }
- virtual Type type() const { return CSS_WRAP_SHAPE_CIRCLE; }
+ virtual Type type() const { return CSS_BASIC_SHAPE_CIRCLE; }
virtual String cssText() const;
private:
- CSSWrapShapeCircle() { }
+ CSSBasicShapeCircle() { }
RefPtr<CSSPrimitiveValue> m_centerY;
RefPtr<CSSPrimitiveValue> m_centerX;
RefPtr<CSSPrimitiveValue> m_radius;
};
-class CSSWrapShapeEllipse : public CSSWrapShape {
+class CSSBasicShapeEllipse : public CSSBasicShape {
public:
- static PassRefPtr<CSSWrapShapeEllipse> create() { return adoptRef(new CSSWrapShapeEllipse); }
+ static PassRefPtr<CSSBasicShapeEllipse> create() { return adoptRef(new CSSBasicShapeEllipse); }
CSSPrimitiveValue* centerX() const { return m_centerX.get(); }
CSSPrimitiveValue* centerY() const { return m_centerY.get(); }
@@ -126,11 +126,11 @@ public:
void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
- virtual Type type() const { return CSS_WRAP_SHAPE_ELLIPSE; }
+ virtual Type type() const { return CSS_BASIC_SHAPE_ELLIPSE; }
virtual String cssText() const;
private:
- CSSWrapShapeEllipse() { }
+ CSSBasicShapeEllipse() { }
RefPtr<CSSPrimitiveValue> m_centerX;
RefPtr<CSSPrimitiveValue> m_centerY;
@@ -138,9 +138,9 @@ private:
RefPtr<CSSPrimitiveValue> m_radiusY;
};
-class CSSWrapShapePolygon : public CSSWrapShape {
+class CSSBasicShapePolygon : public CSSBasicShape {
public:
- static PassRefPtr<CSSWrapShapePolygon> create() { return adoptRef(new CSSWrapShapePolygon); }
+ static PassRefPtr<CSSBasicShapePolygon> create() { return adoptRef(new CSSBasicShapePolygon); }
void appendPoint(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveValue> y)
{
@@ -155,11 +155,11 @@ public:
void setWindRule(WindRule w) { m_windRule = w; }
WindRule windRule() const { return m_windRule; }
- virtual Type type() const { return CSS_WRAP_SHAPE_POLYGON; }
+ virtual Type type() const { return CSS_BASIC_SHAPE_POLYGON; }
virtual String cssText() const;
private:
- CSSWrapShapePolygon()
+ CSSBasicShapePolygon()
: m_windRule(RULE_NONZERO)
{
}
@@ -170,4 +170,4 @@ private:
} // namespace WebCore
-#endif // CSSWrapShapes_h
+#endif // CSSBasicShapes_h
diff --git a/Source/WebCore/css/CSSBorderImageSliceValue.cpp b/Source/WebCore/css/CSSBorderImageSliceValue.cpp
index 551df1f60..02343f905 100644
--- a/Source/WebCore/css/CSSBorderImageSliceValue.cpp
+++ b/Source/WebCore/css/CSSBorderImageSliceValue.cpp
@@ -26,9 +26,9 @@
#include "config.h"
#include "CSSBorderImageSliceValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
#include "Rect.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -46,13 +46,13 @@ String CSSBorderImageSliceValue::customCssText() const
// Now the fill keywords if it is present.
if (m_fill)
- text += " fill";
+ return text + " fill";
return text;
}
void CSSBorderImageSliceValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_slices);
}
diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp
index 5a10c5985..76b8509f0 100755
--- a/Source/WebCore/css/CSSCalculationValue.cpp
+++ b/Source/WebCore/css/CSSCalculationValue.cpp
@@ -33,8 +33,8 @@
#include "CSSValueList.h"
#include "Length.h"
-#include "MemoryInstrumentation.h"
#include "StyleResolver.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
@@ -68,17 +68,19 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type)
case CSSPrimitiveValue::CSS_PC:
case CSSPrimitiveValue::CSS_REMS:
return CalcLength;
+#if ENABLE(CSS_VARIABLES)
+ case CSSPrimitiveValue::CSS_VARIABLE_NAME:
+ return CalcVariable;
+#endif
default:
return CalcOther;
}
}
-
-String CSSCalcValue::customCssText() const
+
+static String buildCssText(const String& expression)
{
StringBuilder result;
-
result.append("-webkit-calc");
- String expression = m_expression->customCssText();
bool expressionHasSingleTerm = expression[0] != '(';
if (expressionHasSingleTerm)
result.append('(');
@@ -88,9 +90,26 @@ String CSSCalcValue::customCssText() const
return result.toString();
}
+String CSSCalcValue::customCssText() const
+{
+ return buildCssText(m_expression->customCssText());
+}
+
+#if ENABLE(CSS_VARIABLES)
+String CSSCalcValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
+{
+ return buildCssText(m_expression->serializeResolvingVariables(variables));
+}
+
+bool CSSCalcValue::hasVariableReference() const
+{
+ return m_expression->hasVariableReference();
+}
+#endif
+
void CSSCalcValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
double CSSCalcValue::clampToPermittedRange(double value) const
@@ -130,6 +149,18 @@ public:
return m_value->cssText();
}
+#if ENABLE(CSS_VARIABLES)
+ virtual String serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
+ {
+ return m_value->customSerializeResolvingVariables(variables);
+ }
+
+ virtual bool hasVariableReference() const
+ {
+ return m_value->isVariableName();
+ }
+#endif
+
virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
{
switch (m_category) {
@@ -143,6 +174,9 @@ public:
// Only types that could be part of a Length expression can be converted
// to a CalcExpressionNode. CalcPercentNumber makes no sense as a Length.
case CalcPercentNumber:
+#if ENABLE(CSS_VARIABLES)
+ case CalcVariable:
+#endif
case CalcOther:
ASSERT_NOT_REACHED();
}
@@ -158,6 +192,9 @@ public:
case CalcLength:
case CalcPercentLength:
case CalcPercentNumber:
+#if ENABLE(CSS_VARIABLES)
+ case CalcVariable:
+#endif
case CalcOther:
ASSERT_NOT_REACHED();
break;
@@ -175,6 +212,9 @@ public:
return m_value->getDoubleValue();
case CalcPercentLength:
case CalcPercentNumber:
+#if ENABLE(CSS_VARIABLES)
+ case CalcVariable:
+#endif
case CalcOther:
ASSERT_NOT_REACHED();
break;
@@ -184,14 +224,14 @@ public:
virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_value);
}
private:
explicit CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger)
: CSSCalcExpressionNode(unitCategory((CSSPrimitiveValue::UnitTypes)value->primitiveType()), isInteger)
- , m_value(value)
+ , m_value(value)
{
}
@@ -205,42 +245,50 @@ static const CalculationCategory addSubtractResult[CalcOther][CalcOther] = {
{ CalcPercentNumber, CalcOther, CalcPercentNumber, CalcPercentNumber, CalcOther },
{ CalcOther, CalcPercentLength, CalcPercentLength, CalcOther, CalcPercentLength },
};
+
+static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSide, const CSSCalcExpressionNode& rightSide, CalcOperator op)
+{
+ CalculationCategory leftCategory = leftSide.category();
+ CalculationCategory rightCategory = rightSide.category();
+
+ if (leftCategory == CalcOther || rightCategory == CalcOther)
+ return CalcOther;
+
+#if ENABLE(CSS_VARIABLES)
+ if (leftCategory == CalcVariable || rightCategory == CalcVariable)
+ return CalcVariable;
+#endif
+
+ switch (op) {
+ case CalcAdd:
+ case CalcSubtract:
+ return addSubtractResult[leftCategory][rightCategory];
+ case CalcMultiply:
+ if (leftCategory != CalcNumber && rightCategory != CalcNumber)
+ return CalcOther;
+ return leftCategory == CalcNumber ? rightCategory : leftCategory;
+ case CalcDivide:
+ if (rightCategory != CalcNumber || rightSide.isZero())
+ return CalcOther;
+ return leftCategory;
+ }
+ ASSERT_NOT_REACHED();
+ return CalcOther;
+}
+
class CSSCalcBinaryOperation : public CSSCalcExpressionNode {
+
public:
static PassRefPtr<CSSCalcBinaryOperation> create(PassRefPtr<CSSCalcExpressionNode> leftSide, PassRefPtr<CSSCalcExpressionNode> rightSide, CalcOperator op)
{
- CalculationCategory leftCategory = leftSide->category();
- CalculationCategory rightCategory = rightSide->category();
- CalculationCategory newCategory = CalcOther;
-
- ASSERT(leftCategory != CalcOther && rightCategory != CalcOther);
-
- switch (op) {
- case CalcAdd:
- case CalcSubtract:
- if (leftCategory == CalcOther || rightCategory == CalcOther)
- return 0;
- newCategory = addSubtractResult[leftCategory][rightCategory];
- break;
-
- case CalcMultiply:
- if (leftCategory != CalcNumber && rightCategory != CalcNumber)
- return 0;
-
- newCategory = leftCategory == CalcNumber ? rightCategory : leftCategory;
- break;
-
- case CalcDivide:
- if (rightCategory != CalcNumber || rightSide->isZero())
- return 0;
- newCategory = leftCategory;
- break;
- }
+ ASSERT(leftSide->category() != CalcOther && rightSide->category() != CalcOther);
+ CalculationCategory newCategory = determineCategory(*leftSide, *rightSide, op);
+
if (newCategory == CalcOther)
return 0;
-
+
return adoptRef(new CSSCalcBinaryOperation(leftSide, rightSide, op, newCategory));
}
@@ -274,24 +322,41 @@ public:
virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_leftSide);
info.addInstrumentedMember(m_rightSide);
}
- virtual String customCssText() const
+ static String buildCssText(const String& leftExpression, const String& rightExpression, CalcOperator op)
{
StringBuilder result;
result.append('(');
- result.append(m_leftSide->customCssText());
+ result.append(leftExpression);
result.append(' ');
- result.append(static_cast<char>(m_operator));
+ result.append(static_cast<char>(op));
result.append(' ');
- result.append(m_rightSide->customCssText());
+ result.append(rightExpression);
result.append(')');
- return result.toString();
+ return result.toString();
+ }
+
+ virtual String customCssText() const
+ {
+ return buildCssText(m_leftSide->customCssText(), m_rightSide->customCssText(), m_operator);
+ }
+
+#if ENABLE(CSS_VARIABLES)
+ virtual String serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
+ {
+ return buildCssText(m_leftSide->serializeResolvingVariables(variables), m_rightSide->serializeResolvingVariables(variables), m_operator);
+ }
+
+ virtual bool hasVariableReference() const
+ {
+ return m_leftSide->hasVariableReference() || m_rightSide->hasVariableReference();
}
+#endif
private:
CSSCalcBinaryOperation(PassRefPtr<CSSCalcExpressionNode> leftSide, PassRefPtr<CSSCalcExpressionNode> rightSide, CalcOperator op, CalculationCategory category)
diff --git a/Source/WebCore/css/CSSCalculationValue.h b/Source/WebCore/css/CSSCalculationValue.h
index b25f7b31a..044cf32a4 100755
--- a/Source/WebCore/css/CSSCalculationValue.h
+++ b/Source/WebCore/css/CSSCalculationValue.h
@@ -52,6 +52,9 @@ enum CalculationCategory {
CalcPercent,
CalcPercentNumber,
CalcPercentLength,
+#if ENABLE(CSS_VARIABLES)
+ CalcVariable,
+#endif
CalcOther
};
@@ -64,6 +67,10 @@ public:
virtual double doubleValue() const = 0;
virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
virtual String customCssText() const = 0;
+#if ENABLE(CSS_VARIABLES)
+ virtual String serializeResolvingVariables(const HashMap<AtomicString, String>&) const = 0;
+ virtual bool hasVariableReference() const = 0;
+#endif
virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0;
@@ -97,6 +104,10 @@ public:
double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
String customCssText() const;
+#if ENABLE(CSS_VARIABLES)
+ String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const;
+ bool hasVariableReference() const;
+#endif
void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
diff --git a/Source/WebCore/css/CSSCanvasValue.cpp b/Source/WebCore/css/CSSCanvasValue.cpp
index 63777bb4d..8ecc80c08 100644
--- a/Source/WebCore/css/CSSCanvasValue.cpp
+++ b/Source/WebCore/css/CSSCanvasValue.cpp
@@ -27,8 +27,9 @@
#include "CSSCanvasValue.h"
#include "ImageBuffer.h"
-#include "MemoryInstrumentation.h"
#include "RenderObject.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -40,9 +41,11 @@ CSSCanvasValue::~CSSCanvasValue()
String CSSCanvasValue::customCssText() const
{
- String result = "-webkit-canvas(";
- result += m_name + ")";
- return result;
+ StringBuilder result;
+ result.appendLiteral("-webkit-canvas(");
+ result.append(m_name);
+ result.append(')');
+ return result.toString();
}
void CSSCanvasValue::canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect)
@@ -95,7 +98,7 @@ PassRefPtr<Image> CSSCanvasValue::image(RenderObject* renderer, const IntSize& /
void CSSCanvasValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSImageGeneratorValue::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_name);
info.addInstrumentedMember(m_element);
diff --git a/Source/WebCore/css/CSSCharsetRule.cpp b/Source/WebCore/css/CSSCharsetRule.cpp
index a3c3e1b9a..97bfc0586 100644
--- a/Source/WebCore/css/CSSCharsetRule.cpp
+++ b/Source/WebCore/css/CSSCharsetRule.cpp
@@ -21,7 +21,7 @@
#include "config.h"
#include "CSSCharsetRule.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
namespace WebCore {
@@ -38,7 +38,7 @@ String CSSCharsetRule::cssText() const
void CSSCharsetRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_encoding);
}
diff --git a/Source/WebCore/css/CSSCharsetRule.h b/Source/WebCore/css/CSSCharsetRule.h
index 0dad47c9e..773ff3aa8 100644
--- a/Source/WebCore/css/CSSCharsetRule.h
+++ b/Source/WebCore/css/CSSCharsetRule.h
@@ -23,7 +23,7 @@
#define CSSCharsetRule_h
#include "CSSRule.h"
-#include "PlatformString.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
index 0708c23ba..ebc27aac7 100644
--- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -25,7 +25,10 @@
#include "CSSComputedStyleDeclaration.h"
#include "AnimationController.h"
+#include "BasicShapeFunctions.h"
+#include "BasicShapes.h"
#include "CSSAspectRatioValue.h"
+#include "CSSBasicShapes.h"
#include "CSSBorderImage.h"
#include "CSSLineBoxContainValue.h"
#include "CSSParser.h"
@@ -46,7 +49,6 @@
#include "FontFeatureSettings.h"
#include "FontFeatureValue.h"
#include "FontValue.h"
-#include "MemoryInstrumentation.h"
#include "Pair.h"
#include "Rect.h"
#include "RenderBox.h"
@@ -56,20 +58,16 @@
#include "StyleInheritedData.h"
#include "StylePropertySet.h"
#include "StylePropertyShorthand.h"
+#include "WebCoreMemoryInstrumentation.h"
#include "WebKitCSSTransformValue.h"
#include "WebKitFontFamilyNames.h"
#include <wtf/text/StringBuilder.h>
-#if ENABLE(CSS_EXCLUSIONS)
-#include "CSSWrapShapes.h"
-#include "WrapShapeFunctions.h"
-#include "WrapShapes.h"
-#endif
-
#if ENABLE(CSS_SHADERS)
#include "CustomFilterNumberParameter.h"
#include "CustomFilterOperation.h"
#include "CustomFilterParameter.h"
+#include "CustomFilterTransformParameter.h"
#include "WebKitCSSMixFunctionValue.h"
#endif
@@ -160,6 +158,7 @@ static const CSSPropertyID computedProperties[] = {
CSSPropertyOutlineColor,
CSSPropertyOutlineStyle,
CSSPropertyOutlineWidth,
+ CSSPropertyOverflowWrap,
CSSPropertyOverflowX,
CSSPropertyOverflowY,
CSSPropertyPaddingBottom,
@@ -234,6 +233,7 @@ static const CSSPropertyID computedProperties[] = {
CSSPropertyWebkitBoxPack,
CSSPropertyWebkitBoxReflect,
CSSPropertyWebkitBoxShadow,
+ CSSPropertyWebkitClipPath,
CSSPropertyWebkitColorCorrection,
CSSPropertyWebkitColumnBreakAfter,
CSSPropertyWebkitColumnBreakBefore,
@@ -253,7 +253,6 @@ static const CSSPropertyID computedProperties[] = {
#if ENABLE(CSS_FILTERS)
CSSPropertyWebkitFilter,
#endif
-#if ENABLE(CSS3_FLEXBOX)
CSSPropertyWebkitAlignContent,
CSSPropertyWebkitAlignItems,
CSSPropertyWebkitAlignSelf,
@@ -263,7 +262,6 @@ static const CSSPropertyID computedProperties[] = {
CSSPropertyWebkitFlexDirection,
CSSPropertyWebkitFlexWrap,
CSSPropertyWebkitJustifyContent,
-#endif
CSSPropertyWebkitFontKerning,
CSSPropertyWebkitFontSmoothing,
CSSPropertyWebkitFontVariantLigatures,
@@ -305,9 +303,7 @@ static const CSSPropertyID computedProperties[] = {
CSSPropertyWebkitMaskRepeat,
CSSPropertyWebkitMaskSize,
CSSPropertyWebkitNbspMode,
-#if ENABLE(CSS3_FLEXBOX)
CSSPropertyWebkitOrder,
-#endif
#if ENABLE(OVERFLOW_SCROLLING)
CSSPropertyWebkitOverflowScrolling,
#endif
@@ -715,6 +711,45 @@ static LayoutRect sizingBox(RenderObject* renderer)
return box->style()->boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
}
+static PassRefPtr<WebKitCSSTransformValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle* style)
+{
+ RefPtr<WebKitCSSTransformValue> transformValue;
+ if (transform.isAffine()) {
+ transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
+
+ transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
+ transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
+ } else {
+ transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
+
+ transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
+
+ transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
+
+ transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
+ transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
+
+ transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
+ transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
+ transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
+ transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
+ }
+
+ return transformValue.release();
+}
+
static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
{
if (!renderer || !renderer->hasTransform() || !style->hasTransform())
@@ -728,50 +763,15 @@ static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const Rend
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;
-
// 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(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(zoomAdjustedNumberValue(transform.e(), style));
- transformVal->append(zoomAdjustedNumberValue(transform.f(), style));
- } else {
- transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
-
- transformVal->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
-
- transformVal->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
-
- transformVal->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
- transformVal->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
-
- transformVal->append(zoomAdjustedNumberValue(transform.m41(), style));
- transformVal->append(zoomAdjustedNumberValue(transform.m42(), style));
- transformVal->append(zoomAdjustedNumberValue(transform.m43(), style));
- transformVal->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
- }
-
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- list->append(transformVal);
+ list->append(matrixTransformValue(transform, style));
return list.release();
}
#if ENABLE(CSS_SHADERS)
-PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter) const
+static PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
{
RefPtr<CSSValueList> numberParameterValue = CSSValueList::createSpaceSeparated();
for (unsigned i = 0; i < numberParameter->size(); ++i)
@@ -779,13 +779,24 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForCustomFilterNumberPara
return numberParameterValue.release();
}
-PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForCustomFilterParameter(const CustomFilterParameter* parameter) const
+static PassRefPtr<CSSValue> valueForCustomFilterTransformParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterTransformParameter* transformParameter)
+{
+ IntSize size = renderer ? pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect()).size() : IntSize();
+ TransformationMatrix transform;
+ transformParameter->applyTransform(transform, size);
+ // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
+ return matrixTransformValue(transform, style);
+}
+
+static PassRefPtr<CSSValue> valueForCustomFilterParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterParameter* parameter)
{
// FIXME: Add here computed style for the other types: boolean, transform, matrix, texture.
ASSERT(parameter);
switch (parameter->parameterType()) {
case CustomFilterParameter::NUMBER:
return valueForCustomFilterNumberParameter(static_cast<const CustomFilterNumberParameter*>(parameter));
+ case CustomFilterParameter::TRANSFORM:
+ return valueForCustomFilterTransformParameter(renderer, style, static_cast<const CustomFilterTransformParameter*>(parameter));
}
ASSERT_NOT_REACHED();
@@ -794,8 +805,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForCustomFilterParameter(
#endif // ENABLE(CSS_SHADERS)
#if ENABLE(CSS_FILTERS)
-PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(RenderStyle* style) const
+PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(const RenderObject* renderer, const RenderStyle* style) const
{
+#if !ENABLE(CSS_SHADERS)
+ UNUSED_PARAM(renderer);
+#endif
if (style->filter().operations().isEmpty())
return cssValuePool().createIdentifierValue(CSSValueNone);
@@ -926,7 +940,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(RenderStyle* st
const CustomFilterParameter* parameter = parameters.at(i).get();
RefPtr<CSSValueList> parameterCSSNameAndValue = CSSValueList::createSpaceSeparated();
parameterCSSNameAndValue->append(cssValuePool().createValue(parameter->name(), CSSPrimitiveValue::CSS_STRING));
- parameterCSSNameAndValue->append(valueForCustomFilterParameter(parameter));
+ parameterCSSNameAndValue->append(valueForCustomFilterParameter(renderer, style, parameter));
parametersCSSValue->append(parameterCSSNameAndValue.release());
}
@@ -1127,7 +1141,7 @@ bool CSSComputedStyleDeclaration::useFixedFontDefaultSize() const
return style->fontDescription().useFixedDefaultSize();
}
-PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, RenderStyle* style) const
+PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style) const
{
if (!shadow)
return cssValuePool().createIdentifierValue(CSSValueNone);
@@ -1273,8 +1287,8 @@ static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPrope
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
- list->append(cssValuePool().createValue(it->first.get(), CSSPrimitiveValue::CSS_STRING));
- short number = propertyID == CSSPropertyCounterIncrement ? it->second.m_incrementValue : it->second.m_resetValue;
+ list->append(cssValuePool().createValue(it->first, CSSPrimitiveValue::CSS_STRING));
+ short number = propertyID == CSSPropertyCounterIncrement ? it->second.incrementValue() : it->second.resetValue();
list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
}
return list.release();
@@ -1680,7 +1694,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return cssValuePool().createValue(style->display());
case CSSPropertyEmptyCells:
return cssValuePool().createValue(style->emptyCells());
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitAlignContent:
return cssValuePool().createValue(style->alignContent());
case CSSPropertyWebkitAlignItems:
@@ -1710,7 +1723,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return cssValuePool().createValue(style->justifyContent());
case CSSPropertyWebkitOrder:
return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
-#endif
case CSSPropertyFloat:
return cssValuePool().createValue(style->floating());
case CSSPropertyFont: {
@@ -1914,6 +1926,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
case CSSPropertyOverflow:
return cssValuePool().createValue(max(style->overflowX(), style->overflowY()));
+ case CSSPropertyOverflowWrap:
+ return cssValuePool().createValue(style->overflowWrap());
case CSSPropertyOverflowX:
return cssValuePool().createValue(style->overflowX());
case CSSPropertyOverflowY:
@@ -2060,7 +2074,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
case CSSPropertyWordSpacing:
return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
case CSSPropertyWordWrap:
- return cssValuePool().createValue(style->wordWrap());
+ return cssValuePool().createValue(style->overflowWrap());
case CSSPropertyWebkitLineBreak:
return cssValuePool().createValue(style->khtmlLineBreak());
case CSSPropertyWebkitNbspMode:
@@ -2390,6 +2404,10 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return counterToCSSValue(style.get(), propertyID);
case CSSPropertyCounterReset:
return counterToCSSValue(style.get(), propertyID);
+ case CSSPropertyWebkitClipPath:
+ if (!style->clipPath())
+ return cssValuePool().createIdentifierValue(CSSValueNone);
+ return valueForBasicShape(style->clipPath());
#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitFlowInto:
if (style->flowThread().isNull())
@@ -2412,17 +2430,17 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
case CSSPropertyWebkitShapeInside:
if (!style->wrapShapeInside())
return cssValuePool().createIdentifierValue(CSSValueAuto);
- return valueForWrapShape(style->wrapShapeInside());
+ return valueForBasicShape(style->wrapShapeInside());
case CSSPropertyWebkitShapeOutside:
if (!style->wrapShapeOutside())
return cssValuePool().createIdentifierValue(CSSValueAuto);
- return valueForWrapShape(style->wrapShapeOutside());
+ return valueForBasicShape(style->wrapShapeOutside());
case CSSPropertyWebkitWrapThrough:
return cssValuePool().createValue(style->wrapThrough());
#endif
#if ENABLE(CSS_FILTERS)
case CSSPropertyWebkitFilter:
- return valueForFilter(style.get());
+ return valueForFilter(renderer, style.get());
#endif
#if ENABLE(CSS_COMPOSITING)
case CSSPropertyWebkitBlendMode:
@@ -2716,7 +2734,7 @@ PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet(co
void CSSComputedStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_node);
}
diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.h b/Source/WebCore/css/CSSComputedStyleDeclaration.h
index 10d01590a..cfc837b9f 100644
--- a/Source/WebCore/css/CSSComputedStyleDeclaration.h
+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.h
@@ -32,6 +32,7 @@ class CSSPrimitiveValue;
class CSSValueList;
class Color;
class Node;
+class RenderObject;
class RenderStyle;
class SVGPaint;
class ShadowData;
@@ -96,19 +97,14 @@ private:
virtual bool cssPropertyMatches(const CSSProperty*) const;
- PassRefPtr<CSSValue> valueForShadow(const ShadowData*, CSSPropertyID, RenderStyle*) const;
+ PassRefPtr<CSSValue> valueForShadow(const ShadowData*, CSSPropertyID, const RenderStyle*) const;
PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const Color&) const;
#if ENABLE(SVG)
PassRefPtr<SVGPaint> adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint>, RenderStyle*) const;
#endif
-#if ENABLE(CSS_SHADERS)
- PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter*) const;
- PassRefPtr<CSSValue> valueForCustomFilterParameter(const CustomFilterParameter*) const;
-#endif
-
#if ENABLE(CSS_FILTERS)
- PassRefPtr<CSSValue> valueForFilter(RenderStyle*) const;
+ PassRefPtr<CSSValue> valueForFilter(const RenderObject*, const RenderStyle*) const;
#endif
PassRefPtr<CSSValueList> getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand&) const;
diff --git a/Source/WebCore/css/CSSCrossfadeValue.cpp b/Source/WebCore/css/CSSCrossfadeValue.cpp
index 5ed7da18d..e347ebd09 100644
--- a/Source/WebCore/css/CSSCrossfadeValue.cpp
+++ b/Source/WebCore/css/CSSCrossfadeValue.cpp
@@ -31,10 +31,11 @@
#include "CachedResourceLoader.h"
#include "CrossfadeGeneratedImage.h"
#include "ImageBuffer.h"
-#include "MemoryInstrumentation.h"
#include "RenderObject.h"
#include "StyleCachedImage.h"
#include "StyleGeneratedImage.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -85,12 +86,15 @@ CSSCrossfadeValue::~CSSCrossfadeValue()
String CSSCrossfadeValue::customCssText() const
{
- String result = "-webkit-cross-fade(";
- result += m_fromValue->cssText() + ", ";
- result += m_toValue->cssText() + ", ";
- result += m_percentageValue->cssText();
- result += ")";
- return result;
+ StringBuilder result;
+ result.appendLiteral("-webkit-cross-fade(");
+ result.append(m_fromValue->cssText());
+ result.appendLiteral(", ");
+ result.append(m_toValue->cssText());
+ result.appendLiteral(", ");
+ result.append(m_percentageValue->cssText());
+ result.append(')');
+ return result.toString();
}
IntSize CSSCrossfadeValue::fixedSize(const RenderObject* renderer)
@@ -137,7 +141,7 @@ void CSSCrossfadeValue::loadSubimages(CachedResourceLoader* cachedResourceLoader
void CSSCrossfadeValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSImageGeneratorValue::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_fromValue);
info.addInstrumentedMember(m_toValue);
diff --git a/Source/WebCore/css/CSSCursorImageValue.cpp b/Source/WebCore/css/CSSCursorImageValue.cpp
index 35038fcd3..68ffa9c11 100644
--- a/Source/WebCore/css/CSSCursorImageValue.cpp
+++ b/Source/WebCore/css/CSSCursorImageValue.cpp
@@ -23,11 +23,11 @@
#include "CSSCursorImageValue.h"
#include "CachedResourceLoader.h"
-#include "MemoryInstrumentation.h"
#include "TreeScope.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/MathExtras.h>
#include <wtf/UnusedParam.h>
+#include <wtf/text/WTFString.h>
#if ENABLE(SVG)
#include "SVGCursorElement.h"
@@ -135,7 +135,7 @@ void CSSCursorImageValue::removeReferencedElement(SVGElement* element)
void CSSCursorImageValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSImageValue::reportDescendantMemoryUsage(memoryObjectInfo);
#if ENABLE(SVG)
info.addInstrumentedHashSet(m_referencedElements);
diff --git a/Source/WebCore/css/CSSFontFaceRule.cpp b/Source/WebCore/css/CSSFontFaceRule.cpp
index e85a6e44c..0dceb8a4d 100644
--- a/Source/WebCore/css/CSSFontFaceRule.cpp
+++ b/Source/WebCore/css/CSSFontFaceRule.cpp
@@ -22,9 +22,10 @@
#include "config.h"
#include "CSSFontFaceRule.h"
-#include "MemoryInstrumentation.h"
#include "StylePropertySet.h"
#include "StyleRule.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -49,11 +50,14 @@ CSSStyleDeclaration* CSSFontFaceRule::style() const
String CSSFontFaceRule::cssText() const
{
- String result("@font-face");
- result += " { ";
- result += m_fontFaceRule->properties()->asText();
- result += "}";
- return result;
+ StringBuilder result;
+ result.appendLiteral("@font-face { ");
+ String descs = m_fontFaceRule->properties()->asText();
+ result.append(descs);
+ if (!descs.isEmpty())
+ result.append(' ');
+ result.append('}');
+ return result.toString();
}
void CSSFontFaceRule::reattach(StyleRuleFontFace* rule)
@@ -66,7 +70,7 @@ void CSSFontFaceRule::reattach(StyleRuleFontFace* rule)
void CSSFontFaceRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_fontFaceRule);
info.addInstrumentedMember(m_propertiesCSSOMWrapper);
diff --git a/Source/WebCore/css/CSSFontFaceSrcValue.cpp b/Source/WebCore/css/CSSFontFaceSrcValue.cpp
index db4eb9b36..0505f60ad 100644
--- a/Source/WebCore/css/CSSFontFaceSrcValue.cpp
+++ b/Source/WebCore/css/CSSFontFaceSrcValue.cpp
@@ -29,10 +29,11 @@
#include "CachedResourceLoader.h"
#include "Document.h"
#include "FontCustomPlatformData.h"
-#include "MemoryInstrumentation.h"
#include "Node.h"
#include "SVGFontFaceElement.h"
#include "StyleSheetContents.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -63,16 +64,19 @@ bool CSSFontFaceSrcValue::isSupportedFormat() const
String CSSFontFaceSrcValue::customCssText() const
{
- String result;
+ StringBuilder result;
if (isLocal())
- result += "local(";
+ result.appendLiteral("local(");
else
- result += "url(";
- result += m_resource;
- result += ")";
- if (!m_format.isEmpty())
- result += " format(" + m_format + ")";
- return result;
+ result.appendLiteral("url(");
+ result.append(m_resource);
+ result.append(')');
+ if (!m_format.isEmpty()) {
+ result.appendLiteral(" format(");
+ result.append(m_format);
+ result.append(')');
+ }
+ return result.toString();
}
void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
@@ -99,7 +103,7 @@ CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document)
void CSSFontFaceSrcValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_resource);
info.addInstrumentedMember(m_format);
// FIXME: add m_cachedFont when MemoryCache is instrumented.
diff --git a/Source/WebCore/css/CSSFontFaceSrcValue.h b/Source/WebCore/css/CSSFontFaceSrcValue.h
index 4444c8606..a2c5466fe 100644
--- a/Source/WebCore/css/CSSFontFaceSrcValue.h
+++ b/Source/WebCore/css/CSSFontFaceSrcValue.h
@@ -28,8 +28,8 @@
#include "CSSValue.h"
#include "CachedResourceHandle.h"
-#include "PlatformString.h"
#include <wtf/PassRefPtr.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/CSSFunctionValue.cpp b/Source/WebCore/css/CSSFunctionValue.cpp
index 9f8f24f30..46a98f9b0 100644
--- a/Source/WebCore/css/CSSFunctionValue.cpp
+++ b/Source/WebCore/css/CSSFunctionValue.cpp
@@ -28,8 +28,9 @@
#include "CSSParserValues.h"
#include "CSSValueList.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/PassOwnPtr.h>
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -43,16 +44,17 @@ CSSFunctionValue::CSSFunctionValue(CSSParserFunction* function)
String CSSFunctionValue::customCssText() const
{
- String result = m_name; // Includes the '('
+ StringBuilder result;
+ result.append(m_name); // Includes the '('
if (m_args)
- result += m_args->cssText();
- result += ")";
- return result;
+ result.append(m_args->cssText());
+ result.append(')');
+ return result.toString();
}
void CSSFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_name);
info.addInstrumentedMember(m_args);
}
diff --git a/Source/WebCore/css/CSSGradientValue.cpp b/Source/WebCore/css/CSSGradientValue.cpp
index c7daacc87..fc485f918 100644
--- a/Source/WebCore/css/CSSGradientValue.cpp
+++ b/Source/WebCore/css/CSSGradientValue.cpp
@@ -33,11 +33,12 @@
#include "Image.h"
#include "IntSize.h"
#include "IntSizeHash.h"
-#include "MemoryInstrumentation.h"
#include "NodeRenderStyle.h"
-#include "PlatformString.h"
#include "RenderObject.h"
#include "StyleResolver.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
using namespace std;
@@ -45,7 +46,7 @@ namespace WebCore {
void CSSGradientColorStop::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_position);
info.addInstrumentedMember(m_color);
}
@@ -462,7 +463,7 @@ bool CSSGradientValue::isCacheable() const
void CSSGradientValue::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSImageGeneratorValue::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_firstX);
info.addInstrumentedMember(m_firstY);
@@ -473,51 +474,71 @@ void CSSGradientValue::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObject
String CSSLinearGradientValue::customCssText() const
{
- String result;
+ StringBuilder result;
if (m_deprecatedType) {
- result = "-webkit-gradient(linear, ";
- result += m_firstX->cssText() + " ";
- result += m_firstY->cssText() + ", ";
- result += m_secondX->cssText() + " ";
- result += m_secondY->cssText();
+ result.appendLiteral("-webkit-gradient(linear, ");
+ result.append(m_firstX->cssText());
+ result.append(' ');
+ result.append(m_firstY->cssText());
+ result.appendLiteral(", ");
+ result.append(m_secondX->cssText());
+ result.append(' ');
+ result.append(m_secondY->cssText());
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
- result += ", ";
- if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0)
- result += "from(" + stop.m_color->cssText() + ")";
- else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1)
- result += "to(" + stop.m_color->cssText() + ")";
- else
- result += "color-stop(" + String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)) + ", " + stop.m_color->cssText() + ")";
+ result.appendLiteral(", ");
+ if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) {
+ result.appendLiteral("from(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) {
+ result.appendLiteral("to(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else {
+ result.appendLiteral("color-stop(");
+ result.append(String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)));
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ }
}
} else {
- result = m_repeating ? "-webkit-repeating-linear-gradient(" : "-webkit-linear-gradient(";
+ if (m_repeating)
+ result.appendLiteral("-webkit-repeating-linear-gradient(");
+ else
+ result.appendLiteral("-webkit-linear-gradient(");
+
if (m_angle)
- result += m_angle->cssText();
+ result.append(m_angle->cssText());
else {
- if (m_firstX && m_firstY)
- result += m_firstX->cssText() + " " + m_firstY->cssText();
- else if (m_firstX || m_firstY) {
+ if (m_firstX && m_firstY) {
+ result.append(m_firstX->cssText());
+ result.append(' ');
+ result.append(m_firstY->cssText());
+ } else if (m_firstX || m_firstY) {
if (m_firstX)
- result += m_firstX->cssText();
+ result.append(m_firstX->cssText());
if (m_firstY)
- result += m_firstY->cssText();
+ result.append(m_firstY->cssText());
}
}
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
- result += ", ";
- result += stop.m_color->cssText();
- if (stop.m_position)
- result += " " + stop.m_position->cssText();
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ if (stop.m_position) {
+ result.append(' ');
+ result.append(stop.m_position->cssText());
+ }
}
}
- result += ")";
- return result;
+ result.append(')');
+ return result.toString();
}
// Compute the endpoints so that a gradient of the given angle covers a box of the given size.
@@ -615,78 +636,99 @@ PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(RenderObject* render
void CSSLinearGradientValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSGradientValue::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_angle);
}
String CSSRadialGradientValue::customCssText() const
{
- String result;
+ StringBuilder result;
if (m_deprecatedType) {
- result = "-webkit-gradient(radial, ";
-
- result += m_firstX->cssText() + " ";
- result += m_firstY->cssText() + ", ";
- result += m_firstRadius->cssText() + ", ";
- result += m_secondX->cssText() + " ";
- result += m_secondY->cssText();
- result += ", ";
- result += m_secondRadius->cssText();
+ result.appendLiteral("-webkit-gradient(radial, ");
+ result.append(m_firstX->cssText());
+ result.append(' ');
+ result.append(m_firstY->cssText());
+ result.appendLiteral(", ");
+ result.append(m_firstRadius->cssText());
+ result.appendLiteral(", ");
+ result.append(m_secondX->cssText());
+ result.append(' ');
+ result.append(m_secondY->cssText());
+ result.appendLiteral(", ");
+ result.append(m_secondRadius->cssText());
// FIXME: share?
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
- result += ", ";
- if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0)
- result += "from(" + stop.m_color->cssText() + ")";
- else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1)
- result += "to(" + stop.m_color->cssText() + ")";
- else
- result += "color-stop(" + String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)) + ", " + stop.m_color->cssText() + ")";
+ result.appendLiteral(", ");
+ if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) {
+ result.appendLiteral("from(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) {
+ result.appendLiteral("to(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else {
+ result.appendLiteral("color-stop(");
+ result.append(String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)));
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ }
}
} else {
+ if (m_repeating)
+ result.appendLiteral("-webkit-repeating-radial-gradient(");
+ else
+ result.appendLiteral("-webkit-radial-gradient(");
- result = m_repeating ? "-webkit-repeating-radial-gradient(" : "-webkit-radial-gradient(";
if (m_firstX && m_firstY) {
- result += m_firstX->cssText() + " " + m_firstY->cssText();
+ result.append(m_firstX->cssText());
+ result.append(' ');
+ result.append(m_firstY->cssText());
} else if (m_firstX)
- result += m_firstX->cssText();
+ result.append(m_firstX->cssText());
else if (m_firstY)
- result += m_firstY->cssText();
+ result.append(m_firstY->cssText());
else
- result += "center";
-
+ result.appendLiteral("center");
if (m_shape || m_sizingBehavior) {
- result += ", ";
- if (m_shape)
- result += m_shape->cssText() + " ";
- else
- result += "ellipse ";
+ result.appendLiteral(", ");
+ if (m_shape) {
+ result.append(m_shape->cssText());
+ result.append(' ');
+ } else
+ result.appendLiteral("ellipse ");
if (m_sizingBehavior)
- result += m_sizingBehavior->cssText();
+ result.append(m_sizingBehavior->cssText());
else
- result += "cover";
+ result.appendLiteral("cover");
} else if (m_endHorizontalSize && m_endVerticalSize) {
- result += ", ";
- result += m_endHorizontalSize->cssText() + " " + m_endVerticalSize->cssText();
+ result.appendLiteral(", ");
+ result.append(m_endHorizontalSize->cssText());
+ result.append(' ');
+ result.append(m_endVerticalSize->cssText());
}
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
- result += ", ";
- result += stop.m_color->cssText();
- if (stop.m_position)
- result += " " + stop.m_position->cssText();
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ if (stop.m_position) {
+ result.append(' ');
+ result.append(stop.m_position->cssText());
+ }
}
}
- result += ")";
- return result;
+ result.append(')');
+ return result.toString();
}
float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderStyle* style, RenderStyle* rootStyle, float* widthOrHeight)
@@ -919,7 +961,7 @@ PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(RenderObject* render
void CSSRadialGradientValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSGradientValue::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_firstRadius);
info.addInstrumentedMember(m_secondRadius);
diff --git a/Source/WebCore/css/CSSGrammar.y b/Source/WebCore/css/CSSGrammar.y
index 29fab4ffe..5167537f7 100644
--- a/Source/WebCore/css/CSSGrammar.y
+++ b/Source/WebCore/css/CSSGrammar.y
@@ -93,14 +93,9 @@ static inline int cssyyerror(void*, const char*)
return 1;
}
-static int cssyylex(YYSTYPE* yylval, CSSParser* parser)
-{
- return parser->lex(yylval);
-}
-
%}
-%expect 62
+%expect 63
%nonassoc LOWEST_PREC
@@ -509,7 +504,7 @@ NAMESPACE_SYM maybe_space maybe_ns_prefix string_or_uri maybe_space ';' {
;
maybe_ns_prefix:
-/* empty */ { $$.characters = 0; }
+/* empty */ { $$.clear(); }
| IDENT maybe_space { $$ = $1; }
;
@@ -694,9 +689,9 @@ key:
| IDENT {
$$.id = 0; $$.isInt = false; $$.unit = CSSPrimitiveValue::CSS_NUMBER;
CSSParserString& str = $1;
- if (equalIgnoringCase("from", str.characters, str.length))
+ if (str.equalIgnoringCase("from"))
$$.fValue = 0;
- else if (equalIgnoringCase("to", str.characters, str.length))
+ else if (str.equalIgnoringCase("to"))
$$.fValue = 100;
else
YYERROR;
@@ -976,8 +971,8 @@ selector:
;
namespace_selector:
- /* empty */ '|' { $$.characters = 0; $$.length = 0; }
- | '*' '|' { static UChar star = '*'; $$.characters = &star; $$.length = 1; }
+ /* empty */ '|' { $$.clear(); }
+ | '*' '|' { static LChar star = '*'; $$.init(&star, 1); }
| IDENT '|' { $$ = $1; }
;
@@ -1040,9 +1035,8 @@ element_name:
$$ = str;
}
| '*' {
- static UChar star = '*';
- $$.characters = &star;
- $$.length = 1;
+ static LChar star = '*';
+ $$.init(&star, 1);
}
;
@@ -1070,7 +1064,7 @@ specifier:
$$->setValue($1);
}
| HEX {
- if ($1.characters[0] >= '0' && $1.characters[0] <= '9') {
+ if ($1[0] >= '0' && $1[0] <= '9') {
$$ = 0;
} else {
$$ = parser->createFloatingSelector();
@@ -1550,6 +1544,13 @@ function:
calc_func_term:
unary_term { $$ = $1; }
+ | VARFUNCTION maybe_space IDENT ')' maybe_space {
+#if ENABLE(CSS_VARIABLES)
+ $$.id = 0;
+ $$.string = $3;
+ $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME;
+#endif
+ }
| unary_operator unary_term { $$ = $2; $$.fValue *= $1; }
;
diff --git a/Source/WebCore/css/CSSImageGeneratorValue.cpp b/Source/WebCore/css/CSSImageGeneratorValue.cpp
index 63040f3be..63cb422a9 100644
--- a/Source/WebCore/css/CSSImageGeneratorValue.cpp
+++ b/Source/WebCore/css/CSSImageGeneratorValue.cpp
@@ -30,8 +30,8 @@
#include "CSSCrossfadeValue.h"
#include "CSSGradientValue.h"
#include "Image.h"
-#include "MemoryInstrumentation.h"
#include "RenderObject.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -111,7 +111,7 @@ void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
void CSSImageGeneratorValue::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addHashCountedSet(m_sizes);
info.addHashMap(m_clients);
info.addHashMap(m_images); // FIXME: instrument Image
diff --git a/Source/WebCore/css/CSSImageSetValue.cpp b/Source/WebCore/css/CSSImageSetValue.cpp
index 28451a254..568d756f4 100644
--- a/Source/WebCore/css/CSSImageSetValue.cpp
+++ b/Source/WebCore/css/CSSImageSetValue.cpp
@@ -33,10 +33,10 @@
#include "CachedImage.h"
#include "CachedResourceLoader.h"
#include "Document.h"
-#include "MemoryInstrumentation.h"
#include "Page.h"
#include "StyleCachedImageSet.h"
#include "StylePendingImage.h"
+#include "WebCoreMemoryInstrumentation.h"
namespace WebCore {
@@ -166,14 +166,14 @@ PassRefPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const
void CSSImageSetValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo);
info.addInstrumentedVector(m_imagesInSet);
}
void CSSImageSetValue::ImageWithScale::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(imageURL);
}
diff --git a/Source/WebCore/css/CSSImageValue.cpp b/Source/WebCore/css/CSSImageValue.cpp
index b7f4d73cd..c370bdc65 100644
--- a/Source/WebCore/css/CSSImageValue.cpp
+++ b/Source/WebCore/css/CSSImageValue.cpp
@@ -28,9 +28,9 @@
#include "CachedResourceLoader.h"
#include "Document.h"
#include "MemoryCache.h"
-#include "MemoryInstrumentation.h"
#include "StyleCachedImage.h"
#include "StylePendingImage.h"
+#include "WebCoreMemoryInstrumentation.h"
namespace WebCore {
@@ -128,7 +128,7 @@ PassRefPtr<CSSValue> CSSImageValue::cloneForCSSOM() const
void CSSImageValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_url);
// No need to report m_image as it is counted as part of RenderArena.
}
diff --git a/Source/WebCore/css/CSSImportRule.cpp b/Source/WebCore/css/CSSImportRule.cpp
index f7e711ba2..772f36589 100644
--- a/Source/WebCore/css/CSSImportRule.cpp
+++ b/Source/WebCore/css/CSSImportRule.cpp
@@ -27,10 +27,10 @@
#include "CachedResourceLoader.h"
#include "Document.h"
#include "MediaList.h"
-#include "MemoryInstrumentation.h"
#include "SecurityOrigin.h"
#include "StyleRuleImport.h"
#include "StyleSheetContents.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -79,13 +79,20 @@ String CSSImportRule::cssText() const
void CSSImportRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_importRule);
info.addInstrumentedMember(m_mediaCSSOMWrapper);
info.addInstrumentedMember(m_styleSheetCSSOMWrapper);
}
+void CSSImportRule::reattachStyleSheetContents()
+{
+ ASSERT(m_styleSheetCSSOMWrapper);
+ ASSERT(!parentStyleSheet() || parentStyleSheet()->contents()->hasOneClient());
+ m_importRule->reattachStyleSheetContents(m_styleSheetCSSOMWrapper->contents());
+}
+
CSSStyleSheet* CSSImportRule::styleSheet() const
{
if (!m_importRule->styleSheet())
diff --git a/Source/WebCore/css/CSSImportRule.h b/Source/WebCore/css/CSSImportRule.h
index c835f7dd5..e7921f76d 100644
--- a/Source/WebCore/css/CSSImportRule.h
+++ b/Source/WebCore/css/CSSImportRule.h
@@ -45,6 +45,8 @@ public:
void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+ void reattachStyleSheetContents();
+
private:
CSSImportRule(StyleRuleImport*, CSSStyleSheet*);
diff --git a/Source/WebCore/css/CSSInheritedValue.cpp b/Source/WebCore/css/CSSInheritedValue.cpp
index f7a426de6..8bcef1891 100644
--- a/Source/WebCore/css/CSSInheritedValue.cpp
+++ b/Source/WebCore/css/CSSInheritedValue.cpp
@@ -21,8 +21,8 @@
#include "config.h"
#include "CSSInheritedValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -33,7 +33,7 @@ String CSSInheritedValue::customCssText() const
void CSSInheritedValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
} // namespace WebCore
diff --git a/Source/WebCore/css/CSSInitialValue.cpp b/Source/WebCore/css/CSSInitialValue.cpp
index 775fe0f80..d5776f11c 100644
--- a/Source/WebCore/css/CSSInitialValue.cpp
+++ b/Source/WebCore/css/CSSInitialValue.cpp
@@ -21,8 +21,8 @@
#include "config.h"
#include "CSSInitialValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -33,7 +33,7 @@ String CSSInitialValue::customCssText() const
void CSSInitialValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
} // namespace WebCore
diff --git a/Source/WebCore/css/CSSLineBoxContainValue.cpp b/Source/WebCore/css/CSSLineBoxContainValue.cpp
index 85f385d71..24c08b400 100644
--- a/Source/WebCore/css/CSSLineBoxContainValue.cpp
+++ b/Source/WebCore/css/CSSLineBoxContainValue.cpp
@@ -27,8 +27,9 @@
#include "CSSLineBoxContainValue.h"
#include "CSSPrimitiveValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -40,42 +41,42 @@ CSSLineBoxContainValue::CSSLineBoxContainValue(unsigned value)
String CSSLineBoxContainValue::customCssText() const
{
- String text("");
+ StringBuilder text;
if (m_value & LineBoxContainBlock)
- text += "block";
+ text.appendLiteral("block");
if (m_value & LineBoxContainInline) {
if (!text.isEmpty())
- text += " ";
- text += "inline";
+ text.append(' ');
+ text.appendLiteral("inline");
}
if (m_value & LineBoxContainFont) {
if (!text.isEmpty())
- text += " ";
- text += "font";
+ text.append(' ');
+ text.appendLiteral("font");
}
if (m_value & LineBoxContainGlyphs) {
if (!text.isEmpty())
- text += " ";
- text += "glyphs";
+ text.append(' ');
+ text.appendLiteral("glyphs");
}
if (m_value & LineBoxContainReplaced) {
if (!text.isEmpty())
- text += " ";
- text += "replaced";
+ text.append(' ');
+ text.appendLiteral("replaced");
}
if (m_value & LineBoxContainInlineBox) {
if (!text.isEmpty())
- text += " ";
- text += "inline-box";
+ text.append(' ');
+ text.appendLiteral("inline-box");
}
- return text;
+ return text.toString();
}
void CSSLineBoxContainValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
}
diff --git a/Source/WebCore/css/CSSMediaRule.cpp b/Source/WebCore/css/CSSMediaRule.cpp
index 278670f41..4542d3e48 100644
--- a/Source/WebCore/css/CSSMediaRule.cpp
+++ b/Source/WebCore/css/CSSMediaRule.cpp
@@ -27,8 +27,8 @@
#include "CSSRuleList.h"
#include "CSSStyleSheet.h"
#include "ExceptionCode.h"
-#include "MemoryInstrumentation.h"
#include "StyleRule.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -177,7 +177,7 @@ void CSSMediaRule::reattach(StyleRuleMedia* rule)
void CSSMediaRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_mediaCSSOMWrapper);
info.addInstrumentedVector(m_childRuleCSSOMWrappers);
diff --git a/Source/WebCore/css/CSSMediaRule.h b/Source/WebCore/css/CSSMediaRule.h
index 69faf1a50..adaca6d62 100644
--- a/Source/WebCore/css/CSSMediaRule.h
+++ b/Source/WebCore/css/CSSMediaRule.h
@@ -25,7 +25,7 @@
#include "CSSRule.h"
#include "MediaList.h"
-#include "PlatformString.h" // needed so bindings will compile
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/CSSPageRule.cpp b/Source/WebCore/css/CSSPageRule.cpp
index f5e63276d..839bc20f7 100644
--- a/Source/WebCore/css/CSSPageRule.cpp
+++ b/Source/WebCore/css/CSSPageRule.cpp
@@ -30,6 +30,7 @@
#include "StylePropertySet.h"
#include "StyleRule.h"
#include <wtf/Vector.h>
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -54,14 +55,17 @@ CSSStyleDeclaration* CSSPageRule::style() const
String CSSPageRule::selectorText() const
{
- String text = "@page";
+ StringBuilder text;
+ text.appendLiteral("@page");
const CSSSelector* selector = m_pageRule->selector();
if (selector) {
String pageSpecification = selector->selectorText();
- if (!pageSpecification.isEmpty() && pageSpecification != starAtom)
- text += " " + pageSpecification;
+ if (!pageSpecification.isEmpty() && pageSpecification != starAtom) {
+ text.append(' ');
+ text.append(pageSpecification);
+ }
}
- return text;
+ return text.toString();
}
void CSSPageRule::setSelectorText(const String& selectorText)
@@ -74,17 +78,20 @@ void CSSPageRule::setSelectorText(const String& selectorText)
CSSStyleSheet::RuleMutationScope mutationScope(this);
- String oldSelectorText = this->selectorText();
m_pageRule->wrapperAdoptSelectorList(selectorList);
}
String CSSPageRule::cssText() const
{
- String result = selectorText();
- result += " { ";
- result += m_pageRule->properties()->asText();
- result += "}";
- return result;
+ StringBuilder result;
+ result.append(selectorText());
+ result.appendLiteral(" { ");
+ String decls = m_pageRule->properties()->asText();
+ result.append(decls);
+ if (!decls.isEmpty())
+ result.append(' ');
+ result.append('}');
+ return result.toString();
}
void CSSPageRule::reattach(StyleRulePage* rule)
@@ -97,7 +104,7 @@ void CSSPageRule::reattach(StyleRulePage* rule)
void CSSPageRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_pageRule);
info.addInstrumentedMember(m_propertiesCSSOMWrapper);
diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp
index 7a5ea37d3..28ce13157 100644
--- a/Source/WebCore/css/CSSParser.cpp
+++ b/Source/WebCore/css/CSSParser.cpp
@@ -27,6 +27,7 @@
#include "CSSParser.h"
#include "CSSAspectRatioValue.h"
+#include "CSSBasicShapes.h"
#include "CSSBorderImage.h"
#include "CSSCanvasValue.h"
#include "CSSCrossfadeValue.h"
@@ -56,7 +57,6 @@
#if ENABLE(CSS_VARIABLES)
#include "CSSVariableValue.h"
#endif
-#include "CSSWrapShapes.h"
#include "Counter.h"
#include "Document.h"
#include "FloatConversion.h"
@@ -91,6 +91,7 @@
#include <wtf/dtoa.h>
#include <wtf/text/StringBuffer.h>
#include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringImpl.h>
#if ENABLE(CSS_IMAGE_SET)
#include "CSSImageSetValue.h"
@@ -104,6 +105,7 @@
#endif
#if ENABLE(CSS_SHADERS)
+#include "WebKitCSSArrayFunctionValue.h"
#include "WebKitCSSMixFunctionValue.h"
#include "WebKitCSSShaderValue.h"
#endif
@@ -155,27 +157,24 @@ namespace WebCore {
static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX;
static const double MAX_SCALE = 1000000;
-static bool equal(const CSSParserString& a, const char* b)
+template <unsigned N>
+static bool equal(const CSSParserString& a, const char (&b)[N])
{
- for (int i = 0; i < a.length; ++i) {
- if (!b[i])
- return false;
- if (a.characters[i] != b[i])
- return false;
- }
- return !b[a.length];
+ unsigned length = N - 1; // Ignore the trailing null character
+ if (a.length() != length)
+ return false;
+
+ return a.is8Bit() ? WTF::equal(a.characters8(), reinterpret_cast<const LChar*>(b), length) : WTF::equal(a.characters16(), reinterpret_cast<const LChar*>(b), length);
}
-static bool equalIgnoringCase(const CSSParserString& a, const char* b)
+template <unsigned N>
+static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N])
{
- for (int i = 0; i < a.length; ++i) {
- if (!b[i])
- return false;
- ASSERT(!isASCIIUpper(b[i]));
- if (toASCIILower(a.characters[i]) != b[i])
- return false;
- }
- return !b[a.length];
+ unsigned length = N - 1; // Ignore the trailing null character
+ if (a.length() != length)
+ return false;
+
+ return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF::equalIgnoringCase(b, a.characters16(), length);
}
static bool hasPrefix(const char* string, unsigned length, const char* prefix)
@@ -260,8 +259,10 @@ CSSParser::CSSParser(const CSSParserContext& context)
, m_propertyRange(UINT_MAX, UINT_MAX)
, m_ruleSourceDataResult(0)
, m_parsingMode(NormalMode)
- , m_currentCharacter(0)
- , m_tokenStart(0)
+ , m_is8BitSource(false)
+ , m_currentCharacter8(0)
+ , m_currentCharacter16(0)
+ , m_length(0)
, m_token(0)
, m_lineNumber(0)
, m_lastSelectorLineNumber(0)
@@ -272,6 +273,7 @@ CSSParser::CSSParser(const CSSParserContext& context)
#if YYDEBUG > 0
cssyydebug = 1;
#endif
+ m_tokenStart.ptr8 = 0;
CSSPropertySourceData::init();
}
@@ -285,7 +287,8 @@ CSSParser::~CSSParser()
deleteAllValues(m_floatingFunctions);
}
-void CSSParserString::lower()
+template <typename CharacterType>
+ALWAYS_INLINE static void makeLower(CharacterType* characters, unsigned length)
{
// FIXME: If we need Unicode lowercasing here, then we probably want the real kind
// that can potentially change the length of the string rather than the character
@@ -294,33 +297,73 @@ void CSSParserString::lower()
if (charactersAreAllASCII(characters, length)) {
// Fast case for all-ASCII.
- for (int i = 0; i < length; i++)
+ for (unsigned i = 0; i < length; i++)
characters[i] = toASCIILower(characters[i]);
} else {
- for (int i = 0; i < length; i++)
+ for (unsigned i = 0; i < length; i++)
characters[i] = Unicode::toLower(characters[i]);
}
}
+void CSSParserString::lower()
+{
+ if (is8Bit()) {
+ makeLower(characters8(), length());
+ return;
+ }
+
+ makeLower(characters16(), length());
+}
+
void CSSParser::setupParser(const char* prefix, const String& string, const char* suffix)
{
m_parsedTextPrefixLength = strlen(prefix);
- int length = string.length() + m_parsedTextPrefixLength + strlen(suffix) + 1;
+ unsigned stringLength = string.length();
+ unsigned length = stringLength + m_parsedTextPrefixLength + strlen(suffix) + 1;
+
+ if (!stringLength || string.is8Bit()) {
+ m_dataStart8 = adoptArrayPtr(new LChar[length]);
+ for (unsigned i = 0; i < m_parsedTextPrefixLength; i++)
+ m_dataStart8[i] = prefix[i];
+
+ if (stringLength)
+ memcpy(m_dataStart8.get() + m_parsedTextPrefixLength, string.characters8(), stringLength * sizeof(LChar));
+
+ unsigned start = m_parsedTextPrefixLength + stringLength;
+ unsigned end = start + strlen(suffix);
+ for (unsigned i = start; i < end; i++)
+ m_dataStart8[i] = suffix[i - start];
+
+ m_dataStart8[length - 1] = 0;
+
+ m_is8BitSource = true;
+ m_currentCharacter8 = m_dataStart8.get();
+ m_currentCharacter16 = 0;
+ setTokenStart<LChar>(m_currentCharacter8);
+ m_length = length;
+ m_lexFunc = &CSSParser::realLex<LChar>;
+ return;
+ }
- m_dataStart = adoptArrayPtr(new UChar[length]);
+ m_dataStart16 = adoptArrayPtr(new UChar[length]);
for (unsigned i = 0; i < m_parsedTextPrefixLength; i++)
- m_dataStart[i] = prefix[i];
+ m_dataStart16[i] = prefix[i];
- memcpy(m_dataStart.get() + m_parsedTextPrefixLength, string.characters(), string.length() * sizeof(UChar));
+ memcpy(m_dataStart16.get() + m_parsedTextPrefixLength, string.characters(), stringLength * sizeof(UChar));
- unsigned start = m_parsedTextPrefixLength + string.length();
+ unsigned start = m_parsedTextPrefixLength + stringLength;
unsigned end = start + strlen(suffix);
for (unsigned i = start; i < end; i++)
- m_dataStart[i] = suffix[i - start];
+ m_dataStart16[i] = suffix[i - start];
- m_dataStart[length - 1] = 0;
+ m_dataStart16[length - 1] = 0;
- m_currentCharacter = m_tokenStart = m_dataStart.get();
+ m_is8BitSource = false;
+ m_currentCharacter8 = 0;
+ m_currentCharacter16 = m_dataStart16.get();
+ setTokenStart<UChar>(m_currentCharacter16);
+ m_length = length;
+ m_lexFunc = &CSSParser::realLex<UChar>;
}
void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, int startLineNumber, RuleSourceDataList* ruleSourceDataResult)
@@ -390,8 +433,7 @@ static bool parseColorValue(StylePropertySet* declaration, CSSPropertyID propert
if (!isColorPropertyID(propertyId))
return false;
CSSParserString cssString;
- cssString.characters = const_cast<UChar*>(string.characters());
- cssString.length = string.length();
+ cssString.init(string);
int valueID = cssValueKeywordID(cssString);
bool validPrimitive = false;
if (valueID == CSSValueWebkitText)
@@ -464,8 +506,8 @@ static inline bool isSimpleLengthPropertyID(CSSPropertyID propertyId, bool& acce
}
}
-template <typename CharType>
-static inline bool parseSimpleLength(const CharType* characters, unsigned& length, CSSPrimitiveValue::UnitTypes& unit, double& number)
+template <typename CharacterType>
+static inline bool parseSimpleLength(const CharacterType* characters, unsigned& length, CSSPrimitiveValue::UnitTypes& unit, double& number)
{
if (length > 2 && (characters[length - 2] | 0x20) == 'p' && (characters[length - 1] | 0x20) == 'x') {
length -= 2;
@@ -558,12 +600,8 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
// inline-table | table-row-group | table-header-group | table-footer-group | table-row |
// table-column-group | table-column | table-cell | table-caption | -webkit-box | -webkit-inline-box | none | inherit
// -webkit-flex | -webkit-inline-flex | -webkit-grid | -webkit-inline-grid
- if ((valueID >= CSSValueInline && valueID <= CSSValueWebkitInlineBox) || valueID == CSSValueNone)
+ if ((valueID >= CSSValueInline && valueID <= CSSValueWebkitInlineFlex) || valueID == CSSValueNone)
return true;
-#if ENABLE(CSS3_FLEXBOX)
- if (valueID == CSSValueWebkitFlex || valueID == CSSValueWebkitInlineFlex)
- return true;
-#endif
if (parserContext.isCSSGridLayoutEnabled && (valueID == CSSValueWebkitGrid || valueID == CSSValueWebkitInlineGrid))
return true;
break;
@@ -598,6 +636,11 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
if (valueID == CSSValueAuto || valueID == CSSValueNone || (valueID >= CSSValueInset && valueID <= CSSValueDouble))
return true;
break;
+ case CSSPropertyOverflowWrap: // normal | break-word
+ case CSSPropertyWordWrap:
+ if (valueID == CSSValueNormal || valueID == CSSValueBreakWord)
+ return true;
+ break;
case CSSPropertyOverflowX: // visible | hidden | scroll | auto | marquee | overlay | inherit
if (valueID == CSSValueVisible || valueID == CSSValueHidden || valueID == CSSValueScroll || valueID == CSSValueAuto || valueID == CSSValueOverlay || valueID == CSSValueWebkitMarquee)
return true;
@@ -723,7 +766,6 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
if (valueID == CSSValueSrgb || valueID == CSSValueDefault)
return true;
break;
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitAlignContent:
if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround || valueID == CSSValueStretch)
return true;
@@ -748,7 +790,6 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround)
return true;
break;
-#endif
case CSSPropertyWebkitFontKerning:
if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == CSSValueNone)
return true;
@@ -881,10 +922,6 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
if (valueID == CSSValueNormal || valueID == CSSValueBreakAll || valueID == CSSValueBreakWord)
return true;
break;
- case CSSPropertyWordWrap: // normal | break-word
- if (valueID == CSSValueNormal || valueID == CSSValueBreakWord)
- return true;
- break;
default:
ASSERT_NOT_REACHED();
return false;
@@ -912,6 +949,7 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
case CSSPropertyListStylePosition:
case CSSPropertyListStyleType:
case CSSPropertyOutlineStyle:
+ case CSSPropertyOverflowWrap:
case CSSPropertyOverflowX:
case CSSPropertyOverflowY:
case CSSPropertyPageBreakAfter:
@@ -955,14 +993,12 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
case CSSPropertyWebkitColumnBreakBefore:
case CSSPropertyWebkitColumnBreakInside:
case CSSPropertyWebkitColumnRuleStyle:
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitAlignContent:
case CSSPropertyWebkitAlignItems:
case CSSPropertyWebkitAlignSelf:
case CSSPropertyWebkitFlexDirection:
case CSSPropertyWebkitFlexWrap:
case CSSPropertyWebkitJustifyContent:
-#endif
case CSSPropertyWebkitFontKerning:
case CSSPropertyWebkitFontSmoothing:
case CSSPropertyWebkitHyphens:
@@ -1017,8 +1053,7 @@ static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID prope
return false;
CSSParserString cssString;
- cssString.characters = const_cast<UChar*>(string.characters());
- cssString.length = string.length();
+ cssString.init(string);
int valueID = cssValueKeywordID(cssString);
if (!valueID)
@@ -1038,8 +1073,8 @@ static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID prope
return true;
}
-template <typename CharType>
-static bool parseTransformArguments(WebKitCSSTransformValue* transformValue, CharType* characters, unsigned length, unsigned start, unsigned expectedCount)
+template <typename CharacterType>
+static bool parseTransformArguments(WebKitCSSTransformValue* transformValue, CharacterType* characters, unsigned length, unsigned start, unsigned expectedCount)
{
while (expectedCount) {
size_t end = WTF::find(characters, length, expectedCount == 1 ? ')' : ',', start);
@@ -1222,8 +1257,7 @@ bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document*
return false;
CSSParserString cssColor;
- cssColor.characters = const_cast<UChar*>(string.characters());
- cssColor.length = string.length();
+ cssColor.init(string);
int id = cssValueKeywordID(cssColor);
if (id <= 0)
return false;
@@ -1443,6 +1477,11 @@ bool CSSParser::validCalculationUnit(CSSParserValue* value, Units unitflags)
case CalcPercentNumber:
b = (unitflags & FPercent) && (unitflags & FNumber);
break;
+#if ENABLE(CSS_VARIABLES)
+ case CalcVariable:
+ b = true;
+ break;
+#endif
case CalcOther:
break;
}
@@ -2304,7 +2343,6 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
validPrimitive = true;
break;
#endif
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitFlex: {
ShorthandScope scope(this, propId);
if (id == CSSValueNone) {
@@ -2334,7 +2372,6 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
m_valueList->next();
}
break;
-#endif
case CSSPropertyWebkitMarquee:
return parseShorthand(propId, webkitMarqueeShorthand(), important);
case CSSPropertyWebkitMarqueeIncrement:
@@ -2656,10 +2693,8 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyPadding:
// <padding-width>{1,4} | inherit
return parse4Values(propId, paddingShorthand().properties(), important);
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitFlexFlow:
return parseShorthand(propId, webkitFlexFlowShorthand(), important);
-#endif
case CSSPropertyFont:
// [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
// 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
@@ -2721,6 +2756,12 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
else
return parseFontVariantLigatures(important);
break;
+ case CSSPropertyWebkitClipPath:
+ if (id == CSSValueNone)
+ validPrimitive = true;
+ else if (value->unit == CSSParserValue::Function)
+ return parseBasicShape(propId, important);
+ break;
#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitShapeInside:
case CSSPropertyWebkitShapeOutside:
@@ -2729,7 +2770,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
if (id == CSSValueAuto)
validPrimitive = true;
else if (value->unit == CSSParserValue::Function)
- return parseExclusionShape((propId == CSSPropertyWebkitShapeInside), important);
+ return parseBasicShape(propId, important);
break;
case CSSPropertyWebkitWrapMargin:
case CSSPropertyWebkitWrapPadding:
@@ -2768,6 +2809,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyListStylePosition:
case CSSPropertyListStyleType:
case CSSPropertyOutlineStyle:
+ case CSSPropertyOverflowWrap:
case CSSPropertyOverflowX:
case CSSPropertyOverflowY:
case CSSPropertyPageBreakAfter:
@@ -2811,14 +2853,12 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyWebkitColumnBreakBefore:
case CSSPropertyWebkitColumnBreakInside:
case CSSPropertyWebkitColumnRuleStyle:
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitAlignContent:
case CSSPropertyWebkitAlignItems:
case CSSPropertyWebkitAlignSelf:
case CSSPropertyWebkitFlexDirection:
case CSSPropertyWebkitFlexWrap:
case CSSPropertyWebkitJustifyContent:
-#endif
case CSSPropertyWebkitFontKerning:
case CSSPropertyWebkitFontSmoothing:
case CSSPropertyWebkitHyphens:
@@ -3065,8 +3105,8 @@ void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr
if (!value)
return;
- ASSERT(name.length > 12);
- AtomicString variableName = String(name.characters + 12, name.length - 12);
+ ASSERT(name.length() > 12);
+ AtomicString variableName = name.is8Bit() ? AtomicString(name.characters8() + 12, name.length() - 12) : AtomicString(name.characters16() + 12, name.length() - 12);
StringBuilder builder;
for (unsigned i = 0, size = value->size(); i < size; i++) {
@@ -4307,7 +4347,7 @@ bool CSSParser::parseDashboardRegions(CSSPropertyID propId, bool important)
}
bool validFunctionName = false;
#if ENABLE(DASHBOARD_SUPPORT)
- static const char* const dashboardRegionFunctionName = "dashboard-region(";
+ static const char dashboardRegionFunctionName[] = "dashboard-region(";
if (equalIgnoringCase(value->function->name, dashboardRegionFunctionName)) {
validFunctionName = true;
#if ENABLE(DASHBOARD_SUPPORT) && ENABLE(WIDGET_REGION)
@@ -4317,7 +4357,7 @@ bool CSSParser::parseDashboardRegions(CSSPropertyID propId, bool important)
}
#endif
#if ENABLE(WIDGET_REGION)
- static const char* const widgetRegionFunctionName = "region(";
+ static const char widgetRegionFunctionName[] = "region(";
if (equalIgnoringCase(value->function->name, widgetRegionFunctionName)) {
validFunctionName = true;
#if ENABLE(DASHBOARD_SUPPORT) && ENABLE(WIDGET_REGION)
@@ -4515,9 +4555,7 @@ bool CSSParser::parseClipShape(CSSPropertyID propId, bool important)
return false;
}
-#if ENABLE(CSS_EXCLUSIONS)
-
-PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeRectangle(CSSParserValueList* args)
+PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeRectangle(CSSParserValueList* args)
{
ASSERT(args);
@@ -4525,7 +4563,7 @@ PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeRectangle(CSSParserValueL
if (args->size() != 7 && args->size() != 9 && args->size() != 11)
return 0;
- RefPtr<CSSWrapShapeRectangle> shape = CSSWrapShapeRectangle::create();
+ RefPtr<CSSBasicShapeRectangle> shape = CSSBasicShapeRectangle::create();
unsigned argumentNumber = 0;
CSSParserValue* argument = args->current();
@@ -4575,7 +4613,7 @@ PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeRectangle(CSSParserValueL
return shape;
}
-PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeCircle(CSSParserValueList* args)
+PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeCircle(CSSParserValueList* args)
{
ASSERT(args);
@@ -4583,7 +4621,7 @@ PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeCircle(CSSParserValueList
if (args->size() != 5)
return 0;
- RefPtr<CSSWrapShapeCircle> shape = CSSWrapShapeCircle::create();
+ RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create();
unsigned argumentNumber = 0;
CSSParserValue* argument = args->current();
@@ -4625,7 +4663,7 @@ PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeCircle(CSSParserValueList
return shape;
}
-PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeEllipse(CSSParserValueList* args)
+PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeEllipse(CSSParserValueList* args)
{
ASSERT(args);
@@ -4633,7 +4671,7 @@ PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeEllipse(CSSParserValueLis
if (args->size() != 7)
return 0;
- RefPtr<CSSWrapShapeEllipse> shape = CSSWrapShapeEllipse::create();
+ RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create();
unsigned argumentNumber = 0;
CSSParserValue* argument = args->current();
while (argument) {
@@ -4676,7 +4714,7 @@ PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeEllipse(CSSParserValueLis
return shape;
}
-PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapePolygon(CSSParserValueList* args)
+PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapePolygon(CSSParserValueList* args)
{
ASSERT(args);
@@ -4684,7 +4722,7 @@ PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapePolygon(CSSParserValueLis
if (!size)
return 0;
- RefPtr<CSSWrapShapePolygon> shape = CSSWrapShapePolygon::create();
+ RefPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::create();
CSSParserValue* argument = args->current();
if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) {
@@ -4727,36 +4765,33 @@ PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapePolygon(CSSParserValueLis
return shape;
}
-bool CSSParser::parseExclusionShape(bool shapeInside, bool important)
+bool CSSParser::parseBasicShape(CSSPropertyID propId, bool important)
{
CSSParserValue* value = m_valueList->current();
+ ASSERT(value->unit == CSSParserValue::Function);
CSSParserValueList* args = value->function->args.get();
if (!args)
return false;
- RefPtr<CSSWrapShape> shape;
-
+ RefPtr<CSSBasicShape> shape;
if (equalIgnoringCase(value->function->name, "rectangle("))
- shape = parseExclusionShapeRectangle(args);
+ shape = parseBasicShapeRectangle(args);
else if (equalIgnoringCase(value->function->name, "circle("))
- shape = parseExclusionShapeCircle(args);
+ shape = parseBasicShapeCircle(args);
else if (equalIgnoringCase(value->function->name, "ellipse("))
- shape = parseExclusionShapeEllipse(args);
+ shape = parseBasicShapeEllipse(args);
else if (equalIgnoringCase(value->function->name, "polygon("))
- shape = parseExclusionShapePolygon(args);
+ shape = parseBasicShapePolygon(args);
- if (shape) {
- addProperty(shapeInside ? CSSPropertyWebkitShapeInside : CSSPropertyWebkitShapeOutside, cssValuePool().createValue(shape.release()), important);
- m_valueList->next();
- return true;
- }
+ if (!shape)
+ return false;
- return false;
+ addProperty(propId, cssValuePool().createValue(shape.release()), important);
+ m_valueList->next();
+ return true;
}
-#endif
-
// [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family'
bool CSSParser::parseFont(bool important)
{
@@ -4843,7 +4878,13 @@ public:
{
if (!m_builder.isEmpty())
m_builder.append(' ');
- m_builder.append(string.characters, string.length);
+
+ if (string.is8Bit()) {
+ m_builder.append(string.characters8(), string.length());
+ return;
+ }
+
+ m_builder.append(string.characters16(), string.length());
}
void commit()
@@ -5196,7 +5237,8 @@ bool CSSParser::parseFontFaceUnicodeRange()
// Returns the number of characters which form a valid double
// and are terminated by the given terminator character
-static int checkForValidDouble(const UChar* string, const UChar* end, const char terminator)
+template <typename CharacterType>
+static int checkForValidDouble(const CharacterType* string, const CharacterType* end, const char terminator)
{
int length = end - string;
if (length < 1)
@@ -5226,7 +5268,8 @@ static int checkForValidDouble(const UChar* string, const UChar* end, const char
// Returns the number of characters consumed for parsing a valid double
// terminated by the given terminator character
-static int parseDouble(const UChar* string, const UChar* end, const char terminator, double& value)
+template <typename CharacterType>
+static int parseDouble(const CharacterType* string, const CharacterType* end, const char terminator, double& value)
{
int length = checkForValidDouble(string, end, terminator);
if (!length)
@@ -5260,9 +5303,10 @@ static int parseDouble(const UChar* string, const UChar* end, const char termina
return length;
}
-static bool parseColorIntOrPercentage(const UChar*& string, const UChar* end, const char terminator, CSSPrimitiveValue::UnitTypes& expect, int& value)
+template <typename CharacterType>
+static bool parseColorIntOrPercentage(const CharacterType*& string, const CharacterType* end, const char terminator, CSSPrimitiveValue::UnitTypes& expect, int& value)
{
- const UChar* current = string;
+ const CharacterType* current = string;
double localValue = 0;
bool negative = false;
while (current != end && isHTMLSpace(*current))
@@ -5327,7 +5371,8 @@ static bool parseColorIntOrPercentage(const UChar*& string, const UChar* end, co
return true;
}
-static inline bool isTenthAlpha(const UChar* string, const int length)
+template <typename CharacterType>
+static inline bool isTenthAlpha(const CharacterType* string, const int length)
{
// "0.X"
if (length == 3 && string[0] == '0' && string[1] == '.' && isASCIIDigit(string[2]))
@@ -5340,7 +5385,8 @@ static inline bool isTenthAlpha(const UChar* string, const int length)
return false;
}
-static inline bool parseAlphaValue(const UChar*& string, const UChar* end, const char terminator, int& value)
+template <typename CharacterType>
+static inline bool parseAlphaValue(const CharacterType*& string, const CharacterType* end, const char terminator, int& value)
{
while (string != end && isHTMLSpace(*string))
string++;
@@ -5391,7 +5437,8 @@ static inline bool parseAlphaValue(const UChar*& string, const UChar* end, const
return true;
}
-static inline bool mightBeRGBA(const UChar* characters, unsigned length)
+template <typename CharacterType>
+static inline bool mightBeRGBA(const CharacterType* characters, unsigned length)
{
if (length < 5)
return false;
@@ -5402,7 +5449,8 @@ static inline bool mightBeRGBA(const UChar* characters, unsigned length)
&& isASCIIAlphaCaselessEqual(characters[3], 'a');
}
-static inline bool mightBeRGB(const UChar* characters, unsigned length)
+template <typename CharacterType>
+static inline bool mightBeRGB(const CharacterType* characters, unsigned length)
{
if (length < 4)
return false;
@@ -5412,14 +5460,13 @@ static inline bool mightBeRGB(const UChar* characters, unsigned length)
&& isASCIIAlphaCaselessEqual(characters[2], 'b');
}
-bool CSSParser::fastParseColor(RGBA32& rgb, const String& name, bool strict)
+template <typename CharacterType>
+static inline bool fastParseColorInternal(RGBA32& rgb, const CharacterType* characters, unsigned length , bool strict)
{
- const UChar* characters = name.characters();
- unsigned length = name.length();
CSSPrimitiveValue::UnitTypes expect = CSSPrimitiveValue::CSS_UNKNOWN;
-
+
if (!strict && length >= 3) {
- if (name[0] == '#') {
+ if (characters[0] == '#') {
if (Color::parseHexColor(characters + 1, length - 1, rgb))
return true;
} else {
@@ -5430,13 +5477,13 @@ bool CSSParser::fastParseColor(RGBA32& rgb, const String& name, bool strict)
// Try rgba() syntax.
if (mightBeRGBA(characters, length)) {
- const UChar* current = characters + 5;
- const UChar* end = characters + length;
+ const CharacterType* current = characters + 5;
+ const CharacterType* end = characters + length;
int red;
int green;
int blue;
int alpha;
-
+
if (!parseColorIntOrPercentage(current, end, ',', expect, red))
return false;
if (!parseColorIntOrPercentage(current, end, ',', expect, green))
@@ -5453,8 +5500,8 @@ bool CSSParser::fastParseColor(RGBA32& rgb, const String& name, bool strict)
// Try rgb() syntax.
if (mightBeRGB(characters, length)) {
- const UChar* current = characters + 4;
- const UChar* end = characters + length;
+ const CharacterType* current = characters + 4;
+ const CharacterType* end = characters + length;
int red;
int green;
int blue;
@@ -5470,6 +5517,25 @@ bool CSSParser::fastParseColor(RGBA32& rgb, const String& name, bool strict)
return true;
}
+ return false;
+}
+
+bool CSSParser::fastParseColor(RGBA32& rgb, const String& name, bool strict)
+{
+ unsigned length = name.length();
+ bool parseResult;
+
+ if (!length)
+ return false;
+
+ if (name.is8Bit())
+ parseResult = fastParseColorInternal(rgb, name.characters8(), length, strict);
+ else
+ parseResult = fastParseColorInternal(rgb, name.characters(), length, strict);
+
+ if (parseResult)
+ return true;
+
// Try named colors.
Color tc;
tc.setNamedColor(name);
@@ -5478,6 +5544,7 @@ bool CSSParser::fastParseColor(RGBA32& rgb, const String& name, bool strict)
return true;
}
return false;
+
}
inline double CSSParser::parsedDouble(CSSParserValue *v, ReleaseParsedCalcValueCondition releaseCalc)
@@ -5891,8 +5958,6 @@ bool CSSParser::parseReflect(CSSPropertyID propId, bool important)
return true;
}
-#if ENABLE(CSS3_FLEXBOX)
-
bool CSSParser::parseFlex(CSSParserValueList* args, bool important)
{
if (!args || !args->size() || args->size() > 3)
@@ -5937,8 +6002,6 @@ bool CSSParser::parseFlex(CSSParserValueList* args, bool important)
return true;
}
-#endif
-
struct BorderImageParseContext {
BorderImageParseContext()
: m_canAdvance(false)
@@ -7180,9 +7243,16 @@ PassRefPtr<CSSValue> CSSParser::parseImageSet(CSSParserValueList* valueList)
double imageScaleFactor = 0;
const String& string = arg->string;
- const UChar* current = string.characters();
- const UChar* end = current + string.length();
- parseDouble(current, end, 'x', imageScaleFactor);
+ unsigned length = string.length();
+ if (!length)
+ return 0;
+ if (string.is8Bit()) {
+ const LChar* start = string.characters8();
+ parseDouble(start, start + length, 'x', imageScaleFactor);
+ } else {
+ const UChar* start = string.characters();
+ parseDouble(start, start + length, 'x', imageScaleFactor);
+ }
if (imageScaleFactor <= 0)
return 0;
imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimitiveValue::CSS_NUMBER));
@@ -7207,10 +7277,10 @@ PassRefPtr<CSSValue> CSSParser::parseImageSet(CSSParserValueList* valueList)
class TransformOperationInfo {
public:
TransformOperationInfo(const CSSParserString& name)
- : m_type(WebKitCSSTransformValue::UnknownTransformOperation)
- , m_argCount(1)
- , m_allowSingleArgument(false)
- , m_unit(CSSParser::FUnknown)
+ : m_type(WebKitCSSTransformValue::UnknownTransformOperation)
+ , m_argCount(1)
+ , m_allowSingleArgument(false)
+ , m_unit(CSSParser::FUnknown)
{
if (equalIgnoringCase(name, "scale(") || equalIgnoringCase(name, "scalex(") || equalIgnoringCase(name, "scaley(") || equalIgnoringCase(name, "scalez(")) {
m_unit = CSSParser::FNumber;
@@ -7437,6 +7507,41 @@ static bool acceptCommaOperator(CSSParserValueList* argsList)
return true;
}
+PassRefPtr<WebKitCSSArrayFunctionValue> CSSParser::parseCustomFilterArrayFunction(CSSParserValue* value)
+{
+ ASSERT(value->unit == CSSParserValue::Function && value->function);
+
+ if (!equalIgnoringCase(value->function->name, "array("))
+ return 0;
+
+ CSSParserValueList* arrayArgsParserValueList = value->function->args.get();
+ if (!arrayArgsParserValueList || !arrayArgsParserValueList->size())
+ return 0;
+
+ // array() values are comma separated.
+ RefPtr<WebKitCSSArrayFunctionValue> arrayFunction = WebKitCSSArrayFunctionValue::create();
+ while (true) {
+ // We parse pairs <Value, Comma> at each step.
+ CSSParserValue* currentParserValue = arrayArgsParserValueList->current();
+ if (!currentParserValue || !validUnit(currentParserValue, FNumber, CSSStrictMode))
+ return 0;
+
+ RefPtr<CSSValue> arrayValue = cssValuePool().createValue(currentParserValue->fValue, CSSPrimitiveValue::CSS_NUMBER);
+ arrayFunction->append(arrayValue.release());
+
+ CSSParserValue* nextParserValue = arrayArgsParserValueList->next();
+ if (!nextParserValue)
+ break;
+
+ if (!isComma(nextParserValue))
+ return 0;
+
+ arrayArgsParserValueList->next();
+ }
+
+ return arrayFunction;
+}
+
PassRefPtr<WebKitCSSMixFunctionValue> CSSParser::parseMixFunction(CSSParserValue* value)
{
ASSERT(value->unit == CSSParserValue::Function && value->function);
@@ -7445,6 +7550,9 @@ PassRefPtr<WebKitCSSMixFunctionValue> CSSParser::parseMixFunction(CSSParserValue
return 0;
CSSParserValueList* argsList = value->function->args.get();
+ if (!argsList)
+ return 0;
+
unsigned numArgs = argsList->size();
if (numArgs < 1 || numArgs > 3)
return 0;
@@ -7602,13 +7710,19 @@ PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilter(CSSParserValue* va
RefPtr<CSSValue> parameterValue;
- if (arg->unit == CSSParserValue::Function && arg->function)
+ if (arg->unit == CSSParserValue::Function && arg->function) {
// TODO: Implement other parameters types parsing.
// textures: https://bugs.webkit.org/show_bug.cgi?id=71442
// mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444
- // array: https://bugs.webkit.org/show_bug.cgi?id=94226
// 3d-transform shall be the last to be checked
- parameterValue = parseCustomFilterTransform(argsList);
+ if (equalIgnoringCase(arg->function->name, "array(")) {
+ parameterValue = parseCustomFilterArrayFunction(arg);
+ // This parsing step only consumes function arguments,
+ // argsList is therefore moved forward explicitely.
+ argsList->next();
+ } else
+ parameterValue = parseCustomFilterTransform(argsList);
+ }
else {
RefPtr<CSSValueList> paramValueList = CSSValueList::createSpaceSeparated();
while ((arg = argsList->current())) {
@@ -8143,17 +8257,17 @@ bool CSSParser::parseLineBoxContain(bool important)
bool CSSParser::parseFontFeatureTag(CSSValueList* settings)
{
// Feature tag name consists of 4-letter characters.
- static const int tagNameLength = 4;
+ static const unsigned tagNameLength = 4;
CSSParserValue* value = m_valueList->current();
// Feature tag name comes first
if (value->unit != CSSPrimitiveValue::CSS_STRING)
return false;
- if (value->string.length != tagNameLength)
+ if (value->string.length() != tagNameLength)
return false;
- for (int i = 0; i < tagNameLength; ++i) {
+ for (unsigned i = 0; i < tagNameLength; ++i) {
// Limits the range of characters to 0x20-0x7E, following the tag name rules defiend in the OpenType specification.
- UChar character = value->string.characters[i];
+ UChar character = value->string[i];
if (character < 0x20 || character > 0x7E)
return false;
}
@@ -8434,30 +8548,35 @@ static const CharacterType typesOfASCIICharacters[128] = {
// Utility functions for the CSS tokenizer.
-static inline bool isCSSLetter(UChar character)
+template <typename CharacterType>
+static inline bool isCSSLetter(CharacterType character)
{
return character >= 128 || typesOfASCIICharacters[character] <= CharacterDash;
}
-static inline bool isCSSEscape(UChar character)
+template <typename CharacterType>
+static inline bool isCSSEscape(CharacterType character)
{
return character >= ' ' && character != 127;
}
-static inline bool isURILetter(UChar character)
+template <typename CharacterType>
+static inline bool isURILetter(CharacterType character)
{
return (character >= '*' && character != 127) || (character >= '#' && character <= '&') || character == '!';
}
-static inline bool isIdentifierStartAfterDash(UChar* currentCharacter)
+template <typename CharacterType>
+static inline bool isIdentifierStartAfterDash(CharacterType* currentCharacter)
{
return isASCIIAlpha(currentCharacter[0]) || currentCharacter[0] == '_' || currentCharacter[0] >= 128
|| (currentCharacter[0] == '\\' && isCSSEscape(currentCharacter[1]));
}
-static inline bool isEqualToCSSIdentifier(UChar* cssString, const char* constantString)
+template <typename CharacterType>
+static inline bool isEqualToCSSIdentifier(CharacterType* cssString, const char* constantString)
{
- // Compare an UChar memory data with a zero terminated string.
+ // Compare an character memory data with a zero terminated string.
do {
// The input must be part of an identifier if constantChar or constString
// contains '-'. Otherwise toASCIILowerUnchecked('\r') would be equal to '-'.
@@ -8469,7 +8588,8 @@ static inline bool isEqualToCSSIdentifier(UChar* cssString, const char* constant
return true;
}
-static UChar* checkAndSkipEscape(UChar* currentCharacter)
+template <typename CharacterType>
+static CharacterType* checkAndSkipEscape(CharacterType* currentCharacter)
{
// Returns with 0, if escape check is failed. Otherwise
// it returns with the following character.
@@ -8494,7 +8614,8 @@ static UChar* checkAndSkipEscape(UChar* currentCharacter)
return currentCharacter + 1;
}
-static inline UChar* skipWhiteSpace(UChar* currentCharacter)
+template <typename CharacterType>
+static inline CharacterType* skipWhiteSpace(CharacterType* currentCharacter)
{
while (isHTMLSpace(*currentCharacter))
++currentCharacter;
@@ -8503,13 +8624,55 @@ static inline UChar* skipWhiteSpace(UChar* currentCharacter)
// Main CSS tokenizer functions.
+template <>
+LChar* CSSParserString::characters<LChar>() const { return characters8(); }
+
+template <>
+UChar* CSSParserString::characters<UChar>() const { return characters16(); }
+
+template <>
+inline LChar*& CSSParser::currentCharacter<LChar>()
+{
+ return m_currentCharacter8;
+}
+
+template <>
+inline UChar*& CSSParser::currentCharacter<UChar>()
+{
+ return m_currentCharacter16;
+}
+
+UChar*& CSSParser::currentCharacter16()
+{
+ if (!m_currentCharacter16) {
+ m_dataStart16 = adoptArrayPtr(new UChar[m_length]);
+ m_currentCharacter16 = m_dataStart16.get();
+ }
+
+ return m_currentCharacter16;
+}
+
+template <>
+inline LChar* CSSParser::tokenStart<LChar>()
+{
+ return m_tokenStart.ptr8;
+}
+
+template <>
+inline UChar* CSSParser::tokenStart<UChar>()
+{
+ return m_tokenStart.ptr16;
+}
+
+template <typename CharacterType>
inline bool CSSParser::isIdentifierStart()
{
// Check whether an identifier is started.
- return isIdentifierStartAfterDash((*m_currentCharacter != '-') ? m_currentCharacter : m_currentCharacter + 1);
+ return isIdentifierStartAfterDash((*currentCharacter<CharacterType>() != '-') ? currentCharacter<CharacterType>() : currentCharacter<CharacterType>() + 1);
}
-inline UChar* CSSParser::checkAndSkipString(UChar* currentCharacter, UChar quote)
+template <typename CharacterType>
+inline CharacterType* CSSParser::checkAndSkipString(CharacterType* currentCharacter, int quote)
{
// Returns with 0, if string check is failed. Otherwise
// it returns with the following character. This is necessary
@@ -8543,101 +8706,194 @@ inline UChar* CSSParser::checkAndSkipString(UChar* currentCharacter, UChar quote
}
}
-void CSSParser::parseEscape(UChar*& result)
+template <typename CharacterType>
+unsigned CSSParser::parseEscape(CharacterType*& src)
{
- ASSERT(*m_currentCharacter == '\\' && isCSSEscape(m_currentCharacter[1]));
+ ASSERT(*src == '\\' && isCSSEscape(src[1]));
+
+ unsigned unicode = 0;
+
+ ++src;
+ if (isASCIIHexDigit(*src)) {
- ++m_currentCharacter;
- if (isASCIIHexDigit(*m_currentCharacter)) {
- unsigned unicode = 0;
int length = 6;
do {
- unicode = (unicode << 4) + toASCIIHexValue(*m_currentCharacter++);
- } while (--length && isASCIIHexDigit(*m_currentCharacter));
+ unicode = (unicode << 4) + toASCIIHexValue(*src++);
+ } while (--length && isASCIIHexDigit(*src));
// Characters above 0x10ffff are not handled.
if (unicode > 0x10ffff)
unicode = 0xfffd;
// Optional space after the escape sequence.
- if (isHTMLSpace(*m_currentCharacter))
- ++m_currentCharacter;
+ if (isHTMLSpace(*src))
+ ++src;
- // Replace unicode with a surrogate pairs when it is bigger than 0xffff
- if (U16_LENGTH(unicode) == 2) {
- *result++ = U16_LEAD(unicode);
- *result = U16_TRAIL(unicode);
- } else
- *result = unicode;
+ return unicode;
+ }
+
+ return *currentCharacter<CharacterType>()++;
+}
+
+template <>
+inline void CSSParser::UnicodeToChars<LChar>(LChar*& result, unsigned unicode)
+{
+ ASSERT(unicode <= 0xff);
+ *result = unicode;
+
+ ++result;
+}
+
+template <>
+inline void CSSParser::UnicodeToChars<UChar>(UChar*& result, unsigned unicode)
+{
+ // Replace unicode with a surrogate pairs when it is bigger than 0xffff
+ if (U16_LENGTH(unicode) == 2) {
+ *result++ = U16_LEAD(unicode);
+ *result = U16_TRAIL(unicode);
} else
- *result = *m_currentCharacter++;
+ *result = unicode;
+
++result;
}
-inline void CSSParser::parseIdentifier(UChar*& result, bool& hasEscape)
+template <typename SrcCharacterType, typename DestCharacterType>
+inline bool CSSParser::parseIdentifierInternal(SrcCharacterType*& src, DestCharacterType*& result, bool& hasEscape)
{
- // If a valid identifier start is found, we can safely
- // parse the identifier until the next invalid character.
- ASSERT(isIdentifierStart());
hasEscape = false;
do {
- if (LIKELY(*m_currentCharacter != '\\'))
- *result++ = *m_currentCharacter++;
+ if (LIKELY(*src != '\\'))
+ *result++ = *src++;
else {
hasEscape = true;
- parseEscape(result);
+ SrcCharacterType* savedEscapeStart = src;
+ unsigned unicode = parseEscape<SrcCharacterType>(src);
+ if (unicode > 0xff && sizeof(DestCharacterType) == 1) {
+ src = savedEscapeStart;
+ return false;
+ }
+ UnicodeToChars(result, unicode);
}
- } while (isCSSLetter(m_currentCharacter[0]) || (m_currentCharacter[0] == '\\' && isCSSEscape(m_currentCharacter[1])));
+ } while (isCSSLetter(src[0]) || (src[0] == '\\' && isCSSEscape(src[1])));
+
+ return true;
+}
+
+template <typename CharacterType>
+inline void CSSParser::parseIdentifier(CharacterType*& result, CSSParserString& resultString, bool& hasEscape)
+{
+ // If a valid identifier start is found, we can safely
+ // parse the identifier until the next invalid character.
+ ASSERT(isIdentifierStart<CharacterType>());
+
+ CharacterType* start = currentCharacter<CharacterType>();
+ if (UNLIKELY(!parseIdentifierInternal(currentCharacter<CharacterType>(), result, hasEscape))) {
+ // Found an escape we couldn't handle with 8 bits, copy what has been recognized and continue
+ ASSERT(is8BitSource());
+ UChar*& result16 = currentCharacter16();
+ UChar* start16 = result16;
+ int i = 0;
+ for (; i < result - start; i++)
+ result16[i] = start[i];
+
+ result16 += i;
+
+ parseIdentifierInternal(currentCharacter<CharacterType>(), result16, hasEscape);
+
+ resultString.init(start16, result16 - start16);
+
+ return;
+ }
+
+ resultString.init(start, result - start);
}
-inline void CSSParser::parseString(UChar*& result, UChar quote)
+template <typename SrcCharacterType, typename DestCharacterType>
+inline bool CSSParser::parseStringInternal(SrcCharacterType*& src, DestCharacterType*& result, UChar quote)
{
while (true) {
- if (UNLIKELY(*m_currentCharacter == quote)) {
+ if (UNLIKELY(*src == quote)) {
// String parsing is done.
- ++m_currentCharacter;
- return;
+ ++src;
+ return true;
}
- if (UNLIKELY(!*m_currentCharacter)) {
+ if (UNLIKELY(!*src)) {
// String parsing is done, but don't advance pointer if at the end of input.
- return;
+ return true;
}
- ASSERT(*m_currentCharacter > '\r' || (*m_currentCharacter < '\n' && *m_currentCharacter) || *m_currentCharacter == '\v');
+ ASSERT(*src > '\r' || (*src < '\n' && *src) || *src == '\v');
- if (LIKELY(m_currentCharacter[0] != '\\'))
- *result++ = *m_currentCharacter++;
- else if (m_currentCharacter[1] == '\n' || m_currentCharacter[1] == '\f')
- m_currentCharacter += 2;
- else if (m_currentCharacter[1] == '\r')
- m_currentCharacter += m_currentCharacter[2] == '\n' ? 3 : 2;
- else
- parseEscape(result);
+ if (LIKELY(src[0] != '\\'))
+ *result++ = *src++;
+ else if (src[1] == '\n' || src[1] == '\f')
+ src += 2;
+ else if (src[1] == '\r')
+ src += src[2] == '\n' ? 3 : 2;
+ else {
+ SrcCharacterType* savedEscapeStart = src;
+ unsigned unicode = parseEscape<SrcCharacterType>(src);
+ if (unicode > 0xff && sizeof(DestCharacterType) == 1) {
+ src = savedEscapeStart;
+ return false;
+ }
+ UnicodeToChars(result, unicode);
+ }
+ }
+
+ return true;
+}
+
+template <typename CharacterType>
+inline void CSSParser::parseString(CharacterType*& result, CSSParserString& resultString, UChar quote)
+{
+ CharacterType* start = currentCharacter<CharacterType>();
+
+ if (UNLIKELY(!parseStringInternal(currentCharacter<CharacterType>(), result, quote))) {
+ // Found an escape we couldn't handle with 8 bits, copy what has been recognized and continue
+ ASSERT(is8BitSource());
+ UChar*& result16 = currentCharacter16();
+ UChar* start16 = result16;
+ int i = 0;
+ for (; i < result - start; i++)
+ result16[i] = start[i];
+
+ result16 += i;
+
+ parseStringInternal(currentCharacter<CharacterType>(), result16, quote);
+
+ resultString.init(start16, result16 - start16);
+ return;
}
+
+ resultString.init(start, result - start);
}
-inline void CSSParser::parseURI(UChar*& start, UChar*& result)
+template <typename CharacterType>
+inline bool CSSParser::parseURIInternal(CharacterType*& start, CharacterType*& result)
{
- UChar* uriStart = skipWhiteSpace(m_currentCharacter);
+ CharacterType* uriStart = skipWhiteSpace(currentCharacter<CharacterType>());
+ CharacterType* savedResult = result;
if (*uriStart == '"' || *uriStart == '\'') {
- UChar quote = *uriStart;
+ CharacterType quote = *uriStart;
++uriStart;
- UChar* stringEnd = checkAndSkipString(uriStart, quote);
+ CharacterType* stringEnd = checkAndSkipString(uriStart, quote);
if (!stringEnd)
- return;
+ return true;
stringEnd = skipWhiteSpace(stringEnd);
if (*stringEnd != ')')
- return;
+ return true;
- start = result = m_currentCharacter = uriStart;
- parseString(result, quote);
+ start = result = currentCharacter<CharacterType>() = uriStart;
+ if (!parseStringInternal(currentCharacter<CharacterType>(), result, quote))
+ return false;
- m_currentCharacter = stringEnd + 1;
+ currentCharacter<CharacterType>() = stringEnd + 1;
m_token = URI;
} else {
- UChar* stringEnd = uriStart;
+ CharacterType* stringEnd = uriStart;
while (isURILetter(*stringEnd)) {
if (*stringEnd != '\\')
@@ -8645,99 +8901,124 @@ inline void CSSParser::parseURI(UChar*& start, UChar*& result)
else {
stringEnd = checkAndSkipEscape(stringEnd);
if (!stringEnd)
- return;
+ return true;
}
}
stringEnd = skipWhiteSpace(stringEnd);
if (*stringEnd != ')')
- return;
+ return true;
- start = result = m_currentCharacter = uriStart;
- while (isURILetter(*m_currentCharacter)) {
- if (LIKELY(*m_currentCharacter != '\\'))
- *result++ = *m_currentCharacter++;
- else
- parseEscape(result);
+ start = result = currentCharacter<CharacterType>() = uriStart;
+ while (isURILetter(*currentCharacter<CharacterType>())) {
+ if (LIKELY(*currentCharacter<CharacterType>() != '\\'))
+ *result++ = *currentCharacter<CharacterType>()++;
+ else {
+ unsigned unicode = parseEscape<CharacterType>(currentCharacter<CharacterType>());
+ if (unicode > 0xff && sizeof(CharacterType) == 1) {
+ result = savedResult;
+ return false;
+ }
+ UnicodeToChars(result, unicode);
+ }
}
- m_currentCharacter = stringEnd + 1;
+ currentCharacter<CharacterType>() = stringEnd + 1;
m_token = URI;
}
+
+ return true;
+}
+
+template <typename CharacterType>
+inline void CSSParser::parseURI(CSSParserString& string)
+{
+ CharacterType* uriStart = string.characters<CharacterType>();
+ CharacterType* result = uriStart + string.length();
+ bool parseResult = parseURIInternal(uriStart, result);
+
+ // parseIdentifier() parsed and created the string, therefore there shouldn't be any unhandled escapses.
+ ASSERT_UNUSED(parseResult, parseResult);
+
+ string.init(uriStart, result - uriStart);
}
+template <typename CharacterType>
inline bool CSSParser::parseUnicodeRange()
{
- UChar* currentCharacter = m_currentCharacter + 1;
+ CharacterType* character = currentCharacter<CharacterType>() + 1;
int length = 6;
- ASSERT(*m_currentCharacter == '+');
+ ASSERT(*currentCharacter<CharacterType>() == '+');
- while (isASCIIHexDigit(*currentCharacter) && length) {
- ++currentCharacter;
+ while (isASCIIHexDigit(*character) && length) {
+ ++character;
--length;
}
- if (length && *currentCharacter == '?') {
+ if (length && *character == '?') {
// At most 5 hex digit followed by a question mark.
do {
- ++currentCharacter;
+ ++character;
--length;
- } while (*currentCharacter == '?' && length);
- m_currentCharacter = currentCharacter;
+ } while (*character == '?' && length);
+ currentCharacter<CharacterType>() = character;
return true;
}
if (length < 6) {
// At least one hex digit.
- if (currentCharacter[0] == '-' && isASCIIHexDigit(currentCharacter[1])) {
+ if (character[0] == '-' && isASCIIHexDigit(character[1])) {
// Followed by a dash and a hex digit.
- ++currentCharacter;
+ ++character;
length = 6;
do {
- ++currentCharacter;
- } while (--length && isASCIIHexDigit(*currentCharacter));
+ ++character;
+ } while (--length && isASCIIHexDigit(*character));
}
- m_currentCharacter = currentCharacter;
+ currentCharacter<CharacterType>() = character;
return true;
}
return false;
}
+template <typename CharacterType>
bool CSSParser::parseNthChild()
{
- UChar* currentCharacter = m_currentCharacter;
+ CharacterType* character = currentCharacter<CharacterType>();
- while (isASCIIDigit(*currentCharacter))
- ++currentCharacter;
- if (isASCIIAlphaCaselessEqual(*currentCharacter, 'n')) {
- m_currentCharacter = currentCharacter + 1;
+ while (isASCIIDigit(*character))
+ ++character;
+ if (isASCIIAlphaCaselessEqual(*character, 'n')) {
+ currentCharacter<CharacterType>() = character + 1;
return true;
}
return false;
}
+template <typename CharacterType>
bool CSSParser::parseNthChildExtra()
{
- UChar* currentCharacter = skipWhiteSpace(m_currentCharacter);
- if (*currentCharacter != '+' && *currentCharacter != '-')
+ CharacterType* character = skipWhiteSpace(currentCharacter<CharacterType>());
+ if (*character != '+' && *character != '-')
return false;
- currentCharacter = skipWhiteSpace(currentCharacter + 1);
- if (!isASCIIDigit(*currentCharacter))
+ character = skipWhiteSpace(character + 1);
+ if (!isASCIIDigit(*character))
return false;
do {
- ++currentCharacter;
- } while (isASCIIDigit(*currentCharacter));
+ ++character;
+ } while (isASCIIDigit(*character));
- m_currentCharacter = currentCharacter;
+ currentCharacter<CharacterType>() = character;
return true;
}
+template <typename CharacterType>
inline void CSSParser::detectFunctionTypeToken(int length)
{
ASSERT(length > 0);
- UChar* name = m_tokenStart;
+ CharacterType* name = tokenStart<CharacterType>();
switch (length) {
case 3:
@@ -8769,10 +9050,11 @@ inline void CSSParser::detectFunctionTypeToken(int length)
}
}
+template <typename CharacterType>
inline void CSSParser::detectMediaQueryToken(int length)
{
ASSERT(m_parsingMode == MediaQueryMode);
- UChar* name = m_tokenStart;
+ CharacterType* name = tokenStart<CharacterType>();
if (length == 3) {
if (isASCIIAlphaCaselessEqual(name[0], 'a') && isASCIIAlphaCaselessEqual(name[1], 'n') && isASCIIAlphaCaselessEqual(name[2], 'd'))
@@ -8786,7 +9068,8 @@ inline void CSSParser::detectMediaQueryToken(int length)
}
}
-inline void CSSParser::detectNumberToken(UChar* type, int length)
+template <typename CharacterType>
+inline void CSSParser::detectNumberToken(CharacterType* type, int length)
{
ASSERT(length > 0);
@@ -8903,9 +9186,10 @@ inline void CSSParser::detectNumberToken(UChar* type, int length)
}
}
+template <typename CharacterType>
inline void CSSParser::detectDashToken(int length)
{
- UChar* name = m_tokenStart;
+ CharacterType* name = tokenStart<CharacterType>();
if (length == 11) {
if (isASCIIAlphaCaselessEqual(name[10], 'y') && isEqualToCSSIdentifier(name + 1, "webkit-an"))
@@ -8922,9 +9206,10 @@ inline void CSSParser::detectDashToken(int length)
m_token = CALCFUNCTION;
}
+template <typename CharacterType>
inline void CSSParser::detectAtToken(int length, bool hasEscape)
{
- UChar* name = m_tokenStart;
+ CharacterType* name = tokenStart<CharacterType>();
ASSERT(name[0] == '@' && length >= 2);
// charset, font-face, import, media, namespace, page,
@@ -9110,81 +9395,80 @@ inline void CSSParser::detectAtToken(int length, bool hasEscape)
}
}
-int CSSParser::lex(void* yylvalWithoutType)
+template <typename SrcCharacterType>
+int CSSParser::realLex(void* yylvalWithoutType)
{
YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType);
// Write pointer for the next character.
- UChar* result;
+ SrcCharacterType* result;
+ CSSParserString resultString;
bool hasEscape;
// The input buffer is terminated by a \0 character, so
// it is safe to read one character ahead of a known non-null.
-
#ifndef NDEBUG
// In debug we check with an ASSERT that the length is > 0 for string types.
- yylval->string.characters = 0;
- yylval->string.length = 0;
+ yylval->string.clear();
#endif
restartAfterComment:
- m_tokenStart = result = m_currentCharacter;
- m_token = *m_currentCharacter;
- ++m_currentCharacter;
+ result = currentCharacter<SrcCharacterType>();
+ setTokenStart(result);
+ m_token = *currentCharacter<SrcCharacterType>();
+ ++currentCharacter<SrcCharacterType>();
switch ((m_token <= 127) ? typesOfASCIICharacters[m_token] : CharacterIdentifierStart) {
case CharacterCaselessU:
- if (UNLIKELY(*m_currentCharacter == '+'))
- if (parseUnicodeRange()) {
+ if (UNLIKELY(*currentCharacter<SrcCharacterType>() == '+'))
+ if (parseUnicodeRange<SrcCharacterType>()) {
m_token = UNICODERANGE;
- yylval->string.characters = m_tokenStart;
- yylval->string.length = m_currentCharacter - m_tokenStart;
+ yylval->string.init(tokenStart<SrcCharacterType>(), currentCharacter<SrcCharacterType>() - tokenStart<SrcCharacterType>());
break;
}
// Fall through to CharacterIdentifierStart.
case CharacterIdentifierStart:
- --m_currentCharacter;
- parseIdentifier(result, hasEscape);
+ --currentCharacter<SrcCharacterType>();
+ parseIdentifier(result, yylval->string, hasEscape);
m_token = IDENT;
- yylval->string.characters = m_tokenStart;
- yylval->string.length = result - m_tokenStart;
-
- if (UNLIKELY(*m_currentCharacter == '(')) {
+ if (UNLIKELY(*currentCharacter<SrcCharacterType>() == '(')) {
m_token = FUNCTION;
if (!hasEscape)
- detectFunctionTypeToken(result - m_tokenStart);
- ++m_currentCharacter;
+ detectFunctionTypeToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>());
+ ++currentCharacter<SrcCharacterType>();
++result;
- ++yylval->string.length;
+ ++yylval->string.m_length;
if (token() == URI) {
m_token = FUNCTION;
// Check whether it is really an URI.
- parseURI(yylval->string.characters, result);
- yylval->string.length = result - yylval->string.characters;
+ if (yylval->string.is8Bit())
+ parseURI<LChar>(yylval->string);
+ else
+ parseURI<UChar>(yylval->string);
}
} else if (UNLIKELY(m_parsingMode != NormalMode) && !hasEscape) {
if (m_parsingMode == MediaQueryMode)
- detectMediaQueryToken(result - m_tokenStart);
- else if (m_parsingMode == NthChildMode && isASCIIAlphaCaselessEqual(m_tokenStart[0], 'n')) {
- if (result - m_tokenStart == 1) {
+ detectMediaQueryToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>());
+ else if (m_parsingMode == NthChildMode && isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[0], 'n')) {
+ if (result - tokenStart<SrcCharacterType>() == 1) {
// String "n" is IDENT but "n+1" is NTH.
- if (parseNthChildExtra()) {
+ if (parseNthChildExtra<SrcCharacterType>()) {
m_token = NTH;
- yylval->string.length = m_currentCharacter - m_tokenStart;
+ yylval->string.m_length = currentCharacter<SrcCharacterType>() - tokenStart<SrcCharacterType>();
}
- } else if (result - m_tokenStart >= 2 && m_tokenStart[1] == '-') {
+ } else if (result - tokenStart<SrcCharacterType>() >= 2 && tokenStart<SrcCharacterType>()[1] == '-') {
// String "n-" is IDENT but "n-1" is NTH.
- // Set m_currentCharacter to '-' to continue parsing.
- UChar* nextCharacter = result;
- m_currentCharacter = m_tokenStart + 1;
- if (parseNthChildExtra()) {
+ // Set currentCharacter to '-' to continue parsing.
+ SrcCharacterType* nextCharacter = result;
+ currentCharacter<SrcCharacterType>() = tokenStart<SrcCharacterType>() + 1;
+ if (parseNthChildExtra<SrcCharacterType>()) {
m_token = NTH;
- yylval->string.length = m_currentCharacter - m_tokenStart;
+ yylval->string.setLength(currentCharacter<SrcCharacterType>() - tokenStart<SrcCharacterType>());
} else {
- // Revert the change to m_currentCharacter if unsuccessful.
- m_currentCharacter = nextCharacter;
+ // Revert the change to currentCharacter if unsuccessful.
+ currentCharacter<SrcCharacterType>() = nextCharacter;
}
}
}
@@ -9192,7 +9476,7 @@ restartAfterComment:
break;
case CharacterDot:
- if (!isASCIIDigit(m_currentCharacter[0]))
+ if (!isASCIIDigit(currentCharacter<SrcCharacterType>()[0]))
break;
// Fall through to CharacterNumber.
@@ -9200,23 +9484,22 @@ restartAfterComment:
bool dotSeen = (m_token == '.');
while (true) {
- if (!isASCIIDigit(m_currentCharacter[0])) {
+ if (!isASCIIDigit(currentCharacter<SrcCharacterType>()[0])) {
// Only one dot is allowed for a number,
// and it must be followed by a digit.
- if (m_currentCharacter[0] != '.' || dotSeen || !isASCIIDigit(m_currentCharacter[1]))
+ if (currentCharacter<SrcCharacterType>()[0] != '.' || dotSeen || !isASCIIDigit(currentCharacter<SrcCharacterType>()[1]))
break;
dotSeen = true;
}
- ++m_currentCharacter;
+ ++currentCharacter<SrcCharacterType>();
}
- if (UNLIKELY(m_parsingMode == NthChildMode) && !dotSeen && isASCIIAlphaCaselessEqual(*m_currentCharacter, 'n')) {
+ if (UNLIKELY(m_parsingMode == NthChildMode) && !dotSeen && isASCIIAlphaCaselessEqual(*currentCharacter<SrcCharacterType>(), 'n')) {
// "[0-9]+n" is always an NthChild.
- ++m_currentCharacter;
- parseNthChildExtra();
+ ++currentCharacter<SrcCharacterType>();
+ parseNthChildExtra<SrcCharacterType>();
m_token = NTH;
- yylval->string.characters = m_tokenStart;
- yylval->string.length = m_currentCharacter - m_tokenStart;
+ yylval->string.init(tokenStart<SrcCharacterType>(), currentCharacter<SrcCharacterType>() - tokenStart<SrcCharacterType>());
break;
}
@@ -9224,52 +9507,51 @@ restartAfterComment:
// Use SVG parser for numbers on SVG presentation attributes.
if (m_context.mode == SVGAttributeMode) {
// We need to take care of units like 'em' or 'ex'.
- UChar* currentCharacter = m_currentCharacter;
- if (isASCIIAlphaCaselessEqual(*currentCharacter, 'e')) {
- ASSERT(currentCharacter - m_tokenStart > 0);
- ++currentCharacter;
- if (*currentCharacter == '-' || *currentCharacter == '+' || isASCIIDigit(*currentCharacter)) {
- ++currentCharacter;
- while (isASCIIDigit(*currentCharacter))
- ++currentCharacter;
+ SrcCharacterType* character = currentCharacter<SrcCharacterType>();
+ if (isASCIIAlphaCaselessEqual(*character, 'e')) {
+ ASSERT(character - tokenStart<SrcCharacterType>() > 0);
+ ++character;
+ if (*character == '-' || *character == '+' || isASCIIDigit(*character)) {
+ ++character;
+ while (isASCIIDigit(*character))
+ ++character;
// Use FLOATTOKEN if the string contains exponents.
dotSeen = true;
- m_currentCharacter = currentCharacter;
+ currentCharacter<SrcCharacterType>() = character;
}
}
- if (!parseSVGNumber(m_tokenStart, currentCharacter - m_tokenStart, yylval->number))
+ if (!parseSVGNumber(tokenStart<SrcCharacterType>(), character - tokenStart<SrcCharacterType>(), yylval->number))
break;
} else
#endif
- yylval->number = charactersToDouble(m_tokenStart, m_currentCharacter - m_tokenStart);
+ yylval->number = charactersToDouble(tokenStart<SrcCharacterType>(), currentCharacter<SrcCharacterType>() - tokenStart<SrcCharacterType>());
// Type of the function.
- if (isIdentifierStart()) {
- UChar* type = m_currentCharacter;
- result = m_currentCharacter;
+ if (isIdentifierStart<SrcCharacterType>()) {
+ SrcCharacterType* type = currentCharacter<SrcCharacterType>();
+ result = currentCharacter<SrcCharacterType>();
- parseIdentifier(result, hasEscape);
- if (*m_currentCharacter == '+') {
+ parseIdentifier(result, resultString, hasEscape);
+ if (*currentCharacter<SrcCharacterType>() == '+') {
// Any identifier followed by a '+' sign is an invalid dimension.
- ++m_currentCharacter;
+ ++currentCharacter<SrcCharacterType>();
m_token = INVALIDDIMEN;
} else {
m_token = DIMEN;
if (!hasEscape)
- detectNumberToken(type, m_currentCharacter - type);
+ detectNumberToken(type, currentCharacter<SrcCharacterType>() - type);
if (m_token == DIMEN) {
// The decoded number is overwritten, but this is intentional.
- yylval->string.characters = m_tokenStart;
- yylval->string.length = m_currentCharacter - m_tokenStart;
+ yylval->string.init(tokenStart<SrcCharacterType>(), currentCharacter<SrcCharacterType>() - tokenStart<SrcCharacterType>());
}
}
- } else if (*m_currentCharacter == '%') {
+ } else if (*currentCharacter<SrcCharacterType>() == '%') {
// Although the CSS grammar says {num}% we follow
// webkit at the moment which uses {num}%+.
do {
- ++m_currentCharacter;
- } while (*m_currentCharacter == '%');
+ ++currentCharacter<SrcCharacterType>();
+ } while (*currentCharacter<SrcCharacterType>() == '%');
m_token = PERCENTAGE;
} else
m_token = dotSeen ? FLOATTOKEN : INTEGER;
@@ -9277,55 +9559,54 @@ restartAfterComment:
}
case CharacterDash:
- if (isIdentifierStartAfterDash(m_currentCharacter)) {
- --m_currentCharacter;
- parseIdentifier(result, hasEscape);
+ if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) {
+ --currentCharacter<SrcCharacterType>();
+ parseIdentifier(result, resultString, hasEscape);
m_token = IDENT;
#if ENABLE(CSS_VARIABLES)
- if (cssVariablesEnabled() && isEqualToCSSIdentifier(m_tokenStart + 1, "webkit-var") && m_tokenStart[11] == '-' && isIdentifierStartAfterDash(m_tokenStart + 12))
+ if (cssVariablesEnabled() && isEqualToCSSIdentifier(tokenStart<SrcCharacterType>() + 1, "webkit-var") && tokenStart<SrcCharacterType>()[11] == '-' && isIdentifierStartAfterDash(tokenStart<SrcCharacterType>() + 12))
m_token = VAR_DEFINITION;
else
#endif
- if (*m_currentCharacter == '(') {
+ if (*currentCharacter<SrcCharacterType>() == '(') {
m_token = FUNCTION;
if (!hasEscape)
- detectDashToken(result - m_tokenStart);
- ++m_currentCharacter;
+ detectDashToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>());
+ ++currentCharacter<SrcCharacterType>();
++result;
- } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape && isASCIIAlphaCaselessEqual(m_tokenStart[1], 'n')) {
- if (result - m_tokenStart == 2) {
+ } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape && isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) {
+ if (result - tokenStart<SrcCharacterType>() == 2) {
// String "-n" is IDENT but "-n+1" is NTH.
- if (parseNthChildExtra()) {
+ if (parseNthChildExtra<SrcCharacterType>()) {
m_token = NTH;
- result = m_currentCharacter;
+ result = currentCharacter<SrcCharacterType>();
}
- } else if (result - m_tokenStart >= 3 && m_tokenStart[2] == '-') {
+ } else if (result - tokenStart<SrcCharacterType>() >= 3 && tokenStart<SrcCharacterType>()[2] == '-') {
// String "-n-" is IDENT but "-n-1" is NTH.
- // Set m_currentCharacter to second '-' of '-n-' to continue parsing.
- UChar* nextCharacter = result;
- m_currentCharacter = m_tokenStart + 2;
- if (parseNthChildExtra()) {
+ // Set currentCharacter to second '-' of '-n-' to continue parsing.
+ SrcCharacterType* nextCharacter = result;
+ currentCharacter<SrcCharacterType>() = tokenStart<SrcCharacterType>() + 2;
+ if (parseNthChildExtra<SrcCharacterType>()) {
m_token = NTH;
- result = m_currentCharacter;
+ result = currentCharacter<SrcCharacterType>();
} else {
- // Revert the change to m_currentCharacter if unsuccessful.
- m_currentCharacter = nextCharacter;
+ // Revert the change to currentCharacter if unsuccessful.
+ currentCharacter<SrcCharacterType>() = nextCharacter;
}
}
}
- yylval->string.characters = m_tokenStart;
- yylval->string.length = result - m_tokenStart;
- } else if (m_currentCharacter[0] == '-' && m_currentCharacter[1] == '>') {
- m_currentCharacter += 2;
+ resultString.setLength(result - tokenStart<SrcCharacterType>());
+ yylval->string = resultString;
+ } else if (currentCharacter<SrcCharacterType>()[0] == '-' && currentCharacter<SrcCharacterType>()[1] == '>') {
+ currentCharacter<SrcCharacterType>() += 2;
m_token = SGML_CD;
} else if (UNLIKELY(m_parsingMode == NthChildMode)) {
// "-[0-9]+n" is always an NthChild.
- if (parseNthChild()) {
- parseNthChildExtra();
+ if (parseNthChild<SrcCharacterType>()) {
+ parseNthChildExtra<SrcCharacterType>();
m_token = NTH;
- yylval->string.characters = m_tokenStart;
- yylval->string.length = m_currentCharacter - m_tokenStart;
+ yylval->string.init(tokenStart<SrcCharacterType>(), currentCharacter<SrcCharacterType>() - tokenStart<SrcCharacterType>());
}
}
break;
@@ -9336,18 +9617,18 @@ restartAfterComment:
case CharacterNull:
// Do not advance pointer at the end of input.
- --m_currentCharacter;
+ --currentCharacter<SrcCharacterType>();
break;
case CharacterWhiteSpace:
m_token = WHITESPACE;
// Might start with a '\n'.
- --m_currentCharacter;
+ --currentCharacter<SrcCharacterType>();
do {
- if (*m_currentCharacter == '\n')
+ if (*currentCharacter<SrcCharacterType>() == '\n')
++m_lineNumber;
- ++m_currentCharacter;
- } while (*m_currentCharacter <= ' ' && (typesOfASCIICharacters[*m_currentCharacter] == CharacterWhiteSpace));
+ ++currentCharacter<SrcCharacterType>();
+ } while (*currentCharacter<SrcCharacterType>() <= ' ' && (typesOfASCIICharacters[*currentCharacter<SrcCharacterType>()] == CharacterWhiteSpace));
break;
case CharacterEndMediaQuery:
@@ -9361,42 +9642,39 @@ restartAfterComment:
break;
case CharacterQuote:
- if (checkAndSkipString(m_currentCharacter, m_token)) {
+ if (checkAndSkipString(currentCharacter<SrcCharacterType>(), m_token)) {
++result;
- parseString(result, m_token);
+ parseString<SrcCharacterType>(result, yylval->string, m_token);
m_token = STRING;
- yylval->string.characters = m_tokenStart + 1;
- yylval->string.length = result - (m_tokenStart + 1);
}
break;
case CharacterExclamationMark: {
- UChar* start = skipWhiteSpace(m_currentCharacter);
+ SrcCharacterType* start = skipWhiteSpace(currentCharacter<SrcCharacterType>());
if (isEqualToCSSIdentifier(start, "important")) {
m_token = IMPORTANT_SYM;
- m_currentCharacter = start + 9;
+ currentCharacter<SrcCharacterType>() = start + 9;
}
break;
}
case CharacterHashmark: {
- UChar* start = m_currentCharacter;
- result = m_currentCharacter;
+ SrcCharacterType* start = currentCharacter<SrcCharacterType>();
+ result = currentCharacter<SrcCharacterType>();
- if (isASCIIDigit(*m_currentCharacter)) {
+ if (isASCIIDigit(*currentCharacter<SrcCharacterType>())) {
// This must be a valid hex number token.
do {
- ++m_currentCharacter;
- } while (isASCIIHexDigit(*m_currentCharacter));
+ ++currentCharacter<SrcCharacterType>();
+ } while (isASCIIHexDigit(*currentCharacter<SrcCharacterType>()));
m_token = HEX;
- yylval->string.characters = start;
- yylval->string.length = m_currentCharacter - start;
- } else if (isIdentifierStart()) {
+ yylval->string.init(start, currentCharacter<SrcCharacterType>() - start);
+ } else if (isIdentifierStart<SrcCharacterType>()) {
m_token = IDSEL;
- parseIdentifier(result, hasEscape);
+ parseIdentifier(result, yylval->string, hasEscape);
if (!hasEscape) {
// Check whether the identifier is also a valid hex number.
- UChar* current = start;
+ SrcCharacterType* current = start;
m_token = HEX;
do {
if (!isASCIIHexDigit(*current)) {
@@ -9406,41 +9684,39 @@ restartAfterComment:
++current;
} while (current < result);
}
- yylval->string.characters = start;
- yylval->string.length = result - start;
}
break;
}
case CharacterSlash:
// Ignore comments. They are not even considered as white spaces.
- if (*m_currentCharacter == '*') {
- ++m_currentCharacter;
- while (m_currentCharacter[0] != '*' || m_currentCharacter[1] != '/') {
- if (*m_currentCharacter == '\n')
+ if (*currentCharacter<SrcCharacterType>() == '*') {
+ ++currentCharacter<SrcCharacterType>();
+ while (currentCharacter<SrcCharacterType>()[0] != '*' || currentCharacter<SrcCharacterType>()[1] != '/') {
+ if (*currentCharacter<SrcCharacterType>() == '\n')
++m_lineNumber;
- if (*m_currentCharacter == '\0') {
+ if (*currentCharacter<SrcCharacterType>() == '\0') {
// Unterminated comments are simply ignored.
- m_currentCharacter -= 2;
+ currentCharacter<SrcCharacterType>() -= 2;
break;
}
- ++m_currentCharacter;
+ ++currentCharacter<SrcCharacterType>();
}
- m_currentCharacter += 2;
+ currentCharacter<SrcCharacterType>() += 2;
goto restartAfterComment;
}
break;
case CharacterDollar:
- if (*m_currentCharacter == '=') {
- ++m_currentCharacter;
+ if (*currentCharacter<SrcCharacterType>() == '=') {
+ ++currentCharacter<SrcCharacterType>();
m_token = ENDSWITH;
}
break;
case CharacterAsterisk:
- if (*m_currentCharacter == '=') {
- ++m_currentCharacter;
+ if (*currentCharacter<SrcCharacterType>() == '=') {
+ ++currentCharacter<SrcCharacterType>();
m_token = CONTAINS;
}
break;
@@ -9448,58 +9724,55 @@ restartAfterComment:
case CharacterPlus:
if (UNLIKELY(m_parsingMode == NthChildMode)) {
// Simplest case. "+[0-9]*n" is always NthChild.
- if (parseNthChild()) {
- parseNthChildExtra();
+ if (parseNthChild<SrcCharacterType>()) {
+ parseNthChildExtra<SrcCharacterType>();
m_token = NTH;
- yylval->string.characters = m_tokenStart;
- yylval->string.length = m_currentCharacter - m_tokenStart;
+ yylval->string.init(tokenStart<SrcCharacterType>(), currentCharacter<SrcCharacterType>() - tokenStart<SrcCharacterType>());
}
}
break;
case CharacterLess:
- if (m_currentCharacter[0] == '!' && m_currentCharacter[1] == '-' && m_currentCharacter[2] == '-') {
- m_currentCharacter += 3;
+ if (currentCharacter<SrcCharacterType>()[0] == '!' && currentCharacter<SrcCharacterType>()[1] == '-' && currentCharacter<SrcCharacterType>()[2] == '-') {
+ currentCharacter<SrcCharacterType>() += 3;
m_token = SGML_CD;
}
break;
case CharacterAt:
- if (isIdentifierStart()) {
+ if (isIdentifierStart<SrcCharacterType>()) {
m_token = ATKEYWORD;
++result;
- parseIdentifier(result, hasEscape);
- detectAtToken(result - m_tokenStart, hasEscape);
+ parseIdentifier(result, resultString, hasEscape);
+ detectAtToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>(), hasEscape);
}
break;
case CharacterBackSlash:
- if (isCSSEscape(*m_currentCharacter)) {
- --m_currentCharacter;
- parseIdentifier(result, hasEscape);
+ if (isCSSEscape(*currentCharacter<SrcCharacterType>())) {
+ --currentCharacter<SrcCharacterType>();
+ parseIdentifier(result, yylval->string, hasEscape);
m_token = IDENT;
- yylval->string.characters = m_tokenStart;
- yylval->string.length = result - m_tokenStart;
}
break;
case CharacterXor:
- if (*m_currentCharacter == '=') {
- ++m_currentCharacter;
+ if (*currentCharacter<SrcCharacterType>() == '=') {
+ ++currentCharacter<SrcCharacterType>();
m_token = BEGINSWITH;
}
break;
case CharacterVerticalBar:
- if (*m_currentCharacter == '=') {
- ++m_currentCharacter;
+ if (*currentCharacter<SrcCharacterType>() == '=') {
+ ++currentCharacter<SrcCharacterType>();
m_token = DASHMATCH;
}
break;
case CharacterTilde:
- if (*m_currentCharacter == '=') {
- ++m_currentCharacter;
+ if (*currentCharacter<SrcCharacterType>() == '=') {
+ ++currentCharacter<SrcCharacterType>();
m_token = INCLUDES;
}
break;
@@ -9509,36 +9782,6 @@ restartAfterComment:
break;
}
-#ifndef NDEBUG
- switch (token()) {
- case STRING:
- ASSERT(yylval->string.characters == m_tokenStart + 1);
- break;
-
- case IDENT:
- case NTH:
- case DIMEN:
- case UNICODERANGE:
- case FUNCTION:
- case ANYFUNCTION:
- case NOTFUNCTION:
- case CALCFUNCTION:
- case MINFUNCTION:
- case MAXFUNCTION:
- ASSERT(yylval->string.characters == m_tokenStart && yylval->string.length > 0);
- break;
-
- case URI:
- ASSERT(yylval->string.characters && yylval->string.characters != m_tokenStart);
- break;
-
- case HEX:
- case IDSEL:
- ASSERT(yylval->string.characters == m_tokenStart + 1 && yylval->string.length > 0);
- break;
- }
-#endif
-
return token();
}
@@ -9945,17 +10188,17 @@ void CSSParser::deleteFontFaceOnlyValues()
StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys)
{
// Create a key string from the passed keys
- String keyString;
+ StringBuilder keyString;
for (unsigned i = 0; i < keys->size(); ++i) {
float key = static_cast<float>(keys->valueAt(i)->fValue);
if (i != 0)
- keyString += ",";
- keyString += String::number(key);
- keyString += "%";
+ keyString.append(',');
+ keyString.append(String::number(key));
+ keyString.append('%');
}
RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
- keyframe->setKeyText(keyString);
+ keyframe->setKeyText(keyString.toString());
keyframe->setProperties(createStylePropertySet());
clearProperties();
@@ -9981,17 +10224,15 @@ void CSSParser::updateLastMediaLine(MediaQuerySet* media)
media->setLastLine(m_lineNumber);
}
-void CSSParser::fixUnparsedPropertyRanges(CSSRuleSourceData* ruleData)
+template <typename CharacterType>
+static inline void fixUnparsedProperties(const CharacterType* characters, CSSRuleSourceData* ruleData)
{
- if (!ruleData->styleSourceData)
- return;
Vector<CSSPropertySourceData>& propertyData = ruleData->styleSourceData->propertyData;
unsigned size = propertyData.size();
if (!size)
return;
unsigned styleStart = ruleData->ruleBodyRange.start;
- const UChar* characters = m_dataStart.get() + m_parsedTextPrefixLength;
CSSPropertySourceData* nextData = &(propertyData.at(0));
for (unsigned i = 0; i < size; ++i) {
CSSPropertySourceData* currentData = nextData;
@@ -10028,36 +10269,60 @@ void CSSParser::fixUnparsedPropertyRanges(CSSRuleSourceData* ruleData)
}
}
+void CSSParser::fixUnparsedPropertyRanges(CSSRuleSourceData* ruleData)
+{
+ if (!ruleData->styleSourceData)
+ return;
+
+ if (is8BitSource()) {
+ fixUnparsedProperties<LChar>(m_dataStart8.get() + m_parsedTextPrefixLength, ruleData);
+ return;
+ }
+
+ fixUnparsedProperties<UChar>(m_dataStart16.get() + m_parsedTextPrefixLength, ruleData);
+}
+
void CSSParser::markRuleHeaderStart(CSSRuleSourceData::Type ruleType)
{
if (!isExtractingSourceData())
return;
RefPtr<CSSRuleSourceData> data = CSSRuleSourceData::create(ruleType);
- data->ruleHeaderRange.start = m_tokenStart - m_dataStart.get();
+ data->ruleHeaderRange.start = tokenStartOffset();
m_currentRuleDataStack->append(data.release());
}
-void CSSParser::markRuleHeaderEnd()
+template <typename CharacterType>
+inline void CSSParser::setRuleHeaderEnd(const CharacterType* dataStart)
{
- if (!isExtractingSourceData())
- return;
- ASSERT(!m_currentRuleDataStack->isEmpty());
- UChar* listEnd = m_tokenStart;
- while (listEnd > m_dataStart.get() + 1) {
+ CharacterType* listEnd = tokenStart<CharacterType>();
+ while (listEnd > dataStart + 1) {
if (isHTMLSpace(*(listEnd - 1)))
--listEnd;
else
break;
}
- m_currentRuleDataStack->last()->ruleHeaderRange.end = listEnd - m_dataStart.get();
+
+ m_currentRuleDataStack->last()->ruleHeaderRange.end = listEnd - dataStart;
+}
+
+void CSSParser::markRuleHeaderEnd()
+{
+ if (!isExtractingSourceData())
+ return;
+ ASSERT(!m_currentRuleDataStack->isEmpty());
+
+ if (is8BitSource())
+ setRuleHeaderEnd<LChar>(m_dataStart8.get());
+ else
+ setRuleHeaderEnd<UChar>(m_dataStart16.get());
}
void CSSParser::markRuleBodyStart()
{
if (!isExtractingSourceData())
return;
- unsigned offset = m_tokenStart - m_dataStart.get();
- if (*m_tokenStart == '{')
+ unsigned offset = tokenStartOffset();
+ if (tokenStartChar() == '{')
++offset; // Skip the rule body opening brace.
ASSERT(!m_currentRuleDataStack->isEmpty());
m_currentRuleDataStack->last()->ruleBodyRange.start = offset;
@@ -10066,7 +10331,7 @@ void CSSParser::markRuleBodyStart()
void CSSParser::markRuleBodyEnd()
{
// Precondition: (!isExtractingSourceData())
- unsigned offset = m_tokenStart - m_dataStart.get();
+ unsigned offset = tokenStartOffset();
ASSERT(!m_currentRuleDataStack->isEmpty());
m_currentRuleDataStack->last()->ruleBodyRange.end = offset;
}
@@ -10078,7 +10343,7 @@ void CSSParser::markPropertyStart()
if (m_currentRuleDataStack->isEmpty() || !m_currentRuleDataStack->last()->styleSourceData)
return;
- m_propertyRange.start = m_tokenStart - m_dataStart.get();
+ m_propertyRange.start = tokenStartOffset();
}
void CSSParser::markPropertyEnd(bool isImportantFound, bool isPropertyParsed)
@@ -10088,8 +10353,8 @@ void CSSParser::markPropertyEnd(bool isImportantFound, bool isPropertyParsed)
if (m_currentRuleDataStack->isEmpty() || !m_currentRuleDataStack->last()->styleSourceData)
return;
- unsigned offset = m_tokenStart - m_dataStart.get();
- if (*m_tokenStart == ';') // Include semicolon into the property text.
+ unsigned offset = tokenStartOffset();
+ if (tokenStartChar() == ';') // Include semicolon into the property text.
++offset;
m_propertyRange.end = offset;
if (m_propertyRange.start != UINT_MAX && !m_currentRuleDataStack->isEmpty()) {
@@ -10097,7 +10362,11 @@ void CSSParser::markPropertyEnd(bool isImportantFound, bool isPropertyParsed)
const unsigned start = m_propertyRange.start;
const unsigned end = m_propertyRange.end;
ASSERT(start < end);
- String propertyString = String(m_dataStart.get() + start, end - start).stripWhiteSpace();
+ String propertyString;
+ if (is8BitSource())
+ propertyString = String(m_dataStart8.get() + start, end - start).stripWhiteSpace();
+ else
+ propertyString = String(m_dataStart16.get() + start, end - start).stripWhiteSpace();
if (propertyString.endsWith(';'))
propertyString = propertyString.left(propertyString.length() - 1);
size_t colonIndex = propertyString.find(':');
@@ -10113,17 +10382,13 @@ void CSSParser::markPropertyEnd(bool isImportantFound, bool isPropertyParsed)
resetPropertyRange();
}
-static CSSPropertyID cssPropertyID(const UChar* propertyName, unsigned length)
+template <typename CharacterType>
+static CSSPropertyID cssPropertyID(const CharacterType* propertyName, unsigned length)
{
- if (!length)
- return CSSPropertyInvalid;
- if (length > maxCSSPropertyNameLength)
- return CSSPropertyInvalid;
-
char buffer[maxCSSPropertyNameLength + 1 + 1]; // 1 to turn "apple"/"khtml" into "webkit", 1 for null character
for (unsigned i = 0; i != length; ++i) {
- UChar c = propertyName[i];
+ CharacterType c = propertyName[i];
if (c == 0 || c >= 0x7F)
return CSSPropertyInvalid; // illegal character
buffer[i] = toASCIILower(c);
@@ -10161,12 +10426,26 @@ static CSSPropertyID cssPropertyID(const UChar* propertyName, unsigned length)
CSSPropertyID cssPropertyID(const String& string)
{
- return cssPropertyID(string.characters(), string.length());
+ unsigned length = string.length();
+
+ if (!length)
+ return CSSPropertyInvalid;
+ if (length > maxCSSPropertyNameLength)
+ return CSSPropertyInvalid;
+
+ return string.is8Bit() ? cssPropertyID(string.characters8(), length) : cssPropertyID(string.characters(), length);
}
CSSPropertyID cssPropertyID(const CSSParserString& string)
{
- return cssPropertyID(string.characters, string.length);
+ unsigned length = string.length();
+
+ if (!length)
+ return CSSPropertyInvalid;
+ if (length > maxCSSPropertyNameLength)
+ return CSSPropertyInvalid;
+
+ return string.is8Bit() ? cssPropertyID(string.characters8(), length) : cssPropertyID(string.characters16(), length);
}
#if PLATFORM(IOS)
@@ -10181,18 +10460,13 @@ void cssPropertyNameIOSAliasing(const char* propertyName, const char*& propertyN
}
#endif
-int cssValueKeywordID(const CSSParserString& string)
+template <typename CharacterType>
+static int cssValueKeywordID(const CharacterType* valueKeyword, unsigned length)
{
- unsigned length = string.length;
- if (!length)
- return 0;
- if (length > maxCSSValueKeywordLength)
- return 0;
-
char buffer[maxCSSValueKeywordLength + 1 + 1]; // 1 to turn "apple"/"khtml" into "webkit", 1 for null character
for (unsigned i = 0; i != length; ++i) {
- UChar c = string.characters[i];
+ CharacterType c = valueKeyword[i];
if (c == 0 || c >= 0x7F)
return 0; // illegal character
buffer[i] = WTF::toASCIILower(c);
@@ -10213,38 +10487,60 @@ int cssValueKeywordID(const CSSParserString& string)
return hashTableEntry ? hashTableEntry->id : 0;
}
-// "ident" from the CSS tokenizer, minus backslash-escape sequences
-static bool isCSSTokenizerIdentifier(const String& string)
+int cssValueKeywordID(const CSSParserString& string)
+{
+ unsigned length = string.length();
+ if (!length)
+ return 0;
+ if (length > maxCSSValueKeywordLength)
+ return 0;
+
+ return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : cssValueKeywordID(string.characters16(), length);
+}
+
+template <typename CharacterType>
+static inline bool isCSSTokenizerIdentifier(const CharacterType* characters, unsigned length)
{
- const UChar* p = string.characters();
- const UChar* end = p + string.length();
+ const CharacterType* end = characters + length;
// -?
- if (p != end && p[0] == '-')
- ++p;
+ if (characters != end && characters[0] == '-')
+ ++characters;
// {nmstart}
- if (p == end || !(p[0] == '_' || p[0] >= 128 || isASCIIAlpha(p[0])))
+ if (characters == end || !(characters[0] == '_' || characters[0] >= 128 || isASCIIAlpha(characters[0])))
return false;
- ++p;
+ ++characters;
// {nmchar}*
- for (; p != end; ++p) {
- if (!(p[0] == '_' || p[0] == '-' || p[0] >= 128 || isASCIIAlphanumeric(p[0])))
+ for (; characters != end; ++characters) {
+ if (!(characters[0] == '_' || characters[0] == '-' || characters[0] >= 128 || isASCIIAlphanumeric(characters[0])))
return false;
}
return true;
}
-// "url" from the CSS tokenizer, minus backslash-escape sequences
-static bool isCSSTokenizerURL(const String& string)
+// "ident" from the CSS tokenizer, minus backslash-escape sequences
+static bool isCSSTokenizerIdentifier(const String& string)
{
- const UChar* p = string.characters();
- const UChar* end = p + string.length();
+ unsigned length = string.length();
- for (; p != end; ++p) {
- UChar c = p[0];
+ if (!length)
+ return false;
+
+ if (string.is8Bit())
+ return isCSSTokenizerIdentifier(string.characters8(), length);
+ return isCSSTokenizerIdentifier(string.characters(), length);
+}
+
+template <typename CharacterType>
+static inline bool isCSSTokenizerURL(const CharacterType* characters, unsigned length)
+{
+ const CharacterType* end = characters + length;
+
+ for (; characters != end; ++characters) {
+ CharacterType c = characters[0];
switch (c) {
case '!':
case '#':
@@ -10261,10 +10557,23 @@ static bool isCSSTokenizerURL(const String& string)
return false;
}
}
-
+
return true;
}
+// "url" from the CSS tokenizer, minus backslash-escape sequences
+static bool isCSSTokenizerURL(const String& string)
+{
+ unsigned length = string.length();
+
+ if (!length)
+ return true;
+
+ if (string.is8Bit())
+ return isCSSTokenizerURL(string.characters8(), length);
+ return isCSSTokenizerURL(string.characters(), length);
+}
+
// We use single quotes for now because markup.cpp uses double quotes.
String quoteCSSString(const String& string)
{
diff --git a/Source/WebCore/css/CSSParser.h b/Source/WebCore/css/CSSParser.h
index 16e5bd70c..e33090f83 100644
--- a/Source/WebCore/css/CSSParser.h
+++ b/Source/WebCore/css/CSSParser.h
@@ -51,7 +51,7 @@ class CSSProperty;
class CSSSelectorList;
class CSSValue;
class CSSValueList;
-class CSSWrapShape;
+class CSSBasicShape;
class Document;
class Element;
class MediaQueryExp;
@@ -66,10 +66,13 @@ class StyleSheetContents;
class StyledElement;
#if ENABLE(CSS_SHADERS)
+class WebKitCSSArrayFunctionValue;
class WebKitCSSMixFunctionValue;
#endif
class CSSParser {
+ friend inline int cssyylex(void*, CSSParser*);
+
public:
CSSParser(const CSSParserContext&);
@@ -148,11 +151,11 @@ public:
bool parseClipShape(CSSPropertyID, bool important);
- bool parseExclusionShape(bool shapeInside, bool important);
- PassRefPtr<CSSWrapShape> parseExclusionShapeRectangle(CSSParserValueList* args);
- PassRefPtr<CSSWrapShape> parseExclusionShapeCircle(CSSParserValueList* args);
- PassRefPtr<CSSWrapShape> parseExclusionShapeEllipse(CSSParserValueList* args);
- PassRefPtr<CSSWrapShape> parseExclusionShapePolygon(CSSParserValueList* args);
+ bool parseBasicShape(CSSPropertyID, bool important);
+ PassRefPtr<CSSBasicShape> parseBasicShapeRectangle(CSSParserValueList* args);
+ PassRefPtr<CSSBasicShape> parseBasicShapeCircle(CSSParserValueList* args);
+ PassRefPtr<CSSBasicShape> parseBasicShapeEllipse(CSSParserValueList* args);
+ PassRefPtr<CSSBasicShape> parseBasicShapePolygon(CSSParserValueList* args);
bool parseFont(bool important);
PassRefPtr<CSSValueList> parseFontFamily();
@@ -219,6 +222,7 @@ public:
PassRefPtr<CSSValueList> parseFilter();
PassRefPtr<WebKitCSSFilterValue> parseBuiltinFilterArguments(CSSParserValueList*, WebKitCSSFilterValue::FilterOperationType);
#if ENABLE(CSS_SHADERS)
+ PassRefPtr<WebKitCSSArrayFunctionValue> parseCustomFilterArrayFunction(CSSParserValue*);
PassRefPtr<WebKitCSSMixFunctionValue> parseMixFunction(CSSParserValue*);
PassRefPtr<WebKitCSSFilterValue> parseCustomFilter(CSSParserValue*);
PassRefPtr<CSSValueList> parseCustomFilterTransform(CSSParserValueList*);
@@ -354,7 +358,9 @@ public:
PassRefPtr<CSSRuleSourceData> popRuleData();
void resetPropertyRange() { m_propertyRange.start = m_propertyRange.end = UINT_MAX; }
bool isExtractingSourceData() const { return !!m_currentRuleDataStack; }
- int lex(void* yylval);
+
+ inline int lex(void* yylval) { return (this->*m_lexFunc)(yylval); }
+
int token() { return m_token; }
PassRefPtr<CSSPrimitiveValue> createPrimitiveNumericValue(CSSParserValue*);
@@ -363,23 +369,72 @@ public:
static KURL completeURL(const CSSParserContext&, const String& url);
private:
+ bool is8BitSource() { return m_is8BitSource; }
+
+ template <typename SourceCharacterType>
+ int realLex(void* yylval);
+
+ UChar*& currentCharacter16();
+
+ template <typename CharacterType>
+ inline CharacterType*& currentCharacter();
+
+ template <typename CharacterType>
+ inline CharacterType* tokenStart();
+
+ template <typename CharacterType>
+ inline void setTokenStart(CharacterType*);
+
+ inline unsigned tokenStartOffset();
+ inline UChar tokenStartChar();
+
+ template <typename CharacterType>
inline bool isIdentifierStart();
- static inline UChar* checkAndSkipString(UChar*, UChar);
+ template <typename CharacterType>
+ static inline CharacterType* checkAndSkipString(CharacterType*, int);
- void parseEscape(UChar*&);
- inline void parseIdentifier(UChar*&, bool&);
- inline void parseString(UChar*&, UChar);
- inline void parseURI(UChar*&, UChar*&);
+ template <typename CharacterType>
+ unsigned parseEscape(CharacterType*&);
+ template <typename DestCharacterType>
+ inline void UnicodeToChars(DestCharacterType*&, unsigned);
+ template <typename SrcCharacterType, typename DestCharacterType>
+ inline bool parseIdentifierInternal(SrcCharacterType*&, DestCharacterType*&, bool&);
+
+ template <typename CharacterType>
+ inline void parseIdentifier(CharacterType*&, CSSParserString&, bool&);
+
+ template <typename SrcCharacterType, typename DestCharacterType>
+ inline bool parseStringInternal(SrcCharacterType*&, DestCharacterType*&, UChar);
+
+ template <typename CharacterType>
+ inline void parseString(CharacterType*&, CSSParserString& resultString, UChar);
+
+ template <typename CharacterType>
+ inline bool parseURIInternal(CharacterType*&, CharacterType*&);
+
+ template <typename CharacterType>
+ inline void parseURI(CSSParserString&);
+ template <typename CharacterType>
inline bool parseUnicodeRange();
+ template <typename CharacterType>
bool parseNthChild();
+ template <typename CharacterType>
bool parseNthChildExtra();
+ template <typename CharacterType>
inline void detectFunctionTypeToken(int);
+ template <typename CharacterType>
inline void detectMediaQueryToken(int);
- inline void detectNumberToken(UChar*, int);
+ template <typename CharacterType>
+ inline void detectNumberToken(CharacterType*, int);
+ template <typename CharacterType>
inline void detectDashToken(int);
+ template <typename CharacterType>
inline void detectAtToken(int, bool);
+ template <typename CharacterType>
+ inline void setRuleHeaderEnd(const CharacterType*);
+
void setStyleSheet(StyleSheetContents*);
inline bool inStrictMode() const { return m_context.mode == CSSStrictMode || m_context.mode == SVGAttributeMode; }
@@ -430,9 +485,16 @@ private:
};
ParsingMode m_parsingMode;
- OwnArrayPtr<UChar> m_dataStart;
- UChar* m_currentCharacter;
- UChar* m_tokenStart;
+ bool m_is8BitSource;
+ OwnArrayPtr<LChar> m_dataStart8;
+ OwnArrayPtr<UChar> m_dataStart16;
+ LChar* m_currentCharacter8;
+ UChar* m_currentCharacter16;
+ union {
+ LChar* ptr8;
+ UChar* ptr16;
+ } m_tokenStart;
+ unsigned m_length;
int m_token;
int m_lineNumber;
int m_lastSelectorLineNumber;
@@ -440,6 +502,8 @@ private:
bool m_allowImportRules;
bool m_allowNamespaceDeclarations;
+ int (CSSParser::*m_lexFunc)(void*);
+
Vector<RefPtr<StyleRuleBase> > m_parsedRules;
Vector<RefPtr<StyleKeyframe> > m_parsedKeyframes;
Vector<RefPtr<MediaQuerySet> > m_parsedMediaQuerySets;
@@ -535,6 +599,38 @@ String quoteCSSStringIfNeeded(const String&);
String quoteCSSURLIfNeeded(const String&);
bool isValidNthToken(const CSSParserString&);
+
+template <>
+inline void CSSParser::setTokenStart<LChar>(LChar* tokenStart)
+{
+ m_tokenStart.ptr8 = tokenStart;
+}
+
+template <>
+inline void CSSParser::setTokenStart<UChar>(UChar* tokenStart)
+{
+ m_tokenStart.ptr16 = tokenStart;
+}
+
+inline unsigned CSSParser::tokenStartOffset()
+{
+ if (is8BitSource())
+ return m_tokenStart.ptr8 - m_dataStart8.get();
+ return m_tokenStart.ptr16 - m_dataStart16.get();
+}
+
+inline UChar CSSParser::tokenStartChar()
+{
+ if (is8BitSource())
+ return *m_tokenStart.ptr8;
+ return *m_tokenStart.ptr16;
+}
+
+inline int cssyylex(void* yylval, CSSParser* parser)
+{
+ return parser->lex(yylval);
+}
+
} // namespace WebCore
#endif // CSSParser_h
diff --git a/Source/WebCore/css/CSSParserValues.cpp b/Source/WebCore/css/CSSParserValues.cpp
index 1ab4dfefd..8b7625578 100644
--- a/Source/WebCore/css/CSSParserValues.cpp
+++ b/Source/WebCore/css/CSSParserValues.cpp
@@ -67,31 +67,81 @@ PassRefPtr<CSSValue> CSSParserValue::createCSSValue()
{
RefPtr<CSSValue> parsedValue;
if (id)
- parsedValue = CSSPrimitiveValue::createIdentifier(id);
- else if (unit == CSSPrimitiveValue::CSS_IDENT)
- parsedValue = CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_PARSER_IDENTIFIER);
- else if (unit == CSSPrimitiveValue::CSS_NUMBER && isInt)
- parsedValue = CSSPrimitiveValue::create(fValue, CSSPrimitiveValue::CSS_PARSER_INTEGER);
- else if (unit == CSSParserValue::Operator) {
+ return CSSPrimitiveValue::createIdentifier(id);
+
+ if (unit == CSSParserValue::Operator) {
RefPtr<CSSPrimitiveValue> primitiveValue = CSSPrimitiveValue::createIdentifier(iValue);
primitiveValue->setPrimitiveType(CSSPrimitiveValue::CSS_PARSER_OPERATOR);
- parsedValue = primitiveValue;
- } else if (unit == CSSParserValue::Function)
- parsedValue = CSSFunctionValue::create(function);
- else if (unit == CSSPrimitiveValue::CSS_STRING
- || unit == CSSPrimitiveValue::CSS_URI
+ return primitiveValue;
+ }
+ if (unit == CSSParserValue::Function)
+ return CSSFunctionValue::create(function);
+ if (unit >= CSSParserValue::Q_EMS)
+ return CSSPrimitiveValue::createAllowingMarginQuirk(fValue, CSSPrimitiveValue::CSS_EMS);
+
+ CSSPrimitiveValue::UnitTypes primitiveUnit = static_cast<CSSPrimitiveValue::UnitTypes>(unit);
+ switch (primitiveUnit) {
+ case CSSPrimitiveValue::CSS_IDENT:
+ return CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_PARSER_IDENTIFIER);
+ case CSSPrimitiveValue::CSS_NUMBER:
+ return CSSPrimitiveValue::create(fValue, isInt ? CSSPrimitiveValue::CSS_PARSER_INTEGER : CSSPrimitiveValue::CSS_NUMBER);
+ case CSSPrimitiveValue::CSS_STRING:
+ case CSSPrimitiveValue::CSS_URI:
#if ENABLE(CSS_VARIABLES)
- || unit == CSSPrimitiveValue::CSS_VARIABLE_NAME
+ case CSSPrimitiveValue::CSS_VARIABLE_NAME:
+#endif
+ case CSSPrimitiveValue::CSS_PARSER_HEXCOLOR:
+ return CSSPrimitiveValue::create(string, primitiveUnit);
+ case CSSPrimitiveValue::CSS_PERCENTAGE:
+ case CSSPrimitiveValue::CSS_EMS:
+ case CSSPrimitiveValue::CSS_EXS:
+ case CSSPrimitiveValue::CSS_PX:
+ case CSSPrimitiveValue::CSS_CM:
+ case CSSPrimitiveValue::CSS_MM:
+ case CSSPrimitiveValue::CSS_IN:
+ case CSSPrimitiveValue::CSS_PT:
+ case CSSPrimitiveValue::CSS_PC:
+ case CSSPrimitiveValue::CSS_DEG:
+ case CSSPrimitiveValue::CSS_RAD:
+ case CSSPrimitiveValue::CSS_GRAD:
+ case CSSPrimitiveValue::CSS_MS:
+ case CSSPrimitiveValue::CSS_S:
+ case CSSPrimitiveValue::CSS_HZ:
+ case CSSPrimitiveValue::CSS_KHZ:
+ case CSSPrimitiveValue::CSS_VW:
+ case CSSPrimitiveValue::CSS_VH:
+ case CSSPrimitiveValue::CSS_VMIN:
+ case CSSPrimitiveValue::CSS_TURN:
+ case CSSPrimitiveValue::CSS_REMS:
+ return CSSPrimitiveValue::create(fValue, primitiveUnit);
+ case CSSPrimitiveValue::CSS_UNKNOWN:
+ case CSSPrimitiveValue::CSS_DIMENSION:
+ case CSSPrimitiveValue::CSS_ATTR:
+ case CSSPrimitiveValue::CSS_COUNTER:
+ case CSSPrimitiveValue::CSS_RECT:
+ case CSSPrimitiveValue::CSS_RGBCOLOR:
+ case CSSPrimitiveValue::CSS_DPPX:
+ case CSSPrimitiveValue::CSS_DPI:
+ case CSSPrimitiveValue::CSS_DPCM:
+ case CSSPrimitiveValue::CSS_PAIR:
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
+ case CSSPrimitiveValue::CSS_DASHBOARD_REGION:
#endif
- || unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR)
- parsedValue = CSSPrimitiveValue::create(string, (CSSPrimitiveValue::UnitTypes)unit);
- else if (unit >= CSSPrimitiveValue::CSS_NUMBER && unit <= CSSPrimitiveValue::CSS_KHZ)
- parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit);
- else if (unit >= CSSPrimitiveValue::CSS_TURN && unit <= CSSPrimitiveValue::CSS_REMS) // CSS3 Values and Units
- parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit);
- else if (unit >= CSSParserValue::Q_EMS)
- parsedValue = CSSPrimitiveValue::createAllowingMarginQuirk(fValue, CSSPrimitiveValue::CSS_EMS);
- return parsedValue;
+ case CSSPrimitiveValue::CSS_UNICODE_RANGE:
+ case CSSPrimitiveValue::CSS_PARSER_OPERATOR:
+ case CSSPrimitiveValue::CSS_PARSER_INTEGER:
+ case CSSPrimitiveValue::CSS_PARSER_IDENTIFIER:
+ case CSSPrimitiveValue::CSS_COUNTER_NAME:
+ case CSSPrimitiveValue::CSS_SHAPE:
+ case CSSPrimitiveValue::CSS_QUAD:
+ case CSSPrimitiveValue::CSS_CALC:
+ case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER:
+ case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH:
+ return 0;
+ }
+
+ ASSERT_NOT_REACHED();
+ return 0;
}
CSSParserSelector::CSSParserSelector()
diff --git a/Source/WebCore/css/CSSParserValues.h b/Source/WebCore/css/CSSParserValues.h
index a736abb89..ad11198be 100644
--- a/Source/WebCore/css/CSSParserValues.h
+++ b/Source/WebCore/css/CSSParserValues.h
@@ -24,6 +24,7 @@
#include "CSSSelector.h"
#include "CSSValueList.h"
#include <wtf/text/AtomicString.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -31,13 +32,74 @@ class CSSValue;
class QualifiedName;
struct CSSParserString {
- UChar* characters;
- int length;
+ void init(LChar* characters, unsigned length)
+ {
+ m_data.characters8 = characters;
+ m_length = length;
+ m_is8Bit = true;
+ }
+
+ void init(UChar* characters, unsigned length)
+ {
+ m_data.characters16 = characters;
+ m_length = length;
+ m_is8Bit = false;
+ }
+
+ void init(String string)
+ {
+ m_length = string.length();
+ if (m_length && string.is8Bit()) {
+ m_data.characters8 = const_cast<LChar*>(string.characters8());
+ m_is8Bit = true;
+ } else {
+ m_data.characters16 = const_cast<UChar*>(string.characters());
+ m_is8Bit = false;
+ }
+ }
+
+ void clear()
+ {
+ m_data.characters8 = 0;
+ m_length = 0;
+ m_is8Bit = false;
+ }
+
+ bool is8Bit() const { return m_is8Bit; }
+ LChar* characters8() const { ASSERT(is8Bit()); return m_data.characters8; }
+ UChar* characters16() const { ASSERT(!is8Bit()); return m_data.characters16; }
+ template <typename CharacterType>
+ CharacterType* characters() const;
+
+ unsigned length() const { return m_length; }
+ void setLength(unsigned length) { m_length = length; }
void lower();
- operator String() const { return String(characters, length); }
- operator AtomicString() const { return AtomicString(characters, length); }
+ UChar operator[](unsigned i)
+ {
+ ASSERT(i < m_length);
+ if (is8Bit())
+ return m_data.characters8[i];
+ return m_data.characters16[i];
+ }
+
+ bool equalIgnoringCase(const char* str)
+ {
+ if (is8Bit())
+ return WTF::equalIgnoringCase(str, characters8(), length());
+ return WTF::equalIgnoringCase(str, characters16(), length());
+ }
+
+ operator String() const { return is8Bit() ? String(m_data.characters8, m_length) : String(m_data.characters16, m_length); }
+ operator AtomicString() const { return is8Bit() ? AtomicString(m_data.characters8, m_length) : AtomicString(m_data.characters16, m_length); }
+
+ union {
+ LChar* characters8;
+ UChar* characters16;
+ } m_data;
+ unsigned m_length;
+ bool m_is8Bit;
};
struct CSSParserFunction;
diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp
index c433f2094..c1bd02233 100644
--- a/Source/WebCore/css/CSSPrimitiveValue.cpp
+++ b/Source/WebCore/css/CSSPrimitiveValue.cpp
@@ -21,24 +21,24 @@
#include "config.h"
#include "CSSPrimitiveValue.h"
+#include "CSSBasicShapes.h"
#include "CSSCalculationValue.h"
#include "CSSHelper.h"
#include "CSSParser.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
-#include "CSSWrapShapes.h"
#include "CalculationValue.h"
#include "Color.h"
#include "Counter.h"
#include "ExceptionCode.h"
#include "Font.h"
-#include "MemoryInstrumentation.h"
#include "Node.h"
#include "Pair.h"
#include "RGBColor.h"
#include "Rect.h"
#include "RenderStyle.h"
#include "StyleSheetContents.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/ASCIICType.h>
#include <wtf/DecimalNumber.h>
#include <wtf/StdLibExtras.h>
@@ -91,7 +91,9 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit
case CSSPrimitiveValue:: CSS_ATTR:
case CSSPrimitiveValue:: CSS_COUNTER:
case CSSPrimitiveValue:: CSS_COUNTER_NAME:
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
case CSSPrimitiveValue:: CSS_DASHBOARD_REGION:
+#endif
#if !ENABLE(CSS_IMAGE_RESOLUTION)
case CSSPrimitiveValue:: CSS_DPPX:
case CSSPrimitiveValue:: CSS_DPI:
@@ -186,6 +188,10 @@ unsigned short CSSPrimitiveValue::primitiveType() const
return CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER;
case CalcPercentLength:
return CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH;
+#if ENABLE(CSS_VARIABLES)
+ case CalcVariable:
+ return CSSPrimitiveValue::CSS_UNKNOWN; // The type of a calculation containing a variable cannot be known until the value of the variable is determined.
+#endif
case CalcOther:
return CSSPrimitiveValue::CSS_UNKNOWN;
}
@@ -347,7 +353,7 @@ void CSSPrimitiveValue::init(PassRefPtr<CSSCalcValue> c)
m_value.calc = c.leakRef();
}
-void CSSPrimitiveValue::init(PassRefPtr<CSSWrapShape> shape)
+void CSSPrimitiveValue::init(PassRefPtr<CSSBasicShape> shape)
{
m_primitiveUnitType = CSS_SHAPE;
m_hasCachedCSSText = false;
@@ -361,11 +367,14 @@ CSSPrimitiveValue::~CSSPrimitiveValue()
void CSSPrimitiveValue::cleanup()
{
- switch (m_primitiveUnitType) {
+ switch (static_cast<UnitTypes>(m_primitiveUnitType)) {
case CSS_STRING:
case CSS_URI:
case CSS_ATTR:
case CSS_COUNTER_NAME:
+#if ENABLE(CSS_VARIABLES)
+ case CSS_VARIABLE_NAME:
+#endif
case CSS_PARSER_HEXCOLOR:
if (m_value.string)
m_value.string->deref();
@@ -382,7 +391,7 @@ void CSSPrimitiveValue::cleanup()
case CSS_PAIR:
m_value.pair->deref();
break;
-#if ENABLE(DASHBOARD_SUPPORT)
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
case CSS_DASHBOARD_REGION:
if (m_value.region)
m_value.region->deref();
@@ -391,6 +400,10 @@ void CSSPrimitiveValue::cleanup()
case CSS_CALC:
m_value.calc->deref();
break;
+ case CSS_CALC_PERCENTAGE_WITH_NUMBER:
+ case CSS_CALC_PERCENTAGE_WITH_LENGTH:
+ ASSERT_NOT_REACHED();
+ break;
case CSS_SHAPE:
m_value.shape->deref();
break;
@@ -417,10 +430,14 @@ void CSSPrimitiveValue::cleanup()
case CSS_VW:
case CSS_VH:
case CSS_VMIN:
+ case CSS_DPPX:
+ case CSS_DPI:
+ case CSS_DPCM:
case CSS_IDENT:
case CSS_RGBCOLOR:
case CSS_DIMENSION:
case CSS_UNKNOWN:
+ case CSS_UNICODE_RANGE:
case CSS_PARSER_OPERATOR:
case CSS_PARSER_IDENTIFIER:
break;
@@ -462,7 +479,8 @@ template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderS
template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
{
#if ENABLE(SUBPIXEL_LAYOUT)
- return Length(static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), Fixed);
+ double value = computeLengthDouble(style, rootStyle, multiplier, computingFontSize);
+ return Length(static_cast<float>(value > intMaxForLayoutUnit || value < intMinForLayoutUnit ? 0.0 : value), Fixed);
#else
return Length(roundForImpreciseConversion<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), Fixed);
#endif
@@ -490,6 +508,10 @@ template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderSty
double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
{
+ if (m_primitiveUnitType == CSS_CALC)
+ // The multiplier and factor is applied to each value in the calc expression individually
+ return m_value.calc->computeLengthPx(style, rootStyle, multiplier, computingFontSize);
+
double factor;
switch (primitiveType()) {
@@ -536,18 +558,11 @@ double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* r
return -1.0;
}
- double computedValue;
- if (m_primitiveUnitType == CSS_CALC)
- // The multiplier is passed in as 1.0 here to ensure it is only applied once
- computedValue = m_value.calc->computeLengthPx(style, rootStyle, 1.0, computingFontSize);
- else
- computedValue = getDoubleValue();
-
// We do not apply the zoom factor when we are computing the value of the font-size property. The zooming
// for font sizes is much more complicated, since we have to worry about enforcing the minimum font size preference
// as well as enforcing the implicit "smart minimum." In addition the CSS property text-size-adjust is used to
// prevent text from zooming at all. Therefore we will not apply the zoom here if we are computing font-size.
- double result = computedValue * factor;
+ double result = getDoubleValue() * factor;
if (computingFontSize || isFontRelativeLength())
return result;
@@ -948,9 +963,7 @@ String CSSPrimitiveValue::customCssText() const
break;
}
case CSS_COUNTER_NAME:
- text = "counter(";
- text += m_value.string;
- text += ")";
+ text = "counter(" + String(m_value.string) + ')';
break;
case CSS_COUNTER: {
StringBuilder result;
@@ -1034,30 +1047,34 @@ String CSSPrimitiveValue::customCssText() const
text = String::adopt(result);
break;
}
- case CSS_PAIR:
- text = m_value.pair->first()->cssText();
+ case CSS_PAIR: {
+ StringBuilder result;
+ result.append(m_value.pair->first()->cssText());
if (m_value.pair->second() != m_value.pair->first()) {
- text += " ";
- text += m_value.pair->second()->cssText();
+ result.append(' ');
+ result.append(m_value.pair->second()->cssText());
}
+ text = result.toString();
break;
+ }
#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
- case CSS_DASHBOARD_REGION:
+ case CSS_DASHBOARD_REGION: {
+ StringBuilder result;
for (DashboardRegion* region = getDashboardRegionValue(); region; region = region->m_next.get()) {
- if (!text.isEmpty())
- text.append(' ');
+ if (!result.isEmpty())
+ result.append(' ');
#if ENABLE(DASHBOARD_SUPPORT) && ENABLE(WIDGET_REGION)
- text += region->m_cssFunctionName;
+ result.append(region->m_cssFunctionName);
#elif ENABLE(DASHBOARD_SUPPORT)
- text += "dashboard-region(";
+ result.appendLiteral("dashboard-region(");
#else
- text += "region(";
+ result.appendLiteral("region(");
#endif
- text += region->m_label;
+ result.append(region->m_label);
if (region->m_isCircle)
- text += " circle";
+ result.appendLiteral(" circle");
else if (region->m_isRectangle)
- text += " rectangle";
+ result.appendLiteral(" rectangle");
else
break;
if (region->top()->m_primitiveUnitType == CSS_IDENT && region->top()->getIdent() == CSSValueInvalid) {
@@ -1068,15 +1085,20 @@ String CSSPrimitiveValue::customCssText() const
ASSERT(region->bottom()->getIdent() == CSSValueInvalid);
ASSERT(region->left()->getIdent() == CSSValueInvalid);
} else {
- text.append(' ');
- text += region->top()->cssText() + " ";
- text += region->right()->cssText() + " ";
- text += region->bottom()->cssText() + " ";
- text += region->left()->cssText();
+ result.append(' ');
+ result.append(region->top()->cssText());
+ result.append(' ');
+ result.append(region->right()->cssText());
+ result.append(' ');
+ result.append(region->bottom()->cssText());
+ result.append(' ');
+ result.append(region->left()->cssText());
}
- text += ")";
+ result.append(')');
}
+ text = result.toString();
break;
+ }
#endif
case CSS_PARSER_OPERATOR: {
char c = static_cast<char>(m_value.ident);
@@ -1103,9 +1125,7 @@ String CSSPrimitiveValue::customCssText() const
break;
#if ENABLE(CSS_VARIABLES)
case CSS_VARIABLE_NAME:
- text = "-webkit-var(";
- text += m_value.string;
- text += ")";
+ text = "-webkit-var(" + String(m_value.string) + ")";
break;
#endif
}
@@ -1119,8 +1139,10 @@ String CSSPrimitiveValue::customCssText() const
#if ENABLE(CSS_VARIABLES)
String CSSPrimitiveValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
{
- if (m_primitiveUnitType == CSS_VARIABLE_NAME && variables.contains(m_value.string))
+ if (isVariableName() && variables.contains(m_value.string))
return variables.get(m_value.string);
+ if (isCalculated())
+ return cssCalcValue()->customSerializeResolvingVariables(variables);
return customCssText();
}
#endif
@@ -1241,7 +1263,7 @@ PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const
void CSSPrimitiveValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
switch (m_primitiveUnitType) {
case CSS_ATTR:
case CSS_COUNTER_NAME:
diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h
index fd0832d34..103ea6a83 100644
--- a/Source/WebCore/css/CSSPrimitiveValue.h
+++ b/Source/WebCore/css/CSSPrimitiveValue.h
@@ -38,7 +38,7 @@ class Quad;
class RGBColor;
class Rect;
class RenderStyle;
-class CSSWrapShape;
+class CSSBasicShape;
struct Length;
@@ -99,7 +99,9 @@ public:
CSS_DPI = 30,
CSS_DPCM = 31,
CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.)
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
CSS_DASHBOARD_REGION = 101, // FIXME: Dashboard region should not be a primitive value.
+#endif
CSS_UNICODE_RANGE = 102,
// These next types are just used internally to allow us to translate back and forth from CSSPrimitiveValues to CSSParserValues.
@@ -282,9 +284,11 @@ public:
Pair* getPairValue(ExceptionCode&) const;
Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_value.pair; }
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
DashboardRegion* getDashboardRegionValue() const { return m_primitiveUnitType != CSS_DASHBOARD_REGION ? 0 : m_value.region; }
+#endif
- CSSWrapShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHAPE ? 0 : m_value.shape; }
+ CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHAPE ? 0 : m_value.shape; }
CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? 0 : m_value.calc; }
@@ -340,7 +344,7 @@ private:
void init(PassRefPtr<Pair>);
void init(PassRefPtr<Quad>);
void init(PassRefPtr<DashboardRegion>); // FIXME: Dashboard region should not be a primitive value.
- void init(PassRefPtr<CSSWrapShape>);
+ void init(PassRefPtr<CSSBasicShape>);
void init(PassRefPtr<CSSCalcValue>);
bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const;
@@ -356,7 +360,7 @@ private:
unsigned rgbcolor;
Pair* pair;
DashboardRegion* region;
- CSSWrapShape* shape;
+ CSSBasicShape* shape;
CSSCalcValue* calc;
} m_value;
};
diff --git a/Source/WebCore/css/CSSPrimitiveValueMappings.h b/Source/WebCore/css/CSSPrimitiveValueMappings.h
index 806605fe3..2df502050 100644
--- a/Source/WebCore/css/CSSPrimitiveValueMappings.h
+++ b/Source/WebCore/css/CSSPrimitiveValueMappings.h
@@ -1147,14 +1147,12 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e)
case INLINE_BOX:
m_value.ident = CSSValueWebkitInlineBox;
break;
-#if ENABLE(CSS3_FLEXBOX)
case FLEX:
m_value.ident = CSSValueWebkitFlex;
break;
case INLINE_FLEX:
m_value.ident = CSSValueWebkitInlineFlex;
break;
-#endif
case GRID:
m_value.ident = CSSValueWebkitGrid;
break;
@@ -1204,8 +1202,6 @@ template<> inline CSSPrimitiveValue::operator EEmptyCell() const
return SHOW;
}
-#if ENABLE(CSS3_FLEXBOX)
-
template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAlignItems e)
: CSSValue(PrimitiveClass)
{
@@ -1411,8 +1407,6 @@ template<> inline CSSPrimitiveValue::operator EFlexWrap() const
return FlexWrapNone;
}
-#endif
-
template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFloat e)
: CSSValue(PrimitiveClass)
{
@@ -2624,31 +2618,31 @@ template<> inline CSSPrimitiveValue::operator EWordBreak() const
return NormalWordBreak;
}
-template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EWordWrap e)
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EOverflowWrap e)
: CSSValue(PrimitiveClass)
{
m_primitiveUnitType = CSS_IDENT;
switch (e) {
- case NormalWordWrap:
+ case NormalOverflowWrap:
m_value.ident = CSSValueNormal;
break;
- case BreakWordWrap:
+ case BreakOverflowWrap:
m_value.ident = CSSValueBreakWord;
break;
}
}
-template<> inline CSSPrimitiveValue::operator EWordWrap() const
+template<> inline CSSPrimitiveValue::operator EOverflowWrap() const
{
switch (m_value.ident) {
case CSSValueBreakWord:
- return BreakWordWrap;
+ return BreakOverflowWrap;
case CSSValueNormal:
- return NormalWordWrap;
+ return NormalOverflowWrap;
}
ASSERT_NOT_REACHED();
- return NormalWordWrap;
+ return NormalOverflowWrap;
}
template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextDirection e)
diff --git a/Source/WebCore/css/CSSProperty.cpp b/Source/WebCore/css/CSSProperty.cpp
index 9bc8966c1..a556b6cb6 100644
--- a/Source/WebCore/css/CSSProperty.cpp
+++ b/Source/WebCore/css/CSSProperty.cpp
@@ -22,15 +22,16 @@
#include "CSSProperty.h"
#include "CSSValueList.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
#include "RenderStyleConstants.h"
#include "StylePropertyShorthand.h"
+#include "WebCoreMemoryInstrumentation.h"
#if ENABLE(CSS_VARIABLES)
#include "CSSVariableValue.h"
#endif
+#include <wtf/text/StringBuilder.h>
+
namespace WebCore {
struct SameSizeAsCSSProperty {
@@ -53,7 +54,14 @@ String CSSProperty::cssName() const
String CSSProperty::cssText() const
{
- return cssName() + ": " + m_value->cssText() + (isImportant() ? " !important" : "") + "; ";
+ StringBuilder result;
+ result.append(cssName());
+ result.appendLiteral(": ");
+ result.append(m_value->cssText());
+ if (isImportant())
+ result.appendLiteral(" !important");
+ result.append(';');
+ return result.toString();
}
void CSSProperty::wrapValueInCommaSeparatedList()
@@ -468,6 +476,7 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
case CSSPropertyOutlineStyle:
case CSSPropertyOutlineWidth:
case CSSPropertyOverflow:
+ case CSSPropertyOverflowWrap:
case CSSPropertyOverflowX:
case CSSPropertyOverflowY:
case CSSPropertyPadding:
@@ -552,6 +561,7 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
case CSSPropertyWebkitBoxPack:
case CSSPropertyWebkitBoxReflect:
case CSSPropertyWebkitBoxShadow:
+ case CSSPropertyWebkitClipPath:
case CSSPropertyWebkitColumnAxis:
case CSSPropertyWebkitColumnBreakAfter:
case CSSPropertyWebkitColumnBreakBefore:
@@ -572,7 +582,6 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
#if ENABLE(CSS_COMPOSITING)
case CSSPropertyWebkitBlendMode:
#endif
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitAlignContent:
case CSSPropertyWebkitAlignItems:
case CSSPropertyWebkitAlignSelf:
@@ -585,7 +594,6 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
case CSSPropertyWebkitFlexWrap:
case CSSPropertyWebkitJustifyContent:
case CSSPropertyWebkitOrder:
-#endif
case CSSPropertyWebkitFontSizeDelta:
case CSSPropertyWebkitGridColumns:
case CSSPropertyWebkitGridRows:
@@ -706,7 +714,7 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
void CSSProperty::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_value);
}
diff --git a/Source/WebCore/css/CSSPropertyNames.in b/Source/WebCore/css/CSSPropertyNames.in
index 685f350ad..7330e0076 100644
--- a/Source/WebCore/css/CSSPropertyNames.in
+++ b/Source/WebCore/css/CSSPropertyNames.in
@@ -95,6 +95,7 @@ caption-side
-epub-caption-side = caption-side
clear
clip
+-webkit-clip-path
content
counter-increment
counter-reset
@@ -136,6 +137,7 @@ outline-offset
outline-style
outline-width
overflow
+overflow-wrap
overflow-x
overflow-y
padding
@@ -269,7 +271,6 @@ z-index
#if defined(ENABLE_CSS_COMPOSITING) && ENABLE_CSS_COMPOSITING
-webkit-blend-mode
#endif
-#if defined(ENABLE_CSS3_FLEXBOX) && ENABLE_CSS3_FLEXBOX
-webkit-align-content
-webkit-align-items
-webkit-align-self
@@ -281,7 +282,6 @@ z-index
-webkit-flex-shrink
-webkit-flex-wrap
-webkit-justify-content
-#endif
-webkit-font-size-delta
-webkit-grid-columns
-webkit-grid-rows
diff --git a/Source/WebCore/css/CSSPropertySourceData.cpp b/Source/WebCore/css/CSSPropertySourceData.cpp
index d17ac8db6..1c5dc9b7e 100644
--- a/Source/WebCore/css/CSSPropertySourceData.cpp
+++ b/Source/WebCore/css/CSSPropertySourceData.cpp
@@ -36,8 +36,8 @@
#include "CSSPropertySourceData.h"
-#include "PlatformString.h"
#include <wtf/StaticConstructors.h>
+#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringHash.h>
namespace WebCore {
@@ -88,18 +88,19 @@ CSSPropertySourceData::CSSPropertySourceData()
String CSSPropertySourceData::toString() const
{
- DEFINE_STATIC_LOCAL(String, emptyValue, ("e"));
- DEFINE_STATIC_LOCAL(String, importantSuffix, (" !important"));
+ DEFINE_STATIC_LOCAL(String, emptyValue, (ASCIILiteral("e")));
+ DEFINE_STATIC_LOCAL(String, importantSuffix, (ASCIILiteral(" !important")));
if (!name && value == emptyValue)
return String();
- String result = name;
- result += ": ";
- result += value;
+ StringBuilder result;
+ result.append(name);
+ result.appendLiteral(": ");
+ result.append(value);
if (important)
- result += importantSuffix;
- result += ";";
- return result;
+ result.append(importantSuffix);
+ result.append(';');
+ return result.toString();
}
unsigned CSSPropertySourceData::hash() const
diff --git a/Source/WebCore/css/CSSPropertySourceData.h b/Source/WebCore/css/CSSPropertySourceData.h
index 24daef4a9..469bdb630 100644
--- a/Source/WebCore/css/CSSPropertySourceData.h
+++ b/Source/WebCore/css/CSSPropertySourceData.h
@@ -31,12 +31,12 @@
#ifndef CSSPropertySourceData_h
#define CSSPropertySourceData_h
-#include "PlatformString.h"
#include <utility>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/CSSReflectValue.cpp b/Source/WebCore/css/CSSReflectValue.cpp
index ede3c9a1f..7ccb76ecf 100644
--- a/Source/WebCore/css/CSSReflectValue.cpp
+++ b/Source/WebCore/css/CSSReflectValue.cpp
@@ -27,8 +27,8 @@
#include "CSSReflectValue.h"
#include "CSSPrimitiveValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
using namespace std;
@@ -36,28 +36,29 @@ namespace WebCore {
String CSSReflectValue::customCssText() const
{
- String result;
+ StringBuilder result;
switch (m_direction) {
case ReflectionBelow:
- result += "below ";
+ result.appendLiteral("below ");
break;
case ReflectionAbove:
- result += "above ";
+ result.appendLiteral("above ");
break;
case ReflectionLeft:
- result += "left ";
+ result.appendLiteral("left ");
break;
case ReflectionRight:
- result += "right ";
+ result.appendLiteral("right ");
break;
default:
break;
}
- result += m_offset->cssText() + " ";
+ result.append(m_offset->cssText());
+ result.append(' ');
if (m_mask)
- result += m_mask->cssText();
- return result;
+ result.append(m_mask->cssText());
+ return result.toString();
}
void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
@@ -68,7 +69,7 @@ void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const Sty
void CSSReflectValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_offset);
info.addInstrumentedMember(m_mask);
}
diff --git a/Source/WebCore/css/CSSRule.cpp b/Source/WebCore/css/CSSRule.cpp
index 2915a6e4a..fa7ecf148 100644
--- a/Source/WebCore/css/CSSRule.cpp
+++ b/Source/WebCore/css/CSSRule.cpp
@@ -212,7 +212,7 @@ const CSSParserContext& CSSRule::parserContext() const
void CSSRule::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
if (m_parentIsRule)
info.addInstrumentedMember(m_parentRule);
else
diff --git a/Source/WebCore/css/CSSRuleList.cpp b/Source/WebCore/css/CSSRuleList.cpp
index aed1a7cd9..472b3dd60 100644
--- a/Source/WebCore/css/CSSRuleList.cpp
+++ b/Source/WebCore/css/CSSRuleList.cpp
@@ -53,7 +53,7 @@ void StaticCSSRuleList::deref()
void StaticCSSRuleList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedVector(m_rules);
}
diff --git a/Source/WebCore/css/CSSRuleList.h b/Source/WebCore/css/CSSRuleList.h
index 311ead529..cacf151af 100644
--- a/Source/WebCore/css/CSSRuleList.h
+++ b/Source/WebCore/css/CSSRuleList.h
@@ -22,7 +22,7 @@
#ifndef CSSRuleList_h
#define CSSRuleList_h
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -88,7 +88,7 @@ public:
virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_rule);
}
diff --git a/Source/WebCore/css/CSSSelector.cpp b/Source/WebCore/css/CSSSelector.cpp
index eabee493a..5c26256a8 100644
--- a/Source/WebCore/css/CSSSelector.cpp
+++ b/Source/WebCore/css/CSSSelector.cpp
@@ -33,6 +33,7 @@
#include <wtf/HashMap.h>
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -515,16 +516,16 @@ bool CSSSelector::operator==(const CSSSelector& other)
String CSSSelector::selectorText() const
{
- String str = "";
+ StringBuilder str;
const AtomicString& prefix = m_tag.prefix();
const AtomicString& localName = m_tag.localName();
if (m_match == CSSSelector::None || !prefix.isNull() || localName != starAtom) {
if (prefix.isNull())
- str = localName;
+ str.append(localName);
else {
- str = prefix.string();
- str.append("|");
+ str.append(prefix.string());
+ str.append('|');
str.append(localName);
}
}
@@ -532,82 +533,82 @@ String CSSSelector::selectorText() const
const CSSSelector* cs = this;
while (true) {
if (cs->m_match == CSSSelector::Id) {
- str += "#";
+ str.append('#');
serializeIdentifier(cs->value(), str);
} else if (cs->m_match == CSSSelector::Class) {
- str += ".";
+ str.append('.');
serializeIdentifier(cs->value(), str);
} else if (cs->m_match == CSSSelector::PseudoClass || cs->m_match == CSSSelector::PagePseudoClass) {
- str += ":";
- str += cs->value();
+ str.append(':');
+ str.append(cs->value());
switch (cs->pseudoType()) {
case PseudoNot:
if (CSSSelectorList* selectorList = cs->selectorList())
- str += selectorList->first()->selectorText();
- str += ")";
+ str.append(selectorList->first()->selectorText());
+ str.append(')');
break;
case PseudoLang:
case PseudoNthChild:
case PseudoNthLastChild:
case PseudoNthOfType:
case PseudoNthLastOfType:
- str += cs->argument();
- str += ")";
+ str.append(cs->argument());
+ str.append(')');
break;
case PseudoAny: {
CSSSelector* firstSubSelector = cs->selectorList()->first();
for (CSSSelector* subSelector = firstSubSelector; subSelector; subSelector = CSSSelectorList::next(subSelector)) {
if (subSelector != firstSubSelector)
- str += ",";
- str += subSelector->selectorText();
+ str.append(',');
+ str.append(subSelector->selectorText());
}
- str += ")";
+ str.append(')');
break;
}
default:
break;
}
} else if (cs->m_match == CSSSelector::PseudoElement) {
- str += "::";
- str += cs->value();
+ str.appendLiteral("::");
+ str.append(cs->value());
} else if (cs->isAttributeSelector()) {
- str += "[";
+ str.append('[');
const AtomicString& prefix = cs->attribute().prefix();
if (!prefix.isNull()) {
str.append(prefix);
str.append("|");
}
- str += cs->attribute().localName();
+ str.append(cs->attribute().localName());
switch (cs->m_match) {
case CSSSelector::Exact:
- str += "=";
+ str.append('=');
break;
case CSSSelector::Set:
// set has no operator or value, just the attrName
- str += "]";
+ str.append(']');
break;
case CSSSelector::List:
- str += "~=";
+ str.appendLiteral("~=");
break;
case CSSSelector::Hyphen:
- str += "|=";
+ str.appendLiteral("|=");
break;
case CSSSelector::Begin:
- str += "^=";
+ str.appendLiteral("^=");
break;
case CSSSelector::End:
- str += "$=";
+ str.appendLiteral("$=");
break;
case CSSSelector::Contain:
- str += "*=";
+ str.appendLiteral("*=");
break;
default:
break;
}
if (cs->m_match != CSSSelector::Set) {
serializeString(cs->value(), str);
- str += "]";
+ str.append(']');
}
}
if (cs->relation() != CSSSelector::SubSelector || !cs->tagHistory())
@@ -618,19 +619,20 @@ String CSSSelector::selectorText() const
if (CSSSelector* tagHistory = cs->tagHistory()) {
String tagHistoryText = tagHistory->selectorText();
if (cs->relation() == CSSSelector::DirectAdjacent)
- str = tagHistoryText + " + " + str;
+ return tagHistoryText + " + " + str.toString();
else if (cs->relation() == CSSSelector::IndirectAdjacent)
- str = tagHistoryText + " ~ " + str;
+ return tagHistoryText + " ~ " + str.toString();
else if (cs->relation() == CSSSelector::Child)
- str = tagHistoryText + " > " + str;
+ return tagHistoryText + " > " + str.toString();
else if (cs->relation() == CSSSelector::ShadowDescendant)
- str = tagHistoryText + str;
- else
+ return tagHistoryText + str.toString();
+ else {
// Descendant
- str = tagHistoryText + " " + str;
+ return tagHistoryText + " " + str.toString();
+ }
}
- return str;
+ return str.toString();
}
void CSSSelector::setAttribute(const QualifiedName& value)
diff --git a/Source/WebCore/css/CSSSelectorList.cpp b/Source/WebCore/css/CSSSelectorList.cpp
index 3cf020a72..56d2859d2 100644
--- a/Source/WebCore/css/CSSSelectorList.cpp
+++ b/Source/WebCore/css/CSSSelectorList.cpp
@@ -28,7 +28,7 @@
#include "CSSSelectorList.h"
#include "CSSParserValues.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -145,7 +145,7 @@ String CSSSelectorList::selectorsText() const
void CSSSelectorList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addRawBuffer(m_selectorArray, length() * sizeof(CSSSelector));
}
diff --git a/Source/WebCore/css/CSSStyleRule.cpp b/Source/WebCore/css/CSSStyleRule.cpp
index 7f82ae593..365d8d90f 100644
--- a/Source/WebCore/css/CSSStyleRule.cpp
+++ b/Source/WebCore/css/CSSStyleRule.cpp
@@ -26,10 +26,10 @@
#include "CSSSelector.h"
#include "CSSStyleSheet.h"
#include "Document.h"
-#include "MemoryInstrumentation.h"
#include "PropertySetCSSStyleDeclaration.h"
#include "StylePropertySet.h"
#include "StyleRule.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -101,24 +101,25 @@ void CSSStyleRule::setSelectorText(const String& selectorText)
CSSStyleSheet::RuleMutationScope mutationScope(this);
- String oldSelectorText = this->selectorText();
m_styleRule->wrapperAdoptSelectorList(selectorList);
if (hasCachedSelectorText()) {
- ASSERT(selectorTextCache().contains(this));
- selectorTextCache().set(this, generateSelectorText());
+ selectorTextCache().remove(this);
+ setHasCachedSelectorText(false);
}
}
String CSSStyleRule::cssText() const
{
- String result = selectorText();
-
- result += " { ";
- result += m_styleRule->properties()->asText();
- result += "}";
-
- return result;
+ StringBuilder result;
+ result.append(selectorText());
+ result.appendLiteral(" { ");
+ String decls = m_styleRule->properties()->asText();
+ result.append(decls);
+ if (!decls.isEmpty())
+ result.append(' ');
+ result.append('}');
+ return result.toString();
}
void CSSStyleRule::reattach(StyleRule* rule)
@@ -130,7 +131,7 @@ void CSSStyleRule::reattach(StyleRule* rule)
void CSSStyleRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_styleRule);
info.addInstrumentedMember(m_propertiesCSSOMWrapper);
diff --git a/Source/WebCore/css/CSSStyleSheet.cpp b/Source/WebCore/css/CSSStyleSheet.cpp
index ec0ebe6fa..90a2ff94a 100644
--- a/Source/WebCore/css/CSSStyleSheet.cpp
+++ b/Source/WebCore/css/CSSStyleSheet.cpp
@@ -32,12 +32,14 @@
#include "ExceptionCode.h"
#include "HTMLNames.h"
#include "MediaList.h"
-#include "MemoryInstrumentation.h"
#include "Node.h"
#include "SVGNames.h"
#include "SecurityOrigin.h"
#include "StyleRule.h"
+#include "StyleRuleImport.h"
#include "StyleSheetContents.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -56,7 +58,7 @@ private:
virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_styleSheet);
}
@@ -149,7 +151,7 @@ void CSSStyleSheet::willMutateRules()
m_contents->setMutable();
// Any existing CSSOM wrappers need to be connected to the copied child rules.
- reattachChildRuleCSSOMWrappers();
+ reattachCSSOMWrappers();
}
void CSSStyleSheet::didMutateRules()
@@ -168,8 +170,11 @@ void CSSStyleSheet::didMutate()
owner->styleResolverChanged(DeferRecalcStyle);
}
-void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
+void CSSStyleSheet::reattachCSSOMWrappers()
{
+ if (m_ownerRule)
+ m_ownerRule->reattachStyleSheetContents();
+
for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
if (!m_childRuleCSSOMWrappers[i])
continue;
@@ -179,7 +184,7 @@ void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
void CSSStyleSheet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_contents);
info.addInstrumentedMember(m_title);
info.addInstrumentedMember(m_mediaQueries);
@@ -282,7 +287,10 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
if (!success) {
ec = HIERARCHY_REQUEST_ERR;
return 0;
- }
+ }
+ if (rule->isImportRule())
+ static_cast<StyleRuleImport*>(rule.get())->requestStyleSheet(rootStyleSheet(), m_contents->parserContext());
+
if (!m_childRuleCSSOMWrappers.isEmpty())
m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>());
@@ -311,7 +319,14 @@ void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec)
int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionCode& ec)
{
- insertRule(selector + " { " + style + " }", index, ec);
+ StringBuilder text;
+ text.append(selector);
+ text.appendLiteral(" { ");
+ text.append(style);
+ if (!style.isEmpty())
+ text.append(' ');
+ text.append('}');
+ insertRule(text.toString(), index, ec);
// As per Microsoft documentation, always return -1.
return -1;
@@ -362,11 +377,17 @@ CSSStyleSheet* CSSStyleSheet::parentStyleSheet() const
return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
}
-Document* CSSStyleSheet::ownerDocument() const
+CSSStyleSheet* CSSStyleSheet::rootStyleSheet() const
{
const CSSStyleSheet* root = this;
while (root->parentStyleSheet())
root = root->parentStyleSheet();
+ return const_cast<CSSStyleSheet*>(root);
+}
+
+Document* CSSStyleSheet::ownerDocument() const
+{
+ const CSSStyleSheet* root = rootStyleSheet();
return root->ownerNode() ? root->ownerNode()->document() : 0;
}
diff --git a/Source/WebCore/css/CSSStyleSheet.h b/Source/WebCore/css/CSSStyleSheet.h
index 44915140c..2b3c5d4b1 100644
--- a/Source/WebCore/css/CSSStyleSheet.h
+++ b/Source/WebCore/css/CSSStyleSheet.h
@@ -81,6 +81,7 @@ public:
virtual bool isLoading() const OVERRIDE;
void clearOwnerRule() { m_ownerRule = 0; }
+ CSSStyleSheet* rootStyleSheet() const;
Document* ownerDocument() const;
MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
void setMediaQueries(PassRefPtr<MediaQuerySet>);
@@ -102,7 +103,6 @@ public:
void didMutate();
void clearChildRuleCSSOMWrappers();
- void reattachChildRuleCSSOMWrappers();
StyleSheetContents* contents() const { return m_contents.get(); }
@@ -116,6 +116,7 @@ private:
virtual String type() const { return "text/css"; }
bool canAccessRules() const;
+ void reattachCSSOMWrappers();
RefPtr<StyleSheetContents> m_contents;
bool m_isInlineStylesheet;
diff --git a/Source/WebCore/css/CSSTimingFunctionValue.cpp b/Source/WebCore/css/CSSTimingFunctionValue.cpp
index 9abb19e69..e1bb1d126 100644
--- a/Source/WebCore/css/CSSTimingFunctionValue.cpp
+++ b/Source/WebCore/css/CSSTimingFunctionValue.cpp
@@ -26,8 +26,8 @@
#include "config.h"
#include "CSSTimingFunctionValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -38,41 +38,31 @@ String CSSLinearTimingFunctionValue::customCssText() const
void CSSLinearTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
String CSSCubicBezierTimingFunctionValue::customCssText() const
{
- String text("cubic-bezier(");
- text += String::number(m_x1);
- text += ", ";
- text += String::number(m_y1);
- text += ", ";
- text += String::number(m_x2);
- text += ", ";
- text += String::number(m_y2);
- text += ")";
- return text;
+ return "cubic-bezier("
+ + String::number(m_x1) + ", "
+ + String::number(m_y1) + ", "
+ + String::number(m_x2) + ", "
+ + String::number(m_y2) + ")";
}
void CSSCubicBezierTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
String CSSStepsTimingFunctionValue::customCssText() const
{
- String text("steps(");
- text += String::number(m_steps);
- text += ", ";
- text += m_stepAtStart ? "start" : "end";
- text += ")";
- return text;
+ return "steps(" + String::number(m_steps) + ", " + (m_stepAtStart ? "start" : "end") + ')';
}
void CSSStepsTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
} // namespace WebCore
diff --git a/Source/WebCore/css/CSSToStyleMap.cpp b/Source/WebCore/css/CSSToStyleMap.cpp
index e154cecd3..1e08334e2 100644
--- a/Source/WebCore/css/CSSToStyleMap.cpp
+++ b/Source/WebCore/css/CSSToStyleMap.cpp
@@ -361,7 +361,7 @@ void CSSToStyleMap::mapAnimationIterationCount(Animation* animation, CSSValue* v
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
if (primitiveValue->getIdent() == CSSValueInfinite)
- animation->setIterationCount(-1);
+ animation->setIterationCount(Animation::IterationCountInfinite);
else
animation->setIterationCount(primitiveValue->getFloatValue());
}
diff --git a/Source/WebCore/css/CSSUnicodeRangeValue.cpp b/Source/WebCore/css/CSSUnicodeRangeValue.cpp
index abd806df4..34d63b6bb 100644
--- a/Source/WebCore/css/CSSUnicodeRangeValue.cpp
+++ b/Source/WebCore/css/CSSUnicodeRangeValue.cpp
@@ -26,8 +26,8 @@
#include "config.h"
#include "CSSUnicodeRangeValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -40,7 +40,7 @@ String CSSUnicodeRangeValue::customCssText() const
void CSSUnicodeRangeValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
}
diff --git a/Source/WebCore/css/CSSUnknownRule.h b/Source/WebCore/css/CSSUnknownRule.h
index ab68aef9e..30d4c5ad6 100644
--- a/Source/WebCore/css/CSSUnknownRule.h
+++ b/Source/WebCore/css/CSSUnknownRule.h
@@ -23,7 +23,7 @@
#define CSSUnknownRule_h
#include "CSSRule.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
namespace WebCore {
@@ -33,7 +33,7 @@ public:
void reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
}
};
diff --git a/Source/WebCore/css/CSSValue.cpp b/Source/WebCore/css/CSSValue.cpp
index ee0a18cf5..f5ef1ef41 100644
--- a/Source/WebCore/css/CSSValue.cpp
+++ b/Source/WebCore/css/CSSValue.cpp
@@ -52,10 +52,11 @@
#endif
#include "FontValue.h"
#include "FontFeatureValue.h"
-#include "MemoryInstrumentation.h"
#include "ShadowValue.h"
#include "SVGColor.h"
#include "SVGPaint.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include "WebKitCSSArrayFunctionValue.h"
#include "WebKitCSSFilterValue.h"
#include "WebKitCSSMixFunctionValue.h"
#include "WebKitCSSShaderValue.h"
@@ -81,7 +82,7 @@ public:
void reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_cssText);
}
@@ -229,6 +230,9 @@ void CSSValue::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
static_cast<const CSSCalcValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
return;
#if ENABLE(CSS_FILTERS) && ENABLE(CSS_SHADERS)
+ case WebKitCSSArrayFunctionValueClass:
+ static_cast<const WebKitCSSArrayFunctionValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+ return;
case WebKitCSSMixFunctionValueClass:
static_cast<const WebKitCSSMixFunctionValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
return;
@@ -339,6 +343,8 @@ String CSSValue::cssText() const
case WebKitCSSFilterClass:
return static_cast<const WebKitCSSFilterValue*>(this)->customCssText();
#if ENABLE(CSS_SHADERS)
+ case WebKitCSSArrayFunctionValueClass:
+ return static_cast<const WebKitCSSArrayFunctionValue*>(this)->customCssText();
case WebKitCSSMixFunctionValueClass:
return static_cast<const WebKitCSSMixFunctionValue*>(this)->customCssText();
case WebKitCSSShaderClass:
@@ -473,6 +479,9 @@ void CSSValue::destroy()
delete static_cast<WebKitCSSFilterValue*>(this);
return;
#if ENABLE(CSS_SHADERS)
+ case WebKitCSSArrayFunctionValueClass:
+ delete static_cast<WebKitCSSArrayFunctionValue*>(this);
+ return;
case WebKitCSSMixFunctionValueClass:
delete static_cast<WebKitCSSMixFunctionValue*>(this);
return;
@@ -515,6 +524,8 @@ PassRefPtr<CSSValue> CSSValue::cloneForCSSOM() const
case WebKitCSSFilterClass:
return static_cast<const WebKitCSSFilterValue*>(this)->cloneForCSSOM();
#if ENABLE(CSS_SHADERS)
+ case WebKitCSSArrayFunctionValueClass:
+ return static_cast<const WebKitCSSArrayFunctionValue*>(this)->cloneForCSSOM();
case WebKitCSSMixFunctionValueClass:
return static_cast<const WebKitCSSMixFunctionValue*>(this)->cloneForCSSOM();
#endif
diff --git a/Source/WebCore/css/CSSValue.h b/Source/WebCore/css/CSSValue.h
index 63b8a2586..25a0095d9 100644
--- a/Source/WebCore/css/CSSValue.h
+++ b/Source/WebCore/css/CSSValue.h
@@ -66,6 +66,9 @@ public:
bool isPrimitiveValue() const { return m_classType == PrimitiveClass; }
bool isValueList() const { return m_classType >= ValueListClass; }
+
+ bool isBaseValueList() const { return m_classType == ValueListClass; }
+
bool isAspectRatioValue() const { return m_classType == AspectRatioClass; }
bool isBorderImageSliceValue() const { return m_classType == BorderImageSliceClass; }
@@ -92,6 +95,7 @@ public:
#if ENABLE(CSS_FILTERS)
bool isWebKitCSSFilterValue() const { return m_classType == WebKitCSSFilterClass; }
#if ENABLE(CSS_SHADERS)
+ bool isWebKitCSSArrayFunctionValue() const { return m_classType == WebKitCSSArrayFunctionValueClass; }
bool isWebKitCSSMixFunctionValue() const { return m_classType == WebKitCSSMixFunctionValueClass; }
bool isWebKitCSSShaderValue() const { return m_classType == WebKitCSSShaderClass; }
#endif
@@ -180,6 +184,7 @@ protected:
#if ENABLE(CSS_FILTERS)
WebKitCSSFilterClass,
#if ENABLE(CSS_SHADERS)
+ WebKitCSSArrayFunctionValueClass,
WebKitCSSMixFunctionValueClass,
#endif
#endif
diff --git a/Source/WebCore/css/CSSValueKeywords.in b/Source/WebCore/css/CSSValueKeywords.in
index 8205cff46..eed910074 100644
--- a/Source/WebCore/css/CSSValueKeywords.in
+++ b/Source/WebCore/css/CSSValueKeywords.in
@@ -331,10 +331,8 @@ table-cell
table-caption
-webkit-box
-webkit-inline-box
-#if defined(ENABLE_CSS3_FLEXBOX) && ENABLE_CSS3_FLEXBOX
-webkit-flex
-webkit-inline-flex
-#endif
-webkit-grid
-webkit-inline-grid
//none
@@ -492,7 +490,6 @@ block-axis
single
multiple
-#if defined(ENABLE_CSS3_FLEXBOX) && ENABLE_CSS3_FLEXBOX
// CSS_PROP_ALIGN_CONTENT
flex-start
flex-end
@@ -524,8 +521,6 @@ column-reverse
// wrap
wrap-reverse
-#endif
-
// CSS_PROP_MARQUEE_DIRECTION
forwards
backwards
diff --git a/Source/WebCore/css/CSSValueList.cpp b/Source/WebCore/css/CSSValueList.cpp
index b120fa242..21e4fa703 100644
--- a/Source/WebCore/css/CSSValueList.cpp
+++ b/Source/WebCore/css/CSSValueList.cpp
@@ -22,8 +22,7 @@
#include "CSSValueList.h"
#include "CSSParserValues.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/text/StringBuilder.h>
@@ -189,7 +188,7 @@ PassRefPtr<CSSValueList> CSSValueList::cloneForCSSOM() const
void CSSValueList::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedVector(m_values);
}
diff --git a/Source/WebCore/css/CSSVariableValue.h b/Source/WebCore/css/CSSVariableValue.h
index 3020e1e1b..e32e48f62 100644
--- a/Source/WebCore/css/CSSVariableValue.h
+++ b/Source/WebCore/css/CSSVariableValue.h
@@ -34,7 +34,7 @@
#include "CSSParserValues.h"
#include "CSSPropertyNames.h"
#include "CSSValue.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
namespace WebCore {
@@ -50,7 +50,7 @@ public:
void reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_name);
info.addInstrumentedMember(m_value);
}
diff --git a/Source/WebCore/css/Counter.h b/Source/WebCore/css/Counter.h
index bd3a078a9..51fa71031 100644
--- a/Source/WebCore/css/Counter.h
+++ b/Source/WebCore/css/Counter.h
@@ -22,7 +22,7 @@
#define Counter_h
#include "CSSPrimitiveValue.h"
-#include "PlatformString.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/FontFeatureValue.cpp b/Source/WebCore/css/FontFeatureValue.cpp
index 413eaa4a2..948d22b64 100644
--- a/Source/WebCore/css/FontFeatureValue.cpp
+++ b/Source/WebCore/css/FontFeatureValue.cpp
@@ -28,7 +28,7 @@
#include "CSSParser.h"
#include "CSSValueKeywords.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -43,16 +43,16 @@ FontFeatureValue::FontFeatureValue(const String& tag, int value)
String FontFeatureValue::customCssText() const
{
StringBuilder builder;
- builder.append("'");
+ builder.append('\'');
builder.append(m_tag);
- builder.append("' ");
- builder.append(String::number(m_value));
+ builder.appendLiteral("' ");
+ builder.appendNumber(m_value);
return builder.toString();
}
void FontFeatureValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_tag);
}
diff --git a/Source/WebCore/css/FontFeatureValue.h b/Source/WebCore/css/FontFeatureValue.h
index 28d89f423..fcab81504 100644
--- a/Source/WebCore/css/FontFeatureValue.h
+++ b/Source/WebCore/css/FontFeatureValue.h
@@ -27,7 +27,7 @@
#define FontFeatureValue_h
#include "CSSValue.h"
-#include "PlatformString.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/FontValue.cpp b/Source/WebCore/css/FontValue.cpp
index 4f8742c70..acb25d24b 100644
--- a/Source/WebCore/css/FontValue.cpp
+++ b/Source/WebCore/css/FontValue.cpp
@@ -22,8 +22,7 @@
#include "CSSValueList.h"
#include "CSSPrimitiveValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -68,7 +67,7 @@ String FontValue::customCssText() const
void FontValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(style);
info.addInstrumentedMember(variant);
info.addInstrumentedMember(weight);
diff --git a/Source/WebCore/css/LengthFunctions.cpp b/Source/WebCore/css/LengthFunctions.cpp
index e6b2abff9..9772e5edb 100644
--- a/Source/WebCore/css/LengthFunctions.cpp
+++ b/Source/WebCore/css/LengthFunctions.cpp
@@ -24,6 +24,7 @@
#include "config.h"
#include "LengthFunctions.h"
+#include "LayoutTypes.h"
#include "Length.h"
#include "RenderView.h"
diff --git a/Source/WebCore/css/MediaList.cpp b/Source/WebCore/css/MediaList.cpp
index 5ba7341eb..773ceebb5 100644
--- a/Source/WebCore/css/MediaList.cpp
+++ b/Source/WebCore/css/MediaList.cpp
@@ -26,7 +26,8 @@
#include "ExceptionCode.h"
#include "MediaQuery.h"
#include "MediaQueryExp.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -198,22 +199,22 @@ void MediaQuerySet::addMediaQuery(PassOwnPtr<MediaQuery> mediaQuery)
String MediaQuerySet::mediaText() const
{
- String text("");
+ StringBuilder text;
bool first = true;
for (size_t i = 0; i < m_queries.size(); ++i) {
if (!first)
- text += ", ";
+ text.appendLiteral(", ");
else
first = false;
- text += m_queries[i]->cssText();
+ text.append(m_queries[i]->cssText());
}
- return text;
+ return text.toString();
}
void MediaQuerySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedVector(m_queries);
}
@@ -291,7 +292,7 @@ void MediaList::reattach(MediaQuerySet* mediaQueries)
void MediaList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_mediaQueries);
}
diff --git a/Source/WebCore/css/MediaQuery.cpp b/Source/WebCore/css/MediaQuery.cpp
index 44c32c142..dda150fb5 100644
--- a/Source/WebCore/css/MediaQuery.cpp
+++ b/Source/WebCore/css/MediaQuery.cpp
@@ -30,7 +30,7 @@
#include "MediaQuery.h"
#include "MediaQueryExp.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/NonCopyingSort.h>
#include <wtf/text/StringBuilder.h>
@@ -136,7 +136,7 @@ String MediaQuery::cssText() const
void MediaQuery::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_mediaType);
info.addInstrumentedVectorPtr(m_expressions);
info.addInstrumentedMember(m_serializationCache);
diff --git a/Source/WebCore/css/MediaQuery.h b/Source/WebCore/css/MediaQuery.h
index f37c76492..3d00c5be1 100644
--- a/Source/WebCore/css/MediaQuery.h
+++ b/Source/WebCore/css/MediaQuery.h
@@ -29,10 +29,10 @@
#ifndef MediaQuery_h
#define MediaQuery_h
-#include "PlatformString.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
class MediaQueryExp;
diff --git a/Source/WebCore/css/MediaQueryEvaluator.h b/Source/WebCore/css/MediaQueryEvaluator.h
index 9eee0f020..71de6eda1 100644
--- a/Source/WebCore/css/MediaQueryEvaluator.h
+++ b/Source/WebCore/css/MediaQueryEvaluator.h
@@ -28,7 +28,7 @@
#ifndef MediaQueryEvaluator_h
#define MediaQueryEvaluator_h
-#include "PlatformString.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
class Frame;
diff --git a/Source/WebCore/css/MediaQueryExp.cpp b/Source/WebCore/css/MediaQueryExp.cpp
index 4b91997d7..695ce0ba6 100644
--- a/Source/WebCore/css/MediaQueryExp.cpp
+++ b/Source/WebCore/css/MediaQueryExp.cpp
@@ -32,7 +32,7 @@
#include "CSSParser.h"
#include "CSSPrimitiveValue.h"
#include "CSSValueList.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -111,7 +111,7 @@ String MediaQueryExp::serialize() const
void MediaQueryExp::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_mediaFeature);
info.addInstrumentedMember(m_serializationCache);
info.addInstrumentedMember(m_value);
diff --git a/Source/WebCore/css/MediaQueryListListener.h b/Source/WebCore/css/MediaQueryListListener.h
index da167dbfd..930e8eef7 100644
--- a/Source/WebCore/css/MediaQueryListListener.h
+++ b/Source/WebCore/css/MediaQueryListListener.h
@@ -20,11 +20,10 @@
#ifndef MediaQueryListListener_h
#define MediaQueryListListener_h
-#include "PlatformString.h"
#include "ScriptState.h"
#include "ScriptValue.h"
-
#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp b/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
index 5fc2d3803..6093cf814 100644
--- a/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
+++ b/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
@@ -26,12 +26,12 @@
#include "CSSStyleSheet.h"
#include "HTMLNames.h"
#include "InspectorInstrumentation.h"
-#include "MemoryInstrumentation.h"
#include "MutationObserverInterestGroup.h"
#include "MutationRecord.h"
#include "StylePropertySet.h"
#include "StyledElement.h"
#include "UndoManager.h"
+#include "WebCoreMemoryInstrumentation.h"
using namespace std;
@@ -171,7 +171,7 @@ void PropertySetCSSStyleDeclaration::deref()
void PropertySetCSSStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_propertySet);
if (m_cssomCSSValueClones)
info.addInstrumentedMapEntries(*m_cssomCSSValueClones);
@@ -430,14 +430,14 @@ void StyleRuleCSSStyleDeclaration::reattach(StylePropertySet* propertySet)
void StyleRuleCSSStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
PropertySetCSSStyleDeclaration::reportMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_parentRule);
}
void InlineCSSStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
PropertySetCSSStyleDeclaration::reportMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_parentElement);
}
diff --git a/Source/WebCore/css/ShadowValue.cpp b/Source/WebCore/css/ShadowValue.cpp
index 5db003651..90ae152fb 100644
--- a/Source/WebCore/css/ShadowValue.cpp
+++ b/Source/WebCore/css/ShadowValue.cpp
@@ -21,8 +21,9 @@
#include "ShadowValue.h"
#include "CSSPrimitiveValue.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -45,42 +46,42 @@ ShadowValue::ShadowValue(PassRefPtr<CSSPrimitiveValue> _x,
String ShadowValue::customCssText() const
{
- String text("");
+ StringBuilder text;
if (color)
- text += color->cssText();
+ text.append(color->cssText());
if (x) {
if (!text.isEmpty())
- text += " ";
- text += x->cssText();
+ text.append(' ');
+ text.append(x->cssText());
}
if (y) {
if (!text.isEmpty())
- text += " ";
- text += y->cssText();
+ text.append(' ');
+ text.append(y->cssText());
}
if (blur) {
if (!text.isEmpty())
- text += " ";
- text += blur->cssText();
+ text.append(' ');
+ text.append(blur->cssText());
}
if (spread) {
if (!text.isEmpty())
- text += " ";
- text += spread->cssText();
+ text.append(' ');
+ text.append(spread->cssText());
}
if (style) {
if (!text.isEmpty())
- text += " ";
- text += style->cssText();
+ text.append(' ');
+ text.append(style->cssText());
}
- return text;
+ return text.toString();
}
void ShadowValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(x);
info.addInstrumentedMember(y);
info.addInstrumentedMember(blur);
diff --git a/Source/WebCore/css/StyleBuilder.cpp b/Source/WebCore/css/StyleBuilder.cpp
index 486a4dbb8..ed0a15fbc 100644
--- a/Source/WebCore/css/StyleBuilder.cpp
+++ b/Source/WebCore/css/StyleBuilder.cpp
@@ -25,6 +25,8 @@
#include "config.h"
#include "StyleBuilder.h"
+#include "BasicShapeFunctions.h"
+#include "BasicShapes.h"
#include "CSSAspectRatioValue.h"
#include "CSSCalculationValue.h"
#include "CSSCursorImageValue.h"
@@ -44,11 +46,6 @@
#include <wtf/StdLibExtras.h>
#include <wtf/UnusedParam.h>
-#if ENABLE(CSS_EXCLUSIONS)
-#include "WrapShapeFunctions.h"
-#include "WrapShapes.h"
-#endif
-
using namespace std;
namespace WebCore {
@@ -1016,20 +1013,9 @@ public:
for (Iterator it = parentMap.begin(); it != end; ++it) {
CounterDirectives& directives = map.add(it->first, CounterDirectives()).iterator->second;
if (counterBehavior == Reset) {
- directives.m_reset = it->second.m_reset;
- directives.m_resetValue = it->second.m_resetValue;
+ directives.inheritReset(it->second);
} else {
- // Inheriting a counter-increment means taking the parent's current value for the counter
- // and adding it to itself.
- directives.m_increment = it->second.m_increment;
- directives.m_incrementValue = 0;
- if (directives.m_increment) {
- float incrementValue = directives.m_incrementValue;
- directives.m_incrementValue = clampToInteger(incrementValue + it->second.m_incrementValue);
- } else {
- directives.m_increment = true;
- directives.m_incrementValue = it->second.m_incrementValue;
- }
+ directives.inheritIncrement(it->second);
}
}
}
@@ -1046,9 +1032,9 @@ public:
Iterator end = map.end();
for (Iterator it = map.begin(); it != end; ++it)
if (counterBehavior == Reset)
- it->second.m_reset = false;
+ it->second.clearReset();
else
- it->second.m_increment = false;
+ it->second.clearIncrement();
int length = list ? list->length() : 0;
for (int i = 0; i < length; ++i) {
@@ -1062,20 +1048,12 @@ public:
AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue();
int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue();
- CounterDirectives& directives = map.add(identifier.impl(), CounterDirectives()).iterator->second;
+ CounterDirectives& directives = map.add(identifier, CounterDirectives()).iterator->second;
if (counterBehavior == Reset) {
- directives.m_reset = true;
- directives.m_resetValue = value;
+ directives.setResetValue(value);
} else {
- if (directives.m_increment) {
- float incrementValue = directives.m_incrementValue;
- directives.m_incrementValue = clampToInteger(incrementValue + value);
- } else {
- directives.m_increment = true;
- directives.m_incrementValue = value;
- }
+ directives.addIncrementValue(value);
}
-
}
}
static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &emptyFunction, &applyValue); }
@@ -1704,11 +1682,34 @@ public:
}
};
+template <BasicShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<BasicShape>), BasicShape* (*initialFunction)()>
+class ApplyPropertyClipPath {
+public:
+ static void setValue(RenderStyle* style, PassRefPtr<BasicShape> value) { (style->*setterFunction)(value); }
+ static void applyValue(StyleResolver* styleResolver, CSSValue* value)
+ {
+ if (value->isPrimitiveValue()) {
+ CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+ if (primitiveValue->getIdent() == CSSValueNone)
+ setValue(styleResolver->style(), 0);
+ else if (primitiveValue->isShape()) {
+ RefPtr<BasicShape> clipPathShape = basicShapeForValue(styleResolver, primitiveValue->getShapeValue());
+ setValue(styleResolver->style(), clipPathShape.release());
+ }
+ }
+ }
+ static PropertyHandler createHandler()
+ {
+ PropertyHandler handler = ApplyPropertyDefaultBase<BasicShape*, getterFunction, PassRefPtr<BasicShape>, setterFunction, BasicShape*, initialFunction>::createHandler();
+ return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
+ }
+};
+
#if ENABLE(CSS_EXCLUSIONS)
-template <WrapShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<WrapShape>), WrapShape* (*initialFunction)()>
+template <BasicShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<BasicShape>), BasicShape* (*initialFunction)()>
class ApplyPropertyWrapShape {
public:
- static void setValue(RenderStyle* style, PassRefPtr<WrapShape> value) { (style->*setterFunction)(value); }
+ static void setValue(RenderStyle* style, PassRefPtr<BasicShape> value) { (style->*setterFunction)(value); }
static void applyValue(StyleResolver* styleResolver, CSSValue* value)
{
if (value->isPrimitiveValue()) {
@@ -1716,14 +1717,14 @@ public:
if (primitiveValue->getIdent() == CSSValueAuto)
setValue(styleResolver->style(), 0);
else if (primitiveValue->isShape()) {
- RefPtr<WrapShape> wrapShape = wrapShapeForValue(styleResolver, primitiveValue->getShapeValue());
+ RefPtr<BasicShape> wrapShape = basicShapeForValue(styleResolver, primitiveValue->getShapeValue());
setValue(styleResolver->style(), wrapShape.release());
}
}
}
static PropertyHandler createHandler()
{
- PropertyHandler handler = ApplyPropertyDefaultBase<WrapShape*, getterFunction, PassRefPtr<WrapShape>, setterFunction, WrapShape*, initialFunction>::createHandler();
+ PropertyHandler handler = ApplyPropertyDefaultBase<BasicShape*, getterFunction, PassRefPtr<BasicShape>, setterFunction, BasicShape*, initialFunction>::createHandler();
return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
}
};
@@ -1883,6 +1884,7 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyOutlineStyle, ApplyPropertyOutlineStyle::createHandler());
setPropertyHandler(CSSPropertyOutlineWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth, &RenderStyle::initialOutlineWidth, NormalDisabled, ThicknessEnabled>::createHandler());
setPropertyHandler(CSSPropertyOverflow, ApplyPropertyExpanding<ExpandValue, CSSPropertyOverflowX, CSSPropertyOverflowY>::createHandler());
+ setPropertyHandler(CSSPropertyOverflowWrap, ApplyPropertyDefault<EOverflowWrap, &RenderStyle::overflowWrap, EOverflowWrap, &RenderStyle::setOverflowWrap, EOverflowWrap, &RenderStyle::initialOverflowWrap>::createHandler());
setPropertyHandler(CSSPropertyOverflowX, ApplyPropertyDefault<EOverflow, &RenderStyle::overflowX, EOverflow, &RenderStyle::setOverflowX, EOverflow, &RenderStyle::initialOverflowX>::createHandler());
setPropertyHandler(CSSPropertyOverflowY, ApplyPropertyDefault<EOverflow, &RenderStyle::overflowY, EOverflow, &RenderStyle::setOverflowY, EOverflow, &RenderStyle::initialOverflowY>::createHandler());
setPropertyHandler(CSSPropertyPadding, ApplyPropertyExpanding<SuppressValue, CSSPropertyPaddingTop, CSSPropertyPaddingRight, CSSPropertyPaddingBottom, CSSPropertyPaddingLeft>::createHandler());
@@ -1929,6 +1931,9 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
setPropertyHandler(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin);
setPropertyHandler(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize);
+#if ENABLE(CSS_COMPOSITING)
+ setPropertyHandler(CSSPropertyWebkitBlendMode, ApplyPropertyDefault<BlendMode, &RenderStyle::blendMode, BlendMode, &RenderStyle::setBlendMode, BlendMode, &RenderStyle::initialBlendMode>::createHandler());
+#endif
setPropertyHandler(CSSPropertyWebkitBorderFit, ApplyPropertyDefault<EBorderFit, &RenderStyle::borderFit, EBorderFit, &RenderStyle::setBorderFit, EBorderFit, &RenderStyle::initialBorderFit>::createHandler());
setPropertyHandler(CSSPropertyWebkitBorderHorizontalSpacing, ApplyPropertyComputeLength<short, &RenderStyle::horizontalBorderSpacing, &RenderStyle::setHorizontalBorderSpacing, &RenderStyle::initialHorizontalBorderSpacing>::createHandler());
setPropertyHandler(CSSPropertyWebkitBorderImage, ApplyPropertyBorderImage<Image, CSSPropertyWebkitBorderImage, &RenderStyle::borderImage, &RenderStyle::setBorderImage>::createHandler());
@@ -1959,7 +1964,6 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyWebkitColumnSpan, ApplyPropertyDefault<ColumnSpan, &RenderStyle::columnSpan, ColumnSpan, &RenderStyle::setColumnSpan, ColumnSpan, &RenderStyle::initialColumnSpan>::createHandler());
setPropertyHandler(CSSPropertyWebkitColumnRuleStyle, ApplyPropertyDefault<EBorderStyle, &RenderStyle::columnRuleStyle, EBorderStyle, &RenderStyle::setColumnRuleStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::createHandler());
setPropertyHandler(CSSPropertyWebkitColumnWidth, ApplyPropertyAuto<float, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth, &RenderStyle::hasAutoColumnWidth, &RenderStyle::setHasAutoColumnWidth, ComputeLength>::createHandler());
-#if ENABLE(CSS3_FLEXBOX)
setPropertyHandler(CSSPropertyWebkitAlignContent, ApplyPropertyDefault<EAlignContent, &RenderStyle::alignContent, EAlignContent, &RenderStyle::setAlignContent, EAlignContent, &RenderStyle::initialAlignContent>::createHandler());
setPropertyHandler(CSSPropertyWebkitAlignItems, ApplyPropertyDefault<EAlignItems, &RenderStyle::alignItems, EAlignItems, &RenderStyle::setAlignItems, EAlignItems, &RenderStyle::initialAlignItems>::createHandler());
setPropertyHandler(CSSPropertyWebkitAlignSelf, ApplyPropertyDefault<EAlignItems, &RenderStyle::alignSelf, EAlignItems, &RenderStyle::setAlignSelf, EAlignItems, &RenderStyle::initialAlignSelf>::createHandler());
@@ -1972,7 +1976,6 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault<EFlexWrap, &RenderStyle::flexWrap, EFlexWrap, &RenderStyle::setFlexWrap, EFlexWrap, &RenderStyle::initialFlexWrap>::createHandler());
setPropertyHandler(CSSPropertyWebkitJustifyContent, ApplyPropertyDefault<EJustifyContent, &RenderStyle::justifyContent, EJustifyContent, &RenderStyle::setJustifyContent, EJustifyContent, &RenderStyle::initialJustifyContent>::createHandler());
setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<int, &RenderStyle::order, int, &RenderStyle::setOrder, int, &RenderStyle::initialOrder>::createHandler());
-#endif
#if ENABLE(CSS_REGIONS)
setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString<MapNoneToNull, &RenderStyle::regionThread, &RenderStyle::setRegionThread, &RenderStyle::initialRegionThread>::createHandler());
setPropertyHandler(CSSPropertyWebkitFlowInto, ApplyPropertyString<MapNoneToNull, &RenderStyle::flowThread, &RenderStyle::setFlowThread, &RenderStyle::initialFlowThread>::createHandler());
@@ -2047,6 +2050,8 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyWebkitUserDrag, ApplyPropertyDefault<EUserDrag, &RenderStyle::userDrag, EUserDrag, &RenderStyle::setUserDrag, EUserDrag, &RenderStyle::initialUserDrag>::createHandler());
setPropertyHandler(CSSPropertyWebkitUserModify, ApplyPropertyDefault<EUserModify, &RenderStyle::userModify, EUserModify, &RenderStyle::setUserModify, EUserModify, &RenderStyle::initialUserModify>::createHandler());
setPropertyHandler(CSSPropertyWebkitUserSelect, ApplyPropertyDefault<EUserSelect, &RenderStyle::userSelect, EUserSelect, &RenderStyle::setUserSelect, EUserSelect, &RenderStyle::initialUserSelect>::createHandler());
+ setPropertyHandler(CSSPropertyWebkitClipPath, ApplyPropertyClipPath<&RenderStyle::clipPath, &RenderStyle::setClipPath, &RenderStyle::initialClipPath>::createHandler());
+
#if ENABLE(CSS_EXCLUSIONS)
setPropertyHandler(CSSPropertyWebkitWrap, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitWrapFlow, CSSPropertyWebkitWrapMargin, CSSPropertyWebkitWrapPadding>::createHandler());
setPropertyHandler(CSSPropertyWebkitWrapFlow, ApplyPropertyDefault<WrapFlow, &RenderStyle::wrapFlow, WrapFlow, &RenderStyle::setWrapFlow, WrapFlow, &RenderStyle::initialWrapFlow>::createHandler());
@@ -2061,12 +2066,10 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyWidth, ApplyPropertyLength<&RenderStyle::width, &RenderStyle::setWidth, &RenderStyle::initialSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicEnabled, NoneDisabled, UndefinedDisabled>::createHandler());
setPropertyHandler(CSSPropertyWordBreak, ApplyPropertyDefault<EWordBreak, &RenderStyle::wordBreak, EWordBreak, &RenderStyle::setWordBreak, EWordBreak, &RenderStyle::initialWordBreak>::createHandler());
setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyComputeLength<int, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing, &RenderStyle::initialLetterWordSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler());
- setPropertyHandler(CSSPropertyWordWrap, ApplyPropertyDefault<EWordWrap, &RenderStyle::wordWrap, EWordWrap, &RenderStyle::setWordWrap, EWordWrap, &RenderStyle::initialWordWrap>::createHandler());
+ // UAs must treat 'word-wrap' as an alternate name for the 'overflow-wrap' property. So using the same handlers.
+ setPropertyHandler(CSSPropertyWordWrap, ApplyPropertyDefault<EOverflowWrap, &RenderStyle::overflowWrap, EOverflowWrap, &RenderStyle::setOverflowWrap, EOverflowWrap, &RenderStyle::initialOverflowWrap>::createHandler());
setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
setPropertyHandler(CSSPropertyZoom, ApplyPropertyZoom::createHandler());
-#if ENABLE(CSS_COMPOSITING)
- setPropertyHandler(CSSPropertyWebkitBlendMode, ApplyPropertyDefault<BlendMode, &RenderStyle::blendMode, BlendMode, &RenderStyle::setBlendMode, BlendMode, &RenderStyle::initialBlendMode>::createHandler());
-#endif
}
diff --git a/Source/WebCore/css/StyleMedia.h b/Source/WebCore/css/StyleMedia.h
index 032929e08..330fe82ba 100644
--- a/Source/WebCore/css/StyleMedia.h
+++ b/Source/WebCore/css/StyleMedia.h
@@ -28,8 +28,8 @@
#define StyleMedia_h
#include "DOMWindowProperty.h"
-#include "PlatformString.h"
#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/StylePropertySet.cpp b/Source/WebCore/css/StylePropertySet.cpp
index adc7fc85c..d0f0fab2a 100644
--- a/Source/WebCore/css/StylePropertySet.cpp
+++ b/Source/WebCore/css/StylePropertySet.cpp
@@ -19,6 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
+#define WTF_DEPRECATED_STRING_OPERATORS
+
#include "config.h"
#include "StylePropertySet.h"
@@ -61,6 +63,13 @@ PassRefPtr<StylePropertySet> StylePropertySet::createImmutable(const CSSProperty
return adoptRef(new (slot) StylePropertySet(properties, count, cssParserMode, /* makeMutable */ false));
}
+PassRefPtr<StylePropertySet> StylePropertySet::immutableCopyIfNeeded() const
+{
+ if (!isMutable())
+ return const_cast<StylePropertySet*>(this);
+ return createImmutable(m_mutablePropertyVector->data(), m_mutablePropertyVector->size(), cssParserMode());
+}
+
StylePropertySet::StylePropertySet(CSSParserMode cssParserMode)
: m_cssParserMode(cssParserMode)
, m_ownsCSSOMWrapper(false)
@@ -87,15 +96,22 @@ StylePropertySet::StylePropertySet(const CSSProperty* properties, unsigned count
}
}
-StylePropertySet::StylePropertySet(const StylePropertySet& o)
+StylePropertySet::StylePropertySet(const StylePropertySet& other)
: RefCounted<StylePropertySet>()
- , m_cssParserMode(o.m_cssParserMode)
+ , m_cssParserMode(other.m_cssParserMode)
, m_ownsCSSOMWrapper(false)
, m_isMutable(true)
, m_arraySize(0)
, m_mutablePropertyVector(new Vector<CSSProperty>)
{
- copyPropertiesFrom(o);
+ if (other.isMutable())
+ *m_mutablePropertyVector = *other.m_mutablePropertyVector;
+ else {
+ m_mutablePropertyVector->clear();
+ m_mutablePropertyVector->reserveCapacity(other.m_arraySize);
+ for (unsigned i = 0; i < other.m_arraySize; ++i)
+ m_mutablePropertyVector->uncheckedAppend(other.array()[i]);
+ }
}
StylePropertySet::~StylePropertySet()
@@ -111,27 +127,6 @@ StylePropertySet::~StylePropertySet()
}
}
-void StylePropertySet::setCSSParserMode(CSSParserMode cssParserMode)
-{
- ASSERT(isMutable());
- m_cssParserMode = cssParserMode;
-}
-
-void StylePropertySet::copyPropertiesFrom(const StylePropertySet& other)
-{
- ASSERT(isMutable());
-
- if (other.isMutable()) {
- *m_mutablePropertyVector = *other.m_mutablePropertyVector;
- return;
- }
-
- ASSERT(m_mutablePropertyVector->isEmpty());
- m_mutablePropertyVector->reserveInitialCapacity(other.m_arraySize);
- for (unsigned i = 0; i < other.m_arraySize; ++i)
- m_mutablePropertyVector->uncheckedAppend(other.array()[i]);
-}
-
String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const
{
RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
@@ -166,12 +161,10 @@ String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const
return get4Values(borderWidthShorthand());
case CSSPropertyBorderStyle:
return get4Values(borderStyleShorthand());
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitFlex:
return getShorthandValue(webkitFlexShorthand());
case CSSPropertyWebkitFlexFlow:
return getShorthandValue(webkitFlexFlowShorthand());
-#endif
case CSSPropertyFont:
return fontValue();
case CSSPropertyMargin:
@@ -307,20 +300,26 @@ String StylePropertySet::get4Values(const StylePropertyShorthand& shorthand) con
bool showBottom = (top->value()->cssText() != bottom->value()->cssText()) || showLeft;
bool showRight = (top->value()->cssText() != right->value()->cssText()) || showBottom;
- String res = top->value()->cssText();
- if (showRight)
- res += " " + right->value()->cssText();
- if (showBottom)
- res += " " + bottom->value()->cssText();
- if (showLeft)
- res += " " + left->value()->cssText();
-
- return res;
+ StringBuilder result;
+ result.append(top->value()->cssText());
+ if (showRight) {
+ result.append(' ');
+ result.append(right->value()->cssText());
+ }
+ if (showBottom) {
+ result.append(' ');
+ result.append(bottom->value()->cssText());
+ }
+ if (showLeft) {
+ result.append(' ');
+ result.append(left->value()->cssText());
+ }
+ return result.toString();
}
String StylePropertySet::getLayeredShorthandValue(const StylePropertyShorthand& shorthand) const
{
- String res;
+ StringBuilder result;
const unsigned size = shorthand.length();
// Begin by collecting the properties into an array.
@@ -330,7 +329,7 @@ String StylePropertySet::getLayeredShorthandValue(const StylePropertyShorthand&
for (unsigned i = 0; i < size; ++i) {
values[i] = getPropertyCSSValue(shorthand.properties()[i]);
if (values[i]) {
- if (values[i]->isValueList()) {
+ if (values[i]->isBaseValueList()) {
CSSValueList* valueList = static_cast<CSSValueList*>(values[i].get());
numLayers = max(valueList->length(), numLayers);
} else
@@ -341,7 +340,7 @@ String StylePropertySet::getLayeredShorthandValue(const StylePropertyShorthand&
// Now stitch the properties together. Implicit initial values are flagged as such and
// can safely be omitted.
for (size_t i = 0; i < numLayers; i++) {
- String layerRes;
+ StringBuilder layerResult;
bool useRepeatXShorthand = false;
bool useRepeatYShorthand = false;
bool useSingleWordShorthand = false;
@@ -349,7 +348,7 @@ String StylePropertySet::getLayeredShorthandValue(const StylePropertyShorthand&
for (unsigned j = 0; j < size; j++) {
RefPtr<CSSValue> value;
if (values[j]) {
- if (values[j]->isValueList())
+ if (values[j]->isBaseValueList())
value = static_cast<CSSValueList*>(values[j].get())->item(i);
else {
value = values[j];
@@ -395,42 +394,44 @@ String StylePropertySet::getLayeredShorthandValue(const StylePropertyShorthand&
}
if (value && !value->isImplicitInitialValue()) {
- if (!layerRes.isNull())
- layerRes += " ";
+ if (!layerResult.isEmpty())
+ layerResult.append(' ');
if (foundBackgroundPositionYCSSProperty && shorthand.properties()[j] == CSSPropertyBackgroundSize)
- layerRes += "/ ";
+ layerResult.appendLiteral("/ ");
if (!foundBackgroundPositionYCSSProperty && shorthand.properties()[j] == CSSPropertyBackgroundSize)
continue;
if (useRepeatXShorthand) {
useRepeatXShorthand = false;
- layerRes += getValueName(CSSValueRepeatX);
+ layerResult.append(getValueName(CSSValueRepeatX));
} else if (useRepeatYShorthand) {
useRepeatYShorthand = false;
- layerRes += getValueName(CSSValueRepeatY);
+ layerResult.append(getValueName(CSSValueRepeatY));
} else if (useSingleWordShorthand) {
useSingleWordShorthand = false;
- layerRes += value->cssText();
+ layerResult.append(value->cssText());
} else
- layerRes += value->cssText();
+ layerResult.append(value->cssText());
if (shorthand.properties()[j] == CSSPropertyBackgroundPositionY)
foundBackgroundPositionYCSSProperty = true;
}
}
- if (!layerRes.isNull()) {
- if (!res.isNull())
- res += ", ";
- res += layerRes;
+ if (!layerResult.isEmpty()) {
+ if (!result.isEmpty())
+ result.appendLiteral(", ");
+ result.append(layerResult);
}
}
- return res;
+ if (result.isEmpty())
+ return String();
+ return result.toString();
}
String StylePropertySet::getShorthandValue(const StylePropertyShorthand& shorthand) const
{
- String res;
+ StringBuilder result;
for (unsigned i = 0; i < shorthand.length(); ++i) {
if (!isPropertyImplicit(shorthand.properties()[i])) {
RefPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i]);
@@ -438,12 +439,14 @@ String StylePropertySet::getShorthandValue(const StylePropertyShorthand& shortha
return String();
if (value->isInitialValue())
continue;
- if (!res.isNull())
- res += " ";
- res += value->cssText();
+ if (!result.isEmpty())
+ result.append(' ');
+ result.append(value->cssText());
}
}
- return res;
+ if (result.isEmpty())
+ return String();
+ return result.toString();
}
// only returns a non-null value if all properties have the same, non-null value
@@ -659,6 +662,7 @@ String StylePropertySet::asText() const
BitArray<numCSSProperties> shorthandPropertyAppeared;
unsigned size = propertyCount();
+ unsigned numDecls = 0;
for (unsigned n = 0; n < size; ++n) {
const CSSProperty& prop = propertyAt(n);
CSSPropertyID propertyID = prop.id();
@@ -669,6 +673,8 @@ String StylePropertySet::asText() const
switch (propertyID) {
#if ENABLE(CSS_VARIABLES)
case CSSPropertyVariable:
+ if (numDecls++)
+ result.append(' ');
result.append(prop.cssText());
continue;
#endif
@@ -762,7 +768,6 @@ String StylePropertySet::asText() const
case CSSPropertyWebkitAnimationFillMode:
shorthandPropertyID = CSSPropertyWebkitAnimation;
break;
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitFlexDirection:
case CSSPropertyWebkitFlexWrap:
shorthandPropertyID = CSSPropertyWebkitFlexFlow;
@@ -772,7 +777,6 @@ String StylePropertySet::asText() const
case CSSPropertyWebkitFlexShrink:
shorthandPropertyID = CSSPropertyWebkitFlex;
break;
-#endif
case CSSPropertyWebkitMaskPositionX:
case CSSPropertyWebkitMaskPositionY:
case CSSPropertyWebkitMaskRepeatX:
@@ -825,11 +829,14 @@ String StylePropertySet::asText() const
if (value == "initial" && !CSSProperty::isInheritedProperty(propertyID))
continue;
+ if (numDecls++)
+ result.append(' ');
result.append(getPropertyName(propertyID));
- result.append(": ");
+ result.appendLiteral(": ");
result.append(value);
- result.append(prop.isImportant() ? " !important" : "");
- result.append("; ");
+ if (prop.isImportant())
+ result.appendLiteral(" !important");
+ result.append(';');
}
// FIXME: This is a not-so-nice way to turn x/y positions into single background-position in output.
@@ -837,44 +844,61 @@ String StylePropertySet::asText() const
// would not work in Firefox (<rdar://problem/5143183>)
// It would be a better solution if background-position was CSS_PAIR.
if (positionXProp && positionYProp && positionXProp->isImportant() == positionYProp->isImportant()) {
- result.append("background-position: ");
+ if (numDecls++)
+ result.append(' ');
+ result.appendLiteral("background-position: ");
if (positionXProp->value()->isValueList() || positionYProp->value()->isValueList())
result.append(getLayeredShorthandValue(backgroundPositionShorthand()));
else {
result.append(positionXProp->value()->cssText());
- result.append(" ");
+ result.append(' ');
result.append(positionYProp->value()->cssText());
}
if (positionXProp->isImportant())
- result.append(" !important");
- result.append("; ");
+ result.appendLiteral(" !important");
+ result.append(';');
} else {
- if (positionXProp)
+ if (positionXProp) {
+ if (numDecls++)
+ result.append(' ');
result.append(positionXProp->cssText());
- if (positionYProp)
+ }
+ if (positionYProp) {
+ if (numDecls++)
+ result.append(' ');
result.append(positionYProp->cssText());
+ }
}
// FIXME: We need to do the same for background-repeat.
if (repeatXProp && repeatYProp && repeatXProp->isImportant() == repeatYProp->isImportant()) {
- result.append("background-repeat: ");
+ if (numDecls++)
+ result.append(' ');
+ result.appendLiteral("background-repeat: ");
if (repeatXProp->value()->isValueList() || repeatYProp->value()->isValueList())
result.append(getLayeredShorthandValue(backgroundRepeatShorthand()));
else {
result.append(repeatXProp->value()->cssText());
- result.append(" ");
+ result.append(' ');
result.append(repeatYProp->value()->cssText());
}
if (repeatXProp->isImportant())
- result.append(" !important");
- result.append("; ");
+ result.appendLiteral(" !important");
+ result.append(';');
} else {
- if (repeatXProp)
+ if (repeatXProp) {
+ if (numDecls++)
+ result.append(' ');
result.append(repeatXProp->cssText());
- if (repeatYProp)
+ }
+ if (repeatYProp) {
+ if (numDecls++)
+ result.append(' ');
result.append(repeatYProp->cssText());
+ }
}
+ ASSERT(!numDecls ^ !result.isEmpty());
return result.toString();
}
@@ -1097,7 +1121,7 @@ unsigned StylePropertySet::averageSizeInBytes()
void StylePropertySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
size_t actualSize = m_isMutable ? sizeof(StylePropertySet) : immutableStylePropertySetSize(m_arraySize);
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS, actualSize);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS, actualSize);
if (m_isMutable)
info.addVectorPtr(m_mutablePropertyVector);
diff --git a/Source/WebCore/css/StylePropertySet.h b/Source/WebCore/css/StylePropertySet.h
index 307a3ef80..5eed32857 100644
--- a/Source/WebCore/css/StylePropertySet.h
+++ b/Source/WebCore/css/StylePropertySet.h
@@ -86,15 +86,12 @@ public:
void mergeAndOverrideOnConflict(const StylePropertySet*);
- void setCSSParserMode(CSSParserMode);
CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetContents* contextStyleSheet) const;
PassRefPtr<StylePropertySet> copy() const;
-
- // Used by StyledElement::copyNonAttributeProperties().
- void copyPropertiesFrom(const StylePropertySet&);
+ PassRefPtr<StylePropertySet> immutableCopyIfNeeded() const;
void removeEquivalentProperties(const StylePropertySet*);
void removeEquivalentProperties(const CSSStyleDeclaration*);
diff --git a/Source/WebCore/css/StylePropertyShorthand.cpp b/Source/WebCore/css/StylePropertyShorthand.cpp
index d5ecd9746..3bff5abde 100644
--- a/Source/WebCore/css/StylePropertyShorthand.cpp
+++ b/Source/WebCore/css/StylePropertyShorthand.cpp
@@ -332,7 +332,6 @@ const StylePropertyShorthand& webkitColumnRuleShorthand()
return webkitColumnRuleLonghands;
}
-#if ENABLE(CSS3_FLEXBOX)
const StylePropertyShorthand& webkitFlexFlowShorthand()
{
static const CSSPropertyID flexFlowProperties[] = { CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap };
@@ -346,7 +345,6 @@ const StylePropertyShorthand& webkitFlexShorthand()
DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexLonghands, (flexProperties, WTF_ARRAY_LENGTH(flexProperties)));
return webkitFlexLonghands;
}
-#endif
const StylePropertyShorthand& webkitMarginCollapseShorthand()
{
@@ -511,12 +509,10 @@ const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID)
return webkitColumnsShorthand();
case CSSPropertyWebkitColumnRule:
return webkitColumnRuleShorthand();
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitFlex:
return webkitFlexShorthand();
case CSSPropertyWebkitFlexFlow:
return webkitFlexFlowShorthand();
-#endif
case CSSPropertyWebkitMarginCollapse:
return webkitMarginCollapseShorthand();
case CSSPropertyWebkitMarquee:
diff --git a/Source/WebCore/css/StylePropertyShorthand.h b/Source/WebCore/css/StylePropertyShorthand.h
index 72da501ce..b4244d788 100644
--- a/Source/WebCore/css/StylePropertyShorthand.h
+++ b/Source/WebCore/css/StylePropertyShorthand.h
@@ -87,10 +87,8 @@ const StylePropertyShorthand& webkitBorderEndShorthand();
const StylePropertyShorthand& webkitBorderStartShorthand();
const StylePropertyShorthand& webkitColumnsShorthand();
const StylePropertyShorthand& webkitColumnRuleShorthand();
-#if ENABLE(CSS3_FLEXBOX)
const StylePropertyShorthand& webkitFlexFlowShorthand();
const StylePropertyShorthand& webkitFlexShorthand();
-#endif
const StylePropertyShorthand& webkitMarginCollapseShorthand();
const StylePropertyShorthand& webkitMarqueeShorthand();
const StylePropertyShorthand& webkitMaskShorthand();
diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp
index 08ee28cda..b55161696 100644
--- a/Source/WebCore/css/StyleResolver.cpp
+++ b/Source/WebCore/css/StyleResolver.cpp
@@ -82,7 +82,6 @@
#include "MatrixTransformOperation.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
-#include "MemoryInstrumentation.h"
#include "NodeRenderStyle.h"
#include "NodeRenderingContext.h"
#include "Page.h"
@@ -119,6 +118,7 @@
#include "TransformationMatrix.h"
#include "TranslateTransformOperation.h"
#include "UserAgentStyleSheets.h"
+#include "WebCoreMemoryInstrumentation.h"
#include "WebKitCSSKeyframeRule.h"
#include "WebKitCSSKeyframesRule.h"
#include "WebKitCSSRegionRule.h"
@@ -150,6 +150,7 @@
#include "CustomFilterNumberParameter.h"
#include "CustomFilterOperation.h"
#include "CustomFilterParameter.h"
+#include "CustomFilterTransformParameter.h"
#include "StyleCachedShader.h"
#include "StyleCustomFilterProgram.h"
#include "StylePendingShader.h"
@@ -740,7 +741,7 @@ void StyleResolver::Features::clear()
void StyleResolver::Features::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addHashSet(idsInRules);
info.addHashSet(attrsInRules);
info.addVector(siblingRules);
@@ -2028,9 +2029,7 @@ static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s
case BLOCK:
case TABLE:
case BOX:
-#if ENABLE(CSS3_FLEXBOX)
case FLEX:
-#endif
case GRID:
return display;
@@ -2043,10 +2042,8 @@ static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s
return TABLE;
case INLINE_BOX:
return BOX;
-#if ENABLE(CSS3_FLEXBOX)
case INLINE_FLEX:
return FLEX;
-#endif
case INLINE_GRID:
return GRID;
@@ -2083,11 +2080,7 @@ static bool doesNotInheritTextDecoration(RenderStyle* style, Element* e)
static bool isDisplayFlexibleBox(EDisplay display)
{
-#if ENABLE(CSS3_FLEXBOX)
return display == FLEX || display == INLINE_FLEX;
-#else
- return false;
-#endif
}
void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e)
@@ -2196,6 +2189,8 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
|| style->hasMask()
|| style->boxReflect()
|| style->hasFilter()
+ || style->hasBlendMode()
+ || style->position() == StickyPosition
#ifdef FIXED_POSITION_CREATES_STACKING_CONTEXT
|| style->position() == FixedPosition
#else
@@ -2552,7 +2547,7 @@ RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, b
void RuleData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
}
RuleSet::RuleSet()
@@ -2570,7 +2565,7 @@ static void reportAtomRuleMap(MemoryClassInfo* info, const RuleSet::AtomRuleMap&
void RuleSet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
reportAtomRuleMap(&info, m_idRules);
reportAtomRuleMap(&info, m_classRules);
reportAtomRuleMap(&info, m_tagRules);
@@ -2584,7 +2579,7 @@ void RuleSet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
void RuleSet::RuleSetSelectorPair::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(ruleSet);
}
@@ -3358,8 +3353,15 @@ static bool createGridPosition(CSSValue* value, Length& position)
#if ENABLE(CSS_VARIABLES)
static bool hasVariableReference(CSSValue* value)
{
- if (value->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(value)->isVariableName())
- return true;
+ if (value->isPrimitiveValue()) {
+ CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+ if (CSSCalcValue* calcValue = primitiveValue->cssCalcValue())
+ return calcValue->hasVariableReference();
+ return primitiveValue->isVariableName();
+ }
+
+ if (value->isCalculationValue())
+ return static_cast<CSSCalcValue*>(value)->hasVariableReference();
for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
if (hasVariableReference(i.value()))
@@ -4301,6 +4303,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
case CSSPropertyOutlineStyle:
case CSSPropertyOutlineWidth:
case CSSPropertyOverflow:
+ case CSSPropertyOverflowWrap:
case CSSPropertyOverflowX:
case CSSPropertyOverflowY:
case CSSPropertyPadding:
@@ -4376,7 +4379,6 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
case CSSPropertyWebkitColumns:
case CSSPropertyWebkitColumnSpan:
case CSSPropertyWebkitColumnWidth:
-#if ENABLE(CSS3_FLEXBOX)
case CSSPropertyWebkitAlignContent:
case CSSPropertyWebkitAlignItems:
case CSSPropertyWebkitAlignSelf:
@@ -4389,7 +4391,6 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
case CSSPropertyWebkitFlexWrap:
case CSSPropertyWebkitJustifyContent:
case CSSPropertyWebkitOrder:
-#endif
#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitFlowFrom:
case CSSPropertyWebkitFlowInto:
@@ -4463,6 +4464,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
case CSSPropertyWebkitUserDrag:
case CSSPropertyWebkitUserModify:
case CSSPropertyWebkitUserSelect:
+ case CSSPropertyWebkitClipPath:
#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrap:
case CSSPropertyWebkitWrapFlow:
@@ -5245,7 +5247,7 @@ static bool sortParametersByNameComparator(const RefPtr<CustomFilterParameter>&
return codePointCompareLessThan(a->name(), b->name());
}
-PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterNumberParamter(const String& name, CSSValueList* values)
+PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterNumberParameter(const String& name, CSSValueList* values)
{
RefPtr<CustomFilterNumberParameter> numberParameter = CustomFilterNumberParameter::create(name);
for (unsigned i = 0; i < values->length(); ++i) {
@@ -5260,6 +5262,46 @@ PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterNumberParamter
return numberParameter.release();
}
+PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterTransformParameter(const String& name, CSSValueList* values)
+{
+ RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTransformParameter::create(name);
+ TransformOperations operations;
+ createTransformOperations(values, style(), m_rootElementStyle, operations);
+ transformParameter->setOperations(operations);
+ return transformParameter.release();
+}
+
+PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterParameter(const String& name, CSSValue* parameterValue)
+{
+ // FIXME: Implement other parameters types parsing.
+ // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438
+ // textures: https://bugs.webkit.org/show_bug.cgi?id=71442
+ // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444
+ if (!parameterValue->isValueList())
+ return 0;
+
+ CSSValueList* values = static_cast<CSSValueList*>(parameterValue);
+ if (!values->length())
+ return 0;
+
+ if (values->itemWithoutBoundsCheck(0)->isWebKitCSSTransformValue())
+ return parseCustomFilterTransformParameter(name, values);
+
+ // We can have only arrays of booleans or numbers, so use the first value to choose between those two.
+ // We need up to 4 values (all booleans or all numbers).
+ if (!values->itemWithoutBoundsCheck(0)->isPrimitiveValue() || values->length() > 4)
+ return 0;
+
+ CSSPrimitiveValue* firstPrimitiveValue = static_cast<CSSPrimitiveValue*>(values->itemWithoutBoundsCheck(0));
+ if (firstPrimitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER)
+ return parseCustomFilterNumberParameter(name, values);
+
+ // FIXME: Implement the boolean array parameter here.
+ // https://bugs.webkit.org/show_bug.cgi?id=76438
+
+ return 0;
+}
+
bool StyleResolver::parseCustomFilterParameterList(CSSValue* parametersValue, CustomFilterParameterList& parameterList)
{
HashSet<String> knownParameterNames;
@@ -5285,34 +5327,9 @@ bool StyleResolver::parseCustomFilterParameterList(CSSValue* parametersValue, Cu
if (!iterator.hasMore())
return false;
- // FIXME: Implement other parameters types parsing.
- // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438
- // textures: https://bugs.webkit.org/show_bug.cgi?id=71442
- // 3d-transforms: https://bugs.webkit.org/show_bug.cgi?id=71443
- // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444
- RefPtr<CustomFilterParameter> parameter;
- if (iterator.value()->isValueList()) {
- CSSValueList* values = static_cast<CSSValueList*>(iterator.value());
- iterator.advance();
-
- // We can have only arrays of booleans or numbers, so use the first value to choose between those two.
- // Make sure we have at least one value. We need up to 4 values (all booleans or all numbers).
- if (!values->length() || values->length() > 4)
- return false;
-
- if (!values->itemWithoutBoundsCheck(0)->isPrimitiveValue())
- return false;
-
- CSSPrimitiveValue* firstPrimitiveValue = static_cast<CSSPrimitiveValue*>(values->itemWithoutBoundsCheck(0));
- if (firstPrimitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER)
- parameter = parseCustomFilterNumberParamter(name, values);
- // FIXME: Implement the boolean array parameter here.
- // https://bugs.webkit.org/show_bug.cgi?id=76438
- }
-
+ RefPtr<CustomFilterParameter> parameter = parseCustomFilterParameter(name, iterator.value());
if (!parameter)
return false;
-
parameterList.append(parameter.release());
}
@@ -5711,25 +5728,25 @@ void StyleResolver::loadPendingResources()
void StyleResolver::MatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(properties);
}
void StyleResolver::MatchedPropertiesCacheItem::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedVector(matchedProperties);
}
void MediaQueryResult::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_expression);
}
void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addMember(m_style);
info.addInstrumentedMember(m_authorStyle);
info.addInstrumentedMember(m_userStyle);
diff --git a/Source/WebCore/css/StyleResolver.h b/Source/WebCore/css/StyleResolver.h
index 2bbc6823e..fe697390c 100644
--- a/Source/WebCore/css/StyleResolver.h
+++ b/Source/WebCore/css/StyleResolver.h
@@ -263,7 +263,9 @@ public:
StyleShader* styleShader(CSSValue*);
StyleShader* cachedOrPendingStyleShaderFromValue(WebKitCSSShaderValue*);
bool parseCustomFilterParameterList(CSSValue*, CustomFilterParameterList&);
- PassRefPtr<CustomFilterParameter> parseCustomFilterNumberParamter(const String& name, CSSValueList*);
+ PassRefPtr<CustomFilterParameter> parseCustomFilterParameter(const String& name, CSSValue*);
+ PassRefPtr<CustomFilterParameter> parseCustomFilterNumberParameter(const String& name, CSSValueList*);
+ PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter(const String& name, CSSValueList*);
PassRefPtr<CustomFilterOperation> createCustomFilterOperation(WebKitCSSFilterValue*);
void loadPendingShaders();
#endif
diff --git a/Source/WebCore/css/StyleRule.cpp b/Source/WebCore/css/StyleRule.cpp
index 03efc3a34..6847c16b9 100644
--- a/Source/WebCore/css/StyleRule.cpp
+++ b/Source/WebCore/css/StyleRule.cpp
@@ -28,8 +28,8 @@
#include "CSSMediaRule.h"
#include "CSSPageRule.h"
#include "CSSStyleRule.h"
-#include "MemoryInstrumentation.h"
#include "StyleRuleImport.h"
+#include "WebCoreMemoryInstrumentation.h"
#include "WebKitCSSKeyframeRule.h"
#include "WebKitCSSKeyframesRule.h"
#include "WebKitCSSRegionRule.h"
@@ -81,7 +81,7 @@ void StyleRuleBase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
case Unknown:
case Charset:
case Keyframe:
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
return;
}
ASSERT_NOT_REACHED();
@@ -208,7 +208,7 @@ unsigned StyleRule::averageSizeInBytes()
void StyleRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_properties);
info.addInstrumentedMember(m_selectorList);
}
@@ -271,7 +271,7 @@ void StyleRulePage::setProperties(PassRefPtr<StylePropertySet> properties)
void StyleRulePage::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_properties);
info.addInstrumentedMember(m_selectorList);
}
@@ -305,7 +305,7 @@ void StyleRuleFontFace::setProperties(PassRefPtr<StylePropertySet> properties)
void StyleRuleFontFace::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_properties);
}
@@ -336,7 +336,7 @@ void StyleRuleBlock::wrapperRemoveRule(unsigned index)
void StyleRuleBlock::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedVector(m_childRules);
}
@@ -355,7 +355,7 @@ StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o)
void StyleRuleMedia::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_mediaQueries);
}
@@ -373,7 +373,7 @@ StyleRuleRegion::StyleRuleRegion(const StyleRuleRegion& o)
void StyleRuleRegion::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_selectorList);
}
diff --git a/Source/WebCore/css/StyleRuleImport.cpp b/Source/WebCore/css/StyleRuleImport.cpp
index 382313e67..6e4501b34 100644
--- a/Source/WebCore/css/StyleRuleImport.cpp
+++ b/Source/WebCore/css/StyleRuleImport.cpp
@@ -32,6 +32,12 @@
namespace WebCore {
+StyleRuleImport::LoadContext::LoadContext(CSSStyleSheet* rootStyleSheet, const CSSParserContext& parentParserContext)
+ : rootStyleSheet(rootStyleSheet)
+ , parentParserContext(parentParserContext)
+{
+}
+
PassRefPtr<StyleRuleImport> StyleRuleImport::create(const String& href, PassRefPtr<MediaQuerySet> media)
{
return adoptRef(new StyleRuleImport(href, media));
@@ -39,12 +45,9 @@ PassRefPtr<StyleRuleImport> StyleRuleImport::create(const String& href, PassRefP
StyleRuleImport::StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet> media)
: StyleRuleBase(Import, 0)
- , m_parentStyleSheet(0)
- , m_styleSheetClient(this)
, m_strHref(href)
, m_mediaQueries(media)
, m_cachedSheet(0)
- , m_loading(false)
{
if (!m_mediaQueries)
m_mediaQueries = MediaQuerySet::create(String());
@@ -52,88 +55,95 @@ StyleRuleImport::StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet> m
StyleRuleImport::~StyleRuleImport()
{
- if (m_styleSheet)
- m_styleSheet->clearOwnerRule();
if (m_cachedSheet)
- m_cachedSheet->removeClient(&m_styleSheetClient);
+ m_cachedSheet->removeClient(this);
}
-void StyleRuleImport::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* cachedStyleSheet)
+void StyleRuleImport::setCSSStyleSheet(const String& url, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*)
{
- if (m_styleSheet)
- m_styleSheet->clearOwnerRule();
-
- CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : CSSStrictMode;
- context.charset = charset;
- if (!baseURL.isNull())
- context.baseURL = baseURL;
-
- m_styleSheet = StyleSheetContents::create(this, href, context);
-
- Document* document = m_parentStyleSheet ? m_parentStyleSheet->singleOwnerDocument() : 0;
- m_styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document ? document->securityOrigin() : 0);
+ ASSERT(m_loadContext);
+ ASSERT(!m_styleSheet);
+ ASSERT(m_cachedSheet);
- m_loading = false;
+ OwnPtr<LoadContext> loadContext = m_loadContext.release();
- if (m_parentStyleSheet) {
- m_parentStyleSheet->notifyLoadedSheet(cachedStyleSheet);
- m_parentStyleSheet->checkLoaded();
+ CSSParserContext parserContext = loadContext->parentParserContext;
+ if (!baseURL.isNull())
+ parserContext.baseURL = baseURL;
+ parserContext.charset = charset;
+
+#if ENABLE(PARSED_STYLE_SHEET_CACHING)
+ m_styleSheet = m_cachedSheet->restoreParsedStyleSheet(parserContext);
+#endif
+ if (!m_styleSheet) {
+ m_styleSheet = StyleSheetContents::create(url, parserContext);
+ m_styleSheet->parseAuthorStyleSheet(m_cachedSheet.get(), loadContext->rootStyleSheet.get());
}
+ loadContext->rootStyleSheet->contents()->checkLoadCompleted();
+
+#if ENABLE(PARSED_STYLE_SHEET_CACHING)
+ if (m_styleSheet->isCacheable())
+ m_cachedSheet->saveParsedStyleSheet(m_styleSheet);
+#endif
}
bool StyleRuleImport::isLoading() const
{
- return m_loading || (m_styleSheet && m_styleSheet->isLoading());
+ return m_loadContext || (m_styleSheet && m_styleSheet->isLoading());
}
-void StyleRuleImport::requestStyleSheet()
+bool StyleRuleImport::hadLoadError() const
{
- if (!m_parentStyleSheet)
- return;
- Document* document = m_parentStyleSheet->singleOwnerDocument();
- if (!document)
- return;
+ return m_cachedSheet && m_cachedSheet->errorOccurred();
+}
- CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
- if (!cachedResourceLoader)
+void StyleRuleImport::requestStyleSheet(CSSStyleSheet* rootSheet, const CSSParserContext& parserContext)
+{
+ ASSERT(!rootSheet->parentStyleSheet());
+ ASSERT(!m_cachedSheet);
+
+ Node* ownerNode = rootSheet->ownerNode();
+ if (!ownerNode)
return;
+ Document* document = ownerNode->document();
- KURL absURL;
- if (!m_parentStyleSheet->baseURL().isNull())
- // use parent styleheet's URL as the base URL
- absURL = KURL(m_parentStyleSheet->baseURL(), m_strHref);
+ KURL resolvedURL;
+ if (!parserContext.baseURL.isNull())
+ resolvedURL = KURL(parserContext.baseURL, m_strHref);
else
- absURL = document->completeURL(m_strHref);
-
- // Check for a cycle in our import chain. If we encounter a stylesheet
- // in our parent chain with the same URL, then just bail.
- StyleSheetContents* rootSheet = m_parentStyleSheet;
- for (StyleSheetContents* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
- if (equalIgnoringFragmentIdentifier(absURL, sheet->baseURL())
- || equalIgnoringFragmentIdentifier(absURL, document->completeURL(sheet->originalURL())))
- return;
- rootSheet = sheet;
- }
+ resolvedURL = document->completeURL(m_strHref);
- ResourceRequest request(absURL);
- if (m_parentStyleSheet->isUserStyleSheet())
- m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, m_parentStyleSheet->charset());
+ StyleSheetContents* rootSheetContents = rootSheet->contents();
+ if (rootSheetContents->hasImportCycle(this, resolvedURL, document->baseURL()))
+ return;
+
+ ResourceRequest request(resolvedURL);
+ CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
+ if (rootSheetContents->isUserStyleSheet())
+ m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, parserContext.charset);
else
- m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, m_parentStyleSheet->charset());
- if (m_cachedSheet) {
- // if the import rule is issued dynamically, the sheet may be
- // removed from the pending sheet count, so let the doc know
- // the sheet being imported is pending.
- if (m_parentStyleSheet && m_parentStyleSheet->loadCompleted() && rootSheet == m_parentStyleSheet)
- m_parentStyleSheet->startLoadingDynamicSheet();
- m_loading = true;
- m_cachedSheet->addClient(&m_styleSheetClient);
- }
+ m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, parserContext.charset);
+
+ if (!m_cachedSheet)
+ return;
+ // if the import rule is issued dynamically, the sheet may be
+ // removed from the pending sheet count, so let the doc know
+ // the sheet being imported is pending.
+ if (rootSheetContents->loadCompleted())
+ ownerNode->startLoadingDynamicSheet();
+
+ m_loadContext = adoptPtr(new LoadContext(rootSheet, parserContext));
+ m_cachedSheet->addClient(this);
+}
+
+void StyleRuleImport::reattachStyleSheetContents(StyleSheetContents* contents)
+{
+ m_styleSheet = contents;
}
void StyleRuleImport::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_strHref);
info.addInstrumentedMember(m_mediaQueries);
info.addInstrumentedMember(m_styleSheet);
diff --git a/Source/WebCore/css/StyleRuleImport.h b/Source/WebCore/css/StyleRuleImport.h
index c0f898c65..b5c9eaea7 100644
--- a/Source/WebCore/css/StyleRuleImport.h
+++ b/Source/WebCore/css/StyleRuleImport.h
@@ -22,6 +22,7 @@
#ifndef StyleRuleImport_h
#define StyleRuleImport_h
+#include "CSSParserMode.h"
#include "CachedResourceHandle.h"
#include "CachedStyleSheetClient.h"
#include "StyleRule.h"
@@ -33,54 +34,41 @@ class MediaQuerySet;
class MemoryObjectInfo;
class StyleSheetContents;
-class StyleRuleImport : public StyleRuleBase {
+class StyleRuleImport : public StyleRuleBase, public CachedStyleSheetClient {
public:
static PassRefPtr<StyleRuleImport> create(const String& href, PassRefPtr<MediaQuerySet>);
- ~StyleRuleImport();
-
- StyleSheetContents* parentStyleSheet() const { return m_parentStyleSheet; }
- void setParentStyleSheet(StyleSheetContents* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; }
- void clearParentStyleSheet() { m_parentStyleSheet = 0; }
+ virtual ~StyleRuleImport();
String href() const { return m_strHref; }
StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
bool isLoading() const;
+ bool hadLoadError() const;
MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); }
- void requestStyleSheet();
+ void requestStyleSheet(CSSStyleSheet* rootSheet, const CSSParserContext&);
void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
-private:
- // NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it
- // to avoid adding a vptr to StyleRuleImport.
- class ImportedStyleSheetClient : public CachedStyleSheetClient {
- public:
- ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }
- virtual ~ImportedStyleSheetClient() { }
- virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)
- {
- m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);
- }
- private:
- StyleRuleImport* m_ownerRule;
- };
-
- void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
- friend class ImportedStyleSheetClient;
+ void reattachStyleSheetContents(StyleSheetContents*);
+private:
StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet>);
- StyleSheetContents* m_parentStyleSheet;
+ virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
- ImportedStyleSheetClient m_styleSheetClient;
String m_strHref;
RefPtr<MediaQuerySet> m_mediaQueries;
RefPtr<StyleSheetContents> m_styleSheet;
+
CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
- bool m_loading;
+ struct LoadContext {
+ LoadContext(CSSStyleSheet* rootStyleSheet, const CSSParserContext& parentParserContext);
+ RefPtr<CSSStyleSheet> rootStyleSheet;
+ CSSParserContext parentParserContext;
+ };
+ OwnPtr<LoadContext> m_loadContext;
};
} // namespace WebCore
diff --git a/Source/WebCore/css/StyleSheet.h b/Source/WebCore/css/StyleSheet.h
index 9f4ecd181..60bbb5f26 100644
--- a/Source/WebCore/css/StyleSheet.h
+++ b/Source/WebCore/css/StyleSheet.h
@@ -23,7 +23,7 @@
#include "CSSParserMode.h"
#include "KURLHash.h"
-#include "PlatformString.h"
+#include <wtf/Forward.h>
#include <wtf/ListHashSet.h>
#include <wtf/RefCounted.h>
diff --git a/Source/WebCore/css/StyleSheetContents.cpp b/Source/WebCore/css/StyleSheetContents.cpp
index cc3cec52a..ba00e2b21 100644
--- a/Source/WebCore/css/StyleSheetContents.cpp
+++ b/Source/WebCore/css/StyleSheetContents.cpp
@@ -26,12 +26,12 @@
#include "CSSStyleSheet.h"
#include "CachedCSSStyleSheet.h"
#include "Document.h"
-#include "MemoryInstrumentation.h"
#include "Node.h"
#include "SecurityOrigin.h"
#include "StylePropertySet.h"
#include "StyleRule.h"
#include "StyleRuleImport.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/Deque.h>
namespace WebCore {
@@ -54,11 +54,9 @@ unsigned StyleSheetContents::estimatedSizeInBytes() const
return size;
}
-StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext& context)
- : m_ownerRule(ownerRule)
- , m_originalURL(originalURL)
+StyleSheetContents::StyleSheetContents(const String& originalURL, const CSSParserContext& context)
+ : m_originalURL(originalURL)
, m_loadCompleted(false)
- , m_isUserStyleSheet(ownerRule && ownerRule->parentStyleSheet() && ownerRule->parentStyleSheet()->isUserStyleSheet())
, m_hasSyntacticallyValidCSSHeader(true)
, m_didLoadErrorOccur(false)
, m_usesRemUnits(false)
@@ -70,7 +68,6 @@ StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule, const String&
StyleSheetContents::StyleSheetContents(const StyleSheetContents& o)
: RefCounted<StyleSheetContents>()
- , m_ownerRule(0)
, m_originalURL(o.m_originalURL)
, m_encodingFromCharsetRule(o.m_encodingFromCharsetRule)
, m_importRules(o.m_importRules.size())
@@ -104,9 +101,6 @@ bool StyleSheetContents::isCacheable() const
// FIXME: Support copying import rules.
if (!m_importRules.isEmpty())
return false;
- // FIXME: Support cached stylesheets in import rules.
- if (m_ownerRule)
- return false;
// This would require dealing with multiple clients for load callbacks.
if (!m_loadCompleted)
return false;
@@ -129,8 +123,6 @@ void StyleSheetContents::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
// Parser enforces that @import rules come before anything else except @charset.
ASSERT(m_childRules.isEmpty());
m_importRules.append(static_cast<StyleRuleImport*>(rule.get()));
- m_importRules.last()->setParentStyleSheet(this);
- m_importRules.last()->requestStyleSheet();
return;
}
m_childRules.append(rule);
@@ -169,10 +161,6 @@ void StyleSheetContents::clearCharsetRule()
void StyleSheetContents::clearRules()
{
- for (unsigned i = 0; i < m_importRules.size(); ++i) {
- ASSERT(m_importRules.at(i)->parentStyleSheet() == this);
- m_importRules[i]->clearParentStyleSheet();
- }
m_importRules.clear();
m_childRules.clear();
clearCharsetRule();
@@ -207,9 +195,6 @@ bool StyleSheetContents::wrapperInsertRule(PassRefPtr<StyleRuleBase> rule, unsig
if (!rule->isImportRule())
return false;
m_importRules.insert(childVectorIndex, static_cast<StyleRuleImport*>(rule.get()));
- m_importRules[childVectorIndex]->setParentStyleSheet(this);
- m_importRules[childVectorIndex]->requestStyleSheet();
- // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded.
return true;
}
// Inserting @import rule after a non-import rule is not allowed.
@@ -235,7 +220,6 @@ void StyleSheetContents::wrapperDeleteRule(unsigned index)
--childVectorIndex;
}
if (childVectorIndex < m_importRules.size()) {
- m_importRules[childVectorIndex]->clearParentStyleSheet();
m_importRules.remove(childVectorIndex);
return;
}
@@ -266,8 +250,22 @@ const AtomicString& StyleSheetContents::determineNamespace(const AtomicString& p
return it->second;
}
-void StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cachedStyleSheet, const SecurityOrigin* securityOrigin)
+void StyleSheetContents::requestImportedStyleSheets(CSSStyleSheet* rootSheet)
{
+ ASSERT(!rootSheet->parentStyleSheet());
+ for (unsigned i = 0; i < m_importRules.size(); ++i)
+ m_importRules[i]->requestStyleSheet(rootSheet, parserContext());
+}
+
+void StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cachedStyleSheet, CSSStyleSheet* rootSheet)
+{
+ if (cachedStyleSheet->errorOccurred()) {
+ m_didLoadErrorOccur = true;
+ return;
+ }
+ Document* ownerDocument = rootSheet->ownerDocument();
+ if (!ownerDocument)
+ return;
// Check to see if we should enforce the MIME type of the CSS resource in strict mode.
// Running in iWeb 2 is one example of where we don't want to - <rdar://problem/6099748>
bool enforceMIMEType = isStrictParserMode(m_parserContext.mode) && m_parserContext.enforcesCSSMIMETypeInNoQuirksMode;
@@ -281,6 +279,7 @@ void StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cached
// to at least start with a syntactically valid CSS rule.
// This prevents an attacker playing games by injecting CSS strings into HTML, XML, JSON, etc. etc.
if (!hasValidMIMEType && !hasSyntacticallyValidCSSHeader()) {
+ const SecurityOrigin* securityOrigin = ownerDocument->securityOrigin();
bool isCrossOriginCSS = !securityOrigin || !securityOrigin->canRequest(baseURL());
if (isCrossOriginCSS) {
clearRules();
@@ -289,14 +288,17 @@ void StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cached
}
if (m_parserContext.needsSiteSpecificQuirks && isStrictParserMode(m_parserContext.mode)) {
// Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
- DEFINE_STATIC_LOCAL(const String, slashKHTMLFixesDotCss, ("/KHTMLFixes.css"));
- DEFINE_STATIC_LOCAL(const String, mediaWikiKHTMLFixesStyleSheet, ("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n"));
+ DEFINE_STATIC_LOCAL(const String, mediaWikiKHTMLFixesStyleSheet, (ASCIILiteral("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n")));
// There are two variants of KHTMLFixes.css. One is equal to mediaWikiKHTMLFixesStyleSheet,
// while the other lacks the second trailing newline.
- if (baseURL().string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
- && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1)
+ if (baseURL().string().endsWith("/KHTMLFixes.css") && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
+ && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
clearRules();
+ return;
+ }
}
+
+ requestImportedStyleSheets(rootSheet);
}
bool StyleSheetContents::parseString(const String& sheetText)
@@ -309,6 +311,10 @@ bool StyleSheetContents::parseStringAtLine(const String& sheetText, int startLin
CSSParser p(parserContext());
p.parseSheet(this, sheetText, startLineNumber);
+ if (!m_clients.isEmpty()) {
+ ASSERT(m_clients.size() == 1);
+ requestImportedStyleSheets(m_clients[0]);
+ }
return true;
}
@@ -321,64 +327,70 @@ bool StyleSheetContents::isLoading() const
return false;
}
-void StyleSheetContents::checkLoaded()
+bool StyleSheetContents::checkImportedSheetLoadCompleted()
{
- if (isLoading())
- return;
+ for (unsigned i = 0; i < m_importRules.size(); ++i) {
+ StyleRuleImport* importRule = m_importRules[i].get();
+ if (importRule->isLoading())
+ return false;
+ if (importRule->styleSheet() && !importRule->styleSheet()->checkImportedSheetLoadCompleted())
+ return false;
+ if (importRule->hadLoadError())
+ m_didLoadErrorOccur = true;
+ }
+ m_loadCompleted = true;
+ return true;
+}
- // Avoid |this| being deleted by scripts that run via
- // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
- // See <rdar://problem/6622300>.
- RefPtr<StyleSheetContents> protector(this);
- StyleSheetContents* parentSheet = parentStyleSheet();
- if (parentSheet) {
- parentSheet->checkLoaded();
- m_loadCompleted = true;
+void StyleSheetContents::checkLoadCompleted()
+{
+ if (m_clients.isEmpty())
return;
- }
- RefPtr<Node> ownerNode = singleOwnerNode();
- if (!ownerNode) {
- m_loadCompleted = true;
+ if (!checkImportedSheetLoadCompleted())
return;
- }
+
+ RefPtr<StyleSheetContents> protect(this);
+
+ ASSERT(hasOneClient());
+ ASSERT(!m_clients[0]->parentStyleSheet());
+ RefPtr<Node> ownerNode = m_clients[0]->ownerNode();
+ if (!ownerNode)
+ return;
+
m_loadCompleted = ownerNode->sheetLoaded();
if (m_loadCompleted)
ownerNode->notifyLoadedSheetAndAllCriticalSubresources(m_didLoadErrorOccur);
}
-void StyleSheetContents::notifyLoadedSheet(const CachedCSSStyleSheet* sheet)
-{
- ASSERT(sheet);
- m_didLoadErrorOccur |= sheet->errorOccurred();
-}
-
-void StyleSheetContents::startLoadingDynamicSheet()
-{
- if (Node* owner = singleOwnerNode())
- owner->startLoadingDynamicSheet();
-}
-
-StyleSheetContents* StyleSheetContents::rootStyleSheet() const
+bool StyleSheetContents::getAncestors(const StyleRuleImport* importRule, Vector<const StyleSheetContents*>& result) const
{
- const StyleSheetContents* root = this;
- while (root->parentStyleSheet())
- root = root->parentStyleSheet();
- return const_cast<StyleSheetContents*>(root);
+ result.append(this);
+ for (unsigned i = 0; i < m_importRules.size(); ++i) {
+ if (m_importRules[i] == importRule)
+ return true;
+ }
+ for (unsigned i = 0; i < m_importRules.size(); ++i) {
+ if (m_importRules[i]->styleSheet() && m_importRules[i]->styleSheet()->getAncestors(importRule, result))
+ return true;
+ }
+ result.removeLast();
+ return false;
}
-Node* StyleSheetContents::singleOwnerNode() const
+bool StyleSheetContents::hasImportCycle(const StyleRuleImport* importRule, const KURL& importURL, const KURL& documentBaseURL) const
{
- StyleSheetContents* root = rootStyleSheet();
- if (root->m_clients.isEmpty())
- return 0;
- ASSERT(root->m_clients.size() == 1);
- return root->m_clients[0]->ownerNode();
-}
+ Vector<const StyleSheetContents*> ancestors;
+ getAncestors(importRule, ancestors);
-Document* StyleSheetContents::singleOwnerDocument() const
-{
- Node* ownerNode = singleOwnerNode();
- return ownerNode ? ownerNode->document() : 0;
+ KURL parentBaseURL = documentBaseURL;
+ for (unsigned i = 0; i < ancestors.size(); ++i) {
+ if (equalIgnoringFragmentIdentifier(importURL, ancestors[i]->baseURL()))
+ return true;
+ if (equalIgnoringFragmentIdentifier(importURL, KURL(parentBaseURL, ancestors[i]->originalURL())))
+ return true;
+ parentBaseURL = ancestors[i]->baseURL();
+ }
+ return false;
}
KURL StyleSheetContents::completeURL(const String& url) const
@@ -451,11 +463,6 @@ bool StyleSheetContents::hasFailedOrCanceledSubresources() const
return childRulesHaveFailedOrCanceledSubresources(m_childRules);
}
-StyleSheetContents* StyleSheetContents::parentStyleSheet() const
-{
- return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
-}
-
void StyleSheetContents::registerClient(CSSStyleSheet* sheet)
{
ASSERT(!m_clients.contains(sheet));
@@ -485,7 +492,7 @@ void StyleSheetContents::removedFromMemoryCache()
void StyleSheetContents::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_originalURL);
info.addInstrumentedMember(m_encodingFromCharsetRule);
info.addVector(m_importRules);
diff --git a/Source/WebCore/css/StyleSheetContents.h b/Source/WebCore/css/StyleSheetContents.h
index af0b294d5..c1ed0d51a 100644
--- a/Source/WebCore/css/StyleSheetContents.h
+++ b/Source/WebCore/css/StyleSheetContents.h
@@ -44,15 +44,11 @@ class StyleSheetContents : public RefCounted<StyleSheetContents> {
public:
static PassRefPtr<StyleSheetContents> create(const CSSParserContext& context = CSSParserContext(CSSStrictMode))
{
- return adoptRef(new StyleSheetContents(0, String(), context));
+ return adoptRef(new StyleSheetContents(String(), context));
}
static PassRefPtr<StyleSheetContents> create(const String& originalURL, const CSSParserContext& context)
{
- return adoptRef(new StyleSheetContents(0, originalURL, context));
- }
- static PassRefPtr<StyleSheetContents> create(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext& context)
- {
- return adoptRef(new StyleSheetContents(ownerRule, originalURL, context));
+ return adoptRef(new StyleSheetContents(originalURL, context));
}
~StyleSheetContents();
@@ -61,7 +57,7 @@ public:
const AtomicString& determineNamespace(const AtomicString& prefix);
- void parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*);
+ void parseAuthorStyleSheet(const CachedCSSStyleSheet*, CSSStyleSheet* rootSheet);
bool parseString(const String&);
bool parseStringAtLine(const String&, int startLineNumber);
@@ -69,12 +65,7 @@ public:
bool isLoading() const;
- void checkLoaded();
- void startLoadingDynamicSheet();
-
- StyleSheetContents* rootStyleSheet() const;
- Node* singleOwnerNode() const;
- Document* singleOwnerDocument() const;
+ void checkLoadCompleted();
const String& charset() const { return m_parserContext.charset; }
@@ -102,12 +93,8 @@ public:
const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRules; }
const Vector<RefPtr<StyleRuleImport> >& importRules() const { return m_importRules; }
- void notifyLoadedSheet(const CachedCSSStyleSheet*);
-
- StyleSheetContents* parentStyleSheet() const;
- StyleRuleImport* ownerRule() const { return m_ownerRule; }
- void clearOwnerRule() { m_ownerRule = 0; }
-
+ bool hasImportCycle(const StyleRuleImport* importRule, const KURL& importURL, const KURL& documentBaseURL) const;
+
// Note that href is the URL that started the redirect chain that led to
// this style sheet. This property probably isn't useful for much except
// the JavaScript binding (which needs to use this value for security).
@@ -124,6 +111,8 @@ public:
bool wrapperInsertRule(PassRefPtr<StyleRuleBase>, unsigned index);
void wrapperDeleteRule(unsigned index);
+ void requestImportedStyleSheets(CSSStyleSheet* rootSheet);
+
PassRefPtr<StyleSheetContents> copy() const { return adoptRef(new StyleSheetContents(*this)); }
void registerClient(CSSStyleSheet*);
@@ -140,12 +129,13 @@ public:
void reportMemoryUsage(MemoryObjectInfo*) const;
private:
- StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext&);
+ StyleSheetContents(const String& originalURL, const CSSParserContext&);
StyleSheetContents(const StyleSheetContents&);
void clearCharsetRule();
- StyleRuleImport* m_ownerRule;
+ bool checkImportedSheetLoadCompleted();
+ bool getAncestors(const StyleRuleImport*, Vector<const StyleSheetContents*>& result) const;
String m_originalURL;
diff --git a/Source/WebCore/css/StyleSheetList.cpp b/Source/WebCore/css/StyleSheetList.cpp
index bbefd318b..f1ab52dc9 100644
--- a/Source/WebCore/css/StyleSheetList.cpp
+++ b/Source/WebCore/css/StyleSheetList.cpp
@@ -25,7 +25,7 @@
#include "Document.h"
#include "HTMLNames.h"
#include "HTMLStyleElement.h"
-#include "PlatformString.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/WebKitCSSArrayFunctionValue.cpp b/Source/WebCore/css/WebKitCSSArrayFunctionValue.cpp
new file mode 100644
index 000000000..2a17a44b7
--- /dev/null
+++ b/Source/WebCore/css/WebKitCSSArrayFunctionValue.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “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 HOLDER 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.
+ */
+
+#include "config.h"
+#include "WebKitCSSArrayFunctionValue.h"
+
+#include "WebCoreMemoryInstrumentation.h"
+
+#if ENABLE(CSS_SHADERS)
+
+namespace WebCore {
+
+WebKitCSSArrayFunctionValue::WebKitCSSArrayFunctionValue()
+ : CSSValueList(WebKitCSSArrayFunctionValueClass, CommaSeparator)
+{
+}
+
+WebKitCSSArrayFunctionValue::WebKitCSSArrayFunctionValue(const WebKitCSSArrayFunctionValue& cloneFrom)
+ : CSSValueList(cloneFrom)
+{
+}
+
+String WebKitCSSArrayFunctionValue::customCssText() const
+{
+ return "array(" + CSSValueList::customCssText() + ')';
+}
+
+PassRefPtr<WebKitCSSArrayFunctionValue> WebKitCSSArrayFunctionValue::cloneForCSSOM() const
+{
+ return adoptRef(new WebKitCSSArrayFunctionValue(*this));
+}
+
+void WebKitCSSArrayFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
+ CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_SHADERS)
diff --git a/Source/WebCore/css/WebKitCSSArrayFunctionValue.h b/Source/WebCore/css/WebKitCSSArrayFunctionValue.h
new file mode 100644
index 000000000..baf27820b
--- /dev/null
+++ b/Source/WebCore/css/WebKitCSSArrayFunctionValue.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “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 HOLDER 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.
+ */
+
+#ifndef WebKitCSSArrayFunctionValue_h
+#define WebKitCSSArrayFunctionValue_h
+
+#if ENABLE(CSS_SHADERS)
+
+#include "CSSValueList.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class WebKitCSSArrayFunctionValue : public CSSValueList {
+public:
+ static PassRefPtr<WebKitCSSArrayFunctionValue> create()
+ {
+ return adoptRef(new WebKitCSSArrayFunctionValue());
+ }
+
+ String customCssText() const;
+
+ PassRefPtr<WebKitCSSArrayFunctionValue> cloneForCSSOM() const;
+
+ void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
+private:
+ WebKitCSSArrayFunctionValue();
+ WebKitCSSArrayFunctionValue(const WebKitCSSArrayFunctionValue& cloneFrom);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_SHADERS)
+
+#endif
diff --git a/Source/WebCore/css/WebKitCSSFilterValue.cpp b/Source/WebCore/css/WebKitCSSFilterValue.cpp
index f70b2673a..f1a1e0ea4 100644
--- a/Source/WebCore/css/WebKitCSSFilterValue.cpp
+++ b/Source/WebCore/css/WebKitCSSFilterValue.cpp
@@ -29,7 +29,7 @@
#if ENABLE(CSS_FILTERS)
#include "CSSValueList.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
@@ -113,7 +113,7 @@ PassRefPtr<WebKitCSSFilterValue> WebKitCSSFilterValue::cloneForCSSOM() const
void WebKitCSSFilterValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo);
}
diff --git a/Source/WebCore/css/WebKitCSSKeyframeRule.cpp b/Source/WebCore/css/WebKitCSSKeyframeRule.cpp
index 80069326f..bf3b8695b 100644
--- a/Source/WebCore/css/WebKitCSSKeyframeRule.cpp
+++ b/Source/WebCore/css/WebKitCSSKeyframeRule.cpp
@@ -26,10 +26,11 @@
#include "config.h"
#include "WebKitCSSKeyframeRule.h"
-#include "MemoryInstrumentation.h"
#include "PropertySetCSSStyleDeclaration.h"
#include "StylePropertySet.h"
+#include "WebCoreMemoryInstrumentation.h"
#include "WebKitCSSKeyframesRule.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -77,18 +78,20 @@ void StyleKeyframe::parseKeyString(const String& s, Vector<float>& keys)
String StyleKeyframe::cssText() const
{
- String result = keyText();
-
- result += " { ";
- result += m_properties->asText();
- result += "}";
-
- return result;
+ StringBuilder result;
+ result.append(keyText());
+ result.appendLiteral(" { ");
+ String decls = m_properties->asText();
+ result.append(decls);
+ if (!decls.isEmpty())
+ result.append(' ');
+ result.append('}');
+ return result.toString();
}
void StyleKeyframe::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_properties);
info.addInstrumentedMember(m_key);
}
@@ -115,7 +118,7 @@ CSSStyleDeclaration* WebKitCSSKeyframeRule::style() const
void WebKitCSSKeyframeRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_keyframe);
info.addInstrumentedMember(m_propertiesCSSOMWrapper);
diff --git a/Source/WebCore/css/WebKitCSSKeyframesRule.cpp b/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
index ca47f79bd..f8d08078d 100644
--- a/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
+++ b/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
@@ -29,9 +29,9 @@
#include "CSSParser.h"
#include "CSSRuleList.h"
#include "CSSStyleSheet.h"
-#include "MemoryInstrumentation.h"
#include "StylePropertySet.h"
#include "StyleSheet.h"
+#include "WebCoreMemoryInstrumentation.h"
#include "WebKitCSSKeyframeRule.h"
#include <wtf/text/StringBuilder.h>
@@ -89,7 +89,7 @@ int StyleRuleKeyframes::findKeyframeIndex(const String& key) const
void StyleRuleKeyframes::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedVector(m_keyframes);
info.addInstrumentedMember(m_name);
}
@@ -208,7 +208,7 @@ void WebKitCSSKeyframesRule::reattach(StyleRuleKeyframes* rule)
void WebKitCSSKeyframesRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_keyframesRule);
info.addInstrumentedVector(m_childRuleCSSOMWrappers);
diff --git a/Source/WebCore/css/WebKitCSSMatrix.h b/Source/WebCore/css/WebKitCSSMatrix.h
index 56b0a7bc0..5f7a5be84 100644
--- a/Source/WebCore/css/WebKitCSSMatrix.h
+++ b/Source/WebCore/css/WebKitCSSMatrix.h
@@ -26,10 +26,10 @@
#ifndef WebKitCSSMatrix_h
#define WebKitCSSMatrix_h
-#include "PlatformString.h"
#include "TransformationMatrix.h"
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
diff --git a/Source/WebCore/css/WebKitCSSMixFunctionValue.cpp b/Source/WebCore/css/WebKitCSSMixFunctionValue.cpp
index 7f8d27d85..3af687e76 100644
--- a/Source/WebCore/css/WebKitCSSMixFunctionValue.cpp
+++ b/Source/WebCore/css/WebKitCSSMixFunctionValue.cpp
@@ -30,7 +30,7 @@
#include "config.h"
#include "WebKitCSSMixFunctionValue.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
#if ENABLE(CSS_SHADERS)
@@ -58,7 +58,7 @@ PassRefPtr<WebKitCSSMixFunctionValue> WebKitCSSMixFunctionValue::cloneForCSSOM()
void WebKitCSSMixFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo);
}
diff --git a/Source/WebCore/css/WebKitCSSMixFunctionValue.h b/Source/WebCore/css/WebKitCSSMixFunctionValue.h
index af9794a19..439967d67 100644
--- a/Source/WebCore/css/WebKitCSSMixFunctionValue.h
+++ b/Source/WebCore/css/WebKitCSSMixFunctionValue.h
@@ -36,7 +36,9 @@
#include <wtf/PassRefPtr.h>
namespace WebCore {
-
+
+class MemoryObjectInfo;
+
class WebKitCSSMixFunctionValue : public CSSValueList {
public:
static PassRefPtr<WebKitCSSMixFunctionValue> create()
diff --git a/Source/WebCore/css/WebKitCSSRegionRule.cpp b/Source/WebCore/css/WebKitCSSRegionRule.cpp
index 2db2059f1..e64832f6b 100644
--- a/Source/WebCore/css/WebKitCSSRegionRule.cpp
+++ b/Source/WebCore/css/WebKitCSSRegionRule.cpp
@@ -110,7 +110,7 @@ void WebKitCSSRegionRule::reattach(StyleRuleRegion* rule)
void WebKitCSSRegionRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo);
info.addInstrumentedMember(m_regionRule);
info.addInstrumentedVector(m_childRuleCSSOMWrappers);
diff --git a/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp b/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp
index d2fbdf18c..e133c9221 100644
--- a/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp
+++ b/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp
@@ -30,7 +30,7 @@
#include "CSSParser.h"
#include "CachedResourceLoader.h"
#include "Document.h"
-#include "MemoryInstrumentation.h"
+#include "WebCoreMemoryInstrumentation.h"
namespace WebCore {
@@ -66,7 +66,7 @@ String WebKitCSSSVGDocumentValue::customCssText() const
void WebKitCSSSVGDocumentValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_url);
// FIXME: add m_document when cached resources are instrumented.
}
diff --git a/Source/WebCore/css/WebKitCSSShaderValue.cpp b/Source/WebCore/css/WebKitCSSShaderValue.cpp
index b89b1834e..2326999b0 100644
--- a/Source/WebCore/css/WebKitCSSShaderValue.cpp
+++ b/Source/WebCore/css/WebKitCSSShaderValue.cpp
@@ -35,9 +35,9 @@
#include "CachedResourceLoader.h"
#include "CSSParser.h"
#include "Document.h"
-#include "MemoryInstrumentation.h"
#include "StyleCachedShader.h"
#include "StylePendingShader.h"
+#include "WebCoreMemoryInstrumentation.h"
namespace WebCore {
@@ -82,7 +82,7 @@ String WebKitCSSShaderValue::customCssText() const
void WebKitCSSShaderValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addInstrumentedMember(m_url);
}
diff --git a/Source/WebCore/css/WebKitCSSTransformValue.cpp b/Source/WebCore/css/WebKitCSSTransformValue.cpp
index 8e196e5ac..2f86ad90e 100644
--- a/Source/WebCore/css/WebKitCSSTransformValue.cpp
+++ b/Source/WebCore/css/WebKitCSSTransformValue.cpp
@@ -27,10 +27,10 @@
#include "WebKitCSSTransformValue.h"
#include "CSSValueList.h"
-#include "MemoryInstrumentation.h"
-#include "PlatformString.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <wtf/PassRefPtr.h>
#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -107,7 +107,7 @@ PassRefPtr<WebKitCSSTransformValue> WebKitCSSTransformValue::cloneForCSSOM() con
void WebKitCSSTransformValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo);
}
diff --git a/Source/WebCore/css/html.css b/Source/WebCore/css/html.css
index c213d38d6..62d19cbb7 100644
--- a/Source/WebCore/css/html.css
+++ b/Source/WebCore/css/html.css
@@ -491,6 +491,8 @@ input::-webkit-datetime-edit-ampm-field {
-webkit-user-modify: read-only !important;
border: none;
padding: 0.15em;
+ display: inline-block;
+ text-align: center;
}
input::-webkit-datetime-edit-hour-field {
@@ -533,7 +535,7 @@ input::-webkit-datetime-edit-second-field {
/* Remove focus ring from fields and use highlight color */
input::-webkit-datetime-edit-ampm-field:focus,
input::-webkit-datetime-edit-hour-field:focus,
-input::-webkit-datetime-edit-millisecond-fiel:focus,
+input::-webkit-datetime-edit-millisecond-field:focus,
input::-webkit-datetime-edit-minute-field:focus,
input::-webkit-datetime-edit-second-field:focus {
background-color: highlight;
diff --git a/Source/WebCore/css/mathml.css b/Source/WebCore/css/mathml.css
index fa4288f51..25bb7baf6 100644
--- a/Source/WebCore/css/mathml.css
+++ b/Source/WebCore/css/mathml.css
@@ -12,9 +12,7 @@ math {
font-family: STIXGeneral, Symbol, "Times New Roman", sans-serif;
display: inline-block;
padding: 0px;
- margin: 0px;
text-align: left;
- vertical-align: baseline;
padding-left: 1px;
padding-right: 1px;
}
@@ -28,10 +26,9 @@ math[display="block"] {
margin-right: auto;
}
-mrow, mfenced {
+mo, mrow, mfenced, mfrac, msub, msup, msubsup, munder, mover, munderover, msqrt, mroot {
display: inline-block;
white-space: nowrap;
- vertical-align: baseline;
}
mfenced {
@@ -48,15 +45,6 @@ mi + mrow {
margin-left: 0.1em;
}
-mfrac {
- display: inline-block;
-}
-
-msub, msup {
- display: inline-block;
- vertical-align: baseline;
-}
-
msub > * + * {
vertical-align: sub;
font-size: 0.75em;
@@ -67,13 +55,7 @@ msup > * + * {
font-size: 0.75em;
}
-msubsup {
- display: inline-block;
- vertical-align: baseline;
-}
-
msubsup > * {
- margin: 0px;
padding: 0px;
}
@@ -81,22 +63,12 @@ msubsup > * + * {
font-size: 0.75em;
}
-munder, mover, munderover {
- display: inline-block;
- vertical-align: baseline;
-}
-
munderover > * + *, mover > * + *, munder > * + * {
font-size: 0.75em;
}
mo, mn, mi, mtext {
padding: 0px;
- margin: 0px;
-}
-
-mo {
- display: inline-block;
}
math > mo, mrow > mo, mfenced > mo {
@@ -136,7 +108,7 @@ math[mathsize="big"], mstyle[mathsize="big"], mo[mathsize="big"], mn[mathsize="b
}
annotation, annotation-xml {
- display:none;
+ display: none;
}
mphantom {
@@ -150,13 +122,7 @@ merror {
background-color: lightYellow;
}
-msqrt {
- display: inline-block;
- white-space: nowrap; /* for the anonymous RenderMathMLRow */
-}
-
mroot {
- display: inline-block;
position: relative;
}
diff --git a/Source/WebCore/css/mediaControlsChromium.css b/Source/WebCore/css/mediaControlsChromium.css
index 3a9f1455a..025c57901 100644
--- a/Source/WebCore/css/mediaControlsChromium.css
+++ b/Source/WebCore/css/mediaControlsChromium.css
@@ -178,6 +178,19 @@ input[type="range"]::-webkit-media-slider-thumb {
margin-right: -7px;
}
+audio::-webkit-media-controls-toggle-closed-captions-button, video::-webkit-media-controls-toggle-closed-captions-button {
+ -webkit-appearance: media-toggle-closed-captions-button;
+ display: -webkit-box;
+ border: none;
+ box-sizing: border-box;
+ width: 30px;
+ height: 30px;
+ line-height: 30px;
+ margin-left: -5px;
+ margin-right: 9px;
+ padding: 0;
+}
+
audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button {
-webkit-appearance: media-enter-fullscreen-button;
display: -webkit-box;