Changeset 286630 in webkit
- Timestamp:
- Dec 7, 2021, 4:40:21 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
- 1 copied
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
Source/WebCore/editing/FontShadow.cpp (copied) (copied from trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm ) (2 diffs)
-
Source/WebCore/editing/FontShadow.h (modified) (2 diffs)
-
Source/WebCore/editing/cocoa/FontShadowCocoa.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebCore/FontShadowTests.cpp (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286628 r286630 1 2021-12-07 Devin Rousso <drousso@apple.com> 2 3 Add helper methods to `WebCore::FontShadow` for serializing to CSS and converting to `NSShadow` 4 https://bugs.webkit.org/show_bug.cgi?id=233938 5 6 Implementing `-pasteFont:` <https://webkit.org/b/191379> requires that we convert native 7 font attribute data into objects understandable by WebCore, one of which is a `NSShadow`. 8 These helpers will make it easier to parse the `NSShadow` and convert it to a CSS value that 9 we will use to override the selection's CSS `text-shadow`. 10 11 No change in behavior. 12 13 Reviewed by Wenson Hsieh. 14 15 Tests: FontShadow.InvalidColor 16 FontShadow.NoOffsetOrBlurRadius 17 FontShadow.NoOffset 18 FontShadow.NegativeOffset 19 FontShadow.NoBlurRadius 20 FontShadow.NegativeBlurRadius 21 FontShadow.AllNegative 22 23 * editing/FontShadow.h: 24 * editing/FontShadow.cpp: Added. 25 (WebCore::serializationForCSS): 26 * editing/cocoa/FontShadowCocoa.mm: 27 (WebCore::fontShadowFromNSShadow): Added. 28 29 * Sources.txt: 30 * WebCore.xcodeproj/project.pbxproj: 31 1 32 2021-12-07 Yoshiaki Jitsukawa <yoshiaki.jitsukawa@sony.com> 2 33 -
trunk/Source/WebCore/Sources.txt
r286596 r286630 1097 1097 editing/EditorCommand.cpp 1098 1098 editing/FontAttributeChanges.cpp 1099 editing/FontShadow.cpp 1099 1100 editing/FormatBlockCommand.cpp 1100 1101 editing/FrameSelection.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r286596 r286630 17662 17662 F48B7D5225C341E6009E75DD /* TextRecognitionResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextRecognitionResult.h; sourceTree = "<group>"; }; 17663 17663 F48D2A6A215623B400C6752B /* FontShadow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontShadow.h; sourceTree = "<group>"; }; 17664 F48D2A6A215623B400C6752C /* FontShadow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontShadow.cpp; sourceTree = "<group>"; }; 17664 17665 F48D2A712156DC0A00C6752B /* FontAttributes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontAttributes.h; sourceTree = "<group>"; }; 17665 17666 F48D2A752156FE5700C6752B /* FontAttributesCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontAttributesCocoa.mm; sourceTree = "<group>"; }; … … 25034 25035 F4E57EDA213F3F5F004EA98E /* FontAttributeChanges.h */, 25035 25036 F48D2A712156DC0A00C6752B /* FontAttributes.h */, 25037 F48D2A6A215623B400C6752C /* FontShadow.cpp */, 25036 25038 F48D2A6A215623B400C6752B /* FontShadow.h */, 25037 25039 D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */, … … 33516 33518 3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */, 33517 33519 F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */, 33520 BC3A00C82754496D0047C0E5 /* ColorInterpolation.h in Headers */, 33518 33521 BC4A23EC25EC160200AAC630 /* ColorLuminance.h in Headers */, 33519 33522 EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */, 33520 33523 7CAC6AE9247F082F00E61D59 /* ColorMatrix.h in Headers */, 33521 33524 BC10137C25C3624B00DC773C /* ColorModels.h in Headers */, 33525 BCB2F88E275BEE58007231BF /* ColorNormalization.h in Headers */, 33522 33526 7CD1E69324ABF6240089C419 /* ColorSerialization.h in Headers */, 33523 33527 9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */, … … 36245 36249 1DBC1B562347B3D200B901AF /* PictureInPictureObserver.h in Headers */, 36246 36250 1D2C82B7236A3F6A0055D6C5 /* PictureInPictureSupport.h in Headers */, 36247 BC3A00C82754496D0047C0E5 /* ColorInterpolation.h in Headers */,36248 36251 1D2F8E062344752300993B68 /* PictureInPictureWindow.h in Headers */, 36249 36252 5758597C23A1FCF300C74572 /* Pin.h in Headers */, … … 36670 36673 078E092017D14D1C00420AA1 /* RTCDTMFSender.h in Headers */, 36671 36674 078E092117D14D1C00420AA1 /* RTCDTMFToneChangeEvent.h in Headers */, 36672 BCB2F88E275BEE58007231BF /* ColorNormalization.h in Headers */,36673 36675 41E6D71B26EA1A4600B765D6 /* RTCError.h in Headers */, 36674 36676 41AB979526E75A2E007C0FE6 /* RTCErrorDetailType.h in Headers */, -
trunk/Source/WebCore/editing/FontShadow.cpp
r286629 r286630 1 1 /* 2 * Copyright (C) 20 18Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #i mport"config.h"27 #i mport"FontShadow.h"26 #include "config.h" 27 #include "FontShadow.h" 28 28 29 #import "ColorCocoa.h" 30 #import "ColorMac.h" 31 32 #if PLATFORM(IOS_FAMILY) 33 #import <pal/ios/UIKitSoftLink.h> 34 #endif 29 #include "ColorSerialization.h" 30 #include <wtf/text/StringBuilder.h> 35 31 36 32 namespace WebCore { 37 33 38 RetainPtr<NSShadow> FontShadow::createShadow() const 34 String serializationForCSS(const FontShadow& shadow) 39 35 { 40 #if USE(APPKIT) 41 auto shadow = adoptNS([NSShadow new]); 42 #elif PLATFORM(IOS_FAMILY) 43 auto shadow = adoptNS([PAL::getNSShadowClass() new]); 44 #endif 45 [shadow setShadowColor:cocoaColor(color).get()]; 46 [shadow setShadowOffset:offset]; 47 [shadow setShadowBlurRadius:blurRadius]; 48 return shadow; 36 if (shadow.offset.isZero() && !shadow.blurRadius) 37 return "none"_s; 38 39 if (!shadow.color.isValid()) 40 return "none"_s; 41 42 StringBuilder builder; 43 builder.append(shadow.offset.width(), "px "); 44 builder.append(shadow.offset.height(), "px "); 45 builder.append(serializationForCSS(shadow.color)); 46 if (shadow.blurRadius) 47 builder.append(" ", shadow.blurRadius, "px"); 48 return builder.toString(); 49 49 } 50 50 51 } 51 } // namespace WebCore -
trunk/Source/WebCore/editing/FontShadow.h
r260078 r286630 29 29 #include "FloatSize.h" 30 30 #include <wtf/RetainPtr.h> 31 #include <wtf/text/WTFString.h> 31 32 32 33 #if PLATFORM(COCOA) … … 70 71 } 71 72 73 #if PLATFORM(COCOA) 74 WEBCORE_EXPORT FontShadow fontShadowFromNSShadow(NSShadow *); 75 #endif 76 77 WEBCORE_EXPORT String serializationForCSS(const FontShadow&); 78 72 79 } // namespace WebCore -
trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm
r284630 r286630 49 49 } 50 50 51 FontShadow fontShadowFromNSShadow(NSShadow *shadow) 52 { 53 return { 54 colorFromCocoaColor(shadow.shadowColor), 55 FloatSize(shadow.shadowOffset), 56 shadow.shadowBlurRadius, 57 }; 51 58 } 59 60 } -
trunk/Tools/ChangeLog
r286629 r286630 1 2021-12-07 Devin Rousso <drousso@apple.com> 2 3 Add helper methods to `WebCore::FontShadow` for serializing to CSS and converting to `NSShadow` 4 https://bugs.webkit.org/show_bug.cgi?id=233938 5 6 Reviewed by Wenson Hsieh. 7 8 * TestWebKitAPI/Tests/WebCore/FontShadowTests.cpp: Added. 9 (TestWebKitAPI::TEST.FontShadow.InvalidColor): 10 (TestWebKitAPI::TEST.FontShadow.NoOffsetOrBlurRadius): 11 (TestWebKitAPI::TEST.FontShadow.NoOffset): 12 (TestWebKitAPI::TEST.FontShadow.NegativeOffset): 13 (TestWebKitAPI::TEST.FontShadow.NoBlurRadius): 14 (TestWebKitAPI::TEST.FontShadow.NegativeBlurRadius): 15 (TestWebKitAPI::TEST.FontShadow.AllNegative): 16 17 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 18 1 19 2021-12-07 Jonathan Bedard <jbedard@apple.com> 2 20 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r286458 r286630 765 765 952F7167270BD9CB00D00DCC /* CSSViewportUnits.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 952F7166270BD99700D00DCC /* CSSViewportUnits.html */; }; 766 766 952F7167270BD9CB00D00DCD /* CSSViewportUnits.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = 952F7166270BD99700D00DCD /* CSSViewportUnits.svg */; }; 767 95C52729275F35E100DA7E40 /* FontShadowTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C52728275F35E100DA7E40 /* FontShadowTests.cpp */; }; 767 768 996EDCCB270E70D7006DF175 /* InspectorExtension-basic-page.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 996EDCCA270E70AB006DF175 /* InspectorExtension-basic-page.html */; }; 768 769 9984FACE1CFFB090008D198C /* editable-body.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9984FACD1CFFB038008D198C /* editable-body.html */; }; … … 2516 2517 95A524942581A10D00461FE9 /* WKWebViewThemeColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewThemeColor.mm; sourceTree = "<group>"; }; 2517 2518 95B6B3B6251EBF2F00FC4382 /* MediaDocument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaDocument.mm; sourceTree = "<group>"; }; 2519 95C52728275F35E100DA7E40 /* FontShadowTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontShadowTests.cpp; sourceTree = "<group>"; }; 2518 2520 996EDCCA270E70AB006DF175 /* InspectorExtension-basic-page.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "InspectorExtension-basic-page.html"; sourceTree = "<group>"; }; 2519 2521 9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewTextInput.mm; sourceTree = "<group>"; }; … … 3686 3688 7A909A711D877475007E10F8 /* FloatRectTests.cpp */, 3687 3689 7A909A721D877475007E10F8 /* FloatSizeTests.cpp */, 3690 95C52728275F35E100DA7E40 /* FontShadowTests.cpp */, 3688 3691 8E4A85361E1D1AA100F53B0F /* GridPosition.cpp */, 3689 3692 83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */, … … 5475 5478 F456AB1C213EDBA300CB2CEF /* FontManagerTests.mm in Sources */, 5476 5479 1C81802725FB09E200608B3E /* FontRegistrySandboxCheck.mm in Sources */, 5480 95C52729275F35E100DA7E40 /* FontShadowTests.cpp in Sources */, 5477 5481 1CF59AE321E68932006E37EC /* ForceLightAppearanceInBundle.mm in Sources */, 5478 5482 7CCE7EF51A411AE600447C4C /* ForceRepaint.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.