Title: [260739] trunk/Source
Revision
260739
Author
[email protected]
Date
2020-04-26 22:12:55 -0700 (Sun, 26 Apr 2020)

Log Message

[Cocoa] stop using out arguments for document attributes when converting to attributed strings
https://bugs.webkit.org/show_bug.cgi?id=211048

Reviewed by Sam Weinig.

Source/WebCore:

* DerivedSources-input.xcfilelist: Building modified this file automatically. Uploading
the new version.

* WebCore.xcodeproj/project.pbxproj: Added AttributedString.h.
* editing/cocoa/AttributedString.h: Added. Moved this from WebKit, but removed a lot of
inessentials.
* editing/cocoa/DictionaryLookup.mm: Removed unneeded include.
* editing/cocoa/EditorCocoa.mm:
(WebCore::selectionAsAttributedString): Updated for change to the return value of the
attributedString function, and use init instead of initWithString:@"".

* editing/cocoa/HTMLConverter.h: Changed to an Objective-C-only header, omitting things
like #pramga once. Return the AttributedString struct from the functions instead of
using an out argument for document attributes.
* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::convert): Return an AttributedString and drop the out argument.
(WebCore::attributedString): Ditto.
(WebCore::editingAttributedString): Ditto. Also refactor a little bit.

* editing/ios/EditorIOS.mm: Removed unneeded include.
* editing/mac/DictionaryLookupLegacy.mm: Removed unneeded include.

* editing/mac/EditorMac.mm:
(WebCore::Editor::dataSelectionForPasteboard): Updated since attributedString
now returns a structure.

* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::policyProperties): Use init instead of initWithString:@"".
* platform/network/cocoa/ResourceRequestCocoa.mm:
(WebCore::siteForCookies): Use init instead of initWithString:@"".

Source/WebKit:

* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::updateTaskWithFirstPartyForSameSiteCookies): Use init instead of initWithString:@"".

* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::AttributedString>::encode): Moved here from AttributedString.mm.
(IPC::ArgumentCoder<WebCore::AttributedString>::decode): Ditto.

* Shared/DocumentEditingContext.h: Updated to use WebCore::AttributeString.
* Shared/DocumentEditingContext.mm:
(IPC::ArgumentCoder<WebKit::DocumentEditingContext>::decode): Ditto.

* Shared/WebCoreArgumentCoders.h: Added coder for WebCore::AttributedString.

* Shared/mac/AttributedString.h: Removed.
* Shared/mac/AttributedString.mm: Removed.

* SourcesCocoa.txt: Removed AttributedString.mm.

* UIProcess/API/Cocoa/WKWebView.mm: Updated to use WebCore::AttributedString.
* UIProcess/Cocoa/TextCheckingController.mm: Ditto.
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::attributedSubstringForProposedRange): Ditto.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::getContentsAsAttributedString): Ditto.
* UIProcess/WebPageProxy.h: Ditto.
* UIProcess/WebPageProxy.messages.in: Ditto.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::attributedSubstringForCharacterRangeAsync): Ditto.
(WebKit::WebPageProxy::attributedStringForCharacterRangeCallback): Ditto.

* WebKit.xcodeproj/project.pbxproj: Removed AttributedString.h and AttributedString.mm.

* WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h: Updated to use WebCore::AttributedString.
* WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in: Ditto.
* WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:
(WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): Ditto.
(WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions): Ditto.

* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::dictionaryPopupInfoForRange): Updated since editingAttributedString
returns a struct.
(WebKit::WebPage::getContentsAsAttributedString): Updated to use SimpleRange and
since attributedString returns a struct.

* WebProcess/WebPage/WebPage.h: Updated to use WebCore::AttributedString.
* WebProcess/WebPage/WebPage.messages.in: Ditto.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestDocumentEditingContext): Ditto.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::attributedSubstringForCharacterRangeAsync): Ditto.
(WebKit::WebPage::handleSelectionServiceClick): Ditto.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebSelectionServiceController.mm:
(WebSelectionServiceController::handleSelectionServiceClick): Updated since
attributedString returns a struct.
* WebView/WebHTMLRepresentation.mm:
(-[WebHTMLRepresentation attributedStringFrom:startOffset:to:endOffset:]): Ditto.
Also use init instead of initWithString:@"".
* WebView/WebHTMLView.mm:
(-[WebHTMLView textStorage]): DItto.
(-[WebHTMLView attributedSubstringFromRange:]): Ditto.
(-[WebHTMLView _attributedStringFromDOMRange:]): Ditto.
(-[WebHTMLView _legacyAttributedStringFrom:offset:to:offset:]): Ditto.
(-[WebHTMLView attributedString]): Ditto.
(-[WebHTMLView selectedAttributedString]): Ditto.
* WebView/WebImmediateActionController.mm:
(+[WebImmediateActionController _dictionaryPopupInfoForRange:inFrame:withLookupOptions:indicatorOptions:transition:]):
Updated.

Source/WTF:

* wtf/cocoa/URLCocoa.mm:
(WTF::URL::createCFURL const): Use init instead of initWithString:@"". The two are
equivalent in more recent versions of Foundation.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (260738 => 260739)


--- trunk/Source/WTF/ChangeLog	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WTF/ChangeLog	2020-04-27 05:12:55 UTC (rev 260739)
@@ -1,3 +1,14 @@
+2020-04-26  Darin Adler  <[email protected]>
+
+        [Cocoa] stop using out arguments for document attributes when converting to attributed strings
+        https://bugs.webkit.org/show_bug.cgi?id=211048
+
+        Reviewed by Sam Weinig.
+
+        * wtf/cocoa/URLCocoa.mm:
+        (WTF::URL::createCFURL const): Use init instead of initWithString:@"". The two are
+        equivalent in more recent versions of Foundation.
+
 2020-04-26  Yoshiaki Jitsukawa  <[email protected]>
 
         [PlayStation] Enable TestWTF and TestWebCore

Modified: trunk/Source/WTF/wtf/cocoa/URLCocoa.mm (260738 => 260739)


--- trunk/Source/WTF/wtf/cocoa/URLCocoa.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WTF/wtf/cocoa/URLCocoa.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -65,7 +65,7 @@
 
     if (isEmpty()) {
         // We use the toll-free bridge between NSURL and CFURL to create a CFURLRef supporting both empty and null values.
-        return (__bridge CFURLRef)adoptNS([[NSURL alloc] initWithString:@""]).get();
+        return (__bridge CFURLRef)adoptNS([[NSURL alloc] init]).get();
     }
 
     RetainPtr<CFURLRef> cfURL;

Modified: trunk/Source/WebCore/ChangeLog (260738 => 260739)


--- trunk/Source/WebCore/ChangeLog	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/ChangeLog	2020-04-27 05:12:55 UTC (rev 260739)
@@ -1,3 +1,41 @@
+2020-04-26  Darin Adler  <[email protected]>
+
+        [Cocoa] stop using out arguments for document attributes when converting to attributed strings
+        https://bugs.webkit.org/show_bug.cgi?id=211048
+
+        Reviewed by Sam Weinig.
+
+        * DerivedSources-input.xcfilelist: Building modified this file automatically. Uploading
+        the new version.
+
+        * WebCore.xcodeproj/project.pbxproj: Added AttributedString.h.
+        * editing/cocoa/AttributedString.h: Added. Moved this from WebKit, but removed a lot of
+        inessentials.
+        * editing/cocoa/DictionaryLookup.mm: Removed unneeded include.
+        * editing/cocoa/EditorCocoa.mm:
+        (WebCore::selectionAsAttributedString): Updated for change to the return value of the
+        attributedString function, and use init instead of initWithString:@"".
+
+        * editing/cocoa/HTMLConverter.h: Changed to an Objective-C-only header, omitting things
+        like #pramga once. Return the AttributedString struct from the functions instead of
+        using an out argument for document attributes.
+        * editing/cocoa/HTMLConverter.mm:
+        (HTMLConverter::convert): Return an AttributedString and drop the out argument.
+        (WebCore::attributedString): Ditto.
+        (WebCore::editingAttributedString): Ditto. Also refactor a little bit.
+
+        * editing/ios/EditorIOS.mm: Removed unneeded include.
+        * editing/mac/DictionaryLookupLegacy.mm: Removed unneeded include.
+
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::dataSelectionForPasteboard): Updated since attributedString
+        now returns a structure.
+
+        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+        (WebCore::policyProperties): Use init instead of initWithString:@"".
+        * platform/network/cocoa/ResourceRequestCocoa.mm:
+        (WebCore::siteForCookies): Use init instead of initWithString:@"".
+
 2020-04-26  Yoshiaki Jitsukawa  <[email protected]>
 
         [PlayStation] Enable TestWTF and TestWebCore

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (260738 => 260739)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-04-27 05:12:55 UTC (rev 260739)
@@ -1180,3 +1180,5 @@
 $(PROJECT_DIR)/xml/XSLTProcessor.idl
 $(PROJECT_DIR)/xml/xmlattrs.in
 $(PROJECT_DIR)/xml/xmlnsattrs.in
+ApplePaySetup.idl
+ApplePaySetupFeature.idl

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (260738 => 260739)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-04-27 05:12:55 UTC (rev 260739)
@@ -2719,6 +2719,7 @@
 		93D9D53C0DA27E180077216C /* RangeBoundaryPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 93D9D53B0DA27E180077216C /* RangeBoundaryPoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93E241FF0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E241FE0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93E2A307123E9DC0009FE12A /* HTMLParserIdioms.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		93E5B2652455E96F005C52D0 /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E5B2632455E96F005C52D0 /* AttributedString.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23C02DE4396018635CA /* HTMLDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93F198E608245E59001E9ABC /* HTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23F02DE4396018635CA /* HTMLElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93F198F608245E59001E9ABC /* TextResourceDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D27902DE43D7018635CA /* TextResourceDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10943,6 +10944,7 @@
 		93E2A304123E9DC0009FE12A /* HTMLParserIdioms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserIdioms.cpp; sourceTree = "<group>"; };
 		93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLParserIdioms.h; sourceTree = "<group>"; };
 		93E5B25424536B1E005C52D0 /* URLDecomposition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLDecomposition.cpp; sourceTree = "<group>"; };
+		93E5B2632455E96F005C52D0 /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; };
 		93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventWithHitTestResults.cpp; sourceTree = "<group>"; };
 		93EEC1E509C2877700C515D1 /* Attr.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Attr.idl; sourceTree = "<group>"; };
 		93EEC1E609C2877700C515D1 /* CharacterData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CharacterData.idl; sourceTree = "<group>"; };
@@ -21583,6 +21585,7 @@
 				CE45946524121A050078019F /* AlternativeTextContextController.mm */,
 				CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */,
 				CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */,
+				93E5B2632455E96F005C52D0 /* AttributedString.h */,
 				5CCC270722D53B6900964FA0 /* AutofillElements.cpp */,
 				5CCC270622D53B6800964FA0 /* AutofillElements.h */,
 				C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */,
@@ -29545,6 +29548,7 @@
 				A8C4A80D09D563270003AC8D /* Attr.h in Headers */,
 				A8C4A80B09D563270003AC8D /* Attribute.h in Headers */,
 				E4A814DA1C70E10D00BF85AC /* AttributeChangeInvalidation.h in Headers */,
+				93E5B2652455E96F005C52D0 /* AttributedString.h in Headers */,
 				FD31607A12B026F700C1A359 /* AudioArray.h in Headers */,
 				FD629EA3154B47160006D026 /* AudioBasicInspectorNode.h in Headers */,
 				FD315FF712B0267600C1A359 /* AudioBasicProcessorNode.h in Headers */,

Copied: trunk/Source/WebCore/editing/cocoa/AttributedString.h (from rev 260738, trunk/Source/WebKit/Shared/mac/AttributedString.mm) (0 => 260739)


--- trunk/Source/WebCore/editing/cocoa/AttributedString.h	                        (rev 0)
+++ trunk/Source/WebCore/editing/cocoa/AttributedString.h	2020-04-27 05:12:55 UTC (rev 260739)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#import <wtf/RetainPtr.h>
+
+OBJC_CLASS NSAttributedString;
+
+namespace WebCore {
+
+struct AttributedString {
+    RetainPtr<NSAttributedString> string;
+    RetainPtr<NSDictionary> documentAttributes;
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm (260738 => 260739)


--- trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -36,7 +36,6 @@
 #import "Frame.h"
 #import "FrameSelection.h"
 #import "GraphicsContextCG.h"
-#import "HTMLConverter.h"
 #import "HitTestResult.h"
 #import "NotImplemented.h"
 #import "Page.h"

Modified: trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm (260738 => 260739)


--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -108,7 +108,7 @@
 static RetainPtr<NSAttributedString> selectionAsAttributedString(const Frame& frame)
 {
     auto range = frame.selection().selection().firstRange();
-    return range ? attributedString(*range) : adoptNS([[NSAttributedString alloc] initWithString:@""]);
+    return range ? attributedString(*range).string : adoptNS([[NSAttributedString alloc] init]);
 }
 
 void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard)

Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.h (260738 => 260739)


--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.h	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.h	2020-04-27 05:12:55 UTC (rev 260739)
@@ -23,25 +23,20 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#pragma once
+#import "AttributedString.h"
+#import "SimpleRange.h"
 
-#import <wtf/Forward.h>
-
-OBJC_CLASS NSAttributedString;
-
 namespace WebCore {
 
-struct SimpleRange;
+WEBCORE_EXPORT AttributedString attributedString(const SimpleRange&);
 
-WEBCORE_EXPORT RetainPtr<NSAttributedString> attributedString(const SimpleRange&, RetainPtr<NSDictionary>* documentAttributes = nullptr);
-
 #if PLATFORM(MAC)
-// This alternate implementation of HTML conversion doesn't handle as many
-// advanced features, such as tables, but it does use TextIterator so the
+// This alternate implementation of HTML conversion doesn't handle as many advanced features,
+// such as tables, and doesn't produce document attributes, but it does use TextIterator so
 // text offsets will exactly match plain text and other editing machinery.
 // FIXME: This function and the one above should be merged.
 enum class IncludeImages { Yes, No };
-WEBCORE_EXPORT RetainPtr<NSAttributedString> editingAttributedString(const SimpleRange&, IncludeImages = IncludeImages::Yes);
+WEBCORE_EXPORT AttributedString editingAttributedString(const SimpleRange&, IncludeImages = IncludeImages::Yes);
 #endif
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (260738 => 260739)


--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -279,7 +279,7 @@
     explicit HTMLConverter(const SimpleRange&);
     ~HTMLConverter();
 
-    RetainPtr<NSAttributedString> convert(RetainPtr<NSDictionary>* documentAttributes = nullptr);
+    AttributedString convert();
 
 private:
     Position m_start;
@@ -397,10 +397,10 @@
     [_writingDirectionArray release];
 }
 
-RetainPtr<NSAttributedString> HTMLConverter::convert(RetainPtr<NSDictionary>* documentAttributes)
+AttributedString HTMLConverter::convert()
 {
     if (comparePositions(m_start, m_end) > 0)
-        return nil;
+        return { };
 
     Node* commonAncestorContainer = _caches->cacheAncestorsOfStartToBeConverted(m_start, m_end);
     ASSERT(commonAncestorContainer);
@@ -418,10 +418,7 @@
     if (_domRangeStartIndex > 0 && _domRangeStartIndex <= [_attrStr length])
         [_attrStr deleteCharactersInRange:NSMakeRange(0, _domRangeStartIndex)];
 
-    if (documentAttributes)
-        *documentAttributes = _documentAttrs;
-
-    return _attrStr;
+    return { WTFMove(_attrStr), WTFMove(_documentAttrs) };
 }
 
 #if !PLATFORM(IOS_FAMILY)
@@ -2368,69 +2365,58 @@
 namespace WebCore {
 
 // This function supports more HTML features than the editing variant below, such as tables.
-RetainPtr<NSAttributedString> attributedString(const SimpleRange& range, RetainPtr<NSDictionary>* documentAttributes)
+AttributedString attributedString(const SimpleRange& range)
 {
-    return HTMLConverter { range }.convert(documentAttributes);
+    return HTMLConverter { range }.convert();
 }
 
 #if PLATFORM(MAC)
 
 // This function uses TextIterator, which makes offsets in its result compatible with HTML editing.
-RetainPtr<NSAttributedString> editingAttributedString(const SimpleRange& range, IncludeImages includeImages)
+AttributedString editingAttributedString(const SimpleRange& range, IncludeImages includeImages)
 {
-    NSFontManager *fontManager = [NSFontManager sharedFontManager];
-    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
+    auto fontManager = [NSFontManager sharedFontManager];
+    auto string = adoptNS([[NSMutableAttributedString alloc] init]);
+    auto attrs = adoptNS([[NSMutableDictionary alloc] init]);
     NSUInteger stringLength = 0;
-    RetainPtr<NSMutableDictionary> attrs = adoptNS([[NSMutableDictionary alloc] init]);
-
     for (TextIterator it(range); !it.atEnd(); it.advance()) {
-        SimpleRange currentTextRange = it.range();
-        Node& startContainer = currentTextRange.start.container;
-        Node& endContainer = currentTextRange.end.container;
-        int startOffset = currentTextRange.start.offset;
-        int endOffset = currentTextRange.end.offset;
+        auto node = it.node();
 
-        if (includeImages == IncludeImages::Yes) {
-            if (&startContainer == &endContainer && (startOffset == endOffset - 1)) {
-                Node* node = startContainer.traverseToChildAt(startOffset);
-                if (is<HTMLImageElement>(node)) {
-                    RetainPtr<NSFileWrapper> fileWrapper = fileWrapperForElement(downcast<HTMLImageElement>(*node));
-                    NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper.get()];
-                    [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
-                    [attachment release];
-                }
-            }
+        if (includeImages == IncludeImages::Yes && is<HTMLImageElement>(node)) {
+            auto fileWrapper = fileWrapperForElement(downcast<HTMLImageElement>(*node));
+            auto attachment = adoptNS([[NSTextAttachment alloc] initWithFileWrapper:fileWrapper.get()]);
+            [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment.get()]];
         }
 
-        int currentTextLength = it.text().length();
+        auto currentTextLength = it.text().length();
         if (!currentTextLength)
             continue;
 
-        RenderObject* renderer = startContainer.renderer();
+        auto renderer = node->renderer();
         ASSERT(renderer);
         if (!renderer)
             continue;
-        const RenderStyle& style = renderer->style();
+        auto& style = renderer->style();
         if (style.textDecorationsInEffect() & TextDecoration::Underline)
-            [attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
+            [attrs setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
         if (style.textDecorationsInEffect() & TextDecoration::LineThrough)
-            [attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
+            [attrs setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
         if (auto font = style.fontCascade().primaryFont().getCTFont())
-            [attrs.get() setObject:toNSFont(font) forKey:NSFontAttributeName];
+            [attrs setObject:toNSFont(font) forKey:NSFontAttributeName];
         else
-            [attrs.get() setObject:[fontManager convertFont:WebDefaultFont() toSize:style.fontCascade().primaryFont().platformData().size()] forKey:NSFontAttributeName];
+            [attrs setObject:[fontManager convertFont:WebDefaultFont() toSize:style.fontCascade().primaryFont().platformData().size()] forKey:NSFontAttributeName];
 
         Color foregroundColor = style.visitedDependentColorWithColorFilter(CSSPropertyColor);
         if (foregroundColor.isVisible())
-            [attrs.get() setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName];
+            [attrs setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName];
         else
-            [attrs.get() removeObjectForKey:NSForegroundColorAttributeName];
+            [attrs removeObjectForKey:NSForegroundColorAttributeName];
 
         Color backgroundColor = style.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
         if (backgroundColor.isVisible())
-            [attrs.get() setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName];
+            [attrs setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName];
         else
-            [attrs.get() removeObjectForKey:NSBackgroundColorAttributeName];
+            [attrs removeObjectForKey:NSBackgroundColorAttributeName];
 
         RetainPtr<NSString> text;
         if (style.nbspMode() == NBSPMode::Normal)
@@ -2443,7 +2429,7 @@
         stringLength += currentTextLength;
     }
 
-    return [string autorelease];
+    return { WTFMove(string), nil };
 }
 
 #endif

Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (260738 => 260739)


--- trunk/Source/WebCore/editing/ios/EditorIOS.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -38,7 +38,6 @@
 #import "Editing.h"
 #import "EditorClient.h"
 #import "Frame.h"
-#import "HTMLConverter.h"
 #import "HTMLInputElement.h"
 #import "HTMLNames.h"
 #import "HTMLParserIdioms.h"

Modified: trunk/Source/WebCore/editing/mac/DictionaryLookupLegacy.mm (260738 => 260739)


--- trunk/Source/WebCore/editing/mac/DictionaryLookupLegacy.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/editing/mac/DictionaryLookupLegacy.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -33,7 +33,6 @@
 #import "FocusController.h"
 #import "Frame.h"
 #import "FrameSelection.h"
-#import "HTMLConverter.h"
 #import "HitTestResult.h"
 #import "Page.h"
 #import "Range.h"

Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (260738 => 260739)


--- trunk/Source/WebCore/editing/mac/EditorMac.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -50,7 +50,6 @@
 #import "RenderImage.h"
 #import "RuntimeApplicationChecks.h"
 #import "RuntimeEnabledFeatures.h"
-#import "SimpleRange.h"
 #import "StyleProperties.h"
 #import "WebContentReader.h"
 #import "WebNSAttributedStringExtras.h"
@@ -188,10 +187,10 @@
         return selectionInWebArchiveFormat();
 
     if (pasteboardType == String(legacyRTFDPasteboardType()))
-        return dataInRTFDFormat(attributedString(*adjustedSelectionRange()).get());
+        return dataInRTFDFormat(attributedString(*adjustedSelectionRange()).string.get());
 
     if (pasteboardType == String(legacyRTFPasteboardType())) {
-        auto string = attributedString(*adjustedSelectionRange());
+        auto string = attributedString(*adjustedSelectionRange()).string;
         // FIXME: Why is this stripping needed here, but not in writeSelectionToPasteboard?
         if ([string containsAttachments])
             string = attributedStringByStrippingAttachmentCharacters(string.get());

Modified: trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm (260738 => 260739)


--- trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -233,7 +233,7 @@
 #if !(PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101400) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
 static RetainPtr<NSDictionary> policyProperties(const SameSiteInfo& sameSiteInfo, NSURL *url)
 {
-    static NSURL *emptyURL = [[NSURL alloc] initWithString:@""];
+    static NSURL *emptyURL = [[NSURL alloc] init];
     NSDictionary *policyProperties = @{
         @"_kCFHTTPCookiePolicyPropertySiteForCookies": sameSiteInfo.isSameSite ? url : emptyURL,
         @"_kCFHTTPCookiePolicyPropertyIsTopLevelNavigation": [NSNumber numberWithBool:sameSiteInfo.isTopSite],

Modified: trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm (260738 => 260739)


--- trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -146,7 +146,7 @@
     case ResourceRequest::SameSiteDisposition::SameSite:
         return url;
     case ResourceRequest::SameSiteDisposition::CrossSite:
-        static NSURL *emptyURL = [[NSURL alloc] initWithString:@""];
+        static NSURL *emptyURL = [[NSURL alloc] init];
         return emptyURL;
     }
 }

Modified: trunk/Source/WebKit/ChangeLog (260738 => 260739)


--- trunk/Source/WebKit/ChangeLog	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/ChangeLog	2020-04-27 05:12:55 UTC (rev 260739)
@@ -1,3 +1,62 @@
+2020-04-26  Darin Adler  <[email protected]>
+
+        [Cocoa] stop using out arguments for document attributes when converting to attributed strings
+        https://bugs.webkit.org/show_bug.cgi?id=211048
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::updateTaskWithFirstPartyForSameSiteCookies): Use init instead of initWithString:@"".
+
+        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+        (IPC::ArgumentCoder<WebCore::AttributedString>::encode): Moved here from AttributedString.mm.
+        (IPC::ArgumentCoder<WebCore::AttributedString>::decode): Ditto.
+
+        * Shared/DocumentEditingContext.h: Updated to use WebCore::AttributeString.
+        * Shared/DocumentEditingContext.mm:
+        (IPC::ArgumentCoder<WebKit::DocumentEditingContext>::decode): Ditto.
+
+        * Shared/WebCoreArgumentCoders.h: Added coder for WebCore::AttributedString.
+
+        * Shared/mac/AttributedString.h: Removed.
+        * Shared/mac/AttributedString.mm: Removed.
+
+        * SourcesCocoa.txt: Removed AttributedString.mm.
+
+        * UIProcess/API/Cocoa/WKWebView.mm: Updated to use WebCore::AttributedString.
+        * UIProcess/Cocoa/TextCheckingController.mm: Ditto.
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::attributedSubstringForProposedRange): Ditto.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::getContentsAsAttributedString): Ditto.
+        * UIProcess/WebPageProxy.h: Ditto.
+        * UIProcess/WebPageProxy.messages.in: Ditto.
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::attributedSubstringForCharacterRangeAsync): Ditto.
+        (WebKit::WebPageProxy::attributedStringForCharacterRangeCallback): Ditto.
+
+        * WebKit.xcodeproj/project.pbxproj: Removed AttributedString.h and AttributedString.mm.
+
+        * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h: Updated to use WebCore::AttributedString.
+        * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in: Ditto.
+        * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:
+        (WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): Ditto.
+        (WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions): Ditto.
+
+        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+        (WebKit::WebPage::dictionaryPopupInfoForRange): Updated since editingAttributedString
+        returns a struct.
+        (WebKit::WebPage::getContentsAsAttributedString): Updated to use SimpleRange and
+        since attributedString returns a struct.
+
+        * WebProcess/WebPage/WebPage.h: Updated to use WebCore::AttributedString.
+        * WebProcess/WebPage/WebPage.messages.in: Ditto.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::requestDocumentEditingContext): Ditto.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::attributedSubstringForCharacterRangeAsync): Ditto.
+        (WebKit::WebPage::handleSelectionServiceClick): Ditto.
+
 2020-04-26  Said Abou-Hallawa  <[email protected]>
 
         Rendering update steps should use Seconds for the timestamps

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (260738 => 260739)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -182,7 +182,7 @@
     if (request.isSameSiteUnspecified())
         return;
 #if HAVE(FOUNDATION_WITH_SAME_SITE_COOKIE_SUPPORT)
-    static NSURL *emptyURL = [[NSURL alloc] initWithString:@""];
+    static NSURL *emptyURL = [[NSURL alloc] init];
     task._siteForCookies = request.isSameSite() ? task.currentRequest.URL : emptyURL;
     task._isTopLevelNavigation = request.isTopSite();
 #else

Modified: trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (260738 => 260739)


--- trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -27,6 +27,7 @@
 #import "WebCoreArgumentCoders.h"
 
 #import "ArgumentCodersCocoa.h"
+#import <WebCore/AttributedString.h>
 #import <WebCore/DictionaryPopupInfo.h>
 #import <WebCore/Font.h>
 #import <WebCore/FontAttributes.h>
@@ -44,6 +45,22 @@
 namespace IPC {
 using namespace WebCore;
 
+void ArgumentCoder<WebCore::AttributedString>::encode(Encoder& encoder, const WebCore::AttributedString& attributedString)
+{
+    encoder << attributedString.string << attributedString.documentAttributes;
+}
+
+Optional<WebCore::AttributedString> ArgumentCoder<WebCore::AttributedString>::decode(Decoder& decoder)
+{
+    RetainPtr<NSAttributedString> attributedString;
+    if (!IPC::decode(decoder, attributedString))
+        return WTF::nullopt;
+    RetainPtr<NSDictionary> documentAttributes;
+    if (!IPC::decode(decoder, documentAttributes))
+        return WTF::nullopt;
+    return { { WTFMove(attributedString), WTFMove(documentAttributes) } };
+}
+
 #if ENABLE(APPLE_PAY)
 
 static bool finishDecoding(Decoder& decoder, WebCore::ApplePaySessionPaymentRequest& request)

Modified: trunk/Source/WebKit/Shared/DocumentEditingContext.h (260738 => 260739)


--- trunk/Source/WebKit/Shared/DocumentEditingContext.h	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/Shared/DocumentEditingContext.h	2020-04-27 05:12:55 UTC (rev 260739)
@@ -28,7 +28,7 @@
 #if PLATFORM(IOS_FAMILY)
 
 #include "ArgumentCoders.h"
-#include "AttributedString.h"
+#include <WebCore/AttributedString.h>
 #include <WebCore/ElementContext.h>
 #include <WebCore/FloatRect.h>
 #include <WebCore/TextGranularity.h>
@@ -63,11 +63,11 @@
 struct DocumentEditingContext {
     UIWKDocumentContext *toPlatformContext(OptionSet<WebKit::DocumentEditingContextRequest::Options>);
 
-    AttributedString contextBefore;
-    AttributedString selectedText;
-    AttributedString contextAfter;
-    AttributedString markedText;
-    AttributedString annotatedText;
+    WebCore::AttributedString contextBefore;
+    WebCore::AttributedString selectedText;
+    WebCore::AttributedString contextAfter;
+    WebCore::AttributedString markedText;
+    WebCore::AttributedString annotatedText;
 
     struct Range {
         uint64_t location { 0 };

Modified: trunk/Source/WebKit/Shared/DocumentEditingContext.mm (260738 => 260739)


--- trunk/Source/WebKit/Shared/DocumentEditingContext.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/Shared/DocumentEditingContext.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -131,31 +131,31 @@
 {
     WebKit::DocumentEditingContext context;
 
-    Optional<WebKit::AttributedString> contextBefore;
+    Optional<WebCore::AttributedString> contextBefore;
     decoder >> contextBefore;
     if (!contextBefore)
         return WTF::nullopt;
     context.contextBefore = *contextBefore;
 
-    Optional<WebKit::AttributedString> selectedText;
+    Optional<WebCore::AttributedString> selectedText;
     decoder >> selectedText;
     if (!selectedText)
         return WTF::nullopt;
     context.selectedText = *selectedText;
 
-    Optional<WebKit::AttributedString> contextAfter;
+    Optional<WebCore::AttributedString> contextAfter;
     decoder >> contextAfter;
     if (!contextAfter)
         return WTF::nullopt;
     context.contextAfter = *contextAfter;
 
-    Optional<WebKit::AttributedString> markedText;
+    Optional<WebCore::AttributedString> markedText;
     decoder >> markedText;
     if (!markedText)
         return WTF::nullopt;
     context.markedText = *markedText;
 
-    Optional<WebKit::AttributedString> annotatedText;
+    Optional<WebCore::AttributedString> annotatedText;
     decoder >> annotatedText;
     if (!annotatedText)
         return WTF::nullopt;

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (260738 => 260739)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2020-04-27 05:12:55 UTC (rev 260739)
@@ -116,6 +116,7 @@
 class TransformationMatrix;
 class UserStyleSheet;
 
+struct AttributedString;
 struct CacheQueryOptions;
 struct CharacterRange;
 struct CompositionUnderline;
@@ -209,6 +210,11 @@
     static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::AffineTransform&);
 };
 
+template<> struct ArgumentCoder<WebCore::AttributedString> {
+    static void encode(Encoder&, const WebCore::AttributedString&);
+    static Optional<WebCore::AttributedString> decode(Decoder&);
+};
+
 template<> struct ArgumentCoder<WebCore::CacheQueryOptions> {
     static void encode(Encoder&, const WebCore::CacheQueryOptions&);
     static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::CacheQueryOptions&);

Deleted: trunk/Source/WebKit/Shared/mac/AttributedString.h (260738 => 260739)


--- trunk/Source/WebKit/Shared/mac/AttributedString.h	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/Shared/mac/AttributedString.h	2020-04-27 05:12:55 UTC (rev 260739)
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "ArgumentCoders.h"
-#include <wtf/RetainPtr.h>
-
-OBJC_CLASS NSAttributedString;
-
-namespace WebKit {
-
-struct AttributedString {
-    RetainPtr<NSAttributedString> string;
-    RetainPtr<NSDictionary> documentAttributes;
-
-    AttributedString() = default;
-
-#if defined(__OBJC__)
-    AttributedString(NSAttributedString *attributedString, NSDictionary *documentAttributes = nil)
-        : string(attributedString)
-        , documentAttributes(documentAttributes)
-    {
-    }
-
-    AttributedString(RetainPtr<NSAttributedString>&& attributedString, RetainPtr<NSDictionary>&& documentAttributes = { })
-        : string(WTFMove(attributedString))
-        , documentAttributes(WTFMove(documentAttributes))
-    {
-    }
-
-    operator NSAttributedString *() const
-    {
-        return string.get();
-    }
-#endif
-};
-
-}
-
-namespace IPC {
-
-template<> struct ArgumentCoder<WebKit::AttributedString> {
-    static void encode(Encoder&, const WebKit::AttributedString&);
-    static Optional<WebKit::AttributedString> decode(Decoder&);
-};
-
-}

Deleted: trunk/Source/WebKit/Shared/mac/AttributedString.mm (260738 => 260739)


--- trunk/Source/WebKit/Shared/mac/AttributedString.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/Shared/mac/AttributedString.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "AttributedString.h"
-
-#import "ArgumentCodersCocoa.h"
-#import "Decoder.h"
-#import "Encoder.h"
-
-namespace IPC {
-
-void ArgumentCoder<WebKit::AttributedString>::encode(Encoder& encoder, const WebKit::AttributedString& attributedString)
-{
-    encoder << attributedString.string << attributedString.documentAttributes;
-}
-
-Optional<WebKit::AttributedString> ArgumentCoder<WebKit::AttributedString>::decode(Decoder& decoder)
-{
-    RetainPtr<NSAttributedString> attributedString;
-    if (!IPC::decode(decoder, attributedString))
-        return WTF::nullopt;
-    RetainPtr<NSDictionary> documentAttributes;
-    if (!IPC::decode(decoder, documentAttributes))
-        return WTF::nullopt;
-    return { { WTFMove(attributedString), WTFMove(documentAttributes) } };
-}
-
-}

Modified: trunk/Source/WebKit/SourcesCocoa.txt (260738 => 260739)


--- trunk/Source/WebKit/SourcesCocoa.txt	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2020-04-27 05:12:55 UTC (rev 260739)
@@ -188,7 +188,6 @@
 Shared/ios/WebPreferencesDefaultValuesIOS.mm
 Shared/ios/WebTouchEventIOS.cpp
 
-Shared/mac/AttributedString.mm
 Shared/mac/AuxiliaryProcessMac.mm
 Shared/mac/CodeSigning.mm
 Shared/mac/ColorSpaceData.mm

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (260738 => 260739)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -30,7 +30,6 @@
 #import "APIFrameTreeNode.h"
 #import "APIPageConfiguration.h"
 #import "APISerializedScriptValue.h"
-#import "AttributedString.h"
 #import "CocoaImage.h"
 #import "CompletionHandlerCallChecker.h"
 #import "ContentAsStringIncludesChildFrames.h"
@@ -116,6 +115,7 @@
 #import "_WKTextManipulationToken.h"
 #import "_WKVisitedLinkStoreInternal.h"
 #import "_WKWebsitePoliciesInternal.h"
+#import <WebCore/AttributedString.h>
 #import <WebCore/ElementContext.h>
 #import <WebCore/JSDOMBinding.h>
 #import <WebCore/JSDOMExceptionHandling.h>

Modified: trunk/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm (260738 => 260739)


--- trunk/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -28,7 +28,6 @@
 
 #if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
 
-#import "AttributedString.h"
 #import "TextCheckingControllerProxyMessages.h"
 #import "WebProcessProxy.h"
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (260738 => 260739)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -32,7 +32,6 @@
 #import "APILegacyContextHistoryClient.h"
 #import "APINavigation.h"
 #import "AppKitSPI.h"
-#import "AttributedString.h"
 #import "ColorSpaceData.h"
 #import "CoreTextHelpers.h"
 #import "FontInfo.h"
@@ -82,6 +81,7 @@
 #import <Carbon/Carbon.h>
 #import <WebCore/AXObjectCache.h>
 #import <WebCore/ActivityState.h>
+#import <WebCore/AttributedString.h>
 #import <WebCore/ColorMac.h>
 #import <WebCore/CompositionHighlight.h>
 #import <WebCore/DictionaryLookup.h>
@@ -4951,7 +4951,7 @@
     auto completionHandler = adoptNS([completionHandlerPtr copy]);
 
     LOG(TextInput, "attributedSubstringFromRange:(%u, %u)", proposedRange.location, proposedRange.length);
-    m_page->attributedSubstringForCharacterRangeAsync(proposedRange, [completionHandler](const AttributedString& string, const EditingRange& actualRange, WebKit::CallbackBase::Error error) {
+    m_page->attributedSubstringForCharacterRangeAsync(proposedRange, [completionHandler](const WebCore::AttributedString& string, const EditingRange& actualRange, WebKit::CallbackBase::Error error) {
         void (^completionHandlerBlock)(NSAttributedString *, NSRange) = (void (^)(NSAttributedString *, NSRange))completionHandler.get();
         if (error != WebKit::CallbackBase::Error::None) {
             LOG(TextInput, "    ...attributedSubstringFromRange failed.");
@@ -4958,9 +4958,8 @@
             completionHandlerBlock(0, NSMakeRange(NSNotFound, 0));
             return;
         }
-        NSAttributedString *attributedString = string;
-        LOG(TextInput, "    -> attributedSubstringFromRange returned %@", [attributedString string]);
-        completionHandlerBlock([[attributedString retain] autorelease], actualRange);
+        LOG(TextInput, "    -> attributedSubstringFromRange returned %@", string.string.get());
+        completionHandlerBlock(string.string.get(), actualRange);
     });
 }
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (260738 => 260739)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-04-27 05:12:55 UTC (rev 260739)
@@ -200,7 +200,6 @@
 #endif
 
 #if PLATFORM(COCOA)
-#include "AttributedString.h"
 #include "InsertTextOptions.h"
 #include "RemoteLayerTreeDrawingAreaProxy.h"
 #include "RemoteLayerTreeScrollingPerformanceData.h"
@@ -208,6 +207,7 @@
 #include "VersionChecks.h"
 #include "VideoFullscreenManagerProxy.h"
 #include "VideoFullscreenManagerProxyMessages.h"
+#include <WebCore/AttributedString.h>
 #include <WebCore/RunLoopObserver.h>
 #include <WebCore/TextIndicatorWindow.h>
 #include <wtf/MachSendRight.h>
@@ -4115,10 +4115,10 @@
 }
 
 #if PLATFORM(COCOA)
-void WebPageProxy::getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&& completionHandler)
+void WebPageProxy::getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&& completionHandler)
 {
     if (!hasRunningProcess()) {
-        completionHandler(AttributedString());
+        completionHandler({ });
         return;
     }
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (260738 => 260739)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-04-27 05:12:55 UTC (rev 260739)
@@ -232,6 +232,7 @@
 enum class WritingDirection : uint8_t;
 
 struct ApplicationManifest;
+struct AttributedString;
 struct BackForwardItemIdentifier;
 struct CompositionHighlight;
 struct ContentRuleListResults;
@@ -253,7 +254,7 @@
 struct ViewportAttributes;
 struct WindowFeatures;
 
-template <typename> class RectEdges;
+template<typename> class RectEdges;
 using FloatBoxExtent = RectEdges<float>;
 }
 
@@ -323,7 +324,6 @@
 class WebWheelEvent;
 class WebsiteDataStore;
 
-struct AttributedString;
 struct WebBackForwardListCounts;
 struct ColorSpaceData;
 struct DataDetectionResult;
@@ -395,7 +395,7 @@
 #endif
 
 #if PLATFORM(MAC)
-typedef GenericCallback<const AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;
+typedef GenericCallback<const WebCore::AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;
 typedef GenericCallback<const FontInfo&, double, bool> FontAtSelectionCallback;
 #endif
 
@@ -881,7 +881,7 @@
     void changeFont(WebCore::FontChanges&&);
 
 #if PLATFORM(MAC)
-    void attributedSubstringForCharacterRangeAsync(const EditingRange&, WTF::Function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>&&);
+    void attributedSubstringForCharacterRangeAsync(const EditingRange&, Function<void(const WebCore::AttributedString&, const EditingRange&, CallbackBase::Error)>&&);
     void fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&&);
 
     void startWindowDrag();
@@ -1103,7 +1103,7 @@
 
     void getContentsAsString(ContentAsStringIncludesChildFrames, WTF::Function<void(const String&, CallbackBase::Error)>&&);
 #if PLATFORM(COCOA)
-    void getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&&);
+    void getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&&);
 #endif
     void getBytecodeProfile(WTF::Function<void (const String&, CallbackBase::Error)>&&);
     void getSamplingProfilerOutput(WTF::Function<void (const String&, CallbackBase::Error)>&&);
@@ -2079,7 +2079,7 @@
 #endif
     void rectForCharacterRangeCallback(const WebCore::IntRect&, const EditingRange&, CallbackID);
 #if PLATFORM(MAC)
-    void attributedStringForCharacterRangeCallback(const AttributedString&, const EditingRange&, CallbackID);
+    void attributedStringForCharacterRangeCallback(const WebCore::AttributedString&, const EditingRange&, CallbackID);
     void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
 #endif
 #if PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (260738 => 260739)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2020-04-27 05:12:55 UTC (rev 260739)
@@ -175,7 +175,7 @@
     ApplicationManifestCallback(Optional<WebCore::ApplicationManifest> manifest, WebKit::CallbackID callbackID)
 #endif
 #if PLATFORM(MAC)
-    AttributedStringForCharacterRangeCallback(struct WebKit::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)
+    AttributedStringForCharacterRangeCallback(struct WebCore::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)
     FontAtSelectionCallback(struct WebKit::FontInfo fontInfo, double fontSize, bool selectionHasMultipleFonts, WebKit::CallbackID callbackID)
 #endif
     FontAttributesCallback(struct WebCore::FontAttributes attributes, WebKit::CallbackID callbackID)

Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (260738 => 260739)


--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -29,7 +29,6 @@
 #if PLATFORM(MAC)
 
 #import "APIUIClient.h"
-#import "AttributedString.h"
 #import "ColorSpaceData.h"
 #import "Connection.h"
 #import "DataReference.h"
@@ -50,6 +49,7 @@
 #import "WebContextMenuProxyMac.h"
 #import "WebPageMessages.h"
 #import "WebProcessProxy.h"
+#import <WebCore/AttributedString.h>
 #import <WebCore/DictationAlternative.h>
 #import <WebCore/DictionaryLookup.h>
 #import <WebCore/DragItem.h>
@@ -186,10 +186,10 @@
     process().send(Messages::WebPage::SetMainFrameIsScrollable(isScrollable), m_webPageID);
 }
 
-void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, WTF::Function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, Function<void(const WebCore::AttributedString&, const EditingRange&, CallbackBase::Error)>&& callbackFunction)
 {
     if (!hasRunningProcess()) {
-        callbackFunction(AttributedString(), EditingRange(), CallbackBase::Error::Unknown);
+        callbackFunction({ }, EditingRange(), CallbackBase::Error::Unknown);
         return;
     }
 
@@ -198,7 +198,7 @@
     process().send(Messages::WebPage::AttributedSubstringForCharacterRangeAsync(range, callbackID), m_webPageID);
 }
 
-void WebPageProxy::attributedStringForCharacterRangeCallback(const AttributedString& string, const EditingRange& actualRange, CallbackID callbackID)
+void WebPageProxy::attributedStringForCharacterRangeCallback(const WebCore::AttributedString& string, const EditingRange& actualRange, CallbackID callbackID)
 {
     MESSAGE_CHECK(actualRange.isValid());
 

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (260738 => 260739)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-04-27 05:12:55 UTC (rev 260739)
@@ -1796,7 +1796,6 @@
 		E18E6918169B667B009B6670 /* SecItemShimProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = E18E6914169B667B009B6670 /* SecItemShimProxyMessages.h */; };
 		E19582D3153CBFD700B60875 /* PDFKitImports.h in Headers */ = {isa = PBXBuildFile; fileRef = E19582D2153CBFD700B60875 /* PDFKitImports.h */; };
 		E19BDA86193665E300B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */; };
-		E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A31731134CEA6C007C9A4F /* AttributedString.h */; };
 		E1AEA22F14687BDB00804569 /* WKFullKeyboardAccessWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */; };
 		E1B78471163F24690007B692 /* RemoteNetworkingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E1B78470163F24690007B692 /* RemoteNetworkingContext.h */; };
 		E1CC1B9012D7EADF00625838 /* PrintInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CC1B8E12D7EADF00625838 /* PrintInfo.h */; };
@@ -5275,8 +5274,6 @@
 		E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebProcess.sb; path = DerivedSources/WebKit2/com.apple.WebProcess.sb; sourceTree = BUILT_PRODUCTS_DIR; };
 		E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.appstore.CodeRedeemerNetscapePlugin.sb; sourceTree = "<group>"; };
 		E19BDA88193686A400B97F57 /* SandboxUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxUtilities.h; sourceTree = "<group>"; };
-		E1A31731134CEA6C007C9A4F /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; };
-		E1A31734134CEA80007C9A4F /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = "<group>"; };
 		E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFullKeyboardAccessWatcher.h; sourceTree = "<group>"; };
 		E1AEA22E14687BDB00804569 /* WKFullKeyboardAccessWatcher.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFullKeyboardAccessWatcher.mm; sourceTree = "<group>"; };
 		E1B78470163F24690007B692 /* RemoteNetworkingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteNetworkingContext.h; sourceTree = "<group>"; };
@@ -9398,8 +9395,6 @@
 		BC111B5A112F628200337BAB /* mac */ = {
 			isa = PBXGroup;
 			children = (
-				E1A31731134CEA6C007C9A4F /* AttributedString.h */,
-				E1A31734134CEA80007C9A4F /* AttributedString.mm */,
 				9F54F88E16488E87007DF81A /* AuxiliaryProcessMac.mm */,
 				CE11AD511CBC482F00681EE5 /* CodeSigning.h */,
 				CE11AD4F1CBC47F800681EE5 /* CodeSigning.mm */,
@@ -10718,7 +10713,6 @@
 				515E7728183DD6F60007203F /* AsyncRequest.h in Headers */,
 				AAFA634F234F7C6400FFA864 /* AsyncRevalidation.h in Headers */,
 				BCEE966D112FAF57006BCC24 /* Attachment.h in Headers */,
-				E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */,
 				512F589712A8838800629530 /* AuthenticationChallengeProxy.h in Headers */,
 				512F589912A8838800629530 /* AuthenticationDecisionListener.h in Headers */,
 				518E8EF916B2091C00E91429 /* AuthenticationManager.h in Headers */,

Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h (260738 => 260739)


--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h	2020-04-27 05:12:55 UTC (rev 260739)
@@ -27,7 +27,6 @@
 
 #if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
 
-#include "AttributedString.h"
 #include "Connection.h"
 #include "EditingRange.h"
 #include "MessageReceiver.h"
@@ -39,6 +38,7 @@
 }
 
 namespace WebCore {
+class AttributedString;
 class VisiblePosition;
 }
 
@@ -52,7 +52,7 @@
     TextCheckingControllerProxy(WebPage&);
     ~TextCheckingControllerProxy();
 
-    static AttributedString annotatedSubstringBetweenPositions(const WebCore::VisiblePosition&, const WebCore::VisiblePosition&);
+    static WebCore::AttributedString annotatedSubstringBetweenPositions(const WebCore::VisiblePosition&, const WebCore::VisiblePosition&);
 
 private:
     // IPC::MessageReceiver
@@ -65,7 +65,7 @@
     Optional<RangeAndOffset> rangeAndOffsetRelativeToSelection(int64_t offset, uint64_t length);
 
     // Message handlers.
-    void replaceRelativeToSelection(const AttributedString&, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength);
+    void replaceRelativeToSelection(const WebCore::AttributedString&, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength);
     void removeAnnotationRelativeToSelection(const String& annotationName, int64_t selectionOffset, uint64_t length);
 
     WebPage& m_page;

Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in (260738 => 260739)


--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in	2020-04-27 05:12:55 UTC (rev 260739)
@@ -23,7 +23,7 @@
 #if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
 
 messages -> TextCheckingControllerProxy NotRefCounted {
-    ReplaceRelativeToSelection(struct WebKit::AttributedString annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength)
+    ReplaceRelativeToSelection(struct WebCore::AttributedString annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength)
 
     RemoveAnnotationRelativeToSelection(String annotationName, int64_t selectionOffset, uint64_t length)
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm (260738 => 260739)


--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -93,7 +93,7 @@
     return { { createLiveRange(resolveCharacterRange(scope, adjustedSelectionCharacterRange)), adjustedSelectionCharacterRange.location } };
 }
 
-void TextCheckingControllerProxy::replaceRelativeToSelection(const AttributedString& annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength)
+void TextCheckingControllerProxy::replaceRelativeToSelection(const WebCore::AttributedString& annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength)
 {
     Frame& frame = m_page.corePage()->focusController().focusedOrMainFrame();
     FrameSelection& frameSelection = frame.selection();
@@ -173,7 +173,7 @@
     }, types);
 }
 
-AttributedString TextCheckingControllerProxy::annotatedSubstringBetweenPositions(const WebCore::VisiblePosition& start, const WebCore::VisiblePosition& end)
+WebCore::AttributedString TextCheckingControllerProxy::annotatedSubstringBetweenPositions(const WebCore::VisiblePosition& start, const WebCore::VisiblePosition& end)
 {
     auto startBoundary = makeBoundaryPoint(start);
     auto endBoundary = makeBoundaryPoint(end);

Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (260738 => 260739)


--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -26,7 +26,6 @@
 #import "config.h"
 #import "WebPage.h"
 
-#import "AttributedString.h"
 #import "InsertTextOptions.h"
 #import "LoadParameters.h"
 #import "PluginView.h"
@@ -51,7 +50,6 @@
 #import <WebCore/PlatformMediaSessionManager.h>
 #import <WebCore/Range.h>
 #import <WebCore/RenderElement.h>
-#import <WebCore/SimpleRange.h>
 
 #if PLATFORM(COCOA)
 
@@ -146,7 +144,7 @@
     dictionaryPopupInfo.options = options;
 
 #if PLATFORM(MAC)
-    auto attributedString = editingAttributedString(range, IncludeImages::No);
+    auto attributedString = editingAttributedString(range, IncludeImages::No).string;
     auto scaledAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[attributedString string]]);
     NSFontManager *fontManager = [NSFontManager sharedFontManager];
     [attributedString enumerateAttributesInRange:NSMakeRange(0, [attributedString length]) options:0 usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) {
@@ -224,17 +222,9 @@
 }
 #endif
 
-void WebPage::getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&& completionHandler)
+void WebPage::getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&& completionHandler)
 {
-    auto* documentElement = m_page->mainFrame().document()->documentElement();
-    if (!documentElement) {
-        completionHandler({ });
-        return;
-    }
-
-    RetainPtr<NSDictionary> documentAttributes;
-    auto string = attributedString(rangeOfContents(*documentElement), &documentAttributes);
-    completionHandler({ WTFMove(string), WTFMove(documentAttributes) });
+    completionHandler(attributedString(makeRangeSelectingNodeContents(*m_page->mainFrame().document())));
 }
 
 void WebPage::setRemoteObjectRegistry(WebRemoteObjectRegistry* registry)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (260738 => 260739)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-04-27 05:12:55 UTC (rev 260739)
@@ -205,6 +205,7 @@
 enum class TextIndicatorPresentationTransition : uint8_t;
 enum class WritingDirection : uint8_t;
 
+struct AttributedString;
 struct BackForwardItemIdentifier;
 struct CompositionHighlight;
 struct CompositionUnderline;
@@ -279,7 +280,6 @@
 enum class DragControllerAction : uint8_t;
 enum class SyntheticEditingCommandType : uint8_t;
 
-struct AttributedString;
 struct BackForwardListItemState;
 struct DataDetectionResult;
 struct DocumentEditingContext;
@@ -1503,7 +1503,7 @@
 
     void getContentsAsString(ContentAsStringIncludesChildFrames, CallbackID);
 #if PLATFORM(COCOA)
-    void getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&&);
+    void getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&&);
 #endif
 #if ENABLE(MHTML)
     void getContentsAsMHTMLData(CallbackID);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (260738 => 260739)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-04-27 05:12:55 UTC (rev 260739)
@@ -200,7 +200,7 @@
     GetContentsAsString(enum:bool WebKit::ContentAsStringIncludesChildFrames inChildFrames, WebKit::CallbackID callbackID)
     GetAllFrames() -> (struct WebKit::FrameTreeNodeData mainFrame) Async
 #if PLATFORM(COCOA)
-    GetContentsAsAttributedString() -> (struct WebKit::AttributedString result) Async
+    GetContentsAsAttributedString() -> (struct WebCore::AttributedString result) Async
 #endif
 #if ENABLE(MHTML)
     GetContentsAsMHTMLData(WebKit::CallbackID callbackID)

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (260738 => 260739)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -4262,22 +4262,22 @@
         }
     }
 
-    auto makeString = [] (const VisiblePosition& start, const VisiblePosition& end) -> RetainPtr<NSAttributedString> {
+    auto makeString = [] (const VisiblePosition& start, const VisiblePosition& end) -> AttributedString {
         auto startBoundary = makeBoundaryPoint(start.deepEquivalent());
         auto endBoundary = makeBoundaryPoint(end.deepEquivalent());
         if (!startBoundary || !endBoundary || *startBoundary == *endBoundary)
-            return nil;
+            return { };
         // FIXME: This should return editing-offset-compatible attributed strings if that option is requested.
-        return adoptNS([[NSAttributedString alloc] initWithString:WebCore::plainTextReplacingNoBreakSpace({ WTFMove(*startBoundary), WTFMove(*endBoundary) })]);
+        return { adoptNS([[NSAttributedString alloc] initWithString:WebCore::plainTextReplacingNoBreakSpace({ WTFMove(*startBoundary), WTFMove(*endBoundary) })]), nil };
     };
 
-    context.contextBefore = makeString(contextBeforeStart, startOfRangeOfInterestInSelection).get();
-    context.selectedText = makeString(startOfRangeOfInterestInSelection, endOfRangeOfInterestInSelection).get();
-    context.contextAfter = makeString(endOfRangeOfInterestInSelection, contextAfterEnd).get();
+    context.contextBefore = makeString(contextBeforeStart, startOfRangeOfInterestInSelection);
+    context.selectedText = makeString(startOfRangeOfInterestInSelection, endOfRangeOfInterestInSelection);
+    context.contextAfter = makeString(endOfRangeOfInterestInSelection, contextAfterEnd);
     if (compositionRange && rangesOverlap(rangeOfInterest.get(), compositionRange.get())) {
         VisiblePosition compositionStart(compositionRange->startPosition());
         VisiblePosition compositionEnd(compositionRange->endPosition());
-        context.markedText = makeString(compositionStart, compositionEnd).get();
+        context.markedText = makeString(compositionStart, compositionEnd);
         context.selectedRangeInMarkedText.location = distanceBetweenPositions(startOfRangeOfInterestInSelection, compositionStart);
         context.selectedRangeInMarkedText.length = [context.selectedText.string length];
     }

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (260738 => 260739)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -28,7 +28,6 @@
 
 #if PLATFORM(MAC)
 
-#import "AttributedString.h"
 #import "ContextMenuContextData.h"
 #import "DataReference.h"
 #import "EditingRange.h"
@@ -339,7 +338,7 @@
         return;
     }
 
-    auto attributedString = editingAttributedString(*range, IncludeImages::No);
+    auto attributedString = editingAttributedString(*range, IncludeImages::No).string;
 
     // WebCore::editingAttributedStringFromRange() insists on inserting a trailing
     // whitespace at the end of the string which breaks the ATOK input method.  <rdar://problem/5400551>
@@ -354,11 +353,11 @@
     ASSERT(rangeToSend.isValid());
     if (!rangeToSend.isValid()) {
         // Send an empty EditingRange as a last resort for <rdar://problem/27078089>.
-        send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback(attributedString.get(), EditingRange(), callbackID));
+        send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback({ WTFMove(attributedString), nil }, EditingRange(), callbackID));
         return;
     }
 
-    send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback(attributedString.get(), rangeToSend, callbackID));
+    send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback({ WTFMove(attributedString), nil }, rangeToSend, callbackID));
 }
 
 void WebPage::fontAtSelection(CallbackID callbackID)
@@ -810,7 +809,7 @@
     if (!range)
         return;
 
-    auto attributedSelection = attributedString(*range);
+    auto attributedSelection = attributedString(*range).string;
     if (!attributedSelection)
         return;
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (260738 => 260739)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-04-27 05:12:55 UTC (rev 260739)
@@ -1,3 +1,27 @@
+2020-04-26  Darin Adler  <[email protected]>
+
+        [Cocoa] stop using out arguments for document attributes when converting to attributed strings
+        https://bugs.webkit.org/show_bug.cgi?id=211048
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/WebSelectionServiceController.mm:
+        (WebSelectionServiceController::handleSelectionServiceClick): Updated since
+        attributedString returns a struct.
+        * WebView/WebHTMLRepresentation.mm:
+        (-[WebHTMLRepresentation attributedStringFrom:startOffset:to:endOffset:]): Ditto.
+        Also use init instead of initWithString:@"".
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView textStorage]): DItto.
+        (-[WebHTMLView attributedSubstringFromRange:]): Ditto.
+        (-[WebHTMLView _attributedStringFromDOMRange:]): Ditto.
+        (-[WebHTMLView _legacyAttributedStringFrom:offset:to:offset:]): Ditto.
+        (-[WebHTMLView attributedString]): Ditto.
+        (-[WebHTMLView selectedAttributedString]): Ditto.
+        * WebView/WebImmediateActionController.mm:
+        (+[WebImmediateActionController _dictionaryPopupInfoForRange:inFrame:withLookupOptions:indicatorOptions:transition:]):
+        Updated.
+
 2020-04-11  Darin Adler  <[email protected]>
 
         Stop using live ranges in functions that return range of the selection

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSelectionServiceController.mm (260738 => 260739)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSelectionServiceController.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSelectionServiceController.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -31,7 +31,6 @@
 #import <WebCore/FrameSelection.h>
 #import <WebCore/HTMLConverter.h>
 #import <WebCore/Range.h>
-#import <WebCore/SimpleRange.h>
 #import <pal/spi/mac/NSSharingServiceSPI.h>
 
 using namespace WebCore;
@@ -51,7 +50,7 @@
     if (!range)
         return;
 
-    auto attributedSelection = attributedString(*range);
+    auto attributedSelection = attributedString(*range).string;
     if (!attributedSelection)
         return;
 

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm (260738 => 260739)


--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -269,9 +269,9 @@
 - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset
 {
     if (!startNode || !endNode)
-        return [[[NSAttributedString alloc] initWithString:@""] autorelease];
+        return [[[NSAttributedString alloc] init] autorelease];
     auto range = SimpleRange { { *core(startNode), static_cast<unsigned>(startOffset) }, { *core(endNode), static_cast<unsigned>(endOffset) } };
-    return editingAttributedString(range).autorelease();
+    return editingAttributedString(range).string.autorelease();
 }
 
 #endif

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (260738 => 260739)


--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -6309,7 +6309,7 @@
     LOG(TextInput, "textStorage -> \"%@\"", result ? [result string] : @"");
     
     // We have to return an empty string rather than null to prevent TSM from calling -string
-    return result ? result : [[[NSAttributedString alloc] initWithString:@""] autorelease];
+    return result ? result : [[[NSAttributedString alloc] init] autorelease];
 }
 
 #endif // PLATFORM(MAC)
@@ -6430,7 +6430,7 @@
         return nil;
     }
 
-    auto result = editingAttributedString(*range);
+    auto result = editingAttributedString(*range).string;
     
     // WebCore::editingAttributedStringFromRange() insists on inserting a trailing
     // whitespace at the end of the string which breaks the ATOK input method.  <rdar://problem/5400551>
@@ -7003,7 +7003,7 @@
 #if !LOG_DISABLED
     double start = CFAbsoluteTimeGetCurrent();
 #endif
-    auto result = attributedString(*core(range)).autorelease();
+    auto result = attributedString(*core(range)).string.autorelease();
 #if !LOG_DISABLED
     double duration = CFAbsoluteTimeGetCurrent() - start;
     LOG(Timing, "creating attributed string from selection took %f seconds.", duration);
@@ -7014,9 +7014,9 @@
 - (NSAttributedString *)_legacyAttributedStringFrom:(DOMNode *)startContainer offset:(int)startOffset to:(DOMNode *)endContainer offset:(int)endOffset
 {
     if (!startContainer || !endContainer)
-        return [[[NSAttributedString alloc] initWithString:@""] autorelease];
+        return [[[NSAttributedString alloc] init] autorelease];
     return attributedString(WebCore::SimpleRange { { *core(startContainer), static_cast<unsigned>(startOffset) },
-        { *core(endContainer), static_cast<unsigned>(endOffset) } }).autorelease();
+        { *core(endContainer), static_cast<unsigned>(endOffset) } }).string.autorelease();
 }
 
 - (NSAttributedString *)attributedString
@@ -7023,21 +7023,21 @@
 {
     DOMDocument *document = [[self _frame] DOMDocument];
     if (!document)
-        return [[[NSAttributedString alloc] initWithString:@""] autorelease];
+        return [[[NSAttributedString alloc] init] autorelease];
     if (auto attributedString = [self _attributedStringFromDOMRange:[document _documentRange]])
         return attributedString;
-    return editingAttributedString(makeRangeSelectingNodeContents(*core(document))).autorelease();
+    return editingAttributedString(makeRangeSelectingNodeContents(*core(document))).string.autorelease();
 }
 
 - (NSAttributedString *)selectedAttributedString
 {
-    RetainPtr<NSAttributedString> attributedString = [self _attributedStringFromDOMRange:[self _selectedRange]];
+    auto attributedString = retainPtr([self _attributedStringFromDOMRange:[self _selectedRange]]);
     if (!attributedString) {
         auto* coreFrame = core([self _frame]);
         if (coreFrame) {
             auto range = coreFrame->selection().selection().toNormalizedRange();
             if (range)
-                attributedString = editingAttributedString(*range);
+                attributedString = editingAttributedString(*range).string;
             else
                 attributedString = adoptNS([[NSAttributedString alloc] init]);
         }

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm (260738 => 260739)


--- trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm	2020-04-27 05:07:40 UTC (rev 260738)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm	2020-04-27 05:12:55 UTC (rev 260739)
@@ -520,7 +520,7 @@
     popupInfo.origin = NSMakePoint(rangeRect.x(), rangeRect.y() + scaledDescent);
     popupInfo.options = lookupOptions;
 
-    auto attributedString = editingAttributedString(range, WebCore::IncludeImages::No);
+    auto attributedString = editingAttributedString(range, WebCore::IncludeImages::No).string;
     auto scaledAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[attributedString string]]);
     NSFontManager *fontManager = [NSFontManager sharedFontManager];
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to