Diff
Modified: trunk/LayoutTests/ChangeLog (286460 => 286461)
--- trunk/LayoutTests/ChangeLog 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/LayoutTests/ChangeLog 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1,3 +1,16 @@
+2021-12-02 Megan Gardner <megan_gard...@apple.com>
+
+ Re-add support of image control menus.
+ https://bugs.webkit.org/show_bug.cgi?id=233305
+
+ Reviewed by Tim Horton.
+
+ Update tests to account for image controls.
+
+ * fast/images/image-controls-basic.html: Added.
+ * fast/images/image-controls-basic-expected.txt: Added.
+ * platform/mac/fast/images/image-controls-basic-expected.txt: Added.
+
2021-12-02 Devin Rousso <drou...@apple.com>
[Payment Request] Validate payment method data on construction
Added: trunk/LayoutTests/fast/images/image-controls-basic-expected.txt (0 => 286461)
--- trunk/LayoutTests/fast/images/image-controls-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/images/image-controls-basic-expected.txt 2021-12-02 23:49:57 UTC (rev 286461)
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderImage {IMG} at (0,0) size 256x256
+ RenderText {#text} at (0,0) size 0x0
Added: trunk/LayoutTests/fast/images/image-controls-basic.html (0 => 286461)
--- trunk/LayoutTests/fast/images/image-controls-basic.html (rev 0)
+++ trunk/LayoutTests/fast/images/image-controls-basic.html 2021-12-02 23:49:57 UTC (rev 286461)
@@ -0,0 +1,8 @@
+ <script>
+if (window.internals)
+ internals.settings.setImageControlsEnabled(true);
+
+</script>
+<body>
+<img src="" x-webkit-imagemenu>
+</body>
\ No newline at end of file
Added: trunk/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt (0 => 286461)
--- trunk/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt 2021-12-02 23:49:57 UTC (rev 286461)
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderImage {IMG} at (0,0) size 256x256
+ RenderText {#text} at (0,0) size 0x0
+layer at (8,8) size 256x256
+ RenderBlock (relative positioned) {DIV} at (0,0) size 256x256 [color=#00000000]
+layer at (214,30) size 28x26
+ RenderButton {BUTTON} at (206,22) size 28x26 [color=#000000D8] [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0)]
Added: trunk/LayoutTests/platform/mac-catalina/fast/images/image-controls-basic-expected.txt (0 => 286461)
--- trunk/LayoutTests/platform/mac-catalina/fast/images/image-controls-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-catalina/fast/images/image-controls-basic-expected.txt 2021-12-02 23:49:57 UTC (rev 286461)
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderImage {IMG} at (0,0) size 256x256
+ RenderText {#text} at (0,0) size 0x0
+layer at (8,8) size 256x256
+ RenderBlock (relative positioned) {DIV} at (0,0) size 256x256 [color=#00000000]
+layer at (215,30) size 27x26
+ RenderButton {BUTTON} at (207,22) size 27x26 [color=#000000D8] [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0)]
Modified: trunk/Source/WTF/ChangeLog (286460 => 286461)
--- trunk/Source/WTF/ChangeLog 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WTF/ChangeLog 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1,3 +1,12 @@
+2021-12-02 Megan Gardner <megan_gard...@apple.com>
+
+ Re-add support of image control menus.
+ https://bugs.webkit.org/show_bug.cgi?id=233305
+
+ Reviewed by Tim Horton.
+
+ * Scripts/Preferences/WebPreferences.yaml:
+
2021-12-02 Myles C. Maxfield <mmaxfi...@apple.com>
[WebGPU] Hook up navigator.gpu.requestAdapter()
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml (286460 => 286461)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml 2021-12-02 23:49:57 UTC (rev 286461)
@@ -934,6 +934,17 @@
WebCore:
default: false
+ImageControlsEnabled:
+ type: bool
+ condition: ENABLE(SERVICE_CONTROLS)
+ defaultValue:
+ WebKitLegacy:
+ default: false
+ WebKit:
+ default: false
+ WebCore:
+ default: false
+
InactiveMediaCaptureSteamRepromptIntervalInMinutes:
type: double
webcoreBinding: none
Modified: trunk/Source/WebCore/ChangeLog (286460 => 286461)
--- trunk/Source/WebCore/ChangeLog 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/ChangeLog 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1,3 +1,95 @@
+2021-12-02 Megan Gardner <megan_gard...@apple.com>
+
+ Re-add support of image control menus.
+ https://bugs.webkit.org/show_bug.cgi?id=233305
+
+ Reviewed by Tim Horton.
+
+ Test: fast/images/image-controls-basic.html
+
+ Image control menus are needed for mail transition to modern WebKit, so re-add them
+ after the removal in https://trac.webkit.org/changeset/272117/webkit
+
+ * DerivedSources-input.xcfilelist:
+ * DerivedSources.make:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSPrimitiveValueMappings.h:
+ (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+ * css/CSSProperties.json:
+ * css/CSSValueKeywords.in:
+ * css/parser/CSSParserIdioms.cpp:
+ (WebCore::isValueAllowedInMode):
+ * dom/mac/ImageControlsMac.cpp: Added.
+ (WebCore::ImageControlsMac::imageControlsElementIdentifier):
+ (WebCore::ImageControlsMac::imageControlsButtonIdentifier):
+ (WebCore::ImageControlsMac::hasControls):
+ (WebCore::ImageControlsMac::imageControlHost):
+ (WebCore::ImageControlsMac::isImageControlsButtonElement):
+ (WebCore::ImageControlsMac::containerRect):
+ (WebCore::ImageControlsMac::createImageControls):
+ * dom/mac/ImageControlsMac.h: Added.
+ * html/HTMLAttributeNames.in:
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::HTMLImageElement):
+ (WebCore::HTMLImageElement::parseAttribute):
+ (WebCore::HTMLImageElement::didAttachRenderers):
+ (WebCore::HTMLImageElement::updateImageControls):
+ (WebCore::HTMLImageElement::tryCreateImageControls):
+ (WebCore::HTMLImageElement::destroyImageControls):
+ (WebCore::HTMLImageElement::hasImageControls const):
+ (WebCore::HTMLImageElement::childShouldCreateRenderer const):
+ * html/HTMLImageElement.h:
+ (WebCore::HTMLImageElement::hasShadowControls const):
+ * html/shadow/mac/ImageControlsMac.css: Added.
+ (#if defined(ENABLE_SERVICE_CONTROLS) && ENABLE_SERVICE_CONTROLS):
+ (button#image-controls-button):
+ (div#image-controls:hover button#image-controls-button):
+ * html/shadow/mac/ImageControlsRootElementMac.cpp: Added.
+ (WebCore::xWebkitImageControlsElementIdentifier):
+ (WebCore::RenderImageControls::RenderImageControls):
+ (WebCore::RenderImageControls::updateLogicalWidth):
+ (WebCore::RenderImageControls::computeLogicalHeight const):
+ (WebCore::hasControl):
+ (WebCore::imageControlHost):
+ (WebCore::isImageControls):
+ (WebCore::ImageControlsRootElement::tryCreate):
+ (WebCore::ImageControlsRootElementMac::ImageControlsRootElementMac):
+ (WebCore::ImageControlsRootElementMac::createElementRenderer):
+ * html/shadow/mac/ImageControlsRootElementMac.h: Added.
+ * page/ContextMenuController.cpp:
+ (WebCore::imageFromImageElementNode):
+ (WebCore::ContextMenuController::maybeCreateContextMenu):
+ (WebCore::ContextMenuController::showImageControlsMenu):
+ * page/ContextMenuController.h:
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::textRecognitionCandidateElement const):
+ * platform/ThemeTypes.cpp:
+ (WebCore::operator<<):
+ * platform/ThemeTypes.h:
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::RenderImage):
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::adjustStyle):
+ (WebCore::RenderTheme::paint):
+ (WebCore::RenderTheme::paintBorderOnly):
+ (WebCore::RenderTheme::paintDecorations):
+ (WebCore::RenderTheme::adjustImageControlsButtonStyle const):
+ * rendering/RenderTheme.h:
+ (WebCore::RenderTheme::imageControlsButtonSize const):
+ (WebCore::RenderTheme::imageControlsButtonPositionOffset const):
+ (WebCore::RenderTheme::paintImageControlsButton):
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::documentViewFor const):
+ (WebCore::RenderThemeMac::adjustImageControlsButtonStyle const):
+ (WebCore::RenderThemeMac::servicesRolloverButtonCell const):
+ (WebCore::RenderThemeMac::paintImageControlsButton):
+ (WebCore::RenderThemeMac::imageControlsButtonSize const):
+ (WebCore::RenderThemeMac::imageControlsButtonPositionOffset const):
+ * style/UserAgentStyle.cpp:
+ * style/UserAgentStyle.h:
+
2021-12-02 Myles C. Maxfield <mmaxfi...@apple.com>
[WebGPU] Hook up navigator.gpu.requestAdapter()
Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (286460 => 286461)
--- trunk/Source/WebCore/DerivedSources-input.xcfilelist 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1321,6 +1321,7 @@
$(PROJECT_DIR)/html/parser/create-html-entity-table
$(PROJECT_DIR)/html/shadow/imageOverlay.css
$(PROJECT_DIR)/html/shadow/meterElementShadow.css
+$(PROJECT_DIR)/html/shadow/mac/imageControlsMac.css
$(PROJECT_DIR)/html/track/AudioTrack.idl
$(PROJECT_DIR)/html/track/AudioTrackList.idl
$(PROJECT_DIR)/html/track/DataCue.idl
Modified: trunk/Source/WebCore/DerivedSources.make (286460 => 286461)
--- trunk/Source/WebCore/DerivedSources.make 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/DerivedSources.make 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1766,6 +1766,7 @@
$(WebCore)/css/plugIns.css \
$(WebCore)/css/quirks.css \
$(WebCore)/css/svg.css \
+ $(WebCore)/html/shadow/mac/imageControlsMac.css \
$(WebCore)/html/shadow/imageOverlay.css \
$(WebCore)/html/shadow/meterElementShadow.css \
ModernMediaControls.css \
Modified: trunk/Source/WebCore/PAL/ChangeLog (286460 => 286461)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1,3 +1,15 @@
+2021-12-02 Megan Gardner <megan_gard...@apple.com>
+
+ Re-add support of image control menus.
+ https://bugs.webkit.org/show_bug.cgi?id=233305
+
+ Reviewed by Tim Horton.
+
+ Move SPI to SPI specific file.
+
+ * PAL.xcodeproj/project.pbxproj:
+ * pal/spi/mac/NSServicesRolloverButtonCellSPI.h: Added.
+
2021-12-02 Brady Eidson <beid...@apple.com>
AVDelegatingPlaybackCoordinator error compiling on macOS 11
Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (286460 => 286461)
--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2021-12-02 23:49:57 UTC (rev 286461)
@@ -294,6 +294,7 @@
4450FCA021F5F602004DFA56 /* QuickLookSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 4450FC9E21F5F602004DFA56 /* QuickLookSoftLink.h */; };
44E1A8AF21FA54E600C3048E /* LookupSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E1A8AD21FA54DA00C3048E /* LookupSoftLink.h */; };
44E1A8B021FA54EB00C3048E /* LookupSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44E1A8AE21FA54DA00C3048E /* LookupSoftLink.mm */; };
+ 44EEA0FF2747438A00594A83 /* NSServicesRolloverButtonCellSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 44EEA0FE2747438900594A83 /* NSServicesRolloverButtonCellSPI.h */; };
4996C0F32717644C002C125D /* TCCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4996C0F22717642B002C125D /* TCCSPI.h */; };
517E03F924B7C0070054895A /* IOKitSPIMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 517E03F824B7C0060054895A /* IOKitSPIMac.h */; };
570AB8F120AE2E8D00B8BE87 /* SecKeyProxySPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */; };
@@ -697,6 +698,7 @@
4450FC9E21F5F602004DFA56 /* QuickLookSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLookSoftLink.h; sourceTree = "<group>"; };
44E1A8AD21FA54DA00C3048E /* LookupSoftLink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LookupSoftLink.h; sourceTree = "<group>"; };
44E1A8AE21FA54DA00C3048E /* LookupSoftLink.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LookupSoftLink.mm; sourceTree = "<group>"; };
+ 44EEA0FE2747438900594A83 /* NSServicesRolloverButtonCellSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSServicesRolloverButtonCellSPI.h; sourceTree = "<group>"; };
4996C0F22717642B002C125D /* TCCSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TCCSPI.h; sourceTree = "<group>"; };
517E03F824B7C0060054895A /* IOKitSPIMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOKitSPIMac.h; sourceTree = "<group>"; };
570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SecKeyProxySPI.h; sourceTree = "<group>"; };
@@ -966,6 +968,7 @@
0C77857D1F45130F00F4EBB6 /* NSScrollingInputFilterSPI.h */,
0C77857E1F45130F00F4EBB6 /* NSScrollingMomentumCalculatorSPI.h */,
A1175B591F6B4A8400C4B9F0 /* NSScrollViewSPI.h */,
+ 44EEA0FE2747438900594A83 /* NSServicesRolloverButtonCellSPI.h */,
0C77857F1F45130F00F4EBB6 /* NSSharingServicePickerSPI.h */,
0C7785801F45130F00F4EBB6 /* NSSharingServiceSPI.h */,
0C7785811F45130F00F4EBB6 /* NSSpellCheckerSPI.h */,
@@ -1504,6 +1507,7 @@
0C7785961F45130F00F4EBB6 /* NSScrollingInputFilterSPI.h in Headers */,
0C7785971F45130F00F4EBB6 /* NSScrollingMomentumCalculatorSPI.h in Headers */,
A1175B5A1F6B4A8400C4B9F0 /* NSScrollViewSPI.h in Headers */,
+ 44EEA0FF2747438A00594A83 /* NSServicesRolloverButtonCellSPI.h in Headers */,
0C7785981F45130F00F4EBB6 /* NSSharingServicePickerSPI.h in Headers */,
0C7785991F45130F00F4EBB6 /* NSSharingServiceSPI.h in Headers */,
0C77859A1F45130F00F4EBB6 /* NSSpellCheckerSPI.h in Headers */,
Added: trunk/Source/WebCore/PAL/pal/spi/mac/NSServicesRolloverButtonCellSPI.h (0 => 286461)
--- trunk/Source/WebCore/PAL/pal/spi/mac/NSServicesRolloverButtonCellSPI.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSServicesRolloverButtonCellSPI.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) NSServicesRolloverButtonCell.hARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if ENABLE(SERVICE_CONTROLS)
+
+#import "NSSharingServicePickerSPI.h"
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppKit/AppKitDefines_Private.h>
+#import <AppKit/NSServicesRolloverButtonCell.h>
+
+#else
+
+@interface NSServicesRolloverButtonCell : NSButtonCell
+@end
+
+@interface NSServicesRolloverButtonCell ()
++ (NSServicesRolloverButtonCell *)serviceRolloverButtonCellForStyle:(NSSharingServicePickerStyle)style;
+- (NSRect)rectForBounds:(NSRect)bounds preferredEdge:(NSRectEdge)preferredEdge;
+@end
+
+#endif // USE(APPLE_INTERNAL_SDK)
+#endif // ENABLE(SERVICE_CONTROLS)
+
+
Modified: trunk/Source/WebCore/Sources.txt (286460 => 286461)
--- trunk/Source/WebCore/Sources.txt 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/Sources.txt 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1063,6 +1063,7 @@
dom/WheelEvent.cpp
dom/WindowEventLoop.cpp
dom/XMLDocument.cpp
+dom/mac/ImageControlsMac.cpp
dom/messageports/MessagePortChannel.cpp
dom/messageports/MessagePortChannelProvider.cpp
dom/messageports/MessagePortChannelProviderImpl.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (286460 => 286461)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1301,6 +1301,7 @@
44C9919F0F3D210E00586670 /* ThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44C9919D0F3D210E00586670 /* ThemeIOS.h */; };
44CE2BBF264379AF007AE110 /* WebTextIndicatorLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 44CE2BBE2643799E007AE110 /* WebTextIndicatorLayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
44E349F9246F4E190068479C /* LibWebRTCEnumTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E349F7246F4DC70068479C /* LibWebRTCEnumTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 44EEA100274757F100594A83 /* ImageControlsMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 44EEA0FA274727F200594A83 /* ImageControlsMac.h */; };
450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 450CEBEF15073BBE002BB149 /* LabelableElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
4512502315DCE37D002F84E2 /* SpinButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4512502115DCE37D002F84E2 /* SpinButtonElement.h */; };
453EB637159C570400001BB7 /* DateTimeFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 453EB635159C570400001BB7 /* DateTimeFormat.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9077,6 +9078,9 @@
44E88E51236A5C8D009B4847 /* Highlight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Highlight.h; sourceTree = "<group>"; };
44E88E52236A667F009B4847 /* HighlightRegister.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HighlightRegister.cpp; sourceTree = "<group>"; };
44E88E54236A66A1009B4847 /* Highlight.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Highlight.cpp; sourceTree = "<group>"; };
+ 44EEA0F627449C0000594A83 /* imageControlsMac.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = imageControlsMac.css; sourceTree = "<group>"; };
+ 44EEA0FA274727F200594A83 /* ImageControlsMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageControlsMac.h; sourceTree = "<group>"; };
+ 44EEA0FC274727F400594A83 /* ImageControlsMac.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageControlsMac.cpp; sourceTree = "<group>"; };
450CEBEE15073BBE002BB149 /* LabelableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LabelableElement.cpp; sourceTree = "<group>"; };
450CEBEF15073BBE002BB149 /* LabelableElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelableElement.h; sourceTree = "<group>"; };
4512502015DCE37D002F84E2 /* SpinButtonElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpinButtonElement.cpp; sourceTree = "<group>"; };
@@ -20552,6 +20556,8 @@
isa = PBXGroup;
children = (
2D5036671BCDDDC400E20BB3 /* GestureEvents.cpp */,
+ 44EEA0FC274727F400594A83 /* ImageControlsMac.cpp */,
+ 44EEA0FA274727F200594A83 /* ImageControlsMac.h */,
);
path = mac;
sourceTree = "<group>";
@@ -20721,6 +20727,7 @@
4150F9ED12B6E0990008C860 /* shadow */ = {
isa = PBXGroup;
children = (
+ 44EEA0E6273F9DED00594A83 /* mac */,
7C1E97251A9F9834007BF0FB /* AutoFillButtonElement.cpp */,
7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */,
E57A740125CA05740050046B /* DataListButtonElement.cpp */,
@@ -21287,6 +21294,14 @@
path = highlight;
sourceTree = "<group>";
};
+ 44EEA0E6273F9DED00594A83 /* mac */ = {
+ isa = PBXGroup;
+ children = (
+ 44EEA0F627449C0000594A83 /* imageControlsMac.css */,
+ );
+ path = mac;
+ sourceTree = "<group>";
+ };
4642404420EAF0BD00B29FD2 /* cocoa */ = {
isa = PBXGroup;
children = (
@@ -34563,6 +34578,7 @@
727A7F3A24078B84004D2931 /* ImageBufferIOSurfaceBackend.h in Headers */,
B2A10D910B3818BD00099AA4 /* ImageBufferPipe.h in Headers */,
CD3E21DD2183444A00E66F55 /* ImageBufferUtilitiesCG.h in Headers */,
+ 44EEA100274757F100594A83 /* ImageControlsMac.h in Headers */,
A779791A0D6B9D0C003851B9 /* ImageData.h in Headers */,
BCA088F5264E1C08003E2A6C /* ImageDataSettings.h in Headers */,
CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */,
Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (286460 => 286461)
--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -608,6 +608,11 @@
m_value.valueID = CSSValueBorderlessAttachment;
break;
#endif
+#if ENABLE(SERVICE_CONTROLS)
+ case ImageControlsButtonPart:
+ m_value.valueID = CSSValueInternalImageControlsButton;
+ break;
+#endif
#if ENABLE(APPLE_PAY)
case ApplePayButtonPart:
m_value.valueID = CSSValueApplePayButton;
Modified: trunk/Source/WebCore/css/CSSProperties.json (286460 => 286461)
--- trunk/Source/WebCore/css/CSSProperties.json 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/css/CSSProperties.json 2021-12-02 23:49:57 UTC (rev 286461)
@@ -5008,6 +5008,7 @@
"continuous-capacity-level-indicator",
"discrete-capacity-level-indicator",
"rating-level-indicator",
+ "-internal-image-controls-button",
"-apple-pay-button",
"textarea",
"attachment",
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (286460 => 286461)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2021-12-02 23:49:57 UTC (rev 286461)
@@ -887,6 +887,9 @@
continuous-capacity-level-indicator
discrete-capacity-level-indicator
rating-level-indicator
+#if defined(ENABLE_SERVICE_CONTROLS) && ENABLE_SERVICE_CONTROLS
+-internal-image-controls-button
+#endif
#if defined(ENABLE_APPLE_PAY) && ENABLE_APPLE_PAY
-apple-pay-button
#endif
Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp (286460 => 286461)
--- trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -40,6 +40,10 @@
return isUASheetBehavior(mode);
case CSSValueWebkitFocusRingColor:
return isUASheetBehavior(mode) || isQuirksModeBehavior(mode);
+#if ENABLE(SERVICE_CONTROLS)
+ case CSSValueInternalImageControlsButton:
+ return isUASheetBehavior(mode);
+#endif
default:
return true;
}
Added: trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp (0 => 286461)
--- trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp (rev 0)
+++ trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ImageControlsMac.h"
+
+#include "ElementInlines.h"
+#include "HTMLButtonElement.h"
+#include "HTMLDivElement.h"
+#include "HTMLNames.h"
+#include "HTMLStyleElement.h"
+#include "RenderImage.h"
+#include "ShadowRoot.h"
+#include "UserAgentStyleSheets.h"
+#include <wtf/text/AtomString.h>
+
+namespace WebCore {
+namespace ImageControlsMac {
+
+#if ENABLE(SERVICE_CONTROLS)
+
+static const AtomString& imageControlsElementIdentifier()
+{
+ static MainThreadNeverDestroyed<const AtomString> identifier("image-controls", AtomString::ConstructFromLiteral);
+ return identifier;
+}
+
+static const AtomString& imageControlsButtonIdentifier()
+{
+ static MainThreadNeverDestroyed<const AtomString> identifier("image-controls-button", AtomString::ConstructFromLiteral);
+ return identifier;
+}
+
+bool hasControls(const HTMLElement& element)
+{
+ auto shadowRoot = element.shadowRoot();
+ if (!shadowRoot || shadowRoot->mode() != ShadowRootMode::UserAgent)
+ return false;
+
+ return shadowRoot->hasElementWithId(*imageControlsElementIdentifier().impl());
+}
+
+static RefPtr<HTMLElement> imageControlHost(const Node& node)
+{
+ auto host = node.shadowHost();
+ if (!is<HTMLElement>(host))
+ return nullptr;
+
+ RefPtr element { &downcast<HTMLElement>(*host) };
+ return hasControls(*element) ? element : nullptr;
+}
+
+bool isImageControlsButtonElement(const Node& node)
+{
+ auto host = imageControlHost(node);
+ if (!host)
+ return false;
+
+ if (RefPtr controlRoot = static_cast<TreeScope&>(*host->userAgentShadowRoot()).getElementById(imageControlsButtonIdentifier()))
+ return node.isDescendantOf(*controlRoot);
+
+ return false;
+}
+
+void createImageControls(HTMLElement& element)
+{
+ Ref document = element.document();
+ Ref shadowRoot = element.ensureUserAgentShadowRoot();
+ auto controlLayer = HTMLDivElement::create(document.get());
+ controlLayer->setIdAttribute(imageControlsElementIdentifier());
+ shadowRoot->appendChild(controlLayer);
+
+ static MainThreadNeverDestroyed<const String> shadowStyle(StringImpl::createWithoutCopying(imageControlsMacUserAgentStyleSheet, sizeof(imageControlsMacUserAgentStyleSheet)));
+ auto style = HTMLStyleElement::create(HTMLNames::styleTag, document.get(), false);
+ style->setTextContent(shadowStyle);
+ shadowRoot->appendChild(WTFMove(style));
+
+ auto button = HTMLButtonElement::create(HTMLNames::buttonTag, element.document(), nullptr);
+ button->setIdAttribute(imageControlsButtonIdentifier());
+ controlLayer->appendChild(button);
+
+ if (auto* renderObject = element.renderer(); is<RenderImage>(renderObject))
+ downcast<RenderImage>(*renderObject).setHasShadowControls(true);
+}
+
+#endif // ENABLE(SERVICE_CONTROLS)
+
+} // namespace ImageControlsMac
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/mac/ImageControlsMac.h (0 => 286461)
--- trunk/Source/WebCore/dom/mac/ImageControlsMac.h (rev 0)
+++ trunk/Source/WebCore/dom/mac/ImageControlsMac.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "IntRect.h"
+
+namespace WebCore {
+
+class HTMLElement;
+class Node;
+
+namespace ImageControlsMac {
+
+#if ENABLE(SERVICE_CONTROLS)
+
+bool hasControls(const HTMLElement&);
+bool isImageControlsButtonElement(const Node&);
+void createImageControls(HTMLElement&);
+
+#endif // ENABLE(SERVICE_CONTROLS)
+
+} // namespace ImageControlsMac
+} // namespace WebCore
Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (286460 => 286461)
--- trunk/Source/WebCore/html/HTMLAttributeNames.in 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in 2021-12-02 23:49:57 UTC (rev 286461)
@@ -429,6 +429,7 @@
onwebkitcurrentplaybacktargetiswirelesschanged
onwebkitplaybacktargetavailabilitychanged
onwebkitpresentationmodechanged
+x-webkit-imagemenu
webkit-playsinline
x-webkit-airplay
x-webkit-wirelessvideoplaybackdisabled
Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (286460 => 286461)
--- trunk/Source/WebCore/html/HTMLImageElement.cpp 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -60,6 +60,10 @@
#include <wtf/IsoMallocInlines.h>
#include <wtf/text/StringBuilder.h>
+#if ENABLE(SERVICE_CONTROLS)
+#include "ImageControlsMac.h"
+#endif
+
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLImageElement);
@@ -308,6 +312,11 @@
BlendMode blendOp = BlendMode::Normal;
if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp))
m_compositeOperator = CompositeOperator::SourceOver;
+#if ENABLE(SERVICE_CONTROLS)
+ } else if (name == webkitimagemenuAttr) {
+ m_imageMenuEnabled = !value.isNull();
+ updateImageControls();
+#endif
} else if (name == loadingAttr) {
// No action needed for eager to lazy transition.
if (!hasLazyLoadableAttributeValue(value))
@@ -376,6 +385,10 @@
if (m_imageLoader->hasPendingBeforeLoadEvent())
return;
+#if ENABLE(SERVICE_CONTROLS)
+ updateImageControls();
+#endif
+
auto& renderImage = downcast<RenderImage>(*renderer());
RenderImageResource& renderImageResource = renderImage.imageResource();
if (renderImageResource.cachedImage())
@@ -753,6 +766,54 @@
#endif // ENABLE(ATTACHMENT_ELEMENT)
+#if ENABLE(SERVICE_CONTROLS)
+void HTMLImageElement::updateImageControls()
+{
+ // If this image element is inside a shadow tree then it is part of an image control.
+ if (isInShadowTree())
+ return;
+ if (!document().settings().imageControlsEnabled())
+ return;
+ bool hasControls = hasImageControls();
+ if (!m_imageMenuEnabled && hasControls)
+ destroyImageControls();
+ else if (m_imageMenuEnabled && !hasControls)
+ tryCreateImageControls();
+}
+
+void HTMLImageElement::tryCreateImageControls()
+{
+ ASSERT(m_imageMenuEnabled);
+ ASSERT(!hasImageControls());
+ ImageControlsMac::createImageControls(*this);
+}
+
+void HTMLImageElement::destroyImageControls()
+{
+ auto shadowRoot = userAgentShadowRoot();
+ if (!shadowRoot)
+ return;
+ if (RefPtr<Node> node = shadowRoot->firstChild()) {
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ImageControlsMac::hasControls(downcast<HTMLElement>(*node)));
+ shadowRoot->removeChild(*node);
+ }
+ auto* renderObject = renderer();
+ if (!renderObject)
+ return;
+ downcast<RenderImage>(*renderObject).setHasShadowControls(false);
+}
+
+bool HTMLImageElement::hasImageControls() const
+{
+ return ImageControlsMac::hasControls(*this);
+}
+
+bool HTMLImageElement::childShouldCreateRenderer(const Node& child) const
+{
+ return hasShadowRootParent(child) && HTMLElement::childShouldCreateRenderer(child);
+}
+#endif // ENABLE(SERVICE_CONTROLS)
+
#if PLATFORM(IOS_FAMILY)
// FIXME: We should find a better place for the touch callout logic. See rdar://problem/48937767.
bool HTMLImageElement::willRespondToMouseClickEvents()
Modified: trunk/Source/WebCore/html/HTMLImageElement.h (286460 => 286461)
--- trunk/Source/WebCore/html/HTMLImageElement.h 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/html/HTMLImageElement.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -116,6 +116,10 @@
const AtomString& imageSourceURL() const override;
+#if ENABLE(SERVICE_CONTROLS)
+ bool imageMenuEnabled() const { return m_imageMenuEnabled; }
+#endif
+
HTMLPictureElement* pictureElement() const;
void setPictureElement(HTMLPictureElement*);
@@ -188,6 +192,14 @@
void copyNonAttributePropertiesFromElement(const Element&) final;
float effectiveImageDevicePixelRatio() const;
+
+#if ENABLE(SERVICE_CONTROLS)
+ void updateImageControls();
+ void tryCreateImageControls();
+ void destroyImageControls();
+ bool hasImageControls() const;
+ bool childShouldCreateRenderer(const Node&) const override;
+#endif
HTMLSourceElement* sourceElement() const;
void setSourceElement(HTMLSourceElement*);
@@ -201,6 +213,9 @@
AtomString m_currentSrc;
AtomString m_parsedUsemap;
float m_imageDevicePixelRatio;
+#if ENABLE(SERVICE_CONTROLS)
+ bool m_imageMenuEnabled { false };
+#endif
bool m_hadNameBeforeAttributeChanged { false }; // FIXME: We only need this because parseAttribute() can't see the old value.
bool m_isDroppedImagePlaceholder { false };
Added: trunk/Source/WebCore/html/shadow/mac/imageControlsMac.css (0 => 286461)
--- trunk/Source/WebCore/html/shadow/mac/imageControlsMac.css (rev 0)
+++ trunk/Source/WebCore/html/shadow/mac/imageControlsMac.css 2021-12-02 23:49:57 UTC (rev 286461)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#if defined(ENABLE_SERVICE_CONTROLS) && ENABLE_SERVICE_CONTROLS
+
+div#image-controls {
+ display: inline-block;
+ position: relative;
+ overflow: hidden;
+ color: transparent;
+}
+
+div#image-controls button#image-controls-button {
+ position: absolute;
+ top: 20px;
+ right: 20px;
+
+ display: block;
+
+ appearance: -internal-image-controls-button;
+
+ transition: opacity 0.25s;
+ opacity: 0.0;
+}
+
+div#image-controls:hover button#image-controls-button {
+ opacity: 1.0;
+}
+
+#endif
+
+
Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (286460 => 286461)
--- trunk/Source/WebCore/page/ContextMenuController.cpp 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -73,7 +73,11 @@
#include <wtf/WallTime.h>
#include <wtf/unicode/CharacterNames.h>
+#if ENABLE(SERVICE_CONTROLS)
+#include "ImageControlsMac.h"
+#endif
+
namespace WebCore {
using namespace WTF::Unicode;
@@ -143,6 +147,21 @@
showContextMenu(event);
}
+#if ENABLE(SERVICE_CONTROLS)
+
+static Image* imageFromImageElementNode(Node& node)
+{
+ auto* renderer = node.renderer();
+ if (!is<RenderImage>(renderer))
+ return nullptr;
+ auto* image = downcast<RenderImage>(*renderer).cachedImage();
+ if (!image || image->errorOccurred())
+ return nullptr;
+ return image->imageForRenderer(renderer);
+}
+
+#endif
+
std::unique_ptr<ContextMenu> ContextMenuController::maybeCreateContextMenu(Event& event, OptionSet<HitTestRequest::Type> hitType, ContextMenuContext::Type contextType)
{
if (!is<MouseEvent>(event))
@@ -162,6 +181,16 @@
m_context = ContextMenuContext(contextType, result);
+#if ENABLE(SERVICE_CONTROLS)
+ if (ImageControlsMac::isImageControlsButtonElement(node)) {
+ if (auto* image = imageFromImageElementNode(*result.innerNonSharedNode()))
+ m_context.setControlledImage(image);
+
+ // FIXME: If we couldn't get the image then we shouldn't try to show the image controls menu for it.
+ return nullptr;
+ }
+#endif
+
return makeUnique<ContextMenu>();
}
@@ -1536,6 +1565,17 @@
#endif
+#if ENABLE(SERVICE_CONTROLS)
+
+void ContextMenuController::showImageControlsMenu(Event& event)
+{
+ clearContextMenu();
+ handleContextMenuEvent(event);
+ m_client.showContextMenu();
+}
+
+#endif
+
} // namespace WebCore
#endif // ENABLE(CONTEXT_MENUS)
Modified: trunk/Source/WebCore/page/ContextMenuController.h (286460 => 286461)
--- trunk/Source/WebCore/page/ContextMenuController.h 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/page/ContextMenuController.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -69,6 +69,10 @@
#if USE(ACCESSIBILITY_CONTEXT_MENUS)
void showContextMenuAt(Frame&, const IntPoint& clickPoint);
#endif
+
+#if ENABLE(SERVICE_CONTROLS)
+ void showImageControlsMenu(Event&);
+#endif
private:
std::unique_ptr<ContextMenu> maybeCreateContextMenu(Event&, OptionSet<HitTestRequest::Type> hitType, ContextMenuContext::Type);
Modified: trunk/Source/WebCore/platform/ThemeTypes.cpp (286460 => 286461)
--- trunk/Source/WebCore/platform/ThemeTypes.cpp 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/platform/ThemeTypes.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -91,6 +91,9 @@
case ContinuousCapacityLevelIndicatorPart: ts << "continuous-capacity-level-indicator-part"; break;
case DiscreteCapacityLevelIndicatorPart: ts << "discrete-capacity-level-indicator-part"; break;
case RatingLevelIndicatorPart: ts << "rating-level-indicator-part"; break;
+#if ENABLE(SERVICE_CONTROLS)
+ case ImageControlsButtonPart: ts << "image-controls-button-part"; break;
+#endif
#if ENABLE(APPLE_PAY)
case ApplePayButtonPart: ts << "apple-pay-button-part"; break;
#endif
Modified: trunk/Source/WebCore/platform/ThemeTypes.h (286460 => 286461)
--- trunk/Source/WebCore/platform/ThemeTypes.h 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/platform/ThemeTypes.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -91,6 +91,9 @@
ContinuousCapacityLevelIndicatorPart,
DiscreteCapacityLevelIndicatorPart,
RatingLevelIndicatorPart,
+#if ENABLE(SERVICE_CONTROLS)
+ ImageControlsButtonPart,
+#endif
#if ENABLE(APPLE_PAY)
ApplePayButtonPart,
#endif
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (286460 => 286461)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -145,6 +145,10 @@
, m_imageDevicePixelRatio(imageDevicePixelRatio)
{
updateAltText();
+#if ENABLE(SERVICE_CONTROLS)
+ if (is<HTMLImageElement>(element))
+ m_hasShadowControls = downcast<HTMLImageElement>(element).imageMenuEnabled();
+#endif
}
RenderImage::RenderImage(Document& document, RenderStyle&& style, StyleImage* styleImage)
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (286460 => 286461)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -267,6 +267,10 @@
case DiscreteCapacityLevelIndicatorPart:
case RatingLevelIndicatorPart:
return adjustMeterStyle(style, element);
+#if ENABLE(SERVICE_CONTROLS)
+ case ImageControlsButtonPart:
+ return adjustImageControlsButtonStyle(style, element);
+#endif
case CapsLockIndicatorPart:
return adjustCapsLockIndicatorStyle(style, element);
#if ENABLE(APPLE_PAY)
@@ -546,6 +550,10 @@
return paintSearchFieldResultsDecorationPart(box, paintInfo, integralSnappedRect);
case SearchFieldResultsButtonPart:
return paintSearchFieldResultsButton(box, paintInfo, integralSnappedRect);
+#if ENABLE(SERVICE_CONTROLS)
+ case ImageControlsButtonPart:
+ return paintImageControlsButton(box, paintInfo, integralSnappedRect);
+#endif
case CapsLockIndicatorPart:
return paintCapsLockIndicator(box, paintInfo, integralSnappedRect);
#if ENABLE(APPLE_PAY)
@@ -612,6 +620,9 @@
case SearchFieldDecorationPart:
case SearchFieldResultsDecorationPart:
case SearchFieldResultsButtonPart:
+#if ENABLE(SERVICE_CONTROLS)
+ case ImageControlsButtonPart:
+#endif
default:
break;
}
@@ -686,6 +697,9 @@
case SearchFieldDecorationPart:
case SearchFieldResultsDecorationPart:
case SearchFieldResultsButtonPart:
+#if ENABLE(SERVICE_CONTROLS)
+ case ImageControlsButtonPart:
+#endif
default:
break;
}
@@ -1277,6 +1291,12 @@
#endif
+#if ENABLE(SERVICE_CONTROLS)
+void RenderTheme::adjustImageControlsButtonStyle(RenderStyle&, const Element*) const
+{
+}
+#endif
+
Seconds RenderTheme::animationRepeatIntervalForProgressBar(const RenderProgress&) const
{
return 0_s;
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (286460 => 286461)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -249,6 +249,10 @@
enum FileUploadDecorations { SingleFile, MultipleFiles };
virtual void paintFileUploadIconDecorations(const RenderObject& /*inputRenderer*/, const RenderObject& /*buttonRenderer*/, const PaintInfo&, const IntRect&, Icon*, FileUploadDecorations) { }
+
+#if ENABLE(SERVICE_CONTROLS)
+ virtual IntSize imageControlsButtonSize() const { return IntSize(); }
+#endif
#if ENABLE(ATTACHMENT_ELEMENT)
virtual LayoutSize attachmentIntrinsicSize(const RenderAttachment&) const { return LayoutSize(); }
@@ -359,6 +363,11 @@
virtual void adjustListButtonStyle(RenderStyle&, const Element*) const;
virtual bool paintListButton(const RenderObject&, const PaintInfo&, const FloatRect&) { return true; }
#endif
+
+#if ENABLE(SERVICE_CONTROLS)
+ virtual void adjustImageControlsButtonStyle(RenderStyle&, const Element*) const;
+ virtual bool paintImageControlsButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
+#endif
virtual void adjustProgressBarStyle(RenderStyle&, const Element*) const;
virtual bool paintProgressBar(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (286460 => 286461)
--- trunk/Source/WebCore/rendering/RenderThemeMac.h 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -145,6 +145,10 @@
void paintListButtonForInput(const RenderObject&, GraphicsContext&, const FloatRect&);
void adjustListButtonStyle(RenderStyle&, const Element*) const final;
#endif
+
+#if ENABLE(SERVICE_CONTROLS)
+ void adjustImageControlsButtonStyle(RenderStyle&, const Element*) const final;
+#endif
#if ENABLE(VIDEO)
bool supportsClosedCaptioning() const final { return true; }
@@ -208,7 +212,14 @@
int minimumProgressBarHeight(const RenderStyle&) const;
const IntSize* progressBarSizes() const;
const int* progressBarMargins(NSControlSize) const;
+
+#if ENABLE(SERVICE_CONTROLS)
+ bool paintImageControlsButton(const RenderObject&, const PaintInfo&, const IntRect&) final;
+ IntSize imageControlsButtonSize() const final;
+ NSServicesRolloverButtonCell *servicesRolloverButtonCell() const;
+#endif
+
mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
mutable RetainPtr<NSSearchFieldCell> m_search;
mutable RetainPtr<NSMenu> m_searchMenuTemplate;
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (286460 => 286461)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2021-12-02 23:49:57 UTC (rev 286461)
@@ -75,6 +75,7 @@
#import <pal/spi/mac/NSAppearanceSPI.h>
#import <pal/spi/mac/NSCellSPI.h>
#import <pal/spi/mac/NSImageSPI.h>
+#import <pal/spi/mac/NSServicesRolloverButtonCellSPI.h>
#import <pal/spi/mac/NSSharingServicePickerSPI.h>
#import <wtf/MathExtras.h>
#import <wtf/ObjCRuntimeExtras.h>
@@ -82,18 +83,7 @@
#import <wtf/StdLibExtras.h>
#import <wtf/text/StringBuilder.h>
-#if ENABLE(SERVICE_CONTROLS)
-
// FIXME: This should go into an SPI.h file in the spi directory.
-#if USE(APPLE_INTERNAL_SDK)
-#import <AppKit/AppKitDefines_Private.h>
-#else
-#define APPKIT_PRIVATE_CLASS
-#endif
-
-#endif // ENABLE(SERVICE_CONTROLS)
-
-// FIXME: This should go into an SPI.h file in the spi directory.
@interface NSTextFieldCell ()
- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus;
- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus maskOnly:(BOOL)maskOnly;
@@ -1093,6 +1083,14 @@
#endif
+#if ENABLE(SERVICE_CONTROLS)
+void RenderThemeMac::adjustImageControlsButtonStyle(RenderStyle& style, const Element*) const
+{
+ style.setHeight(Length(imageControlsButtonSize().height(), LengthType::Fixed));
+ style.setWidth(Length(imageControlsButtonSize().width(), LengthType::Fixed));
+}
+#endif
+
bool RenderThemeMac::paintTextField(const RenderObject& o, const PaintInfo& paintInfo, const FloatRect& r)
{
LocalCurrentGraphicsContext localContext(paintInfo.context());
@@ -2282,6 +2280,37 @@
return StringTruncator::centerTruncate(strToTruncate, width, font);
}
+#if ENABLE(SERVICE_CONTROLS)
+NSServicesRolloverButtonCell* RenderThemeMac::servicesRolloverButtonCell() const
+{
+ if (!m_servicesRolloverButton) {
+ m_servicesRolloverButton = [NSServicesRolloverButtonCell serviceRolloverButtonCellForStyle:NSSharingServicePickerStyleRollover];
+ [m_servicesRolloverButton setBezelStyle:NSBezelStyleRoundedDisclosure];
+ [m_servicesRolloverButton setButtonType:NSButtonTypePushOnPushOff];
+ [m_servicesRolloverButton setImagePosition:NSImageOnly];
+ [m_servicesRolloverButton setState:NO];
+ }
+ return m_servicesRolloverButton.get();
+}
+
+bool RenderThemeMac::paintImageControlsButton(const RenderObject& renderer, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ NSServicesRolloverButtonCell *cell = servicesRolloverButtonCell();
+ LocalCurrentGraphicsContext localContext(paintInfo.context());
+ GraphicsContextStateSaver stateSaver(paintInfo.context());
+ paintInfo.context().translate(rect.location());
+ IntRect innerFrame(IntPoint(), rect.size());
+ [cell drawWithFrame:innerFrame inView:documentViewFor(renderer)];
+ [cell setControlView:nil];
+ return false;
+}
+
+IntSize RenderThemeMac::imageControlsButtonSize() const
+{
+ return IntSize(servicesRolloverButtonCell().cellSize);
+}
+#endif
+
#if ENABLE(ATTACHMENT_ELEMENT)
const CGFloat attachmentIconSize = 48;
const CGFloat attachmentIconBackgroundPadding = 6;
Modified: trunk/Source/WebCore/style/UserAgentStyle.cpp (286460 => 286461)
--- trunk/Source/WebCore/style/UserAgentStyle.cpp 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/style/UserAgentStyle.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -74,6 +74,9 @@
StyleSheetContents* UserAgentStyle::mediaControlsStyleSheet;
StyleSheetContents* UserAgentStyle::fullscreenStyleSheet;
StyleSheetContents* UserAgentStyle::plugInsStyleSheet;
+#if ENABLE(SERVICE_CONTROLS)
+StyleSheetContents* UserAgentStyle::imageControlsStyleSheet;
+#endif
StyleSheetContents* UserAgentStyle::mediaQueryStyleSheet;
#if ENABLE(DATALIST_ELEMENT)
StyleSheetContents* UserAgentStyle::dataListStyleSheet;
Modified: trunk/Source/WebCore/style/UserAgentStyle.h (286460 => 286461)
--- trunk/Source/WebCore/style/UserAgentStyle.h 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebCore/style/UserAgentStyle.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -46,6 +46,9 @@
static StyleSheetContents* mediaControlsStyleSheet;
static StyleSheetContents* fullscreenStyleSheet;
static StyleSheetContents* plugInsStyleSheet;
+#if ENABLE(SERVICE_CONTROLS)
+ static StyleSheetContents* imageControlsStyleSheet;
+#endif
#if ENABLE(DATALIST_ELEMENT)
static StyleSheetContents* dataListStyleSheet;
#endif
Modified: trunk/Source/WebKit/ChangeLog (286460 => 286461)
--- trunk/Source/WebKit/ChangeLog 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebKit/ChangeLog 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1,3 +1,26 @@
+2021-12-02 Megan Gardner <megan_gard...@apple.com>
+
+ Re-add support of image control menus.
+ https://bugs.webkit.org/show_bug.cgi?id=233305
+
+ Reviewed by Tim Horton.
+
+ Image control menus are needed for mail transition to modern WebKit, so re-add them
+ after the removal in https://trac.webkit.org/changeset/272117/webkit
+
+ * Platform/spi/mac/AppKitSPI.h:
+ * UIProcess/API/C/WKPreferences.cpp:
+ (WKPreferencesSetImageControlsEnabled):
+ (WKPreferencesGetImageControlsEnabled):
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _setupPageConfiguration:]):
+ * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+ (-[WKWebViewConfiguration init]):
+ (-[WKWebViewConfiguration copyWithZone:]):
+ (-[WKWebViewConfiguration _imageControlsEnabled]):
+ (-[WKWebViewConfiguration _setImageControlsEnabled:]):
+ * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+
2021-12-02 Per Arne Vollan <pvol...@apple.com>
[iOS] Add required system call to WebKit sandboxes
Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (286460 => 286461)
--- trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp 2021-12-02 23:49:57 UTC (rev 286461)
@@ -1421,15 +1421,14 @@
return toImpl(preferencesRef)->serviceControlsEnabled();
}
-void WKPreferencesSetImageControlsEnabled(WKPreferencesRef, bool)
+void WKPreferencesSetImageControlsEnabled(WKPreferencesRef preferencesRef, bool enabled)
{
- // Image controls are no longer supported.
+ toImpl(preferencesRef)->setImageControlsEnabled(enabled);
}
-bool WKPreferencesGetImageControlsEnabled(WKPreferencesRef)
+bool WKPreferencesGetImageControlsEnabled(WKPreferencesRef preferencesRef)
{
- // Image controls are no longer supported.
- return false;
+ return toImpl(preferencesRef)->imageControlsEnabled();
}
void WKPreferencesSetGamepadsEnabled(WKPreferencesRef preferencesRef, bool enabled)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (286460 => 286461)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-12-02 23:49:57 UTC (rev 286461)
@@ -489,6 +489,7 @@
#if PLATFORM(MAC)
pageConfiguration->preferences()->setShowsURLsInToolTipsEnabled(!![_configuration _showsURLsInToolTips]);
pageConfiguration->preferences()->setServiceControlsEnabled(!![_configuration _serviceControlsEnabled]);
+ pageConfiguration->preferences()->setImageControlsEnabled(!![_configuration _imageControlsEnabled]);
pageConfiguration->preferences()->setUserInterfaceDirectionPolicy(convertUserInterfaceDirectionPolicy([_configuration userInterfaceDirectionPolicy]));
// We are in the View's initialization routine, so our client hasn't had time to set our user interface direction.
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (286460 => 286461)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2021-12-02 23:49:57 UTC (rev 286461)
@@ -157,6 +157,7 @@
WKRetainPtr<WKPageGroupRef> _pageGroup;
BOOL _showsURLsInToolTips;
BOOL _serviceControlsEnabled;
+ BOOL _imageControlsEnabled;
#endif
BOOL _waitsForPaintAfterViewDidMoveToWindow;
BOOL _controlledByAutomation;
@@ -227,6 +228,7 @@
_respectsImageOrientation = NO;
_showsURLsInToolTips = NO;
_serviceControlsEnabled = NO;
+ _imageControlsEnabled = NO;
#endif
_waitsForPaintAfterViewDidMoveToWindow = YES;
@@ -425,6 +427,7 @@
configuration->_userInterfaceDirectionPolicy = self->_userInterfaceDirectionPolicy;
configuration->_showsURLsInToolTips = self->_showsURLsInToolTips;
configuration->_serviceControlsEnabled = self->_serviceControlsEnabled;
+ configuration->_imageControlsEnabled = self->_imageControlsEnabled;
configuration->_pageGroup = self._pageGroup;
#endif
#if ENABLE(DATA_DETECTION) && PLATFORM(IOS_FAMILY)
@@ -1145,13 +1148,12 @@
- (BOOL)_imageControlsEnabled
{
- // Image controls are no longer supported.
- return NO;
+ return _imageControlsEnabled;
}
- (void)_setImageControlsEnabled:(BOOL)imageControlsEnabled
{
- // Image controls are no longer supported.
+ _imageControlsEnabled = imageControlsEnabled;
}
- (BOOL)_requiresUserActionForEditingControlsManager
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (286460 => 286461)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h 2021-12-02 23:48:09 UTC (rev 286460)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h 2021-12-02 23:49:57 UTC (rev 286461)
@@ -105,7 +105,7 @@
#else
@property (nonatomic, setter=_setShowsURLsInToolTips:) BOOL _showsURLsInToolTips WK_API_AVAILABLE(macos(10.12));
@property (nonatomic, setter=_setServiceControlsEnabled:) BOOL _serviceControlsEnabled WK_API_AVAILABLE(macos(10.12));
-@property (nonatomic, setter=_setImageControlsEnabled:) BOOL _imageControlsEnabled WK_API_DEPRECATED("Image controls are no longer supported", macos(10.12, 12.0));
+@property (nonatomic, setter=_setImageControlsEnabled:) BOOL _imageControlsEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA));
@property (nonatomic, readwrite, setter=_setRequiresUserActionForEditingControlsManager:) BOOL _requiresUserActionForEditingControlsManager WK_API_AVAILABLE(macos(10.12));
@property (nonatomic, readwrite, setter=_setCPULimit:) double _cpuLimit WK_API_AVAILABLE(macos(10.13.4));
@property (nonatomic, readwrite, setter=_setPageGroup:) WKPageGroupRef _pageGroup WK_API_AVAILABLE(macos(10.13.4));