Changeset 204508 in webkit


Ignore:
Timestamp:
Aug 16, 2016 9:56:07 AM (8 years ago)
Author:
Darin Adler
Message:

[Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
https://bugs.webkit.org/show_bug.cgi?id=160891

Reviewed by Anders Carlsson.

Source/WebCore:

  • WebCore.xcodeproj/project.pbxproj: Removed EditorCocoa.h.
  • editing/Editor.cpp: Removed member initialization for members now

initialized in the class definition.

  • editing/Editor.h: Added FragmentAndResources struct, createFragment

member function, and _WebCreateFragment function. Also initialize all the
scalar data members here instead of in the constructor.

  • editing/cocoa/EditorCocoa.h: Removed. This was unused.
  • editing/cocoa/EditorCocoa.mm:

(WebCore::Editor::createFragment): Added. Calls through to WebKitLegacy
using soft linking for now, but later should be implemented here in WebCore.

  • editing/ios/EditorIOS.mm:

(WebCore::Editor::createFragmentAndAddResources): Call createFragment.

  • editing/mac/EditorMac.mm:

(WebCore::Editor::createFragmentAndAddResources): Call createFragment.

  • loader/EmptyClients.h: Removed documentFragmentFromAttributedString

implementation.

  • page/EditorClient.h: Removed documentFragmentFromAttributedString.

Two reasons: The first is that this is now implemented in WebCore. While
there is a call through to WebKitLegacy, it's a temporary thing and done
with soft linking. The second reason is that this returned a raw pointer,
which is not safe in general. Was safe here because it was returning a
pointer owned by an autoreleased Objective-C object.

Source/WebKit/mac:

  • WebCoreSupport/WebEditorClient.h: Removed documentFragmentFromAttributedString.
  • WebCoreSupport/WebEditorClient.mm:

(attributesForAttributedStringConversion): Replaced the
createExcludedElementsForAttributedStringConversion function with this one.
No good reason to keep the array around instead of the dictionary.
(_WebCreateFragment): Renamed from documentFragmentFromAttributedString.
This is now a global function exported so it can be called by WebCore with
a different way of returning its value.

  • WebKit.exp: Added _WebCreateFragment.
  • WebView/WebHTMLView.mm:

(-[WebHTMLView _documentFragmentFromPasteboard:forType:inContext:subresources:]):
Removed long-ago-obsolete workaround for Radar bug 5052369.

Source/WebKit2:

  • WebProcess/WebCoreSupport/WebEditorClient.h: Removed documentFragmentFromAttributedString.
  • WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:

(WebKit::WebEditorClient::documentFragmentFromAttributedString): Deleted.

  • WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:

(WebKit::createExcludedElementsForAttributedStringConversion): Deleted.
(WebKit::WebEditorClient::documentFragmentFromAttributedString): Deleted.

Location:
trunk/Source
Files:
1 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r204506 r204508  
     12016-08-16  Darin Adler  <darin@apple.com>
     2
     3        [Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
     4        https://bugs.webkit.org/show_bug.cgi?id=160891
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebCore.xcodeproj/project.pbxproj: Removed EditorCocoa.h.
     9
     10        * editing/Editor.cpp: Removed member initialization for members now
     11        initialized in the class definition.
     12
     13        * editing/Editor.h: Added FragmentAndResources struct, createFragment
     14        member function, and _WebCreateFragment function. Also initialize all the
     15        scalar data members here instead of in the constructor.
     16
     17        * editing/cocoa/EditorCocoa.h: Removed. This was unused.
     18
     19        * editing/cocoa/EditorCocoa.mm:
     20        (WebCore::Editor::createFragment): Added. Calls through to WebKitLegacy
     21        using soft linking for now, but later should be implemented here in WebCore.
     22
     23        * editing/ios/EditorIOS.mm:
     24        (WebCore::Editor::createFragmentAndAddResources): Call createFragment.
     25
     26        * editing/mac/EditorMac.mm:
     27        (WebCore::Editor::createFragmentAndAddResources): Call createFragment.
     28
     29        * loader/EmptyClients.h: Removed documentFragmentFromAttributedString
     30        implementation.
     31
     32        * page/EditorClient.h: Removed documentFragmentFromAttributedString.
     33        Two reasons: The first is that this is now implemented in WebCore. While
     34        there is a call through to WebKitLegacy, it's a temporary thing and done
     35        with soft linking. The second reason is that this returned a raw pointer,
     36        which is not safe in general. Was safe here because it was returning a
     37        pointer owned by an autoreleased Objective-C object.
     38
    1392016-08-16  Brady Eidson  <beidson@apple.com>
    240
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r204501 r204508  
    1149411494                9B532EA21BA928570038A827 /* SlotAssignment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlotAssignment.h; sourceTree = "<group>"; };
    1149511495                9B55EEE81B3E8898005342BC /* EditorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditorCocoa.mm; sourceTree = "<group>"; };
    11496                 9B55EEEA1B3F3FEF005342BC /* EditorCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EditorCocoa.h; sourceTree = "<group>"; };
    1149711496                9B56C9A81C89312800C456DF /* LifecycleCallbackQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LifecycleCallbackQueue.h; sourceTree = "<group>"; };
    1149811497                9B56C9A91C89329A00C456DF /* LifecycleCallbackQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LifecycleCallbackQueue.cpp; sourceTree = "<group>"; };
     
    1834918348                                C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */,
    1835018349                                C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */,
    18351                                 9B55EEEA1B3F3FEF005342BC /* EditorCocoa.h */,
    1835218350                                9B55EEE81B3E8898005342BC /* EditorCocoa.mm */,
    1835318351                                7C3E510818DF8F3500C112F7 /* HTMLConverter.h */,
  • trunk/Source/WebCore/editing/Editor.cpp

    r203302 r204508  
    11091109Editor::Editor(Frame& frame)
    11101110    : m_frame(frame)
    1111     , m_ignoreCompositionSelectionChange(false)
    1112     // This is off by default, since most editors want this behavior (this matches IE but not FF).
    1113     , m_shouldStyleWithCSS(false)
    11141111    , m_killRing(std::make_unique<KillRing>())
    11151112    , m_spellChecker(std::make_unique<SpellChecker>(frame))
    11161113    , m_alternativeTextController(std::make_unique<AlternativeTextController>(frame))
    1117     , m_areMarkedTextMatchesHighlighted(false)
    1118     , m_defaultParagraphSeparator(EditorParagraphSeparatorIsDiv)
    1119     , m_overwriteModeEnabled(false)
    11201114    , m_editorUIUpdateTimer(*this, &Editor::editorUIUpdateTimerFired)
    1121     , m_editorUIUpdateTimerShouldCheckSpellingAndGrammar(false)
    1122     , m_editorUIUpdateTimerWasTriggeredByDictation(false)
    11231115#if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
    11241116    , m_telephoneNumberDetectionUpdateTimer(*this, &Editor::scanSelectionForTelephoneNumbers)
  • trunk/Source/WebCore/editing/Editor.h

    r202757 r204508  
    2424 */
    2525
    26 #ifndef Editor_h
    27 #define Editor_h
     26#pragma once
    2827
    2928#include "Color.h"
     
    9897};
    9998
     99#if PLATFORM(COCOA)
     100struct FragmentAndResources {
     101    RefPtr<DocumentFragment> fragment;
     102    Vector<RefPtr<ArchiveResource>> resources;
     103};
     104#endif
     105
    100106class Editor {
    101107    WTF_MAKE_FAST_ALLOCATED;
     
    198204    void unappliedSpellCorrection(const VisibleSelection& selectionOfCorrected, const String& corrected, const String& correction);
    199205
     206    // This is off by default, since most editors want this behavior (originally matched IE but not Firefox).
    200207    void setShouldStyleWithCSS(bool flag) { m_shouldStyleWithCSS = flag; }
    201208    bool shouldStyleWithCSS() const { return m_shouldStyleWithCSS; }
     
    266273#if !PLATFORM(IOS)
    267274    WEBCORE_EXPORT void advanceToNextMisspelling(bool startBeforeSelection = false);
    268 #endif // !PLATFORM(IOS)
     275#endif
    269276    void showSpellingGuessPanel();
    270277    bool spellingPanelIsShowing();
     
    499506    RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&);
    500507    RefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *);
     508    FragmentAndResources createFragment(NSAttributedString *);
    501509    void fillInUserVisibleForm(PasteboardURL&);
    502510#endif
     
    510518    unsigned m_compositionEnd;
    511519    Vector<CompositionUnderline> m_customCompositionUnderlines;
    512     bool m_ignoreCompositionSelectionChange;
    513     bool m_shouldStartNewKillRingSequence {false};
    514     bool m_shouldStyleWithCSS;
     520    bool m_ignoreCompositionSelectionChange { false };
     521    bool m_shouldStartNewKillRingSequence { false };
     522    bool m_shouldStyleWithCSS { false };
    515523    const std::unique_ptr<KillRing> m_killRing;
    516524    const std::unique_ptr<SpellChecker> m_spellChecker;
    517525    const std::unique_ptr<AlternativeTextController> m_alternativeTextController;
    518526    VisibleSelection m_mark;
    519     bool m_areMarkedTextMatchesHighlighted;
    520     EditorParagraphSeparator m_defaultParagraphSeparator;
    521     bool m_overwriteModeEnabled;
     527    bool m_areMarkedTextMatchesHighlighted { false };
     528    EditorParagraphSeparator m_defaultParagraphSeparator { EditorParagraphSeparatorIsDiv };
     529    bool m_overwriteModeEnabled { false };
    522530
    523531    VisibleSelection m_oldSelectionForEditorUIUpdate;
    524532    Timer m_editorUIUpdateTimer;
    525     bool m_editorUIUpdateTimerShouldCheckSpellingAndGrammar;
    526     bool m_editorUIUpdateTimerWasTriggeredByDictation;
     533    bool m_editorUIUpdateTimerShouldCheckSpellingAndGrammar { false };
     534    bool m_editorUIUpdateTimerWasTriggeredByDictation { false };
    527535    bool m_isHandlingAcceptedCandidate { false };
    528536
     
    558566} // namespace WebCore
    559567
    560 #endif // Editor_h
     568#if PLATFORM(COCOA)
     569// This function is declared here but defined in the WebKitLegacy framework.
     570// FIXME: Get rid of this and change this so it doesn't use WebKitLegacy.
     571extern "C" void _WebCreateFragment(WebCore::Document&, NSAttributedString *, WebCore::FragmentAndResources&);
     572#endif
  • trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm

    r203322 r204508  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2013, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#import "Editor.h"
    2828
     29#import "ArchiveResource.h"
    2930#import "CSSValueList.h"
    3031#import "CSSValuePool.h"
     32#import "DocumentFragment.h"
    3133#import "EditingStyle.h"
    3234#import "Frame.h"
     
    3941#import "htmlediting.h"
    4042
     43SOFT_LINK_FRAMEWORK(WebKitLegacy)
     44
     45SOFT_LINK(WebKitLegacy, _WebCreateFragment, void, (WebCore::Document& document, NSAttributedString *string, WebCore::FragmentAndResources& result), (document, string, result))
     46
    4147namespace WebCore {
    4248
    4349// FIXME: This figures out the current style by inserting a <span>!
    44 const RenderStyle* Editor::styleForSelectionStart(Frame* frame, Node *&nodeToRemove)
     50const RenderStyle* Editor::styleForSelectionStart(Frame* frame, Node*& nodeToRemove)
    4551{
    4652    nodeToRemove = nullptr;
     
    98104}
    99105
     106FragmentAndResources Editor::createFragment(NSAttributedString *string)
     107{
     108    // FIXME: The algorithm to convert an attributed string into HTML should be implemented here in WebCore.
     109    // For now, though, we call into WebKitLegacy, which in turn calls into AppKit/TextKit.
     110    FragmentAndResources result;
     111    _WebCreateFragment(*m_frame.document(), string, result);
     112    return result;
    100113}
     114
     115}
  • trunk/Source/WebCore/editing/ios/EditorIOS.mm

    r203482 r204508  
    567567        cachedResourceLoader.setImagesEnabled(false);
    568568
    569     Vector<RefPtr<ArchiveResource>> resources;
    570     RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources);
     569    auto fragmentAndResources = createFragment(string);
    571570
    572571    if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
    573         for (auto& resource : resources) {
     572        for (auto& resource : fragmentAndResources.resources) {
    574573            if (resource)
    575574                loader->addArchiveResource(resource.releaseNonNull());
     
    582581        m_frame.page()->setDefersLoading(false);
    583582   
    584     return fragment;
     583    return WTFMove(fragmentAndResources.fragment);
    585584}
    586585
  • trunk/Source/WebCore/editing/mac/EditorMac.mm

    r203322 r204508  
    660660        m_frame.page()->setDefersLoading(true);
    661661
    662     Vector<RefPtr<ArchiveResource>> resources;
    663     RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources);
     662    auto fragmentAndResources = createFragment(string);
    664663
    665664    if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
    666         for (auto& resource : resources) {
     665        for (auto& resource : fragmentAndResources.resources) {
    667666            if (resource)
    668667                loader->addArchiveResource(resource.releaseNonNull());
     
    673672        m_frame.page()->setDefersLoading(false);
    674673
    675     return fragment;
     674    return WTFMove(fragmentAndResources.fragment);
    676675}
    677676
  • trunk/Source/WebCore/loader/EmptyClients.h

    r204320 r204508  
    511511
    512512#if PLATFORM(COCOA)
    513     NSString* userVisibleString(NSURL*) override { return nullptr; }
    514     DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<RefPtr<ArchiveResource>>&) override { return nullptr; };
     513    NSString* userVisibleString(NSURL *) override { return nullptr; }
    515514    void setInsertionPasteboard(const String&) override { };
    516     NSURL *canonicalizeURL(NSURL*) override { return nullptr; }
    517     NSURL *canonicalizeURLString(NSString*) override { return nullptr; }
     515    NSURL *canonicalizeURL(NSURL *) override { return nullptr; }
     516    NSURL *canonicalizeURLString(NSString *) override { return nullptr; }
    518517#endif
    519518
  • trunk/Source/WebCore/page/EditorClient.h

    r201894 r204508  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
    44 *
     
    2525 */
    2626
    27 #ifndef EditorClient_h
    28 #define EditorClient_h
     27#pragma once
    2928
    3029#include "EditorInsertAction.h"
    31 #include "FloatRect.h"
    3230#include "TextAffinity.h"
    3331#include "TextChecking.h"
     
    3735
    3836#if PLATFORM(COCOA)
    39 OBJC_CLASS NSAttributedString;
    4037OBJC_CLASS NSString;
    4138OBJC_CLASS NSURL;
     
    144141#if PLATFORM(COCOA)
    145142    virtual NSString* userVisibleString(NSURL*) = 0;
    146     virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector< RefPtr<ArchiveResource>>&) = 0;
    147143    virtual void setInsertionPasteboard(const String& pasteboardName) = 0;
    148144    virtual NSURL* canonicalizeURL(NSURL*) = 0;
     
    191187
    192188}
    193 
    194 #endif // EditorClient_h
  • trunk/Source/WebKit/mac/ChangeLog

    r204482 r204508  
     12016-08-16  Darin Adler  <darin@apple.com>
     2
     3        [Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
     4        https://bugs.webkit.org/show_bug.cgi?id=160891
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebCoreSupport/WebEditorClient.h: Removed documentFragmentFromAttributedString.
     9
     10        * WebCoreSupport/WebEditorClient.mm:
     11        (attributesForAttributedStringConversion): Replaced the
     12        createExcludedElementsForAttributedStringConversion function with this one.
     13        No good reason to keep the array around instead of the dictionary.
     14        (_WebCreateFragment): Renamed from documentFragmentFromAttributedString.
     15        This is now a global function exported so it can be called by WebCore with
     16        a different way of returning its value.
     17
     18        * WebKit.exp: Added _WebCreateFragment.
     19
     20        * WebView/WebHTMLView.mm:
     21        (-[WebHTMLView _documentFragmentFromPasteboard:forType:inContext:subresources:]):
     22        Removed long-ago-obsolete workaround for Radar bug 5052369.
     23
    1242016-08-15  Anders Carlsson  <andersca@apple.com>
    225
  • trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h

    r201894 r204508  
    11/*
    2  * Copyright (C) 2006, 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
    44 *
     
    4444@class WebEditorUndoTarget;
    4545
    46 class WebEditorClient : public WebCore::EditorClient, public WebCore::TextCheckerClient {
     46class WebEditorClient final : public WebCore::EditorClient, public WebCore::TextCheckerClient {
    4747public:
    4848    WebEditorClient(WebView *);
     
    5252
    5353private:
    54     bool isGrammarCheckingEnabled() override;
    55     void toggleGrammarChecking() override;
    56     bool isContinuousSpellCheckingEnabled() override;
    57     void toggleContinuousSpellChecking() override;
    58     int spellCheckerDocumentTag() override;
    59 
    60     bool smartInsertDeleteEnabled() override;
    61     bool isSelectTrailingWhitespaceEnabled() override;
    62 
    63     bool shouldDeleteRange(WebCore::Range*) override;
    64 
    65     bool shouldBeginEditing(WebCore::Range*) override;
    66     bool shouldEndEditing(WebCore::Range*) override;
    67     bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) override;
    68     bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) override;
    69     bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) override;
    70 
    71     bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) override;
    72     void didApplyStyle() override;
    73 
    74     bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range* rangeToBeReplaced) override;
    75 
    76     void didBeginEditing() override;
    77     void didEndEditing() override;
    78     void willWriteSelectionToPasteboard(WebCore::Range*) override;
    79     void didWriteSelectionToPasteboard() override;
    80     void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) override;
    81 
    82     NSString *userVisibleString(NSURL *) override;
    83     WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource>>&) override;
    84     void setInsertionPasteboard(const String&) override;
    85     NSURL *canonicalizeURL(NSURL *) override;
    86     NSURL *canonicalizeURLString(NSString *) override;
     54    bool isGrammarCheckingEnabled() final;
     55    void toggleGrammarChecking() final;
     56    bool isContinuousSpellCheckingEnabled() final;
     57    void toggleContinuousSpellChecking() final;
     58    int spellCheckerDocumentTag() final;
     59
     60    bool smartInsertDeleteEnabled() final;
     61    bool isSelectTrailingWhitespaceEnabled() final;
     62
     63    bool shouldDeleteRange(WebCore::Range*) final;
     64
     65    bool shouldBeginEditing(WebCore::Range*) final;
     66    bool shouldEndEditing(WebCore::Range*) final;
     67    bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) final;
     68    bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) final;
     69    bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) final;
     70
     71    bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) final;
     72    void didApplyStyle() final;
     73
     74    bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range* rangeToBeReplaced) final;
     75
     76    void didBeginEditing() final;
     77    void didEndEditing() final;
     78    void willWriteSelectionToPasteboard(WebCore::Range*) final;
     79    void didWriteSelectionToPasteboard() final;
     80    void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final;
     81
     82    NSString *userVisibleString(NSURL *) final;
     83    void setInsertionPasteboard(const String&) final;
     84    NSURL *canonicalizeURL(NSURL *) final;
     85    NSURL *canonicalizeURLString(NSString *) final;
    8786   
    8887#if USE(APPKIT)
    89     void uppercaseWord() override;
    90     void lowercaseWord() override;
    91     void capitalizeWord() override;
     88    void uppercaseWord() final;
     89    void lowercaseWord() final;
     90    void capitalizeWord() final;
    9291#endif
    9392
    9493#if USE(AUTOMATIC_TEXT_REPLACEMENT)
    95     void showSubstitutionsPanel(bool show) override;
    96     bool substitutionsPanelIsShowing() override;
    97     void toggleSmartInsertDelete() override;
    98     bool isAutomaticQuoteSubstitutionEnabled() override;
    99     void toggleAutomaticQuoteSubstitution() override;
    100     bool isAutomaticLinkDetectionEnabled() override;
    101     void toggleAutomaticLinkDetection() override;
    102     bool isAutomaticDashSubstitutionEnabled() override;
    103     void toggleAutomaticDashSubstitution() override;
    104     bool isAutomaticTextReplacementEnabled() override;
    105     void toggleAutomaticTextReplacement() override;
    106     bool isAutomaticSpellingCorrectionEnabled() override;
    107     void toggleAutomaticSpellingCorrection() override;
    108 #endif
    109 
    110     TextCheckerClient* textChecker() override { return this; }
    111 
    112     void respondToChangedContents() override;
    113     void respondToChangedSelection(WebCore::Frame*) override;
    114     void didChangeSelectionAndUpdateLayout() override { }
    115     void discardedComposition(WebCore::Frame*) override;
    116 
    117     void registerUndoStep(PassRefPtr<WebCore::UndoStep>) override;
    118     void registerRedoStep(PassRefPtr<WebCore::UndoStep>) override;
    119     void clearUndoRedoOperations() override;
    120 
    121     bool canCopyCut(WebCore::Frame*, bool defaultValue) const override;
    122     bool canPaste(WebCore::Frame*, bool defaultValue) const override;
    123     bool canUndo() const override;
    124     bool canRedo() const override;
    125    
    126     void undo() override;
    127     void redo() override;
    128    
    129     void handleKeyboardEvent(WebCore::KeyboardEvent*) override;
    130     void handleInputMethodKeydown(WebCore::KeyboardEvent*) override;
    131 
    132     void textFieldDidBeginEditing(WebCore::Element*) override;
    133     void textFieldDidEndEditing(WebCore::Element*) override;
    134     void textDidChangeInTextField(WebCore::Element*) override;
    135     bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) override;
    136     void textWillBeDeletedInTextField(WebCore::Element*) override;
    137     void textDidChangeInTextArea(WebCore::Element*) override;
    138     void overflowScrollPositionChanged() override { };
    139 
    140 #if PLATFORM(IOS)
    141     void startDelayingAndCoalescingContentChangeNotifications() override;
    142     void stopDelayingAndCoalescingContentChangeNotifications() override;
    143     void writeDataToPasteboard(NSDictionary*) override;
    144     NSArray* supportedPasteboardTypesForCurrentSelection() override;
    145     NSArray* readDataFromPasteboard(NSString* type, int index) override;
    146     bool hasRichlyEditableSelection() override;
    147     int getPasteboardItemsCount() override;
    148     WebCore::DocumentFragment* documentFragmentFromDelegate(int index) override;
    149     bool performsTwoStepPaste(WebCore::DocumentFragment*) override;
    150     int pasteboardChangeCount() override;
    151 #endif
    152    
    153     bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
    154     void ignoreWordInSpellDocument(const String&) override;
    155     void learnWord(const String&) override;
    156     void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
    157     String getAutoCorrectSuggestionForMisspelledWord(const String&) override;
    158     void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
    159     Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) override;
    160     void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) override;
    161     void updateSpellingUIWithMisspelledWord(const String&) override;
    162     void showSpellingUI(bool show) override;
    163     bool spellingUIIsShowing() override;
    164     void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) override;
    165 
    166     void willSetInputMethodState() override;
    167     void setInputMethodState(bool enabled) override;
    168     void requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) override;
     94    void showSubstitutionsPanel(bool show) final;
     95    bool substitutionsPanelIsShowing() final;
     96    void toggleSmartInsertDelete() final;
     97    bool isAutomaticQuoteSubstitutionEnabled() final;
     98    void toggleAutomaticQuoteSubstitution() final;
     99    bool isAutomaticLinkDetectionEnabled() final;
     100    void toggleAutomaticLinkDetection() final;
     101    bool isAutomaticDashSubstitutionEnabled() final;
     102    void toggleAutomaticDashSubstitution() final;
     103    bool isAutomaticTextReplacementEnabled() final;
     104    void toggleAutomaticTextReplacement() final;
     105    bool isAutomaticSpellingCorrectionEnabled() final;
     106    void toggleAutomaticSpellingCorrection() final;
     107#endif
     108
     109    TextCheckerClient* textChecker() final { return this; }
     110
     111    void respondToChangedContents() final;
     112    void respondToChangedSelection(WebCore::Frame*) final;
     113    void didChangeSelectionAndUpdateLayout() final { }
     114    void discardedComposition(WebCore::Frame*) final;
     115
     116    void registerUndoStep(PassRefPtr<WebCore::UndoStep>) final;
     117    void registerRedoStep(PassRefPtr<WebCore::UndoStep>) final;
     118    void clearUndoRedoOperations() final;
     119
     120    bool canCopyCut(WebCore::Frame*, bool defaultValue) const final;
     121    bool canPaste(WebCore::Frame*, bool defaultValue) const final;
     122    bool canUndo() const final;
     123    bool canRedo() const final;
     124   
     125    void undo() final;
     126    void redo() final;
     127   
     128    void handleKeyboardEvent(WebCore::KeyboardEvent*) final;
     129    void handleInputMethodKeydown(WebCore::KeyboardEvent*) final;
     130
     131    void textFieldDidBeginEditing(WebCore::Element*) final;
     132    void textFieldDidEndEditing(WebCore::Element*) final;
     133    void textDidChangeInTextField(WebCore::Element*) final;
     134    bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) final;
     135    void textWillBeDeletedInTextField(WebCore::Element*) final;
     136    void textDidChangeInTextArea(WebCore::Element*) final;
     137    void overflowScrollPositionChanged() final { };
     138
     139#if PLATFORM(IOS)
     140    void startDelayingAndCoalescingContentChangeNotifications() final;
     141    void stopDelayingAndCoalescingContentChangeNotifications() final;
     142    void writeDataToPasteboard(NSDictionary*) final;
     143    NSArray* supportedPasteboardTypesForCurrentSelection() final;
     144    NSArray* readDataFromPasteboard(NSString* type, int index) final;
     145    bool hasRichlyEditableSelection() final;
     146    int getPasteboardItemsCount() final;
     147    WebCore::DocumentFragment* documentFragmentFromDelegate(int index) final;
     148    bool performsTwoStepPaste(WebCore::DocumentFragment*) final;
     149    int pasteboardChangeCount() final;
     150#endif
     151   
     152    bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const final;
     153    void ignoreWordInSpellDocument(const String&) final;
     154    void learnWord(const String&) final;
     155    void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) final;
     156    String getAutoCorrectSuggestionForMisspelledWord(const String&) final;
     157    void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) final;
     158    Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) final;
     159    void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) final;
     160    void updateSpellingUIWithMisspelledWord(const String&) final;
     161    void showSpellingUI(bool show) final;
     162    bool spellingUIIsShowing() final;
     163    void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) final;
     164
     165    void willSetInputMethodState() final;
     166    void setInputMethodState(bool enabled) final;
     167    void requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) final;
    169168
    170169#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    171     void requestCandidatesForSelection(const WebCore::VisibleSelection&) override;
     170    void requestCandidatesForSelection(const WebCore::VisibleSelection&) final;
    172171    void handleRequestedCandidates(NSInteger, NSArray<NSTextCheckingResult *> *);
    173     void handleAcceptedCandidateWithSoftSpaces(WebCore::TextCheckingResult) override;
     172    void handleAcceptedCandidateWithSoftSpaces(WebCore::TextCheckingResult) final;
    174173#endif
    175174
     
    178177    WebView *m_webView;
    179178    RetainPtr<WebEditorUndoTarget> m_undoTarget;
    180     bool m_haveUndoRedoOperations;
     179    bool m_haveUndoRedoOperations { false };
    181180    RefPtr<WebCore::TextCheckingRequest> m_textCheckingRequest;
    182 #if PLATFORM(IOS)
    183     bool m_delayingContentChangeNotifications;
    184     bool m_hasDelayedContentChangeNotification;
     181
     182#if PLATFORM(IOS)
     183    bool m_delayingContentChangeNotifications { false };
     184    bool m_hasDelayedContentChangeNotification { false };
    185185#endif
    186186
    187187    WebCore::VisibleSelection m_lastSelectionForRequestedCandidates;
     188
    188189#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    189190    RetainPtr<NSString> m_paragraphContextForCandidateRequest;
     
    195196};
    196197
    197 #if PLATFORM(COCOA)
    198198inline NSSelectionAffinity kit(WebCore::EAffinity affinity)
    199199{
     
    219219    return WebCore::EAffinity::UPSTREAM;
    220220}
    221 #endif
    222221
    223222#if PLATFORM(IOS)
  • trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm

    r201894 r204508  
    11/*
    2  * Copyright (C) 2006 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
    44 *
     
    3232#import "DOMCSSStyleDeclarationInternal.h"
    3333#import "DOMDocumentFragmentInternal.h"
     34#import "DOMDocumentInternal.h"
    3435#import "DOMHTMLElementInternal.h"
    3536#import "DOMHTMLInputElementInternal.h"
     
    99100
    100101@interface NSAttributedString (WebNSAttributedStringDetails)
    101 - (id)_initWithDOMRange:(DOMRange*)range;
    102 - (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources;
     102- (DOMDocumentFragment *)_documentFromRange:(NSRange)range document:(DOMDocument *)document documentAttributes:(NSDictionary *)attributes subresources:(NSArray **)subresources;
    103103@end
    104104
     
    160160
    161161@interface WebEditorUndoTarget : NSObject
    162 {
    163 }
    164162
    165163- (void)undoEditing:(id)arg;
     
    187185    : m_webView(webView)
    188186    , m_undoTarget(adoptNS([[WebEditorUndoTarget alloc] init]))
    189     , m_haveUndoRedoOperations(false)
    190 #if PLATFORM(IOS)
    191     , m_delayingContentChangeNotifications(0)
    192     , m_hasDelayedContentChangeNotification(0)
    193 #endif
    194187    , m_weakPtrFactory(this)
    195188{
     
    206199
    207200#if !PLATFORM(IOS)
     201
    208202void WebEditorClient::toggleContinuousSpellChecking()
    209203{
     
    225219    return [m_webView spellCheckerDocumentTag];
    226220}
     221
    227222#endif
    228223
     
    313308
    314309#if PLATFORM(IOS)
     310
    315311void WebEditorClient::startDelayingAndCoalescingContentChangeNotifications()
    316312{
     
    327323    m_hasDelayedContentChangeNotification = false;
    328324}
     325
    329326#endif
    330327
     
    419416}
    420417
    421 static NSArray *createExcludedElementsForAttributedStringConversion()
    422 {
    423     NSArray *elements = [[NSArray alloc] initWithObjects:
     418static NSDictionary *attributesForAttributedStringConversion()
     419{
     420    NSArray *excludedElements = [[NSArray alloc] initWithObjects:
    424421        // Omit style since we want style to be inline so the fragment can be easily inserted.
    425         @"style", 
     422        @"style",
    426423        // Omit xml so the result is not XHTML.
    427         @"xml", 
     424        @"xml",
    428425        // Omit tags that will get stripped when converted to a fragment anyway.
    429426        @"doctype", @"html", @"head", @"body",
     
    432429        // Omit object so no file attachments are part of the fragment.
    433430        @"object", nil];
    434     CFRetain(elements);
    435     return elements;
    436 }
    437431
    438432#if PLATFORM(IOS)
    439 static NSString *NSExcludedElementsDocumentAttribute = @"ExcludedElements";
    440 #endif
    441 
    442 DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *string, Vector<RefPtr<ArchiveResource>>& resources)
    443 {
    444     static NSArray *excludedElements = createExcludedElementsForAttributedStringConversion();
    445    
     433    static NSString * const NSExcludedElementsDocumentAttribute = @"ExcludedElements";
     434#endif
     435
    446436    NSDictionary *dictionary = [NSDictionary dictionaryWithObject:excludedElements forKey:NSExcludedElementsDocumentAttribute];
    447437
    448     NSArray *subResources;
     438    [excludedElements release];
     439
     440    return dictionary;
     441}
     442
     443void _WebCreateFragment(Document& document, NSAttributedString *string, FragmentAndResources& result)
     444{
     445    static NSDictionary *documentAttributes = [attributesForAttributedStringConversion() retain];
     446    NSArray *subresources;
    449447    DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length])
    450                                                       document:[[m_webView mainFrame] DOMDocument]
    451                                             documentAttributes:dictionary
    452                                                   subresources:&subResources];
    453     for (WebResource* resource in subResources)
    454         resources.append([resource _coreResource]);
    455 
    456     return core(fragment);
     448        document:kit(&document) documentAttributes:documentAttributes subresources:&subresources];
     449    result.fragment = core(fragment);
     450    for (WebResource* resource in subresources)
     451        result.resources.append([resource _coreResource]);
    457452}
    458453
     
    466461
    467462#if USE(APPKIT)
     463
    468464void WebEditorClient::uppercaseWord()
    469465{
     
    480476    [m_webView capitalizeWord:nil];
    481477}
     478
    482479#endif
    483480
    484481#if USE(AUTOMATIC_TEXT_REPLACEMENT)
     482
    485483void WebEditorClient::showSubstitutionsPanel(bool show)
    486484{
     
    551549    [m_webView toggleAutomaticSpellingCorrection:nil];
    552550}
     551
    553552#endif // USE(AUTOMATIC_TEXT_REPLACEMENT)
    554553
     
    613612   
    614613    NSUndoManager *undoManager = [m_webView undoManager];
     614
    615615#if PLATFORM(IOS)
    616     // While we are undoing, we shouldn't be asked to register another Undo operation, we shouldn't even be touching the DOM.  But
    617     // just in case this happens, return to avoid putting the undo manager into an inconsistent state.  Same for being
    618     // asked to register a Redo operation in the midst of another Redo.
     616    // While we are undoing, we shouldn't be asked to register another Undo operation, we shouldn't even be touching the DOM.
     617    // But just in case this happens, return to avoid putting the undo manager into an inconsistent state.
     618    // Same for being asked to register a Redo operation in the midst of another Redo.
    619619    if (([undoManager isUndoing] && !isRedo) || ([undoManager isRedoing] && isRedo))
    620620        return;
    621621#endif
     622
    622623    NSString *actionName = undoNameForEditAction(step->editingAction());
    623624    WebUndoStep *webEntry = [WebUndoStep stepWithUndoStep:step];
     
    818819}
    819820
    820 NSArray* WebEditorClient::supportedPasteboardTypesForCurrentSelection()
     821NSArray *WebEditorClient::supportedPasteboardTypesForCurrentSelection()
    821822{
    822823    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(supportedPasteboardTypesForCurrentSelection)])
     
    826827}
    827828
    828 NSArray* WebEditorClient::readDataFromPasteboard(NSString* type, int index)
     829NSArray *WebEditorClient::readDataFromPasteboard(NSString* type, int index)
    829830{
    830831    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(readDataFromPasteboard:withIndex:)])
     
    858859    }
    859860   
    860     return 0;
     861    return nullptr;
    861862}
    862863
     
    11331134
    11341135#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     1136
    11351137void WebEditorClient::requestCandidatesForSelection(const VisibleSelection& selection)
    11361138{
     
    12201222    frame->editor().handleAcceptedCandidate(acceptedCandidate);
    12211223}
     1224
    12221225#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    12231226
    12241227#if !PLATFORM(IOS)
     1228
    12251229@interface WebEditorSpellCheckResponder : NSObject
    12261230{
     
    12581262    m_textCheckingRequest = nullptr;
    12591263}
     1264
    12601265#endif
    12611266
  • trunk/Source/WebKit/mac/WebKit.exp

    r204482 r204508  
    103103_WebViewProgressStartedNotification
    104104_WebViewWillCloseNotification
     105__WebCreateFragment
    105106__WebHTMLViewPrintingMaximumShrinkFactor
    106107__WebHTMLViewPrintingMinimumShrinkFactor
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r202524 r204508  
    25582558    }
    25592559
    2560     // The _hasHTMLDocument clause here is a workaround for a bug in NSAttributedString: Radar 5052369.
    2561     // If we call _documentFromRange on an XML document we'll get "setInnerHTML: method not found".
    2562     // FIXME: Remove this once bug 5052369 is fixed.
    2563     if ([self _hasHTMLDocument] && (pboardType == NSRTFPboardType || pboardType == NSRTFDPboardType)) {
     2560    if (pboardType == NSRTFPboardType || pboardType == NSRTFDPboardType) {
    25642561        NSAttributedString *string = nil;
    25652562        if (pboardType == NSRTFDPboardType)
  • trunk/Source/WebKit2/ChangeLog

    r204506 r204508  
     12016-08-16  Darin Adler  <darin@apple.com>
     2
     3        [Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
     4        https://bugs.webkit.org/show_bug.cgi?id=160891
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebProcess/WebCoreSupport/WebEditorClient.h: Removed documentFragmentFromAttributedString.
     9        * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
     10        (WebKit::WebEditorClient::documentFragmentFromAttributedString): Deleted.
     11        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
     12        (WebKit::createExcludedElementsForAttributedStringConversion): Deleted.
     13        (WebKit::WebEditorClient::documentFragmentFromAttributedString): Deleted.
     14
    1152016-08-16  Brady Eidson  <beidson@apple.com>
    216
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h

    r201894 r204508  
    2424 */
    2525
    26 #ifndef WebEditorClient_h
    27 #define WebEditorClient_h
     26#pragma once
    2827
    2928#include <WebCore/EditorClient.h>
     
    3433class WebPage;
    3534
    36 class WebEditorClient : public WebCore::EditorClient, public WebCore::TextCheckerClient {
     35class WebEditorClient final : public WebCore::EditorClient, public WebCore::TextCheckerClient {
    3736public:
    3837    WebEditorClient(WebPage* page)
     
    4241
    4342private:
    44     bool shouldDeleteRange(WebCore::Range*) override;
    45     bool smartInsertDeleteEnabled() override;
    46     bool isSelectTrailingWhitespaceEnabled() override;
    47     bool isContinuousSpellCheckingEnabled() override;
    48     void toggleContinuousSpellChecking() override;
    49     bool isGrammarCheckingEnabled() override;
    50     void toggleGrammarChecking() override;
    51     int spellCheckerDocumentTag() override;
     43    bool shouldDeleteRange(WebCore::Range*) final;
     44    bool smartInsertDeleteEnabled() final;
     45    bool isSelectTrailingWhitespaceEnabled() final;
     46    bool isContinuousSpellCheckingEnabled() final;
     47    void toggleContinuousSpellChecking() final;
     48    bool isGrammarCheckingEnabled() final;
     49    void toggleGrammarChecking() final;
     50    int spellCheckerDocumentTag() final;
    5251   
    53     bool shouldBeginEditing(WebCore::Range*) override;
    54     bool shouldEndEditing(WebCore::Range*) override;
    55     bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) override;
    56     bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) override;
    57     bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) override;
     52    bool shouldBeginEditing(WebCore::Range*) final;
     53    bool shouldEndEditing(WebCore::Range*) final;
     54    bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) final;
     55    bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) final;
     56    bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) final;
    5857   
    59     bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) override;
    60     void didApplyStyle() override;
    61     bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*) override;
     58    bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) final;
     59    void didApplyStyle() final;
     60    bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*) final;
    6261
    63     void didBeginEditing() override;
    64     void respondToChangedContents() override;
    65     void respondToChangedSelection(WebCore::Frame*) override;
    66     void didChangeSelectionAndUpdateLayout() override;
    67     void discardedComposition(WebCore::Frame*) override;
    68     void didEndEditing() override;
    69     void willWriteSelectionToPasteboard(WebCore::Range*) override;
    70     void didWriteSelectionToPasteboard() override;
    71     void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) override;
     62    void didBeginEditing() final;
     63    void respondToChangedContents() final;
     64    void respondToChangedSelection(WebCore::Frame*) final;
     65    void didChangeSelectionAndUpdateLayout() final;
     66    void discardedComposition(WebCore::Frame*) final;
     67    void didEndEditing() final;
     68    void willWriteSelectionToPasteboard(WebCore::Range*) final;
     69    void didWriteSelectionToPasteboard() final;
     70    void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final;
    7271   
    73     void registerUndoStep(PassRefPtr<WebCore::UndoStep>) override;
    74     void registerRedoStep(PassRefPtr<WebCore::UndoStep>) override;
    75     void clearUndoRedoOperations() override;
     72    void registerUndoStep(PassRefPtr<WebCore::UndoStep>) final;
     73    void registerRedoStep(PassRefPtr<WebCore::UndoStep>) final;
     74    void clearUndoRedoOperations() final;
    7675
    77     bool canCopyCut(WebCore::Frame*, bool defaultValue) const override;
    78     bool canPaste(WebCore::Frame*, bool defaultValue) const override;
    79     bool canUndo() const override;
    80     bool canRedo() const override;
     76    bool canCopyCut(WebCore::Frame*, bool defaultValue) const final;
     77    bool canPaste(WebCore::Frame*, bool defaultValue) const final;
     78    bool canUndo() const final;
     79    bool canRedo() const final;
    8180   
    82     void undo() override;
    83     void redo() override;
     81    void undo() final;
     82    void redo() final;
    8483
    85     void handleKeyboardEvent(WebCore::KeyboardEvent*) override;
    86     void handleInputMethodKeydown(WebCore::KeyboardEvent*) override;
     84    void handleKeyboardEvent(WebCore::KeyboardEvent*) final;
     85    void handleInputMethodKeydown(WebCore::KeyboardEvent*) final;
    8786   
    88     void textFieldDidBeginEditing(WebCore::Element*) override;
    89     void textFieldDidEndEditing(WebCore::Element*) override;
    90     void textDidChangeInTextField(WebCore::Element*) override;
    91     bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) override;
    92     void textWillBeDeletedInTextField(WebCore::Element*) override;
    93     void textDidChangeInTextArea(WebCore::Element*) override;
    94     void overflowScrollPositionChanged() override;
     87    void textFieldDidBeginEditing(WebCore::Element*) final;
     88    void textFieldDidEndEditing(WebCore::Element*) final;
     89    void textDidChangeInTextField(WebCore::Element*) final;
     90    bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) final;
     91    void textWillBeDeletedInTextField(WebCore::Element*) final;
     92    void textDidChangeInTextArea(WebCore::Element*) final;
     93    void overflowScrollPositionChanged() final;
    9594
    9695#if PLATFORM(COCOA)
    97     NSString *userVisibleString(NSURL *) override;
    98     WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource>>&) override;
    99     void setInsertionPasteboard(const String& pasteboardName) override;
    100     NSURL* canonicalizeURL(NSURL*) override;
    101     NSURL* canonicalizeURLString(NSString*) override;
     96    NSString *userVisibleString(NSURL *) final;
     97    void setInsertionPasteboard(const String& pasteboardName) final;
     98    NSURL *canonicalizeURL(NSURL *) final;
     99    NSURL *canonicalizeURLString(NSString *) final;
    102100#endif
    103101
    104102#if USE(APPKIT)
    105     void uppercaseWord() override;
    106     void lowercaseWord() override;
    107     void capitalizeWord() override;
     103    void uppercaseWord() final;
     104    void lowercaseWord() final;
     105    void capitalizeWord() final;
    108106#endif
     107
    109108#if USE(AUTOMATIC_TEXT_REPLACEMENT)
    110     void showSubstitutionsPanel(bool show) override;
    111     bool substitutionsPanelIsShowing() override;
    112     void toggleSmartInsertDelete() override;
    113     bool isAutomaticQuoteSubstitutionEnabled() override;
    114     void toggleAutomaticQuoteSubstitution() override;
    115     bool isAutomaticLinkDetectionEnabled() override;
    116     void toggleAutomaticLinkDetection() override;
    117     bool isAutomaticDashSubstitutionEnabled() override;
    118     void toggleAutomaticDashSubstitution() override;
    119     bool isAutomaticTextReplacementEnabled() override;
    120     void toggleAutomaticTextReplacement() override;
    121     bool isAutomaticSpellingCorrectionEnabled() override;
    122     void toggleAutomaticSpellingCorrection() override;
     109    void showSubstitutionsPanel(bool show) final;
     110    bool substitutionsPanelIsShowing() final;
     111    void toggleSmartInsertDelete() final;
     112    bool isAutomaticQuoteSubstitutionEnabled() final;
     113    void toggleAutomaticQuoteSubstitution() final;
     114    bool isAutomaticLinkDetectionEnabled() final;
     115    void toggleAutomaticLinkDetection() final;
     116    bool isAutomaticDashSubstitutionEnabled() final;
     117    void toggleAutomaticDashSubstitution() final;
     118    bool isAutomaticTextReplacementEnabled() final;
     119    void toggleAutomaticTextReplacement() final;
     120    bool isAutomaticSpellingCorrectionEnabled() final;
     121    void toggleAutomaticSpellingCorrection() final;
    123122#endif
    124123
     
    129128#endif
    130129
    131     TextCheckerClient* textChecker()  override { return this; }
     130    TextCheckerClient* textChecker() final { return this; }
    132131
    133     bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
    134     void ignoreWordInSpellDocument(const String&) override;
    135     void learnWord(const String&) override;
    136     void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
    137     String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) override;
    138     void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
     132    bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const final;
     133    void ignoreWordInSpellDocument(const String&) final;
     134    void learnWord(const String&) final;
     135    void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) final;
     136    String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) final;
     137    void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) final;
     138
    139139#if USE(UNIFIED_TEXT_CHECKING)
    140     Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) override;
     140    Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) final;
    141141#endif
    142     void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) override;
    143     void updateSpellingUIWithMisspelledWord(const String&) override;
    144     void showSpellingUI(bool show) override;
    145     bool spellingUIIsShowing() override;
    146     void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) override;
    147     void willSetInputMethodState() override;
    148     void setInputMethodState(bool enabled) override;
    149     void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) override;
     142
     143    void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) final;
     144    void updateSpellingUIWithMisspelledWord(const String&) final;
     145    void showSpellingUI(bool show) final;
     146    bool spellingUIIsShowing() final;
     147    void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) final;
     148    void willSetInputMethodState() final;
     149    void setInputMethodState(bool enabled) final;
     150    void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) final;
    150151
    151152#if PLATFORM(GTK)
    152     bool shouldShowUnicodeMenu() override;
    153 #endif
    154 #if PLATFORM(IOS)
    155     void startDelayingAndCoalescingContentChangeNotifications() override;
    156     void stopDelayingAndCoalescingContentChangeNotifications() override;
    157     void writeDataToPasteboard(NSDictionary*) override;
    158     NSArray *supportedPasteboardTypesForCurrentSelection() override;
    159     NSArray *readDataFromPasteboard(NSString* type, int index) override;
    160     bool hasRichlyEditableSelection() override;
    161     int getPasteboardItemsCount() override;
    162     WebCore::DocumentFragment* documentFragmentFromDelegate(int index) override;
    163     bool performsTwoStepPaste(WebCore::DocumentFragment*) override;
    164     int pasteboardChangeCount() override;
     153    bool shouldShowUnicodeMenu() final;
    165154#endif
    166155
    167     bool supportsGlobalSelection() override;
     156#if PLATFORM(IOS)
     157    void startDelayingAndCoalescingContentChangeNotifications() final;
     158    void stopDelayingAndCoalescingContentChangeNotifications() final;
     159    void writeDataToPasteboard(NSDictionary*) final;
     160    NSArray *supportedPasteboardTypesForCurrentSelection() final;
     161    NSArray *readDataFromPasteboard(NSString* type, int index) final;
     162    bool hasRichlyEditableSelection() final;
     163    int getPasteboardItemsCount() final;
     164    WebCore::DocumentFragment* documentFragmentFromDelegate(int index) final;
     165    bool performsTwoStepPaste(WebCore::DocumentFragment*) final;
     166    int pasteboardChangeCount() final;
     167#endif
     168
     169    bool supportsGlobalSelection() final;
    168170
    169171    WebPage* m_page;
     
    171173
    172174} // namespace WebKit
    173 
    174 #endif // WebEditorClient_h
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm

    r198177 r204508  
    6464    notImplemented();
    6565    return nil;
    66 }
    67 
    68 DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *, Vector<RefPtr<ArchiveResource> >&)
    69 {
    70     notImplemented();
    71     return nullptr;
    7266}
    7367
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm

    r199565 r204508  
    11/*
    2  * Copyright (C) 2006, 2010, 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2010-2016 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
    44 *
     
    3333#if PLATFORM(MAC)
    3434
    35 #import "WebCoreArgumentCoders.h"
    3635#import "WebPage.h"
    37 #import "WebFrame.h"
    3836#import "WebPageProxyMessages.h"
    3937#import "WebProcess.h"
    40 #import <WebCore/ArchiveResource.h>
    41 #import <WebCore/DocumentFragment.h>
    42 #import <WebCore/DOMDocumentFragmentInternal.h>
    43 #import <WebCore/DOMDocumentInternal.h>
    4438#import <WebCore/FocusController.h>
    4539#import <WebCore/Frame.h>
    4640#import <WebCore/KeyboardEvent.h>
    47 #import <WebCore/MainFrame.h>
    4841#import <WebCore/NotImplemented.h>
    49 #import <WebCore/Page.h>
    5042#import <WebCore/WebCoreNSURLExtras.h>
    5143
    5244using namespace WebCore;
    53 
    54 @interface NSAttributedString (WebNSAttributedStringDetails)
    55 - (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources;
    56 @end
    57 
    58 @interface NSObject (WebResourceInternal)
    59 - (WebCore::ArchiveResource*)_coreResource;
    60 @end
    6145
    6246namespace WebKit {
     
    9175    return URL;
    9276}
    93    
    94 static NSArray *createExcludedElementsForAttributedStringConversion()
    95 {
    96     NSArray *elements = [[NSArray alloc] initWithObjects:
    97         // Omit style since we want style to be inline so the fragment can be easily inserted.
    98         @"style",
    99         // Omit xml so the result is not XHTML.
    100         @"xml",
    101         // Omit tags that will get stripped when converted to a fragment anyway.
    102         @"doctype", @"html", @"head", @"body",
    103         // Omit deprecated tags.
    104         @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u",
    105         // Omit object so no file attachments are part of the fragment.
    106         @"object", nil];
    107     CFRetain(elements);
    108     return elements;
    109 }
    110 
    111 DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *string, Vector<RefPtr<ArchiveResource>>& resources)
    112 {
    113     static NSArray *excludedElements = createExcludedElementsForAttributedStringConversion();
    114    
    115     NSDictionary *dictionary = [NSDictionary dictionaryWithObject:excludedElements forKey:NSExcludedElementsDocumentAttribute];
    116    
    117     NSArray *subResources;
    118     Document* document = m_page->mainFrame()->document();
    119 
    120     // FIXME: Isntead of calling this WebKit1 method, the code should be factored out and moved into WebCore.
    121     DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length])
    122                                                       document:kit(document)
    123                                             documentAttributes:dictionary
    124                                                   subresources:&subResources];
    125     for (id resource in subResources)
    126         resources.append([resource _coreResource]);
    127 
    128     return core(fragment);
    129 }
    13077
    13178void WebEditorClient::setInsertionPasteboard(const String&)
     
    13481    notImplemented();
    13582}
    136 
    13783
    13884static void changeWordCase(WebPage* page, SEL selector)
     
    14894}
    14995
    150 #if USE(APPKIT)
    15196void WebEditorClient::uppercaseWord()
    15297{
     
    163108    changeWordCase(m_page, @selector(capitalizedString));
    164109}
    165 #endif
    166110
    167111#if USE(AUTOMATIC_TEXT_REPLACEMENT)
     112
    168113void WebEditorClient::showSubstitutionsPanel(bool)
    169114{
     
    249194    notImplemented();
    250195}
     196
    251197#endif // USE(AUTOMATIC_TEXT_REPLACEMENT)
    252198
Note: See TracChangeset for help on using the changeset viewer.