Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement CanvasRenderingContext2d.fillText's "unimplemented" message #18020
Conversation
highfive
commented
Aug 9, 2017
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @metajack (or someone else) soon. |
highfive
commented
Aug 9, 2017
highfive
commented
Aug 9, 2017
|
So first of all, this is awesome, thank you! :) It's a bit unclear to me how easy it is to fill the missing pieces here. For the current 2d canvas APIs for now we use bindings to azure. So, in theory, the only thing that we have to do is to expose the text drawing APIs azure has, and use them from here, with the current parameters (that is, font-size, etc). That being said, I suspect this is not an easy task though. As far as I understand, all the text caches in azure aren't thread-safe, so it'd need a fair amount of work. It'd be nice to try to use another back-end, but that's also a huge amount of work. If we want to implement this properly, I'd rather discuss with people what's the best long-term fix for this. I know @asajeffrey has been fiddling with Canvas2D for a while now, so maybe he has ideas. @glennw may also have an opinion on what's the best way to support text stuff in Canvas2D. |
|
I've talked to @pcwalton about using a back-end based on webrender + pathfinder, so I'm not sure how much effort we should put in to updating the current azure back end. |
|
|
|
It may be interesting to provide a mock implementation for fillText or other missing Canvas2D methods before the long term webrender/pathfinder solution lands (any ETA on this? I'm assuming that it can take some time). Some WebGL demos that I try crash due to the missing methods and usually is to render a sprite not related to the game itself (e.g. the fps stats). I'd prefer some "unimplemented method" warnings in the console instead of a crash in those cases. Also a lot of WebGL tests are exiting early because of the missing fillText() function, it would be good to enable them. What do you think? |
|
@MortimerGoro I am confused how a missing JS method could cause a crash/panic in Servo. Do you mean that the tests report a JS exception? |
|
@jdm Yes, I meant that JavaScript/game execution "crashes" with a uncaught JS exception, not the servo process. |
|
I would be open to adding stubs for missing canvas APIs that are hidden behind a preference. |
|
|
|
Can you elaborate on that @jdm ? Basically change my |
|
Replace them with |
|
Not sure if this is what you were thinking about, and it doesn't really fix any of the mentioned issues, though, because they would require an actual implementation. I do understand, as per @MortimerGoro's comment that it's fine and this will somewhat improve things. Please let me know if I'm missing any other sort of unit tests or something. |
| @@ -800,6 +800,13 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { | |||
| receiver.recv().unwrap() | |||
| } | |||
|
|
|||
| // https://html.spec.whatwg.org/multipage/#dom-context-2d-filltext | |||
| fn FillText(&self, text: DOMString, x: f64, y: f64, max_width: Option<f64>) { | |||
| let parsed_text: String = text.parse().unwrap(); | |||
This comment has been minimized.
This comment has been minimized.
emilio
Aug 19, 2017
Member
This doesn't need parse(), you should be able to do into(), or if it doesn't exist, you may as well add it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
BrunoBernardino
Aug 19, 2017
Author
Contributor
Oh. I'm afraid DOMString doesn't have into() and I'm not sure how to add it to components/script/dom/bindings/str.rs, can you help?
This comment has been minimized.
This comment has been minimized.
BrunoBernardino
Aug 19, 2017
Author
Contributor
Apparently just .into() works. I was trying .into().unwrap(). Thanks!
|
|
| @@ -1,7 +1,7 @@ | |||
| { | |||
| "dom.bluetooth.enabled": false, | |||
| "dom.bluetooth.testing.enabled": false, | |||
| "dom.canvas-text.enabled": false, | |||
| "dom.canvas-text.enabled": true, | |||
This comment has been minimized.
This comment has been minimized.
jdm
Aug 22, 2017
Member
Please revert this change. We do not want this to be exposed by default, since it is incomplete. Anybody that needs to run tests with this API present can enable it explicitly.
This comment has been minimized.
This comment has been minimized.
BrunoBernardino
Aug 23, 2017
Author
Contributor
Sounds good! I thought the goal here was to prevent the JS Exception by default.
|
Alright, I think that's it! |
Otherwise, these changes look good. Could you squash all of the commits into one? |
|
Will do. |
|
@bors-servo: r+ |
|
|
|
|
|
|
|
@bors-servo: retry |
Implement CanvasRenderingContext2d.fillText's "unimplemented" message Basic skeleton for implementing CanvasRenderingContext2d.fillText, only adding methods and parameters in the right place, and a basic test, with some `println!()`. <!-- Please describe your changes on the following line: --> This is only the beginning. It were my first couple of hours looking at Rust and Servo. However, I have _no clue_ how to get the text to render now (basically go from the `println!()` to something else). It's also possible I messed something up with the `DOMString.parse()` but not entirely sure. I'm doing this PR as a starting point to get help and learn more about this, _or_ at least maybe save someone some time while implementing this, if no one's able to take the time and show me where/how. Because it's still a work-in-progress, I'm leaving the boxes below unchecked (even though there are no errors). --- <!-- 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 - [ ] These changes fix #11681 and #17963 <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18020) <!-- Reviewable:end -->
|
|


BrunoBernardino commentedAug 9, 2017
•
edited
Basic skeleton for implementing CanvasRenderingContext2d.fillText, only adding methods and parameters in the right place, and a basic test, with some
println!().This is only the beginning. It were my first couple of hours looking at Rust and Servo.
However, I have no clue how to get the text to render now (basically go from the
println!()to something else).It's also possible I messed something up with the
DOMString.parse()but not entirely sure.I'm doing this PR as a starting point to get help and learn more about this, or at least maybe save someone some time while implementing this, if no one's able to take the time and show me where/how.
Because it's still a work-in-progress, I'm leaving the boxes below unchecked (even though there are no errors).
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is