[webkit-changes] [WebKit/WebKit] 86b51a: Don't apply canvas noise on drawImage/putImageData...

Matthew Finkel noreply at github.com
Fri Nov 3 15:04:15 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 86b51a59cf534cac68af4f8e4304e6134f8f45bf
      https://github.com/WebKit/WebKit/commit/86b51a59cf534cac68af4f8e4304e6134f8f45bf
  Author: Matthew Finkel <sysrqb at apple.com>
  Date:   2023-11-03 (Fri, 03 Nov 2023)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/fast/canvas/canvas-noise-injection-expected.txt
    M LayoutTests/fast/canvas/canvas-noise-injection.html
    M Source/WebCore/html/CanvasBase.cpp
    M Source/WebCore/html/CanvasNoiseInjection.cpp
    M Source/WebCore/html/CanvasNoiseInjection.h
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h

  Log Message:
  -----------
  Don't apply canvas noise on drawImage/putImageData rects
https://bugs.webkit.org/show_bug.cgi?id=263129
rdar://115313154

Reviewed by Simon Fraser.

When noise injection is enabled, the backing pixelbuffer of Canvas2D has noise
applied as an anti-fingerprinting protection. That operation is expensive and
the protection is not needed in situations where we are given an explicit
ImageData or specific types of Images because those data don't reveal any
identifying information about the machine when extracted via getImageData() or
toDataURL().

This patch abstracts the default DidDrawOptions into a static function that
includes DidDrawOption::ApplyPostProcessing, and a companion function that
doesn't include ApplyPostProcessing. These are static class functions because
they should both be updated if the default DidDrawOption OptionSet changes in
the future, and defining them separately seems error prone.

As described above, the noise injection post-processing is not applied after
certain drawImage operations where the image is a bitmap, and post-processing
is conditionally applied when the entire canvas is dirty.

* LayoutTests/TestExpectations:
* LayoutTests/fast/canvas/canvas-noise-injection-expected.txt:
* LayoutTests/fast/canvas/canvas-noise-injection.html:
* Source/WebCore/html/CanvasBase.cpp:
(WebCore::CanvasBase::didDraw):
* Source/WebCore/html/CanvasNoiseInjection.cpp:
(WebCore::CanvasNoiseInjection::clearDirtyRect):
* Source/WebCore/html/CanvasNoiseInjection.h:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::clearRect):
(WebCore::CanvasRenderingContext2DBase::drawImage):
(WebCore::CanvasRenderingContext2DBase::didDrawEntireCanvas):
(WebCore::CanvasRenderingContext2DBase::didDraw):
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:
(WebCore::CanvasRenderingContext2DBase::defaultDidDrawOptions):
(WebCore::CanvasRenderingContext2DBase::defaultDidDrawOptionsWithoutPostProcessing):
(WebCore::CanvasRenderingContext2DBase::didDraw): Deleted.

Canonical link: https://commits.webkit.org/270207@main




More information about the webkit-changes mailing list