Skip to content

Commit

Permalink
[macOS] Remove linen texture when zoomed or rubber banding
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260002
rdar://113648503

Reviewed by Simon Fraser.

When running on OS X Mavericks 10.9 and earlier, web views used to draw a gray linen texture when zoomed out or
rubber banding. This design has been replaced with a flat color since the OS X Yosemite 10.10, but we continue
to draw the linen texture, only to have it covered by an opaque foreground layer.

In popup windows, this linen texture may unexpectedly become visible in some circumstances on macOS Sonoma. To
reduce resource usage and remove a source of layout bugs, drop the linen texture implementation completely.

* Source/WebCore/platform/ScrollbarTheme.h:
(WebCore::ScrollbarTheme::setUpOverhangAreasLayerContents): Deleted.
(WebCore::ScrollbarTheme::setUpContentShadowLayer): Deleted.
Removed since these are no longer used on supported versions of macOS.

* Source/WebCore/platform/graphics/GraphicsLayer.cpp:
(WebCore::operator<<):
Remove the ScrollingOverhang appearance since we no longer need to draw any linen.

* Source/WebCore/platform/graphics/GraphicsLayer.h:
Same as above.

* Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(WebCore::PlatformCALayerCocoa::updateCustomAppearance):
Do not set up or remove the linen overhang area background.

* Source/WebCore/platform/mac/ScrollbarThemeMac.h:
* Source/WebCore/platform/mac/ScrollbarThemeMac.mm:
(WebCore::linenBackgroundColor): Deleted.
(WebCore::ScrollbarThemeMac::setUpOverhangAreaBackground): Deleted.
(WebCore::ScrollbarThemeMac::removeOverhangAreaBackground): Deleted.
(WebCore::ScrollbarThemeMac::setUpOverhangAreasLayerContents): Deleted.
(WebCore::ScrollbarThemeMac::setUpContentShadowLayer): Deleted.
Remove code to set up and update the linen overhang area background.

* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateLayerForOverhangAreasBackgroundColor):
Stop setting a custom linen appearance for the overhang area.

* Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
(WebKit::updateCustomAppearance):
Do not set up or remove the linen overhang area background.

Canonical link: https://commits.webkit.org/266752@main
  • Loading branch information
Luming Yin authored and smfr committed Aug 10, 2023
1 parent cf15c62 commit b0c4742
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 75 deletions.
5 changes: 0 additions & 5 deletions Source/WebCore/platform/ScrollbarTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ class ScrollbarTheme {
virtual void paintTickmarks(GraphicsContext&, Scrollbar&, const IntRect&) { }
virtual void paintOverhangAreas(ScrollView&, GraphicsContext&, const IntRect&, const IntRect&, const IntRect&) { }

#if HAVE(RUBBER_BANDING)
virtual void setUpOverhangAreasLayerContents(GraphicsLayer*, const Color&) { }
virtual void setUpContentShadowLayer(GraphicsLayer*) { }
#endif

virtual ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart);
virtual bool shouldSnapBackToDragOrigin(Scrollbar&, const PlatformMouseEvent&) { return false; }
virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar&, const PlatformMouseEvent&) { return false; }
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/platform/graphics/GraphicsLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,6 @@ TextStream& operator<<(TextStream& ts, const GraphicsLayer::CustomAppearance& cu
{
switch (customAppearance) {
case GraphicsLayer::CustomAppearance::None: ts << "none"; break;
case GraphicsLayer::CustomAppearance::ScrollingOverhang: ts << "scrolling-overhang"; break;
case GraphicsLayer::CustomAppearance::ScrollingShadow: ts << "scrolling-shadow"; break;
}
return ts;
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/platform/graphics/GraphicsLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ class GraphicsLayer : public RefCounted<GraphicsLayer> {

enum class CustomAppearance : uint8_t {
None,
ScrollingOverhang,
ScrollingShadow
};
virtual void setCustomAppearance(CustomAppearance customAppearance) { m_customAppearance = customAppearance; }
Expand Down Expand Up @@ -850,7 +849,6 @@ template<> struct EnumTraits<WebCore::GraphicsLayer::CustomAppearance> {
using values = EnumValues<
WebCore::GraphicsLayer::CustomAppearance,
WebCore::GraphicsLayer::CustomAppearance::None,
WebCore::GraphicsLayer::CustomAppearance::ScrollingOverhang,
WebCore::GraphicsLayer::CustomAppearance::ScrollingShadow
>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1064,12 +1064,8 @@ - (void)setOwner:(WebCore::PlatformCALayer*)owner
#if HAVE(RUBBER_BANDING)
switch (appearance) {
case GraphicsLayer::CustomAppearance::None:
ScrollbarThemeMac::removeOverhangAreaBackground(platformLayer());
ScrollbarThemeMac::removeOverhangAreaShadow(platformLayer());
break;
case GraphicsLayer::CustomAppearance::ScrollingOverhang:
ScrollbarThemeMac::setUpOverhangAreaBackground(platformLayer());
break;
case GraphicsLayer::CustomAppearance::ScrollingShadow:
ScrollbarThemeMac::setUpOverhangAreaShadow(platformLayer());
break;
Expand Down
8 changes: 0 additions & 8 deletions Source/WebCore/platform/mac/ScrollbarThemeMac.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ class ScrollbarThemeMac : public ScrollbarThemeComposite {
bool isLayoutDirectionRTL(Scrollbar&);

#if HAVE(RUBBER_BANDING)
WEBCORE_EXPORT static void setUpOverhangAreaBackground(CALayer *, const Color& customBackgroundColor = Color());
WEBCORE_EXPORT static void removeOverhangAreaBackground(CALayer *);

WEBCORE_EXPORT static void setUpOverhangAreaShadow(CALayer *);
WEBCORE_EXPORT static void removeOverhangAreaShadow(CALayer *);
#endif
Expand All @@ -94,11 +91,6 @@ class ScrollbarThemeMac : public ScrollbarThemeComposite {
ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override;
bool shouldDragDocumentInsteadOfThumb(Scrollbar&, const PlatformMouseEvent&) override;
int scrollbarPartToHIPressedState(ScrollbarPart);

#if HAVE(RUBBER_BANDING)
void setUpOverhangAreasLayerContents(GraphicsLayer*, const Color&) override;
void setUpContentShadowLayer(GraphicsLayer*) override;
#endif
};

}
Expand Down
48 changes: 0 additions & 48 deletions Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@
using WebCore::scrollbarMap;
using WebCore::ScrollbarToScrollerImpMap;

@interface NSColor (WebNSColorDetails)
+ (NSImage *)_linenPatternImage;
@end

@interface WebScrollbarPrefsObserver : NSObject
{
}
Expand Down Expand Up @@ -585,38 +581,6 @@ static void paintScrollbar(Scrollbar& scrollbar, GraphicsContext& context)
}

#if HAVE(RUBBER_BANDING)
static RetainPtr<CGColorRef> linenBackgroundColor()
{
NSImage *image = nil;
CGImageRef cgImage = nullptr;
BEGIN_BLOCK_OBJC_EXCEPTIONS
image = [NSColor _linenPatternImage];
cgImage = [image CGImageForProposedRect:NULL context:NULL hints:nil];
END_BLOCK_OBJC_EXCEPTIONS

if (!cgImage)
return nullptr;

RetainPtr<CGPatternRef> pattern = adoptCF(CGPatternCreateWithImage2(cgImage, CGAffineTransformIdentity, kCGPatternTilingNoDistortion));
RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreatePattern(0));

const CGFloat alpha = 1.0;
return adoptCF(CGColorCreateWithPattern(colorSpace.get(), pattern.get(), &alpha));
}

void ScrollbarThemeMac::setUpOverhangAreaBackground(CALayer *layer, const Color& customBackgroundColor)
{
static CGColorRef cachedLinenBackgroundColor = linenBackgroundColor().leakRef();
// We operate on the CALayer directly here, since GraphicsLayer doesn't have the concept
// of pattern images, and we know that WebCore won't touch this layer.
layer.backgroundColor = customBackgroundColor.isValid() ? cachedCGColor(customBackgroundColor).get() : cachedLinenBackgroundColor;
}

void ScrollbarThemeMac::removeOverhangAreaBackground(CALayer *layer)
{
layer.backgroundColor = nil;
}

void ScrollbarThemeMac::setUpOverhangAreaShadow(CALayer *layer)
{
static const CGFloat shadowOpacity = 0.66;
Expand All @@ -639,18 +603,6 @@ static void paintScrollbar(Scrollbar& scrollbar, GraphicsContext& context)
layer.shadowPath = nil;
layer.shadowOpacity = 0;
}

void ScrollbarThemeMac::setUpOverhangAreasLayerContents(GraphicsLayer* graphicsLayer, const Color& customBackgroundColor)
{
ScrollbarThemeMac::setUpOverhangAreaBackground(graphicsLayer->platformLayer(), customBackgroundColor);
}

void ScrollbarThemeMac::setUpContentShadowLayer(GraphicsLayer* graphicsLayer)
{
// We operate on the CALayer directly here, since GraphicsLayer doesn't have the concept
// of shadows, and we know that WebCore won't touch this layer.
setUpOverhangAreaShadow(graphicsLayer->platformLayer());
}
#endif

} // namespace WebCore
Expand Down
3 changes: 0 additions & 3 deletions Source/WebCore/rendering/RenderLayerCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4157,9 +4157,6 @@ void RenderLayerCompositor::updateLayerForOverhangAreasBackgroundColor()
})();
m_layerForOverhangAreas->setBackgroundColor(backgroundColor);
}

if (!backgroundColor.isValid())
m_layerForOverhangAreas->setCustomAppearance(GraphicsLayer::CustomAppearance::ScrollingOverhang);
}

#endif // HAVE(RUBBER_BANDING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,8 @@ static void updateCustomAppearance(CALayer *layer, GraphicsLayer::CustomAppearan
#if HAVE(RUBBER_BANDING)
switch (customAppearance) {
case GraphicsLayer::CustomAppearance::None:
ScrollbarThemeMac::removeOverhangAreaBackground(layer);
ScrollbarThemeMac::removeOverhangAreaShadow(layer);
break;
case GraphicsLayer::CustomAppearance::ScrollingOverhang:
ScrollbarThemeMac::setUpOverhangAreaBackground(layer);
break;
case GraphicsLayer::CustomAppearance::ScrollingShadow:
ScrollbarThemeMac::setUpOverhangAreaShadow(layer);
break;
Expand Down

0 comments on commit b0c4742

Please sign in to comment.