diff options
author | Moonchild <moonchild@palemoon.org> | 2021-03-26 17:19:27 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-03-26 17:19:27 +0000 |
commit | b969ea3b9ced3eac51cd94c3390742ab57a4e520 (patch) | |
tree | 29b84a9d4dabb6383ee00ea861aa486914406d09 /layout/svg | |
parent | 698b235b286f9e9d1121cd6d7c322772ce9babb9 (diff) | |
download | uxp-b969ea3b9ced3eac51cd94c3390742ab57a4e520.tar.gz |
Issue #1754 - Fix clip path overflow.
Resolves #1754.
Diffstat (limited to 'layout/svg')
-rw-r--r-- | layout/svg/nsCSSClipPathInstance.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/layout/svg/nsCSSClipPathInstance.cpp b/layout/svg/nsCSSClipPathInstance.cpp index e923eaa0e7..ac522c91fa 100644 --- a/layout/svg/nsCSSClipPathInstance.cpp +++ b/layout/svg/nsCSSClipPathInstance.cpp @@ -12,6 +12,7 @@ #include "mozilla/gfx/PathHelpers.h" #include "nsCSSRendering.h" #include "nsIFrame.h" +#include "nsMathUtils.h" #include "nsRenderingContext.h" #include "nsRuleNode.h" @@ -135,8 +136,6 @@ nsCSSClipPathInstance::CreateClipPathCircle(DrawTarget* aDrawTarget, const nsTArray<nsStyleCoord>& coords = basicShape->Coordinates(); MOZ_ASSERT(coords.Length() == 1, "wrong number of arguments"); - float referenceLength = sqrt((aRefBox.width * aRefBox.width + - aRefBox.height * aRefBox.height) / 2.0); nscoord r = 0; if (coords[0].GetUnit() == eStyleUnit_Enumerated) { nscoord horizontal, vertical; @@ -150,7 +149,12 @@ nsCSSClipPathInstance::CreateClipPathCircle(DrawTarget* aDrawTarget, r = horizontal < vertical ? horizontal : vertical; } } else { - r = nsRuleNode::ComputeCoordPercentCalc(coords[0], referenceLength); + // We resolve percent <shape-radius> value for circle() as defined here: + // https://drafts.csswg.org/css-shapes/#funcdef-circle + const double sqrt2 = std::sqrt(2.0); + double referenceLength = NS_hypot(aRefBox.width, aRefBox.height) / sqrt2; + r = nsRuleNode::ComputeCoordPercentCalc(coords[0], + NSToCoordRound(referenceLength)); } nscoord appUnitsPerDevPixel = |