Diff
Modified: trunk/Source/WebCore/ChangeLog (286629 => 286630)
--- trunk/Source/WebCore/ChangeLog 2021-12-08 00:24:28 UTC (rev 286629)
+++ trunk/Source/WebCore/ChangeLog 2021-12-08 00:40:21 UTC (rev 286630)
@@ -1,3 +1,34 @@
+2021-12-07 Devin Rousso <[email protected]>
+
+ Add helper methods to `WebCore::FontShadow` for serializing to CSS and converting to `NSShadow`
+ https://bugs.webkit.org/show_bug.cgi?id=233938
+
+ Implementing `-pasteFont:` <https://webkit.org/b/191379> requires that we convert native
+ font attribute data into objects understandable by WebCore, one of which is a `NSShadow`.
+ These helpers will make it easier to parse the `NSShadow` and convert it to a CSS value that
+ we will use to override the selection's CSS `text-shadow`.
+
+ No change in behavior.
+
+ Reviewed by Wenson Hsieh.
+
+ Tests: FontShadow.InvalidColor
+ FontShadow.NoOffsetOrBlurRadius
+ FontShadow.NoOffset
+ FontShadow.NegativeOffset
+ FontShadow.NoBlurRadius
+ FontShadow.NegativeBlurRadius
+ FontShadow.AllNegative
+
+ * editing/FontShadow.h:
+ * editing/FontShadow.cpp: Added.
+ (WebCore::serializationForCSS):
+ * editing/cocoa/FontShadowCocoa.mm:
+ (WebCore::fontShadowFromNSShadow): Added.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+
2021-12-07 Yoshiaki Jitsukawa <[email protected]>
Support Animated JPEG-XL images
Modified: trunk/Source/WebCore/Sources.txt (286629 => 286630)
--- trunk/Source/WebCore/Sources.txt 2021-12-08 00:24:28 UTC (rev 286629)
+++ trunk/Source/WebCore/Sources.txt 2021-12-08 00:40:21 UTC (rev 286630)
@@ -1096,6 +1096,7 @@
editing/Editor.cpp
editing/EditorCommand.cpp
editing/FontAttributeChanges.cpp
+editing/FontShadow.cpp
editing/FormatBlockCommand.cpp
editing/FrameSelection.cpp
editing/HTMLInterchange.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (286629 => 286630)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-08 00:24:28 UTC (rev 286629)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-08 00:40:21 UTC (rev 286630)
@@ -17661,6 +17661,7 @@
F48570A42644C76D00C05F71 /* TranslationContextMenuInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TranslationContextMenuInfo.h; sourceTree = "<group>"; };
F48B7D5225C341E6009E75DD /* TextRecognitionResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextRecognitionResult.h; sourceTree = "<group>"; };
F48D2A6A215623B400C6752B /* FontShadow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontShadow.h; sourceTree = "<group>"; };
+ F48D2A6A215623B400C6752C /* FontShadow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontShadow.cpp; sourceTree = "<group>"; };
F48D2A712156DC0A00C6752B /* FontAttributes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontAttributes.h; sourceTree = "<group>"; };
F48D2A752156FE5700C6752B /* FontAttributesCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontAttributesCocoa.mm; sourceTree = "<group>"; };
F48D2A7A2157051E00C6752B /* FontShadowCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontShadowCocoa.mm; sourceTree = "<group>"; };
@@ -25033,6 +25034,7 @@
F442850B2140412500CCDA22 /* FontAttributeChanges.cpp */,
F4E57EDA213F3F5F004EA98E /* FontAttributeChanges.h */,
F48D2A712156DC0A00C6752B /* FontAttributes.h */,
+ F48D2A6A215623B400C6752C /* FontShadow.cpp */,
F48D2A6A215623B400C6752B /* FontShadow.h */,
D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */,
D05CED280A40BB2C00C5AF38 /* FormatBlockCommand.h */,
@@ -33515,10 +33517,12 @@
CD3EEF3C25799FAB006563BB /* ColorGamut.h in Headers */,
3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */,
F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
+ BC3A00C82754496D0047C0E5 /* ColorInterpolation.h in Headers */,
BC4A23EC25EC160200AAC630 /* ColorLuminance.h in Headers */,
EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */,
7CAC6AE9247F082F00E61D59 /* ColorMatrix.h in Headers */,
BC10137C25C3624B00DC773C /* ColorModels.h in Headers */,
+ BCB2F88E275BEE58007231BF /* ColorNormalization.h in Headers */,
7CD1E69324ABF6240089C419 /* ColorSerialization.h in Headers */,
9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */,
BCAFEDB425968D0B0030E6AA /* ColorSpaceCG.h in Headers */,
@@ -36244,7 +36248,6 @@
49D5DC2E0F423A73008F20FD /* PerspectiveTransformOperation.h in Headers */,
1DBC1B562347B3D200B901AF /* PictureInPictureObserver.h in Headers */,
1D2C82B7236A3F6A0055D6C5 /* PictureInPictureSupport.h in Headers */,
- BC3A00C82754496D0047C0E5 /* ColorInterpolation.h in Headers */,
1D2F8E062344752300993B68 /* PictureInPictureWindow.h in Headers */,
5758597C23A1FCF300C74572 /* Pin.h in Headers */,
D0FF2A5E11F8C45A007E74E0 /* PingLoader.h in Headers */,
@@ -36669,7 +36672,6 @@
4188D56326C551B1004858C8 /* RTCDtlsTransportState.h in Headers */,
078E092017D14D1C00420AA1 /* RTCDTMFSender.h in Headers */,
078E092117D14D1C00420AA1 /* RTCDTMFToneChangeEvent.h in Headers */,
- BCB2F88E275BEE58007231BF /* ColorNormalization.h in Headers */,
41E6D71B26EA1A4600B765D6 /* RTCError.h in Headers */,
41AB979526E75A2E007C0FE6 /* RTCErrorDetailType.h in Headers */,
078E092317D14D1C00420AA1 /* RTCIceCandidate.h in Headers */,
Copied: trunk/Source/WebCore/editing/FontShadow.cpp (from rev 286629, trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm) (0 => 286630)
--- trunk/Source/WebCore/editing/FontShadow.cpp (rev 0)
+++ trunk/Source/WebCore/editing/FontShadow.cpp 2021-12-08 00:40:21 UTC (rev 286630)
@@ -0,0 +1,51 @@
+/*
+ * 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 "FontShadow.h"
+
+#include "ColorSerialization.h"
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+String serializationForCSS(const FontShadow& shadow)
+{
+ if (shadow.offset.isZero() && !shadow.blurRadius)
+ return "none"_s;
+
+ if (!shadow.color.isValid())
+ return "none"_s;
+
+ StringBuilder builder;
+ builder.append(shadow.offset.width(), "px ");
+ builder.append(shadow.offset.height(), "px ");
+ builder.append(serializationForCSS(shadow.color));
+ if (shadow.blurRadius)
+ builder.append(" ", shadow.blurRadius, "px");
+ return builder.toString();
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/editing/FontShadow.h (286629 => 286630)
--- trunk/Source/WebCore/editing/FontShadow.h 2021-12-08 00:24:28 UTC (rev 286629)
+++ trunk/Source/WebCore/editing/FontShadow.h 2021-12-08 00:40:21 UTC (rev 286630)
@@ -28,6 +28,7 @@
#include "Color.h"
#include "FloatSize.h"
#include <wtf/RetainPtr.h>
+#include <wtf/text/WTFString.h>
#if PLATFORM(COCOA)
OBJC_CLASS NSShadow;
@@ -69,4 +70,10 @@
return true;
}
+#if PLATFORM(COCOA)
+WEBCORE_EXPORT FontShadow fontShadowFromNSShadow(NSShadow *);
+#endif
+
+WEBCORE_EXPORT String serializationForCSS(const FontShadow&);
+
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm (286629 => 286630)
--- trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm 2021-12-08 00:24:28 UTC (rev 286629)
+++ trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm 2021-12-08 00:40:21 UTC (rev 286630)
@@ -48,4 +48,13 @@
return shadow;
}
+FontShadow fontShadowFromNSShadow(NSShadow *shadow)
+{
+ return {
+ colorFromCocoaColor(shadow.shadowColor),
+ FloatSize(shadow.shadowOffset),
+ shadow.shadowBlurRadius,
+ };
}
+
+}
Modified: trunk/Tools/ChangeLog (286629 => 286630)
--- trunk/Tools/ChangeLog 2021-12-08 00:24:28 UTC (rev 286629)
+++ trunk/Tools/ChangeLog 2021-12-08 00:40:21 UTC (rev 286630)
@@ -1,3 +1,21 @@
+2021-12-07 Devin Rousso <[email protected]>
+
+ Add helper methods to `WebCore::FontShadow` for serializing to CSS and converting to `NSShadow`
+ https://bugs.webkit.org/show_bug.cgi?id=233938
+
+ Reviewed by Wenson Hsieh.
+
+ * TestWebKitAPI/Tests/WebCore/FontShadowTests.cpp: Added.
+ (TestWebKitAPI::TEST.FontShadow.InvalidColor):
+ (TestWebKitAPI::TEST.FontShadow.NoOffsetOrBlurRadius):
+ (TestWebKitAPI::TEST.FontShadow.NoOffset):
+ (TestWebKitAPI::TEST.FontShadow.NegativeOffset):
+ (TestWebKitAPI::TEST.FontShadow.NoBlurRadius):
+ (TestWebKitAPI::TEST.FontShadow.NegativeBlurRadius):
+ (TestWebKitAPI::TEST.FontShadow.AllNegative):
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
2021-12-07 Jonathan Bedard <[email protected]>
[commits.webkit.org] Fallback to remote repository (Part 2)
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (286629 => 286630)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-12-08 00:24:28 UTC (rev 286629)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-12-08 00:40:21 UTC (rev 286630)
@@ -764,6 +764,7 @@
93FCDB34263631560046DD7D /* SortedArrayMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93FCDB33263631560046DD7D /* SortedArrayMap.cpp */; };
952F7167270BD9CB00D00DCC /* CSSViewportUnits.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 952F7166270BD99700D00DCC /* CSSViewportUnits.html */; };
952F7167270BD9CB00D00DCD /* CSSViewportUnits.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = 952F7166270BD99700D00DCD /* CSSViewportUnits.svg */; };
+ 95C52729275F35E100DA7E40 /* FontShadowTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C52728275F35E100DA7E40 /* FontShadowTests.cpp */; };
996EDCCB270E70D7006DF175 /* InspectorExtension-basic-page.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 996EDCCA270E70AB006DF175 /* InspectorExtension-basic-page.html */; };
9984FACE1CFFB090008D198C /* editable-body.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9984FACD1CFFB038008D198C /* editable-body.html */; };
99E2846626F93DB50003F1FA /* InspectorExtension-TabIcon-30x30.png in Copy Resources */ = {isa = PBXBuildFile; fileRef = 99E2846526F93D760003F1FA /* InspectorExtension-TabIcon-30x30.png */; };
@@ -2515,6 +2516,7 @@
958B70E026C46EDC00B2022B /* NSAttributedStringWebKitAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NSAttributedStringWebKitAdditions.mm; sourceTree = "<group>"; };
95A524942581A10D00461FE9 /* WKWebViewThemeColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewThemeColor.mm; sourceTree = "<group>"; };
95B6B3B6251EBF2F00FC4382 /* MediaDocument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaDocument.mm; sourceTree = "<group>"; };
+ 95C52728275F35E100DA7E40 /* FontShadowTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontShadowTests.cpp; sourceTree = "<group>"; };
996EDCCA270E70AB006DF175 /* InspectorExtension-basic-page.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "InspectorExtension-basic-page.html"; sourceTree = "<group>"; };
9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewTextInput.mm; sourceTree = "<group>"; };
9984FACD1CFFB038008D198C /* editable-body.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "editable-body.html"; sourceTree = "<group>"; };
@@ -3685,6 +3687,7 @@
F4AD183725ED791500B1A19F /* FloatQuadTests.cpp */,
7A909A711D877475007E10F8 /* FloatRectTests.cpp */,
7A909A721D877475007E10F8 /* FloatSizeTests.cpp */,
+ 95C52728275F35E100DA7E40 /* FontShadowTests.cpp */,
8E4A85361E1D1AA100F53B0F /* GridPosition.cpp */,
83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */,
5CA1DEC71F71F40700E71BD3 /* HTTPHeaderField.cpp */,
@@ -5474,6 +5477,7 @@
F4BC0B142146C849002A0478 /* FocusPreservationTests.mm in Sources */,
F456AB1C213EDBA300CB2CEF /* FontManagerTests.mm in Sources */,
1C81802725FB09E200608B3E /* FontRegistrySandboxCheck.mm in Sources */,
+ 95C52729275F35E100DA7E40 /* FontShadowTests.cpp in Sources */,
1CF59AE321E68932006E37EC /* ForceLightAppearanceInBundle.mm in Sources */,
7CCE7EF51A411AE600447C4C /* ForceRepaint.cpp in Sources */,
7CCE7EC01A411A7E00447C4C /* FragmentNavigation.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/FontShadowTests.cpp (0 => 286630)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/FontShadowTests.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/FontShadowTests.cpp 2021-12-08 00:40:21 UTC (rev 286630)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2011-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 "Test.h"
+#include <WebCore/FontShadow.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+TEST(FontShadow, InvalidColor)
+{
+ FontShadow fontShadow;
+ fontShadow.offset = { 1.1, 2.2 };
+ fontShadow.blurRadius = 3.3;
+ EXPECT_EQ(serializationForCSS(fontShadow), "none");
+ fontShadow.color = Color();
+ EXPECT_EQ(serializationForCSS(fontShadow), "none");
+}
+
+TEST(FontShadow, NoOffsetOrBlurRadius)
+{
+ FontShadow fontShadow;
+ fontShadow.color = Color::red;
+ EXPECT_EQ(serializationForCSS(fontShadow), "none");
+ fontShadow.offset = { 0, 0 };
+ EXPECT_EQ(serializationForCSS(fontShadow), "none");
+ fontShadow.blurRadius = 0;
+ EXPECT_EQ(serializationForCSS(fontShadow), "none");
+}
+
+TEST(FontShadow, NoOffset)
+{
+ FontShadow fontShadow;
+ fontShadow.color = Color::red;
+ fontShadow.blurRadius = 3.3;
+ EXPECT_EQ(serializationForCSS(fontShadow), "0px 0px rgb(255, 0, 0) 3.3px");
+ fontShadow.offset = { 0, 0 };
+ EXPECT_EQ(serializationForCSS(fontShadow), "0px 0px rgb(255, 0, 0) 3.3px");
+}
+
+TEST(FontShadow, NegativeOffset)
+{
+ FontShadow fontShadow;
+ fontShadow.color = Color::red;
+ fontShadow.offset = { -1.1, -2.2 };
+ fontShadow.blurRadius = 3.3;
+ EXPECT_EQ(serializationForCSS(fontShadow), "-1.1px -2.2px rgb(255, 0, 0) 3.3px");
+}
+
+TEST(FontShadow, NoBlurRadius)
+{
+ FontShadow fontShadow;
+ fontShadow.color = Color::red;
+ fontShadow.offset = { 1.1, 2.2 };
+ EXPECT_EQ(serializationForCSS(fontShadow), "1.1px 2.2px rgb(255, 0, 0)");
+ fontShadow.blurRadius = 0;
+ EXPECT_EQ(serializationForCSS(fontShadow), "1.1px 2.2px rgb(255, 0, 0)");
+}
+
+TEST(FontShadow, NegativeBlurRadius)
+{
+ FontShadow fontShadow;
+ fontShadow.color = Color::red;
+ fontShadow.offset = { 1.1, 2.2 };
+ fontShadow.blurRadius = -3.3;
+ EXPECT_EQ(serializationForCSS(fontShadow), "1.1px 2.2px rgb(255, 0, 0) -3.3px");
+}
+
+TEST(FontShadow, AllNegative)
+{
+ FontShadow fontShadow;
+ fontShadow.color = Color::red;
+ fontShadow.offset = { -1.1, -2.2 };
+ fontShadow.blurRadius = -3.3;
+ EXPECT_EQ(serializationForCSS(fontShadow), "-1.1px -2.2px rgb(255, 0, 0) -3.3px");
+}
+
+} // namespace TestWebKitAPI