Changeset 243113 in webkit
- Timestamp:
- Mar 18, 2019 4:32:20 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243112 r243113 1 2019-03-18 Timothy Hatcher <timothy@apple.com> 2 3 Add new NSAttributedString API for converting HTML. 4 https://bugs.webkit.org/show_bug.cgi?id=195636 5 rdar://problem/45055697 6 7 Reviewed by Tim Horton. 8 9 * en.lproj/Localizable.strings: Updated. 10 1 11 2019-03-18 Zalan Bujtas <zalan@apple.com> 2 12 -
trunk/Source/WebCore/en.lproj/Localizable.strings
r242920 r243113 110 110 "Are you sure you wish to go to this site?" = "Are you sure you wish to go to this site?"; 111 111 112 /* WKErrorAttributedStringContentFailedToLoad description */ 113 "Attributed string content failed to load" = "Attributed string content failed to load"; 114 112 115 /* Menu item label for automatic track selection behavior */ 113 116 "Auto (Recommended)" = "Auto (Recommended)"; … … 803 806 "Tighten Kerning (Undo action name)" = "Tighten Kerning"; 804 807 808 /* WKErrorAttributedStringContentLoadTimedOut description */ 809 "Timed out while loading attributed string content" = "Timed out while loading attributed string content"; 810 805 811 /* prompt string in authentication panel */ 806 812 "To view this page, you must log in to area “%@” on %@." = "To view this page, you must log in to area “%@” on %@."; -
trunk/Source/WebKit/ChangeLog
r243110 r243113 1 2019-03-18 Timothy Hatcher <timothy@apple.com> 2 3 Add new NSAttributedString API for converting HTML. 4 https://bugs.webkit.org/show_bug.cgi?id=195636 5 rdar://problem/45055697 6 7 Reviewed by Tim Horton. 8 9 * Platform/spi/ios/UIKitSPI.h: 10 * SourcesCocoa.txt: 11 * UIProcess/API/Cocoa/NSAttributedString.h: Added. 12 * UIProcess/API/Cocoa/NSAttributedString.mm: Added. 13 (-[_WKAttributedStringNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]): 14 (-[_WKAttributedStringNavigationDelegate webView:didFailProvisionalNavigation:withError:]): 15 (-[_WKAttributedStringNavigationDelegate webView:didFailNavigation:withError:]): 16 (-[_WKAttributedStringNavigationDelegate webView:didFinishNavigation:]): 17 (+[_WKAttributedStringWebViewCache cache]): 18 (+[_WKAttributedStringWebViewCache configuration]): 19 (+[_WKAttributedStringWebViewCache clearConfiguration]): 20 (+[_WKAttributedStringWebViewCache retrieveOrCreateWebView]): 21 (+[_WKAttributedStringWebViewCache cacheWebView:]): 22 (+[_WKAttributedStringWebViewCache resetPurgeDelay]): 23 (+[_WKAttributedStringWebViewCache purgeSingleWebView]): 24 (+[_WKAttributedStringWebViewCache purgeAllWebViews]): 25 (+[NSAttributedString _loadFromHTMLWithOptions:contentLoader:completionHandler:]): 26 (+[NSAttributedString loadFromHTMLWithRequest:options:completionHandler:]): 27 (+[NSAttributedString loadFromHTMLWithFileURL:options:completionHandler:]): 28 (+[NSAttributedString loadFromHTMLWithString:options:completionHandler:]): 29 (+[NSAttributedString loadFromHTMLWithData:options:completionHandler:]): 30 * UIProcess/API/Cocoa/NSAttributedStringPrivate.h: Copied from Source/WebKit/UIProcess/API/Cocoa/WKErrorInternal.h. 31 * UIProcess/API/Cocoa/WKError.h: 32 * UIProcess/API/Cocoa/WKError.mm: 33 (localizedDescriptionForErrorCode): 34 (createNSError): 35 * UIProcess/API/Cocoa/WKErrorInternal.h: 36 * WebKit.xcodeproj/project.pbxproj: 37 * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: 38 (WebKit::WebPage::getContentsAsAttributedString): 39 1 40 2019-03-18 Alex Christensen <achristensen@webkit.org> 2 41 -
trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h
r242807 r243113 1194 1194 extern NSString *const UIBacklightLevelChangedNotification; 1195 1195 1196 extern NSString * const NSTextEncodingNameDocumentOption; 1197 extern NSString * const NSBaseURLDocumentOption; 1198 extern NSString * const NSTimeoutDocumentOption; 1199 extern NSString * const NSWebPreferencesDocumentOption; 1200 extern NSString * const NSWebResourceLoadDelegateDocumentOption; 1201 extern NSString * const NSTextSizeMultiplierDocumentOption; 1202 1196 1203 WTF_EXTERN_C_END -
trunk/Source/WebKit/SourcesCocoa.txt
r243110 r243113 273 273 UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm 274 274 UIProcess/API/Cocoa/LegacyBundleForClass.mm 275 UIProcess/API/Cocoa/NSAttributedString.mm 275 276 UIProcess/API/Cocoa/WKBackForwardList.mm 276 277 UIProcess/API/Cocoa/WKBackForwardListItem.mm -
trunk/Source/WebKit/UIProcess/API/Cocoa/NSAttributedStringPrivate.h
r243112 r243113 1 1 /* 2 * Copyright (C) 201 4Apple Inc. All rights reserved.2 * Copyright (C) 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 "WKErrorPrivate.h"26 #import <WebKit/NSAttributedString.h> 27 27 28 #import <wtf/RetainPtr.h> 29 #import "GenericCallback.h" 28 @class WKNavigation; 29 @class WKWebView; 30 30 31 RetainPtr<NSError> createNSError(WKErrorCode); 32 NSString *localizedDescriptionForErrorCode(WKErrorCode); 31 NS_ASSUME_NONNULL_BEGIN 32 33 /*! 34 @discussion Private extension of @link //apple_ref/occ/NSAttributedString NSAttributedString @/link to 35 translate HTML content into attributed strings using WebKit. 36 */ 37 @interface NSAttributedString (WKPrivate) 38 39 /*! 40 @abstract Converts the contents loaded by a content loader block into an attributed string. 41 @param options Document attributes for interpreting the document contents. 42 NSTextSizeMultiplierDocumentOption, and NSTimeoutDocumentOption are supported option keys. 43 @param contentLoader A block to invoke when content needs to be loaded in the supplied 44 @link WKWebView @/link. A @link WKNavigation @/link for the main frame must be returned. 45 @param completionHandler A block to invoke when the translation completes or fails. 46 @discussion The completionHandler is passed the attributed string result along with any 47 document-level attributes, or an error. 48 */ 49 + (void)_loadFromHTMLWithOptions:(NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *)options contentLoader:(WKNavigation *(^)(WKWebView *))loadWebContent completionHandler:(NSAttributedStringCompletionHandler)completionHandler; 50 51 @end 52 53 NS_ASSUME_NONNULL_END -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKError.h
r242339 r243113 44 44 @constant WKErrorContentRuleListStoreRemoveFailed Indicates that removing a WKUserContentRuleList failed. 45 45 @constant WKErrorContentRuleListStoreVersionMismatch Indicates that the WKUserContentRuleList version did not match the latest. 46 @constant WKErrorAttributedStringContentFailedToLoad Indicates that the attributed string content failed to load. 47 @constant WKErrorAttributedStringContentLoadTimedOut Indicates that loading attributed string content timed out. 46 48 */ 47 49 typedef NS_ENUM(NSInteger, WKErrorCode) { … … 55 57 WKErrorContentRuleListStoreRemoveFailed WK_API_AVAILABLE(macosx(10.13), ios(11.0)), 56 58 WKErrorContentRuleListStoreVersionMismatch WK_API_AVAILABLE(macosx(10.13), ios(11.0)), 59 WKErrorAttributedStringContentFailedToLoad WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)), 60 WKErrorAttributedStringContentLoadTimedOut WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)), 57 61 } WK_API_AVAILABLE(macosx(10.10), ios(8.0)); 58 62 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKError.mm
r242339 r243113 68 68 case WKErrorContentRuleListStoreRemoveFailed: 69 69 return WEB_UI_STRING("Removing a WKContentRuleList failed", "WKErrorContentRuleListStoreRemoveFailed description"); 70 71 case WKErrorAttributedStringContentFailedToLoad: 72 return WEB_UI_STRING("Attributed string content failed to load", "WKErrorAttributedStringContentFailedToLoad description"); 73 74 case WKErrorAttributedStringContentLoadTimedOut: 75 return WEB_UI_STRING("Timed out while loading attributed string content", "WKErrorAttributedStringContentLoadTimedOut description"); 70 76 } 71 77 } 72 78 73 RetainPtr<NSError> createNSError(WKErrorCode errorCode )79 RetainPtr<NSError> createNSError(WKErrorCode errorCode, NSError* underlyingError) 74 80 { 75 auto userInfo = adoptNS([[NSDictionary alloc] initWithObjectsAndKeys:localizedDescriptionForErrorCode(errorCode), NSLocalizedDescriptionKey, nil]); 81 NSDictionary *userInfo = nil; 82 if (underlyingError) 83 userInfo = @{ NSLocalizedDescriptionKey: localizedDescriptionForErrorCode(errorCode), NSUnderlyingErrorKey: underlyingError }; 84 else 85 userInfo = @{ NSLocalizedDescriptionKey: localizedDescriptionForErrorCode(errorCode) }; 76 86 77 return adoptNS([[NSError alloc] initWithDomain:WKErrorDomain code:errorCode userInfo:userInfo .get()]);87 return adoptNS([[NSError alloc] initWithDomain:WKErrorDomain code:errorCode userInfo:userInfo]); 78 88 } -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKErrorInternal.h
r242339 r243113 29 29 #import "GenericCallback.h" 30 30 31 RetainPtr<NSError> createNSError(WKErrorCode );31 RetainPtr<NSError> createNSError(WKErrorCode, NSError* underlyingError = nil); 32 32 NSString *localizedDescriptionForErrorCode(WKErrorCode); -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r243110 r243113 386 386 1C0A19581C90068F00FE0EBB /* WebAutomationSessionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0A19561C90068F00FE0EBB /* WebAutomationSessionMessages.h */; }; 387 387 1C0A195C1C916E1B00FE0EBB /* WebAutomationSessionProxyScriptSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0A195B1C916E1B00FE0EBB /* WebAutomationSessionProxyScriptSource.h */; }; 388 1C20936022318CB000026A39 /* NSAttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C20935E22318CB000026A39 /* NSAttributedString.h */; settings = {ATTRIBUTES = (Private, ); }; }; 389 1C2184022233872800BAC700 /* NSAttributedStringPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C2184012233872800BAC700 /* NSAttributedStringPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 388 390 1C891D6619B124FF00BA79DD /* WebInspectorUI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C891D6319B124FF00BA79DD /* WebInspectorUI.h */; }; 389 391 1C8E28201275D15400BC7BD0 /* WebInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8E281E1275D15400BC7BD0 /* WebInspector.h */; }; … … 2397 2399 1C0A195A1C91669500FE0EBB /* WebAutomationSessionProxy.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = WebAutomationSessionProxy.js; sourceTree = "<group>"; }; 2398 2400 1C0A195B1C916E1B00FE0EBB /* WebAutomationSessionProxyScriptSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAutomationSessionProxyScriptSource.h; path = DerivedSources/WebKit2/WebAutomationSessionProxyScriptSource.h; sourceTree = BUILT_PRODUCTS_DIR; }; 2401 1C20935E22318CB000026A39 /* NSAttributedString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSAttributedString.h; sourceTree = "<group>"; }; 2402 1C20935F22318CB000026A39 /* NSAttributedString.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NSAttributedString.mm; sourceTree = "<group>"; }; 2403 1C2184012233872800BAC700 /* NSAttributedStringPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSAttributedStringPrivate.h; sourceTree = "<group>"; }; 2399 2404 1C77C1951288A872006A742F /* WebInspectorProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebInspectorProxy.messages.in; sourceTree = "<group>"; }; 2400 2405 1C891D6219B124FF00BA79DD /* WebInspectorUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorUI.cpp; sourceTree = "<group>"; }; … … 6142 6147 1A3635AB1A3145E500ED6197 /* APIWebsiteDataStoreCocoa.mm */, 6143 6148 1AFDE64319510B5500C48FFA /* LegacyBundleForClass.mm */, 6149 1C20935E22318CB000026A39 /* NSAttributedString.h */, 6150 1C20935F22318CB000026A39 /* NSAttributedString.mm */, 6151 1C2184012233872800BAC700 /* NSAttributedStringPrivate.h */, 6144 6152 37C4C08B1814AC5C003688B9 /* WKBackForwardList.h */, 6145 6153 37C4C08A1814AC5C003688B9 /* WKBackForwardList.mm */, … … 9294 9302 1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */, 9295 9303 1A2D84A3127F6AD1001EB962 /* NPVariantData.h in Headers */, 9304 1C20936022318CB000026A39 /* NSAttributedString.h in Headers */, 9305 1C2184022233872800BAC700 /* NSAttributedStringPrivate.h in Headers */, 9296 9306 3754D5451B3A29FD003A4C7F /* NSInvocationSPI.h in Headers */, 9297 9307 BC8ACA1316670D89004C1941 /* ObjCObjectGraph.h in Headers */, -
trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
r243012 r243113 209 209 210 210 RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame.document()->documentElement(), 0, INT_MAX); 211 if (!range) { 212 completionHandler({ }); 213 return; 214 } 211 215 212 216 NSDictionary* documentAttributes = nil;
Note: See TracChangeset
for help on using the changeset viewer.