[webkit-changes] [WebKit/WebKit] ac4e9e: Image controls should not be web exposed

Aditya Keerthi noreply at github.com
Thu Jan 19 21:49:09 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ac4e9ee871bebc572bd839c246ef9ff83d44fb7c
      https://github.com/WebKit/WebKit/commit/ac4e9ee871bebc572bd839c246ef9ff83d44fb7c
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-01-19 (Thu, 19 Jan 2023)

  Changed paths:
    A LayoutTests/fast/images/mac/image-controls-button-is-not-exposed-expected.html
    A LayoutTests/fast/images/mac/image-controls-button-is-not-exposed.html
    M Source/WebCore/dom/mac/ImageControlsMac.cpp
    M Source/WebCore/dom/mac/ImageControlsMac.h
    M Source/WebCore/rendering/RenderTheme.cpp
    M Source/WebCore/rendering/RenderTheme.h
    M Source/WebCore/rendering/RenderThemeMac.h
    M Source/WebCore/rendering/RenderThemeMac.mm

  Log Message:
  -----------
  Image controls should not be web exposed
https://bugs.webkit.org/show_bug.cgi?id=250729
rdar://104352792

Reviewed by Wenson Hsieh, Tim Nguyen and Ryosuke Niwa.

Following 245760 at main, any `<button>` element that has the ID "image-controls-button"
paints an NSServicesRolloverButtonCell. This issue occurs due to the fact that
`ImageControlsMac::isImageControlsButtonElement` simply checks the ID of the element
parameter, and `RenderTheme` applies the internal image controls `appearance` value
when that method returns true.

To fix, update `ImageControlsMac::isImageControlsButtonElement` to only return
true, if the ID matches, and the element is in the user-agent shadow tree.
Additionally, perform some cleanup around related code.

* LayoutTests/fast/images/mac/image-controls-button-is-not-exposed-expected.html: Added.
* LayoutTests/fast/images/mac/image-controls-button-is-not-exposed.html: Added.
* Source/WebCore/dom/mac/ImageControlsMac.cpp:
(WebCore::ImageControlsMac::hasImageControls):
(WebCore::ImageControlsMac::imageControlsHost):
(WebCore::ImageControlsMac::isImageControlsButtonElement):
(WebCore::ImageControlsMac::isInsideImageControls):

Update the implementation to actually check whether the element is inside the
image controls shadow tree. Previously this method simply checked that the
element is equal to the image controls container.

(WebCore::ImageControlsMac::destroyImageControls):
(WebCore::ImageControlsMac::hasControls): Deleted.

Remove redundant method in favor of `hasImageControls`, which has a more descriptive name.

* Source/WebCore/dom/mac/ImageControlsMac.h:
* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::autoAppearanceForElement const):

Move the image controls check further down, since in the majority of cases it is
unlikely we have an image controls button. Prioritize determining the appearance
of input element, which are more frequently observed in web content.

* Source/WebCore/rendering/RenderTheme.h:
(WebCore::RenderTheme::isImageControlsButton const):
(WebCore::RenderTheme::isImageControl const): Deleted.

Renamed this method to `isImageControlsButton`, since that is what it is actually checking.

* Source/WebCore/rendering/RenderThemeMac.h:
* Source/WebCore/rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::isImageControlsButton const):
(WebCore::RenderThemeMac::isImageControl const): Deleted.

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




More information about the webkit-changes mailing list