Changeset 251086 in webkit
- Timestamp:
- Oct 14, 2019 12:42:50 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r251084 r251086 1 2019-10-14 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] REGRESSION (r245672): Contenteditable with optical sizing freezes Safari 4 https://bugs.webkit.org/show_bug.cgi?id=202262 5 6 Reviewed by Tim Horton. 7 8 * fast/forms/contenteditable-font-optical-size-expected.txt: Added. 9 * fast/forms/contenteditable-font-optical-size.html: Added. 10 1 11 2019-10-14 Russell Epstein <russell_e@apple.com> 2 12 -
trunk/Source/WebKit/ChangeLog
r251074 r251086 1 2019-10-14 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] REGRESSION (r245672): Contenteditable with optical sizing freezes Safari 4 https://bugs.webkit.org/show_bug.cgi?id=202262 5 6 Reviewed by Tim Horton. 7 8 r250640 didn't go far enough. We need to apply the same fix everywhere [NSFontDescriptor fontDescriptorWithFontAttributes:] is called. 9 10 * Shared/Cocoa/ArgumentCodersCocoa.mm: 11 (IPC::decodeFontInternal): 12 * Shared/Cocoa/CoreTextHelpers.h: Added. 13 * Shared/Cocoa/CoreTextHelpers.mm: Added. 14 (fontDescriptorWithFontAttributes): 15 * SourcesCocoa.txt: 16 * UIProcess/Cocoa/WebViewImpl.mm: 17 (WebKit::WebViewImpl::updateFontManagerIfNeeded): 18 * UIProcess/mac/WebPopupMenuProxyMac.mm: 19 (WebKit::WebPopupMenuProxyMac::showPopupMenu): 20 * WebKit.xcodeproj/project.pbxproj: 21 1 22 2019-10-14 Truitt Savell <tsavell@apple.com> 2 23 -
trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm
r246726 r251086 30 30 31 31 #import "ArgumentCodersCF.h" 32 #import "CoreTextHelpers.h" 32 33 #import <CoreText/CTFont.h> 33 34 #import <CoreText/CTFontDescriptor.h> 34 35 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> 36 #import <wtf/BlockObjCExceptions.h> 35 37 #import <wtf/HashSet.h> 36 38 … … 329 331 return WTF::nullopt; 330 332 331 PlatformFontDescriptor *fontDescriptor = [PlatformFontDescriptor fontDescriptorWithFontAttributes:fontAttributes.get()]; 333 BEGIN_BLOCK_OBJC_EXCEPTIONS; 334 335 PlatformFontDescriptor *fontDescriptor = WebKit::fontDescriptorWithFontAttributes(fontAttributes.get()); 332 336 return { [PlatformFont fontWithDescriptor:fontDescriptor size:0] }; 337 338 END_BLOCK_OBJC_EXCEPTIONS 339 340 return { }; 333 341 } 334 342 -
trunk/Source/WebKit/Shared/Cocoa/CoreTextHelpers.h
r251085 r251086 1 1 /* 2 * Copyright (C) 201 9 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2019 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 #import "config.h" 27 #import "WebAutocorrectionData.h" 26 #pragma once 28 27 29 #if PLATFORM(IOS_FAMILY) 28 #if USE(APPKIT) 29 #import <AppKit/AppKit.h> 30 #else 31 #import <UIKit/UIKit.h> 32 #endif 30 33 31 #import "ArgumentCodersCocoa.h" 32 #import "Decoder.h" 33 #import "Encoder.h" 34 #import "WebCoreArgumentCoders.h" 35 #import <WebCore/FloatRect.h> 34 #import <wtf/RetainPtr.h> 36 35 37 36 namespace WebKit { 38 using namespace WebCore;39 37 40 void WebAutocorrectionData::encode(IPC::Encoder& encoder) const 41 { 42 encoder << textRects; 43 IPC::encode(encoder, font.get()); 38 #if USE(APPKIT) 39 using PlatformFontDescriptor = NSFontDescriptor; 40 #else 41 using PlatformFontDescriptor = UIFontDescriptor; 42 #endif 43 44 PlatformFontDescriptor *fontDescriptorWithFontAttributes(NSDictionary *attributes); 45 44 46 } 45 46 Optional<WebAutocorrectionData> WebAutocorrectionData::decode(IPC::Decoder& decoder)47 {48 Optional<Vector<FloatRect>> textRects;49 decoder >> textRects;50 if (!textRects)51 return WTF::nullopt;52 53 RetainPtr<UIFont> font;54 if (!IPC::decode(decoder, font, @[ UIFont.class ]))55 return WTF::nullopt;56 57 return {{ *textRects, font }};58 }59 60 } // namespace WebKit61 62 #endif // PLATFORM(IOS_FAMILY) -
trunk/Source/WebKit/Shared/Cocoa/CoreTextHelpers.mm
r251085 r251086 25 25 26 26 #import "config.h" 27 #import " WebAutocorrectionData.h"27 #import "CoreTextHelpers.h" 28 28 29 #if PLATFORM(IOS_FAMILY) 30 31 #import "ArgumentCodersCocoa.h" 32 #import "Decoder.h" 33 #import "Encoder.h" 34 #import "WebCoreArgumentCoders.h" 35 #import <WebCore/FloatRect.h> 29 #import <pal/spi/cocoa/CoreTextSPI.h> 30 #import <wtf/BlockObjCExceptions.h> 36 31 37 32 namespace WebKit { 38 using namespace WebCore;39 33 40 void WebAutocorrectionData::encode(IPC::Encoder& encoder) const 34 PlatformFontDescriptor *fontDescriptorWithFontAttributes(NSDictionary *attributes) 41 35 { 42 encoder << textRects; 43 IPC::encode(encoder, font.get()); 36 BEGIN_BLOCK_OBJC_EXCEPTIONS; 37 38 #if HAVE(NSFONT_WITH_OPTICAL_SIZING_BUG) 39 auto mutableDictionary = adoptNS([attributes mutableCopy]); 40 if (id opticalSizeAttribute = [mutableDictionary objectForKey:(__bridge NSString *)kCTFontOpticalSizeAttribute]) { 41 if ([opticalSizeAttribute isKindOfClass:[NSString class]]) { 42 [mutableDictionary removeObjectForKey:(__bridge NSString *)kCTFontOpticalSizeAttribute]; 43 if (NSNumber *size = [mutableDictionary objectForKey:(__bridge NSString *)kCTFontSizeAttribute]) 44 [mutableDictionary setObject:size forKey:(__bridge NSString *)kCTFontOpticalSizeAttribute]; 45 } 46 } 47 return [PlatformFontDescriptor fontDescriptorWithFontAttributes:mutableDictionary.get()]; 48 #else 49 return [PlatformFontDescriptor fontDescriptorWithFontAttributes:attributes]; 50 #endif 51 52 END_BLOCK_OBJC_EXCEPTIONS 53 54 return nil; 44 55 } 45 56 46 Optional<WebAutocorrectionData> WebAutocorrectionData::decode(IPC::Decoder& decoder)47 {48 Optional<Vector<FloatRect>> textRects;49 decoder >> textRects;50 if (!textRects)51 return WTF::nullopt;52 53 RetainPtr<UIFont> font;54 if (!IPC::decode(decoder, font, @[ UIFont.class ]))55 return WTF::nullopt;56 57 return {{ *textRects, font }};58 57 } 59 60 } // namespace WebKit61 62 #endif // PLATFORM(IOS_FAMILY) -
trunk/Source/WebKit/Shared/ios/WebAutocorrectionData.mm
r245998 r251086 33 33 #import "Encoder.h" 34 34 #import "WebCoreArgumentCoders.h" 35 #import <UIKit/UIKit.h> 35 36 #import <WebCore/FloatRect.h> 36 37 -
trunk/Source/WebKit/SourcesCocoa.txt
r250729 r251086 143 143 Shared/Cocoa/AuxiliaryProcessCocoa.mm 144 144 Shared/Cocoa/CompletionHandlerCallChecker.mm 145 Shared/Cocoa/CoreTextHelpers.mm 145 146 Shared/Cocoa/DataDetectionResult.mm 146 147 Shared/Cocoa/InsertTextOptions.cpp -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r250973 r251086 35 35 #import "AttributedString.h" 36 36 #import "ColorSpaceData.h" 37 #import "CoreTextHelpers.h" 37 38 #import "FontInfo.h" 38 39 #import "FullscreenClient.h" … … 118 119 #import <pal/spi/mac/NSWindowSPI.h> 119 120 #import <sys/stat.h> 121 #import <wtf/BlockObjCExceptions.h> 120 122 #import <wtf/FileSystem.h> 121 123 #import <wtf/NeverDestroyed.h> … … 1120 1122 ASSERT_NOT_REACHED(); 1121 1123 } 1122 1124 1123 1125 return nsTextAlignment; 1124 1126 } … … 1600 1602 1601 1603 m_page->activityStateDidChange(WebCore::ActivityState::IsFocused); 1602 1604 1603 1605 m_inResignFirstResponder = false; 1604 1606 1605 1607 return true; 1606 1608 } … … 1749 1751 accessibilityPosition = [[weakThis->m_view accessibilityAttributeValue:NSAccessibilityPositionAttribute] pointValue]; 1750 1752 ALLOW_DEPRECATED_DECLARATIONS_END 1751 1753 1752 1754 weakThis->m_page->windowAndViewFramesChanged(viewFrameInWindowCoordinates, accessibilityPosition); 1753 1755 }); … … 2322 2324 ColorSpaceData colorSpaceData; 2323 2325 colorSpaceData.cgColorSpace = [m_colorSpace CGColorSpace]; 2324 2326 2325 2327 return colorSpaceData; 2326 2328 } … … 2569 2571 [[WKTextInputWindowController sharedTextInputWindowController] unmarkText]; 2570 2572 } 2571 2573 2572 2574 // This will force the current input context to be updated to its correct value. 2573 2575 [NSApp updateWindows]; … … 2819 2821 if (_shareSheet) 2820 2822 [_shareSheet dismiss]; 2821 2823 2822 2824 ASSERT([view respondsToSelector:@selector(shareSheetDidDismiss:)]); 2823 2825 _shareSheet = adoptNS([[WKShareSheet alloc] initWithView:view]); 2824 2826 [_shareSheet setDelegate:view]; 2825 2827 2826 2828 [_shareSheet presentWithParameters:data inRect:WTF::nullopt completionHandler:WTFMove(completionHandler)]; 2827 2829 } 2828 2830 2829 2831 void WebViewImpl::shareSheetDidDismiss(WKShareSheet *shareSheet) 2830 2832 { 2831 2833 ASSERT(_shareSheet == shareSheet); 2832 2834 2833 2835 [_shareSheet setDelegate:nil]; 2834 2836 _shareSheet = nil; … … 2854 2856 return; 2855 2857 2858 BEGIN_BLOCK_OBJC_EXCEPTIONS; 2859 2856 2860 NSDictionary *attributeDictionary = (__bridge NSDictionary *)fontInfo.fontAttributeDictionary.get(); 2857 2861 if (!attributeDictionary) 2858 2862 return; 2859 2863 2860 NSFontDescriptor *descriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:attributeDictionary];2864 PlatformFontDescriptor *descriptor = fontDescriptorWithFontAttributes(attributeDictionary); 2861 2865 if (!descriptor) 2862 2866 return; … … 2867 2871 2868 2872 [NSFontManager.sharedFontManager setSelectedFont:font isMultiple:selectionHasMultipleFonts]; 2873 2874 END_BLOCK_OBJC_EXCEPTIONS 2869 2875 }); 2870 2876 } … … 3239 3245 if (static_cast<bool>(flag) == TextChecker::state().isAutomaticTextReplacementEnabled) 3240 3246 return; 3241 3247 3242 3248 TextChecker::setAutomaticTextReplacementEnabled(flag); 3243 3249 m_page->process().updateTextCheckerState(); … … 3662 3668 if ([attribute isEqualToString:NSAccessibilityEnabledAttribute]) 3663 3669 return @YES; 3664 3670 3665 3671 if ([attribute isEqualToString:@"AXConvertRelativeFrame"]) { 3666 3672 if ([parameter isKindOfClass:[NSValue class]]) { … … 3669 3675 } 3670 3676 } 3671 3677 3672 3678 return [m_view _web_superAccessibilityAttributeValue:attribute]; 3673 3679 } … … 3781 3787 if (!oldToolTip.isNull()) 3782 3788 sendToolTipMouseExited(); 3783 3789 3784 3790 if (!newToolTip.isEmpty()) { 3785 3791 // See radar 3500217 for why we remove all tooltips rather than just the single one we created. … … 3972 3978 3973 3979 if (![types containsObject:PasteboardTypes::WebArchivePboardType] && [types containsObject:WebCore::legacyFilesPromisePasteboardType()]) { 3974 3980 3975 3981 // FIXME: legacyFilesPromisePasteboardType() contains UTIs, not path names. Also, it's not 3976 3982 // guaranteed that the count of UTIs equals the count of files, since some clients only write … … 4026 4032 return false; 4027 4033 } 4028 4034 4029 4035 Vector<String> fileNames; 4030 4036 4031 4037 for (NSString *file in files) 4032 4038 fileNames.append(file); … … 4249 4255 NSString *filename = filenameByFixingIllegalCharacters([path lastPathComponent]); 4250 4256 path = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:filename]; 4251 4257 4252 4258 if (fileExists(path)) { 4253 4259 // Don't overwrite existing file by appending "-n", "-n.ext" or "-n.ext.ext" to the filename. … … 4256 4262 NSString *lastPathComponent = [path lastPathComponent]; 4257 4263 NSRange periodRange = [lastPathComponent rangeOfString:@"."]; 4258 4264 4259 4265 if (periodRange.location == NSNotFound) { 4260 4266 pathWithoutExtensions = path; … … 4264 4270 pathWithoutExtensions = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:lastPathComponent]; 4265 4271 } 4266 4272 4267 4273 for (unsigned i = 1; ; i++) { 4268 4274 NSString *pathWithAppendedNumber = [NSString stringWithFormat:@"%@-%d", pathWithoutExtensions, i]; … … 4272 4278 } 4273 4279 } 4274 4280 4275 4281 return path; 4276 4282 } … … 4280 4286 RetainPtr<NSFileWrapper> wrapper; 4281 4287 RetainPtr<NSData> data; 4282 4288 4283 4289 if (m_promisedImage) { 4284 4290 data = m_promisedImage->data()->createNSData(); … … 4286 4292 } else 4287 4293 wrapper = adoptNS([[NSFileWrapper alloc] initWithURL:[NSURL URLWithString:m_promisedURL] options:NSFileWrapperReadingImmediate error:nil]); 4288 4294 4289 4295 if (wrapper) 4290 4296 [wrapper setPreferredFilename:m_promisedFilename]; … … 4293 4299 return nil; 4294 4300 } 4295 4301 4296 4302 // FIXME: Report an error if we fail to create a file. 4297 4303 NSString *path = [[dropDestination path] stringByAppendingPathComponent:[wrapper preferredFilename]]; … … 4302 4308 if (!m_promisedURL.isEmpty()) 4303 4309 FileSystem::setMetadataURL(String(path), m_promisedURL); 4304 4310 4305 4311 return [NSArray arrayWithObject:[path lastPathComponent]]; 4306 4312 } … … 4499 4505 4500 4506 gestureController.setShouldIgnorePinnedState(wasIgnoringPinnedState); 4501 4507 4502 4508 return handledEvent; 4503 4509 } … … 4642 4648 [NSApp _setCurrentEvent:event]; 4643 4649 [NSApp sendEvent:event]; 4644 4650 4645 4651 m_keyDownEventBeingResent = nullptr; 4646 4652 } … … 4687 4693 result.append(WebCore::CompositionUnderline(range.location, NSMaxRange(range), compositionUnderlineColor, color, style.intValue > 1)); 4688 4694 } 4689 4695 4690 4696 i = range.location + range.length; 4691 4697 } … … 5107 5113 return YES; 5108 5114 } 5109 5115 5110 5116 return [m_view _web_superPerformKeyEquivalent:event]; 5111 5117 } … … 5317 5323 NSRect eventScreenPosition = [[m_view window] convertRectToScreen:NSMakeRect(event.locationInWindow.x, event.locationInWindow.y, 0, 0)]; 5318 5324 NSInteger eventWindowNumber = [NSWindow windowNumberAtPoint:eventScreenPosition.origin belowWindowWithWindowNumber:0]; 5319 5325 5320 5326 return [m_view window].windowNumber != eventWindowNumber; 5321 5327 } … … 5357 5363 return m_gestureController->completeSimulatedSwipeInDirectionForTesting(ViewGestureController::SwipeDirection::Back); 5358 5364 } 5359 5365 5360 5366 void WebViewImpl::setUseSystemAppearance(bool useSystemAppearance) 5361 5367 { -
trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm
r250640 r251086 29 29 #if USE(APPKIT) 30 30 31 #import "CoreTextHelpers.h" 31 32 #import "NativeWebMouseEvent.h" 32 33 #import "PageClientImplMac.h" … … 34 35 #import "StringUtilities.h" 35 36 #import "WebPopupItem.h" 36 #import <pal/spi/cocoa/CoreTextSPI.h>37 37 #import <pal/system/mac/PopupMenu.h> 38 38 #import <wtf/BlockObjCExceptions.h> … … 107 107 108 108 if (data.fontInfo.fontAttributeDictionary) { 109 RetainPtr<NSMutableDictionary> mutableDictionary = adoptNS([(__bridge NSDictionary *)data.fontInfo.fontAttributeDictionary.get() mutableCopy]); 110 #if HAVE(NSFONT_WITH_OPTICAL_SIZING_BUG) 111 if (id opticalSizeAttribute = [mutableDictionary objectForKey:(__bridge NSString *)kCTFontOpticalSizeAttribute]) { 112 if ([opticalSizeAttribute isKindOfClass:[NSString class]]) { 113 [mutableDictionary removeObjectForKey:(__bridge NSString *)kCTFontOpticalSizeAttribute]; 114 if (NSNumber *size = [mutableDictionary objectForKey:(__bridge NSString *)kCTFontSizeAttribute]) 115 [mutableDictionary setObject:size forKey:(__bridge NSString *)kCTFontOpticalSizeAttribute]; 116 } 117 } 118 #endif 119 NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:mutableDictionary.get()]; 109 PlatformFontDescriptor *fontDescriptor = fontDescriptorWithFontAttributes(static_cast<NSDictionary *>(data.fontInfo.fontAttributeDictionary.get())); 120 110 font = [NSFont fontWithDescriptor:fontDescriptor size:((pageScaleFactor != 1) ? [fontDescriptor pointSize] * pageScaleFactor : 0)]; 121 111 } else -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r251022 r251086 2475 2475 1C20935F22318CB000026A39 /* NSAttributedString.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NSAttributedString.mm; sourceTree = "<group>"; }; 2476 2476 1C2184012233872800BAC700 /* NSAttributedStringPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSAttributedStringPrivate.h; sourceTree = "<group>"; }; 2477 1C739E852347BCF600C621EC /* CoreTextHelpers.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreTextHelpers.mm; sourceTree = "<group>"; }; 2478 1C739E872347BD0F00C621EC /* CoreTextHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreTextHelpers.h; sourceTree = "<group>"; }; 2477 2479 1C77C1951288A872006A742F /* WebInspectorProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebInspectorProxy.messages.in; sourceTree = "<group>"; }; 2478 2480 1C891D6219B124FF00BA79DD /* WebInspectorUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorUI.cpp; sourceTree = "<group>"; }; … … 6519 6521 37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */, 6520 6522 37BEC4DE19491486008B4286 /* CompletionHandlerCallChecker.mm */, 6523 1C739E872347BD0F00C621EC /* CoreTextHelpers.h */, 6524 1C739E852347BCF600C621EC /* CoreTextHelpers.mm */, 6521 6525 C55F916C1C595E440029E92D /* DataDetectionResult.h */, 6522 6526 C55F916D1C595E440029E92D /* DataDetectionResult.mm */,
Note: See TracChangeset
for help on using the changeset viewer.