Changeset 260739 in webkit


Ignore:
Timestamp:
Apr 26, 2020 10:12:55 PM (4 years ago)
Author:
Darin Adler
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.

Location:
trunk/Source
Files:
1 deleted
42 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r260738 r260739  
     12020-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
    1122020-04-26  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
    213
  • trunk/Source/WTF/wtf/cocoa/URLCocoa.mm

    r260679 r260739  
    6666    if (isEmpty()) {
    6767        // 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] initWithString:@""]).get();
     68        return (__bridge CFURLRef)adoptNS([[NSURL alloc] init]).get();
    6969    }
    7070
  • trunk/Source/WebCore/ChangeLog

    r260738 r260739  
     12020-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
    1392020-04-26  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
    240
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r260718 r260739  
    11811181$(PROJECT_DIR)/xml/xmlattrs.in
    11821182$(PROJECT_DIR)/xml/xmlnsattrs.in
     1183ApplePaySetup.idl
     1184ApplePaySetupFeature.idl
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r260736 r260739  
    27202720                93E241FF0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E241FE0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
    27212721                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, ); }; };
    27222723                93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23C02DE4396018635CA /* HTMLDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
    27232724                93F198E608245E59001E9ABC /* HTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23F02DE4396018635CA /* HTMLElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1094410945                93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLParserIdioms.h; sourceTree = "<group>"; };
    1094510946                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>"; };
    1094610948                93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventWithHitTestResults.cpp; sourceTree = "<group>"; };
    1094710949                93EEC1E509C2877700C515D1 /* Attr.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Attr.idl; sourceTree = "<group>"; };
     
    2158421586                                CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */,
    2158521587                                CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */,
     21588                                93E5B2632455E96F005C52D0 /* AttributedString.h */,
    2158621589                                5CCC270722D53B6900964FA0 /* AutofillElements.cpp */,
    2158721590                                5CCC270622D53B6800964FA0 /* AutofillElements.h */,
     
    2954629549                                A8C4A80B09D563270003AC8D /* Attribute.h in Headers */,
    2954729550                                E4A814DA1C70E10D00BF85AC /* AttributeChangeInvalidation.h in Headers */,
     29551                                93E5B2652455E96F005C52D0 /* AttributedString.h in Headers */,
    2954829552                                FD31607A12B026F700C1A359 /* AudioArray.h in Headers */,
    2954929553                                FD629EA3154B47160006D026 /* AudioBasicInspectorNode.h in Headers */,
  • trunk/Source/WebCore/editing/cocoa/AttributedString.h

    r260738 r260739  
    11/*
    2  * Copyright (C) 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "AttributedString.h"
     26#pragma once
    2827
    29 #import "ArgumentCodersCocoa.h"
    30 #import "Decoder.h"
    31 #import "Encoder.h"
     28#import <wtf/RetainPtr.h>
    3229
    33 namespace IPC {
     30OBJC_CLASS NSAttributedString;
    3431
    35 void ArgumentCoder<WebKit::AttributedString>::encode(Encoder& encoder, const WebKit::AttributedString& attributedString)
    36 {
    37     encoder << attributedString.string << attributedString.documentAttributes;
    38 }
     32namespace WebCore {
    3933
    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;
     34struct AttributedString {
     35    RetainPtr<NSAttributedString> string;
    4536    RetainPtr<NSDictionary> documentAttributes;
    46     if (!IPC::decode(decoder, documentAttributes))
    47         return WTF::nullopt;
    48     return { { WTFMove(attributedString), WTFMove(documentAttributes) } };
    49 }
     37};
    5038
    51 }
     39} // namespace WebCore
  • trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm

    r260725 r260739  
    3737#import "FrameSelection.h"
    3838#import "GraphicsContextCG.h"
    39 #import "HTMLConverter.h"
    4039#import "HitTestResult.h"
    4140#import "NotImplemented.h"
  • trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm

    r260725 r260739  
    109109{
    110110    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]);
    112112}
    113113
  • trunk/Source/WebCore/editing/cocoa/HTMLConverter.h

    r260725 r260739  
    2424 */
    2525
    26 #pragma once
    27 
    28 #import <wtf/Forward.h>
    29 
    30 OBJC_CLASS NSAttributedString;
     26#import "AttributedString.h"
     27#import "SimpleRange.h"
    3128
    3229namespace WebCore {
    3330
    34 struct SimpleRange;
    35 
    36 WEBCORE_EXPORT RetainPtr<NSAttributedString> attributedString(const SimpleRange&, RetainPtr<NSDictionary>* documentAttributes = nullptr);
     31WEBCORE_EXPORT AttributedString attributedString(const SimpleRange&);
    3732
    3833#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 the
     34// 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
    4136// text offsets will exactly match plain text and other editing machinery.
    4237// FIXME: This function and the one above should be merged.
    4338enum class IncludeImages { Yes, No };
    44 WEBCORE_EXPORT RetainPtr<NSAttributedString> editingAttributedString(const SimpleRange&, IncludeImages = IncludeImages::Yes);
     39WEBCORE_EXPORT AttributedString editingAttributedString(const SimpleRange&, IncludeImages = IncludeImages::Yes);
    4540#endif
    4641
  • trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm

    r260725 r260739  
    280280    ~HTMLConverter();
    281281
    282     RetainPtr<NSAttributedString> convert(RetainPtr<NSDictionary>* documentAttributes = nullptr);
     282    AttributedString convert();
    283283
    284284private:
     
    398398}
    399399
    400 RetainPtr<NSAttributedString> HTMLConverter::convert(RetainPtr<NSDictionary>* documentAttributes)
     400AttributedString HTMLConverter::convert()
    401401{
    402402    if (comparePositions(m_start, m_end) > 0)
    403         return nil;
     403        return { };
    404404
    405405    Node* commonAncestorContainer = _caches->cacheAncestorsOfStartToBeConverted(m_start, m_end);
     
    419419        [_attrStr deleteCharactersInRange:NSMakeRange(0, _domRangeStartIndex)];
    420420
    421     if (documentAttributes)
    422         *documentAttributes = _documentAttrs;
    423 
    424     return _attrStr;
     421    return { WTFMove(_attrStr), WTFMove(_documentAttrs) };
    425422}
    426423
     
    23692366
    23702367// 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);
     2368AttributedString attributedString(const SimpleRange& range)
     2369{
     2370    return HTMLConverter { range }.convert();
    23742371}
    23752372
     
    23772374
    23782375// 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];
     2376AttributedString 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]);
    23832381    NSUInteger stringLength = 0;
    2384     RetainPtr<NSMutableDictionary> attrs = adoptNS([[NSMutableDictionary alloc] init]);
    2385 
    23862382    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();
    24062392        if (!currentTextLength)
    24072393            continue;
    24082394
    2409         RenderObject* renderer = startContainer.renderer();
     2395        auto renderer = node->renderer();
    24102396        ASSERT(renderer);
    24112397        if (!renderer)
    24122398            continue;
    2413         const RenderStyle& style = renderer->style();
     2399        auto& style = renderer->style();
    24142400        if (style.textDecorationsInEffect() & TextDecoration::Underline)
    2415             [attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
     2401            [attrs setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
    24162402        if (style.textDecorationsInEffect() & TextDecoration::LineThrough)
    2417             [attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
     2403            [attrs setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
    24182404        if (auto font = style.fontCascade().primaryFont().getCTFont())
    2419             [attrs.get() setObject:toNSFont(font) forKey:NSFontAttributeName];
     2405            [attrs setObject:toNSFont(font) forKey:NSFontAttributeName];
    24202406        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];
    24222408
    24232409        Color foregroundColor = style.visitedDependentColorWithColorFilter(CSSPropertyColor);
    24242410        if (foregroundColor.isVisible())
    2425             [attrs.get() setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName];
     2411            [attrs setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName];
    24262412        else
    2427             [attrs.get() removeObjectForKey:NSForegroundColorAttributeName];
     2413            [attrs removeObjectForKey:NSForegroundColorAttributeName];
    24282414
    24292415        Color backgroundColor = style.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
    24302416        if (backgroundColor.isVisible())
    2431             [attrs.get() setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName];
     2417            [attrs setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName];
    24322418        else
    2433             [attrs.get() removeObjectForKey:NSBackgroundColorAttributeName];
     2419            [attrs removeObjectForKey:NSBackgroundColorAttributeName];
    24342420
    24352421        RetainPtr<NSString> text;
     
    24442430    }
    24452431
    2446     return [string autorelease];
     2432    return { WTFMove(string), nil };
    24472433}
    24482434
  • trunk/Source/WebCore/editing/ios/EditorIOS.mm

    r260707 r260739  
    3939#import "EditorClient.h"
    4040#import "Frame.h"
    41 #import "HTMLConverter.h"
    4241#import "HTMLInputElement.h"
    4342#import "HTMLNames.h"
  • trunk/Source/WebCore/editing/mac/DictionaryLookupLegacy.mm

    r260725 r260739  
    3434#import "Frame.h"
    3535#import "FrameSelection.h"
    36 #import "HTMLConverter.h"
    3736#import "HitTestResult.h"
    3837#import "Page.h"
  • trunk/Source/WebCore/editing/mac/EditorMac.mm

    r260725 r260739  
    5151#import "RuntimeApplicationChecks.h"
    5252#import "RuntimeEnabledFeatures.h"
    53 #import "SimpleRange.h"
    5453#import "StyleProperties.h"
    5554#import "WebContentReader.h"
     
    189188
    190189    if (pasteboardType == String(legacyRTFDPasteboardType()))
    191         return dataInRTFDFormat(attributedString(*adjustedSelectionRange()).get());
     190        return dataInRTFDFormat(attributedString(*adjustedSelectionRange()).string.get());
    192191
    193192    if (pasteboardType == String(legacyRTFPasteboardType())) {
    194         auto string = attributedString(*adjustedSelectionRange());
     193        auto string = attributedString(*adjustedSelectionRange()).string;
    195194        // FIXME: Why is this stripping needed here, but not in writeSelectionToPasteboard?
    196195        if ([string containsAttachments])
  • trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm

    r260485 r260739  
    234234static RetainPtr<NSDictionary> policyProperties(const SameSiteInfo& sameSiteInfo, NSURL *url)
    235235{
    236     static NSURL *emptyURL = [[NSURL alloc] initWithString:@""];
     236    static NSURL *emptyURL = [[NSURL alloc] init];
    237237    NSDictionary *policyProperties = @{
    238238        @"_kCFHTTPCookiePolicyPropertySiteForCookies": sameSiteInfo.isSameSite ? url : emptyURL,
  • trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm

    r260485 r260739  
    147147        return url;
    148148    case ResourceRequest::SameSiteDisposition::CrossSite:
    149         static NSURL *emptyURL = [[NSURL alloc] initWithString:@""];
     149        static NSURL *emptyURL = [[NSURL alloc] init];
    150150        return emptyURL;
    151151    }
  • trunk/Source/WebKit/ChangeLog

    r260736 r260739  
     12020-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
    1602020-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
    261
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

    r260707 r260739  
    183183        return;
    184184#if HAVE(FOUNDATION_WITH_SAME_SITE_COOKIE_SUPPORT)
    185     static NSURL *emptyURL = [[NSURL alloc] initWithString:@""];
     185    static NSURL *emptyURL = [[NSURL alloc] init];
    186186    task._siteForCookies = request.isSameSite() ? task.currentRequest.URL : emptyURL;
    187187    task._isTopLevelNavigation = request.isTopSite();
  • trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm

    r260717 r260739  
    2828
    2929#import "ArgumentCodersCocoa.h"
     30#import <WebCore/AttributedString.h>
    3031#import <WebCore/DictionaryPopupInfo.h>
    3132#import <WebCore/Font.h>
     
    4445namespace IPC {
    4546using namespace WebCore;
     47
     48void ArgumentCoder<WebCore::AttributedString>::encode(Encoder& encoder, const WebCore::AttributedString& attributedString)
     49{
     50    encoder << attributedString.string << attributedString.documentAttributes;
     51}
     52
     53Optional<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}
    4663
    4764#if ENABLE(APPLE_PAY)
  • trunk/Source/WebKit/Shared/DocumentEditingContext.h

    r252528 r260739  
    2929
    3030#include "ArgumentCoders.h"
    31 #include "AttributedString.h"
     31#include <WebCore/AttributedString.h>
    3232#include <WebCore/ElementContext.h>
    3333#include <WebCore/FloatRect.h>
     
    6464    UIWKDocumentContext *toPlatformContext(OptionSet<WebKit::DocumentEditingContextRequest::Options>);
    6565
    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;
    7171
    7272    struct Range {
  • trunk/Source/WebKit/Shared/DocumentEditingContext.mm

    r260366 r260739  
    132132    WebKit::DocumentEditingContext context;
    133133
    134     Optional<WebKit::AttributedString> contextBefore;
     134    Optional<WebCore::AttributedString> contextBefore;
    135135    decoder >> contextBefore;
    136136    if (!contextBefore)
     
    138138    context.contextBefore = *contextBefore;
    139139
    140     Optional<WebKit::AttributedString> selectedText;
     140    Optional<WebCore::AttributedString> selectedText;
    141141    decoder >> selectedText;
    142142    if (!selectedText)
     
    144144    context.selectedText = *selectedText;
    145145
    146     Optional<WebKit::AttributedString> contextAfter;
     146    Optional<WebCore::AttributedString> contextAfter;
    147147    decoder >> contextAfter;
    148148    if (!contextAfter)
     
    150150    context.contextAfter = *contextAfter;
    151151
    152     Optional<WebKit::AttributedString> markedText;
     152    Optional<WebCore::AttributedString> markedText;
    153153    decoder >> markedText;
    154154    if (!markedText)
     
    156156    context.markedText = *markedText;
    157157
    158     Optional<WebKit::AttributedString> annotatedText;
     158    Optional<WebCore::AttributedString> annotatedText;
    159159    decoder >> annotatedText;
    160160    if (!annotatedText)
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h

    r259937 r260739  
    117117class UserStyleSheet;
    118118
     119struct AttributedString;
    119120struct CacheQueryOptions;
    120121struct CharacterRange;
     
    210211};
    211212
     213template<> struct ArgumentCoder<WebCore::AttributedString> {
     214    static void encode(Encoder&, const WebCore::AttributedString&);
     215    static Optional<WebCore::AttributedString> decode(Decoder&);
     216};
     217
    212218template<> struct ArgumentCoder<WebCore::CacheQueryOptions> {
    213219    static void encode(Encoder&, const WebCore::CacheQueryOptions&);
  • trunk/Source/WebKit/SourcesCocoa.txt

    r260717 r260739  
    189189Shared/ios/WebTouchEventIOS.cpp
    190190
    191 Shared/mac/AttributedString.mm
    192191Shared/mac/AuxiliaryProcessMac.mm
    193192Shared/mac/CodeSigning.mm
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r260667 r260739  
    3131#import "APIPageConfiguration.h"
    3232#import "APISerializedScriptValue.h"
    33 #import "AttributedString.h"
    3433#import "CocoaImage.h"
    3534#import "CompletionHandlerCallChecker.h"
     
    117116#import "_WKVisitedLinkStoreInternal.h"
    118117#import "_WKWebsitePoliciesInternal.h"
     118#import <WebCore/AttributedString.h>
    119119#import <WebCore/ElementContext.h>
    120120#import <WebCore/JSDOMBinding.h>
  • trunk/Source/WebKit/UIProcess/Cocoa/TextCheckingController.mm

    r249275 r260739  
    2929#if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
    3030
    31 #import "AttributedString.h"
    3231#import "TextCheckingControllerProxyMessages.h"
    3332#import "WebProcessProxy.h"
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r260186 r260739  
    3333#import "APINavigation.h"
    3434#import "AppKitSPI.h"
    35 #import "AttributedString.h"
    3635#import "ColorSpaceData.h"
    3736#import "CoreTextHelpers.h"
     
    8382#import <WebCore/AXObjectCache.h>
    8483#import <WebCore/ActivityState.h>
     84#import <WebCore/AttributedString.h>
    8585#import <WebCore/ColorMac.h>
    8686#import <WebCore/CompositionHighlight.h>
     
    49524952
    49534953    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) {
    49554955        void (^completionHandlerBlock)(NSAttributedString *, NSRange) = (void (^)(NSAttributedString *, NSRange))completionHandler.get();
    49564956        if (error != WebKit::CallbackBase::Error::None) {
     
    49594959            return;
    49604960        }
    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);
    49644963    });
    49654964}
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r260709 r260739  
    201201
    202202#if PLATFORM(COCOA)
    203 #include "AttributedString.h"
    204203#include "InsertTextOptions.h"
    205204#include "RemoteLayerTreeDrawingAreaProxy.h"
     
    209208#include "VideoFullscreenManagerProxy.h"
    210209#include "VideoFullscreenManagerProxyMessages.h"
     210#include <WebCore/AttributedString.h>
    211211#include <WebCore/RunLoopObserver.h>
    212212#include <WebCore/TextIndicatorWindow.h>
     
    41164116
    41174117#if PLATFORM(COCOA)
    4118 void WebPageProxy::getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&& completionHandler)
     4118void WebPageProxy::getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&& completionHandler)
    41194119{
    41204120    if (!hasRunningProcess()) {
    4121         completionHandler(AttributedString());
     4121        completionHandler({ });
    41224122        return;
    41234123    }
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r260684 r260739  
    233233
    234234struct ApplicationManifest;
     235struct AttributedString;
    235236struct BackForwardItemIdentifier;
    236237struct CompositionHighlight;
     
    254255struct WindowFeatures;
    255256
    256 template <typename> class RectEdges;
     257template<typename> class RectEdges;
    257258using FloatBoxExtent = RectEdges<float>;
    258259}
     
    324325class WebsiteDataStore;
    325326
    326 struct AttributedString;
    327327struct WebBackForwardListCounts;
    328328struct ColorSpaceData;
     
    396396
    397397#if PLATFORM(MAC)
    398 typedef GenericCallback<const AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;
     398typedef GenericCallback<const WebCore::AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;
    399399typedef GenericCallback<const FontInfo&, double, bool> FontAtSelectionCallback;
    400400#endif
     
    882882
    883883#if PLATFORM(MAC)
    884     void attributedSubstringForCharacterRangeAsync(const EditingRange&, WTF::Function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>&&);
     884    void attributedSubstringForCharacterRangeAsync(const EditingRange&, Function<void(const WebCore::AttributedString&, const EditingRange&, CallbackBase::Error)>&&);
    885885    void fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&&);
    886886
     
    11041104    void getContentsAsString(ContentAsStringIncludesChildFrames, WTF::Function<void(const String&, CallbackBase::Error)>&&);
    11051105#if PLATFORM(COCOA)
    1106     void getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&&);
     1106    void getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&&);
    11071107#endif
    11081108    void getBytecodeProfile(WTF::Function<void (const String&, CallbackBase::Error)>&&);
     
    20802080    void rectForCharacterRangeCallback(const WebCore::IntRect&, const EditingRange&, CallbackID);
    20812081#if PLATFORM(MAC)
    2082     void attributedStringForCharacterRangeCallback(const AttributedString&, const EditingRange&, CallbackID);
     2082    void attributedStringForCharacterRangeCallback(const WebCore::AttributedString&, const EditingRange&, CallbackID);
    20832083    void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
    20842084#endif
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r260652 r260739  
    176176#endif
    177177#if PLATFORM(MAC)
    178     AttributedStringForCharacterRangeCallback(struct WebKit::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)
     178    AttributedStringForCharacterRangeCallback(struct WebCore::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)
    179179    FontAtSelectionCallback(struct WebKit::FontInfo fontInfo, double fontSize, bool selectionHasMultipleFonts, WebKit::CallbackID callbackID)
    180180#endif
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r260476 r260739  
    3030
    3131#import "APIUIClient.h"
    32 #import "AttributedString.h"
    3332#import "ColorSpaceData.h"
    3433#import "Connection.h"
     
    5150#import "WebPageMessages.h"
    5251#import "WebProcessProxy.h"
     52#import <WebCore/AttributedString.h>
    5353#import <WebCore/DictationAlternative.h>
    5454#import <WebCore/DictionaryLookup.h>
     
    187187}
    188188
    189 void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, WTF::Function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>&& callbackFunction)
     189void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, Function<void(const WebCore::AttributedString&, const EditingRange&, CallbackBase::Error)>&& callbackFunction)
    190190{
    191191    if (!hasRunningProcess()) {
    192         callbackFunction(AttributedString(), EditingRange(), CallbackBase::Error::Unknown);
     192        callbackFunction({ }, EditingRange(), CallbackBase::Error::Unknown);
    193193        return;
    194194    }
     
    199199}
    200200
    201 void WebPageProxy::attributedStringForCharacterRangeCallback(const AttributedString& string, const EditingRange& actualRange, CallbackID callbackID)
     201void WebPageProxy::attributedStringForCharacterRangeCallback(const WebCore::AttributedString& string, const EditingRange& actualRange, CallbackID callbackID)
    202202{
    203203    MESSAGE_CHECK(actualRange.isValid());
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r260718 r260739  
    17971797                E19582D3153CBFD700B60875 /* PDFKitImports.h in Headers */ = {isa = PBXBuildFile; fileRef = E19582D2153CBFD700B60875 /* PDFKitImports.h */; };
    17981798                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 */; };
    18001799                E1AEA22F14687BDB00804569 /* WKFullKeyboardAccessWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */; };
    18011800                E1B78471163F24690007B692 /* RemoteNetworkingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E1B78470163F24690007B692 /* RemoteNetworkingContext.h */; };
     
    52765275                E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.appstore.CodeRedeemerNetscapePlugin.sb; sourceTree = "<group>"; };
    52775276                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>"; };
    52805277                E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFullKeyboardAccessWatcher.h; sourceTree = "<group>"; };
    52815278                E1AEA22E14687BDB00804569 /* WKFullKeyboardAccessWatcher.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFullKeyboardAccessWatcher.mm; sourceTree = "<group>"; };
     
    93999396                        isa = PBXGroup;
    94009397                        children = (
    9401                                 E1A31731134CEA6C007C9A4F /* AttributedString.h */,
    9402                                 E1A31734134CEA80007C9A4F /* AttributedString.mm */,
    94039398                                9F54F88E16488E87007DF81A /* AuxiliaryProcessMac.mm */,
    94049399                                CE11AD511CBC482F00681EE5 /* CodeSigning.h */,
     
    1071910714                                AAFA634F234F7C6400FFA864 /* AsyncRevalidation.h in Headers */,
    1072010715                                BCEE966D112FAF57006BCC24 /* Attachment.h in Headers */,
    10721                                 E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */,
    1072210716                                512F589712A8838800629530 /* AuthenticationChallengeProxy.h in Headers */,
    1072310717                                512F589912A8838800629530 /* AuthenticationDecisionListener.h in Headers */,
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h

    r259401 r260739  
    2828#if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
    2929
    30 #include "AttributedString.h"
    3130#include "Connection.h"
    3231#include "EditingRange.h"
     
    4039
    4140namespace WebCore {
     41class AttributedString;
    4242class VisiblePosition;
    4343}
     
    5353    ~TextCheckingControllerProxy();
    5454
    55     static AttributedString annotatedSubstringBetweenPositions(const WebCore::VisiblePosition&, const WebCore::VisiblePosition&);
     55    static WebCore::AttributedString annotatedSubstringBetweenPositions(const WebCore::VisiblePosition&, const WebCore::VisiblePosition&);
    5656
    5757private:
     
    6666
    6767    // 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);
    6969    void removeAnnotationRelativeToSelection(const String& annotationName, int64_t selectionOffset, uint64_t length);
    7070
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in

    r252677 r260739  
    2424
    2525messages -> TextCheckingControllerProxy NotRefCounted {
    26     ReplaceRelativeToSelection(struct WebKit::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)
    2727
    2828    RemoveAnnotationRelativeToSelection(String annotationName, int64_t selectionOffset, uint64_t length)
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm

    r259575 r260739  
    9494}
    9595
    96 void TextCheckingControllerProxy::replaceRelativeToSelection(const AttributedString& annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength)
     96void TextCheckingControllerProxy::replaceRelativeToSelection(const WebCore::AttributedString& annotatedString, int64_t selectionOffset, uint64_t length, uint64_t relativeReplacementLocation, uint64_t relativeReplacementLength)
    9797{
    9898    Frame& frame = m_page.corePage()->focusController().focusedOrMainFrame();
     
    174174}
    175175
    176 AttributedString TextCheckingControllerProxy::annotatedSubstringBetweenPositions(const WebCore::VisiblePosition& start, const WebCore::VisiblePosition& end)
     176WebCore::AttributedString TextCheckingControllerProxy::annotatedSubstringBetweenPositions(const WebCore::VisiblePosition& start, const WebCore::VisiblePosition& end)
    177177{
    178178    auto startBoundary = makeBoundaryPoint(start);
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm

    r260725 r260739  
    2727#import "WebPage.h"
    2828
    29 #import "AttributedString.h"
    3029#import "InsertTextOptions.h"
    3130#import "LoadParameters.h"
     
    5251#import <WebCore/Range.h>
    5352#import <WebCore/RenderElement.h>
    54 #import <WebCore/SimpleRange.h>
    5553
    5654#if PLATFORM(COCOA)
     
    147145
    148146#if PLATFORM(MAC)
    149     auto attributedString = editingAttributedString(range, IncludeImages::No);
     147    auto attributedString = editingAttributedString(range, IncludeImages::No).string;
    150148    auto scaledAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[attributedString string]]);
    151149    NSFontManager *fontManager = [NSFontManager sharedFontManager];
     
    225223#endif
    226224
    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) });
     225void WebPage::getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&& completionHandler)
     226{
     227    completionHandler(attributedString(makeRangeSelectingNodeContents(*m_page->mainFrame().document())));
    238228}
    239229
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r260725 r260739  
    206206enum class WritingDirection : uint8_t;
    207207
     208struct AttributedString;
    208209struct BackForwardItemIdentifier;
    209210struct CompositionHighlight;
     
    280281enum class SyntheticEditingCommandType : uint8_t;
    281282
    282 struct AttributedString;
    283283struct BackForwardListItemState;
    284284struct DataDetectionResult;
     
    15041504    void getContentsAsString(ContentAsStringIncludesChildFrames, CallbackID);
    15051505#if PLATFORM(COCOA)
    1506     void getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&&);
     1506    void getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&&);
    15071507#endif
    15081508#if ENABLE(MHTML)
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r260684 r260739  
    201201    GetAllFrames() -> (struct WebKit::FrameTreeNodeData mainFrame) Async
    202202#if PLATFORM(COCOA)
    203     GetContentsAsAttributedString() -> (struct WebKit::AttributedString result) Async
     203    GetContentsAsAttributedString() -> (struct WebCore::AttributedString result) Async
    204204#endif
    205205#if ENABLE(MHTML)
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r260725 r260739  
    42634263    }
    42644264
    4265     auto makeString = [] (const VisiblePosition& start, const VisiblePosition& end) -> RetainPtr<NSAttributedString> {
     4265    auto makeString = [] (const VisiblePosition& start, const VisiblePosition& end) -> AttributedString {
    42664266        auto startBoundary = makeBoundaryPoint(start.deepEquivalent());
    42674267        auto endBoundary = makeBoundaryPoint(end.deepEquivalent());
    42684268        if (!startBoundary || !endBoundary || *startBoundary == *endBoundary)
    4269             return nil;
     4269            return { };
    42704270        // 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 };
    42724272    };
    42734273
    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);
    42774277    if (compositionRange && rangesOverlap(rangeOfInterest.get(), compositionRange.get())) {
    42784278        VisiblePosition compositionStart(compositionRange->startPosition());
    42794279        VisiblePosition compositionEnd(compositionRange->endPosition());
    4280         context.markedText = makeString(compositionStart, compositionEnd).get();
     4280        context.markedText = makeString(compositionStart, compositionEnd);
    42814281        context.selectedRangeInMarkedText.location = distanceBetweenPositions(startOfRangeOfInterestInSelection, compositionStart);
    42824282        context.selectedRangeInMarkedText.length = [context.selectedText.string length];
  • trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm

    r260725 r260739  
    2929#if PLATFORM(MAC)
    3030
    31 #import "AttributedString.h"
    3231#import "ContextMenuContextData.h"
    3332#import "DataReference.h"
     
    340339    }
    341340
    342     auto attributedString = editingAttributedString(*range, IncludeImages::No);
     341    auto attributedString = editingAttributedString(*range, IncludeImages::No).string;
    343342
    344343    // WebCore::editingAttributedStringFromRange() insists on inserting a trailing
     
    355354    if (!rangeToSend.isValid()) {
    356355        // 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));
    362361}
    363362
     
    811810        return;
    812811
    813     auto attributedSelection = attributedString(*range);
     812    auto attributedSelection = attributedString(*range).string;
    814813    if (!attributedSelection)
    815814        return;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r260725 r260739  
     12020-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
    1252020-04-11  Darin Adler  <darin@apple.com>
    226
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSelectionServiceController.mm

    r260725 r260739  
    3232#import <WebCore/HTMLConverter.h>
    3333#import <WebCore/Range.h>
    34 #import <WebCore/SimpleRange.h>
    3534#import <pal/spi/mac/NSSharingServiceSPI.h>
    3635
     
    5251        return;
    5352
    54     auto attributedSelection = attributedString(*range);
     53    auto attributedSelection = attributedString(*range).string;
    5554    if (!attributedSelection)
    5655        return;
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm

    r260725 r260739  
    270270{
    271271    if (!startNode || !endNode)
    272         return [[[NSAttributedString alloc] initWithString:@""] autorelease];
     272        return [[[NSAttributedString alloc] init] autorelease];
    273273    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();
    275275}
    276276
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

    r260725 r260739  
    63106310   
    63116311    // We have to return an empty string rather than null to prevent TSM from calling -string
    6312     return result ? result : [[[NSAttributedString alloc] initWithString:@""] autorelease];
     6312    return result ? result : [[[NSAttributedString alloc] init] autorelease];
    63136313}
    63146314
     
    64316431    }
    64326432
    6433     auto result = editingAttributedString(*range);
     6433    auto result = editingAttributedString(*range).string;
    64346434   
    64356435    // WebCore::editingAttributedStringFromRange() insists on inserting a trailing
     
    70047004    double start = CFAbsoluteTimeGetCurrent();
    70057005#endif
    7006     auto result = attributedString(*core(range)).autorelease();
     7006    auto result = attributedString(*core(range)).string.autorelease();
    70077007#if !LOG_DISABLED
    70087008    double duration = CFAbsoluteTimeGetCurrent() - start;
     
    70157015{
    70167016    if (!startContainer || !endContainer)
    7017         return [[[NSAttributedString alloc] initWithString:@""] autorelease];
     7017        return [[[NSAttributedString alloc] init] autorelease];
    70187018    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();
    70207020}
    70217021
     
    70247024    DOMDocument *document = [[self _frame] DOMDocument];
    70257025    if (!document)
    7026         return [[[NSAttributedString alloc] initWithString:@""] autorelease];
     7026        return [[[NSAttributedString alloc] init] autorelease];
    70277027    if (auto attributedString = [self _attributedStringFromDOMRange:[document _documentRange]])
    70287028        return attributedString;
    7029     return editingAttributedString(makeRangeSelectingNodeContents(*core(document))).autorelease();
     7029    return editingAttributedString(makeRangeSelectingNodeContents(*core(document))).string.autorelease();
    70307030}
    70317031
    70327032- (NSAttributedString *)selectedAttributedString
    70337033{
    7034     RetainPtr<NSAttributedString> attributedString = [self _attributedStringFromDOMRange:[self _selectedRange]];
     7034    auto attributedString = retainPtr([self _attributedStringFromDOMRange:[self _selectedRange]]);
    70357035    if (!attributedString) {
    70367036        auto* coreFrame = core([self _frame]);
     
    70387038            auto range = coreFrame->selection().selection().toNormalizedRange();
    70397039            if (range)
    7040                 attributedString = editingAttributedString(*range);
     7040                attributedString = editingAttributedString(*range).string;
    70417041            else
    70427042                attributedString = adoptNS([[NSAttributedString alloc] init]);
  • trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm

    r260725 r260739  
    521521    popupInfo.options = lookupOptions;
    522522
    523     auto attributedString = editingAttributedString(range, WebCore::IncludeImages::No);
     523    auto attributedString = editingAttributedString(range, WebCore::IncludeImages::No).string;
    524524    auto scaledAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[attributedString string]]);
    525525    NSFontManager *fontManager = [NSFontManager sharedFontManager];
Note: See TracChangeset for help on using the changeset viewer.