Bug 227009

Summary: GraphicsContext restores need to do nothing if the state stack is empty
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: New BugsAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, kkinnunen, koivisto, rniwa, sabouhallawa, simon.fraser, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=227028
https://bugs.webkit.org/show_bug.cgi?id=227525
Attachments:
Description Flags
Patch
none
Patch
none
Patch
ews-feeder: commit-queue-
Patch none

Description Myles C. Maxfield 2021-06-14 20:20:41 PDT
GraphicsContext restores need to do nothing if the state stack is empty
Comment 1 Myles C. Maxfield 2021-06-14 20:23:27 PDT
Created attachment 431397 [details]
Patch
Comment 2 Tim Horton 2021-06-14 20:43:59 PDT
Comment on attachment 431397 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=431397&action=review

> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:222
> +    if (!stackSize())
> +        return;

I think you'll want this in all of the subclasses?
Comment 3 Simon Fraser (smfr) 2021-06-14 20:49:59 PDT
Comment on attachment 431397 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=431397&action=review

> Source/WebCore/ChangeLog:10
> +        According to the HTML spec (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-restore-dev),
> +        "If there is no saved state, then the method must do nothing."

That's true, and the CanvasRenderingContext protects against it, but you're changing GraphicsContext.

We have thus far assumed that mismatched push/pop in GraphicsContext is a programming error.
Comment 4 Myles C. Maxfield 2021-06-14 22:06:53 PDT
Created attachment 431400 [details]
Patch
Comment 5 Myles C. Maxfield 2021-06-14 23:28:53 PDT
Created attachment 431407 [details]
Patch
Comment 6 Myles C. Maxfield 2021-06-15 00:14:45 PDT
Created attachment 431408 [details]
Patch
Comment 7 EWS 2021-06-15 11:16:03 PDT
Committed r278884 (238826@main): <https://commits.webkit.org/238826@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 431408 [details].
Comment 8 Radar WebKit Bug Importer 2021-06-15 11:17:22 PDT
<rdar://problem/79352121>