Changeset 204508 in webkit
- Timestamp:
- Aug 16, 2016 9:56:07 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r204506 r204508 1 2016-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 1 39 2016-08-16 Brady Eidson <beidson@apple.com> 2 40 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r204501 r204508 11494 11494 9B532EA21BA928570038A827 /* SlotAssignment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlotAssignment.h; sourceTree = "<group>"; }; 11495 11495 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>"; };11497 11496 9B56C9A81C89312800C456DF /* LifecycleCallbackQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LifecycleCallbackQueue.h; sourceTree = "<group>"; }; 11498 11497 9B56C9A91C89329A00C456DF /* LifecycleCallbackQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LifecycleCallbackQueue.cpp; sourceTree = "<group>"; }; … … 18349 18348 C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */, 18350 18349 C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */, 18351 9B55EEEA1B3F3FEF005342BC /* EditorCocoa.h */,18352 18350 9B55EEE81B3E8898005342BC /* EditorCocoa.mm */, 18353 18351 7C3E510818DF8F3500C112F7 /* HTMLConverter.h */, -
trunk/Source/WebCore/editing/Editor.cpp
r203302 r204508 1109 1109 Editor::Editor(Frame& frame) 1110 1110 : 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)1114 1111 , m_killRing(std::make_unique<KillRing>()) 1115 1112 , m_spellChecker(std::make_unique<SpellChecker>(frame)) 1116 1113 , m_alternativeTextController(std::make_unique<AlternativeTextController>(frame)) 1117 , m_areMarkedTextMatchesHighlighted(false)1118 , m_defaultParagraphSeparator(EditorParagraphSeparatorIsDiv)1119 , m_overwriteModeEnabled(false)1120 1114 , m_editorUIUpdateTimer(*this, &Editor::editorUIUpdateTimerFired) 1121 , m_editorUIUpdateTimerShouldCheckSpellingAndGrammar(false)1122 , m_editorUIUpdateTimerWasTriggeredByDictation(false)1123 1115 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS) 1124 1116 , m_telephoneNumberDetectionUpdateTimer(*this, &Editor::scanSelectionForTelephoneNumbers) -
trunk/Source/WebCore/editing/Editor.h
r202757 r204508 24 24 */ 25 25 26 #ifndef Editor_h 27 #define Editor_h 26 #pragma once 28 27 29 28 #include "Color.h" … … 98 97 }; 99 98 99 #if PLATFORM(COCOA) 100 struct FragmentAndResources { 101 RefPtr<DocumentFragment> fragment; 102 Vector<RefPtr<ArchiveResource>> resources; 103 }; 104 #endif 105 100 106 class Editor { 101 107 WTF_MAKE_FAST_ALLOCATED; … … 198 204 void unappliedSpellCorrection(const VisibleSelection& selectionOfCorrected, const String& corrected, const String& correction); 199 205 206 // This is off by default, since most editors want this behavior (originally matched IE but not Firefox). 200 207 void setShouldStyleWithCSS(bool flag) { m_shouldStyleWithCSS = flag; } 201 208 bool shouldStyleWithCSS() const { return m_shouldStyleWithCSS; } … … 266 273 #if !PLATFORM(IOS) 267 274 WEBCORE_EXPORT void advanceToNextMisspelling(bool startBeforeSelection = false); 268 #endif // !PLATFORM(IOS)275 #endif 269 276 void showSpellingGuessPanel(); 270 277 bool spellingPanelIsShowing(); … … 499 506 RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&); 500 507 RefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *); 508 FragmentAndResources createFragment(NSAttributedString *); 501 509 void fillInUserVisibleForm(PasteboardURL&); 502 510 #endif … … 510 518 unsigned m_compositionEnd; 511 519 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 }; 515 523 const std::unique_ptr<KillRing> m_killRing; 516 524 const std::unique_ptr<SpellChecker> m_spellChecker; 517 525 const std::unique_ptr<AlternativeTextController> m_alternativeTextController; 518 526 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 }; 522 530 523 531 VisibleSelection m_oldSelectionForEditorUIUpdate; 524 532 Timer m_editorUIUpdateTimer; 525 bool m_editorUIUpdateTimerShouldCheckSpellingAndGrammar ;526 bool m_editorUIUpdateTimerWasTriggeredByDictation ;533 bool m_editorUIUpdateTimerShouldCheckSpellingAndGrammar { false }; 534 bool m_editorUIUpdateTimerWasTriggeredByDictation { false }; 527 535 bool m_isHandlingAcceptedCandidate { false }; 528 536 … … 558 566 } // namespace WebCore 559 567 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. 571 extern "C" void _WebCreateFragment(WebCore::Document&, NSAttributedString *, WebCore::FragmentAndResources&); 572 #endif -
trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm
r203322 r204508 1 1 /* 2 * Copyright (C) 2006 , 2007, 2008, 2013, 2015Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #import "Editor.h" 28 28 29 #import "ArchiveResource.h" 29 30 #import "CSSValueList.h" 30 31 #import "CSSValuePool.h" 32 #import "DocumentFragment.h" 31 33 #import "EditingStyle.h" 32 34 #import "Frame.h" … … 39 41 #import "htmlediting.h" 40 42 43 SOFT_LINK_FRAMEWORK(WebKitLegacy) 44 45 SOFT_LINK(WebKitLegacy, _WebCreateFragment, void, (WebCore::Document& document, NSAttributedString *string, WebCore::FragmentAndResources& result), (document, string, result)) 46 41 47 namespace WebCore { 42 48 43 49 // FIXME: This figures out the current style by inserting a <span>! 44 const RenderStyle* Editor::styleForSelectionStart(Frame* frame, Node *&nodeToRemove)50 const RenderStyle* Editor::styleForSelectionStart(Frame* frame, Node*& nodeToRemove) 45 51 { 46 52 nodeToRemove = nullptr; … … 98 104 } 99 105 106 FragmentAndResources 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; 100 113 } 114 115 } -
trunk/Source/WebCore/editing/ios/EditorIOS.mm
r203482 r204508 567 567 cachedResourceLoader.setImagesEnabled(false); 568 568 569 Vector<RefPtr<ArchiveResource>> resources; 570 RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources); 569 auto fragmentAndResources = createFragment(string); 571 570 572 571 if (DocumentLoader* loader = m_frame.loader().documentLoader()) { 573 for (auto& resource : resources) {572 for (auto& resource : fragmentAndResources.resources) { 574 573 if (resource) 575 574 loader->addArchiveResource(resource.releaseNonNull()); … … 582 581 m_frame.page()->setDefersLoading(false); 583 582 584 return fragment;583 return WTFMove(fragmentAndResources.fragment); 585 584 } 586 585 -
trunk/Source/WebCore/editing/mac/EditorMac.mm
r203322 r204508 660 660 m_frame.page()->setDefersLoading(true); 661 661 662 Vector<RefPtr<ArchiveResource>> resources; 663 RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources); 662 auto fragmentAndResources = createFragment(string); 664 663 665 664 if (DocumentLoader* loader = m_frame.loader().documentLoader()) { 666 for (auto& resource : resources) {665 for (auto& resource : fragmentAndResources.resources) { 667 666 if (resource) 668 667 loader->addArchiveResource(resource.releaseNonNull()); … … 673 672 m_frame.page()->setDefersLoading(false); 674 673 675 return fragment;674 return WTFMove(fragmentAndResources.fragment); 676 675 } 677 676 -
trunk/Source/WebCore/loader/EmptyClients.h
r204320 r204508 511 511 512 512 #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; } 515 514 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; } 518 517 #endif 519 518 -
trunk/Source/WebCore/page/EditorClient.h
r201894 r204508 1 1 /* 2 * Copyright (C) 2006 , 2007Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 4 * … … 25 25 */ 26 26 27 #ifndef EditorClient_h 28 #define EditorClient_h 27 #pragma once 29 28 30 29 #include "EditorInsertAction.h" 31 #include "FloatRect.h"32 30 #include "TextAffinity.h" 33 31 #include "TextChecking.h" … … 37 35 38 36 #if PLATFORM(COCOA) 39 OBJC_CLASS NSAttributedString;40 37 OBJC_CLASS NSString; 41 38 OBJC_CLASS NSURL; … … 144 141 #if PLATFORM(COCOA) 145 142 virtual NSString* userVisibleString(NSURL*) = 0; 146 virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector< RefPtr<ArchiveResource>>&) = 0;147 143 virtual void setInsertionPasteboard(const String& pasteboardName) = 0; 148 144 virtual NSURL* canonicalizeURL(NSURL*) = 0; … … 191 187 192 188 } 193 194 #endif // EditorClient_h -
trunk/Source/WebKit/mac/ChangeLog
r204482 r204508 1 2016-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 1 24 2016-08-15 Anders Carlsson <andersca@apple.com> 2 25 -
trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h
r201894 r204508 1 1 /* 2 * Copyright (C) 2006 , 2014Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 4 * … … 44 44 @class WebEditorUndoTarget; 45 45 46 class WebEditorClient : public WebCore::EditorClient, public WebCore::TextCheckerClient {46 class WebEditorClient final : public WebCore::EditorClient, public WebCore::TextCheckerClient { 47 47 public: 48 48 WebEditorClient(WebView *); … … 52 52 53 53 private: 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; 87 86 88 87 #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; 92 91 #endif 93 92 94 93 #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; 169 168 170 169 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 171 void requestCandidatesForSelection(const WebCore::VisibleSelection&) override;170 void requestCandidatesForSelection(const WebCore::VisibleSelection&) final; 172 171 void handleRequestedCandidates(NSInteger, NSArray<NSTextCheckingResult *> *); 173 void handleAcceptedCandidateWithSoftSpaces(WebCore::TextCheckingResult) override;172 void handleAcceptedCandidateWithSoftSpaces(WebCore::TextCheckingResult) final; 174 173 #endif 175 174 … … 178 177 WebView *m_webView; 179 178 RetainPtr<WebEditorUndoTarget> m_undoTarget; 180 bool m_haveUndoRedoOperations ;179 bool m_haveUndoRedoOperations { false }; 181 180 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 }; 185 185 #endif 186 186 187 187 WebCore::VisibleSelection m_lastSelectionForRequestedCandidates; 188 188 189 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 189 190 RetainPtr<NSString> m_paragraphContextForCandidateRequest; … … 195 196 }; 196 197 197 #if PLATFORM(COCOA)198 198 inline NSSelectionAffinity kit(WebCore::EAffinity affinity) 199 199 { … … 219 219 return WebCore::EAffinity::UPSTREAM; 220 220 } 221 #endif222 221 223 222 #if PLATFORM(IOS) -
trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm
r201894 r204508 1 1 /* 2 * Copyright (C) 2006 Apple Inc.All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 4 * … … 32 32 #import "DOMCSSStyleDeclarationInternal.h" 33 33 #import "DOMDocumentFragmentInternal.h" 34 #import "DOMDocumentInternal.h" 34 35 #import "DOMHTMLElementInternal.h" 35 36 #import "DOMHTMLInputElementInternal.h" … … 99 100 100 101 @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; 103 103 @end 104 104 … … 160 160 161 161 @interface WebEditorUndoTarget : NSObject 162 {163 }164 162 165 163 - (void)undoEditing:(id)arg; … … 187 185 : m_webView(webView) 188 186 , m_undoTarget(adoptNS([[WebEditorUndoTarget alloc] init])) 189 , m_haveUndoRedoOperations(false)190 #if PLATFORM(IOS)191 , m_delayingContentChangeNotifications(0)192 , m_hasDelayedContentChangeNotification(0)193 #endif194 187 , m_weakPtrFactory(this) 195 188 { … … 206 199 207 200 #if !PLATFORM(IOS) 201 208 202 void WebEditorClient::toggleContinuousSpellChecking() 209 203 { … … 225 219 return [m_webView spellCheckerDocumentTag]; 226 220 } 221 227 222 #endif 228 223 … … 313 308 314 309 #if PLATFORM(IOS) 310 315 311 void WebEditorClient::startDelayingAndCoalescingContentChangeNotifications() 316 312 { … … 327 323 m_hasDelayedContentChangeNotification = false; 328 324 } 325 329 326 #endif 330 327 … … 419 416 } 420 417 421 static NS Array *createExcludedElementsForAttributedStringConversion()422 { 423 NSArray *e lements = [[NSArray alloc] initWithObjects:418 static NSDictionary *attributesForAttributedStringConversion() 419 { 420 NSArray *excludedElements = [[NSArray alloc] initWithObjects: 424 421 // Omit style since we want style to be inline so the fragment can be easily inserted. 425 @"style", 422 @"style", 426 423 // Omit xml so the result is not XHTML. 427 @"xml", 424 @"xml", 428 425 // Omit tags that will get stripped when converted to a fragment anyway. 429 426 @"doctype", @"html", @"head", @"body", … … 432 429 // Omit object so no file attachments are part of the fragment. 433 430 @"object", nil]; 434 CFRetain(elements);435 return elements;436 }437 431 438 432 #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 446 436 NSDictionary *dictionary = [NSDictionary dictionaryWithObject:excludedElements forKey:NSExcludedElementsDocumentAttribute]; 447 437 448 NSArray *subResources; 438 [excludedElements release]; 439 440 return dictionary; 441 } 442 443 void _WebCreateFragment(Document& document, NSAttributedString *string, FragmentAndResources& result) 444 { 445 static NSDictionary *documentAttributes = [attributesForAttributedStringConversion() retain]; 446 NSArray *subresources; 449 447 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]); 457 452 } 458 453 … … 466 461 467 462 #if USE(APPKIT) 463 468 464 void WebEditorClient::uppercaseWord() 469 465 { … … 480 476 [m_webView capitalizeWord:nil]; 481 477 } 478 482 479 #endif 483 480 484 481 #if USE(AUTOMATIC_TEXT_REPLACEMENT) 482 485 483 void WebEditorClient::showSubstitutionsPanel(bool show) 486 484 { … … 551 549 [m_webView toggleAutomaticSpellingCorrection:nil]; 552 550 } 551 553 552 #endif // USE(AUTOMATIC_TEXT_REPLACEMENT) 554 553 … … 613 612 614 613 NSUndoManager *undoManager = [m_webView undoManager]; 614 615 615 #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. But617 // just in case this happens, return to avoid putting the undo manager into an inconsistent state. Same for being618 // 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. 619 619 if (([undoManager isUndoing] && !isRedo) || ([undoManager isRedoing] && isRedo)) 620 620 return; 621 621 #endif 622 622 623 NSString *actionName = undoNameForEditAction(step->editingAction()); 623 624 WebUndoStep *webEntry = [WebUndoStep stepWithUndoStep:step]; … … 818 819 } 819 820 820 NSArray * WebEditorClient::supportedPasteboardTypesForCurrentSelection()821 NSArray *WebEditorClient::supportedPasteboardTypesForCurrentSelection() 821 822 { 822 823 if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(supportedPasteboardTypesForCurrentSelection)]) … … 826 827 } 827 828 828 NSArray *WebEditorClient::readDataFromPasteboard(NSString* type, int index)829 NSArray *WebEditorClient::readDataFromPasteboard(NSString* type, int index) 829 830 { 830 831 if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(readDataFromPasteboard:withIndex:)]) … … 858 859 } 859 860 860 return 0;861 return nullptr; 861 862 } 862 863 … … 1133 1134 1134 1135 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 1136 1135 1137 void WebEditorClient::requestCandidatesForSelection(const VisibleSelection& selection) 1136 1138 { … … 1220 1222 frame->editor().handleAcceptedCandidate(acceptedCandidate); 1221 1223 } 1224 1222 1225 #endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 1223 1226 1224 1227 #if !PLATFORM(IOS) 1228 1225 1229 @interface WebEditorSpellCheckResponder : NSObject 1226 1230 { … … 1258 1262 m_textCheckingRequest = nullptr; 1259 1263 } 1264 1260 1265 #endif 1261 1266 -
trunk/Source/WebKit/mac/WebKit.exp
r204482 r204508 103 103 _WebViewProgressStartedNotification 104 104 _WebViewWillCloseNotification 105 __WebCreateFragment 105 106 __WebHTMLViewPrintingMaximumShrinkFactor 106 107 __WebHTMLViewPrintingMinimumShrinkFactor -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r202524 r204508 2558 2558 } 2559 2559 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) { 2564 2561 NSAttributedString *string = nil; 2565 2562 if (pboardType == NSRTFDPboardType) -
trunk/Source/WebKit2/ChangeLog
r204506 r204508 1 2016-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 1 15 2016-08-16 Brady Eidson <beidson@apple.com> 2 16 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
r201894 r204508 24 24 */ 25 25 26 #ifndef WebEditorClient_h 27 #define WebEditorClient_h 26 #pragma once 28 27 29 28 #include <WebCore/EditorClient.h> … … 34 33 class WebPage; 35 34 36 class WebEditorClient : public WebCore::EditorClient, public WebCore::TextCheckerClient {35 class WebEditorClient final : public WebCore::EditorClient, public WebCore::TextCheckerClient { 37 36 public: 38 37 WebEditorClient(WebPage* page) … … 42 41 43 42 private: 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; 52 51 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; 58 57 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; 62 61 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; 72 71 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; 76 75 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; 81 80 82 void undo() override;83 void redo() override;81 void undo() final; 82 void redo() final; 84 83 85 void handleKeyboardEvent(WebCore::KeyboardEvent*) override;86 void handleInputMethodKeydown(WebCore::KeyboardEvent*) override;84 void handleKeyboardEvent(WebCore::KeyboardEvent*) final; 85 void handleInputMethodKeydown(WebCore::KeyboardEvent*) final; 87 86 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; 95 94 96 95 #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; 102 100 #endif 103 101 104 102 #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; 108 106 #endif 107 109 108 #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; 123 122 #endif 124 123 … … 129 128 #endif 130 129 131 TextCheckerClient* textChecker() override{ return this; }130 TextCheckerClient* textChecker() final { return this; } 132 131 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 139 139 #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; 141 141 #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; 150 151 151 152 #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; 165 154 #endif 166 155 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; 168 170 169 171 WebPage* m_page; … … 171 173 172 174 } // namespace WebKit 173 174 #endif // WebEditorClient_h -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm
r198177 r204508 64 64 notImplemented(); 65 65 return nil; 66 }67 68 DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *, Vector<RefPtr<ArchiveResource> >&)69 {70 notImplemented();71 return nullptr;72 66 } 73 67 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
r199565 r204508 1 1 /* 2 * Copyright (C) 2006, 2010 , 2011 Apple Inc.All rights reserved.2 * Copyright (C) 2006, 2010-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 4 * … … 33 33 #if PLATFORM(MAC) 34 34 35 #import "WebCoreArgumentCoders.h"36 35 #import "WebPage.h" 37 #import "WebFrame.h"38 36 #import "WebPageProxyMessages.h" 39 37 #import "WebProcess.h" 40 #import <WebCore/ArchiveResource.h>41 #import <WebCore/DocumentFragment.h>42 #import <WebCore/DOMDocumentFragmentInternal.h>43 #import <WebCore/DOMDocumentInternal.h>44 38 #import <WebCore/FocusController.h> 45 39 #import <WebCore/Frame.h> 46 40 #import <WebCore/KeyboardEvent.h> 47 #import <WebCore/MainFrame.h>48 41 #import <WebCore/NotImplemented.h> 49 #import <WebCore/Page.h>50 42 #import <WebCore/WebCoreNSURLExtras.h> 51 43 52 44 using namespace WebCore; 53 54 @interface NSAttributedString (WebNSAttributedStringDetails)55 - (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources;56 @end57 58 @interface NSObject (WebResourceInternal)59 - (WebCore::ArchiveResource*)_coreResource;60 @end61 45 62 46 namespace WebKit { … … 91 75 return URL; 92 76 } 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:dictionary124 subresources:&subResources];125 for (id resource in subResources)126 resources.append([resource _coreResource]);127 128 return core(fragment);129 }130 77 131 78 void WebEditorClient::setInsertionPasteboard(const String&) … … 134 81 notImplemented(); 135 82 } 136 137 83 138 84 static void changeWordCase(WebPage* page, SEL selector) … … 148 94 } 149 95 150 #if USE(APPKIT)151 96 void WebEditorClient::uppercaseWord() 152 97 { … … 163 108 changeWordCase(m_page, @selector(capitalizedString)); 164 109 } 165 #endif166 110 167 111 #if USE(AUTOMATIC_TEXT_REPLACEMENT) 112 168 113 void WebEditorClient::showSubstitutionsPanel(bool) 169 114 { … … 249 194 notImplemented(); 250 195 } 196 251 197 #endif // USE(AUTOMATIC_TEXT_REPLACEMENT) 252 198
Note: See TracChangeset
for help on using the changeset viewer.