Commit Graph

32 Commits

Author SHA1 Message Date
Sam Atkins
62b561e2e1 LibWeb: Extract CanvasDrawPath class from CRC2D
Again, this is an entirely virtual class since the methods involve
direct access to the Painter. Though, maybe I could just expose the
Painter...
2022-08-14 11:30:40 +02:00
Sam Atkins
c0494988ed LibWeb: Extract CanvasRect class from CRC2D
This one requires drawing to the canvas, so it doesn't make so much
sense to move the implementation over.
2022-08-14 11:30:40 +02:00
Sam Atkins
afabd613bd LibWeb: Extract CanvasFillStrokeStyles class from CRC2D 2022-08-14 11:30:40 +02:00
Sam Atkins
aa87b9699e LibWeb: Extract CanvasTransform class from CRC2D
The implementation of this got a little funky, because it has to access
methods from CanvasState.
2022-08-14 11:30:40 +02:00
Sam Atkins
08e6071ebb LibWeb: Extract CanvasState class from CRC2D
As with CanvasPath, this is to better match the spec IDL.
2022-08-14 11:30:40 +02:00
Sam Atkins
6644f3ab44 LibWeb: Teach CRC2D to draw Path2Ds :^) 2022-08-14 11:30:40 +02:00
Sam Atkins
a37ab7b9f8 LibWeb: Extract CanvasPath class from CRC2D
This better matches the spec, and makes it possible for things like
Path2D to reuse the same implementation without duplicate code. :^)
2022-08-14 11:30:40 +02:00
Sam Atkins
8fd83b56d5 LibWeb: Use "unrestricted float/double" where we should in IDL 2022-08-14 11:30:40 +02:00
Luke Wilde
adf8341c4e LibWeb: Forward CRC2D's ref count to HTMLCanvasElement
This allows HTMLCanvasElement and CRC2D to share their lifetime, as JS
allows them to arbitrarily access them at any time and CRC2D.canvas
expects a non-null return value.
2022-06-27 22:54:41 +01:00
Luke Wilde
89c4e011e4 LibWeb: Stub CanvasRenderingContext2D.clip
This is primarily required by Google Maps Street View, but the map view
works without this.
2022-04-10 19:59:14 +02:00
Luke Wilde
27cc8742ce LibWeb: Implement CanvasRenderingContext2D.resetTransform 2022-04-10 19:59:14 +02:00
Luke Wilde
329e740c85 LibWeb: Implement CanvasRenderingContext2D.setTransform 2022-04-10 19:59:14 +02:00
Luke Wilde
df7a83ac0e LibWeb: Implement CanvasRenderingContext2D.transform 2022-04-10 19:59:14 +02:00
Idan Horowitz
bc0fafade9 LibWeb: Add all overloads of CanvasRenderingContext2D::drawImage() 2022-03-05 23:40:08 +01:00
Linus Groh
e890cd5464 LibWeb: Implement CanvasRenderingContext2D.getImageData()
The actual copying of the pixel values into the created ImageData object
is a bit ugly, but Gfx::Painter doesn't like the underlying RGBA8888
bitmap.
2022-03-04 23:03:29 +01:00
Linus Groh
08608932cc LibWeb: Change CanvasRenderingContext2D.createImageData() args to long
Not sure why these are doubles in the IDL definition, both the IDL in
the spec and the implementation in the CanvasRenderingContext2D class
use integers.
2022-03-04 23:03:29 +01:00
Linus Groh
3f3326f1dc LibWeb: Implement CanvasRenderingContext2D.drawImage() closer to spec
Also add support for HTMLCanvasElement for the image parameter, leading
to replacing HTMLImageElement with the CanvasImageSource Variant type.

Also stub out the 'check the usability of the image argument' and 'is
not origin-clean' operations, while taking into consideration that these
can throw (and require DOM::ExceptionOr).
2022-03-04 23:03:29 +01:00
Ali Mohammad Pur
a59800b4a0 LibWeb: Add imports to all IDL files that depend on others 2022-02-16 22:48:32 +03:30
Andreas Kling
926d5271b4 LibWeb: Forward CanvasRenderingContext.strokeText() to fillText()
This is a hack until we get an actual text stroking implementation.
2022-02-03 22:35:13 +01:00
Andreas Kling
dc3bf32307 LibWeb: Add barebones CanvasGradient object
Also add the CanvasRenderingContext2D APIs to go along with it.
Note that it can't be used for anything yet.
2022-02-03 22:35:13 +01:00
Andreas Kling
90a8744823 LibWeb: Add CanvasRenderingContext2D.bezierCurveTo() 2022-02-03 22:35:13 +01:00
sin-ack
9121cc7cae LibWeb: Implement CanvasRenderingContext2D.measureText
This requires an implementation of the "text preparation algorithm" as
specified here:

html.spec.whatwg.org/multipage/canvas.html#text-preparation-algorithm

However, we're missing a lot of things such as the
CanvasTextDrawingStyles interface, so most of the algorithm was not
implemented. Additionally, we also are not able to use a LineBox like
the algorithm suggests, because our layouting infra is not up to the
task yet. The prepare_text function does nothing other than figuring out
the width of the given text and return glyphs with offsets at the
moment.
2022-01-04 22:41:07 +00:00
Linus Groh
1298c27ca9 LibWeb: Implement CanvasRenderingContext2D.isContextLost()
Note that we don't implement the "context lost steps" yet, so this will
always return the initial value (false).
2021-12-27 16:43:23 +01:00
Linus Groh
2576af5db1 LibWeb: Implement CanvasRenderingContext2D.reset() 2021-12-27 16:43:23 +01:00
Linus Groh
3e0e965f24 LibWeb: Implement CanvasRenderingContext2D.restore() 2021-12-27 16:43:23 +01:00
Linus Groh
7d435b5ada LibWeb: Implement CanvasRenderingContext2D.save() 2021-12-27 16:43:23 +01:00
Idan Horowitz
00114ab01d LibWeb: Add a naive implemention of CanvasRenderingContext2D::fill_text
This doesnt actually account for several unimplemented attributes
(like ltr/rtl, alignment, etc) yet, so this should be expanded in
the future.
2021-04-15 20:22:08 +02:00
AnotherTest
801daf47f0 LibGfx+LibWeb: Wire up CanvasRenderingContext2D.ellipse()
Note that this is *extremely* naive, and not very good at being correct.
2021-04-15 17:50:16 +02:00
Idan Horowitz
aab99d5945 LibWeb: Implement the CanvasRenderingContext2D::rect path method
This method adds a rectangle to the current 2D path.
2021-04-14 23:01:23 +02:00
Idan Horowitz
4c0937225e LibWeb: Make CanvasRenderingContext2D::fill's fillRule argument optional
As defined by the specification (and used by the website i am testing):
interface mixin CanvasDrawPath {
  undefined fill(optional CanvasFillRule fillRule = "nonzero");
}
2021-04-14 23:01:23 +02:00
Andreas Kling
d434ae71b3 LibWeb: Add CanvasRenderingContext2D.clearRect()
Similar to fillRect, except this API fills with transparent black.
2021-03-15 21:20:33 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00