Open Bug 1400771 Opened 6 years ago Updated 1 year ago
stylo: preshints (mapped attributes) not handled correctly for elements created from non-docshell-associated document
From bug 1353177 comment 5, an example code which passes in Gecko but fails in Stylo: <!DOCTYPE html> <body> <script> document.body.offsetWidth; var doc = document.implementation.createHTMLDocument(); var f = doc.createElement("font"); f.setAttribute("color", "green"); alert(getComputedStyle(f).color); </script> </body> A poc patch is submitted in bug 1353177 comment 7, but it is not clear whether that is the right way forward.
Summary: stylo: preshints (mapped attributes) not handled correctly for elements created from different document → stylo: preshints (mapped attributes) not handled correctly for elements created from non-docshell-associated document
(In reply to Boris Zbarsky [:bz] (still digging out from vacation mail) from bug 1353177 comment #8) > Hmm. Doing the "pass the document" thing makes some sense. I'm not > entirely sure about the way it picks a prescontext to use and whether that > approach makes sense. > > How does Gecko pass my testcase from bug 1353177 comment 6 without creating > an attr stylesheet? I guess it just has a non-sheet-associated mapped > attributes that it then walks without involving an attr stylesheet in any way? So the Gecko counterpart of ServoSpecifiedValues is nsRuleData, which is created in-stack in nsRuleNode::WalkRuleTree  with the pres context of the rule node. I didn't track all way up for where is the nsRuleNode comes from, but from a debugger, it seems to me the nsRuleNode is from the document of the nsComputedDOMStyle, which is different from the owner document of the target element. Given that, my guess is that Gecko always uses the pres context nsComputedDOMStyle. We can probably do so for Stylo as well.  https://searchfox.org/mozilla-central/rev/15ce5cb2db0c85abbabe39a962b0e697c9ef098f/layout/style/nsRuleNode.cpp#2583-2584
(In reply to Boris Zbarsky [:bz] (still digging out from vacation mail) from bug 1353177 comment #8) > > I suspect that we should probably create mAttrStyleSheet when document is created. > > It's not clear which is best here. This would involve allocating a bunch of > stuff... but maybe we allocate it anyway in common "data document" cases > like XHR result documents. Probably we can create it lazily, e.g. creating one when nsIDocument::GetAttributeStyleSheet is called (and rename it to nsIDocument::AttributeStyleSheet instead), so that for document we don't need to calculate stylesheet, we won't need it.
status-firefox57=wontfix unless someone thinks this bug should block 57
You need to log in before you can comment on or make changes to this bug.