Closed Bug 1391499 Opened 8 years ago Closed 8 years ago

Apply correct scale transform with nested transform divs

Categories

(Core :: Graphics: WebRender, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: pchang, Assigned: pchang)

References

Details

Attachments

(1 file)

With nested transform divs, layers-free mode got the wrong result from the following test case. layout/reftests/transform/compound-1-ref.html [Test case] <div style="left:0px; top:200px;"> <div style="-moz-transform: translate(100px);"> <div style="-moz-transform:"> <div style="-moz-transform: scale(2) rotate(90deg);"> <div class="testr"> </div> </div> </div> </div> </div>
Assignee: nobody → howareyou322
Blocks: 1389000
We need to apply inherited scale from parent to get correct transform in layers-free mode.
Comment on attachment 8898787 [details] Bug 1391499 - Apply the inherited scale from ancestors, https://reviewboard.mozilla.org/r/170180/#review175460 Overall looks reasonable but there's enough nits/fixes that I'd like to see an updated version. Thanks! ::: gfx/layers/wr/StackingContextHelper.h:91 (Diff revision 1) > private: > wr::DisplayListBuilder* mBuilder; > LayerPoint mOrigin; > gfx::Matrix4x4 mTransform; > + > + float mXScale, mYScale; One declaration per line please ::: gfx/layers/wr/StackingContextHelper.cpp:16 (Diff revision 1) > - : mBuilder(nullptr) > + : mBuilder(nullptr), > + mXScale(1.0), > + mYScale(1.0) Please line up the commas with the colon : mBuilder(nullptr) , mXScale(1.0) , mYScale(1.0) ::: gfx/layers/wr/StackingContextHelper.cpp:28 (Diff revision 1) > : mBuilder(&aBuilder) > { You should initialize mXScale and mYScale in all four constructors (and definitely in the one you're modifying, because right now there are codepaths where it can be left as uninitialized and then can be later read). ::: gfx/layers/wr/StackingContextHelper.cpp:91 (Diff revision 1) > + aTransformPtr->PostScale(aParentSC.mXScale, aParentSC.mYScale, 1.0); > + aTransformPtr->NudgeToIntegersFixedEpsilon(); I don't really like that you're modifying the passed-in argument as a side-effect here. Since this function later makes a copy of *aTransformPtr into mTransform anyway, can we move that earlier, and then make these changes on mTransform? That way it won't unexpectedly modify the caller's Matrix. ::: gfx/layers/wr/StackingContextHelper.cpp:94 (Diff revision 1) > + > + // Apply the inherited scale from parent > + aTransformPtr->PostScale(aParentSC.mXScale, aParentSC.mYScale, 1.0); > + aTransformPtr->NudgeToIntegersFixedEpsilon(); > + > + gfxSize scale = ThebesMatrix(aTransformPtr->As2D()).ScaleFactors(true); ThebesMatrix is now just a typedef for MatrixDouble, so please use that directly. Likewise s/gfxSize/SizeDouble/ ::: gfx/layers/wr/StackingContextHelper.cpp:95 (Diff revision 1) > + if (fabs(scale.width) < 1e-8 || fabs(scale.height) < 1e-8) { > + scale = gfxSize(1.0, 1.0); It's not clear to me why this is needed. Is a scale of 0 not valid here? If so please add a comment why. Also instead of hard-coding 1e-8 here I'd prefer if you used one of the existing FuzzyEquals methods in the codebase, for example the FuzzyEqualsAdditive in MFBT.
Attachment #8898787 - Flags: review?(bugmail) → review-
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #3) > ThebesMatrix is now just a typedef for MatrixDouble, so please use that > directly. Oh, sorry, I didn't realize ThebesMatrix was the function to convert from Matrix to MatrixDouble. Using that is ok.
Now I couldn't reproduce the try failures with latest nightly, I will check which bug fixed this problem later.
Comment on attachment 8898787 [details] Bug 1391499 - Apply the inherited scale from ancestors, https://reviewboard.mozilla.org/r/170180/#review177952 Much better, thanks. I'm kind of wondering if this is a bug in webrender though, it seems like if stacking contexts are nested the semantics should be that the scale gets inherited down automatically. It seems odd that we need to do this manually on our side.
Attachment #8898787 - Flags: review?(bugmail) → review+
We're sorry, Autoland could not rebase your commits for you automatically. Please manually rebase your commits and try again. hg error in cmd: hg rebase -s 342ee7d2072c -d f06ff175be4f: rebasing 416228:342ee7d2072c "Bug 1391499 - Apply the inherited scale from ancestors, r=kats" (tip) merging gfx/layers/wr/StackingContextHelper.cpp merging gfx/layers/wr/StackingContextHelper.h warning: conflicts while merging gfx/layers/wr/StackingContextHelper.cpp! (edit, then use 'hg resolve --mark') unresolved conflicts (see hg resolve, then hg rebase --continue)
Pushed by pchang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/22d7763100aa Apply the inherited scale from ancestors, r=kats
Backed out for build bustage on Windows at gfx/layers/wr/StackingContextHelper.cpp(105): 'Size': undeclared identifier: https://hg.mozilla.org/integration/autoland/rev/c137b3d03017b8449ae19bfc58752aa688888ab8 Push with bustage: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=22d7763100aad8ac76f9c36b84e67f6349371fac&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-resultStatus=retry&filter-resultStatus=usercancel&filter-resultStatus=runnable Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=126387680&repo=autoland 10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(105): error C2065: 'Size': undeclared identifier 10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(105): error C2146: syntax error: missing ';' before identifier 'scale' 10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(105): error C2065: 'scale': undeclared identifier 10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(108): error C2065: 'scale': undeclared identifier 10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(108): error C2228: left of '.width' must have class/struct/union 10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(108): note: type is 'unknown-type' etc.
Flags: needinfo?(howareyou322)
Pushed by pchang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a36884ff708d Apply the inherited scale from ancestors, r=kats
I just fixed the build failure on windows in comment 13.
Flags: needinfo?(howareyou322)
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
So I backed out 4 patches locally: the ones from bug 1399050, bug 1394308, and bug 1391499, and ran the reftest layout/reftests/transform/compound-1a.html in layers-free WR. What I see is that the reference image is shifted over to the right by around 200px but other than looks fine. Is this the same as what you were seeing when you wrote comment 0? I'm wondering if there's a better way to go about fixing this, because extracting the scale here and then manually applying it to everything is turning out to be quite complicated (e.g. in bug 1399043).
Flags: needinfo?(howareyou322)
(Clearing needinfo here, let's keep the discussion in bug 1400034)
Flags: needinfo?(howareyou322)
See Also: → 1400034
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: