Closed Bug 1401317 Opened 7 years ago Closed 7 years ago

stylo: Broken rendering of -moz-selection text when stylo is enabled

Categories

(Core :: CSS Parsing and Computation, defect, P2)

Unspecified
All
defect

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox-esr52 --- unaffected
firefox55 --- unaffected
firefox56 --- unaffected
firefox57 --- fixed

People

(Reporter: jfkthame, Assigned: bholley)

References

Details

(Keywords: regression)

Attachments

(7 files)

The rendering of selected text when -moz-selection is used seems to be significantly broken when stylo is enabled. Using attachment 610677 [details] (testcase from bug 721750), load the example and then press Cmd-A to Select All (on macOS). Two issues: First, the highlighting when stylo is enabled is very different from the non-stylo version (compare screenshots 1 and 2). Second, pressing Cmd-A a second time (or any number of additional times) changes the stylo highlighting again (compare screenshots 2 and 3). Indeed, the result varies depending exactly how the content is selected. (So selecting individual words or lines may give different results from selecting the whole text.) This inconsistent behavior is clearly unexpected.
This does seem to be a Mac-specific issue; I'm not seeing similar behavior on Windows.
OS: Unspecified → Mac OS X
Not Mac-only after all, I'm seeing similar behavior on Linux. Maybe it's a recent regression and my Windows build is too old to show it...?
Yup. Broken in latest Windows nightly, too.
Keywords: regression
OS: Mac OS X → All
Summary: [stylo] Broken rendering of -moz-selection text when stylo is enabled → stylo: Broken rendering of -moz-selection text when stylo is enabled
Flags: needinfo?(bobbyholley)
Blocks: 1397976
Flags: needinfo?(bobbyholley)
Priority: -- → P2
Assignee: nobody → bobbyholley
So the basic problem here is that the simplification in bug 1368291 comment 9 doesn't hold anymore. I'll attach a reftest.
Attached patch Reftest. r=meSplinter Review
MozReview-Commit-ID: KnGCuU0rcgi
Attachment #8910027 - Flags: review+
There are various ways to solve this. Emilio, any preference on which way?
Flags: needinfo?(emilio)
(In reply to Bobby Holley (:bholley) (busy with Stylo) from comment #7) > So the basic problem here is that the simplification in bug 1368291 comment > 9 doesn't hold anymore. This doesn't have nothing to do with that simplification, but with the general lazy pseudo style cache mechanism. (In reply to Bobby Holley (:bholley) (busy with Stylo) from comment #9) > There are various ways to solve this. Emilio, any preference on which way? I'm not totally sure about what kind of ways are you thinking about. The lazy pseudo-style cache didn't help memory that much when we land it, so easiest thing is just remove it, and get back that word in the style contexts. However, if we really really want to keep it, I guess we'd need to resolve the style and just compare the rule node pointers to cache them. Looking at the list of pseudo-elements, the only ones worth sharing are :-moz-list-bullet and :-moz-list-number... And per bz's comment right above it, maybe we should just convert them to inheriting anonymous boxes (post-57, ofc). It's not clear the lazy pseudo cache is a great memory win, so I'd propose just getting rid of it.
Flags: needinfo?(emilio)
(In reply to Emilio Cobos Álvarez [:emilio] from comment #10) > Looking at the list of pseudo-elements, the only ones worth sharing are > :-moz-list-bullet and :-moz-list-number... And per bz's comment right above > it, maybe we should just convert them to inheriting anonymous boxes > (post-57, ofc). it == the pseudo-element definition, in particular: // XXXbz should we really allow random content to style these? Maybe // use our flags to prevent that? CSS_PSEUDO_ELEMENT(mozListBullet, ":-moz-list-bullet", 0) CSS_PSEUDO_ELEMENT(mozListNumber, ":-moz-list-number", 0)
(In reply to Emilio Cobos Álvarez [:emilio] from comment #10) > (In reply to Bobby Holley (:bholley) (busy with Stylo) from comment #7) > > So the basic problem here is that the simplification in bug 1368291 comment > > 9 doesn't hold anymore. > > This doesn't have nothing to do with that simplification, but with the > general lazy pseudo style cache mechanism. Per IRC discussion, my original comment holds. > (In reply to Bobby Holley (:bholley) (busy with Stylo) from comment #9) > > There are various ways to solve this. Emilio, any preference on which way? > > I'm not totally sure about what kind of ways are you thinking about. The two that I had in mind where (1) matching before sharing, and (2) disabling caching when the primary style was reused via the second pass. > > The lazy pseudo-style cache didn't help memory that much when we land it Per bug 1367862 comment 22, the impact isn't negligible. I'd imagine it varies a lot by page, but it basically boils down to an extra CV per <li> element, and it's not such a stretch to think that there are pages out there with a lot of <li> elements. > , so > easiest thing is just remove it, and get back that word in the style > contexts. > > However, if we really really want to keep it, I guess we'd need to resolve > the style and just compare the rule node pointers to cache them. I think option (2) above is pretty simple and low-risk. I'll attach a patch for that. > > Looking at the list of pseudo-elements, the only ones worth sharing are > :-moz-list-bullet and :-moz-list-number... And per bz's comment right above > it, maybe we should just convert them to inheriting anonymous boxes > (post-57, ofc). That sounds like a good plan, filed bug 1401449 for it.
This makes it easier to detect sharing-related weirdness in the future. MozReview-Commit-ID: 8U0xekMHGg8
Attachment #8910122 - Flags: review?(emilio)
Do you really think it's worth to share style across <li> element at the expense of an extra word for every single style context? It doesn't sound like an obvious win at all to me. And honestly the less code that interacts with the ElementData flags the best over all, I think.
Flags: needinfo?(bobbyholley)
Attachment #8910122 - Flags: review?(emilio) → review+
I'd rather take a few numbers here now that we have proper memory reporting, and remove the code if that optimization doesn't look worth it.
Comment on attachment 8910121 [details] [diff] [review] Disable lazy pseudo caching when the originating element's primary style was reused via the rule node. v1 Review of attachment 8910121 [details] [diff] [review]: ----------------------------------------------------------------- Per IRC discussion, let's do this, I guess we can always get rid of this later... ::: servo/ports/geckolib/glue.rs @@ +844,5 @@ > } > > #[no_mangle] > +pub extern "C" fn Servo_Element_IsPrimaryStyleReusedViaRuleNode(element: RawGeckoElementBorrowed) -> bool > +{ nit: Either brace to the previous line, or alignment of the argument as a block, your call. While you're here you can also fixup the previous function.
Attachment #8910121 - Flags: review?(emilio) → review+
07:43 <emilio> bholley: do you really think it's worth it to sacrifice a word in every single style context to share styles on <li> elements? It doesn't seem obvious to me that it's a win 07:52 <bholley> emilio: hard to say about the average, but the worst-case behavior is better. In any case, it seems weird to use this bug to revive that whole tradeoff analysis two days before the merge. I'd be sympathetic if it were our only easy option, but we have another one 07:52 <bholley> emilio: so I'm more inclined to land the minimal change for now, and then try to ship the anon box thing in 58
Flags: needinfo?(bobbyholley)
Thanks! https://github.com/servo/servo/pull/18571 (The servo changes are not interdependent with the gecko ones, so I'll let that land overnight and then push the gecko bits in the morning)
(In reply to Bobby Holley (:bholley) (busy with Stylo) from comment #21) > Thanks! > > https://github.com/servo/servo/pull/18571 Servo-side changes landed as https://hg.mozilla.org/integration/autoland/rev/4d6c6ad56429
Pushed by bholley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ef5d46900a24 Disable lazy pseudo caching when the originating element's primary style was reused via the rule node. r=emilio https://hg.mozilla.org/integration/autoland/rev/cd809c5e79a5 Reftest. r=me
Depends on: 1402285
Attachment #8910070 - Flags: review?(bobbyholley)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: