Auto merge of #18020 - BrunoBernardino:feature-canvas-filltext, r=jdm

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 -->
This commit is contained in:
bors-servo 2017-08-23 14:00:47 -05:00 committed by GitHub
commit acd08c75f7
6 changed files with 35 additions and 3 deletions

View file

@ -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.into();
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::FillText(parsed_text, x, y, max_width))).unwrap();
self.mark_as_dirty();
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
fn DrawImage(&self,
image: CanvasImageSource,

View file

@ -153,8 +153,9 @@ interface CanvasUserInterface {
[NoInterfaceObject]
interface CanvasText {
// text (see also the CanvasDrawingStyles interface)
//void fillText(DOMString text, unrestricted double x, unrestricted double y,
// optional unrestricted double maxWidth);
[Pref="dom.canvas-text.enabled"]
void fillText(DOMString text, unrestricted double x, unrestricted double y,
optional unrestricted double maxWidth);
//void strokeText(DOMString text, unrestricted double x, unrestricted double y,
// optional unrestricted double maxWidth);
//TextMetrics measureText(DOMString text);
@ -264,4 +265,3 @@ interface CanvasPath {
// double rotation, double startAngle, double endAngle,
// boolean anticlockwise);
};