Make handleAcceptedCandidate a public function
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 May 2016 23:24:19 +0000 (23:24 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 May 2016 23:24:19 +0000 (23:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157763
-and corresponding-
rdar://problem/26206397

Reviewed by Tim Horton.

Source/WebCore:

Define handleAcceptedCandidateWithSoftSpaces on EditorClient so that it can
be invoked on any EditorClient.
* loader/EmptyClients.h:
* page/EditorClient.h:
(WebCore::EditorClient::handleAcceptedCandidateWithSoftSpaces):

Source/WebKit/mac:

This patch re-names handleAcceptedCandidate to
handleAcceptedCandidateWithSoftSpaces. The function now takes a
WebCore::TextCheckingResult instead of an NSTextCheckingResult and it can be
called from outside of WebEditorClient.

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::handleRequestedCandidates):
(WebEditorClient::handleAcceptedCandidateWithSoftSpaces):
(textCheckingResultFromNSTextCheckingResult): Deleted.
(WebEditorClient::handleAcceptedCandidate): Deleted.

Move showCandidates to WebViewPrivate so that it can be overridden by a test.
* WebView/WebViewInternal.h:
* WebView/WebViewPrivate.h:

Source/WebKit2:

This patch makes handleAcceptedCandidate a public member of WebViewImpl
instead of a private member.
* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::createWeakPtr):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/autofocused-text-input.html: Added.
* TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm: Added.
(-[DoNotLeakWebView dealloc]):
(-[DoNotLeakWebView showCandidates:forString:inRect:forSelectedRange:view:completionHandler:]):
(-[DoNotLeakFrameLoadDelegate webView:didFinishLoadForFrame:]):
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201056 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/EditorClient.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebEditorClient.h
Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm
Source/WebKit/mac/WebView/WebViewInternal.h
Source/WebKit/mac/WebView/WebViewPrivate.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autofocused-text-input.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm [new file with mode: 0644]

index bfa9645..0b0d29e 100644 (file)
@@ -1,3 +1,18 @@
+2016-05-17  Beth Dakin  <bdakin@apple.com>
+
+        Make handleAcceptedCandidate a public function
+        https://bugs.webkit.org/show_bug.cgi?id=157763
+        -and corresponding-
+        rdar://problem/26206397
+
+        Reviewed by Tim Horton.
+
+        Define handleAcceptedCandidateWithSoftSpaces on EditorClient so that it can 
+        be invoked on any EditorClient. 
+        * loader/EmptyClients.h:
+        * page/EditorClient.h:
+        (WebCore::EditorClient::handleAcceptedCandidateWithSoftSpaces):
+
 2016-05-17  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed debug build fix after r201052.
index b197d3e..984f48e 100644 (file)
@@ -468,6 +468,7 @@ public:
     void didWriteSelectionToPasteboard() override { }
     void getClientPasteboardDataForRange(Range*, Vector<String>&, Vector<RefPtr<SharedBuffer>>&) override { }
     void requestCandidatesForSelection(const VisibleSelection&) override { }
+    void handleAcceptedCandidateWithSoftSpaces(TextCheckingResult) override { }
 
     void registerUndoStep(PassRefPtr<UndoStep>) override;
     void registerRedoStep(PassRefPtr<UndoStep>) override;
index 9363de5..0b43a6b 100644 (file)
@@ -100,6 +100,7 @@ public:
     virtual void didWriteSelectionToPasteboard() = 0;
     virtual void getClientPasteboardDataForRange(Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<SharedBuffer>>& pasteboardData) = 0;
     virtual void requestCandidatesForSelection(const VisibleSelection&) { }
+    virtual void handleAcceptedCandidateWithSoftSpaces(TextCheckingResult) { }
 
     // Notify an input method that a composition was voluntarily discarded by WebCore, so that it could clean up too.
     // This function is not called when a composition is closed per a request from an input method.
index 24dea45..32d1651 100644 (file)
@@ -1,3 +1,28 @@
+2016-05-17  Beth Dakin  <bdakin@apple.com>
+
+        Make handleAcceptedCandidate a public function
+        https://bugs.webkit.org/show_bug.cgi?id=157763
+        -and corresponding-
+        rdar://problem/26206397
+
+        Reviewed by Tim Horton.
+
+        This patch re-names handleAcceptedCandidate to 
+        handleAcceptedCandidateWithSoftSpaces. The function now takes a 
+        WebCore::TextCheckingResult instead of an NSTextCheckingResult and it can be 
+        called from outside of WebEditorClient.
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::handleRequestedCandidates):
+        (WebEditorClient::handleAcceptedCandidateWithSoftSpaces):
+        (textCheckingResultFromNSTextCheckingResult): Deleted.
+        (WebEditorClient::handleAcceptedCandidate): Deleted.
+
+        Move showCandidates to WebViewPrivate so that it can be overridden by a test.
+        * WebView/WebViewInternal.h:
+        * WebView/WebViewPrivate.h:
+
 2016-05-17  Dean Jackson  <dino@apple.com>
 
         Remove ES6_GENERATORS flag
index 01827fa..c72b5f7 100644 (file)
@@ -172,7 +172,7 @@ private:
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     void requestCandidatesForSelection(const WebCore::VisibleSelection&) override;
     void handleRequestedCandidates(NSInteger, NSArray<NSTextCheckingResult *> *);
-    void handleAcceptedCandidate(NSTextCheckingResult *);
+    void handleAcceptedCandidateWithSoftSpaces(WebCore::TextCheckingResult) override;
 #endif
 
     void registerUndoOrRedoStep(PassRefPtr<WebCore::UndoStep>, bool isRedo);
index 464bc16..5eb6ab5 100644 (file)
@@ -1197,44 +1197,11 @@ void WebEditorClient::handleRequestedCandidates(NSInteger sequenceNumber, NSArra
     if (!quads.isEmpty())
         rectForSelectionCandidates = frame->view()->contentsToWindow(quads[0].enclosingBoundingBox());
 
-    auto weakEditor = m_weakPtrFactory.createWeakPtr();
-    [m_webView showCandidates:candidates forString:m_paragraphContextForCandidateRequest.get() inRect:rectForSelectionCandidates forSelectedRange:m_rangeForCandidates view:m_webView completionHandler:[weakEditor](NSTextCheckingResult *acceptedCandidate) {
-        dispatch_async(dispatch_get_main_queue(), ^{
-            if (!weakEditor)
-                return;
-            weakEditor->handleAcceptedCandidate(acceptedCandidate);
-        });
-    }];
-
-}
-
-static WebCore::TextCheckingResult textCheckingResultFromNSTextCheckingResult(NSTextCheckingResult *nsResult)
-{
-    WebCore::TextCheckingResult result;
-
-    switch ([nsResult resultType]) {
-    case NSTextCheckingTypeSpelling:
-        result.type = WebCore::TextCheckingTypeSpelling;
-        break;
-    case NSTextCheckingTypeReplacement:
-        result.type = WebCore::TextCheckingTypeReplacement;
-        break;
-    case NSTextCheckingTypeCorrection:
-        result.type = WebCore::TextCheckingTypeCorrection;
-        break;
-    default:
-        result.type = WebCore::TextCheckingTypeNone;
-    }
-
-    NSRange resultRange = [nsResult range];
-    result.location = resultRange.location;
-    result.length = resultRange.length;
-    result.replacement = [nsResult replacementString];
+    [m_webView showCandidates:candidates forString:m_paragraphContextForCandidateRequest.get() inRect:rectForSelectionCandidates forSelectedRange:m_rangeForCandidates view:m_webView completionHandler:nil];
 
-    return result;
 }
 
-void WebEditorClient::handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate)
+void WebEditorClient::handleAcceptedCandidateWithSoftSpaces(TextCheckingResult acceptedCandidate)
 {
     Frame* frame = core([m_webView _selectedOrMainFrame]);
     if (!frame)
@@ -1246,16 +1213,16 @@ void WebEditorClient::handleAcceptedCandidate(NSTextCheckingResult *acceptedCand
 
     NSView <WebDocumentView> *view = [[[m_webView selectedFrame] frameView] documentView];
     if ([view isKindOfClass:[WebHTMLView class]]) {
-        NSRange range = [acceptedCandidate range];
-        if (acceptedCandidate.replacementString && [acceptedCandidate.replacementString length] > 0) {
-            NSRange replacedRange = NSMakeRange(range.location, [acceptedCandidate.replacementString length]);
+        unsigned replacementLength = acceptedCandidate.replacement.length();
+        if (replacementLength > 0) {
+            NSRange replacedRange = NSMakeRange(acceptedCandidate.location, replacementLength);
             NSRange softSpaceRange = NSMakeRange(NSMaxRange(replacedRange) - 1, 1);
-            if ([acceptedCandidate.replacementString hasSuffix:@" "])
+            if (acceptedCandidate.replacement.endsWith(" "))
                 [(WebHTMLView *)view _setSoftSpaceRange:softSpaceRange];
         }
     }
 
-    frame->editor().handleAcceptedCandidate(textCheckingResultFromNSTextCheckingResult(acceptedCandidate));
+    frame->editor().handleAcceptedCandidate(acceptedCandidate);
 }
 #endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
 
index 546d46c..cd1bb51 100644 (file)
@@ -297,7 +297,6 @@ OBJC_CLASS NSTextAlternatives;
 
 @interface WebView (WebUpdateWebViewAdditions)
 - (void)updateWebViewAdditions;
-- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
 - (BOOL)shouldRequestCandidates;
 - (void)webViewAdditionsWillDestroyView;
 @end
index 4f1a58c..9d359c5 100644 (file)
@@ -1067,6 +1067,10 @@ Could be worth adding to the API.
 - (NSCachedURLResponse *)webView:(WebView *)sender resource:(id)identifier willCacheResponse:(NSCachedURLResponse *)response fromDataSource:(WebDataSource *)dataSource;
 @end
 
+@interface WebView (WebShowCandidates)
+- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
+@end
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 49bda4d..59a5598 100644 (file)
@@ -1,3 +1,17 @@
+2016-05-17  Beth Dakin  <bdakin@apple.com>
+
+        Make handleAcceptedCandidate a public function
+        https://bugs.webkit.org/show_bug.cgi?id=157763
+        -and corresponding-
+        rdar://problem/26206397
+
+        Reviewed by Tim Horton.
+
+        This patch makes handleAcceptedCandidate a public member of WebViewImpl 
+        instead of a private member. 
+        * UIProcess/Cocoa/WebViewImpl.h:
+        (WebKit::WebViewImpl::createWeakPtr):
+
 2016-05-17  Dean Jackson  <dino@apple.com>
 
         Remove ES6_GENERATORS flag
index 3e3cae0..008dfa4 100644 (file)
@@ -478,9 +478,12 @@ public:
 
     bool windowIsFrontWindowUnderMouse(NSEvent *);
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 
+    void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
+#if USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/WebViewImplAdditions.h>
 #endif
+#endif
 
 private:
     WeakPtr<WebViewImpl> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
@@ -514,7 +517,6 @@ private:
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     void handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates);
-    void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
 #endif
 
     NSView <WebViewImplDelegate> *m_view;
index 440d85e..ea0e01f 100644 (file)
@@ -1,3 +1,20 @@
+2016-05-17  Beth Dakin  <bdakin@apple.com>
+
+        Make handleAcceptedCandidate a public function
+        https://bugs.webkit.org/show_bug.cgi?id=157763
+        -and corresponding-
+        rdar://problem/26206397
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/autofocused-text-input.html: Added.
+        * TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm: Added.
+        (-[DoNotLeakWebView dealloc]):
+        (-[DoNotLeakWebView showCandidates:forString:inRect:forSelectedRange:view:completionHandler:]):
+        (-[DoNotLeakFrameLoadDelegate webView:didFinishLoadForFrame:]):
+        (TestWebKitAPI::TEST):
+
 2016-05-17  Keith Miller  <keith_miller@apple.com>
 
         Add test262 harness support code
index 024e40f..40676b6 100644 (file)
                936F72811CD7D9EC0068A0FB /* large-video-with-audio.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 936F727F1CD7D9D00068A0FB /* large-video-with-audio.mp4 */; };
                93AF4ECE1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */; };
                93AF4ED11506F130007FD57E /* lots-of-images.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93AF4ECF1506F123007FD57E /* lots-of-images.html */; };
+               93CFA8671CEB9E38000565A8 /* autofocused-text-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */; };
+               93CFA8691CEBCFED000565A8 /* ViewWithEditableAreaLeak.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93CFA8681CEBCFED000565A8 /* ViewWithEditableAreaLeak.mm */; };
                93E943F21CD3E87E00AC08C2 /* VideoControlsManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93E943F11CD3E87E00AC08C2 /* VideoControlsManager.mm */; };
                93F1DB3414DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB3314DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp */; };
                93F1DB5714DB1B840024C362 /* NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB5614DB1B840024C362 /* NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp */; };
                        dstPath = TestWebKitAPI.resources;
                        dstSubfolderSpec = 7;
                        files = (
+                               93CFA8671CEB9E38000565A8 /* autofocused-text-input.html in Copy Resources */,
                                93625D271CD9741C006DC1F1 /* large-video-without-audio.html in Copy Resources */,
                                936F72801CD7D9EC0068A0FB /* large-video-with-audio.html in Copy Resources */,
                                936F72811CD7D9EC0068A0FB /* large-video-with-audio.mp4 in Copy Resources */,
                93AF4ECA1506F035007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages.cpp; sourceTree = "<group>"; };
                93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp; sourceTree = "<group>"; };
                93AF4ECF1506F123007FD57E /* lots-of-images.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-images.html"; sourceTree = "<group>"; };
+               93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autofocused-text-input.html"; sourceTree = "<group>"; };
+               93CFA8681CEBCFED000565A8 /* ViewWithEditableAreaLeak.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewWithEditableAreaLeak.mm; sourceTree = "<group>"; };
                93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "all-content-in-one-iframe.html"; sourceTree = "<group>"; };
                93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutMilestonesWithAllContentInFrame.cpp; sourceTree = "<group>"; };
                93E943F11CD3E87E00AC08C2 /* VideoControlsManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoControlsManager.mm; sourceTree = "<group>"; };
                                51BCEE4D1C84F52C0042C82E /* IndexedDBMultiProcess-2.html */,
                                51B1EE941C80FADD0064FB98 /* IndexedDBPersistence-1.html */,
                                51B1EE951C80FADD0064FB98 /* IndexedDBPersistence-2.html */,
+                               93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */,
                                936F727E1CD7D9D00068A0FB /* large-video-with-audio.html */,
                                936F727F1CD7D9D00068A0FB /* large-video-with-audio.mp4 */,
                                93625D261CD973AF006DC1F1 /* large-video-without-audio.html */,
                                939BFE3918E5548900883275 /* StringTruncator.mm */,
                                37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */,
                                E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */,
+                               93CFA8681CEBCFED000565A8 /* ViewWithEditableAreaLeak.mm */,
                                51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */,
                                C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */,
                                51B454EB1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm */,
                                41973B5B1AF2286A006C7B36 /* FileSystem.cpp in Sources */,
                                CD89D03A1C4EDB2A00040A04 /* WebCoreNSURLSession.mm in Sources */,
                                83B88A341C80056D00BB2418 /* HTMLParserIdioms.cpp in Sources */,
+                               93CFA8691CEBCFED000565A8 /* ViewWithEditableAreaLeak.mm in Sources */,
                                A1C4FB6E1BACCE50003742D0 /* QuickLook.mm in Sources */,
                                51B1EE8E1C80F5880064FB98 /* IndexedDBPersistence.mm in Sources */,
                                7A5623111AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autofocused-text-input.html b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autofocused-text-input.html
new file mode 100644 (file)
index 0000000..c429b18
--- /dev/null
@@ -0,0 +1,3 @@
+<body>
+<input id="input" type="text" autofocus/>
+</body>
diff --git a/Tools/TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm b/Tools/TestWebKitAPI/Tests/mac/ViewWithEditableAreaLeak.mm
new file mode 100644 (file)
index 0000000..25bce4b
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#import "PlatformUtilities.h"
+#import <WebKit/WebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+
+static bool webViewWasDeallocated = false;
+static bool didFinishLoad = false;
+static bool didCallShowCandidates = false;
+
+@interface DoNotLeakWebView : WebView
+@end
+
+@implementation DoNotLeakWebView
+
+- (void)dealloc
+{
+    webViewWasDeallocated = true;
+    [super dealloc];
+}
+
+- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock
+{
+    [super showCandidates:candidates forString:string inRect:rectOfTypedString forSelectedRange:range view:view completionHandler:completionBlock];
+    didCallShowCandidates = true;
+}
+
+@end
+
+@interface DoNotLeakFrameLoadDelegate : NSObject <WebFrameLoadDelegate> {
+}
+@end
+
+@implementation DoNotLeakFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(DoNotLeakWebView, ViewThatLoadsEditableArea)
+{
+    DoNotLeakWebView *webView = [[DoNotLeakWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
+    DoNotLeakFrameLoadDelegate *delegate = [[DoNotLeakFrameLoadDelegate alloc] init];
+    [webView setFrameLoadDelegate:delegate];
+    
+    NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"autofocused-text-input" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+    [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:contentURL]];
+    
+    TestWebKitAPI::Util::run(&didFinishLoad);
+    TestWebKitAPI::Util::run(&didCallShowCandidates);
+
+    [webView release];
+    EXPECT_TRUE(webViewWasDeallocated);
+}
+
+}
+
+#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200