Diff
Modified: trunk/Source/WebCore/ChangeLog (204507 => 204508)
--- trunk/Source/WebCore/ChangeLog 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/ChangeLog 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,3 +1,41 @@
+2016-08-16 Darin Adler <[email protected]>
+
+ [Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
+ https://bugs.webkit.org/show_bug.cgi?id=160891
+
+ Reviewed by Anders Carlsson.
+
+ * 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.
+
2016-08-16 Brady Eidson <[email protected]>
Cleanup WK2 platform gamepad handling.
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (204507 => 204508)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-08-16 16:56:07 UTC (rev 204508)
@@ -11493,7 +11493,6 @@
9B532EA11BA928570038A827 /* SlotAssignment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SlotAssignment.cpp; sourceTree = "<group>"; };
9B532EA21BA928570038A827 /* SlotAssignment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlotAssignment.h; sourceTree = "<group>"; };
9B55EEE81B3E8898005342BC /* EditorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditorCocoa.mm; sourceTree = "<group>"; };
- 9B55EEEA1B3F3FEF005342BC /* EditorCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EditorCocoa.h; sourceTree = "<group>"; };
9B56C9A81C89312800C456DF /* LifecycleCallbackQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LifecycleCallbackQueue.h; sourceTree = "<group>"; };
9B56C9A91C89329A00C456DF /* LifecycleCallbackQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LifecycleCallbackQueue.cpp; sourceTree = "<group>"; };
9B69D3B11B98FF0A00E3512B /* HTMLSlotElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLSlotElement.idl; sourceTree = "<group>"; };
@@ -18348,7 +18347,6 @@
children = (
C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */,
C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */,
- 9B55EEEA1B3F3FEF005342BC /* EditorCocoa.h */,
9B55EEE81B3E8898005342BC /* EditorCocoa.mm */,
7C3E510818DF8F3500C112F7 /* HTMLConverter.h */,
7C3E510918DF8F3500C112F7 /* HTMLConverter.mm */,
Modified: trunk/Source/WebCore/editing/Editor.cpp (204507 => 204508)
--- trunk/Source/WebCore/editing/Editor.cpp 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/editing/Editor.cpp 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1108,18 +1108,10 @@
Editor::Editor(Frame& frame)
: m_frame(frame)
- , m_ignoreCompositionSelectionChange(false)
- // This is off by default, since most editors want this behavior (this matches IE but not FF).
- , m_shouldStyleWithCSS(false)
, m_killRing(std::make_unique<KillRing>())
, m_spellChecker(std::make_unique<SpellChecker>(frame))
, m_alternativeTextController(std::make_unique<AlternativeTextController>(frame))
- , m_areMarkedTextMatchesHighlighted(false)
- , m_defaultParagraphSeparator(EditorParagraphSeparatorIsDiv)
- , m_overwriteModeEnabled(false)
, m_editorUIUpdateTimer(*this, &Editor::editorUIUpdateTimerFired)
- , m_editorUIUpdateTimerShouldCheckSpellingAndGrammar(false)
- , m_editorUIUpdateTimerWasTriggeredByDictation(false)
#if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
, m_telephoneNumberDetectionUpdateTimer(*this, &Editor::scanSelectionForTelephoneNumbers)
#endif
Modified: trunk/Source/WebCore/editing/Editor.h (204507 => 204508)
--- trunk/Source/WebCore/editing/Editor.h 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/editing/Editor.h 2016-08-16 16:56:07 UTC (rev 204508)
@@ -23,8 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef Editor_h
-#define Editor_h
+#pragma once
#include "Color.h"
#include "DataTransferAccessPolicy.h"
@@ -97,6 +96,13 @@
IgnoreBlockquote,
};
+#if PLATFORM(COCOA)
+struct FragmentAndResources {
+ RefPtr<DocumentFragment> fragment;
+ Vector<RefPtr<ArchiveResource>> resources;
+};
+#endif
+
class Editor {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -197,6 +203,7 @@
void reappliedEditing(PassRefPtr<EditCommandComposition>);
void unappliedSpellCorrection(const VisibleSelection& selectionOfCorrected, const String& corrected, const String& correction);
+ // This is off by default, since most editors want this behavior (originally matched IE but not Firefox).
void setShouldStyleWithCSS(bool flag) { m_shouldStyleWithCSS = flag; }
bool shouldStyleWithCSS() const { return m_shouldStyleWithCSS; }
@@ -265,7 +272,7 @@
#if !PLATFORM(IOS)
WEBCORE_EXPORT void advanceToNextMisspelling(bool startBeforeSelection = false);
-#endif // !PLATFORM(IOS)
+#endif
void showSpellingGuessPanel();
bool spellingPanelIsShowing();
@@ -498,6 +505,7 @@
RefPtr<Range> adjustedSelectionRange();
RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&);
RefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *);
+ FragmentAndResources createFragment(NSAttributedString *);
void fillInUserVisibleForm(PasteboardURL&);
#endif
@@ -509,21 +517,21 @@
unsigned m_compositionStart;
unsigned m_compositionEnd;
Vector<CompositionUnderline> m_customCompositionUnderlines;
- bool m_ignoreCompositionSelectionChange;
- bool m_shouldStartNewKillRingSequence {false};
- bool m_shouldStyleWithCSS;
+ bool m_ignoreCompositionSelectionChange { false };
+ bool m_shouldStartNewKillRingSequence { false };
+ bool m_shouldStyleWithCSS { false };
const std::unique_ptr<KillRing> m_killRing;
const std::unique_ptr<SpellChecker> m_spellChecker;
const std::unique_ptr<AlternativeTextController> m_alternativeTextController;
VisibleSelection m_mark;
- bool m_areMarkedTextMatchesHighlighted;
- EditorParagraphSeparator m_defaultParagraphSeparator;
- bool m_overwriteModeEnabled;
+ bool m_areMarkedTextMatchesHighlighted { false };
+ EditorParagraphSeparator m_defaultParagraphSeparator { EditorParagraphSeparatorIsDiv };
+ bool m_overwriteModeEnabled { false };
VisibleSelection m_oldSelectionForEditorUIUpdate;
Timer m_editorUIUpdateTimer;
- bool m_editorUIUpdateTimerShouldCheckSpellingAndGrammar;
- bool m_editorUIUpdateTimerWasTriggeredByDictation;
+ bool m_editorUIUpdateTimerShouldCheckSpellingAndGrammar { false };
+ bool m_editorUIUpdateTimerWasTriggeredByDictation { false };
bool m_isHandlingAcceptedCandidate { false };
#if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
@@ -557,4 +565,8 @@
} // namespace WebCore
-#endif // Editor_h
+#if PLATFORM(COCOA)
+// This function is declared here but defined in the WebKitLegacy framework.
+// FIXME: Get rid of this and change this so it doesn't use WebKitLegacy.
+extern "C" void _WebCreateFragment(WebCore::Document&, NSAttributedString *, WebCore::FragmentAndResources&);
+#endif
Deleted: trunk/Source/WebCore/editing/cocoa/EditorCocoa.h (204507 => 204508)
--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.h 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.h 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2013, 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EditorCocoa_h
-#define EditorCocoa_h
-
-#include "Editor.h"
-
-#if PLATFORM(IOS)
-
-typedef NS_ENUM(NSInteger, NSUnderlineStyle) {
- NSUnderlineStyleNone = 0x00,
- NSUnderlineStyleSingle = 0x01,
- NSUnderlineStyleThick NS_ENUM_AVAILABLE_IOS(7_0) = 0x02,
- NSUnderlineStyleDouble NS_ENUM_AVAILABLE_IOS(7_0) = 0x09,
-
- NSUnderlinePatternSolid NS_ENUM_AVAILABLE_IOS(7_0) = 0x0000,
- NSUnderlinePatternDot NS_ENUM_AVAILABLE_IOS(7_0) = 0x0100,
- NSUnderlinePatternDash NS_ENUM_AVAILABLE_IOS(7_0) = 0x0200,
- NSUnderlinePatternDashDot NS_ENUM_AVAILABLE_IOS(7_0) = 0x0300,
- NSUnderlinePatternDashDotDot NS_ENUM_AVAILABLE_IOS(7_0) = 0x0400,
-
- NSUnderlineByWord NS_ENUM_AVAILABLE_IOS(7_0) = 0x8000
-};
-
-#endif
-
-#endif
Modified: trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm (204507 => 204508)
--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,10 @@
#import "config.h"
#import "Editor.h"
+#import "ArchiveResource.h"
#import "CSSValueList.h"
#import "CSSValuePool.h"
+#import "DocumentFragment.h"
#import "EditingStyle.h"
#import "Frame.h"
#import "FrameSelection.h"
@@ -38,10 +40,14 @@
#import "Text.h"
#import "htmlediting.h"
+SOFT_LINK_FRAMEWORK(WebKitLegacy)
+
+SOFT_LINK(WebKitLegacy, _WebCreateFragment, void, (WebCore::Document& document, NSAttributedString *string, WebCore::FragmentAndResources& result), (document, string, result))
+
namespace WebCore {
// FIXME: This figures out the current style by inserting a <span>!
-const RenderStyle* Editor::styleForSelectionStart(Frame* frame, Node *&nodeToRemove)
+const RenderStyle* Editor::styleForSelectionStart(Frame* frame, Node*& nodeToRemove)
{
nodeToRemove = nullptr;
@@ -97,4 +103,13 @@
}
}
+FragmentAndResources Editor::createFragment(NSAttributedString *string)
+{
+ // FIXME: The algorithm to convert an attributed string into HTML should be implemented here in WebCore.
+ // For now, though, we call into WebKitLegacy, which in turn calls into AppKit/TextKit.
+ FragmentAndResources result;
+ _WebCreateFragment(*m_frame.document(), string, result);
+ return result;
}
+
+}
Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (204507 => 204508)
--- trunk/Source/WebCore/editing/ios/EditorIOS.mm 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm 2016-08-16 16:56:07 UTC (rev 204508)
@@ -566,11 +566,10 @@
if (wasImagesEnabled)
cachedResourceLoader.setImagesEnabled(false);
- Vector<RefPtr<ArchiveResource>> resources;
- RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources);
+ auto fragmentAndResources = createFragment(string);
if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
- for (auto& resource : resources) {
+ for (auto& resource : fragmentAndResources.resources) {
if (resource)
loader->addArchiveResource(resource.releaseNonNull());
}
@@ -581,7 +580,7 @@
if (!wasDeferringCallbacks)
m_frame.page()->setDefersLoading(false);
- return fragment;
+ return WTFMove(fragmentAndResources.fragment);
}
RefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&& resource)
Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (204507 => 204508)
--- trunk/Source/WebCore/editing/mac/EditorMac.mm 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm 2016-08-16 16:56:07 UTC (rev 204508)
@@ -659,11 +659,10 @@
if (!wasDeferringCallbacks)
m_frame.page()->setDefersLoading(true);
- Vector<RefPtr<ArchiveResource>> resources;
- RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources);
+ auto fragmentAndResources = createFragment(string);
if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
- for (auto& resource : resources) {
+ for (auto& resource : fragmentAndResources.resources) {
if (resource)
loader->addArchiveResource(resource.releaseNonNull());
}
@@ -672,7 +671,7 @@
if (!wasDeferringCallbacks)
m_frame.page()->setDefersLoading(false);
- return fragment;
+ return WTFMove(fragmentAndResources.fragment);
}
void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributedString, MailBlockquoteHandling mailBlockquoteHandling)
Modified: trunk/Source/WebCore/loader/EmptyClients.h (204507 => 204508)
--- trunk/Source/WebCore/loader/EmptyClients.h 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/loader/EmptyClients.h 2016-08-16 16:56:07 UTC (rev 204508)
@@ -510,11 +510,10 @@
#endif
#if PLATFORM(COCOA)
- NSString* userVisibleString(NSURL*) override { return nullptr; }
- DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<RefPtr<ArchiveResource>>&) override { return nullptr; };
+ NSString* userVisibleString(NSURL *) override { return nullptr; }
void setInsertionPasteboard(const String&) override { };
- NSURL *canonicalizeURL(NSURL*) override { return nullptr; }
- NSURL *canonicalizeURLString(NSString*) override { return nullptr; }
+ NSURL *canonicalizeURL(NSURL *) override { return nullptr; }
+ NSURL *canonicalizeURLString(NSString *) override { return nullptr; }
#endif
#if USE(APPKIT)
Modified: trunk/Source/WebCore/page/EditorClient.h (204507 => 204508)
--- trunk/Source/WebCore/page/EditorClient.h 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebCore/page/EditorClient.h 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
@@ -24,11 +24,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef EditorClient_h
-#define EditorClient_h
+#pragma once
#include "EditorInsertAction.h"
-#include "FloatRect.h"
#include "TextAffinity.h"
#include "TextChecking.h"
#include "UndoStep.h"
@@ -36,7 +34,6 @@
#include <wtf/Vector.h>
#if PLATFORM(COCOA)
-OBJC_CLASS NSAttributedString;
OBJC_CLASS NSString;
OBJC_CLASS NSURL;
#endif
@@ -143,7 +140,6 @@
#if PLATFORM(COCOA)
virtual NSString* userVisibleString(NSURL*) = 0;
- virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector< RefPtr<ArchiveResource>>&) = 0;
virtual void setInsertionPasteboard(const String& pasteboardName) = 0;
virtual NSURL* canonicalizeURL(NSURL*) = 0;
virtual NSURL* canonicalizeURLString(NSString*) = 0;
@@ -190,5 +186,3 @@
};
}
-
-#endif // EditorClient_h
Modified: trunk/Source/WebKit/mac/ChangeLog (204507 => 204508)
--- trunk/Source/WebKit/mac/ChangeLog 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,3 +1,26 @@
+2016-08-16 Darin Adler <[email protected]>
+
+ [Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
+ https://bugs.webkit.org/show_bug.cgi?id=160891
+
+ Reviewed by Anders Carlsson.
+
+ * 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.
+
2016-08-15 Anders Carlsson <[email protected]>
Another build fix.
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (204507 => 204508)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
@class WebView;
@class WebEditorUndoTarget;
-class WebEditorClient : public WebCore::EditorClient, public WebCore::TextCheckerClient {
+class WebEditorClient final : public WebCore::EditorClient, public WebCore::TextCheckerClient {
public:
WebEditorClient(WebView *);
virtual ~WebEditorClient();
@@ -51,126 +51,125 @@
void didCheckSucceed(int sequence, NSArray *results);
private:
- bool isGrammarCheckingEnabled() override;
- void toggleGrammarChecking() override;
- bool isContinuousSpellCheckingEnabled() override;
- void toggleContinuousSpellChecking() override;
- int spellCheckerDocumentTag() override;
+ bool isGrammarCheckingEnabled() final;
+ void toggleGrammarChecking() final;
+ bool isContinuousSpellCheckingEnabled() final;
+ void toggleContinuousSpellChecking() final;
+ int spellCheckerDocumentTag() final;
- bool smartInsertDeleteEnabled() override;
- bool isSelectTrailingWhitespaceEnabled() override;
+ bool smartInsertDeleteEnabled() final;
+ bool isSelectTrailingWhitespaceEnabled() final;
- bool shouldDeleteRange(WebCore::Range*) override;
+ bool shouldDeleteRange(WebCore::Range*) final;
- bool shouldBeginEditing(WebCore::Range*) override;
- bool shouldEndEditing(WebCore::Range*) override;
- bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) override;
- bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) override;
- bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) override;
+ bool shouldBeginEditing(WebCore::Range*) final;
+ bool shouldEndEditing(WebCore::Range*) final;
+ bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) final;
+ bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) final;
+ bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) final;
- bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) override;
- void didApplyStyle() override;
+ bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) final;
+ void didApplyStyle() final;
- bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range* rangeToBeReplaced) override;
+ bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range* rangeToBeReplaced) final;
- void didBeginEditing() override;
- void didEndEditing() override;
- void willWriteSelectionToPasteboard(WebCore::Range*) override;
- void didWriteSelectionToPasteboard() override;
- void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) override;
+ void didBeginEditing() final;
+ void didEndEditing() final;
+ void willWriteSelectionToPasteboard(WebCore::Range*) final;
+ void didWriteSelectionToPasteboard() final;
+ void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final;
- NSString *userVisibleString(NSURL *) override;
- WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource>>&) override;
- void setInsertionPasteboard(const String&) override;
- NSURL *canonicalizeURL(NSURL *) override;
- NSURL *canonicalizeURLString(NSString *) override;
+ NSString *userVisibleString(NSURL *) final;
+ void setInsertionPasteboard(const String&) final;
+ NSURL *canonicalizeURL(NSURL *) final;
+ NSURL *canonicalizeURLString(NSString *) final;
#if USE(APPKIT)
- void uppercaseWord() override;
- void lowercaseWord() override;
- void capitalizeWord() override;
+ void uppercaseWord() final;
+ void lowercaseWord() final;
+ void capitalizeWord() final;
#endif
#if USE(AUTOMATIC_TEXT_REPLACEMENT)
- void showSubstitutionsPanel(bool show) override;
- bool substitutionsPanelIsShowing() override;
- void toggleSmartInsertDelete() override;
- bool isAutomaticQuoteSubstitutionEnabled() override;
- void toggleAutomaticQuoteSubstitution() override;
- bool isAutomaticLinkDetectionEnabled() override;
- void toggleAutomaticLinkDetection() override;
- bool isAutomaticDashSubstitutionEnabled() override;
- void toggleAutomaticDashSubstitution() override;
- bool isAutomaticTextReplacementEnabled() override;
- void toggleAutomaticTextReplacement() override;
- bool isAutomaticSpellingCorrectionEnabled() override;
- void toggleAutomaticSpellingCorrection() override;
+ void showSubstitutionsPanel(bool show) final;
+ bool substitutionsPanelIsShowing() final;
+ void toggleSmartInsertDelete() final;
+ bool isAutomaticQuoteSubstitutionEnabled() final;
+ void toggleAutomaticQuoteSubstitution() final;
+ bool isAutomaticLinkDetectionEnabled() final;
+ void toggleAutomaticLinkDetection() final;
+ bool isAutomaticDashSubstitutionEnabled() final;
+ void toggleAutomaticDashSubstitution() final;
+ bool isAutomaticTextReplacementEnabled() final;
+ void toggleAutomaticTextReplacement() final;
+ bool isAutomaticSpellingCorrectionEnabled() final;
+ void toggleAutomaticSpellingCorrection() final;
#endif
- TextCheckerClient* textChecker() override { return this; }
+ TextCheckerClient* textChecker() final { return this; }
- void respondToChangedContents() override;
- void respondToChangedSelection(WebCore::Frame*) override;
- void didChangeSelectionAndUpdateLayout() override { }
- void discardedComposition(WebCore::Frame*) override;
+ void respondToChangedContents() final;
+ void respondToChangedSelection(WebCore::Frame*) final;
+ void didChangeSelectionAndUpdateLayout() final { }
+ void discardedComposition(WebCore::Frame*) final;
- void registerUndoStep(PassRefPtr<WebCore::UndoStep>) override;
- void registerRedoStep(PassRefPtr<WebCore::UndoStep>) override;
- void clearUndoRedoOperations() override;
+ void registerUndoStep(PassRefPtr<WebCore::UndoStep>) final;
+ void registerRedoStep(PassRefPtr<WebCore::UndoStep>) final;
+ void clearUndoRedoOperations() final;
- bool canCopyCut(WebCore::Frame*, bool defaultValue) const override;
- bool canPaste(WebCore::Frame*, bool defaultValue) const override;
- bool canUndo() const override;
- bool canRedo() const override;
+ bool canCopyCut(WebCore::Frame*, bool defaultValue) const final;
+ bool canPaste(WebCore::Frame*, bool defaultValue) const final;
+ bool canUndo() const final;
+ bool canRedo() const final;
- void undo() override;
- void redo() override;
+ void undo() final;
+ void redo() final;
- void handleKeyboardEvent(WebCore::KeyboardEvent*) override;
- void handleInputMethodKeydown(WebCore::KeyboardEvent*) override;
+ void handleKeyboardEvent(WebCore::KeyboardEvent*) final;
+ void handleInputMethodKeydown(WebCore::KeyboardEvent*) final;
- void textFieldDidBeginEditing(WebCore::Element*) override;
- void textFieldDidEndEditing(WebCore::Element*) override;
- void textDidChangeInTextField(WebCore::Element*) override;
- bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) override;
- void textWillBeDeletedInTextField(WebCore::Element*) override;
- void textDidChangeInTextArea(WebCore::Element*) override;
- void overflowScrollPositionChanged() override { };
+ void textFieldDidBeginEditing(WebCore::Element*) final;
+ void textFieldDidEndEditing(WebCore::Element*) final;
+ void textDidChangeInTextField(WebCore::Element*) final;
+ bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) final;
+ void textWillBeDeletedInTextField(WebCore::Element*) final;
+ void textDidChangeInTextArea(WebCore::Element*) final;
+ void overflowScrollPositionChanged() final { };
#if PLATFORM(IOS)
- void startDelayingAndCoalescingContentChangeNotifications() override;
- void stopDelayingAndCoalescingContentChangeNotifications() override;
- void writeDataToPasteboard(NSDictionary*) override;
- NSArray* supportedPasteboardTypesForCurrentSelection() override;
- NSArray* readDataFromPasteboard(NSString* type, int index) override;
- bool hasRichlyEditableSelection() override;
- int getPasteboardItemsCount() override;
- WebCore::DocumentFragment* documentFragmentFromDelegate(int index) override;
- bool performsTwoStepPaste(WebCore::DocumentFragment*) override;
- int pasteboardChangeCount() override;
+ void startDelayingAndCoalescingContentChangeNotifications() final;
+ void stopDelayingAndCoalescingContentChangeNotifications() final;
+ void writeDataToPasteboard(NSDictionary*) final;
+ NSArray* supportedPasteboardTypesForCurrentSelection() final;
+ NSArray* readDataFromPasteboard(NSString* type, int index) final;
+ bool hasRichlyEditableSelection() final;
+ int getPasteboardItemsCount() final;
+ WebCore::DocumentFragment* documentFragmentFromDelegate(int index) final;
+ bool performsTwoStepPaste(WebCore::DocumentFragment*) final;
+ int pasteboardChangeCount() final;
#endif
- bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
- void ignoreWordInSpellDocument(const String&) override;
- void learnWord(const String&) override;
- void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
- String getAutoCorrectSuggestionForMisspelledWord(const String&) override;
- void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
- Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) override;
- void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) override;
- void updateSpellingUIWithMisspelledWord(const String&) override;
- void showSpellingUI(bool show) override;
- bool spellingUIIsShowing() override;
- void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) override;
+ bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const final;
+ void ignoreWordInSpellDocument(const String&) final;
+ void learnWord(const String&) final;
+ void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) final;
+ String getAutoCorrectSuggestionForMisspelledWord(const String&) final;
+ void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) final;
+ Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) final;
+ void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) final;
+ void updateSpellingUIWithMisspelledWord(const String&) final;
+ void showSpellingUI(bool show) final;
+ bool spellingUIIsShowing() final;
+ void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) final;
- void willSetInputMethodState() override;
- void setInputMethodState(bool enabled) override;
- void requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) override;
+ void willSetInputMethodState() final;
+ void setInputMethodState(bool enabled) final;
+ void requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) final;
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
- void requestCandidatesForSelection(const WebCore::VisibleSelection&) override;
+ void requestCandidatesForSelection(const WebCore::VisibleSelection&) final;
void handleRequestedCandidates(NSInteger, NSArray<NSTextCheckingResult *> *);
- void handleAcceptedCandidateWithSoftSpaces(WebCore::TextCheckingResult) override;
+ void handleAcceptedCandidateWithSoftSpaces(WebCore::TextCheckingResult) final;
#endif
void registerUndoOrRedoStep(PassRefPtr<WebCore::UndoStep>, bool isRedo);
@@ -177,14 +176,16 @@
WebView *m_webView;
RetainPtr<WebEditorUndoTarget> m_undoTarget;
- bool m_haveUndoRedoOperations;
+ bool m_haveUndoRedoOperations { false };
RefPtr<WebCore::TextCheckingRequest> m_textCheckingRequest;
+
#if PLATFORM(IOS)
- bool m_delayingContentChangeNotifications;
- bool m_hasDelayedContentChangeNotification;
+ bool m_delayingContentChangeNotifications { false };
+ bool m_hasDelayedContentChangeNotification { false };
#endif
WebCore::VisibleSelection m_lastSelectionForRequestedCandidates;
+
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
RetainPtr<NSString> m_paragraphContextForCandidateRequest;
NSRange m_rangeForCandidates;
@@ -194,7 +195,6 @@
WeakPtrFactory<WebEditorClient> m_weakPtrFactory;
};
-#if PLATFORM(COCOA)
inline NSSelectionAffinity kit(WebCore::EAffinity affinity)
{
switch (affinity) {
@@ -218,7 +218,6 @@
ASSERT_NOT_REACHED();
return WebCore::EAffinity::UPSTREAM;
}
-#endif
#if PLATFORM(IOS)
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (204507 => 204508)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@
#import "DOMCSSStyleDeclarationInternal.h"
#import "DOMDocumentFragmentInternal.h"
+#import "DOMDocumentInternal.h"
#import "DOMHTMLElementInternal.h"
#import "DOMHTMLInputElementInternal.h"
#import "DOMHTMLTextAreaElementInternal.h"
@@ -98,8 +99,7 @@
#endif
@interface NSAttributedString (WebNSAttributedStringDetails)
-- (id)_initWithDOMRange:(DOMRange*)range;
-- (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources;
+- (DOMDocumentFragment *)_documentFromRange:(NSRange)range document:(DOMDocument *)document documentAttributes:(NSDictionary *)attributes subresources:(NSArray **)subresources;
@end
static WebViewInsertAction kit(EditorInsertAction coreAction)
@@ -159,8 +159,6 @@
@end
@interface WebEditorUndoTarget : NSObject
-{
-}
- (void)undoEditing:(id)arg;
- (void)redoEditing:(id)arg;
@@ -186,11 +184,6 @@
WebEditorClient::WebEditorClient(WebView *webView)
: m_webView(webView)
, m_undoTarget(adoptNS([[WebEditorUndoTarget alloc] init]))
- , m_haveUndoRedoOperations(false)
-#if PLATFORM(IOS)
- , m_delayingContentChangeNotifications(0)
- , m_hasDelayedContentChangeNotification(0)
-#endif
, m_weakPtrFactory(this)
{
}
@@ -205,6 +198,7 @@
}
#if !PLATFORM(IOS)
+
void WebEditorClient::toggleContinuousSpellChecking()
{
[m_webView toggleContinuousSpellChecking:nil];
@@ -224,6 +218,7 @@
{
return [m_webView spellCheckerDocumentTag];
}
+
#endif
bool WebEditorClient::shouldDeleteRange(Range* range)
@@ -312,6 +307,7 @@
}
#if PLATFORM(IOS)
+
void WebEditorClient::startDelayingAndCoalescingContentChangeNotifications()
{
m_delayingContentChangeNotifications = true;
@@ -326,6 +322,7 @@
m_hasDelayedContentChangeNotification = false;
}
+
#endif
void WebEditorClient::respondToChangedContents()
@@ -418,13 +415,13 @@
return URL;
}
-static NSArray *createExcludedElementsForAttributedStringConversion()
+static NSDictionary *attributesForAttributedStringConversion()
{
- NSArray *elements = [[NSArray alloc] initWithObjects:
+ NSArray *excludedElements = [[NSArray alloc] initWithObjects:
// Omit style since we want style to be inline so the fragment can be easily inserted.
- @"style",
+ @"style",
// Omit xml so the result is not XHTML.
- @"xml",
+ @"xml",
// Omit tags that will get stripped when converted to a fragment anyway.
@"doctype", @"html", @"head", @"body",
// Omit deprecated tags.
@@ -431,31 +428,29 @@
@"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u",
// Omit object so no file attachments are part of the fragment.
@"object", nil];
- CFRetain(elements);
- return elements;
-}
#if PLATFORM(IOS)
-static NSString *NSExcludedElementsDocumentAttribute = @"ExcludedElements";
+ static NSString * const NSExcludedElementsDocumentAttribute = @"ExcludedElements";
#endif
-DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *string, Vector<RefPtr<ArchiveResource>>& resources)
-{
- static NSArray *excludedElements = createExcludedElementsForAttributedStringConversion();
-
NSDictionary *dictionary = [NSDictionary dictionaryWithObject:excludedElements forKey:NSExcludedElementsDocumentAttribute];
- NSArray *subResources;
- DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length])
- document:[[m_webView mainFrame] DOMDocument]
- documentAttributes:dictionary
- subresources:&subResources];
- for (WebResource* resource in subResources)
- resources.append([resource _coreResource]);
+ [excludedElements release];
- return core(fragment);
+ return dictionary;
}
+void _WebCreateFragment(Document& document, NSAttributedString *string, FragmentAndResources& result)
+{
+ static NSDictionary *documentAttributes = [attributesForAttributedStringConversion() retain];
+ NSArray *subresources;
+ DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length])
+ document:kit(&document) documentAttributes:documentAttributes subresources:&subresources];
+ result.fragment = core(fragment);
+ for (WebResource* resource in subresources)
+ result.resources.append([resource _coreResource]);
+}
+
void WebEditorClient::setInsertionPasteboard(const String& pasteboardName)
{
#if !PLATFORM(IOS)
@@ -465,6 +460,7 @@
}
#if USE(APPKIT)
+
void WebEditorClient::uppercaseWord()
{
[m_webView uppercaseWord:nil];
@@ -479,9 +475,11 @@
{
[m_webView capitalizeWord:nil];
}
+
#endif
#if USE(AUTOMATIC_TEXT_REPLACEMENT)
+
void WebEditorClient::showSubstitutionsPanel(bool show)
{
NSPanel *spellingPanel = [[NSSpellChecker sharedSpellChecker] substitutionsPanel];
@@ -550,6 +548,7 @@
{
[m_webView toggleAutomaticSpellingCorrection:nil];
}
+
#endif // USE(AUTOMATIC_TEXT_REPLACEMENT)
bool WebEditorClient::shouldInsertNode(Node *node, Range* replacingRange, EditorInsertAction givenAction)
@@ -612,13 +611,15 @@
ASSERT(step);
NSUndoManager *undoManager = [m_webView undoManager];
+
#if PLATFORM(IOS)
- // While we are undoing, we shouldn't be asked to register another Undo operation, we shouldn't even be touching the DOM. But
- // just in case this happens, return to avoid putting the undo manager into an inconsistent state. Same for being
- // asked to register a Redo operation in the midst of another Redo.
+ // While we are undoing, we shouldn't be asked to register another Undo operation, we shouldn't even be touching the DOM.
+ // But just in case this happens, return to avoid putting the undo manager into an inconsistent state.
+ // Same for being asked to register a Redo operation in the midst of another Redo.
if (([undoManager isUndoing] && !isRedo) || ([undoManager isRedoing] && isRedo))
return;
#endif
+
NSString *actionName = undoNameForEditAction(step->editingAction());
WebUndoStep *webEntry = [WebUndoStep stepWithUndoStep:step];
[undoManager registerUndoWithTarget:m_undoTarget.get() selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:webEntry];
@@ -817,7 +818,7 @@
[[m_webView _UIKitDelegateForwarder] writeDataToPasteboard:representation];
}
-NSArray* WebEditorClient::supportedPasteboardTypesForCurrentSelection()
+NSArray *WebEditorClient::supportedPasteboardTypesForCurrentSelection()
{
if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(supportedPasteboardTypesForCurrentSelection)])
return [[m_webView _UIKitDelegateForwarder] supportedPasteboardTypesForCurrentSelection];
@@ -825,7 +826,7 @@
return nil;
}
-NSArray* WebEditorClient::readDataFromPasteboard(NSString* type, int index)
+NSArray *WebEditorClient::readDataFromPasteboard(NSString* type, int index)
{
if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(readDataFromPasteboard:withIndex:)])
return [[m_webView _UIKitDelegateForwarder] readDataFromPasteboard:type withIndex:index];
@@ -857,7 +858,7 @@
return core(fragmentFromDelegate);
}
- return 0;
+ return nullptr;
}
bool WebEditorClient::performsTwoStepPaste(WebCore::DocumentFragment* fragment)
@@ -1132,6 +1133,7 @@
}
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+
void WebEditorClient::requestCandidatesForSelection(const VisibleSelection& selection)
{
if (![m_webView shouldRequestCandidates])
@@ -1219,9 +1221,11 @@
frame->editor().handleAcceptedCandidate(acceptedCandidate);
}
+
#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
#if !PLATFORM(IOS)
+
@interface WebEditorSpellCheckResponder : NSObject
{
WebEditorClient* _client;
@@ -1257,6 +1261,7 @@
m_textCheckingRequest->didSucceed(core(results, m_textCheckingRequest->data().mask()));
m_textCheckingRequest = nullptr;
}
+
#endif
void WebEditorClient::requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest> request, const VisibleSelection& currentSelection)
Modified: trunk/Source/WebKit/mac/WebKit.exp (204507 => 204508)
--- trunk/Source/WebKit/mac/WebKit.exp 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit/mac/WebKit.exp 2016-08-16 16:56:07 UTC (rev 204508)
@@ -102,6 +102,7 @@
_WebViewProgressEstimateChangedNotification
_WebViewProgressStartedNotification
_WebViewWillCloseNotification
+__WebCreateFragment
__WebHTMLViewPrintingMaximumShrinkFactor
__WebHTMLViewPrintingMinimumShrinkFactor
__WebViewDidStartAcceleratedCompositingNotification
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (204507 => 204508)
--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-08-16 16:56:07 UTC (rev 204508)
@@ -2557,10 +2557,7 @@
return [[self _frame] _documentFragmentWithMarkupString:HTMLString baseURLString:nil];
}
- // The _hasHTMLDocument clause here is a workaround for a bug in NSAttributedString: Radar 5052369.
- // If we call _documentFromRange on an XML document we'll get "setInnerHTML: method not found".
- // FIXME: Remove this once bug 5052369 is fixed.
- if ([self _hasHTMLDocument] && (pboardType == NSRTFPboardType || pboardType == NSRTFDPboardType)) {
+ if (pboardType == NSRTFPboardType || pboardType == NSRTFDPboardType) {
NSAttributedString *string = nil;
if (pboardType == NSRTFDPboardType)
string = [[NSAttributedString alloc] initWithRTFD:[pasteboard dataForType:NSRTFDPboardType] documentAttributes:NULL];
Modified: trunk/Source/WebKit2/ChangeLog (204507 => 204508)
--- trunk/Source/WebKit2/ChangeLog 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit2/ChangeLog 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,3 +1,17 @@
+2016-08-16 Darin Adler <[email protected]>
+
+ [Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
+ https://bugs.webkit.org/show_bug.cgi?id=160891
+
+ Reviewed by Anders Carlsson.
+
+ * 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.
+
2016-08-16 Brady Eidson <[email protected]>
Cleanup WK2 platform gamepad handling.
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (204507 => 204508)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h 2016-08-16 16:56:07 UTC (rev 204508)
@@ -23,8 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebEditorClient_h
-#define WebEditorClient_h
+#pragma once
#include <WebCore/EditorClient.h>
#include <WebCore/TextCheckerClient.h>
@@ -33,7 +32,7 @@
class WebPage;
-class WebEditorClient : public WebCore::EditorClient, public WebCore::TextCheckerClient {
+class WebEditorClient final : public WebCore::EditorClient, public WebCore::TextCheckerClient {
public:
WebEditorClient(WebPage* page)
: m_page(page)
@@ -41,85 +40,85 @@
}
private:
- bool shouldDeleteRange(WebCore::Range*) override;
- bool smartInsertDeleteEnabled() override;
- bool isSelectTrailingWhitespaceEnabled() override;
- bool isContinuousSpellCheckingEnabled() override;
- void toggleContinuousSpellChecking() override;
- bool isGrammarCheckingEnabled() override;
- void toggleGrammarChecking() override;
- int spellCheckerDocumentTag() override;
+ bool shouldDeleteRange(WebCore::Range*) final;
+ bool smartInsertDeleteEnabled() final;
+ bool isSelectTrailingWhitespaceEnabled() final;
+ bool isContinuousSpellCheckingEnabled() final;
+ void toggleContinuousSpellChecking() final;
+ bool isGrammarCheckingEnabled() final;
+ void toggleGrammarChecking() final;
+ int spellCheckerDocumentTag() final;
- bool shouldBeginEditing(WebCore::Range*) override;
- bool shouldEndEditing(WebCore::Range*) override;
- bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) override;
- bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) override;
- bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) override;
+ bool shouldBeginEditing(WebCore::Range*) final;
+ bool shouldEndEditing(WebCore::Range*) final;
+ bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) final;
+ bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) final;
+ bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) final;
- bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) override;
- void didApplyStyle() override;
- bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*) override;
+ bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) final;
+ void didApplyStyle() final;
+ bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*) final;
- void didBeginEditing() override;
- void respondToChangedContents() override;
- void respondToChangedSelection(WebCore::Frame*) override;
- void didChangeSelectionAndUpdateLayout() override;
- void discardedComposition(WebCore::Frame*) override;
- void didEndEditing() override;
- void willWriteSelectionToPasteboard(WebCore::Range*) override;
- void didWriteSelectionToPasteboard() override;
- void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) override;
+ void didBeginEditing() final;
+ void respondToChangedContents() final;
+ void respondToChangedSelection(WebCore::Frame*) final;
+ void didChangeSelectionAndUpdateLayout() final;
+ void discardedComposition(WebCore::Frame*) final;
+ void didEndEditing() final;
+ void willWriteSelectionToPasteboard(WebCore::Range*) final;
+ void didWriteSelectionToPasteboard() final;
+ void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final;
- void registerUndoStep(PassRefPtr<WebCore::UndoStep>) override;
- void registerRedoStep(PassRefPtr<WebCore::UndoStep>) override;
- void clearUndoRedoOperations() override;
+ void registerUndoStep(PassRefPtr<WebCore::UndoStep>) final;
+ void registerRedoStep(PassRefPtr<WebCore::UndoStep>) final;
+ void clearUndoRedoOperations() final;
- bool canCopyCut(WebCore::Frame*, bool defaultValue) const override;
- bool canPaste(WebCore::Frame*, bool defaultValue) const override;
- bool canUndo() const override;
- bool canRedo() const override;
+ bool canCopyCut(WebCore::Frame*, bool defaultValue) const final;
+ bool canPaste(WebCore::Frame*, bool defaultValue) const final;
+ bool canUndo() const final;
+ bool canRedo() const final;
- void undo() override;
- void redo() override;
+ void undo() final;
+ void redo() final;
- void handleKeyboardEvent(WebCore::KeyboardEvent*) override;
- void handleInputMethodKeydown(WebCore::KeyboardEvent*) override;
+ void handleKeyboardEvent(WebCore::KeyboardEvent*) final;
+ void handleInputMethodKeydown(WebCore::KeyboardEvent*) final;
- void textFieldDidBeginEditing(WebCore::Element*) override;
- void textFieldDidEndEditing(WebCore::Element*) override;
- void textDidChangeInTextField(WebCore::Element*) override;
- bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) override;
- void textWillBeDeletedInTextField(WebCore::Element*) override;
- void textDidChangeInTextArea(WebCore::Element*) override;
- void overflowScrollPositionChanged() override;
+ void textFieldDidBeginEditing(WebCore::Element*) final;
+ void textFieldDidEndEditing(WebCore::Element*) final;
+ void textDidChangeInTextField(WebCore::Element*) final;
+ bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) final;
+ void textWillBeDeletedInTextField(WebCore::Element*) final;
+ void textDidChangeInTextArea(WebCore::Element*) final;
+ void overflowScrollPositionChanged() final;
#if PLATFORM(COCOA)
- NSString *userVisibleString(NSURL *) override;
- WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource>>&) override;
- void setInsertionPasteboard(const String& pasteboardName) override;
- NSURL* canonicalizeURL(NSURL*) override;
- NSURL* canonicalizeURLString(NSString*) override;
+ NSString *userVisibleString(NSURL *) final;
+ void setInsertionPasteboard(const String& pasteboardName) final;
+ NSURL *canonicalizeURL(NSURL *) final;
+ NSURL *canonicalizeURLString(NSString *) final;
#endif
#if USE(APPKIT)
- void uppercaseWord() override;
- void lowercaseWord() override;
- void capitalizeWord() override;
+ void uppercaseWord() final;
+ void lowercaseWord() final;
+ void capitalizeWord() final;
#endif
+
#if USE(AUTOMATIC_TEXT_REPLACEMENT)
- void showSubstitutionsPanel(bool show) override;
- bool substitutionsPanelIsShowing() override;
- void toggleSmartInsertDelete() override;
- bool isAutomaticQuoteSubstitutionEnabled() override;
- void toggleAutomaticQuoteSubstitution() override;
- bool isAutomaticLinkDetectionEnabled() override;
- void toggleAutomaticLinkDetection() override;
- bool isAutomaticDashSubstitutionEnabled() override;
- void toggleAutomaticDashSubstitution() override;
- bool isAutomaticTextReplacementEnabled() override;
- void toggleAutomaticTextReplacement() override;
- bool isAutomaticSpellingCorrectionEnabled() override;
- void toggleAutomaticSpellingCorrection() override;
+ void showSubstitutionsPanel(bool show) final;
+ bool substitutionsPanelIsShowing() final;
+ void toggleSmartInsertDelete() final;
+ bool isAutomaticQuoteSubstitutionEnabled() final;
+ void toggleAutomaticQuoteSubstitution() final;
+ bool isAutomaticLinkDetectionEnabled() final;
+ void toggleAutomaticLinkDetection() final;
+ bool isAutomaticDashSubstitutionEnabled() final;
+ void toggleAutomaticDashSubstitution() final;
+ bool isAutomaticTextReplacementEnabled() final;
+ void toggleAutomaticTextReplacement() final;
+ bool isAutomaticSpellingCorrectionEnabled() final;
+ void toggleAutomaticSpellingCorrection() final;
#endif
#if PLATFORM(GTK)
@@ -128,47 +127,48 @@
void updateGlobalSelection(WebCore::Frame*);
#endif
- TextCheckerClient* textChecker() override { return this; }
+ TextCheckerClient* textChecker() final { return this; }
- bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
- void ignoreWordInSpellDocument(const String&) override;
- void learnWord(const String&) override;
- void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
- String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) override;
- void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
+ bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const final;
+ void ignoreWordInSpellDocument(const String&) final;
+ void learnWord(const String&) final;
+ void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) final;
+ String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) final;
+ void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) final;
+
#if USE(UNIFIED_TEXT_CHECKING)
- Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) override;
+ Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) final;
#endif
- void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) override;
- void updateSpellingUIWithMisspelledWord(const String&) override;
- void showSpellingUI(bool show) override;
- bool spellingUIIsShowing() override;
- void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) override;
- void willSetInputMethodState() override;
- void setInputMethodState(bool enabled) override;
- void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) override;
+ void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) final;
+ void updateSpellingUIWithMisspelledWord(const String&) final;
+ void showSpellingUI(bool show) final;
+ bool spellingUIIsShowing() final;
+ void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) final;
+ void willSetInputMethodState() final;
+ void setInputMethodState(bool enabled) final;
+ void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) final;
+
#if PLATFORM(GTK)
- bool shouldShowUnicodeMenu() override;
+ bool shouldShowUnicodeMenu() final;
#endif
+
#if PLATFORM(IOS)
- void startDelayingAndCoalescingContentChangeNotifications() override;
- void stopDelayingAndCoalescingContentChangeNotifications() override;
- void writeDataToPasteboard(NSDictionary*) override;
- NSArray *supportedPasteboardTypesForCurrentSelection() override;
- NSArray *readDataFromPasteboard(NSString* type, int index) override;
- bool hasRichlyEditableSelection() override;
- int getPasteboardItemsCount() override;
- WebCore::DocumentFragment* documentFragmentFromDelegate(int index) override;
- bool performsTwoStepPaste(WebCore::DocumentFragment*) override;
- int pasteboardChangeCount() override;
+ void startDelayingAndCoalescingContentChangeNotifications() final;
+ void stopDelayingAndCoalescingContentChangeNotifications() final;
+ void writeDataToPasteboard(NSDictionary*) final;
+ NSArray *supportedPasteboardTypesForCurrentSelection() final;
+ NSArray *readDataFromPasteboard(NSString* type, int index) final;
+ bool hasRichlyEditableSelection() final;
+ int getPasteboardItemsCount() final;
+ WebCore::DocumentFragment* documentFragmentFromDelegate(int index) final;
+ bool performsTwoStepPaste(WebCore::DocumentFragment*) final;
+ int pasteboardChangeCount() final;
#endif
- bool supportsGlobalSelection() override;
+ bool supportsGlobalSelection() final;
WebPage* m_page;
};
} // namespace WebKit
-
-#endif // WebEditorClient_h
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm (204507 => 204508)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm 2016-08-16 16:56:07 UTC (rev 204508)
@@ -65,12 +65,6 @@
return nil;
}
-DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *, Vector<RefPtr<ArchiveResource> >&)
-{
- notImplemented();
- return nullptr;
-}
-
void WebEditorClient::setInsertionPasteboard(const String&)
{
// This is used only by Mail, no need to implement it now.
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm (204507 => 204508)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm 2016-08-16 16:52:45 UTC (rev 204507)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm 2016-08-16 16:56:07 UTC (rev 204508)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2010-2016 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
@@ -32,33 +32,17 @@
#if PLATFORM(MAC)
-#import "WebCoreArgumentCoders.h"
#import "WebPage.h"
-#import "WebFrame.h"
#import "WebPageProxyMessages.h"
#import "WebProcess.h"
-#import <WebCore/ArchiveResource.h>
-#import <WebCore/DocumentFragment.h>
-#import <WebCore/DOMDocumentFragmentInternal.h>
-#import <WebCore/DOMDocumentInternal.h>
#import <WebCore/FocusController.h>
#import <WebCore/Frame.h>
#import <WebCore/KeyboardEvent.h>
-#import <WebCore/MainFrame.h>
#import <WebCore/NotImplemented.h>
-#import <WebCore/Page.h>
#import <WebCore/WebCoreNSURLExtras.h>
using namespace WebCore;
-@interface NSAttributedString (WebNSAttributedStringDetails)
-- (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources;
-@end
-
-@interface NSObject (WebResourceInternal)
-- (WebCore::ArchiveResource*)_coreResource;
-@end
-
namespace WebKit {
void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
@@ -90,44 +74,7 @@
URL = "" nil));
return URL;
}
-
-static NSArray *createExcludedElementsForAttributedStringConversion()
-{
- NSArray *elements = [[NSArray alloc] initWithObjects:
- // Omit style since we want style to be inline so the fragment can be easily inserted.
- @"style",
- // Omit xml so the result is not XHTML.
- @"xml",
- // Omit tags that will get stripped when converted to a fragment anyway.
- @"doctype", @"html", @"head", @"body",
- // Omit deprecated tags.
- @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u",
- // Omit object so no file attachments are part of the fragment.
- @"object", nil];
- CFRetain(elements);
- return elements;
-}
-DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *string, Vector<RefPtr<ArchiveResource>>& resources)
-{
- static NSArray *excludedElements = createExcludedElementsForAttributedStringConversion();
-
- NSDictionary *dictionary = [NSDictionary dictionaryWithObject:excludedElements forKey:NSExcludedElementsDocumentAttribute];
-
- NSArray *subResources;
- Document* document = m_page->mainFrame()->document();
-
- // FIXME: Isntead of calling this WebKit1 method, the code should be factored out and moved into WebCore.
- DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length])
- document:kit(document)
- documentAttributes:dictionary
- subresources:&subResources];
- for (id resource in subResources)
- resources.append([resource _coreResource]);
-
- return core(fragment);
-}
-
void WebEditorClient::setInsertionPasteboard(const String&)
{
// This is used only by Mail, no need to implement it now.
@@ -134,7 +81,6 @@
notImplemented();
}
-
static void changeWordCase(WebPage* page, SEL selector)
{
Frame& frame = page->corePage()->focusController().focusedOrMainFrame();
@@ -147,7 +93,6 @@
page->replaceSelectionWithText(&frame, [selectedString performSelector:selector]);
}
-#if USE(APPKIT)
void WebEditorClient::uppercaseWord()
{
changeWordCase(m_page, @selector(uppercaseString));
@@ -162,9 +107,9 @@
{
changeWordCase(m_page, @selector(capitalizedString));
}
-#endif
#if USE(AUTOMATIC_TEXT_REPLACEMENT)
+
void WebEditorClient::showSubstitutionsPanel(bool)
{
notImplemented();
@@ -248,6 +193,7 @@
{
notImplemented();
}
+
#endif // USE(AUTOMATIC_TEXT_REPLACEMENT)
} // namespace WebKit