зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1246762 - Add support for inset() in clip-path ; r=dholbert
MozReview-Commit-ID: 9AhkTu9gVVm --HG-- extra : rebase_source : d9ee4f4b4f3654203d2cd1c0f915eea04374d5d0
This commit is contained in:
Родитель
e95d6d0b9c
Коммит
b83e274dee
|
@ -101,7 +101,7 @@ nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget)
|
|||
case StyleBasicShapeType::Polygon:
|
||||
return CreateClipPathPolygon(aDrawTarget, r);
|
||||
case StyleBasicShapeType::Inset:
|
||||
// XXXkrit support all basic shapes
|
||||
return CreateClipPathInset(aDrawTarget, r);
|
||||
break;
|
||||
default:
|
||||
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected shape type");
|
||||
|
@ -239,3 +239,41 @@ nsCSSClipPathInstance::CreateClipPathPolygon(DrawTarget* aDrawTarget,
|
|||
builder->Close();
|
||||
return builder->Finish();
|
||||
}
|
||||
|
||||
already_AddRefed<Path>
|
||||
nsCSSClipPathInstance::CreateClipPathInset(DrawTarget* aDrawTarget,
|
||||
const nsRect& aRefBox)
|
||||
{
|
||||
StyleBasicShape* basicShape = mClipPathStyle.GetBasicShape();
|
||||
const nsTArray<nsStyleCoord>& coords = basicShape->Coordinates();
|
||||
MOZ_ASSERT(coords.Length() == 4, "wrong number of arguments");
|
||||
|
||||
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
|
||||
|
||||
nscoord appUnitsPerDevPixel =
|
||||
mTargetFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
|
||||
nsMargin inset(nsRuleNode::ComputeCoordPercentCalc(coords[0], aRefBox.height),
|
||||
nsRuleNode::ComputeCoordPercentCalc(coords[1], aRefBox.width),
|
||||
nsRuleNode::ComputeCoordPercentCalc(coords[2], aRefBox.height),
|
||||
nsRuleNode::ComputeCoordPercentCalc(coords[3], aRefBox.width));
|
||||
|
||||
nsRect insetRect(aRefBox);
|
||||
insetRect.Deflate(inset);
|
||||
const Rect insetRectPixels = NSRectToRect(insetRect, appUnitsPerDevPixel);
|
||||
const nsStyleCorners& radius = basicShape->GetRadius();
|
||||
|
||||
nscoord appUnitsRadii[8];
|
||||
|
||||
if (nsIFrame::ComputeBorderRadii(radius, insetRect.Size(), aRefBox.Size(),
|
||||
Sides(), appUnitsRadii)) {
|
||||
RectCornerRadii corners;
|
||||
nsCSSRendering::ComputePixelRadii(appUnitsRadii,
|
||||
appUnitsPerDevPixel, &corners);
|
||||
|
||||
AppendRoundedRectToPath(builder, insetRectPixels, corners, true);
|
||||
} else {
|
||||
AppendRectToPath(builder, insetRectPixels, true);
|
||||
}
|
||||
return builder->Finish();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ private:
|
|||
already_AddRefed<Path> CreateClipPathPolygon(DrawTarget* aDrawTarget,
|
||||
const nsRect& aRefBox);
|
||||
|
||||
already_AddRefed<Path> CreateClipPathInset(DrawTarget* aDrawTarget,
|
||||
const nsRect& aRefBox);
|
||||
/**
|
||||
* The frame for the element that is currently being clipped.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче