Closed Bug 1303623 Opened 9 years ago Closed 9 years ago

Parsing mask-clip/mask-origin: fill-box|stroke-box|view-box|no-clip values

Categories

(Core :: Layout, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: u459114, Assigned: ethlin)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(5 files, 12 obsolete files)

58 bytes, text/x-review-board-request
heycam
: review+
Details
58 bytes, text/x-review-board-request
heycam
: review+
Details
58 bytes, text/x-review-board-request
heycam
: review+
Details
58 bytes, text/x-review-board-request
heycam
: review+
Details
58 bytes, text/x-review-board-request
heycam
: review+
Details
According to masking spec: https://drafts.fxtf.org/css-masking-1/#the-mask-clip 4 more properties support needed.
Hi Astley, This bug is similiar to bug 1289011. Want to find someone fix it? If no one want to fix it, please assign back to me.
Flags: needinfo?(aschen)
rename to correct prop name.
Summary: Handle mask-repeat: fill-box|stroke-box|view-box|no-clip → Handle mask-clip: fill-box|stroke-box|view-box|no-clip values
Whiteboard: tlt-queue
Assignee: nobody → ethlin
Flags: needinfo?(aschen)
Whiteboard: tlt-queue → tlt-wip
Status: NEW → ASSIGNED
Attached patch css parser (obsolete) — — Splinter Review
This patch is for CSS parse. But I seems to mix background-clip and mask-clip.
We may just handle css parsing + style and make sure all test case pass in this bug. And create another one to fix rendering issues in nsCSSRendering + nsDisplayMask + nsSVGIntergrationUtils
And, not only mask-clip, mask-position need to support these new box as well
Summary: Handle mask-clip: fill-box|stroke-box|view-box|no-clip values → Parsing mask-clip/mask-origin: fill-box|stroke-box|view-box|no-clip values
Attached patch css parser (obsolete) — — Splinter Review
Fix the struct 'CSS_PROP_SVGRESET'. 'mask-clip' can read these values correctly, but 'background-clip' can read too. I need make these values illegal for 'background-clip'.
Attachment #8801021 - Attachment is obsolete: true
Priority: -- → P2
Blocks: 1311270
Attached patch Part1. Style const changes. (obsolete) — — Splinter Review
Style constant changes.
Attachment #8801606 - Attachment is obsolete: true
Attachment #8802418 - Flags: review?(cam)
Attached patch Part2. Style structure changes (obsolete) — — Splinter Review
Style structure changes.
Attachment #8802419 - Flags: review?(cam)
Attached patch Part3. Parser changes (obsolete) — — Splinter Review
The patch is for parser changes.
Attachment #8802420 - Flags: review?(cam)
Attached patch Part4. Rendering changes (obsolete) — — Splinter Review
Bug 1311270 will implement the rendering part. So this patch is for fallback to default value.
Attachment #8802422 - Flags: review?(cam)
Attached patch Part5. Testcase changes (obsolete) — — Splinter Review
Fix testcase after adding fill-box|stroke-box|view-box|no-clip values.
Attachment #8802423 - Flags: review?(cam)
Attachment #8802418 - Flags: review?(cam) → review+
Comment on attachment 8802419 [details] [diff] [review] Part2. Style structure changes Review of attachment 8802419 [details] [diff] [review]: ----------------------------------------------------------------- OK, but a couple of things to fix. ::: layout/style/nsCSSProps.cpp @@ +930,5 @@ > + { eCSSKeyword_view_box, NS_STYLE_IMAGELAYER_CLIP_VIEW }, > + { eCSSKeyword_no_clip, NS_STYLE_IMAGELAYER_CLIP_NO_CLIP }, > + // The next entry is controlled by the layout.css.background-clip-text.enabled > + // pref. > + { eCSSKeyword_text, NS_STYLE_IMAGELAYER_CLIP_TEXT }, The "text" value should only be supported for background-clip, not for mask-clip. The value is defined here: https://compat.spec.whatwg.org/#valdef--webkit-background-clip-text @@ +936,5 @@ > +}; > + > +static_assert(MOZ_ARRAY_LENGTH(nsCSSProps::kMaskOriginKTable) == > + MOZ_ARRAY_LENGTH(nsCSSProps::kMaskClipKTable) - 2, > + "background-clip has two extra value, which are no-clip and text, compared" The original assertion was checking that {background,mask}-origin and background-clip had almost identical arrays. If we want to preserve that, we should keep that assertion (just for background-origin vs background-clip) and have a second one for the mask arrays. But I think it's probably not important to keep. We have should have mochitest that check we support the right set of values. So I suggest removing it. ::: layout/style/nsCSSProps.h @@ +691,5 @@ > static const KTableEntry kAzimuthKTable[]; > static const KTableEntry kBackfaceVisibilityKTable[]; > static const KTableEntry kTransformStyleKTable[]; > static const KTableEntry kImageLayerAttachmentKTable[]; > static const KTableEntry kImageLayerOriginKTable[]; Please rename this to kBackgroundOriginKTable, now that it is not being used for both background-origin and mask-origin. @@ +702,5 @@ > static const KTableEntry kImageLayerModeKTable[]; > // Not const because we modify its entries when the pref > // "layout.css.background-clip.text" changes: > static KTableEntry kBackgroundClipKTable[]; > + static KTableEntry kMaskClipKTable[]; Then we can make this const.
Attachment #8802419 - Flags: review?(cam) → review-
Comment on attachment 8802418 [details] [diff] [review] Part1. Style const changes. Review of attachment 8802418 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/style/nsStyleConsts.h @@ +351,5 @@ > +#define NS_STYLE_IMAGELAYER_CLIP_MARGIN 3 > +#define NS_STYLE_IMAGELAYER_CLIP_FILL 4 > +#define NS_STYLE_IMAGELAYER_CLIP_STROKE 5 > +#define NS_STYLE_IMAGELAYER_CLIP_VIEW 6 > +#define NS_STYLE_IMAGELAYER_CLIP_NO_CLIP 7 Can you comment somewhere in here that MARGIN, FILL, etc. are only supported by mask-clip, and not background-clip. @@ +370,5 @@ > #define NS_STYLE_IMAGELAYER_ORIGIN_CONTENT 2 > +#define NS_STYLE_IMAGELAYER_ORIGIN_MARGIN 3 > +#define NS_STYLE_IMAGELAYER_ORIGIN_FILL 4 > +#define NS_STYLE_IMAGELAYER_ORIGIN_STROKE 5 > +#define NS_STYLE_IMAGELAYER_ORIGIN_VIEW 6 Similarly here, that that MARGIN, FILL, etc. are only supported by mask-origin, and not background-origin.
Attachment #8802420 - Flags: review?(cam) → review+
Comment on attachment 8802422 [details] [diff] [review] Part4. Rendering changes Review of attachment 8802422 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/nsCSSRendering.cpp @@ +1835,5 @@ > + backgroundClip == NS_STYLE_IMAGELAYER_CLIP_FILL || > + backgroundClip == NS_STYLE_IMAGELAYER_CLIP_STROKE || > + backgroundClip == NS_STYLE_IMAGELAYER_CLIP_VIEW || > + backgroundClip == NS_STYLE_IMAGELAYER_CLIP_NO_CLIP) { > + backgroundClip = NS_STYLE_IMAGELAYER_CLIP_BORDER; It would be nice to be able to assert that we don't get these values for background-clip (and only for mask-clip). But inside GetImageLayerClip we don't know if we're here for background or mask...
Attachment #8802422 - Flags: review?(cam) → review+
Comment on attachment 8802423 [details] [diff] [review] Part5. Testcase changes Review of attachment 8802423 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/style/test/property_database.js @@ +2372,5 @@ > inherited: false, > type: CSS_TYPE_LONGHAND, > initial_values: [ "padding-box" ], > other_values: [ "border-box", "content-box", "border-box, padding-box", "padding-box, padding-box, padding-box", "border-box, border-box" ], > + invalid_values: [ "margin-box", "padding-box padding-box", "fill-box", "stroke-box", "view-box" ] Put no-clip in here too?
Attachment #8802423 - Flags: review?(cam) → review+
Since these properties are enabled by default on Nightly (and Aurora) currently, we shouldn't land these changes until we have the rendering changes ready to land at the same time. Otherwise style sheets like the following will be broken, as it will seem like these keywords are supported but their rendering isn't: @supports (mask-clip: fill-box) { /* for when the browser supports mask-clip:fill-box */ #abc { mask-image: url(...); mask-clip: fill-box; ... } #abc-fallback { display: none; } } @supports not (mask-clip: fill-box) { /* for when the browser doesn't support mask-clip:fill-box */ #abc { display: none; } #abc-fallback { display: block; } }
(In reply to Cameron McCormack (:heycam) (away Oct 25) from comment #15) > Comment on attachment 8802423 [details] [diff] [review] > Part5. Testcase changes > > Review of attachment 8802423 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: layout/style/test/property_database.js > @@ +2372,5 @@ > > inherited: false, > > type: CSS_TYPE_LONGHAND, > > initial_values: [ "padding-box" ], > > other_values: [ "border-box", "content-box", "border-box, padding-box", "padding-box, padding-box, padding-box", "border-box, border-box" ], > > + invalid_values: [ "margin-box", "padding-box padding-box", "fill-box", "stroke-box", "view-box" ] > > Put no-clip in here too? Oh, 'no-clip' should be here. I'll add it.
Attached patch Part1. Style const changes. (carry r+: heycam) (obsolete) — — Splinter Review
Address heycam's comments.
Attachment #8802418 - Attachment is obsolete: true
Attached patch Part5. Testcase changes (carry r+: heycam) (obsolete) — — Splinter Review
Add 'no-clip' for invalid value of background-origin.
Attachment #8802423 - Attachment is obsolete: true
Attached patch Part2. Style structure changes (obsolete) — — Splinter Review
Address comment 12.
Attachment #8802419 - Attachment is obsolete: true
Attachment #8806223 - Flags: review?(cam)
No longer blocks: mask-ship
(In reply to Ethan Lin[:ethlin] from comment #20) > Created attachment 8806223 [details] [diff] [review] > Part2. Style structure changes > > Address comment 12. Don't we need to change how CSSParserImpl::ParseImageLayersItem works so that it uses the correct keyword table for the origin property, i.e. uses kBackgroundOriginKTable or kMaskOriginKTable depending on what property we're parsing?
Flags: needinfo?(ethlin)
(In reply to Cameron McCormack (:heycam) from comment #21) > Don't we need to change how CSSParserImpl::ParseImageLayersItem works so > that it uses the correct keyword table for the origin property, i.e. uses > kBackgroundOriginKTable or kMaskOriginKTable depending on what property > we're parsing? We should do this. I'll update the patch.
Flags: needinfo?(ethlin)
Attached patch Part2. Style structure changes (obsolete) — — Splinter Review
Choose correct table (kBackgroundOriginKTable or kMaskOriginKTable) in ParseImageLayersItem.
Attachment #8806223 - Attachment is obsolete: true
Attachment #8806223 - Flags: review?(cam)
Attachment #8807412 - Flags: review?(cam)
Comment on attachment 8807412 [details] [diff] [review] Part2. Style structure changes Review of attachment 8807412 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/style/nsCSSParser.cpp @@ +12226,5 @@ > > + MOZ_ASSERT(aTable == nsStyleImageLayers::kBackgroundLayerTable || > + aTable == nsStyleImageLayers::kMaskLayerTable); > + const KTableEntry* originTable = (aTable == nsStyleImageLayers::kBackgroundLayerTable) ? > + nsCSSProps::kBackgroundOriginKTable : nsCSSProps::kMaskOriginKTable; I just thought of a slightly better way to get the origin table. You can use nsCSSProps::kKeywordTableTable to look it up based on whether we have background-origin or mask-origin in aTable. So: const KTableEntry* originTable = nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::origin]]; Then we don't need the assertion on the aTable value itself. So, r=me with that (here, and below for looping and the clip keyword table, and in Declaration.cpp too).
Attachment #8807412 - Flags: review?(cam) → review+
(In reply to Cameron McCormack (:heycam) from comment #24) > Comment on attachment 8807412 [details] [diff] [review] > Part2. Style structure changes > > Review of attachment 8807412 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: layout/style/nsCSSParser.cpp > @@ +12226,5 @@ > > > > + MOZ_ASSERT(aTable == nsStyleImageLayers::kBackgroundLayerTable || > > + aTable == nsStyleImageLayers::kMaskLayerTable); > > + const KTableEntry* originTable = (aTable == nsStyleImageLayers::kBackgroundLayerTable) ? > > + nsCSSProps::kBackgroundOriginKTable : nsCSSProps::kMaskOriginKTable; > > I just thought of a slightly better way to get the origin table. You can > use nsCSSProps::kKeywordTableTable to look it up based on whether we have > background-origin or mask-origin in aTable. So: > > const KTableEntry* originTable = > nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::origin]]; > > Then we don't need the assertion on the aTable value itself. > > So, r=me with that (here, and below for looping and the clip keyword table, > and in Declaration.cpp too). Okay, thanks for the review.
Address :heycam's comment.
Attachment #8807412 - Attachment is obsolete: true
Attachment #8808021 - Attachment description: Part2. Style structure changes → Part2. Style structure changes (carry r: heycam)
Whiteboard: tlt-wip
Ehtan, https://treeherder.mozilla.org/#/jobs?repo=try&revision=99a88b0c346c6e38eab49dbd190c01d4b4119fb3&selectedJob=31657719 TEST-UNEXPECTED-FAIL | layout/style/test/test_property_syntax_errors.html | invalid value 'margin-box' not accepted for 'mask-origin' property - got "margin-box", expected "" Not only mask-clip, you probably should also update mask-origin valid/invalid value in property database
Depends on: 1319667
Using mozreview is easier for bug 1311270 to merge and push the patches. I also rebased the patches. :heycam, sorry for sending review request again.
Attachment #8802420 - Attachment is obsolete: true
Attachment #8802422 - Attachment is obsolete: true
Attachment #8806221 - Attachment is obsolete: true
Attachment #8806222 - Attachment is obsolete: true
Attachment #8808021 - Attachment is obsolete: true
Ethan, bug 1260094 commend 6. We probably should remove implementation of margin-box first.
(In reply to C.J. Ku[:cjku](UTC+8) from comment #34) > Ethan, bug 1260094 commend 6. We probably should remove implementation of > margin-box first. Okay, I'll update the patches.
Comment on attachment 8814024 [details] Bug 1303623 - Part2. Style structure changes. https://reviewboard.mozilla.org/r/95328/#review95618 ::: layout/style/Declaration.cpp:404 (Diff revision 2) > - for (size_t i = 0; nsCSSProps::kImageLayerOriginKTable[i].mValue != -1; i++) { > + const nsCSSProps::KTableEntry* originTable = nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::origin]]; > + const nsCSSProps::KTableEntry* clipTable = nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::clip]]; Please keep these within 80 columns. ::: layout/style/nsCSSParser.cpp:12365 (Diff revision 2) > haveOrigin = false, > haveComposite = false, > haveMode = false, > haveSomething = false; > > + const KTableEntry* originTable = nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::origin]]; Here too. ::: layout/style/nsCSSParser.cpp:12450 (Diff revision 2) > > // The spec allows a second box value (for background-clip), > // immediately following the first one (for background-origin). > > #ifdef DEBUG > - for (size_t i = 0; nsCSSProps::kImageLayerOriginKTable[i].mValue != -1; i++) { > + const KTableEntry* clipTable = nsCSSProps::kKeywordTableTable[aTable[nsStyleImageLayers::clip]]; And here.
Attachment #8814024 - Flags: review?(cam) → review+
Attachment #8814023 - Flags: review?(cam) → review+
Attachment #8814025 - Flags: review?(cam) → review+
Attachment #8814026 - Flags: review?(cam) → review+
Attachment #8814027 - Flags: review?(cam) → review+
Looks good. Again, let's not land this until bug 1311270 is ready to land.
These are already documented at https://developer.mozilla.org/en-US/docs/Web/CSS/mask-clip https://developer.mozilla.org/en-US/docs/Web/CSS/mask-origin And the Fx53 release notes already mention support for the mask-* properties. So I don't think anything else needs to be done for the docs.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: