Closed Bug 567663 Opened 14 years ago Closed 14 years ago

Implement the hidden attribute

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b3

People

(Reporter: Ms2ger, Assigned: Ms2ger)

References

(Depends on 1 open bug, )

Details

(Keywords: dev-doc-complete, html5, Whiteboard: [parity-webkit])

Attachments

(1 file, 6 obsolete files)

No description provided.
Attached patch Patch v1 (obsolete) (deleted) — Splinter Review
Attachment #446977 - Flags: review?(bzbarsky)
Attachment #446977 - Flags: review?(bzbarsky) → review?(Olli.Pettay)
Whiteboard: [parity-webkit]
Attached patch Patch v1.1, merged to tip (obsolete) (deleted) — Splinter Review
Attachment #446977 - Attachment is obsolete: true
Attachment #450840 - Flags: review?(Olli.Pettay)
Attachment #446977 - Flags: review?(Olli.Pettay)
Attached patch Patch v1.2, merged to tip (obsolete) (deleted) — Splinter Review
Attachment #450840 - Attachment is obsolete: true
Attachment #451887 - Flags: review?(Olli.Pettay)
Attachment #450840 - Flags: review?(Olli.Pettay)
Attachment #451887 - Flags: review?(Olli.Pettay) → review+
I recall #webkit scrollback to the effect that their implementation wasn't as simple as the rule addition made here, for reasons of perf considerations of checking for an attribute on every element during style resolution. (I think that's the term I want, somebody tell me if I'm mistaken.) Do we not have to worry about this method of implementation having performance impact?
Uh, right. Need to check how this affects to performance.
> Do we not have to worry about this method of implementation having performance > impact? We do, in general. Not sure how much it would show up in practice so far, but as we optimize more and more it could become noticeable.... It's worth looking at how the webkit folks implemented theirs.
What do we do when we check for matches to the :lang() pseudo-class, for example?
I'm not sure I follow the question in comment 7.... Also note that we already have [dir] rules in html.css. :( This would be no worse....
Since the :lang pseudo-class requires a check of the "lang" attribute on every element, I wondered how we handled that, since it might help us in this bug.
We check the lang attribute. The :lang pseudo-class is rarely used. This patch, however, would have the [hidden] check for all HTML elements.
And again, it may be that the concern is not important. Can we get some numbers here (using a stylesheet with such a rule in it, say)? What did webkit end up doing?
Thanks. We could do that sort of thing, though our mapped attr code is more similar to our style resolution code (involves attr gets during resolution time). But it would only happen for elements with mapped attributes... If we want to do that, you'd want to add it to nsGenericHTMLElement::sCommonAttributeMap and change nsGenericHTMLElement::MapCommonAttributesInto. It's worth getting numbers on the performance impact before resorting to the complicated way, seems like.
Using the attribute mapping code isn't all that complicated, and I think it's also more consistent with other code. And I suspect there would be a big perf impact from changing everything from the attribute mapping code to being written in CSS. There's also the question of whether this belongs at the preshint or UA level of the cascade.
That had crossed my mind, but I think putting it in preshint for the time being is fine.
Comment on attachment 451887 [details] [diff] [review] Patch v1.2, merged to tip dbaron says that it would be more performant to implement this using nsGenericHTMLElement::MapCommonAttributesInto/nsGenericHTMLElement::sCommonAttributeMap. Check it to that and ask me for review. Would be great to have this in Firefox 4.
Attachment #451887 - Flags: review-
... that's instead of the html.css changes.
Attached patch Mapped attribute WIP (obsolete) (deleted) — Splinter Review
This doesn't work. I can't find any documentation that explains what I should do instead. David, perhaps you could tell me?
Attachment #458096 - Flags: feedback?(dbaron)
You don't want mDisplay.SetNoneValue(); instead you want mDisplay.SetIntValue(NS_STYLE_DISPLAY_NONE, eCSSUnit_Enumerated).
Comment on attachment 458096 [details] [diff] [review] Mapped attribute WIP (and otherwise this looks fine, assuming that makes it work... except for the fact that the html.css change doesn't need to be added in the other patch and removed in this one)
Attachment #458096 - Flags: feedback?(dbaron) → feedback+
Attached patch Patch v2 (obsolete) (deleted) — Splinter Review
Thanks, that did make it work.
Attachment #451887 - Attachment is obsolete: true
Attachment #458096 - Attachment is obsolete: true
Attachment #458169 - Flags: review?(jonas)
Doesn't that patch also need to check that the display is not already set? Seems like this: <style> div { display: block !important; } </style> <div hidden>This text should show up</div> would not work with the patch as written...
Er, right, it does. I forgot about that because I was looking at the lang case above, which is the exception. It should probably look like: if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) { nsRuleDataDisplay *disp = aData->mDisplayData; if (disp->mDisplay.GetUnit() == eCSSUnit_Null) { if (aAttributes->IndexOfAttr(nsGkAtoms::hidden, kNameSpaceID_None) >= 0) { disp->mDisplay.SetIntValue(NS_STYLE_DISPLAY_NONE, eCSSUnit_Enumerated); } } }
Attachment #458169 - Flags: review?(jonas)
Attached patch Patch v2.1 (obsolete) (deleted) — Splinter Review
Thanks, it looks like that works.
Attachment #458169 - Attachment is obsolete: true
Attachment #458397 - Flags: review?(jonas)
Presumably comment 22 should be added as a reftest too...
Comment on attachment 458397 [details] [diff] [review] Patch v2.1 r=me if you also add the testcase in comment 22 as a reftest.
Attachment #458397 - Flags: review?(jonas) → review+
Attached patch Patch v2.2 for checkin (deleted) — Splinter Review
Done.
Attachment #458397 - Attachment is obsolete: true
You need to request approval2.0 on your patch before it can land.
Keywords: checkin-needed
Attachment #458608 - Flags: approval2.0?
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
Keywords: checkin-needed
Resolution: --- → FIXED
Thanks! You rock!
Target Milestone: --- → mozilla2.0b3
Depends on: 585101
Depends on: 613722
Running Firefox 4 RC, the hidden attribute hides elements on a page with XHTML transitional doctype (i.e not HTML5)? Is this correct?
(In reply to comment #32) > Running Firefox 4 RC, the hidden attribute hides elements on a page with XHTML > transitional doctype (i.e not HTML5)? Is this correct? Yes. We're not IE, we implement everything in all modes, unless there's a good reason not to. This is what the HTML specification requires. If you want to use non-standard attributes, please use the data-* attributes; in that case you're sure we'll never do something with them.
(In reply to comment #33) > Yes. We're not IE, we implement everything in all modes, unless there's a good > reason not to. This is what the HTML specification requires. I didn't realise that changes like this impacted on previous html versions. I realised after making my post that if I don't fix this now I'd have to do it if we changed to HTML5 anyway, so have addressed the issue. Thanks for the prompt reply.
> I didn't realise that changes like this impacted on previous html versions. The point is we only implement one version of HTML. We ignore the doctype completely, except for deciding on standards or quirks mode...
Depends on: 1437969
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: