Bug 1546636 - Should consider geometry box type r=longsonr
authorviolet <violet.bugreport@gmail.com>
Thu, 25 Apr 2019 19:56:15 +0000
changeset 530227 54dcd30fb687720d349337ec93817a6ccb2d1079
parent 530226 bc11fcee57413b33a88ae49a9e89d0e842a09099
child 530228 82d825105204245bb27e1258386b43c22df19774
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs1546636, 1289011
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546636 - Should consider geometry box type r=longsonr Geometry box was implemented long ago in Bug 1289011. But during some refactoring, the existence of geometry box was overlooked. We add back its support. Differential Revision: https://phabricator.services.mozilla.com/D28815
layout/reftests/svg/clipPath-fill-box-ref.html
layout/reftests/svg/clipPath-fill-box.html
layout/reftests/svg/reftest.list
layout/svg/nsCSSClipPathInstance.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/clipPath-fill-box-ref.html
@@ -0,0 +1,3 @@
+<svg style="width: 400px; height: 400px">
+  <rect width="200" height="200" fill="purple"></rect>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/clipPath-fill-box.html
@@ -0,0 +1,3 @@
+<svg style="width: 400px; height: 400px">
+  <rect width="200" height="200" fill="purple" style="clip-path: fill-box"></rect>
+</svg>
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -76,16 +76,17 @@ fuzzy-if(/^Windows\x20NT\x2010\.0/.test(
 == clipPath-basic-03.svg pass.svg
 == clipPath-basic-04.svg pass.svg
 == clipPath-basic-05.svg pass.svg
 == clipPath-basic-06.svg pass.svg
 == clipPath-basic-07.svg pass.svg
 == clipPath-basic-08.svg pass.svg
 == clipPath-basic-shape-transform.html clipPath-basic-shape-transform-ref.html
 == clipPath-css-transform.html clipPath-css-transform-ref.html
+== clipPath-fill-box.html clipPath-fill-box-ref.html
 == clipPath-on-outflowElement-01a.html clipPath-on-outflowElement-01-ref.html
 == clipPath-on-outflowElement-01b.html clipPath-on-outflowElement-01-ref.html
 fuzzy(0-1,0-32400) == clipPath-on-outflowElement-02a.html clipPath-on-outflowElement-02-ref.html
 fuzzy(0-1,0-32400) == clipPath-on-outflowElement-02b.html clipPath-on-outflowElement-02-ref.html
 == clipPath-polygon-01.svg pass.svg
 == clipPath-polygon-elementFromPoint-01.svg pass.svg
 != clipPath-on-thin-object.svg about:blank
 == clipPath-winding-01.svg pass.svg
--- a/layout/svg/nsCSSClipPathInstance.cpp
+++ b/layout/svg/nsCSSClipPathInstance.cpp
@@ -100,23 +100,24 @@ already_AddRefed<Path> nsCSSClipPathInst
   gfxRect rr(r.x, r.y, r.width, r.height);
   rr.Scale(1.0 / AppUnitsPerCSSPixel());
   rr = aTransform.TransformRect(rr);
   rr.Scale(appUnitsPerDevPixel);
   rr.Round();
 
   r = nsRect(int(rr.x), int(rr.y), int(rr.width), int(rr.height));
 
-  if (mClipPathStyle.GetType() != StyleShapeSourceType::Shape) {
-    // TODO Clip to border-radius/reference box if no shape
-    // was specified.
+  if (mClipPathStyle.GetType() == StyleShapeSourceType::Box) {
     RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
+    AppendRectToPath(builder, NSRectToRect(r, appUnitsPerDevPixel), true);
     return builder->Finish();
   }
 
+  MOZ_ASSERT(mClipPathStyle.GetType() == StyleShapeSourceType::Shape);
+
   r = ToAppUnits(r.ToNearestPixels(appUnitsPerDevPixel), appUnitsPerDevPixel);
 
   const auto& basicShape = mClipPathStyle.BasicShape();
   switch (basicShape.GetShapeType()) {
     case StyleBasicShapeType::Circle:
       return CreateClipPathCircle(aDrawTarget, r);
     case StyleBasicShapeType::Ellipse:
       return CreateClipPathEllipse(aDrawTarget, r);