Title: [223625] trunk
Revision
223625
Author
[email protected]
Date
2017-10-18 13:20:37 -0700 (Wed, 18 Oct 2017)

Log Message

Unreviewed, rolling out r223291.

Source/WebCore:

After further investigation, this removed codepath is
something Mail may want to re-adopt. Additionally, the
original breaking change was rolled out in r223408, so
this test once again passes on ToT.

Reverted changeset:

"Remove Editor::simplifyMarkup"
https://bugs.webkit.org/show_bug.cgi?id=178271
https://trac.webkit.org/changeset/223291

Source/WebKitLegacy/mac:

See WebCore ChangeLog for more detail.

Reverted changeset:

"Remove Editor::simplifyMarkup"
https://bugs.webkit.org/show_bug.cgi?id=178271
https://trac.webkit.org/changeset/223291

Tools:

See WebCore ChangeLog for more detail.

Reverted changeset:

"Remove Editor::simplifyMarkup"
https://bugs.webkit.org/show_bug.cgi?id=178271
https://trac.webkit.org/changeset/223291

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (223624 => 223625)


--- trunk/Source/WebCore/ChangeLog	2017-10-18 20:18:38 UTC (rev 223624)
+++ trunk/Source/WebCore/ChangeLog	2017-10-18 20:20:37 UTC (rev 223625)
@@ -1,3 +1,18 @@
+2017-10-18  Wenson Hsieh  <[email protected]>
+
+        Unreviewed, rolling out r223291.
+
+        After further investigation, this removed codepath is
+        something Mail may want to re-adopt. Additionally, the
+        original breaking change was rolled out in r223408, so
+        this test once again passes on ToT.
+
+        Reverted changeset:
+
+        "Remove Editor::simplifyMarkup"
+        https://bugs.webkit.org/show_bug.cgi?id=178271
+        https://trac.webkit.org/changeset/223291
+
 2017-10-18  Sam Weinig  <[email protected]>
 
         [Settings] Move remaining simple settings to Settings.in

Modified: trunk/Source/WebCore/editing/Editor.cpp (223624 => 223625)


--- trunk/Source/WebCore/editing/Editor.cpp	2017-10-18 20:18:38 UTC (rev 223624)
+++ trunk/Source/WebCore/editing/Editor.cpp	2017-10-18 20:20:37 UTC (rev 223625)
@@ -82,6 +82,7 @@
 #include "ReplaceSelectionCommand.h"
 #include "Settings.h"
 #include "ShadowRoot.h"
+#include "SimplifyMarkupCommand.h"
 #include "SpellChecker.h"
 #include "SpellingCorrectionCommand.h"
 #include "StaticPasteboard.h"
@@ -1414,6 +1415,24 @@
     setStartNewKillRingSequence(false);
 }
 
+void Editor::simplifyMarkup(Node* startNode, Node* endNode)
+{
+    if (!startNode)
+        return;
+    if (endNode) {
+        if (&startNode->document() != &endNode->document())
+            return;
+        // check if start node is before endNode
+        Node* node = startNode;
+        while (node && node != endNode)
+            node = NodeTraversal::next(*node);
+        if (!node)
+            return;
+    }
+    
+    SimplifyMarkupCommand::create(document(), startNode, endNode ? NodeTraversal::next(*endNode) : nullptr)->apply();
+}
+
 void Editor::copyURL(const URL& url, const String& title)
 {
     copyURL(url, title, *Pasteboard::createForCopyAndPaste());

Modified: trunk/Source/WebCore/editing/Editor.h (223624 => 223625)


--- trunk/Source/WebCore/editing/Editor.h	2017-10-18 20:18:38 UTC (rev 223624)
+++ trunk/Source/WebCore/editing/Editor.h	2017-10-18 20:20:37 UTC (rev 223625)
@@ -428,6 +428,8 @@
     void updateMarkersForWordsAffectedByEditing(bool onlyHandleWordsContainingSelection);
     void deletedAutocorrectionAtPosition(const Position&, const String& originalString);
     
+    WEBCORE_EXPORT void simplifyMarkup(Node* startNode, Node* endNode);
+
     EditorParagraphSeparator defaultParagraphSeparator() const { return m_defaultParagraphSeparator; }
     void setDefaultParagraphSeparator(EditorParagraphSeparator separator) { m_defaultParagraphSeparator = separator; }
     Vector<String> dictationAlternativesForMarker(const DocumentMarker&);

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (223624 => 223625)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-10-18 20:18:38 UTC (rev 223624)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-10-18 20:20:37 UTC (rev 223625)
@@ -1,3 +1,15 @@
+2017-10-18  Wenson Hsieh  <[email protected]>
+
+        Unreviewed, rolling out r223291.
+
+        See WebCore ChangeLog for more detail.
+
+        Reverted changeset:
+
+        "Remove Editor::simplifyMarkup"
+        https://bugs.webkit.org/show_bug.cgi?id=178271
+        https://trac.webkit.org/changeset/223291
+
 2017-10-17  Keith Miller  <[email protected]>
 
         Change WebCore sources to work with unified source builds

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (223624 => 223625)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-10-18 20:18:38 UTC (rev 223624)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-10-18 20:20:37 UTC (rev 223625)
@@ -8532,6 +8532,13 @@
 
 - (void)_simplifyMarkup:(DOMNode *)startNode endNode:(DOMNode *)endNode
 {
+    Frame* coreFrame = core([self mainFrame]);
+    if (!coreFrame || !startNode)
+        return;
+    Node* coreStartNode= core(startNode);
+    if (&coreStartNode->document() != coreFrame->document())
+        return;
+    return coreFrame->editor().simplifyMarkup(coreStartNode, core(endNode));
 }
 
 @end

Modified: trunk/Tools/ChangeLog (223624 => 223625)


--- trunk/Tools/ChangeLog	2017-10-18 20:18:38 UTC (rev 223624)
+++ trunk/Tools/ChangeLog	2017-10-18 20:20:37 UTC (rev 223625)
@@ -1,3 +1,15 @@
+2017-10-18  Wenson Hsieh  <[email protected]>
+
+        Unreviewed, rolling out r223291.
+
+        See WebCore ChangeLog for more detail.
+
+        Reverted changeset:
+
+        "Remove Editor::simplifyMarkup"
+        https://bugs.webkit.org/show_bug.cgi?id=178271
+        https://trac.webkit.org/changeset/223291
+
 2017-10-18  Chris Dumez  <[email protected]>
 
         Add an efficient data structure for WebCore to query if there is a Service Worker registered for a given origin

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (223624 => 223625)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-10-18 20:18:38 UTC (rev 223624)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-10-18 20:20:37 UTC (rev 223625)
@@ -409,6 +409,7 @@
 		7CCE7ECA1A411A7E00447C4C /* RenderedImageFromDOMRange.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */; };
 		7CCE7ECB1A411A7E00447C4C /* SetAndUpdateCacheModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = 261516D515B0E60500A2C201 /* SetAndUpdateCacheModel.mm */; };
 		7CCE7ECC1A411A7E00447C4C /* SetDocumentURI.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52B8CF9515868CF000281053 /* SetDocumentURI.mm */; };
+		7CCE7ECD1A411A7E00447C4C /* SimplifyMarkup.mm in Sources */ = {isa = PBXBuildFile; fileRef = C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */; };
 		7CCE7ECE1A411A7E00447C4C /* StopLoadingFromDidFinishLoading.mm in Sources */ = {isa = PBXBuildFile; fileRef = 291861FD17BD4DC700D4E41E /* StopLoadingFromDidFinishLoading.mm */; };
 		7CCE7ECF1A411A7E00447C4C /* StopLoadingFromDidReceiveResponse.mm in Sources */ = {isa = PBXBuildFile; fileRef = E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */; };
 		7CCE7ED01A411A7E00447C4C /* StringByEvaluatingJavaScriptFromString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */; };
@@ -1672,6 +1673,7 @@
 		C507E8A614C6545B005D6B3B /* InspectorBar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorBar.mm; sourceTree = "<group>"; };
 		C5101C4E176B8BB900EE9B15 /* findRanges.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = findRanges.html; sourceTree = "<group>"; };
 		C51AFB98169F49FF009CCF66 /* FindMatches.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindMatches.mm; sourceTree = "<group>"; };
+		C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimplifyMarkup.mm; sourceTree = "<group>"; };
 		C540F783152E5A7800A40C8C /* verboseMarkup.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = verboseMarkup.html; sourceTree = "<group>"; };
 		C54237ED16B8955800E638FC /* PasteboardNotifications_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PasteboardNotifications_Bundle.cpp; sourceTree = "<group>"; };
 		C54237EE16B8955800E638FC /* PasteboardNotifications.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteboardNotifications.mm; sourceTree = "<group>"; };
@@ -2789,6 +2791,7 @@
 				3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */,
 				261516D515B0E60500A2C201 /* SetAndUpdateCacheModel.mm */,
 				52B8CF9515868CF000281053 /* SetDocumentURI.mm */,
+				C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */,
 				291861FD17BD4DC700D4E41E /* StopLoadingFromDidFinishLoading.mm */,
 				E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */,
 				3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */,
@@ -3248,6 +3251,7 @@
 				7CCE7F291A411B1000447C4C /* CustomProtocolsInvalidScheme.mm in Sources */,
 				7CCE7F2A1A411B1000447C4C /* CustomProtocolsSyncXHRTest.mm in Sources */,
 				7CCE7F2B1A411B1000447C4C /* CustomProtocolsTest.mm in Sources */,
+				751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */,
 				2DC4CF771D2D9DD800ECCC94 /* DataDetection.mm in Sources */,
 				F4D4F3B61E4E2BCB00BB2767 /* DataInteractionSimulator.mm in Sources */,
 				F4D4F3B91E4E36E400BB2767 /* DataInteractionTests.mm in Sources */,
@@ -3448,6 +3452,7 @@
 				7CCE7F141A411AE600447C4C /* ShouldKeepCurrentBackForwardListItemInList.cpp in Sources */,
 				37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */,
 				7C83E0C51D0A654600FEBCF3 /* ShrinkToFit.mm in Sources */,
+				7CCE7ECD1A411A7E00447C4C /* SimplifyMarkup.mm in Sources */,
 				2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */,
 				0F4FFA9E1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm in Sources */,
 				7CCE7F151A411AE600447C4C /* SpacebarScrolling.cpp in Sources */,
@@ -3546,7 +3551,6 @@
 				0F3B94A71A77267400DE3272 /* WKWebViewEvaluateJavaScript.mm in Sources */,
 				D34E08761E4E42E1005FF14A /* WKWebViewGetContents.mm in Sources */,
 				F4FA91811E61849B007B8C1D /* WKWebViewMacEditingTests.mm in Sources */,
-				751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */,
 				93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */,
 				9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
 				764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm (0 => 223625)


--- trunk/Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/SimplifyMarkup.mm	2017-10-18 20:20:37 UTC (rev 223625)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2012 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"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include <wtf/RetainPtr.h>
+
+#import <WebKit/DOM.h>
+#import <WebKit/WebViewPrivate.h>
+
+@interface SimplifyMarkupTest : NSObject <WebFrameLoadDelegate> {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation SimplifyMarkupTest
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKitLegacy, SimplifyMarkupTest)
+{
+    RetainPtr<WebView> webView1 = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+    RetainPtr<WebView> webView2 = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+    RetainPtr<SimplifyMarkupTest> testController = adoptNS([SimplifyMarkupTest new]);
+    
+    webView1.get().frameLoadDelegate = testController.get();
+    [[webView1.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"verboseMarkup" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+    
+    Util::run(&didFinishLoad);
+    didFinishLoad = false;
+
+    webView2.get().frameLoadDelegate = testController.get();
+    [[webView2.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"verboseMarkup" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+    
+    Util::run(&didFinishLoad);
+    didFinishLoad = false;
+
+    DOMDocument *document1 = webView1.get().mainFrameDocument;
+    NSString* markupBefore = [[document1 body] innerHTML];
+    DOMDocument *document2 = webView2.get().mainFrameDocument;
+    
+    // If start is after end, nothing is done
+    DOMNode *start = [document1 getElementById:@"test2"];
+    DOMNode *end = [document1 getElementById:@"test1"];
+
+    [webView1.get() _simplifyMarkup:[document1 body] endNode:end];
+    NSString* markupAfter = [[document1 body] innerHTML];
+
+    EXPECT_WK_STREQ(markupBefore, markupAfter);
+    EXPECT_EQ([markupBefore length], [markupAfter length]);
+
+    // If the two nodes are not in the same webView, nothing is done.
+    start = [document1 getElementById:@"test1"];
+    end = [document2 getElementById:@"test2"];
+    [webView1.get() _simplifyMarkup:start endNode:end];
+    markupAfter = [[document1 body] innerHTML];
+    
+    EXPECT_WK_STREQ(markupBefore, markupAfter);
+    EXPECT_EQ([markupBefore length], [markupAfter length]);
+
+    // If the two nodes are not in the same document, nothing is done.
+    DOMHTMLFrameElement* frame = (DOMHTMLFrameElement *)[document1 getElementById:@"test3"];
+    end = [[frame contentDocument] firstChild];
+    
+    [webView1.get() _simplifyMarkup:start endNode:end];
+    markupAfter = [[document1 body] innerHTML];
+    
+    EXPECT_WK_STREQ(markupBefore, markupAfter);
+    EXPECT_EQ([markupBefore length], [markupAfter length]);
+
+    // If the nodes are in the same webView, same document and in the right order,
+    // we should have a simplified markup.
+    [webView1.get() _simplifyMarkup:[document1 body] endNode:nil];
+    markupAfter = [[document1 body] innerHTML];
+    // We only verify that the markup has changed and that it is less verbose
+    // then the original version.
+    // The accuracy of the operation is tested by the DRT tests already.
+    EXPECT_GT([markupBefore length], [markupAfter length]);
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to