Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement currentColor for Canvas colors #7120

Merged
merged 1 commit into from Nov 23, 2015
Merged

Conversation

@dzbarsky
Copy link
Member

dzbarsky commented Aug 10, 2015

I made addColorStop throw for currentColor, which matches Firefox. It's easy enough to change the behavior to fetch the color from the canvas, which is what Chrome and Safari do. I'll file a spec bug to decide what to do here.

Review on Reviewable

@dzbarsky dzbarsky force-pushed the dzbarsky:currentcolor branch from 343cadc to f318ff1 Aug 10, 2015
@Ms2ger
Copy link
Contributor

Ms2ger commented Aug 10, 2015

It's easy enough to change the behavior to fetch the color from the canvas

It actually isn't: these objects are not bound to one particular canvas.

@dzbarsky dzbarsky force-pushed the dzbarsky:currentcolor branch 2 times, most recently from 85a6349 to 813f4a8 Aug 11, 2015
@dzbarsky
Copy link
Member Author

dzbarsky commented Aug 11, 2015

Simon found the spec text in #7106 and I updated the PR to match. It doesn't check whether the canvas is actually being rendered, I'll do that in a followup since I'll need to add a new message and some layout code.

@dzbarsky
Copy link
Member Author

dzbarsky commented Aug 11, 2015

The second commit checks if the canvas is rendered before grabbing the used color for currentColor.
With it, we pass the following testcase:

     var canvas = document.getElementById('canvas');
    var ctx = canvas.getContext('2d');
    canvas.style.color = 'red';
    canvas.style.display = 'none';
    canvas.offsetTop;
    ctx.fillStyle = 'currentColor';
 canvas.style.display = 'inline';
  ctx.fillRect(0, 0, 100, 50);

However, Firefox, Chrome, and Safari all display a red rect instead of a black one, so I think this requirement isn't actually necessary.

@Ms2ger
Copy link
Contributor

Ms2ger commented Aug 11, 2015

I don't see that test case in the PR? ;)

@dzbarsky
Copy link
Member Author

dzbarsky commented Aug 11, 2015

I didn't want to spend effort making it an actual reftest in case we decided not to land the second patch. If you think we should follow the spec here instead of changing it to match browsers, I can add the test.

@Ms2ger
Copy link
Contributor

Ms2ger commented Aug 11, 2015

I'd probably stick with matching current browsers and filing issues. I still want the test, though, with the colours swapped.

@dzbarsky dzbarsky force-pushed the dzbarsky:currentcolor branch from 1526c19 to 2fec1c8 Aug 11, 2015
@dzbarsky
Copy link
Member Author

dzbarsky commented Aug 11, 2015

Ok, I changed the test a little and added it.

@bors-servo
Copy link
Contributor

bors-servo commented Aug 11, 2015

The latest upstream changes (presumably #7104) made this pull request unmergeable. Please resolve the merge conflicts.

@dzbarsky dzbarsky force-pushed the dzbarsky:currentcolor branch 2 times, most recently from a25c698 to 1637b0e Aug 11, 2015
@nox nox removed the S-needs-rebase label Aug 18, 2015
@dzbarsky dzbarsky force-pushed the dzbarsky:currentcolor branch from 1637b0e to 2c4ce40 Aug 18, 2015
@bors-servo
Copy link
Contributor

bors-servo commented Aug 27, 2015

The latest upstream changes (presumably #7416) made this pull request unmergeable. Please resolve the merge conflicts.

@dzbarsky dzbarsky force-pushed the dzbarsky:currentcolor branch 2 times, most recently from 4ef38f6 to 01bd6c5 Aug 28, 2015
@bors-servo
Copy link
Contributor

bors-servo commented Aug 28, 2015

The latest upstream changes (presumably #7431) made this pull request unmergeable. Please resolve the merge conflicts.

@metajack
Copy link
Contributor

metajack commented Sep 1, 2015

r? @Ms2ger

@dzbarsky dzbarsky force-pushed the dzbarsky:currentcolor branch from 01bd6c5 to 6725e8a Sep 8, 2015
@highfive highfive assigned SimonSapin and unassigned Ms2ger Sep 28, 2015
@SimonSapin
Copy link
Member

SimonSapin commented Sep 28, 2015

Reviewed 7 of 7 files at r1.
Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


components/script/dom/canvasgradient.rs, line 53 [r1] (raw file):
Is this function still used at all? If not, please remove it.


components/script/dom/canvasrenderingcontext2d.rs, line 426 [r1] (raw file):
This seems wasteful: it serializes an RGBA struct to a string just to parse it again. Could this code access the ComputedValues struct directly, rather than use GetComputedStyle?


tests/wpt/web-platform-tests/2dcontext/fill-and-stroke-styles/2d.fillStyle.parse.current.notrendered.html, line 2 [r1] (raw file):
I don’t see this file upstream. @Ms2ger, would it be removed at the next sync? Should it go to tests/wpt/mozilla instead?


Comments from the review on Reviewable.io

@frewsxcv
Copy link
Member

frewsxcv commented Nov 20, 2015

@dzbarsky Any updates on this?

@dzbarsky
Copy link
Member Author

dzbarsky commented Nov 20, 2015

Didn't realize this got reviewed, I'll fix it up.

@dzbarsky
Copy link
Member Author

dzbarsky commented Nov 21, 2015

Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


components/script/dom/canvasgradient.rs, line 53 [r1] (raw file):
which function? parse_color is still used in canvasrenderingcontext2d.


components/script/dom/canvasrenderingcontext2d.rs, line 426 [r1] (raw file):
It seems like we need a TSLayounNode to access ComputedStyles and I'm not even sure if that's ok to create from script. The complexity doesn't seem worth it for this edge case.


tests/wpt/web-platform-tests/2dcontext/fill-and-stroke-styles/2d.fillStyle.parse.current.notrendered.html, line 2 [r1] (raw file):
I believe it gets added for WPT (as opposed to CSS tests)


Comments from the review on Reviewable.io

@dzbarsky dzbarsky force-pushed the dzbarsky:currentcolor branch from 6725e8a to 8408891 Nov 21, 2015
@jdm
Copy link
Member

jdm commented Nov 21, 2015

The computed styles question sounds very similar to #7267.

@SimonSapin
Copy link
Member

SimonSapin commented Nov 23, 2015

@bors-servo r+


Reviewed 3 of 3 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from the review on Reviewable.io

@bors-servo
Copy link
Contributor

bors-servo commented Nov 23, 2015

📌 Commit 8408891 has been approved by SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Nov 23, 2015

Testing commit 8408891 with merge 0bf19b5...

bors-servo added a commit that referenced this pull request Nov 23, 2015
Implement currentColor for Canvas colors

I made addColorStop throw for currentColor, which matches Firefox.  It's easy enough to change the behavior to fetch the color from the canvas, which is what Chrome and Safari do. I'll file a spec bug to decide what to do here.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7120)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 23, 2015

💔 Test failed - mac-rel-wpt

@frewsxcv
Copy link
Member

frewsxcv commented Nov 23, 2015

./components/script/dom/canvasrenderingcontext2d.rs:444: missing space after ,
bors-servo added a commit that referenced this pull request Nov 23, 2015
Implement currentColor for Canvas colors

Fixes #7120.

This is #7120 by @dzbarsky, with one tidy error fixed.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8656)
<!-- Reviewable:end -->
@bors-servo bors-servo merged commit 8408891 into servo:master Nov 23, 2015
1 of 3 checks passed
1 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
homu Test failed
Details
code-review/reviewable Review complete: all files reviewed, all discussions resolved
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

9 participants
You can’t perform that action at this time.