[webkit-changes] [WebKit/WebKit] f011ab: Cache NoiseInjectionHashSalt in CanvasBase

Matthew Finkel noreply at github.com
Fri Jun 16 22:37:38 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f011ab9a032634fb8820735ab22bef1c893da181
      https://github.com/WebKit/WebKit/commit/f011ab9a032634fb8820735ab22bef1c893da181
  Author: Matthew Finkel <sysrqb at apple.com>
  Date:   2023-06-16 (Fri, 16 Jun 2023)

  Changed paths:
    M Source/WebCore/html/CanvasBase.cpp
    M Source/WebCore/html/CanvasBase.h
    M Source/WebCore/html/CustomPaintCanvas.cpp
    M Source/WebCore/html/HTMLCanvasElement.cpp
    M Source/WebCore/html/OffscreenCanvas.cpp

  Log Message:
  -----------
  Cache NoiseInjectionHashSalt in CanvasBase
https://bugs.webkit.org/show_bug.cgi?id=258176
rdar://109862698

Reviewed by Wenson Hsieh.

This change avoids calling ScriptExecutionContext::noiseInjectionHashSalt() in
hot code paths. Caching the value is safe because it should never change
between calls, and even if we did, using an old value wouldn't meaningfully
reduce the protection.

This change is covered by existing tests.

* Source/WebCore/html/CanvasBase.cpp:
(WebCore::CanvasBase::CanvasBase):
(WebCore::CanvasBase::~CanvasBase):
(WebCore::CanvasBase::makeRenderingResultsAvailable):
(WebCore::CanvasBase::shouldInjectNoiseBeforeReadback const):
(WebCore::CanvasBase::postProcessPixelBufferResults const):
* Source/WebCore/html/CanvasBase.h:
* Source/WebCore/html/CustomPaintCanvas.cpp:
(WebCore::CustomPaintCanvas::CustomPaintCanvas):
* Source/WebCore/html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::HTMLCanvasElement):
* Source/WebCore/html/OffscreenCanvas.cpp:
(WebCore::OffscreenCanvas::OffscreenCanvas):

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




More information about the webkit-changes mailing list