Closed Bug 836604 Opened 11 years ago Closed 11 years ago

Merge nsStyleSet::GetContext()'s boolean parameters into a single 'flags' parameter

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: dholbert, Assigned: dholbert)

References

Details

Attachments

(1 file, 1 obsolete file)

      No description provided.
(sorry, forgot the bug description)

I'd like to add another boolean variable to nsStyleSet::GetContext, in bug 812822, but I don't want it to have four mysterious "..., true, false, ..., true, true)" boolean args in each invocation. Better to collapse the bools into a flags bitfield. Filing this bug on that.
Attached patch fix v1 (obsolete) — Splinter Review
Attachment #708484 - Flags: review?(bzbarsky)
Comment on attachment 708484 [details] [diff] [review]
fix v1

>-                                                aIsVisitedLink);
>+                                                aFlags & eIsLink);

eIsVisitedLink?

>+        aFlags & eIsLink ?
>+        aFlags & eIsVisitedLink
>+        : (aParentContext && aParentContext->RelevantLinkVisited());

This would benefit from some parens and the bit operations, I think.

>+                          aFlags & ^eDoAnimation);

That should be a '~'.  I assume the above doesn't compile, right?


>                     // For pseudos, |data.IsLink()| being true means that
>                     // our parent node is a link.

That comment should probably move to above the |flags = eNoFlags;|, both times.

>+  if ((aStyleContext->IsLinkContext() &&
>+       aStyleContext->RelevantLinkVisited()) ||
>+      aNewParentContext->RelevantLinkVisited()) {

No, this is wrong.  Say aStyleContext->IsLinkContext() is true, aStyleContext->RelevantLinkVisited() is false, and aNewParentContext->RelevantLinkVisited() is true.  The new code returns true, while the old code correctly returned false.

r=me with those issues fixed.
Attachment #708484 - Flags: review?(bzbarsky) → review+
Attached patch fix v2Splinter Review
(In reply to Boris Zbarsky (:bz) from comment #3)
> eIsVisitedLink?

Oops, thanks! Fixed.

> >+        aFlags & eIsLink ?
> >+        aFlags & eIsVisitedLink
> >+        : (aParentContext && aParentContext->RelevantLinkVisited());
> 
> This would benefit from some parens and the bit operations, I think.

I added parens around bit operations, and I pulled the first chunk (before the '?') up to the previous line -- hopefully it's clearer now.

> >+                          aFlags & ^eDoAnimation);
> 
> That should be a '~'.  I assume the above doesn't compile, right?

Yup (& it doesn't compile -- sorry about that. Previously, I just was incorrectly passing 'aFlags' straight through, and *that* compiled, but I noticed just before posting that I needed to invert the eDoAnimation bit, and of course I used the wrong operator-symbol. :))

Fixed.

> >                     // For pseudos, |data.IsLink()| being true means that
> >                     // our parent node is a link.
> 
> That comment should probably move to above the |flags = eNoFlags;|, both
> times.

Fixed.

> >+  if ((aStyleContext->IsLinkContext() &&
> >+       aStyleContext->RelevantLinkVisited()) ||
> >+      aNewParentContext->RelevantLinkVisited()) {
> 
> No, this is wrong.  Say aStyleContext->IsLinkContext() is true,
> aStyleContext->RelevantLinkVisited() is false, and
> aNewParentContext->RelevantLinkVisited() is true.  The new code returns
> true, while the old code correctly returned false.

Ah, right -- technically I should be checking "!aStyleContext->IsLinkContext()" on that last line there, to preserve all of the original logic.

Instead of that, though, I just reverted this change back to the original code, w/ 'bool relevantLinkVisited', and then I set the flag if relevantLinkVisited is true.

> r=me with those issues fixed.

Thanks!
Attachment #708484 - Attachment is obsolete: true
Attachment #708744 - Flags: review+
Try run (all tests on linux64 debug & opt):
 https://tbpl.mozilla.org/?tree=Try&rev=e55242bf2a17
Try run is looking good! I'll land this tomorrow.
Flags: in-testsuite-
https://hg.mozilla.org/mozilla-central/rev/7245eecea323
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: