Closed
Bug 889964
Opened 11 years ago
Closed 8 years ago
"border-image-repeat: round" uses ceil instead of round in tile width calculation
Categories
(Core :: Web Painting, defect)
Core
Web Painting
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: jbroman, Assigned: ethlin)
References
()
Details
Attachments
(3 files, 6 obsolete files)
12.29 KB,
patch
|
dbaron
:
review+
|
Details | Diff | Splinter Review |
1.58 KB,
patch
|
dbaron
:
review+
|
Details | Diff | Splinter Review |
905 bytes,
patch
|
ethlin
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 Steps to reproduce: Launch Firefox (I used Nightly) and open a document in there is a border image with the 'round' repeat style, and the number of tiles which fit in the available length of a border is between k and k+1/2 for some integer k. A trivial such example is data:text/html,<div style="border:27px solid transparent; border-image:url(http://www.w3.org/TR/css3-background/border.png) 27 27 round; width:28px"></div> Actual results: One extra copy of the tile is rendered, and all tiles are rescaled to fit that extra copy. In the example above, two narrow yellow diamonds are rendered instead of a single yellow diamond in each of the top and bottom borders (for a total of 8 diamonds visible). Expected results: The number of tiles to be rendered should conform to the specification: "If X ≠ 0 is the width of the image after step one and W is the width of the background positioning area, then the rounded width X' = W / round(W / X) where round() is a function that returns the nearest natural number (integer greater than zero)." (http://www.w3.org/TR/css3-background/). This formula applies to the border as well as background since the spec for border-image-repeat says "If the first keyword is ‘round’, the top, middle and bottom images are resized in width, so that exactly a whole number of them fit in the middle part of the border-image area, exactly as for ‘round’ in the ‘background-repeat’ property.". In example given above, it is expected that one yellow diamond appear on each of the top and bottom edges of the border (for a total of 6 diamonds visible). This appears to be a result of using "ceil" in the DrawBorderImageComponent in layout/base/nsCSSRendering.cpp, when what is desired is "round" (restricted to positive integers to avoid division by zero).
Component: General → Layout: View Rendering
OS: Linux → All
Hardware: x86_64 → All
Version: 25 Branch → Trunk
The code has now moved to the ComputeTile helper function just above DrawBorderImageComponent. :ethlin, any chance you could fix this one as well given that you're in the area? (It looks like this will make us match Chromium on the testcase; I didn't test Edge, although it's probably worth checking.)
Flags: needinfo?(ethlin)
Assignee | ||
Comment 3•8 years ago
|
||
The round calculation of border-image-repeat is wrong. I applied the background-repeat calculation to fix it. I will write testcase later.
Reporter | ||
Comment 4•8 years ago
|
||
Comment on attachment 8758171 [details] [diff] [review] Part 1. Fix round calculation. Review of attachment 8758171 [details] [diff] [review]: ----------------------------------------------------------------- I hope you don't mind the drive-by comment, but it seems like this should have changes to both the horizontal and vertical cases. ::: layout/base/nsCSSRendering.cpp @@ +5409,5 @@ > tile.width = aUnitSize.width; > break; > case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND: > tile.x = aFill.x; > + tile.width = ComputeRoundedSize(aUnitSize.width, aFill.width); There's a similar computation for tile.height a few lines down that presumably needs the same change.
Assignee | ||
Comment 5•8 years ago
|
||
(In reply to jbroman from comment #4) > Comment on attachment 8758171 [details] [diff] [review] > Part 1. Fix round calculation. > > Review of attachment 8758171 [details] [diff] [review]: > ----------------------------------------------------------------- > > I hope you don't mind the drive-by comment, but it seems like this should > have changes to both the horizontal and vertical cases. > > ::: layout/base/nsCSSRendering.cpp > @@ +5409,5 @@ > > tile.width = aUnitSize.width; > > break; > > case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND: > > tile.x = aFill.x; > > + tile.width = ComputeRoundedSize(aUnitSize.width, aFill.width); > > There's a similar computation for tile.height a few lines down that > presumably needs the same change. Okay. Thanks.
Assignee | ||
Comment 6•8 years ago
|
||
I applied the background-repeat calculation to border-image's round calculations.
Attachment #8758171 -
Attachment is obsolete: true
Attachment #8758547 -
Flags: review?(dbaron)
Assignee | ||
Comment 7•8 years ago
|
||
I added a testcase for border-image-repeat: round for this problem.
Attachment #8758550 -
Flags: review?(dbaron)
Assignee | ||
Comment 8•8 years ago
|
||
Remove redundant settings.
Attachment #8758550 -
Attachment is obsolete: true
Attachment #8758550 -
Flags: review?(dbaron)
Attachment #8758556 -
Flags: review?(dbaron)
Comment on attachment 8758547 [details] [diff] [review] Part 1. Fix round calculation. ># HG changeset patch ># User Ethan Lin <ethlin@mozilla.com> > >Bug 889964 - Part 1. Fix the caluculation of boarder image: round. r=dbaron Please fix the spelling of "calculation" (remove the first "u") and "border-image" (no "a", with "-") r=dbaron with that
Attachment #8758547 -
Flags: review?(dbaron) → review+
Comment on attachment 8758556 [details] [diff] [review] Part 2. Add reftest for border-image-repeat: round >+ <meta name="assert" content="The test checks whether border-image-repeat: 'round' works correctly or not."> "works correctly or not" should be clearer. Perhaps "uses the correct rounding formula"? Does the test fail without the patch? And does it test the <1 case (in particular, with something that's less than 0.5)? If not, it should (for both questions). Please put the test in the background/ directory instead of creating a new border-image/ directory. (Note that for the creation of the border-image subdirectory to be correct, you would have needed to add to the parent directory's reftest.list. But you shouldn't do that.) r=dbaron with that
Attachment #8758556 -
Flags: review?(dbaron) → review+
Assignee | ||
Comment 11•8 years ago
|
||
(In reply to David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) (vacation June 4-12) from comment #10) > Comment on attachment 8758556 [details] [diff] [review] > Part 2. Add reftest for border-image-repeat: round > > >+ <meta name="assert" content="The test checks whether border-image-repeat: 'round' works correctly or not."> > > "works correctly or not" should be clearer. Perhaps "uses the correct > rounding formula"? > Okay, I'll change that. > Does the test fail without the patch? And does it test the <1 case (in > particular, with something that's less than 0.5)? If not, it should (for > both questions). > The test will fail without the patch, but it doesn't test <1 case. I will add <1 case. > > Please put the test in the background/ directory instead of creating a new > border-image/ directory. > Okay, I'll move it. > (Note that for the creation of the border-image subdirectory to be correct, > you would have needed to add to the parent directory's reftest.list. But > you shouldn't do that.) > > r=dbaron with that
Assignee | ||
Comment 12•8 years ago
|
||
Address :dbaron's comment.
Attachment #8758547 -
Attachment is obsolete: true
Assignee | ||
Comment 13•8 years ago
|
||
I added another test case for <1 and moved the tests to background folder.
Attachment #8758556 -
Attachment is obsolete: true
Assignee | ||
Comment 14•8 years ago
|
||
I forget to include the reftest.list in bug 548372. Turn on it so try server will run it.
Assignee | ||
Comment 15•8 years ago
|
||
try server result: https://treeherder.mozilla.org/#/jobs?repo=try&revision=63aa99990f35&selectedJob=21919213
Assignee | ||
Comment 16•8 years ago
|
||
It was a wrong patch. Correct it.
Attachment #8759573 -
Attachment is obsolete: true
Attachment #8759582 -
Flags: review+
Attachment #8759576 -
Flags: review+
Attachment #8759579 -
Flags: review+
Comment on attachment 8759579 [details] [diff] [review] Part 3. Turn on background tests Though, actually, instead of adding a new line at the bottom, this should uncomment: # include background3/reftest.list and remove the "3". in both that line and the comment line above it.
Assignee | ||
Comment 18•8 years ago
|
||
(In reply to David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) (vacation June 4-12) from comment #17) > Comment on attachment 8759579 [details] [diff] [review] > Part 3. Turn on background tests > > Though, actually, instead of adding a new line at the bottom, this should > uncomment: > > # include background3/reftest.list > > and remove the "3". in both that line and the comment line above it. Okay, I'll change it.
Assignee | ||
Comment 19•8 years ago
|
||
Address :dbaron's comment.
Attachment #8759579 -
Attachment is obsolete: true
Assignee | ||
Updated•8 years ago
|
Attachment #8759931 -
Flags: review+
Assignee | ||
Updated•8 years ago
|
Keywords: checkin-needed
https://hg.mozilla.org/integration/mozilla-inbound/rev/2ce152b78b405f545225ba5804366faa61d601bf Bug 889964 - Part 1. Fix the calculation of border-image: round. r=dbaron https://hg.mozilla.org/integration/mozilla-inbound/rev/0631776a11b102b0041c53b9f265d856f0b68108 Bug 889964 - Part 2. Add reftest for boarder image: round. r=dbaron https://hg.mozilla.org/integration/mozilla-inbound/rev/3e6967898d93bc686b291a310b715f3371c19e08 Bug 889964 - Part 3. Turn on background reftest. r=dbaron
Comment 21•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/2ce152b78b40 https://hg.mozilla.org/mozilla-central/rev/0631776a11b1 https://hg.mozilla.org/mozilla-central/rev/3e6967898d93
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Updated•6 years ago
|
Component: Layout: View Rendering → Layout: Web Painting
You need to log in
before you can comment on or make changes to this bug.
Description
•