canvas: Use strum::{Display, EnumString} for canvas enums (#37670)

This makes it easier to add variants, I also added some spec links and
reordered enum variants to match the spec.

Testing: Just refactor, but the code is covered by WPT tests.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev 2025-06-24 15:03:41 +02:00 committed by GitHub
parent 2dc62c504f
commit ef7be66c56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 82 additions and 202 deletions

View file

@ -1197,8 +1197,8 @@ impl CanvasState {
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalcompositeoperation
pub(crate) fn global_composite_operation(&self) -> DOMString {
match self.state.borrow().global_composition {
CompositionOrBlending::Composition(op) => DOMString::from(op.to_str()),
CompositionOrBlending::Blending(op) => DOMString::from(op.to_str()),
CompositionOrBlending::Composition(op) => DOMString::from(op.to_string()),
CompositionOrBlending::Blending(op) => DOMString::from(op.to_string()),
}
}