Changeset 236445 in webkit
- Timestamp:
- Sep 24, 2018 5:17:29 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r236443 r236445 1 2018-09-24 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor Editor::fontAttributesForSelectionStart to be platform-agnostic 4 https://bugs.webkit.org/show_bug.cgi?id=189918 5 Work towards <rdar://problem/44648705> 6 7 Reviewed by Tim Horton. 8 9 Refactors the functionality in Editor::fontAttributesForSelectionStart to not be Cocoa-only. Rename this to 10 fontAttributesAtSelectionStart (to be consistent with `EditingStyle::styleAtSelectionStart`) and move it from 11 EditorCocoa.mm to Editor.cpp; instead of creating and populating an NSDictionary with font attribute 12 information, create and populate a new `FontAttributes` struct that contains the same information. Cocoa clients 13 in WebKitLegacy may then create an `NSDictionary` as needed from the `FontAttributes`. 14 15 * SourcesCocoa.txt: 16 * WebCore.xcodeproj/project.pbxproj: 17 * editing/Editor.cpp: 18 (WebCore::Editor::platformFontAttributesAtSelectionStart const): 19 20 Add a hook to allow platforms to supply additional information in FontAttributes. On Cocoa, this adds a UIFont 21 or NSFont to FontAttributes; otherwise, this is a no-op. 22 23 (WebCore::Editor::fontAttributesAtSelectionStart const): 24 * editing/Editor.h: 25 * editing/FontAttributeChanges.cpp: 26 (WebCore::cssValueListForShadow): 27 * editing/FontAttributeChanges.h: 28 (): Deleted. 29 (WebCore::FontShadow::encode const): Deleted. 30 (WebCore::FontShadow::decode): Deleted. 31 * editing/FontAttributes.h: Added. 32 33 Introduce a new struct that contains font attribute information. May be converted into an NSDictionary for use 34 by Cocoa clients in WebKitLegacy and WebKit. In a future patch, this will become serializable over IPC for use 35 in WebKit2. 36 37 * editing/FontShadow.h: Added. 38 39 Move FontShadow out into a separate header file, included in `FontAttributeChanges.h` and `FontAttributes.h`. 40 41 (WebCore::FontShadow::encode const): 42 (WebCore::FontShadow::decode): 43 * editing/cocoa/EditorCocoa.mm: 44 45 Add a helper function to convert a WebCore::Color to either `UIColor` on iOS or `NSColor` when AppKit is being 46 used. 47 48 (WebCore::Editor::platformFontAttributesAtSelectionStart const): 49 (WebCore::Editor::getTextDecorationAttributesRespectingTypingStyle const): Deleted. 50 51 Remove a helper function that was only used to compute text decoration attributes in 52 fontAttributesForSelectionStart. 53 54 (WebCore::Editor::fontAttributesForSelectionStart const): Deleted. 55 * editing/cocoa/FontAttributesCocoa.mm: Added. 56 (WebCore::FontAttributes::createDictionary const): 57 * editing/cocoa/FontShadowCocoa.mm: Added. 58 (WebCore::FontShadow::createShadow const): 59 * editing/cocoa/HTMLConverter.mm: 60 (_webKitBundle): 61 (HTMLConverter::_colorForElement): 62 (_platformColor): Deleted. 63 64 Adopt platformColor(). 65 66 * platform/graphics/cocoa/ColorCocoa.h: Added. 67 * platform/graphics/cocoa/ColorCocoa.mm: Added. 68 (WebCore::platformColor): 69 * platform/graphics/metal/GPURenderPassDescriptorMetal.mm: 70 71 Build fix due to changes in unified sources. 72 73 * platform/mac/WebCoreNSFontManagerExtras.mm: 74 (WebCore::computedFontAttributeChanges): 75 * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm: 76 * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm: 77 78 More build fixes due to changes in unified sources. 79 1 80 2018-09-24 Jer Noble <jer.noble@apple.com> 2 81 -
trunk/Source/WebCore/PAL/ChangeLog
r236366 r236445 1 2018-09-24 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor Editor::fontAttributesForSelectionStart to be platform-agnostic 4 https://bugs.webkit.org/show_bug.cgi?id=189918 5 Work towards <rdar://problem/44648705> 6 7 Reviewed by Tim Horton. 8 9 Add `+_disambiguated_due_to_CIImage_colorWithCGColor:` as a UIColor SPI definition. Also, import 10 `UIColor_Private.h` directly when the Apple internal SDK is used. 11 12 * pal/spi/ios/UIKitSPI.h: 13 1 14 2018-09-21 Jer Noble <jer.noble@apple.com> 2 15 -
trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h
r221187 r236445 28 28 #import <UIKit/UIApplicationSceneConstants.h> 29 29 #import <UIKit/UIApplication_Private.h> 30 #import <UIKit/UIColor_Private.h> 30 31 #import <UIKit/UIInterface_Private.h> 31 32 #import <UIKit/UIScreen_Private.h> … … 74 75 + (UIColor *)systemRedColor; 75 76 + (UIColor *)systemYellowColor; 77 78 + (UIColor *)_disambiguated_due_to_CIImage_colorWithCGColor:(CGColorRef)cgColor; 76 79 77 80 @end -
trunk/Source/WebCore/SourcesCocoa.txt
r236094 r236445 80 80 editing/cocoa/EditorCocoa.mm 81 81 editing/cocoa/FontAttributeChangesCocoa.mm 82 editing/cocoa/FontAttributesCocoa.mm 83 editing/cocoa/FontShadowCocoa.mm 82 84 editing/cocoa/HTMLConverter.mm @no-unify 83 85 editing/cocoa/WebArchiveResourceFromNSAttributedString.mm … … 294 296 platform/graphics/cg/UTIRegistry.cpp 295 297 298 platform/graphics/cocoa/ColorCocoa.mm 296 299 platform/graphics/cocoa/GraphicsContext3DCocoa.mm 297 300 platform/graphics/cocoa/GraphicsContextCocoa.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r236429 r236445 4844 4844 F48223111E3869B80066FC79 /* WebItemProviderPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F482230F1E3869B80066FC79 /* WebItemProviderPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4845 4845 F48223131E386E240066FC79 /* AbstractPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F48223121E386E240066FC79 /* AbstractPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4846 F48D2A6C215623B400C6752B /* FontShadow.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2A6A215623B400C6752B /* FontShadow.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4847 F48D2A7E2157182600C6752B /* FontAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2A712156DC0A00C6752B /* FontAttributes.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4848 F48D2AA52159740D00C6752B /* ColorCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2AA32159740D00C6752B /* ColorCocoa.h */; }; 4846 4849 F49786881FF45FA500E060AB /* PasteboardItemInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = F49786871FF45FA500E060AB /* PasteboardItemInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4847 4850 F4BFB9851E1DDF9B00862C24 /* DumpEditingHistory.js in Copy Scripts */ = {isa = PBXBuildFile; fileRef = F48389831E1DDF2B0076B7EA /* DumpEditingHistory.js */; }; … … 14584 14587 F48389831E1DDF2B0076B7EA /* DumpEditingHistory.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = DumpEditingHistory.js; path = Scripts/DumpEditingHistory.js; sourceTree = "<group>"; }; 14585 14588 F48389841E1DDF2B0076B7EA /* EditingHistoryUtil.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = EditingHistoryUtil.js; path = Scripts/EditingHistoryUtil.js; sourceTree = "<group>"; }; 14589 F48D2A6A215623B400C6752B /* FontShadow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontShadow.h; sourceTree = "<group>"; }; 14590 F48D2A712156DC0A00C6752B /* FontAttributes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontAttributes.h; sourceTree = "<group>"; }; 14591 F48D2A752156FE5700C6752B /* FontAttributesCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontAttributesCocoa.mm; sourceTree = "<group>"; }; 14592 F48D2A7A2157051E00C6752B /* FontShadowCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontShadowCocoa.mm; sourceTree = "<group>"; }; 14593 F48D2AA32159740D00C6752B /* ColorCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorCocoa.h; sourceTree = "<group>"; }; 14594 F48D2AA42159740D00C6752B /* ColorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ColorCocoa.mm; sourceTree = "<group>"; }; 14586 14595 F49786871FF45FA500E060AB /* PasteboardItemInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardItemInfo.h; sourceTree = "<group>"; }; 14587 14596 F4E57EDA213F3F5F004EA98E /* FontAttributeChanges.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontAttributeChanges.h; sourceTree = "<group>"; }; … … 19942 19951 9B55EEE81B3E8898005342BC /* EditorCocoa.mm */, 19943 19952 F42CEB54214031EE002DCA72 /* FontAttributeChangesCocoa.mm */, 19953 F48D2A752156FE5700C6752B /* FontAttributesCocoa.mm */, 19954 F48D2A7A2157051E00C6752B /* FontShadowCocoa.mm */, 19944 19955 7C3E510818DF8F3500C112F7 /* HTMLConverter.h */, 19945 19956 7C3E510918DF8F3500C112F7 /* HTMLConverter.mm */, … … 20246 20257 F442850B2140412500CCDA22 /* FontAttributeChanges.cpp */, 20247 20258 F4E57EDA213F3F5F004EA98E /* FontAttributeChanges.h */, 20259 F48D2A712156DC0A00C6752B /* FontAttributes.h */, 20260 F48D2A6A215623B400C6752B /* FontShadow.h */, 20248 20261 D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */, 20249 20262 D05CED280A40BB2C00C5AF38 /* FormatBlockCommand.h */, … … 23946 23959 isa = PBXGroup; 23947 23960 children = ( 23961 F48D2AA32159740D00C6752B /* ColorCocoa.h */, 23962 F48D2AA42159740D00C6752B /* ColorCocoa.mm */, 23948 23963 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */, 23949 23964 C2458E611FE8979E00594759 /* FontCacheCoreText.h */, … … 27467 27482 C330A22313EC196B0000B45B /* ColorChooser.h in Headers */, 27468 27483 C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */, 27484 F48D2AA52159740D00C6752B /* ColorCocoa.h in Headers */, 27469 27485 3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */, 27470 27486 F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */, … … 28065 28081 1AC2D89D1B1E291F00D52E87 /* FontAntialiasingStateSaver.h in Headers */, 28066 28082 F4E57EDC213F3F5F004EA98E /* FontAttributeChanges.h in Headers */, 28083 F48D2A7E2157182600C6752B /* FontAttributes.h in Headers */, 28067 28084 BCB92D4F1293550B00C8387F /* FontBaseline.h in Headers */, 28068 28085 B2C3DA630D006CD600EF6F26 /* FontCache.h in Headers */, … … 28081 28098 B2C3DA6B0D006CD600EF6F26 /* FontSelector.h in Headers */, 28082 28099 E419041F1CC6486B00C35F5D /* FontSelectorClient.h in Headers */, 28100 F48D2A6C215623B400C6752B /* FontShadow.h in Headers */, 28083 28101 4A6E9FC813C17D570046A7F8 /* FontTaggedSettings.h in Headers */, 28084 28102 C2015C0A1BE6FEB200822389 /* FontVariantBuilder.h in Headers */, -
trunk/Source/WebCore/editing/Editor.cpp
r235955 r236445 49 49 #include "File.h" 50 50 #include "FocusController.h" 51 #include "FontAttributes.h" 51 52 #include "Frame.h" 52 53 #include "FrameLoader.h" … … 3852 3853 } 3853 3854 3855 #if !PLATFORM(COCOA) 3856 3857 void Editor::platformFontAttributesAtSelectionStart(FontAttributes&, const RenderStyle&) const 3858 { 3859 } 3860 3861 #endif 3862 3863 FontAttributes Editor::fontAttributesAtSelectionStart() const 3864 { 3865 FontAttributes attributes; 3866 Node* nodeToRemove = nullptr; 3867 auto* style = styleForSelectionStart(&m_frame, nodeToRemove); 3868 if (!style) { 3869 if (nodeToRemove) 3870 nodeToRemove->remove(); 3871 return attributes; 3872 } 3873 3874 platformFontAttributesAtSelectionStart(attributes, *style); 3875 3876 // FIXME: for now, always report the colors after applying -apple-color-filter. In future not all clients 3877 // may want this, so we may have to add a setting to control it. See also editingAttributedStringFromRange(). 3878 auto backgroundColor = style->visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor); 3879 if (backgroundColor.isVisible()) 3880 attributes.backgroundColor = backgroundColor; 3881 3882 auto foregroundColor = style->visitedDependentColorWithColorFilter(CSSPropertyColor); 3883 // FIXME: isBlackColor not suitable for dark mode. 3884 if (foregroundColor.isValid() && !Color::isBlackColor(foregroundColor)) 3885 attributes.foregroundColor = foregroundColor; 3886 3887 if (auto* shadowData = style->textShadow()) 3888 attributes.fontShadow = { shadowData->color(), { static_cast<float>(shadowData->x()), static_cast<float>(shadowData->y()) }, static_cast<double>(shadowData->radius()) }; 3889 3890 switch (style->verticalAlign()) { 3891 case VerticalAlign::Baseline: 3892 case VerticalAlign::Bottom: 3893 case VerticalAlign::BaselineMiddle: 3894 case VerticalAlign::Length: 3895 case VerticalAlign::Middle: 3896 case VerticalAlign::TextBottom: 3897 case VerticalAlign::TextTop: 3898 case VerticalAlign::Top: 3899 break; 3900 case VerticalAlign::Sub: 3901 attributes.subscriptOrSuperscript = SubscriptOrSuperscript::Subscript; 3902 break; 3903 case VerticalAlign::Super: 3904 attributes.subscriptOrSuperscript = SubscriptOrSuperscript::Superscript; 3905 break; 3906 } 3907 3908 auto typingStyle = makeRefPtr(m_frame.selection().typingStyle()); 3909 if (typingStyle && typingStyle->style()) { 3910 auto value = typingStyle->style()->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); 3911 if (value && value->isValueList()) { 3912 CSSValueList& valueList = downcast<CSSValueList>(*value); 3913 if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueLineThrough).ptr())) 3914 attributes.hasStrikeThrough = true; 3915 if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueUnderline).ptr())) 3916 attributes.hasUnderline = true; 3917 } 3918 } else { 3919 auto decoration = style->textDecorationsInEffect(); 3920 if (decoration & TextDecoration::LineThrough) 3921 attributes.hasStrikeThrough = true; 3922 if (decoration & TextDecoration::Underline) 3923 attributes.hasUnderline = true; 3924 } 3925 3926 if (nodeToRemove) 3927 nodeToRemove->remove(); 3928 3929 return attributes; 3930 } 3931 3854 3932 #if ENABLE(ATTACHMENT_ELEMENT) 3855 3933 -
trunk/Source/WebCore/editing/Editor.h
r235955 r236445 82 82 class TextEvent; 83 83 84 struct FontAttributes; 84 85 struct PasteboardPlainText; 85 86 struct PasteboardURL; … … 470 471 WEBCORE_EXPORT const Font* fontForSelection(bool& hasMultipleFonts) const; 471 472 WEBCORE_EXPORT static const RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove); 473 WEBCORE_EXPORT FontAttributes fontAttributesAtSelectionStart() const; 472 474 473 475 #if PLATFORM(COCOA) 474 void getTextDecorationAttributesRespectingTypingStyle(const RenderStyle&, NSMutableDictionary*) const;475 WEBCORE_EXPORT RetainPtr<NSDictionary> fontAttributesForSelectionStart() const;476 476 WEBCORE_EXPORT String stringSelectionForPasteboard(); 477 477 String stringSelectionForPasteboardWithImageAltText(); … … 563 563 static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *); 564 564 #endif 565 void platformFontAttributesAtSelectionStart(FontAttributes&, const RenderStyle&) const; 565 566 566 567 void scheduleEditorUIUpdate(); -
trunk/Source/WebCore/editing/FontAttributeChanges.cpp
r235914 r236445 82 82 static RefPtr<CSSValueList> cssValueListForShadow(const FontShadow& shadow) 83 83 { 84 if ( !shadow.width && !shadow.height&& !shadow.blurRadius)84 if (shadow.offset.isEmpty() && !shadow.blurRadius) 85 85 return nullptr; 86 86 87 87 auto list = CSSValueList::createCommaSeparated(); 88 88 auto& cssValuePool = CSSValuePool::singleton(); 89 auto width = cssValuePool.createValue(shadow. width, CSSPrimitiveValue::CSS_PX);90 auto height = cssValuePool.createValue(shadow. height, CSSPrimitiveValue::CSS_PX);89 auto width = cssValuePool.createValue(shadow.offset.width(), CSSPrimitiveValue::CSS_PX); 90 auto height = cssValuePool.createValue(shadow.offset.height(), CSSPrimitiveValue::CSS_PX); 91 91 auto blurRadius = cssValuePool.createValue(shadow.blurRadius, CSSPrimitiveValue::CSS_PX); 92 92 auto color = cssValuePool.createValue(shadow.color); -
trunk/Source/WebCore/editing/FontAttributeChanges.h
r235914 r236445 27 27 28 28 #include "Color.h" 29 #include "FontShadow.h" 29 30 #include <wtf/EnumTraits.h> 30 31 #include <wtf/Forward.h> … … 68 69 std::optional<bool> m_bold; 69 70 std::optional<bool> m_italic; 70 };71 72 struct FontShadow {73 template<class Encoder> void encode(Encoder&) const;74 template<class Decoder> static bool decode(Decoder&, FontShadow&);75 76 Color color;77 double width { 0 };78 double height { 0 };79 double blurRadius { 0 };80 71 }; 81 72 … … 139 130 140 131 template<class Encoder> 141 void FontShadow::encode(Encoder& encoder) const142 {143 encoder << color << width << height << blurRadius;144 }145 146 template<class Decoder>147 bool FontShadow::decode(Decoder& decoder, FontShadow& shadow)148 {149 if (!decoder.decode(shadow.color))150 return false;151 152 if (!decoder.decode(shadow.width))153 return false;154 155 if (!decoder.decode(shadow.height))156 return false;157 158 if (!decoder.decode(shadow.blurRadius))159 return false;160 161 return true;162 }163 164 template<class Encoder>165 132 void FontAttributeChanges::encode(Encoder& encoder) const 166 133 { -
trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm
r235955 r236445 37 37 #import "EditingStyle.h" 38 38 #import "EditorClient.h" 39 #import "FontAttributes.h" 39 40 #import "FontCascade.h" 40 41 #import "Frame.h" … … 59 60 namespace WebCore { 60 61 61 void Editor::getTextDecorationAttributesRespectingTypingStyle(const RenderStyle& style, NSMutableDictionary* result) const 62 { 63 RefPtr<EditingStyle> typingStyle = m_frame.selection().typingStyle(); 64 if (typingStyle && typingStyle->style()) { 65 RefPtr<CSSValue> value = typingStyle->style()->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); 66 if (value && value->isValueList()) { 67 CSSValueList& valueList = downcast<CSSValueList>(*value); 68 if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueLineThrough).ptr())) 69 [result setObject:@(NSUnderlineStyleSingle) forKey:NSStrikethroughStyleAttributeName]; 70 if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueUnderline).ptr())) 71 [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName]; 72 } 73 } else { 74 auto decoration = style.textDecorationsInEffect(); 75 if (decoration & TextDecoration::LineThrough) 76 [result setObject:@(NSUnderlineStyleSingle) forKey:NSStrikethroughStyleAttributeName]; 77 if (decoration & TextDecoration::Underline) 78 [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName]; 79 } 80 } 81 82 RetainPtr<NSDictionary> Editor::fontAttributesForSelectionStart() const 83 { 84 Node* nodeToRemove; 85 auto* style = styleForSelectionStart(&m_frame, nodeToRemove); 86 if (!style) 87 return nil; 88 89 RetainPtr<NSMutableDictionary> attributes = adoptNS([[NSMutableDictionary alloc] init]); 90 91 if (auto ctFont = style->fontCascade().primaryFont().getCTFont()) 92 [attributes setObject:(__bridge id)ctFont forKey:NSFontAttributeName]; 93 94 // FIXME: Why would we not want to retrieve these attributes on iOS? 95 #if PLATFORM(MAC) 96 // FIXME: for now, always report the colors after applying -apple-color-filter. In future not all clients 97 // may want this, so we may have to add a setting to control it. See also editingAttributedStringFromRange(). 98 Color backgroundColor = style->visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor); 99 if (backgroundColor.isVisible()) 100 [attributes setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName]; 101 102 Color foregroundColor = style->visitedDependentColorWithColorFilter(CSSPropertyColor); 103 // FIXME: isBlackColor not suitable for dark mode. 104 if (foregroundColor.isValid() && !Color::isBlackColor(foregroundColor)) 105 [attributes setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName]; 106 107 const ShadowData* shadowData = style->textShadow(); 108 if (shadowData) { 109 RetainPtr<NSShadow> platformShadow = adoptNS([[NSShadow alloc] init]); 110 [platformShadow setShadowOffset:NSMakeSize(shadowData->x(), shadowData->y())]; 111 [platformShadow setShadowBlurRadius:shadowData->radius()]; 112 [platformShadow setShadowColor:nsColor(shadowData->color())]; 113 [attributes setObject:platformShadow.get() forKey:NSShadowAttributeName]; 114 } 115 116 int superscriptInt = 0; 117 switch (style->verticalAlign()) { 118 case VerticalAlign::Baseline: 119 case VerticalAlign::Bottom: 120 case VerticalAlign::BaselineMiddle: 121 case VerticalAlign::Length: 122 case VerticalAlign::Middle: 123 case VerticalAlign::TextBottom: 124 case VerticalAlign::TextTop: 125 case VerticalAlign::Top: 126 break; 127 case VerticalAlign::Sub: 128 superscriptInt = -1; 129 break; 130 case VerticalAlign::Super: 131 superscriptInt = 1; 132 break; 133 } 134 if (superscriptInt) 135 [attributes setObject:@(superscriptInt) forKey:NSSuperscriptAttributeName]; 136 #endif 137 138 getTextDecorationAttributesRespectingTypingStyle(*style, attributes.get()); 139 140 if (nodeToRemove) 141 nodeToRemove->remove(); 142 143 return attributes; 62 void Editor::platformFontAttributesAtSelectionStart(FontAttributes& attributes, const RenderStyle& style) const 63 { 64 if (auto ctFont = style.fontCascade().primaryFont().getCTFont()) 65 attributes.font = (__bridge id)ctFont; 144 66 } 145 67 -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r234348 r236445 33 33 #import "CachedImage.h" 34 34 #import "CharacterData.h" 35 #import "ColorCocoa.h" 35 36 #import "ColorMac.h" 36 37 #import "Document.h" … … 206 207 + (UIColor *)clearColor; 207 208 - (CGFloat)alphaComponent; 208 + (UIColor *)_disambiguated_due_to_CIImage_colorWithCGColor:(CGColorRef)cgColor;209 209 @end 210 210 … … 864 864 return bundle; 865 865 } 866 867 static inline UIColor *_platformColor(Color color)868 {869 return [getUIColorClass() _disambiguated_due_to_CIImage_colorWithCGColor:cachedCGColor(color)];870 }871 #else872 static inline NSColor *_platformColor(Color color)873 {874 return nsColor(color);875 }876 866 #endif 877 867 … … 1021 1011 if (!result.isValid()) 1022 1012 return nil; 1023 PlatformColor *platformResult = _platformColor(result);1013 PlatformColor *platformResult = platformColor(result); 1024 1014 if ([[PlatformColorClass clearColor] isEqual:platformResult] || ([platformResult alphaComponent] == 0.0)) 1025 1015 return nil; -
trunk/Source/WebCore/platform/graphics/metal/GPURenderPassDescriptorMetal.mm
r234258 r236445 33 33 #import "Logging.h" 34 34 #import <Metal/Metal.h> 35 #import <wtf/Vector.h> 35 36 36 37 namespace WebCore { -
trunk/Source/WebCore/platform/mac/WebCoreNSFontManagerExtras.mm
r235769 r236445 137 137 NSShadow *convertedShadow = [convertedAttributesA objectForKey:NSShadowAttributeName]; 138 138 if (convertedShadow) { 139 auto offset = convertedShadow.shadowOffset;140 changes.setShadow({ colorFromNSColor(convertedShadow.shadowColor ?: NSColor.blackColor), offset .width, offset.height, convertedShadow.shadowBlurRadius });139 FloatSize offset { static_cast<float>(convertedShadow.shadowOffset.width), static_cast<float>(convertedShadow.shadowOffset.height) }; 140 changes.setShadow({ colorFromNSColor(convertedShadow.shadowColor ?: NSColor.blackColor), offset, convertedShadow.shadowBlurRadius }); 141 141 } else if (![convertedAttributesB objectForKey:NSShadowAttributeName]) 142 142 changes.setShadow({ }); -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h
r236423 r236445 33 33 34 34 using CMSampleBufferRef = struct opaqueCMSampleBuffer*; 35 using CVPixelBufferPoolRef = struct __CVPixelBufferPool*; 35 36 using CVPixelBufferRef = struct __CVBuffer*; 36 37 -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm
r236423 r236445 33 33 #include "Logging.h" 34 34 #include "MediaSampleAVFObjC.h" 35 #include "RealtimeVideoUtilities.h" 35 36 #include <pal/cf/CoreMediaSoftLink.h> 36 37 -
trunk/Source/WebKitLegacy/mac/ChangeLog
r236066 r236445 1 2018-09-24 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor Editor::fontAttributesForSelectionStart to be platform-agnostic 4 https://bugs.webkit.org/show_bug.cgi?id=189918 5 Work towards <rdar://problem/44648705> 6 7 Reviewed by Tim Horton. 8 9 Replace call sites of fontAttributesForSelectionStart() to fontAttributesAtSelectionStart().createDictionary(). 10 11 * WebView/WebHTMLView.mm: 12 (-[WebHTMLView _selectionStartFontAttributesAsRTF]): 13 (-[WebHTMLView _updateFontPanel]): 14 * WebView/WebView.mm: 15 (-[WebView typingAttributes]): 16 1 17 2018-09-17 Darin Adler <darin@apple.com> 2 18 -
trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
r235935 r236445 97 97 #import <WebCore/Font.h> 98 98 #import <WebCore/FontAttributeChanges.h> 99 #import <WebCore/FontAttributes.h> 99 100 #import <WebCore/FontCache.h> 100 101 #import <WebCore/Frame.h> … … 5058 5059 Frame* coreFrame = core([self _frame]); 5059 5060 auto string = adoptNS([[NSAttributedString alloc] initWithString:@"x" 5060 attributes:coreFrame ? coreFrame->editor().fontAttributes ForSelectionStart().get() : nil]);5061 attributes:coreFrame ? coreFrame->editor().fontAttributesAtSelectionStart().createDictionary().get() : nil]); 5061 5062 return [string RTFFromRange:NSMakeRange(0, [string length]) documentAttributes:@{ }]; 5062 5063 } … … 5705 5706 if (const Font* fd = coreFrame->editor().fontForSelection(multipleFonts)) 5706 5707 font = (NSFont *)fd->platformData().registeredFont(); 5707 attributes = coreFrame->editor().fontAttributes ForSelectionStart();5708 attributes = coreFrame->editor().fontAttributesAtSelectionStart().createDictionary(); 5708 5709 } 5709 5710 -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r235935 r236445 145 145 #import <WebCore/FileSystem.h> 146 146 #import <WebCore/FocusController.h> 147 #import <WebCore/FontAttributes.h> 147 148 #import <WebCore/FontCache.h> 148 149 #import <WebCore/Frame.h> … … 8624 8625 - (NSDictionary *)typingAttributes 8625 8626 { 8626 Frame* coreFrame = core([self _selectedOrMainFrame]); 8627 if (coreFrame) 8628 return coreFrame->editor().fontAttributesForSelectionStart().autorelease(); 8627 if (auto* coreFrame = core([self _selectedOrMainFrame])) 8628 return coreFrame->editor().fontAttributesAtSelectionStart().createDictionary().autorelease(); 8629 8629 8630 8630 return nil;
Note: See TracChangeset
for help on using the changeset viewer.