Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / BasicShapeFunctions.cpp
index b2e5f4f..5bd3a01 100644 (file)
@@ -40,7 +40,7 @@
 
 namespace WebCore {
 
-static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle& style, const BasicShapeCenterCoordinate& center)
+static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle& style, const BasicShapeCenterCoordinate& center)
 {
     CSSValueID keyword = CSSValueInvalid;
     switch (center.keyword()) {
@@ -63,7 +63,7 @@ static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool
     return pool.createValue(Pair::create(pool.createIdentifierValue(keyword), pool.createValue(center.length(), style), Pair::DropIdenticalValues));
 }
 
-static PassRefPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(CSSValuePool& pool, const RenderStyle& style, const BasicShapeRadius& radius)
+static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(CSSValuePool& pool, const RenderStyle& style, const BasicShapeRadius& radius)
 {
     switch (radius.type()) {
     case BasicShapeRadius::Value:
@@ -168,6 +168,23 @@ PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle& style, const BasicSha
         basicShapeValue = rectangleValue.release();
         break;
     }
+    case BasicShape::BasicShapeInsetType: {
+        const BasicShapeInset* inset = static_cast<const BasicShapeInset*>(basicShape);
+        RefPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset::create();
+
+        insetValue->setTop(CSSPrimitiveValue::create(inset->top()));
+        insetValue->setRight(CSSPrimitiveValue::create(inset->right()));
+        insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom()));
+        insetValue->setLeft(CSSPrimitiveValue::create(inset->left()));
+
+        insetValue->setTopLeftRadius(CSSPrimitiveValue::create(inset->topLeftRadius()));
+        insetValue->setTopRightRadius(CSSPrimitiveValue::create(inset->topRightRadius()));
+        insetValue->setBottomRightRadius(CSSPrimitiveValue::create(inset->bottomRightRadius()));
+        insetValue->setBottomLeftRadius(CSSPrimitiveValue::create(inset->bottomLeftRadius()));
+
+        basicShapeValue = insetValue.release();
+        break;
+    }
     default:
         break;
     }
@@ -180,9 +197,20 @@ PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle& style, const BasicSha
 
 static Length convertToLength(const StyleResolverState& state, CSSPrimitiveValue* value)
 {
+    if (!value)
+        return Length(0, Fixed);
     return value->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData());
 }
 
+static LengthSize convertToLengthSize(const StyleResolverState& state, CSSPrimitiveValue* value)
+{
+    if (!value)
+        return LengthSize(Length(0, Fixed), Length(0, Fixed));
+
+    Pair* pair = value->getPairValue();
+    return LengthSize(convertToLength(state, pair->first()), convertToLength(state, pair->second()));
+}
+
 static BasicShapeCenterCoordinate convertToCenterCoordinate(const StyleResolverState& state, CSSPrimitiveValue* value)
 {
     if (Pair* pair = value->getPairValue()) {
@@ -210,7 +238,7 @@ static BasicShapeCenterCoordinate convertToCenterCoordinate(const StyleResolverS
     return BasicShapeCenterCoordinate(convertToLength(state, value));
 }
 
-static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& state, PassRefPtr<CSSPrimitiveValue> radius)
+static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& state, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius)
 {
     if (!radius)
         return BasicShapeRadius(BasicShapeRadius::ClosestSide);
@@ -347,6 +375,23 @@ PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const
         basicShape = rect.release();
         break;
     }
+    case CSSBasicShape::CSSBasicShapeInsetType: {
+        const CSSBasicShapeInset* rectValue = static_cast<const CSSBasicShapeInset* >(basicShapeValue);
+        RefPtr<BasicShapeInset> rect = BasicShapeInset::create();
+
+        rect->setTop(convertToLength(state, rectValue->top()));
+        rect->setRight(convertToLength(state, rectValue->right()));
+        rect->setBottom(convertToLength(state, rectValue->bottom()));
+        rect->setLeft(convertToLength(state, rectValue->left()));
+
+        rect->setTopLeftRadius(convertToLengthSize(state, rectValue->topLeftRadius()));
+        rect->setTopRightRadius(convertToLengthSize(state, rectValue->topRightRadius()));
+        rect->setBottomRightRadius(convertToLengthSize(state, rectValue->bottomRightRadius()));
+        rect->setBottomLeftRadius(convertToLengthSize(state, rectValue->bottomLeftRadius()));
+
+        basicShape = rect.release();
+        break;
+    }
     default:
         break;
     }