Changeset 260739 in webkit
- Timestamp:
- Apr 26, 2020 10:12:55 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 deleted
- 42 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r260738 r260739 1 2020-04-26 Darin Adler <darin@apple.com> 2 3 [Cocoa] stop using out arguments for document attributes when converting to attributed strings 4 https://bugs.webkit.org/show_bug.cgi?id=211048 5 6 Reviewed by Sam Weinig. 7 8 * wtf/cocoa/URLCocoa.mm: 9 (WTF::URL::createCFURL const): Use init instead of initWithString:@"". The two are 10 equivalent in more recent versions of Foundation. 11 1 12 2020-04-26 Yoshiaki Jitsukawa <yoshiaki.jitsukawa@sony.com> 2 13 -
trunk/Source/WTF/wtf/cocoa/URLCocoa.mm
r260679 r260739 66 66 if (isEmpty()) { 67 67 // We use the toll-free bridge between NSURL and CFURL to create a CFURLRef supporting both empty and null values. 68 return (__bridge CFURLRef)adoptNS([[NSURL alloc] init WithString:@""]).get();68 return (__bridge CFURLRef)adoptNS([[NSURL alloc] init]).get(); 69 69 } 70 70 -
trunk/Source/WebCore/ChangeLog
r260738 r260739 1 2020-04-26 Darin Adler <darin@apple.com> 2 3 [Cocoa] stop using out arguments for document attributes when converting to attributed strings 4 https://bugs.webkit.org/show_bug.cgi?id=211048 5 6 Reviewed by Sam Weinig. 7 8 * DerivedSources-input.xcfilelist: Building modified this file automatically. Uploading 9 the new version. 10 11 * WebCore.xcodeproj/project.pbxproj: Added AttributedString.h. 12 * editing/cocoa/AttributedString.h: Added. Moved this from WebKit, but removed a lot of 13 inessentials. 14 * editing/cocoa/DictionaryLookup.mm: Removed unneeded include. 15 * editing/cocoa/EditorCocoa.mm: 16 (WebCore::selectionAsAttributedString): Updated for change to the return value of the 17 attributedString function, and use init instead of initWithString:@"". 18 19 * editing/cocoa/HTMLConverter.h: Changed to an Objective-C-only header, omitting things 20 like #pramga once. Return the AttributedString struct from the functions instead of 21 using an out argument for document attributes. 22 * editing/cocoa/HTMLConverter.mm: 23 (HTMLConverter::convert): Return an AttributedString and drop the out argument. 24 (WebCore::attributedString): Ditto. 25 (WebCore::editingAttributedString): Ditto. Also refactor a little bit. 26 27 * editing/ios/EditorIOS.mm: Removed unneeded include. 28 * editing/mac/DictionaryLookupLegacy.mm: Removed unneeded include. 29 30 * editing/mac/EditorMac.mm: 31 (WebCore::Editor::dataSelectionForPasteboard): Updated since attributedString 32 now returns a structure. 33 34 * platform/network/cocoa/NetworkStorageSessionCocoa.mm: 35 (WebCore::policyProperties): Use init instead of initWithString:@"". 36 * platform/network/cocoa/ResourceRequestCocoa.mm: 37 (WebCore::siteForCookies): Use init instead of initWithString:@"". 38 1 39 2020-04-26 Yoshiaki Jitsukawa <yoshiaki.jitsukawa@sony.com> 2 40 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r260718 r260739 1181 1181 $(PROJECT_DIR)/xml/xmlattrs.in 1182 1182 $(PROJECT_DIR)/xml/xmlnsattrs.in 1183 ApplePaySetup.idl 1184 ApplePaySetupFeature.idl -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r260736 r260739 2720 2720 93E241FF0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E241FE0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2721 2721 93E2A307123E9DC0009FE12A /* HTMLParserIdioms.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2722 93E5B2652455E96F005C52D0 /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E5B2632455E96F005C52D0 /* AttributedString.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2722 2723 93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23C02DE4396018635CA /* HTMLDocument.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2723 2724 93F198E608245E59001E9ABC /* HTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23F02DE4396018635CA /* HTMLElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 10944 10945 93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLParserIdioms.h; sourceTree = "<group>"; }; 10945 10946 93E5B25424536B1E005C52D0 /* URLDecomposition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLDecomposition.cpp; sourceTree = "<group>"; }; 10947 93E5B2632455E96F005C52D0 /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; }; 10946 10948 93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventWithHitTestResults.cpp; sourceTree = "<group>"; }; 10947 10949 93EEC1E509C2877700C515D1 /* Attr.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Attr.idl; sourceTree = "<group>"; }; … … 21584 21586 CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */, 21585 21587 CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */, 21588 93E5B2632455E96F005C52D0 /* AttributedString.h */, 21586 21589 5CCC270722D53B6900964FA0 /* AutofillElements.cpp */, 21587 21590 5CCC270622D53B6800964FA0 /* AutofillElements.h */, … … 29546 29549 A8C4A80B09D563270003AC8D /* Attribute.h in Headers */, 29547 29550 E4A814DA1C70E10D00BF85AC /* AttributeChangeInvalidation.h in Headers */, 29551 93E5B2652455E96F005C52D0 /* AttributedString.h in Headers */, 29548 29552 FD31607A12B026F700C1A359 /* AudioArray.h in Headers */, 29549 29553 FD629EA3154B47160006D026 /* AudioBasicInspectorNode.h in Headers */, -
trunk/Source/WebCore/editing/cocoa/AttributedString.h
r260738 r260739 1 1 /* 2 * Copyright (C) 20 11Apple Inc. All rights reserved.2 * Copyright (C) 2020 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 "AttributedString.h" 26 #pragma once 28 27 29 #import "ArgumentCodersCocoa.h" 30 #import "Decoder.h" 31 #import "Encoder.h" 28 #import <wtf/RetainPtr.h> 32 29 33 namespace IPC { 30 OBJC_CLASS NSAttributedString; 34 31 35 void ArgumentCoder<WebKit::AttributedString>::encode(Encoder& encoder, const WebKit::AttributedString& attributedString) 36 { 37 encoder << attributedString.string << attributedString.documentAttributes; 38 } 32 namespace WebCore { 39 33 40 Optional<WebKit::AttributedString> ArgumentCoder<WebKit::AttributedString>::decode(Decoder& decoder) 41 { 42 RetainPtr<NSAttributedString> attributedString; 43 if (!IPC::decode(decoder, attributedString)) 44 return WTF::nullopt; 34 struct AttributedString { 35 RetainPtr<NSAttributedString> string; 45 36 RetainPtr<NSDictionary> documentAttributes; 46 if (!IPC::decode(decoder, documentAttributes)) 47 return WTF::nullopt; 48 return { { WTFMove(attributedString), WTFMove(documentAttributes) } }; 49 } 37 }; 50 38 51 } 39 } // namespace WebCore -
trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm
r260725 r260739 37 37 #import "FrameSelection.h" 38 38 #import "GraphicsContextCG.h" 39 #import "HTMLConverter.h"40 39 #import "HitTestResult.h" 41 40 #import "NotImplemented.h" -
trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm
r260725 r260739 109 109 { 110 110 auto range = frame.selection().selection().firstRange(); 111 return range ? attributedString(*range) : adoptNS([[NSAttributedString alloc] initWithString:@""]);111 return range ? attributedString(*range).string : adoptNS([[NSAttributedString alloc] init]); 112 112 } 113 113 -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.h
r260725 r260739 24 24 */ 25 25 26 #pragma once 27 28 #import <wtf/Forward.h> 29 30 OBJC_CLASS NSAttributedString; 26 #import "AttributedString.h" 27 #import "SimpleRange.h" 31 28 32 29 namespace WebCore { 33 30 34 struct SimpleRange; 35 36 WEBCORE_EXPORT RetainPtr<NSAttributedString> attributedString(const SimpleRange&, RetainPtr<NSDictionary>* documentAttributes = nullptr); 31 WEBCORE_EXPORT AttributedString attributedString(const SimpleRange&); 37 32 38 33 #if PLATFORM(MAC) 39 // This alternate implementation of HTML conversion doesn't handle as many 40 // advanced features, such as tables, but it does use TextIterator so the34 // This alternate implementation of HTML conversion doesn't handle as many advanced features, 35 // such as tables, and doesn't produce document attributes, but it does use TextIterator so 41 36 // text offsets will exactly match plain text and other editing machinery. 42 37 // FIXME: This function and the one above should be merged. 43 38 enum class IncludeImages { Yes, No }; 44 WEBCORE_EXPORT RetainPtr<NSAttributedString>editingAttributedString(const SimpleRange&, IncludeImages = IncludeImages::Yes);39 WEBCORE_EXPORT AttributedString editingAttributedString(const SimpleRange&, IncludeImages = IncludeImages::Yes); 45 40 #endif 46 41 -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r260725 r260739 280 280 ~HTMLConverter(); 281 281 282 RetainPtr<NSAttributedString> convert(RetainPtr<NSDictionary>* documentAttributes = nullptr);282 AttributedString convert(); 283 283 284 284 private: … … 398 398 } 399 399 400 RetainPtr<NSAttributedString> HTMLConverter::convert(RetainPtr<NSDictionary>* documentAttributes)400 AttributedString HTMLConverter::convert() 401 401 { 402 402 if (comparePositions(m_start, m_end) > 0) 403 return nil;403 return { }; 404 404 405 405 Node* commonAncestorContainer = _caches->cacheAncestorsOfStartToBeConverted(m_start, m_end); … … 419 419 [_attrStr deleteCharactersInRange:NSMakeRange(0, _domRangeStartIndex)]; 420 420 421 if (documentAttributes) 422 *documentAttributes = _documentAttrs; 423 424 return _attrStr; 421 return { WTFMove(_attrStr), WTFMove(_documentAttrs) }; 425 422 } 426 423 … … 2369 2366 2370 2367 // This function supports more HTML features than the editing variant below, such as tables. 2371 RetainPtr<NSAttributedString> attributedString(const SimpleRange& range, RetainPtr<NSDictionary>* documentAttributes)2372 { 2373 return HTMLConverter { range }.convert( documentAttributes);2368 AttributedString attributedString(const SimpleRange& range) 2369 { 2370 return HTMLConverter { range }.convert(); 2374 2371 } 2375 2372 … … 2377 2374 2378 2375 // This function uses TextIterator, which makes offsets in its result compatible with HTML editing. 2379 RetainPtr<NSAttributedString> editingAttributedString(const SimpleRange& range, IncludeImages includeImages) 2380 { 2381 NSFontManager *fontManager = [NSFontManager sharedFontManager]; 2382 NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init]; 2376 AttributedString editingAttributedString(const SimpleRange& range, IncludeImages includeImages) 2377 { 2378 auto fontManager = [NSFontManager sharedFontManager]; 2379 auto string = adoptNS([[NSMutableAttributedString alloc] init]); 2380 auto attrs = adoptNS([[NSMutableDictionary alloc] init]); 2383 2381 NSUInteger stringLength = 0; 2384 RetainPtr<NSMutableDictionary> attrs = adoptNS([[NSMutableDictionary alloc] init]);2385 2386 2382 for (TextIterator it(range); !it.atEnd(); it.advance()) { 2387 SimpleRange currentTextRange = it.range(); 2388 Node& startContainer = currentTextRange.start.container; 2389 Node& endContainer = currentTextRange.end.container; 2390 int startOffset = currentTextRange.start.offset; 2391 int endOffset = currentTextRange.end.offset; 2392 2393 if (includeImages == IncludeImages::Yes) { 2394 if (&startContainer == &endContainer && (startOffset == endOffset - 1)) { 2395 Node* node = startContainer.traverseToChildAt(startOffset); 2396 if (is<HTMLImageElement>(node)) { 2397 RetainPtr<NSFileWrapper> fileWrapper = fileWrapperForElement(downcast<HTMLImageElement>(*node)); 2398 NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper.get()]; 2399 [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]]; 2400 [attachment release]; 2401 } 2402 } 2403 } 2404 2405 int currentTextLength = it.text().length(); 2383 auto node = it.node(); 2384 2385 if (includeImages == IncludeImages::Yes && is<HTMLImageElement>(node)) { 2386 auto fileWrapper = fileWrapperForElement(downcast<HTMLImageElement>(*node)); 2387 auto attachment = adoptNS([[NSTextAttachment alloc] initWithFileWrapper:fileWrapper.get()]); 2388 [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment.get()]]; 2389 } 2390 2391 auto currentTextLength = it.text().length(); 2406 2392 if (!currentTextLength) 2407 2393 continue; 2408 2394 2409 RenderObject* renderer = startContainer.renderer();2395 auto renderer = node->renderer(); 2410 2396 ASSERT(renderer); 2411 2397 if (!renderer) 2412 2398 continue; 2413 const RenderStyle& style = renderer->style();2399 auto& style = renderer->style(); 2414 2400 if (style.textDecorationsInEffect() & TextDecoration::Underline) 2415 [attrs .get()setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];2401 [attrs setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName]; 2416 2402 if (style.textDecorationsInEffect() & TextDecoration::LineThrough) 2417 [attrs .get()setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];2403 [attrs setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName]; 2418 2404 if (auto font = style.fontCascade().primaryFont().getCTFont()) 2419 [attrs .get()setObject:toNSFont(font) forKey:NSFontAttributeName];2405 [attrs setObject:toNSFont(font) forKey:NSFontAttributeName]; 2420 2406 else 2421 [attrs .get()setObject:[fontManager convertFont:WebDefaultFont() toSize:style.fontCascade().primaryFont().platformData().size()] forKey:NSFontAttributeName];2407 [attrs setObject:[fontManager convertFont:WebDefaultFont() toSize:style.fontCascade().primaryFont().platformData().size()] forKey:NSFontAttributeName]; 2422 2408 2423 2409 Color foregroundColor = style.visitedDependentColorWithColorFilter(CSSPropertyColor); 2424 2410 if (foregroundColor.isVisible()) 2425 [attrs .get()setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName];2411 [attrs setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName]; 2426 2412 else 2427 [attrs .get()removeObjectForKey:NSForegroundColorAttributeName];2413 [attrs removeObjectForKey:NSForegroundColorAttributeName]; 2428 2414 2429 2415 Color backgroundColor = style.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor); 2430 2416 if (backgroundColor.isVisible()) 2431 [attrs .get()setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName];2417 [attrs setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName]; 2432 2418 else 2433 [attrs .get()removeObjectForKey:NSBackgroundColorAttributeName];2419 [attrs removeObjectForKey:NSBackgroundColorAttributeName]; 2434 2420 2435 2421 RetainPtr<NSString> text; … … 2444 2430 } 2445 2431 2446 return [string autorelease];2432 return { WTFMove(string), nil }; 2447 2433 } 2448 2434 -
trunk/Source/WebCore/editing/ios/EditorIOS.mm
r260707 r260739 39 39 #import "EditorClient.h" 40 40 #import "Frame.h" 41 #import "HTMLConverter.h"42 41 #import "HTMLInputElement.h" 43 42 #import "HTMLNames.h" -
trunk/Source/WebCore/editing/mac/DictionaryLookupLegacy.mm
r260725 r260739 34 34 #import "Frame.h" 35 35 #import "FrameSelection.h" 36 #import "HTMLConverter.h"37 36 #import "HitTestResult.h" 38 37 #import "Page.h" -
trunk/Source/WebCore/editing/mac/EditorMac.mm
r260725 r260739 51 51 #import "RuntimeApplicationChecks.h" 52 52 #import "RuntimeEnabledFeatures.h" 53 #import "SimpleRange.h"54 53 #import "StyleProperties.h" 55 54 #import "WebContentReader.h" … … 189 188 190 189 if (pasteboardType == String(legacyRTFDPasteboardType())) 191 return dataInRTFDFormat(attributedString(*adjustedSelectionRange()). get());190 return dataInRTFDFormat(attributedString(*adjustedSelectionRange()).string.get()); 192 191 193 192 if (pasteboardType == String(legacyRTFPasteboardType())) { 194 auto string = attributedString(*adjustedSelectionRange()) ;193 auto string = attributedString(*adjustedSelectionRange()).string; 195 194 // FIXME: Why is this stripping needed here, but not in writeSelectionToPasteboard? 196 195 if ([string containsAttachments]) -
trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm
r260485 r260739 234 234 static RetainPtr<NSDictionary> policyProperties(const SameSiteInfo& sameSiteInfo, NSURL *url) 235 235 { 236 static NSURL *emptyURL = [[NSURL alloc] init WithString:@""];236 static NSURL *emptyURL = [[NSURL alloc] init]; 237 237 NSDictionary *policyProperties = @{ 238 238 @"_kCFHTTPCookiePolicyPropertySiteForCookies": sameSiteInfo.isSameSite ? url : emptyURL, -
trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm
r260485 r260739 147 147 return url; 148 148 case ResourceRequest::SameSiteDisposition::CrossSite: 149 static NSURL *emptyURL = [[NSURL alloc] init WithString:@""];149 static NSURL *emptyURL = [[NSURL alloc] init]; 150 150 return emptyURL; 151 151 } -
trunk/Source/WebKit/ChangeLog
r260736 r260739 1 2020-04-26 Darin Adler <darin@apple.com> 2 3 [Cocoa] stop using out arguments for document attributes when converting to attributed strings 4 https://bugs.webkit.org/show_bug.cgi?id=211048 5 6 Reviewed by Sam Weinig. 7 8 * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: 9 (WebKit::updateTaskWithFirstPartyForSameSiteCookies): Use init instead of initWithString:@"". 10 11 * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: 12 (IPC::ArgumentCoder<WebCore::AttributedString>::encode): Moved here from AttributedString.mm. 13 (IPC::ArgumentCoder<WebCore::AttributedString>::decode): Ditto. 14 15 * Shared/DocumentEditingContext.h: Updated to use WebCore::AttributeString. 16 * Shared/DocumentEditingContext.mm: 17 (IPC::ArgumentCoder<WebKit::DocumentEditingContext>::decode): Ditto. 18 19 * Shared/WebCoreArgumentCoders.h: Added coder for WebCore::AttributedString. 20 21 * Shared/mac/AttributedString.h: Removed. 22 * Shared/mac/AttributedString.mm: Removed. 23 24 * SourcesCocoa.txt: Removed AttributedString.mm. 25 26 * UIProcess/API/Cocoa/WKWebView.mm: Updated to use WebCore::AttributedString. 27 * UIProcess/Cocoa/TextCheckingController.mm: Ditto. 28 * UIProcess/Cocoa/WebViewImpl.mm: 29 (WebKit::WebViewImpl::attributedSubstringForProposedRange): Ditto. 30 * UIProcess/WebPageProxy.cpp: 31 (WebKit::WebPageProxy::getContentsAsAttributedString): Ditto. 32 * UIProcess/WebPageProxy.h: Ditto. 33 * UIProcess/WebPageProxy.messages.in: Ditto. 34 * UIProcess/mac/WebPageProxyMac.mm: 35 (WebKit::WebPageProxy::attributedSubstringForCharacterRangeAsync): Ditto. 36 (WebKit::WebPageProxy::attributedStringForCharacterRangeCallback): Ditto. 37 38 * WebKit.xcodeproj/project.pbxproj: Removed AttributedString.h and AttributedString.mm. 39 40 * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h: Updated to use WebCore::AttributedString. 41 * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in: Ditto. 42 * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm: 43 (WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): Ditto. 44 (WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions): Ditto. 45 46 * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: 47 (WebKit::WebPage::dictionaryPopupInfoForRange): Updated since editingAttributedString 48 returns a struct. 49 (WebKit::WebPage::getContentsAsAttributedString): Updated to use SimpleRange and 50 since attributedString returns a struct. 51 52 * WebProcess/WebPage/WebPage.h: Updated to use WebCore::AttributedString. 53 * WebProcess/WebPage/WebPage.messages.in: Ditto. 54 * WebProcess/WebPage/ios/WebPageIOS.mm: 55 (WebKit::WebPage::requestDocumentEditingContext): Ditto. 56 * WebProcess/WebPage/mac/WebPageMac.mm: 57 (WebKit::WebPage::attributedSubstringForCharacterRangeAsync): Ditto. 58 (WebKit::WebPage::handleSelectionServiceClick): Ditto. 59 1 60 2020-04-26 Said Abou-Hallawa <sabouhallawa@apple.com> 2 61 -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
r260707 r260739 183 183 return; 184 184 #if HAVE(FOUNDATION_WITH_SAME_SITE_COOKIE_SUPPORT) 185 static NSURL *emptyURL = [[NSURL alloc] init WithString:@""];185 static NSURL *emptyURL = [[NSURL alloc] init]; 186 186 task._siteForCookies = request.isSameSite() ? task.currentRequest.URL : emptyURL; 187 187 task._isTopLevelNavigation = request.isTopSite(); -
trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
r260717 r260739 28 28 29 29 #import "ArgumentCodersCocoa.h" 30 #import <WebCore/AttributedString.h> 30 31 #import <WebCore/DictionaryPopupInfo.h> 31 32 #import <WebCore/Font.h> … … 44 45 namespace IPC { 45 46 using namespace WebCore; 47 48 void ArgumentCoder<WebCore::AttributedString>::encode(Encoder& encoder, const WebCore::AttributedString& attributedString) 49 { 50 encoder << attributedString.string << attributedString.documentAttributes; 51 } 52 53 Optional<WebCore::AttributedString> ArgumentCoder<WebCore::AttributedString>::decode(Decoder& decoder) 54 { 55 RetainPtr<NSAttributedString> attributedString; 56 if (!IPC::decode(decoder, attributedString)) 57 return WTF::nullopt; 58 RetainPtr<NSDictionary> documentAttributes; 59 if (!IPC::decode(decoder, documentAttributes)) 60 return WTF::nullopt; 61 return { { WTFMove(attributedString), WTFMove(documentAttributes) } }; 62 } 46 63 47 64 #if ENABLE(APPLE_PAY) -
trunk/Source/WebKit/Shared/DocumentEditingContext.h
r252528 r260739 29 29 30 30 #include "ArgumentCoders.h" 31 #include "AttributedString.h"31 #include <WebCore/AttributedString.h> 32 32 #include <WebCore/ElementContext.h> 33 33 #include <WebCore/FloatRect.h> … … 64 64 UIWKDocumentContext *toPlatformContext(OptionSet<WebKit::DocumentEditingContextRequest::Options>); 65 65 66 AttributedString contextBefore;67 AttributedString selectedText;68 AttributedString contextAfter;69 AttributedString markedText;70 AttributedString annotatedText;66 WebCore::AttributedString contextBefore; 67 WebCore::AttributedString selectedText; 68 WebCore::AttributedString contextAfter; 69 WebCore::AttributedString markedText; 70 WebCore::AttributedString annotatedText; 71 71 72 72 struct Range { -
trunk/Source/WebKit/Shared/DocumentEditingContext.mm
r260366 r260739 132 132 WebKit::DocumentEditingContext context; 133 133 134 Optional<Web Kit::AttributedString> contextBefore;134 Optional<WebCore::AttributedString> contextBefore; 135 135 decoder >> contextBefore; 136 136 if (!contextBefore) … … 138 138 context.contextBefore = *contextBefore; 139 139 140 Optional<Web Kit::AttributedString> selectedText;140 Optional<WebCore::AttributedString> selectedText; 141 141 decoder >> selectedText; 142 142 if (!selectedText) … … 144 144 context.selectedText = *selectedText; 145 145 146 Optional<Web Kit::AttributedString> contextAfter;146 Optional<WebCore::AttributedString> contextAfter; 147 147 decoder >> contextAfter; 148 148 if (!contextAfter) … … 150 150 context.contextAfter = *contextAfter; 151 151 152 Optional<Web Kit::AttributedString> markedText;152 Optional<WebCore::AttributedString> markedText; 153 153 decoder >> markedText; 154 154 if (!markedText) … … 156 156 context.markedText = *markedText; 157 157 158 Optional<Web Kit::AttributedString> annotatedText;158 Optional<WebCore::AttributedString> annotatedText; 159 159 decoder >> annotatedText; 160 160 if (!annotatedText) -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h
r259937 r260739 117 117 class UserStyleSheet; 118 118 119 struct AttributedString; 119 120 struct CacheQueryOptions; 120 121 struct CharacterRange; … … 210 211 }; 211 212 213 template<> struct ArgumentCoder<WebCore::AttributedString> { 214 static void encode(Encoder&, const WebCore::AttributedString&); 215 static Optional<WebCore::AttributedString> decode(Decoder&); 216 }; 217 212 218 template<> struct ArgumentCoder<WebCore::CacheQueryOptions> { 213 219 static void encode(Encoder&, const WebCore::CacheQueryOptions&); -
trunk/Source/WebKit/SourcesCocoa.txt
r260717 r260739 189 189 Shared/ios/WebTouchEventIOS.cpp 190 190 191 Shared/mac/AttributedString.mm192 191 Shared/mac/AuxiliaryProcessMac.mm 193 192 Shared/mac/CodeSigning.mm -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r260667 r260739 31 31 #import "APIPageConfiguration.h" 32 32 #import "APISerializedScriptValue.h" 33 #import "AttributedString.h"34 33 #import "CocoaImage.h" 35 34 #import "CompletionHandlerCallChecker.h" … … 117 116 #import "_WKVisitedLinkStoreInternal.h" 118 117 #import "_WKWebsitePoliciesInternal.h" 118 #import <WebCore/AttributedString.h> 119 119 #import <WebCore/ElementContext.h> 120 120 #import <WebCore/JSDOMBinding.h> -
trunk/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm
r249275 r260739 29 29 #if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING) 30 30 31 #import "AttributedString.h"32 31 #import "TextCheckingControllerProxyMessages.h" 33 32 #import "WebProcessProxy.h" -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r260186 r260739 33 33 #import "APINavigation.h" 34 34 #import "AppKitSPI.h" 35 #import "AttributedString.h"36 35 #import "ColorSpaceData.h" 37 36 #import "CoreTextHelpers.h" … … 83 82 #import <WebCore/AXObjectCache.h> 84 83 #import <WebCore/ActivityState.h> 84 #import <WebCore/AttributedString.h> 85 85 #import <WebCore/ColorMac.h> 86 86 #import <WebCore/CompositionHighlight.h> … … 4952 4952 4953 4953 LOG(TextInput, "attributedSubstringFromRange:(%u, %u)", proposedRange.location, proposedRange.length); 4954 m_page->attributedSubstringForCharacterRangeAsync(proposedRange, [completionHandler](const AttributedString& string, const EditingRange& actualRange, WebKit::CallbackBase::Error error) {4954 m_page->attributedSubstringForCharacterRangeAsync(proposedRange, [completionHandler](const WebCore::AttributedString& string, const EditingRange& actualRange, WebKit::CallbackBase::Error error) { 4955 4955 void (^completionHandlerBlock)(NSAttributedString *, NSRange) = (void (^)(NSAttributedString *, NSRange))completionHandler.get(); 4956 4956 if (error != WebKit::CallbackBase::Error::None) { … … 4959 4959 return; 4960 4960 } 4961 NSAttributedString *attributedString = string; 4962 LOG(TextInput, " -> attributedSubstringFromRange returned %@", [attributedString string]); 4963 completionHandlerBlock([[attributedString retain] autorelease], actualRange); 4961 LOG(TextInput, " -> attributedSubstringFromRange returned %@", string.string.get()); 4962 completionHandlerBlock(string.string.get(), actualRange); 4964 4963 }); 4965 4964 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r260709 r260739 201 201 202 202 #if PLATFORM(COCOA) 203 #include "AttributedString.h"204 203 #include "InsertTextOptions.h" 205 204 #include "RemoteLayerTreeDrawingAreaProxy.h" … … 209 208 #include "VideoFullscreenManagerProxy.h" 210 209 #include "VideoFullscreenManagerProxyMessages.h" 210 #include <WebCore/AttributedString.h> 211 211 #include <WebCore/RunLoopObserver.h> 212 212 #include <WebCore/TextIndicatorWindow.h> … … 4116 4116 4117 4117 #if PLATFORM(COCOA) 4118 void WebPageProxy::getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&& completionHandler)4118 void WebPageProxy::getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&& completionHandler) 4119 4119 { 4120 4120 if (!hasRunningProcess()) { 4121 completionHandler( AttributedString());4121 completionHandler({ }); 4122 4122 return; 4123 4123 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r260684 r260739 233 233 234 234 struct ApplicationManifest; 235 struct AttributedString; 235 236 struct BackForwardItemIdentifier; 236 237 struct CompositionHighlight; … … 254 255 struct WindowFeatures; 255 256 256 template 257 template<typename> class RectEdges; 257 258 using FloatBoxExtent = RectEdges<float>; 258 259 } … … 324 325 class WebsiteDataStore; 325 326 326 struct AttributedString;327 327 struct WebBackForwardListCounts; 328 328 struct ColorSpaceData; … … 396 396 397 397 #if PLATFORM(MAC) 398 typedef GenericCallback<const AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;398 typedef GenericCallback<const WebCore::AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback; 399 399 typedef GenericCallback<const FontInfo&, double, bool> FontAtSelectionCallback; 400 400 #endif … … 882 882 883 883 #if PLATFORM(MAC) 884 void attributedSubstringForCharacterRangeAsync(const EditingRange&, WTF::Function<void (constAttributedString&, const EditingRange&, CallbackBase::Error)>&&);884 void attributedSubstringForCharacterRangeAsync(const EditingRange&, Function<void(const WebCore::AttributedString&, const EditingRange&, CallbackBase::Error)>&&); 885 885 void fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&&); 886 886 … … 1104 1104 void getContentsAsString(ContentAsStringIncludesChildFrames, WTF::Function<void(const String&, CallbackBase::Error)>&&); 1105 1105 #if PLATFORM(COCOA) 1106 void getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&&);1106 void getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&&); 1107 1107 #endif 1108 1108 void getBytecodeProfile(WTF::Function<void (const String&, CallbackBase::Error)>&&); … … 2080 2080 void rectForCharacterRangeCallback(const WebCore::IntRect&, const EditingRange&, CallbackID); 2081 2081 #if PLATFORM(MAC) 2082 void attributedStringForCharacterRangeCallback(const AttributedString&, const EditingRange&, CallbackID);2082 void attributedStringForCharacterRangeCallback(const WebCore::AttributedString&, const EditingRange&, CallbackID); 2083 2083 void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID); 2084 2084 #endif -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r260652 r260739 176 176 #endif 177 177 #if PLATFORM(MAC) 178 AttributedStringForCharacterRangeCallback(struct Web Kit::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)178 AttributedStringForCharacterRangeCallback(struct WebCore::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID) 179 179 FontAtSelectionCallback(struct WebKit::FontInfo fontInfo, double fontSize, bool selectionHasMultipleFonts, WebKit::CallbackID callbackID) 180 180 #endif -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r260476 r260739 30 30 31 31 #import "APIUIClient.h" 32 #import "AttributedString.h"33 32 #import "ColorSpaceData.h" 34 33 #import "Connection.h" … … 51 50 #import "WebPageMessages.h" 52 51 #import "WebProcessProxy.h" 52 #import <WebCore/AttributedString.h> 53 53 #import <WebCore/DictationAlternative.h> 54 54 #import <WebCore/DictionaryLookup.h> … … 187 187 } 188 188 189 void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, WTF::Function<void (constAttributedString&, const EditingRange&, CallbackBase::Error)>&& callbackFunction)189 void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, Function<void(const WebCore::AttributedString&, const EditingRange&, CallbackBase::Error)>&& callbackFunction) 190 190 { 191 191 if (!hasRunningProcess()) { 192 callbackFunction( AttributedString(), EditingRange(), CallbackBase::Error::Unknown);192 callbackFunction({ }, EditingRange(), CallbackBase::Error::Unknown); 193 193 return; 194 194 } … … 199 199 } 200 200 201 void WebPageProxy::attributedStringForCharacterRangeCallback(const AttributedString& string, const EditingRange& actualRange, CallbackID callbackID)201 void WebPageProxy::attributedStringForCharacterRangeCallback(const WebCore::AttributedString& string, const EditingRange& actualRange, CallbackID callbackID) 202 202 { 203 203 MESSAGE_CHECK(actualRange.isValid()); -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r260718 r260739 1797 1797 E19582D3153CBFD700B60875 /* PDFKitImports.h in Headers */ = {isa = PBXBuildFile; fileRef = E19582D2153CBFD700B60875 /* PDFKitImports.h */; }; 1798 1798 E19BDA86193665E300B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */; }; 1799 E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A31731134CEA6C007C9A4F /* AttributedString.h */; };1800 1799 E1AEA22F14687BDB00804569 /* WKFullKeyboardAccessWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */; }; 1801 1800 E1B78471163F24690007B692 /* RemoteNetworkingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E1B78470163F24690007B692 /* RemoteNetworkingContext.h */; }; … … 5276 5275 E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.appstore.CodeRedeemerNetscapePlugin.sb; sourceTree = "<group>"; }; 5277 5276 E19BDA88193686A400B97F57 /* SandboxUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxUtilities.h; sourceTree = "<group>"; }; 5278 E1A31731134CEA6C007C9A4F /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; };5279 E1A31734134CEA80007C9A4F /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = "<group>"; };5280 5277 E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFullKeyboardAccessWatcher.h; sourceTree = "<group>"; }; 5281 5278 E1AEA22E14687BDB00804569 /* WKFullKeyboardAccessWatcher.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFullKeyboardAccessWatcher.mm; sourceTree = "<group>"; }; … … 9399 9396 isa = PBXGroup; 9400 9397 children = ( 9401 E1A31731134CEA6C007C9A4F /* AttributedString.h */,9402 E1A31734134CEA80007C9A4F /* AttributedString.mm */,9403 9398 9F54F88E16488E87007DF81A /* AuxiliaryProcessMac.mm */, 9404 9399 CE11AD511CBC482F00681EE5 /* CodeSigning.h */, … … 10719 10714 AAFA634F234F7C6400FFA864 /* AsyncRevalidation.h in Headers */, 10720 10715 BCEE966D112FAF57006BCC24 /* Attachment.h in Headers */, 10721 E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */,10722 10716 512F589712A8838800629530 /* AuthenticationChallengeProxy.h in Headers */, 10723 10717 512F589912A8838800629530 /* AuthenticationDecisionListener.h in Headers */, -
trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h
r259401 r260739 28 28 #if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING) 29 29 30 #include "AttributedString.h"31 30 #include "Connection.h" 32 31 #include "EditingRange.h" … … 40 39 41 40 namespace WebCore { 41 class AttributedString; 42 42 class VisiblePosition; 43 43 } … … 53 53 ~TextCheckingControllerProxy(); 54 54 55 static AttributedString annotatedSubstringBetweenPositions(const WebCore::VisiblePosition&, const WebCore::VisiblePosition&);55 static WebCore::AttributedString annotatedSubstringBetweenPositions(const WebCore::VisiblePosition&, const WebCore::VisiblePosition&); 56 56 57 57 private: … … 66 66 67 67 // Message handlers. 68 void replaceRelativeToSelection(const AttributedString&, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength);68 void replaceRelativeToSelection(const WebCore::AttributedString&, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength); 69 69 void removeAnnotationRelativeToSelection(const String& annotationName, int64_t selectionOffset, uint64_t length); 70 70 -
trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in
r252677 r260739 24 24 25 25 messages -> TextCheckingControllerProxy NotRefCounted { 26 ReplaceRelativeToSelection(struct Web Kit::AttributedString annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength)26 ReplaceRelativeToSelection(struct WebCore::AttributedString annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength) 27 27 28 28 RemoveAnnotationRelativeToSelection(String annotationName, int64_t selectionOffset, uint64_t length) -
trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm
r259575 r260739 94 94 } 95 95 96 void TextCheckingControllerProxy::replaceRelativeToSelection(const AttributedString& annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength)96 void TextCheckingControllerProxy::replaceRelativeToSelection(const WebCore::AttributedString& annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength) 97 97 { 98 98 Frame& frame = m_page.corePage()->focusController().focusedOrMainFrame(); … … 174 174 } 175 175 176 AttributedString TextCheckingControllerProxy::annotatedSubstringBetweenPositions(const WebCore::VisiblePosition& start, const WebCore::VisiblePosition& end)176 WebCore::AttributedString TextCheckingControllerProxy::annotatedSubstringBetweenPositions(const WebCore::VisiblePosition& start, const WebCore::VisiblePosition& end) 177 177 { 178 178 auto startBoundary = makeBoundaryPoint(start); -
trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
r260725 r260739 27 27 #import "WebPage.h" 28 28 29 #import "AttributedString.h"30 29 #import "InsertTextOptions.h" 31 30 #import "LoadParameters.h" … … 52 51 #import <WebCore/Range.h> 53 52 #import <WebCore/RenderElement.h> 54 #import <WebCore/SimpleRange.h>55 53 56 54 #if PLATFORM(COCOA) … … 147 145 148 146 #if PLATFORM(MAC) 149 auto attributedString = editingAttributedString(range, IncludeImages::No) ;147 auto attributedString = editingAttributedString(range, IncludeImages::No).string; 150 148 auto scaledAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[attributedString string]]); 151 149 NSFontManager *fontManager = [NSFontManager sharedFontManager]; … … 225 223 #endif 226 224 227 void WebPage::getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&& completionHandler) 228 { 229 auto* documentElement = m_page->mainFrame().document()->documentElement(); 230 if (!documentElement) { 231 completionHandler({ }); 232 return; 233 } 234 235 RetainPtr<NSDictionary> documentAttributes; 236 auto string = attributedString(rangeOfContents(*documentElement), &documentAttributes); 237 completionHandler({ WTFMove(string), WTFMove(documentAttributes) }); 225 void WebPage::getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&& completionHandler) 226 { 227 completionHandler(attributedString(makeRangeSelectingNodeContents(*m_page->mainFrame().document()))); 238 228 } 239 229 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r260725 r260739 206 206 enum class WritingDirection : uint8_t; 207 207 208 struct AttributedString; 208 209 struct BackForwardItemIdentifier; 209 210 struct CompositionHighlight; … … 280 281 enum class SyntheticEditingCommandType : uint8_t; 281 282 282 struct AttributedString;283 283 struct BackForwardListItemState; 284 284 struct DataDetectionResult; … … 1504 1504 void getContentsAsString(ContentAsStringIncludesChildFrames, CallbackID); 1505 1505 #if PLATFORM(COCOA) 1506 void getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&&);1506 void getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&&); 1507 1507 #endif 1508 1508 #if ENABLE(MHTML) -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r260684 r260739 201 201 GetAllFrames() -> (struct WebKit::FrameTreeNodeData mainFrame) Async 202 202 #if PLATFORM(COCOA) 203 GetContentsAsAttributedString() -> (struct Web Kit::AttributedString result) Async203 GetContentsAsAttributedString() -> (struct WebCore::AttributedString result) Async 204 204 #endif 205 205 #if ENABLE(MHTML) -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r260725 r260739 4263 4263 } 4264 4264 4265 auto makeString = [] (const VisiblePosition& start, const VisiblePosition& end) -> RetainPtr<NSAttributedString>{4265 auto makeString = [] (const VisiblePosition& start, const VisiblePosition& end) -> AttributedString { 4266 4266 auto startBoundary = makeBoundaryPoint(start.deepEquivalent()); 4267 4267 auto endBoundary = makeBoundaryPoint(end.deepEquivalent()); 4268 4268 if (!startBoundary || !endBoundary || *startBoundary == *endBoundary) 4269 return nil;4269 return { }; 4270 4270 // FIXME: This should return editing-offset-compatible attributed strings if that option is requested. 4271 return adoptNS([[NSAttributedString alloc] initWithString:WebCore::plainTextReplacingNoBreakSpace({ WTFMove(*startBoundary), WTFMove(*endBoundary) })]);4271 return { adoptNS([[NSAttributedString alloc] initWithString:WebCore::plainTextReplacingNoBreakSpace({ WTFMove(*startBoundary), WTFMove(*endBoundary) })]), nil }; 4272 4272 }; 4273 4273 4274 context.contextBefore = makeString(contextBeforeStart, startOfRangeOfInterestInSelection) .get();4275 context.selectedText = makeString(startOfRangeOfInterestInSelection, endOfRangeOfInterestInSelection) .get();4276 context.contextAfter = makeString(endOfRangeOfInterestInSelection, contextAfterEnd) .get();4274 context.contextBefore = makeString(contextBeforeStart, startOfRangeOfInterestInSelection); 4275 context.selectedText = makeString(startOfRangeOfInterestInSelection, endOfRangeOfInterestInSelection); 4276 context.contextAfter = makeString(endOfRangeOfInterestInSelection, contextAfterEnd); 4277 4277 if (compositionRange && rangesOverlap(rangeOfInterest.get(), compositionRange.get())) { 4278 4278 VisiblePosition compositionStart(compositionRange->startPosition()); 4279 4279 VisiblePosition compositionEnd(compositionRange->endPosition()); 4280 context.markedText = makeString(compositionStart, compositionEnd) .get();4280 context.markedText = makeString(compositionStart, compositionEnd); 4281 4281 context.selectedRangeInMarkedText.location = distanceBetweenPositions(startOfRangeOfInterestInSelection, compositionStart); 4282 4282 context.selectedRangeInMarkedText.length = [context.selectedText.string length]; -
trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r260725 r260739 29 29 #if PLATFORM(MAC) 30 30 31 #import "AttributedString.h"32 31 #import "ContextMenuContextData.h" 33 32 #import "DataReference.h" … … 340 339 } 341 340 342 auto attributedString = editingAttributedString(*range, IncludeImages::No) ;341 auto attributedString = editingAttributedString(*range, IncludeImages::No).string; 343 342 344 343 // WebCore::editingAttributedStringFromRange() insists on inserting a trailing … … 355 354 if (!rangeToSend.isValid()) { 356 355 // Send an empty EditingRange as a last resort for <rdar://problem/27078089>. 357 send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback( attributedString.get(), EditingRange(), callbackID));358 return; 359 } 360 361 send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback( attributedString.get(), rangeToSend, callbackID));356 send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback({ WTFMove(attributedString), nil }, EditingRange(), callbackID)); 357 return; 358 } 359 360 send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback({ WTFMove(attributedString), nil }, rangeToSend, callbackID)); 362 361 } 363 362 … … 811 810 return; 812 811 813 auto attributedSelection = attributedString(*range) ;812 auto attributedSelection = attributedString(*range).string; 814 813 if (!attributedSelection) 815 814 return; -
trunk/Source/WebKitLegacy/mac/ChangeLog
r260725 r260739 1 2020-04-26 Darin Adler <darin@apple.com> 2 3 [Cocoa] stop using out arguments for document attributes when converting to attributed strings 4 https://bugs.webkit.org/show_bug.cgi?id=211048 5 6 Reviewed by Sam Weinig. 7 8 * WebCoreSupport/WebSelectionServiceController.mm: 9 (WebSelectionServiceController::handleSelectionServiceClick): Updated since 10 attributedString returns a struct. 11 * WebView/WebHTMLRepresentation.mm: 12 (-[WebHTMLRepresentation attributedStringFrom:startOffset:to:endOffset:]): Ditto. 13 Also use init instead of initWithString:@"". 14 * WebView/WebHTMLView.mm: 15 (-[WebHTMLView textStorage]): DItto. 16 (-[WebHTMLView attributedSubstringFromRange:]): Ditto. 17 (-[WebHTMLView _attributedStringFromDOMRange:]): Ditto. 18 (-[WebHTMLView _legacyAttributedStringFrom:offset:to:offset:]): Ditto. 19 (-[WebHTMLView attributedString]): Ditto. 20 (-[WebHTMLView selectedAttributedString]): Ditto. 21 * WebView/WebImmediateActionController.mm: 22 (+[WebImmediateActionController _dictionaryPopupInfoForRange:inFrame:withLookupOptions:indicatorOptions:transition:]): 23 Updated. 24 1 25 2020-04-11 Darin Adler <darin@apple.com> 2 26 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSelectionServiceController.mm
r260725 r260739 32 32 #import <WebCore/HTMLConverter.h> 33 33 #import <WebCore/Range.h> 34 #import <WebCore/SimpleRange.h>35 34 #import <pal/spi/mac/NSSharingServiceSPI.h> 36 35 … … 52 51 return; 53 52 54 auto attributedSelection = attributedString(*range) ;53 auto attributedSelection = attributedString(*range).string; 55 54 if (!attributedSelection) 56 55 return; -
trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm
r260725 r260739 270 270 { 271 271 if (!startNode || !endNode) 272 return [[[NSAttributedString alloc] init WithString:@""] autorelease];272 return [[[NSAttributedString alloc] init] autorelease]; 273 273 auto range = SimpleRange { { *core(startNode), static_cast<unsigned>(startOffset) }, { *core(endNode), static_cast<unsigned>(endOffset) } }; 274 return editingAttributedString(range). autorelease();274 return editingAttributedString(range).string.autorelease(); 275 275 } 276 276 -
trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
r260725 r260739 6310 6310 6311 6311 // We have to return an empty string rather than null to prevent TSM from calling -string 6312 return result ? result : [[[NSAttributedString alloc] init WithString:@""] autorelease];6312 return result ? result : [[[NSAttributedString alloc] init] autorelease]; 6313 6313 } 6314 6314 … … 6431 6431 } 6432 6432 6433 auto result = editingAttributedString(*range) ;6433 auto result = editingAttributedString(*range).string; 6434 6434 6435 6435 // WebCore::editingAttributedStringFromRange() insists on inserting a trailing … … 7004 7004 double start = CFAbsoluteTimeGetCurrent(); 7005 7005 #endif 7006 auto result = attributedString(*core(range)). autorelease();7006 auto result = attributedString(*core(range)).string.autorelease(); 7007 7007 #if !LOG_DISABLED 7008 7008 double duration = CFAbsoluteTimeGetCurrent() - start; … … 7015 7015 { 7016 7016 if (!startContainer || !endContainer) 7017 return [[[NSAttributedString alloc] init WithString:@""] autorelease];7017 return [[[NSAttributedString alloc] init] autorelease]; 7018 7018 return attributedString(WebCore::SimpleRange { { *core(startContainer), static_cast<unsigned>(startOffset) }, 7019 { *core(endContainer), static_cast<unsigned>(endOffset) } }). autorelease();7019 { *core(endContainer), static_cast<unsigned>(endOffset) } }).string.autorelease(); 7020 7020 } 7021 7021 … … 7024 7024 DOMDocument *document = [[self _frame] DOMDocument]; 7025 7025 if (!document) 7026 return [[[NSAttributedString alloc] init WithString:@""] autorelease];7026 return [[[NSAttributedString alloc] init] autorelease]; 7027 7027 if (auto attributedString = [self _attributedStringFromDOMRange:[document _documentRange]]) 7028 7028 return attributedString; 7029 return editingAttributedString(makeRangeSelectingNodeContents(*core(document))). autorelease();7029 return editingAttributedString(makeRangeSelectingNodeContents(*core(document))).string.autorelease(); 7030 7030 } 7031 7031 7032 7032 - (NSAttributedString *)selectedAttributedString 7033 7033 { 7034 RetainPtr<NSAttributedString> attributedString = [self _attributedStringFromDOMRange:[self _selectedRange]];7034 auto attributedString = retainPtr([self _attributedStringFromDOMRange:[self _selectedRange]]); 7035 7035 if (!attributedString) { 7036 7036 auto* coreFrame = core([self _frame]); … … 7038 7038 auto range = coreFrame->selection().selection().toNormalizedRange(); 7039 7039 if (range) 7040 attributedString = editingAttributedString(*range) ;7040 attributedString = editingAttributedString(*range).string; 7041 7041 else 7042 7042 attributedString = adoptNS([[NSAttributedString alloc] init]); -
trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm
r260725 r260739 521 521 popupInfo.options = lookupOptions; 522 522 523 auto attributedString = editingAttributedString(range, WebCore::IncludeImages::No) ;523 auto attributedString = editingAttributedString(range, WebCore::IncludeImages::No).string; 524 524 auto scaledAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[attributedString string]]); 525 525 NSFontManager *fontManager = [NSFontManager sharedFontManager];
Note: See TracChangeset
for help on using the changeset viewer.