Merge pull request #2102 from NativeScript/clip-path

clip-path support added
This commit is contained in:
Vladimir Enchev
2016-05-16 11:27:19 +03:00
10 changed files with 314 additions and 35 deletions

View File

@ -85,4 +85,4 @@
</TabViewItem> </TabViewItem>
</TabView.items> </TabView.items>
</TabView> </TabView>
</Page> </Page>

View File

@ -0,0 +1,9 @@
<Page>
<GridLayout rows="*,*,*,*,*">
<Button text="circle" style="background-color: red; border-width:2; border-color: blue; clip-path: circle(100% at 50% 50%);"/>
<Button text="ellipse" style="background-color: orange; border-width:2; border-color: green; clip-path: ellipse(50% 50% at 50% 50%);" row="1" />
<Button text="rect" style="background-color: red; border-width:2; border-color: blue; clip-path: rect(0, 0, 100%, 100%);" row="2" />
<Button text="polygon" style="background-color: magenta; border-width:2; border-color: red; clip-path: polygon(20% 0%, 0% 20%, 30% 50%, 0% 80%, 20% 100%, 50% 70%, 80% 100%, 100% 80%, 70% 50%, 100% 20%, 80% 0%, 50% 30%);" row="3" />
<Button text="image polygon" style="background-image: url('https://media-cdn.tripadvisor.com/media/photo-s/03/9b/2f/ce/maldives.jpg'); border-width:2; border-color: red; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);" row="4" />
</GridLayout>
</Page>

View File

@ -742,6 +742,7 @@ export class ViewStyler implements style.Styler {
style.registerHandler(style.borderWidthProperty, borderHandler); style.registerHandler(style.borderWidthProperty, borderHandler);
style.registerHandler(style.borderColorProperty, borderHandler); style.registerHandler(style.borderColorProperty, borderHandler);
style.registerHandler(style.borderRadiusProperty, borderHandler); style.registerHandler(style.borderRadiusProperty, borderHandler);
style.registerHandler(style.clipPathProperty, borderHandler);
style.registerHandler(style.nativeLayoutParamsProperty, new style.StylePropertyChangedHandler( style.registerHandler(style.nativeLayoutParamsProperty, new style.StylePropertyChangedHandler(
ViewStyler.setNativeLayoutParamsProperty, ViewStyler.setNativeLayoutParamsProperty,

View File

@ -567,7 +567,7 @@ export class ViewStyler implements style.Styler {
private static getTranslateYProperty(view: View): any { private static getTranslateYProperty(view: View): any {
return view.translateY; return view.translateY;
} }
//z-index //z-index
private static setZIndexProperty(view: View, newValue: any) { private static setZIndexProperty(view: View, newValue: any) {
view.ios.layer.zPosition = newValue; view.ios.layer.zPosition = newValue;
@ -580,13 +580,41 @@ export class ViewStyler implements style.Styler {
private static getZIndexProperty(view: View): any { private static getZIndexProperty(view: View): any {
return view.ios.layer.zPosition; return view.ios.layer.zPosition;
} }
//Clip-path methods
private static setClipPathProperty(view: View, newValue: any) {
var nativeView: UIView = <UIView>view._nativeView;
if (nativeView) {
ensureBackground();
var updateSuspended = view._isPresentationLayerUpdateSuspeneded();
if (!updateSuspended) {
CATransaction.begin();
}
nativeView.backgroundColor = background.ios.createBackgroundUIColor(view);
if (!updateSuspended) {
CATransaction.commit();
}
}
}
private static resetClipPathProperty(view: View, nativeValue: any) {
var nativeView: UIView = <UIView>view._nativeView;
if (nativeView) {
// TODO: Check how to reset.
}
}
public static registerHandlers() { public static registerHandlers() {
style.registerHandler(style.backgroundInternalProperty, new style.StylePropertyChangedHandler( style.registerHandler(style.backgroundInternalProperty, new style.StylePropertyChangedHandler(
ViewStyler.setBackgroundInternalProperty, ViewStyler.setBackgroundInternalProperty,
ViewStyler.resetBackgroundInternalProperty, ViewStyler.resetBackgroundInternalProperty,
ViewStyler.getNativeBackgroundInternalValue)); ViewStyler.getNativeBackgroundInternalValue));
style.registerHandler(style.clipPathProperty, new style.StylePropertyChangedHandler(
ViewStyler.setClipPathProperty,
ViewStyler.resetClipPathProperty));
style.registerHandler(style.visibilityProperty, new style.StylePropertyChangedHandler( style.registerHandler(style.visibilityProperty, new style.StylePropertyChangedHandler(
ViewStyler.setVisibilityProperty, ViewStyler.setVisibilityProperty,
ViewStyler.resetVisibilityProperty)); ViewStyler.resetVisibilityProperty));

View File

@ -3,6 +3,7 @@ import colorModule = require("color");
import enums = require("ui/enums"); import enums = require("ui/enums");
import definition = require("ui/styling/background"); import definition = require("ui/styling/background");
import cssValue = require("css-value"); import cssValue = require("css-value");
import utils = require("utils/utils");
import * as typesModule from "utils/types"; import * as typesModule from "utils/types";
var types: typeof typesModule; var types: typeof typesModule;
@ -242,3 +243,18 @@ export class Background implements definition.Background {
colorModule.Color.equals(value1.color, value2.color); colorModule.Color.equals(value1.color, value2.color);
} }
} }
export function cssValueToDevicePixels(source: string, total: number): number {
var result;
source = source.trim();
if (source.indexOf("px") !== -1) {
result = parseFloat(source.replace("px", ""));
}
else if (source.indexOf("%") !== -1 && total > 0) {
result = (parseFloat(source.replace("%", "")) / 100) * utils.layout.toDeviceIndependentPixels(total);
} else {
result = parseFloat(source);
}
return utils.layout.toDevicePixels(result);
}

View File

@ -42,12 +42,23 @@ export module ad {
private _borderWidth: number; private _borderWidth: number;
private _cornerRadius: number; private _cornerRadius: number;
private _borderColor: number; private _borderColor: number;
private _clipPath: string;
constructor() { constructor() {
super(); super();
return global.__native(this); return global.__native(this);
} }
get clipPath(): string {
return this._clipPath;
}
set clipPath(value: string) {
if (this._clipPath !== value) {
this._clipPath = value;
this.invalidateSelf();
}
}
get borderWidth(): number { get borderWidth(): number {
return this._borderWidth; return this._borderWidth;
} }
@ -101,7 +112,7 @@ export module ad {
let backgroundBoundsF = new android.graphics.RectF(bounds.left + backoffAntialias, bounds.top + backoffAntialias, bounds.right - backoffAntialias, bounds.bottom - backoffAntialias); let backgroundBoundsF = new android.graphics.RectF(bounds.left + backoffAntialias, bounds.top + backoffAntialias, bounds.right - backoffAntialias, bounds.bottom - backoffAntialias);
let outerRadius = this._cornerRadius * this._density; let outerRadius = this._cornerRadius * this._density;
// draw background // draw background
if (this.background.color && this.background.color.android) { if (this.background.color && this.background.color.android) {
let backgroundColorPaint = new android.graphics.Paint(); let backgroundColorPaint = new android.graphics.Paint();
@ -109,7 +120,11 @@ export module ad {
backgroundColorPaint.setColor(this.background.color.android); backgroundColorPaint.setColor(this.background.color.android);
backgroundColorPaint.setAntiAlias(true); backgroundColorPaint.setAntiAlias(true);
canvas.drawRoundRect(backgroundBoundsF, outerRadius, outerRadius, backgroundColorPaint); if (this.clipPath) {
drawClipPath(this.clipPath, canvas, backgroundColorPaint, backgroundBoundsF);
} else {
canvas.drawRoundRect(backgroundBoundsF, outerRadius, outerRadius, backgroundColorPaint);
}
} }
// draw image // draw image
@ -139,21 +154,25 @@ export module ad {
params.posX = params.repeatX ? 0 : params.posX; params.posX = params.repeatX ? 0 : params.posX;
params.posY = params.repeatY ? 0 : params.posY; params.posY = params.repeatY ? 0 : params.posY;
let supportsPathOp = android.os.Build.VERSION.SDK_INT >= 19; if (this.clipPath) {
if (supportsPathOp) { drawClipPath(this.clipPath, canvas, backgroundImagePaint, backgroundBoundsF);
// Path.Op can be used in API level 19+ to achieve the perfect geometry.
let backgroundPath = new android.graphics.Path();
backgroundPath.addRoundRect(backgroundBoundsF, outerRadius, outerRadius, android.graphics.Path.Direction.CCW);
let backgroundNoRepeatPath = new android.graphics.Path();
backgroundNoRepeatPath.addRect(params.posX, params.posY, params.posX + imageWidth, params.posY + imageHeight, android.graphics.Path.Direction.CCW);
(<any>backgroundPath).op(backgroundNoRepeatPath, (<any>android).graphics.Path.Op.INTERSECT);
canvas.drawPath(backgroundPath, backgroundImagePaint);
} else { } else {
// Clipping here will not be antialiased but at least it won't shine through the rounded corners. let supportsPathOp = android.os.Build.VERSION.SDK_INT >= 19;
canvas.save(); if (supportsPathOp) {
canvas.clipRect(params.posX, params.posY, params.posX + imageWidth, params.posY + imageHeight); // Path.Op can be used in API level 19+ to achieve the perfect geometry.
canvas.drawRoundRect(backgroundBoundsF, outerRadius, outerRadius, backgroundImagePaint); let backgroundPath = new android.graphics.Path();
canvas.restore(); backgroundPath.addRoundRect(backgroundBoundsF, outerRadius, outerRadius, android.graphics.Path.Direction.CCW);
let backgroundNoRepeatPath = new android.graphics.Path();
backgroundNoRepeatPath.addRect(params.posX, params.posY, params.posX + imageWidth, params.posY + imageHeight, android.graphics.Path.Direction.CCW);
(<any>backgroundPath).op(backgroundNoRepeatPath, (<any>android).graphics.Path.Op.INTERSECT);
canvas.drawPath(backgroundPath, backgroundImagePaint);
} else {
// Clipping here will not be antialiased but at least it won't shine through the rounded corners.
canvas.save();
canvas.clipRect(params.posX, params.posY, params.posX + imageWidth, params.posY + imageHeight);
canvas.drawRoundRect(backgroundBoundsF, outerRadius, outerRadius, backgroundImagePaint);
canvas.restore();
}
} }
} }
@ -164,23 +183,29 @@ export module ad {
borderPaint.setColor(this._borderColor); borderPaint.setColor(this._borderColor);
borderPaint.setAntiAlias(true); borderPaint.setAntiAlias(true);
if (outerRadius <= 0) { if (this.clipPath) {
borderPaint.setStyle(android.graphics.Paint.Style.STROKE); borderPaint.setStyle(android.graphics.Paint.Style.STROKE);
borderPaint.setStrokeWidth(borderWidth); borderPaint.setStrokeWidth(borderWidth);
canvas.drawRect(middleBoundsF, borderPaint); drawClipPath(this.clipPath, canvas, borderPaint, backgroundBoundsF);
} else if (outerRadius >= borderWidth) {
borderPaint.setStyle(android.graphics.Paint.Style.STROKE);
borderPaint.setStrokeWidth(borderWidth);
let middleRadius = Math.max(0, outerRadius - halfBorderWidth);
canvas.drawRoundRect(middleBoundsF, middleRadius, middleRadius, borderPaint);
} else { } else {
let borderPath = new android.graphics.Path(); if (outerRadius <= 0) {
let borderOuterBoundsF = new android.graphics.RectF(bounds.left, bounds.top, bounds.right, bounds.bottom); borderPaint.setStyle(android.graphics.Paint.Style.STROKE);
borderPath.addRoundRect(borderOuterBoundsF, outerRadius, outerRadius, android.graphics.Path.Direction.CCW); borderPaint.setStrokeWidth(borderWidth);
let borderInnerBoundsF = new android.graphics.RectF(bounds.left + borderWidth, bounds.top + borderWidth, bounds.right - borderWidth, bounds.bottom - borderWidth); canvas.drawRect(middleBoundsF, borderPaint);
borderPath.addRect(borderInnerBoundsF, android.graphics.Path.Direction.CW); } else if (outerRadius >= borderWidth) {
borderPaint.setStyle(android.graphics.Paint.Style.FILL); borderPaint.setStyle(android.graphics.Paint.Style.STROKE);
canvas.drawPath(borderPath, borderPaint); borderPaint.setStrokeWidth(borderWidth);
let middleRadius = Math.max(0, outerRadius - halfBorderWidth);
canvas.drawRoundRect(middleBoundsF, middleRadius, middleRadius, borderPaint);
} else {
let borderPath = new android.graphics.Path();
let borderOuterBoundsF = new android.graphics.RectF(bounds.left, bounds.top, bounds.right, bounds.bottom);
borderPath.addRoundRect(borderOuterBoundsF, outerRadius, outerRadius, android.graphics.Path.Direction.CCW);
let borderInnerBoundsF = new android.graphics.RectF(bounds.left + borderWidth, bounds.top + borderWidth, bounds.right - borderWidth, bounds.bottom - borderWidth);
borderPath.addRect(borderInnerBoundsF, android.graphics.Path.Direction.CW);
borderPaint.setStyle(android.graphics.Paint.Style.FILL);
canvas.drawPath(borderPath, borderPaint);
}
} }
} }
} }
@ -209,6 +234,8 @@ export module ad {
ensureBorderDrawable(); ensureBorderDrawable();
ensureLazyRequires(); ensureLazyRequires();
var clipPathValue = v.style._getValue(style.clipPathProperty);
var backgroundValue = v.style._getValue(style.backgroundInternalProperty); var backgroundValue = v.style._getValue(style.backgroundInternalProperty);
var borderWidth = v.borderWidth; var borderWidth = v.borderWidth;
var bkg = <any>nativeView.getBackground(); var bkg = <any>nativeView.getBackground();
@ -220,7 +247,7 @@ export module ad {
let backgroundColor = bkg.backgroundColor = v.style._getValue(style.backgroundColorProperty).android; let backgroundColor = bkg.backgroundColor = v.style._getValue(style.backgroundColorProperty).android;
bkg.setColorFilter(backgroundColor, android.graphics.PorterDuff.Mode.SRC_IN); bkg.setColorFilter(backgroundColor, android.graphics.PorterDuff.Mode.SRC_IN);
bkg.backgroundColor = backgroundColor; bkg.backgroundColor = backgroundColor;
} else if (v.borderWidth !== 0 || v.borderRadius !== 0 || !backgroundValue.isEmpty()) { } else if (v.borderWidth !== 0 || v.borderRadius !== 0 || !backgroundValue.isEmpty() || !clipPathValue.isEmpty()) {
if (!(bkg instanceof BorderDrawableClass)) { if (!(bkg instanceof BorderDrawableClass)) {
bkg = new BorderDrawableClass(); bkg = new BorderDrawableClass();
@ -236,6 +263,7 @@ export module ad {
bkg.cornerRadius = v.borderRadius; bkg.cornerRadius = v.borderRadius;
bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT; bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT;
bkg.background = backgroundValue; bkg.background = backgroundValue;
bkg.clipPath = clipPathValue;
if (getSDK() < 18) { if (getSDK() < 18) {
// Switch to software because of unsupported canvas methods if hardware acceleration is on: // Switch to software because of unsupported canvas methods if hardware acceleration is on:
@ -274,3 +302,66 @@ export module ad {
); );
} }
} }
function drawClipPath(clipPath: string, canvas: android.graphics.Canvas, paint: android.graphics.Paint, bounds: android.graphics.RectF) {
var functionName = clipPath.substring(0, clipPath.indexOf("("));
var value = clipPath.replace(`${functionName}(`, "").replace(")", "");
if (functionName === "rect") {
var arr = value.split(/[\s]+/);
var top = common.cssValueToDevicePixels(arr[0], bounds.top);
var left = common.cssValueToDevicePixels(arr[1], bounds.left);
var bottom = common.cssValueToDevicePixels(arr[2], bounds.bottom);
var right = common.cssValueToDevicePixels(arr[3], bounds.right);
canvas.drawRect(left, top, right, bottom, paint);
} else if (functionName === "circle") {
var arr = value.split(/[\s]+/);
var radius = common.cssValueToDevicePixels(arr[0], (bounds.width() > bounds.height() ? bounds.height() : bounds.width()) / 2);
var y = common.cssValueToDevicePixels(arr[2], bounds.height());
var x = common.cssValueToDevicePixels(arr[3], bounds.width());
canvas.drawCircle(x, y, radius, paint);
} else if (functionName === "ellipse") {
var arr = value.split(/[\s]+/);
var rX = common.cssValueToDevicePixels(arr[0], bounds.right);
var rY = common.cssValueToDevicePixels(arr[1], bounds.bottom);
var cX = common.cssValueToDevicePixels(arr[3], bounds.right);
var cY = common.cssValueToDevicePixels(arr[4], bounds.bottom);
var left = cX - rX;
var top = cY - rY;
var right = (rX * 2) + left;
var bottom = (rY * 2) + top;
canvas.drawOval(new android.graphics.RectF(left, top, right, bottom), paint);
} else if (functionName === "polygon") {
var path = new android.graphics.Path();
var firstPoint: view.Point;
var arr = value.split(/[,]+/);
for (let i = 0; i < arr.length; i++) {
let xy = arr[i].trim().split(/[\s]+/);
let point: view.Point = {
x: common.cssValueToDevicePixels(xy[0], bounds.width()),
y: common.cssValueToDevicePixels(xy[1], bounds.height())
};
if (!firstPoint) {
firstPoint = point;
path.moveTo(point.x, point.y);
}
path.lineTo(point.x, point.y);
}
path.lineTo(firstPoint.x, firstPoint.y);
canvas.drawPath(path, paint);
}
}

View File

@ -13,11 +13,16 @@ function ensureStyle() {
export module ios { export module ios {
export function createBackgroundUIColor(view: viewModule.View, flip?: boolean): UIColor { export function createBackgroundUIColor(view: viewModule.View, flip?: boolean): UIColor {
if(!view._nativeView){ if (!view._nativeView) {
return undefined; return undefined;
} }
ensureStyle(); ensureStyle();
var background = <common.Background> view.style._getValue(style.backgroundInternalProperty);
if (view.style.clipPath) {
drawClipPath(view);
}
var background = <common.Background>view.style._getValue(style.backgroundInternalProperty);
if (!background || background.isEmpty()) { if (!background || background.isEmpty()) {
return undefined; return undefined;
@ -98,3 +103,103 @@ export module ios {
return flippedImage; return flippedImage;
} }
} }
function drawClipPath(view: viewModule.View) {
var path: any;
var nativeView = <UIView>view._nativeView;
var bounds = {
left: nativeView.bounds.origin.x,
top: nativeView.bounds.origin.y,
bottom: nativeView.bounds.size.height,
right: nativeView.bounds.size.width
};
if (bounds.right === 0 || bounds.bottom === 0) {
return;
}
var clipPath = view.style.clipPath;
var functionName = clipPath.substring(0, clipPath.indexOf("("));
var value = clipPath.replace(`${functionName}(`, "").replace(")", "");
if (functionName === "rect") {
var arr = value.split(/[\s]+/);
var top = common.cssValueToDevicePixels(arr[0], bounds.top);
var left = common.cssValueToDevicePixels(arr[1], bounds.left);
var bottom = common.cssValueToDevicePixels(arr[2], bounds.bottom);
var right = common.cssValueToDevicePixels(arr[3], bounds.right);
path = UIBezierPath.bezierPathWithRect(CGRectMake(left, top, right, bottom)).CGPath;
} else if (functionName === "circle") {
var arr = value.split(/[\s]+/);
var radius = common.cssValueToDevicePixels(arr[0], (bounds.right > bounds.bottom ? bounds.bottom : bounds.right) / 2);
var y = common.cssValueToDevicePixels(arr[2], bounds.bottom);
var x = common.cssValueToDevicePixels(arr[3], bounds.right);
path = UIBezierPath.bezierPathWithArcCenterRadiusStartAngleEndAngleClockwise(CGPointMake(x, y), radius, 0, 360, true).CGPath;
} else if (functionName === "ellipse") {
var arr = value.split(/[\s]+/);
var rX = common.cssValueToDevicePixels(arr[0], bounds.right);
var rY = common.cssValueToDevicePixels(arr[1], bounds.bottom);
var cX = common.cssValueToDevicePixels(arr[3], bounds.right);
var cY = common.cssValueToDevicePixels(arr[4], bounds.bottom);
var left = cX - rX;
var top = cY - rY;
var width = rX * 2;
var height = rY * 2;
path = UIBezierPath.bezierPathWithOvalInRect(CGRectMake(left, top, width, height)).CGPath;
} else if (functionName === "polygon") {
path = CGPathCreateMutable()
var firstPoint: viewModule.Point;
var arr = value.split(/[,]+/);
for (let i = 0; i < arr.length; i++) {
let xy = arr[i].trim().split(/[\s]+/);
let point: viewModule.Point = {
x: common.cssValueToDevicePixels(xy[0], bounds.right),
y: common.cssValueToDevicePixels(xy[1], bounds.bottom)
};
if (!firstPoint) {
firstPoint = point;
CGPathMoveToPoint(path, null, point.x, point.y)
}
CGPathAddLineToPoint(path, null, point.x, point.y)
}
CGPathAddLineToPoint(path, null, firstPoint.x, firstPoint.y)
}
if (path) {
var shape = CAShapeLayer.layer();
shape.path = path;
nativeView.layer.mask = shape;
nativeView.clipsToBounds = true;
if (view.borderWidth > 0 && view.borderColor) {
var borderLayer = CAShapeLayer.layer();
borderLayer.path = path;
borderLayer.lineWidth = view.borderWidth * 2;
borderLayer.strokeColor = view.borderColor.ios.CGColor;
borderLayer.fillColor = UIColor.clearColor().CGColor;
borderLayer.frame = nativeView.bounds;
nativeView.layer.borderColor = undefined;
nativeView.layer.borderWidth = 0;
nativeView.layer.addSublayer(borderLayer);
}
}
}

View File

@ -75,6 +75,7 @@ declare module "ui/styling/style" {
public horizontalAlignment: string; public horizontalAlignment: string;
public verticalAlignment: string; public verticalAlignment: string;
public visibility: string; public visibility: string;
public clipPath: string;
public opacity: number; public opacity: number;
public whiteSpace: string; public whiteSpace: string;
public letterSpacing: number; public letterSpacing: number;
@ -111,6 +112,7 @@ declare module "ui/styling/style" {
export var borderColorProperty: styleProperty.Property; export var borderColorProperty: styleProperty.Property;
export var borderWidthProperty: styleProperty.Property; export var borderWidthProperty: styleProperty.Property;
export var borderRadiusProperty: styleProperty.Property; export var borderRadiusProperty: styleProperty.Property;
export var clipPathProperty: styleProperty.Property;
export var backgroundInternalProperty: styleProperty.Property; export var backgroundInternalProperty: styleProperty.Property;
export var fontSizeProperty: styleProperty.Property; export var fontSizeProperty: styleProperty.Property;
export var fontFamilyProperty: styleProperty.Property; export var fontFamilyProperty: styleProperty.Property;

View File

@ -403,6 +403,13 @@ function isPaddingValid(value: number): boolean {
return isFinite(value) && !isNaN(value) && value >= 0; return isFinite(value) && !isNaN(value) && value >= 0;
} }
var supportedPaths = ["rect", "circle", "ellipse", "polygon"];
function isClipPathValid(value: string): boolean {
var functionName = value.substring(0, value.indexOf("(")).trim();
return supportedPaths.indexOf(functionName) !== -1 || value === "";
}
function isMarginValid(value: number): boolean { function isMarginValid(value: number): boolean {
var result = convertToPercentHelper(value); var result = convertToPercentHelper(value);
if (result.isError) { if (result.isError) {
@ -590,6 +597,13 @@ export class Style extends DependencyObservable implements styling.Style {
this._setValue(borderRadiusProperty, value); this._setValue(borderRadiusProperty, value);
} }
get clipPath(): string {
return this._getValue(clipPathProperty);
}
set clipPath(value: string) {
this._setValue(clipPathProperty, value);
}
get fontSize(): number { get fontSize(): number {
return this._getValue(fontSizeProperty); return this._getValue(fontSizeProperty);
} }
@ -880,6 +894,11 @@ export class Style extends DependencyObservable implements styling.Style {
if (!(<background.Background>this._getValue(backgroundInternalProperty)).isEmpty()) { if (!(<background.Background>this._getValue(backgroundInternalProperty)).isEmpty()) {
this._applyProperty(backgroundInternalProperty, this._getValue(backgroundInternalProperty)); this._applyProperty(backgroundInternalProperty, this._getValue(backgroundInternalProperty));
} }
var clipPathPropertyValue = this._getValue(clipPathProperty);
if (types.isString(clipPathPropertyValue) && clipPathPropertyValue !== "") {
this._applyProperty(clipPathProperty, clipPathPropertyValue);
}
} }
private _applyProperty(property: Property, newValue: any) { private _applyProperty(property: Property, newValue: any) {
@ -1048,6 +1067,9 @@ export var borderWidthProperty = new styleProperty.Property("borderWidth", "bord
export var borderRadiusProperty = new styleProperty.Property("borderRadius", "border-radius", export var borderRadiusProperty = new styleProperty.Property("borderRadius", "border-radius",
new PropertyMetadata(0, AffectsLayout, null, isPaddingValid), converters.numberConverter); new PropertyMetadata(0, AffectsLayout, null, isPaddingValid), converters.numberConverter);
export var clipPathProperty = new styleProperty.Property("clipPath", "clip-path",
new PropertyMetadata(undefined, AffectsLayout, null, isClipPathValid));
export var backgroundInternalProperty = new styleProperty.Property("_backgroundInternal", "_backgroundInternal", export var backgroundInternalProperty = new styleProperty.Property("_backgroundInternal", "_backgroundInternal",
new PropertyMetadata(background.Background.default, PropertyMetadataSettings.None, undefined, undefined, background.Background.equals)); new PropertyMetadata(background.Background.default, PropertyMetadataSettings.None, undefined, undefined, background.Background.equals));

View File

@ -82,6 +82,11 @@
* Gets or sets the border-radius style property. * Gets or sets the border-radius style property.
*/ */
borderRadius: number; borderRadius: number;
/**
* Gets or sets the clip-path style property.
*/
clipPath: string;
/** /**
* Gets or sets font-size style property. * Gets or sets font-size style property.