Closed Bug 1258286 Opened 8 years ago Closed 8 years ago

initial value for mask-origin property should be border-box, not padding-box

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: bmo, Assigned: bmo)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(2 files, 12 obsolete files)

2.20 KB, patch
bmo
: review+
Details | Diff | Splinter Review
44.44 KB, patch
bmo
: review+
Details | Diff | Splinter Review
Attached file mask-origin-1-ref.html (obsolete) —
initial value of mask-origin is border-box. From the attached test cases, we observed that the default value of current impl is padding-box instead of border-box.

property spec- https://drafts.fxtf.org/css-masking-1/#the-mask-origin
Attached file reference html (obsolete) —
Attachment #8732734 - Attachment is obsolete: true
cjku, can you suggest where to start to solve this issue ? I'd like to work on this issue directly. Thanks.
Flags: needinfo?(cku)
I guess you may try to modify the default value here
https://dxr.mozilla.org/mozilla-central/source/layout/style/nsStyleStruct.cpp#2529
Change mOrigin(NS_STYLE_IMAGELAYER_ORIGIN_PADDING) to mOrigin(NS_STYLE_IMAGELAYER_ORIGIN_BORDER), and see the result.

If you get correct rendering result after that... you know what to do.
Flags: needinfo?(cku)
Assignee: nobody → aschen
Status: NEW → ASSIGNED
Will this change bring us closer or further from matching other implementations?
(In reply to David Baron [:dbaron] ⌚️UTC-7 (review requests must explain patch) from comment #7)
> Will this change bring us closer or further from matching other
> implementations?

Yes. AFAIK, Webkit/Blink/Opera behave correctly as spec said. We need to fix this bug before ship.
* * *
try: -b do -p all -u all -t none
Attachment #8756707 - Attachment is obsolete: true
Attached patch Part 2 - update w3c css tests (obsolete) — Splinter Review
Attachment #8756840 - Flags: feedback?(cku)
Comment on attachment 8756840 [details] [diff] [review]
Part 1 - add layer types to nsStyleImageLayers and layer initialization

Review of attachment 8756840 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/style/nsComputedDOMStyle.cpp
@@ +6108,3 @@
>        !firstLayer.mSize.IsInitialValue() ||
>        !(firstLayer.mImage.GetType() == eStyleImageType_Null ||
> +        firstLayer.mImage.GetType() == eStyleImageType_Image)) {

Have nsStyleImages::IsInitialValue(aLyaerIndex) to hide all these detail

::: layout/style/nsStyleStruct.cpp
@@ +2551,5 @@
> +  } else if (aType == LayerType::Mask) {
> +    mXRepeat = NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT;
> +    mYRepeat = NS_STYLE_IMAGELAYER_REPEAT_NO_REPEAT;
> +  } else {
> +    MOZ_ASSERT(false, "not supported layer type.");

MOZ_UNREACHABLE

@@ +2580,5 @@
> +    mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_PADDING;    
> +  } else if (aType == LayerType::Mask) {
> +    mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_BORDER;    
> +  } else {
> +    MOZ_ASSERT(false, "unsupported style image layer type.");

MOZ_UNREACHABLE

::: layout/style/nsStyleStruct.h
@@ +492,5 @@
> +    Background = 0,
> +    Mask
> +  };
> +
> +  nsStyleImageLayers(LayerType type);

nsStyleImageLayers() = delete, if possible
Attachment #8756840 - Flags: feedback?(cku) → feedback+
Re comment 14:
s/MOZ_UNREACHABLE/MOZ_ASSERT_UNREACHABLE
* * *
try: -b do -p all -u all -t none
* * *
temp
Attachment #8756840 - Attachment is obsolete: true
Attached patch Part 2 - update w3c css tests (obsolete) — Splinter Review
Attachment #8756841 - Attachment is obsolete: true
Attachment #8757180 - Attachment is obsolete: true
Attachment #8757236 - Flags: review?(cam)
Comment on attachment 8757181 [details] [diff] [review]
Part 2 - update w3c css tests

previous code was wrong and rectified in this patch.
Attachment #8757181 - Flags: review?(cam)
Attachment #8757236 - Attachment is obsolete: true
Attachment #8757236 - Flags: review?(cam)
Comment on attachment 8757249 [details] [diff] [review]
Part 1 - add layer types to nsStyleImageLayers and layer initialization

Addressed "error: bad implicit conversion constructor for 'nsStyleImageLayers'" on try.
Attachment #8757249 - Flags: review?(cam)
Blocks: 1273804
Summary: default value for mask-origin property is border-box but padding-box → initial value for mask-origin property should be border-box, not padding-box
Summary: initial value for mask-origin property should be border-box, not padding-box → initial value for mask-origin/mask-repeat properties should be border-box/no-repeat, not padding-box/repeat
(Sorry for the bug title spam, didn't realize mask-repeat is being handled in another bug.)
Summary: initial value for mask-origin/mask-repeat properties should be border-box/no-repeat, not padding-box/repeat → initial value for mask-origin property should be border-box, not padding-box
Comment on attachment 8757249 [details] [diff] [review]
Part 1 - add layer types to nsStyleImageLayers and layer initialization

Review of attachment 8757249 [details] [diff] [review]:
-----------------------------------------------------------------

Can we avoid storing the layer type in the nsStyleImageLayers object?  It looks like we generally pass in the layer type into functions on the nsStyleImageLayers object.  We only use mLayerType outside of the constructor in nsComputedDOMStyle::DoGetMask, and in there we know this is for a mask-* property so we can just pass in nsStyleImageLayers::LayerType::Mask directly.

::: layout/style/nsComputedDOMStyle.cpp
@@ +6103,5 @@
>        firstLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_PADDING ||
>        firstLayer.mComposite != NS_STYLE_MASK_COMPOSITE_ADD ||
>        firstLayer.mMaskMode != NS_STYLE_MASK_MODE_MATCH_SOURCE ||
>        !firstLayer.mPosition.IsInitialValue() ||
> +      !firstLayer.mRepeat.IsInitialValue(svg->mMask.GetLayerType()) ||

Just pass in nsStyleImageLayers::LayerType::Mask.

::: layout/style/nsStyleStruct.cpp
@@ +2559,3 @@
>  }
>  
>  nsStyleImageLayers::Layer::Layer()

Can you add a comment in nsStyleStruct.h that this constructor does not initialize mRepeat or mOrigin and that Initialize() must be called to do that.

@@ +2573,5 @@
>  nsStyleImageLayers::Layer::~Layer()
>  {
>  }
>  
> +void nsStyleImageLayers::Layer::Initialize(nsStyleImageLayers::LayerType aType)

Newline after "void".

@@ +2582,5 @@
> +    mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_PADDING;
> +  } else if (aType == LayerType::Mask) {
> +    mOrigin = NS_STYLE_IMAGELAYER_ORIGIN_BORDER;
> +  } else {
> +    MOZ_ASSERT_UNREACHABLE("unsupported layer type.");

Let's make the unexpected case still do something reasonable.  So something like:

if (aType == LayerType::Mask) {
  mOrigin = ...;
} else {
  MOZ_ASSERT(aType == LayerType::Background, ...);
  mOrigin = ...;
}

@@ +2650,5 @@
>  
>  nsStyleBackground::nsStyleBackground(StyleStructContext aContext)
> +  : mImage(nsStyleImageLayers::LayerType::Background)
> +  , mBackgroundColor(NS_RGBA(0, 0, 0, 0))
> +  

Nit: Remove the blank line.
Attachment #8757249 - Flags: review?(cam)
Attachment #8757249 - Attachment is obsolete: true
Comment on attachment 8757775 [details] [diff] [review]
Part 1 - add layer types to nsStyleImageLayers and layer initialization. r?=heycam

Addressed review comment 24 and re-submitted the patch for 2nd review.
Attachment #8757775 - Attachment description: Part 1 - add layer types to nsStyleImageLayers and layer initialization → Part 1 - add layer types to nsStyleImageLayers and layer initialization. r?=heycam
Attachment #8757775 - Flags: review?(cam)
Attachment #8757775 - Attachment is obsolete: true
Attachment #8757775 - Flags: review?(cam)
Comment on attachment 8757780 [details] [diff] [review]
Part 1 - add layer types to nsStyleImageLayers and layer initialization. r?=heycam

Updated patch since I forgot to qref on last upload. Sorry for this.
Attachment #8757780 - Attachment description: Part 1 - add layer types to nsStyleImageLayers and layer initialization → Part 1 - add layer types to nsStyleImageLayers and layer initialization. r?=heycam
Attachment #8757780 - Flags: review?(cam)
Target Milestone: --- → mozilla49
Blocks: 1258623
Attachment #8757780 - Flags: review?(cam) → review+
Comment on attachment 8757181 [details] [diff] [review]
Part 2 - update w3c css tests

Review of attachment 8757181 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with this change.

::: layout/reftests/w3c-css/submitted/masking/mask-repeat-1-ref.html
@@ +23,5 @@
> +        width: 50px; height: 50px;
> +      }
> +
> +      #repeat-x {
> +        position: absolute; top: 0;

The left: 0; top: 0; properties aren't needed since these divs are positioned at (0, 0) anyway.  So either remove them from the #default, #repeat-x, #repeat-y rules or consistently set both of them.  (At the moment you set only top in #repeat-x and only left in #repeat-y.)
Attachment #8757181 - Flags: review?(cam) → review+
Attachment #8757780 - Attachment is obsolete: true
Attachment #8757181 - Attachment is obsolete: true
Comment on attachment 8758525 [details] [diff] [review]
Part 1 - add layer types to nsStyleImageLayers and layer initialization. r=heycam

Carry r+. r=heycam.
Attachment #8758525 - Attachment description: Part 1 - add layer types to nsStyleImageLayers and layer initialization → Part 1 - add layer types to nsStyleImageLayers and layer initialization. r=heycam
Attachment #8758525 - Flags: review+
Comment on attachment 8758526 [details] [diff] [review]
Part 2 - update w3c css masking mask-repeat ref test case. r=heycam

Addressed review comment 29 and carry r+. r=heycam.
Attachment #8758526 - Attachment description: Part 2 - update w3c css masking mask-repeat ref test case → Part 2 - update w3c css masking mask-repeat ref test case. r=heycam
Attachment #8758526 - Flags: review+
Keywords: checkin-needed
Pushed by tlin@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a9db7e5634d7
Part 1 - add layer types to nsStyleImageLayers and layer initialization. r=heycam
https://hg.mozilla.org/integration/mozilla-inbound/rev/d5832177887d
Part 2 - update w3c css masking mask-repeat ref test case. r=heycam
Keywords: checkin-needed
sorry had to back this out for test failures like https://treeherder.mozilla.org/logviewer.html#?job_id=29183980&repo=mozilla-inbound
Flags: needinfo?(aschen)
Backout by cbook@mozilla.com:
https://hg.mozilla.org/mozilla-central/rev/b8dddcad3c5e
Backed out changeset d5832177887d 
https://hg.mozilla.org/mozilla-central/rev/c2b9ede08259
Backed out changeset a9db7e5634d7 for test_smilCSSFromTo.xhtml test failures
(In reply to Carsten Book [:Tomcat] from comment #35)
> sorry had to back this out for test failures like
> https://treeherder.mozilla.org/logviewer.html#?job_id=29183980&repo=mozilla-
> inbound

Thanks for doing this and sorry for the fault I'd made here. I'll address this failure carefully.
Flags: needinfo?(aschen)
Blocks: 1235015
Attachment #8758525 - Attachment is obsolete: true
Comment on attachment 8759910 [details] [diff] [review]
Part 1 - add layer types to nsStyleImageLayers and layer initialization. r=heycam

Addressed try failure. New try result looks good now.

https://treeherder.mozilla.org/#/jobs?repo=try&revision=1e1bdb5d41a5&selectedJob=21953549
Attachment #8759910 - Attachment description: Part 1 - add layer types to nsStyleImageLayers and layer initialization → Part 1 - add layer types to nsStyleImageLayers and layer initialization. r=heycam
Attachment #8759910 - Flags: review+
good to go now.
Keywords: checkin-needed
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/0839610737b4
Part 1 - add layer types to nsStyleImageLayers and layer initialization. r=heycam
https://hg.mozilla.org/integration/mozilla-inbound/rev/f930971eaa0d
Part 2 - update w3c css masking mask-repeat ref test case. r=heycam
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/0839610737b4
https://hg.mozilla.org/mozilla-central/rev/f930971eaa0d
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: