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

Add a simple implementation of CanvasRenderingContext2d.fillText #25782

Merged
merged 2 commits into from Mar 19, 2020

Conversation

@kaiakz
Copy link
Contributor

kaiakz commented Feb 17, 2020

I added a simple implementation of CanvasRenderingContext2d.fillText.
Some code are merged from @mikrut, and I fixed a bug about text scaling.
Also, the bug of text rotation should be fixed after raqote merged my other PR.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix (part of) #11681 (GitHub issue number if applicable)
  • There are tests for these changes
@highfive
Copy link

highfive commented Feb 17, 2020

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @asajeffrey (or someone else) soon.

@kaiakz kaiakz requested a review from jdm Feb 17, 2020
@jdm jdm assigned jdm and unassigned asajeffrey Feb 21, 2020
@jdm
Copy link
Member

jdm commented Feb 21, 2020

@bors-servo try=wpt

@jdm
jdm approved these changes Feb 21, 2020
@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2020

Trying commit 573b6a4 with merge a2bb672...

bors-servo added a commit that referenced this pull request Feb 21, 2020
Add a simple implementation of CanvasRenderingContext2d.fillText

<!-- Please describe your changes on the following line: -->
I added a simple implementation of CanvasRenderingContext2d.fillText.
Some code are merged from @mikrut, and I fixed a bug about text scaling.
Also, the bug of text rotation should be fixed after `raqote` merged my other PR.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11681 (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2020

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Feb 21, 2020

  ▶ FAIL [expected PASS] /2dcontext/text-styles/canvas_text_font_001.htm
  │   → /2dcontext/text-styles/canvas_text_font_001.htm 54ed3fe6baf2d8bc9bddcdb0e82725a5c568a6e6
  └   → /2dcontext/text-styles/canvas_text_font_001-ref.htm 652917f3c91833309587adc905f58a56e6998530

This means that you will need to run:

  1. ./mach test-wpt /2dcontext/text-styles/canvas_text_font_001.htm --log-raw wpt
  2. ./mach update-wpt
  3. git add tests/wpt/metadata/2dcontext
    And commit the changes.
@kaiakz
Copy link
Contributor Author

kaiakz commented Feb 21, 2020

@jdm
./mach test-wpt /2dcontext/text-styles/canvas_text_font_001.htm --log-raw wpt says:

 0:03.57 INFO Using 8 client processes
 0:03.66 INFO Starting http server on 127.0.0.1:8000
 0:03.66 INFO Starting http server on 127.0.0.1:8001
 0:03.68 INFO Starting https server on 127.0.0.1:8443
 0:04.15 SUITE_START: web-platform-test - running 1 tests
 0:04.15 INFO Running reftest tests
 0:04.16 INFO Starting runner
 0:04.17 INFO No more tests
 0:04.17 INFO No more tests
 0:04.17 INFO No more tests
 0:04.17 INFO No more tests
 0:04.18 INFO No more tests
 0:04.18 TEST_START: /2dcontext/text-styles/canvas_text_font_001.htm
 0:04.18 INFO No more tests
 0:04.18 WARNING Got command init_succeeded in state running
 0:04.18 INFO No more tests
 0:04.56 pid:8768 Full command: /run/media/kaiakz/Data/moz/folk/servo/target/debug/servo --hard-fail -u Servo/wptrunner -z http://web-platform.test:8000/2dcontext/text-styles/canvas_text_font_001.htm -Z disable-text-aa,load-webfonts-synchronously,replace-surrogates --user-stylesheet /run/media/kaiakz/Data/moz/folk/servo/resources/ahem.css --pref dom.canvas-text.enabled=false --certificate-path /run/media/kaiakzi/Data/moz/folk/servo/tests/wpt/web-platform-tests/tools/certs/cacert.pem --exit --output=/tmp/tmpsNxVdR/39f64eea-4444-4292-b235-2488ae0592ff --resolution 800x600
pid:8768 
 0:04.56 pid:8768 
 0:04.57 pid:8768 
 0:08.77 pid:8768 [2020-02-21T11:20:24Z ERROR script::dom::bindings::error] Error at http://web-platform.test:8000/2dcontext/text-styles/canvas_text_font_001.htm:20:21 ctx.fillText is not a function
 0:09.62 pid:8768 Shutting down the Constellation after generating an output file or exit flag specified
 0:09.90 pid:8864 Full command: /run/media/kaiakz/Data/moz/folk/servo/target/debug/servo --hard-fail -u Servo/wptrunner -z http://web-platform.test:8000/2dcontext/text-styles/canvas_text_font_001-ref.htm -Z disable-text-aa,load-webfonts-synchronously,replace-surrogates --user-stylesheet /run/media/kaiakz/Data/moz/folk/servo/resources/ahem.css --certificate-path /run/media/kaiakz/Data/moz/folk/servo/tests/wpt/web-platform-tests/tools/certs/cacert.pem --exit --output=/tmp/tmpsNxVdR/a15d030f-1666-4ac9-b93a-a63583a11768 --resolution 800x600
pid:8864 
 0:09.90 pid:8864 
 0:09.90 pid:8864 
 0:14.39 pid:8864 Shutting down the Constellation after generating an output file or exit flag specified
 0:15.21 INFO Image hashes didn't match, checking pixel differences
 0:15.32 INFO Found 900 pixels different, maximum difference per channel 255
 0:15.32 TEST_END: FAIL, expected PASS - /2dcontext/text-styles/canvas_text_font_001.htm 1fa1aef7b66b7af2d04621d380782299ec9c0e10
/2dcontext/text-styles/canvas_text_font_001-ref.htm d8c11dca7773f5977e977513c7310bd60d853355
 0:15.32 INFO No more tests
 0:15.33 INFO Closing logging queue
 0:15.33 INFO queue closed
 0:15.33 INFO Running wdspec tests
 0:15.33 INFO No wdspec tests to run
 0:15.33 INFO Running testharness tests
 0:15.33 INFO No testharness tests to run
 0:15.33 INFO Running crashtest tests
 0:15.33 INFO No crashtest tests to run
 0:15.33 INFO Got 1 unexpected results
 0:15.33 SUITE_END

web-platform-test
~~~~~~~~~~~~~~~~~
Ran 1 checks (1 tests)
Expected results: 0
Unexpected results: 1
  test: 1 (1 fail)

Unexpected Results
------------------
FAIL /2dcontext/text-styles/canvas_text_font_001.htm - /2dcontext/text-styles/canvas_text_font_001.htm 1fa1aef7b66b7af2d04621d380782299ec9c0e10
/2dcontext/text-styles/canvas_text_font_001-ref.htm d8c11dca7773f5977e977513c7310bd60d853355
 0:15.37 INFO Closing logging queue
 0:15.37 INFO queue closed

How can I fix it? Does it mean I have to implement the canvas_text_font?

@jdm
Copy link
Member

jdm commented Feb 21, 2020

@kaiakz I gave you the steps to fix it - the current implementation test fails because the reference rendering does not match the test rendering, because the font support isn't implemented. The steps I suggested update the expected test result to indicate that the test will not pass, so the test failure won't be reported as a problem.

@jdm
Copy link
Member

jdm commented Feb 21, 2020

r? @pcwalton
Could you check if this looks like a reasonable first cut at a canvas text implementation, disregarding the lack of font selection?

@highfive highfive assigned pcwalton and unassigned jdm Feb 21, 2020
pattern: canvas_data::Pattern,
draw_options: &DrawOptions,
) {
let font = SystemSource::new()

This comment has been minimized.

@pcwalton

pcwalton Feb 21, 2020

Contributor

Needs a TODO because this should eventually use the same infrastructure as layout (i.e. layout should be updated to use font-kit as well).

This comment has been minimized.

@pcwalton

pcwalton Feb 21, 2020

Contributor

Also, this is in the chrome process, right? It needs to not be in the content process because the content process shouldn't have access to the SystemSource. (It's too dangerous; on macOS for example it needs a connection to the font server, which has had a lot of security vulnerabilities.)

This comment has been minimized.

@jdm

jdm Feb 21, 2020

Member

Yes, the canvas code runs in the chrome process.

This comment has been minimized.

@kaiakz

kaiakz Feb 22, 2020

Author Contributor

So, I need to do:

  1. add a TODO to raqote_backend.rs
  2. move font_kit code from raqote_backend.rs to canvas_data.rs and pass the SystemSource things through` the parameter?(Well, my code made some compromised, since I am not familiar with all components.)

Also, this is in the chrome process, right? It needs to not be in the content process because the content process shouldn't have access to the SystemSource.

I noticed there is a FontCacheThread, maybe I can use it?

This comment has been minimized.

@jdm

jdm Feb 24, 2020

Member

Let's keep the font_kit code in raqote_backend.rs for now until it's more clear how the proper font integration will work. The FontCacheThread is integrated with many other parts of the system, so converting that code to use font_kit will be part of resolving that TODO.

This comment has been minimized.

@kaiakz

kaiakz Feb 25, 2020

Author Contributor

@jdm
If I understood well, I moved all font_kit code to raqote_backend.rs, including some functions:
replace_whitespace & get_text_width( They are parts of text preparation algorithm, in fact, I just moved the algorithm to raqote_backend.rs).

I would like to do the converting if have any spare time. 😄

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2020

Testing commit 777b9d7 with merge 8d9a099...

bors-servo added a commit that referenced this pull request Mar 19, 2020
Add a simple implementation of CanvasRenderingContext2d.fillText

<!-- Please describe your changes on the following line: -->
I added a simple implementation of CanvasRenderingContext2d.fillText.
Some code are merged from @mikrut, and I fixed a bug about text scaling.
Also, the bug of text rotation should be fixed after `raqote` merged my other PR.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (part of) #11681 (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2020

💔 Test failed - status-taskcluster

@pylbrecht
Copy link
Contributor

pylbrecht commented Mar 19, 2020

The layout-2020 equivalents must be updated as well (see #25940 (comment) for an explanation why). The layout-2020 tests' metadata files are located in tests/wpt/metadata-layout-2020/.

1 unexpected results that are NOT known-intermittents:
  ▶ Unexpected subtest result in /2dcontext/line-styles/2d.line.cap.closed.html:
  └ PASS [expected FAIL] Line caps are not drawn at the corners of an unclosed rectangle
2 unexpected results that are NOT known-intermittents:
  ▶ Unexpected subtest result in /2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fillText.html:
  │ FAIL [expected PASS] Canvas test: 2d.gradient.interpolate.zerosize.fillText
  │   → assert_equals: d[12824] expected 0 but got 28
  │ 
  │ testColor@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:78:22
  │ _assertGreen@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:84:22
  │ @http://web-platform.test:8000/2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fillText.html:31:13
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1958:25
  │ _addTest/</<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:66:15
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1958:25
  └ _addTest/<@http://web-platform.test:8000/2dcontext/resources/canvas-tests.js:63:11
  ▶ Unexpected subtest result in /2dcontext/fill-and-stroke-styles/2d.gradient.radial.inside3.html:
  └ PASS [expected FAIL] Canvas test: 2d.gradient.radial.inside3
@kaiakz
Copy link
Contributor Author

kaiakz commented Mar 19, 2020

@pylbrecht
How did you update the layout-2020 tests' metadata files? ./mach test-wpt & ./mach update-wpt do not work for those.

@jdm
Copy link
Member

jdm commented Mar 19, 2020

Sorry, let's just wait for #25960 to merge.

@pylbrecht
Copy link
Contributor

pylbrecht commented Mar 19, 2020

I did it manually: copying the corresponding .ini file from the regular tests/wpt/metadata/ directory to the tests/wpt/metadata-layout-2020/ directory in case of a FAIL, or deleting the corresponding .ini file in case of a PASS.
But I think you also can wait until #25960 is merged.

@jdm
Copy link
Member

jdm commented Mar 19, 2020

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2020

Testing commit 777b9d7 with merge 3735f7a...

bors-servo added a commit that referenced this pull request Mar 19, 2020
Add a simple implementation of CanvasRenderingContext2d.fillText

<!-- Please describe your changes on the following line: -->
I added a simple implementation of CanvasRenderingContext2d.fillText.
Some code are merged from @mikrut, and I fixed a bug about text scaling.
Also, the bug of text rotation should be fixed after `raqote` merged my other PR.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix (part of) #11681 (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2020

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Mar 19, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2020

Testing commit 777b9d7 with merge ffdb83b...

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2020

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing ffdb83b to master...

@bors-servo bors-servo merged commit ffdb83b into servo:master Mar 19, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
@paulrouget
Copy link
Contributor

paulrouget commented Mar 23, 2020

This makes servo crash on Windows: #26015

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.