Closed
Bug 984728
Opened 11 years ago
Closed 11 years ago
ParseGridAutoFlow should use ParseBitmaskValues
Categories
(Core :: CSS Parsing and Computation, defect)
Core
CSS Parsing and Computation
Tracking
()
RESOLVED
FIXED
mozilla31
People
(Reporter: dholbert, Assigned: SimonSapin)
References
Details
Attachments
(1 file, 3 obsolete files)
9.70 KB,
patch
|
dholbert
:
review+
|
Details | Diff | Splinter Review |
While reviewing bug 981752 patch 2b, I'm realizing ParseGridAutoFlow should use ParseChoice, and then sanity-check the results of that, rather than hard-coding its own "parse a subset of these keywords in any order" process.
(I'm spinning off this as a helper-bug to avoid scope-creep over there.)
Reporter | ||
Comment 1•11 years ago
|
||
Sorry, my bad -- ParseChoice isn't right here. It's for shorthands, and I used it for ParseFlexFlow which *is* a shorthand, and which is somewhat similar in structure to the (non-shorthand) grid-auto-flow (in that it can take row/column and an optional suffix/prefix).
It might be that ParseBitmaskValues() might be closer to what we want, but I'm not sure yet.
Reporter | ||
Comment 2•11 years ago
|
||
Yeah, I'm pretty sure ParseBitmaskValues is exactly what we should be using in ParseGridAutoFlow. (particularly given that we end up representing the result in a bitmask)
We probably should ditch "none" from ParseGridAutoFlow's initial ParseVariant call, too, and let the ParseBitmaskValues call handle it (since the "none" keyword is in our keyword table), I think.
Summary: ParseGridAutoFlow should use ParseChoice → ParseGridAutoFlow should use ParseBitmaskValues
Assignee | ||
Comment 3•11 years ago
|
||
Assignee | ||
Comment 4•11 years ago
|
||
Attachment #8394619 -
Attachment is obsolete: true
Attachment #8394619 -
Flags: review?(dholbert)
Attachment #8394623 -
Flags: review?(dholbert)
Assignee | ||
Comment 5•11 years ago
|
||
Attachment #8394623 -
Attachment is obsolete: true
Attachment #8394623 -
Flags: review?(dholbert)
Attachment #8394633 -
Flags: review?(dholbert)
Reporter | ||
Comment 6•11 years ago
|
||
Comment on attachment 8394633 [details] [diff] [review]
Patch v3
>+// End-of-array marker for mask arguments to ParseBitmaskValues
>+#define MASK_END_VALUE -1
Use parens here -- i.e.:
#define MASK_END_VALUE (-1)
Otherwise, this macro will mysteriously be accepted in contexts where we wouldn't like it to.
e.g.: this would be treated as a valid number (when we'd prefer that it be a compiler error):
5 MASK_END_VALUE
since it evaluates to 5 -1 which is 4.
> nsCSSValue value;
> if (ParseVariant(value, VARIANT_INHERIT | VARIANT_NONE, nullptr)) {
> AppendValue(eCSSProperty_grid_auto_flow, value);
> return true;
> }
[...]
>+ // Do not parse 'none' here, it's already covered above.
I would prefer that we *do* parse 'none' as part of the ParseBitmaskValues() call (and leave ParseVariant to *only* do INHERIT), for consistency in how we handle 'none' for this property. (as a keyword-table entry, which we encode in a bitmask)
This will mean we can drop the "case eCSSUnit_None:" special-case for this property in nsRuleNode.cpp, too (which we should do as part of this patch).
>+ static const int32_t mask[] = {
>+ NS_STYLE_GRID_AUTO_FLOW_COLUMN | NS_STYLE_GRID_AUTO_FLOW_ROW,
>+ NS_STYLE_GRID_AUTO_FLOW_NONE | NS_STYLE_GRID_AUTO_FLOW_COLUMN,
>+ NS_STYLE_GRID_AUTO_FLOW_NONE | NS_STYLE_GRID_AUTO_FLOW_ROW,
>+ NS_STYLE_GRID_AUTO_FLOW_NONE | NS_STYLE_GRID_AUTO_FLOW_DENSE,
>+ MASK_END_VALUE
>+ };
Instead of all of these exclusion bitfields for _NONE with every other possible value, we should just have a single check after ParseBitmaskValues() like so:
// 'none' is only valid if it occurs alone:
if ((bitField & NS_STYLE_GRID_AUTO_FLOW_NONE) &&
bitfield != NS_STYLE_GRID_AUTO_FLOW_NONE) {
return false;
}
This will be more future-proof, and it also makes our ParseBitmaskValues() code more efficient in the usual case (because we have fewer masks to loop across on each progressive keyword that ParseBitmaskValues() gets for us.)
(I believe one of the other ParseBitmaskValues clients already does something like this, too.)
Attachment #8394633 -
Flags: review?(dholbert) → feedback+
Assignee | ||
Comment 7•11 years ago
|
||
Attachment #8394633 -
Attachment is obsolete: true
Attachment #8394882 -
Flags: review?(dholbert)
Reporter | ||
Comment 8•11 years ago
|
||
Comment on attachment 8394882 [details] [diff] [review]
Patch v4
Looks good. Thanks!
Attachment #8394882 -
Flags: review?(dholbert) → review+
Reporter | ||
Comment 9•11 years ago
|
||
(Simon, could you give this a Try run & add checkin-needed when we're sure it's good to go?)
Flags: needinfo?(simon.sapin)
Assignee | ||
Comment 10•11 years ago
|
||
Flags: needinfo?(simon.sapin)
Assignee | ||
Comment 11•11 years ago
|
||
The two orange bits seem to be intermittent.
Keywords: checkin-needed
Comment 12•11 years ago
|
||
Flags: in-testsuite-
Keywords: checkin-needed
Comment 13•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
You need to log in
before you can comment on or make changes to this bug.
Description
•