Bug 1247218 - Should consider CSS transform when using non-scaling-stroke draft
authorviolet <violet.bugreport@gmail.com>
Wed, 17 Apr 2019 22:41:37 -0400
changeset 1960072 da8c8b5c9646cd3d78c850ab24feabd9c4e68f4b
parent 1960071 73c757bcd39f274763a5357779fed31a2a0a9659
child 1960073 fca25f79056090e62bc1cb653d1c7c2073d29a7b
child 1960144 4b38843cffef119e053ffc63f7d54723d388622f
push id351199
push userviolet.bugreport@gmail.com
push dateThu, 18 Apr 2019 05:30:58 +0000
treeherdertry@fca25f790560 [default view] [failures only]
bugs1247218
milestone68.0a1
Bug 1247218 - Should consider CSS transform when using non-scaling-stroke
.clang-format
layout/reftests/svg/reftest.list
layout/reftests/svg/test_bug1247218-ref.html
layout/reftests/svg/test_bug1247218.html
layout/svg/nsSVGUtils.cpp
--- a/.clang-format
+++ b/.clang-format
@@ -20,10 +20,10 @@ NS_INTERFACE_TABLE_END|\
 NS_INTERFACE_TABLE_TAIL.*|\
 NS_INTERFACE_MAP_END_.*|\
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END_INHERITED|\
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED|\
 NS_QUERYFRAME_TAIL.*$"
 
 SortIncludes: false
 IndentPPDirectives: AfterHash
-StatementMacros: [MARKUPMAP, ASSERT_TRUE, ASSERT_FALSE, TEST, CHECK]
+#StatementMacros: [MARKUPMAP, ASSERT_TRUE, ASSERT_FALSE, TEST, CHECK]
 
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -157,16 +157,17 @@ fuzzy-if(d2d&&layersGPUAccelerated,0-3,0
 == dynamic-rect-04.xhtml pass.svg
 == dynamic-rect-05.svg pass.svg
 == dynamic-reflow-01.svg dynamic-reflow-01-ref.svg
 == dynamic-small-object-scaled-up-01.svg pass.svg
 == dynamic-small-object-scaled-up-02.svg pass.svg
 == dynamic-stroke-01.svg pass.svg
 == dynamic-stroke-opacity-01.svg pass.svg
 == dynamic-stroke-width-01.svg pass.svg
+== test_bug1247218.html test_bug1247218-ref.html
 == dynamic-switch-01.svg pass.svg
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == dynamic-text-01.svg dynamic-text-01-ref.svg # bug 1392106
 fuzzy-if(d2d&&layersGPUAccelerated,0-3,0-12739) == dynamic-text-02.svg dynamic-text-02-ref.svg # bug 776038 for Win7, Win8
 fuzzy-if(d2d&&layersGPUAccelerated,0-2,0-10539) == dynamic-text-03.svg dynamic-text-03-ref.svg # bug 776038 for Win7
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == dynamic-text-04.svg dynamic-text-04-ref.svg # bug 776038 for Win7 # bug 1392106
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == dynamic-text-05.svg pass.svg # bug 1392106
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == dynamic-text-06.svg pass.svg # bug 1392106
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == dynamic-text-07.svg dynamic-text-07-ref.svg # bug 1392106
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/test_bug1247218-ref.html
@@ -0,0 +1,3 @@
+<svg style="width: 500px; height: 500px; border: 1px solid green;">
+  <rect id="square" transform="translate(100,200) scale(1,2.5)" stroke="blue" vector-effect="non-scaling-stroke" stroke-width="6" x="50px" y="50px" width="50px" height="50px" fill="pink" />
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/test_bug1247218.html
@@ -0,0 +1,8 @@
+<style>
+  #square{
+    transform: translate(100px,200px) scale(1,2.5);
+  }
+</style>
+<svg style="width: 500px; height: 500px; border: 1px solid green;">
+  <rect id="square" stroke="blue" vector-effect="non-scaling-stroke" stroke-width="6" x="50px" y="50px" width="50px" height="50px" fill="pink" />
+</svg>
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1243,23 +1243,23 @@ bool nsSVGUtils::GetNonScalingStrokeTran
   if (aFrame->GetContent()->IsText()) {
     aFrame = aFrame->GetParent();
   }
 
   if (!aFrame->StyleSVGReset()->HasNonScalingStroke()) {
     return false;
   }
 
-  nsIContent* content = aFrame->GetContent();
-  MOZ_ASSERT(content->IsSVGElement(), "bad cast");
+  MOZ_ASSERT(aFrame->GetContent() && aFrame->GetContent()->IsSVGElement(),
+             "should be an SVG element");
 
-  *aUserToOuterSVG = ThebesMatrix(
-      SVGContentUtils::GetCTM(static_cast<SVGElement*>(content), true));
+  nsSVGOuterSVGFrame* outer = nsSVGUtils::GetOuterSVGFrame(aFrame);
+  *aUserToOuterSVG = nsSVGUtils::GetTransformMatrixInUserSpace(aFrame, outer);
 
-  return !aUserToOuterSVG->IsIdentity();
+  return aUserToOuterSVG->HasNonTranslation();
 }
 
 // The logic here comes from _cairo_stroke_style_max_distance_from_path
 static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
                                              nsIFrame* aFrame,
                                              double aStyleExpansionFactor,
                                              const gfxMatrix& aMatrix) {
   double style_expansion =