Title: [244494] trunk
Revision
244494
Author
[email protected]
Date
2019-04-21 14:10:31 -0700 (Sun, 21 Apr 2019)

Log Message

Defer EditorState updates until the next layer tree flush in a few additional circumstances
https://bugs.webkit.org/show_bug.cgi?id=197145
<rdar://problem/50078170>

Reviewed by Darin Adler.

Source/WebKit:

Gets rid of sendPartialEditorStateAndSchedulePostLayoutUpdate(), in favor of always scheduling a full editor
state update after the next compositing flush.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updateEditorStateAfterLayoutIfEditabilityChanged):
(WebKit::WebPage::setNeedsFontAttributes):
(WebKit::WebPage::didChangeOverflowScrollPosition):
(WebKit::WebPage::didChangeSelection):
(WebKit::WebPage::didChangeSelectionOrOverflowScrollPosition):
(WebKit::WebPage::sendPartialEditorStateAndSchedulePostLayoutUpdate): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformEditorState const):
(WebKit::WebPage::updateVisibleContentRects):

Tools:

Adjusts several editing API tests to wait for a presentation update following a selection change, programmatic
focus, or showing the font manager.

* TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm:
(TEST):
* TestWebKitAPI/Tests/mac/FontManagerTests.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (244493 => 244494)


--- trunk/Source/WebKit/ChangeLog	2019-04-21 20:14:04 UTC (rev 244493)
+++ trunk/Source/WebKit/ChangeLog	2019-04-21 21:10:31 UTC (rev 244494)
@@ -1,3 +1,26 @@
+2019-04-21  Wenson Hsieh  <[email protected]>
+
+        Defer EditorState updates until the next layer tree flush in a few additional circumstances
+        https://bugs.webkit.org/show_bug.cgi?id=197145
+        <rdar://problem/50078170>
+
+        Reviewed by Darin Adler.
+
+        Gets rid of sendPartialEditorStateAndSchedulePostLayoutUpdate(), in favor of always scheduling a full editor
+        state update after the next compositing flush.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updateEditorStateAfterLayoutIfEditabilityChanged):
+        (WebKit::WebPage::setNeedsFontAttributes):
+        (WebKit::WebPage::didChangeOverflowScrollPosition):
+        (WebKit::WebPage::didChangeSelection):
+        (WebKit::WebPage::didChangeSelectionOrOverflowScrollPosition):
+        (WebKit::WebPage::sendPartialEditorStateAndSchedulePostLayoutUpdate): Deleted.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::platformEditorState const):
+        (WebKit::WebPage::updateVisibleContentRects):
+
 2019-04-21  Chris Dumez  <[email protected]>
 
         Regression(r243767) WebFrame::m_navigationIsContinuingInAnotherProcess flag is never reset

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (244493 => 244494)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-04-21 20:14:04 UTC (rev 244493)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-04-21 21:10:31 UTC (rev 244494)
@@ -1125,7 +1125,7 @@
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     EditorStateIsContentEditable editorStateIsContentEditable = frame.selection().selection().isContentEditable() ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
     if (m_lastEditorStateWasContentEditable != editorStateIsContentEditable)
-        sendPartialEditorStateAndSchedulePostLayoutUpdate();
+        scheduleFullEditorStateUpdate();
 }
 
 String WebPage::renderTreeExternalRepresentation() const
@@ -2764,7 +2764,7 @@
     m_needsFontAttributes = needsFontAttributes;
 
     if (m_needsFontAttributes)
-        sendPartialEditorStateAndSchedulePostLayoutUpdate();
+        scheduleFullEditorStateUpdate();
 }
 
 void WebPage::restoreSessionInternal(const Vector<BackForwardListItemState>& itemStates, WasRestoredByAPIRequest restoredByAPIRequest, WebBackForwardListProxy::OverwriteExistingItem overwrite)
@@ -5287,15 +5287,15 @@
 
 void WebPage::didChangeOverflowScrollPosition()
 {
-    didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling::Deferred);
+    didChangeSelectionOrOverflowScrollPosition();
 }
 
 void WebPage::didChangeSelection()
 {
-    didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling::Immediate);
+    didChangeSelectionOrOverflowScrollPosition();
 }
 
-void WebPage::didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling editorStateScheduling)
+void WebPage::didChangeSelectionOrOverflowScrollPosition()
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     // The act of getting Dictionary Popup info can make selection changes that we should not propagate to the UIProcess.
@@ -5338,10 +5338,7 @@
     }
 #endif
 
-    if (editorStateScheduling == EditorStateUpdateScheduling::Immediate)
-        sendPartialEditorStateAndSchedulePostLayoutUpdate();
-    else
-        scheduleFullEditorStateUpdate();
+    scheduleFullEditorStateUpdate();
 }
 
 void WebPage::resetFocusedElementForFrame(WebFrame* frame)
@@ -6024,16 +6021,6 @@
 }
 #endif
 
-void WebPage::sendPartialEditorStateAndSchedulePostLayoutUpdate()
-{
-    Frame& frame = m_page->focusController().focusedOrMainFrame();
-    if (frame.editor().ignoreSelectionChanges())
-        return;
-
-    send(Messages::WebPageProxy::EditorStateChanged(editorState(IncludePostLayoutDataHint::No)), pageID());
-    scheduleFullEditorStateUpdate();
-}
-
 void WebPage::flushPendingEditorStateUpdate()
 {
     if (!m_hasPendingEditorStateUpdate)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (244493 => 244494)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-04-21 20:14:04 UTC (rev 244493)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-04-21 21:10:31 UTC (rev 244494)
@@ -1113,7 +1113,6 @@
 
     static PluginView* pluginViewForFrame(WebCore::Frame*);
 
-    void sendPartialEditorStateAndSchedulePostLayoutUpdate();
     void flushPendingEditorStateUpdate();
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
@@ -1272,8 +1271,7 @@
     void executeEditCommand(const String&, const String&);
     void setEditable(bool);
 
-    enum class EditorStateUpdateScheduling { Deferred, Immediate };
-    void didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling);
+    void didChangeSelectionOrOverflowScrollPosition();
 
     void increaseListLevel();
     void decreaseListLevel();

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (244493 => 244494)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-04-21 20:14:04 UTC (rev 244493)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-04-21 21:10:31 UTC (rev 244494)
@@ -215,7 +215,7 @@
 #if !PLATFORM(IOSMAC)
     requiresPostLayoutData |= m_keyboardIsAttached;
 #endif
-    if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No && needsLayout && !requiresPostLayoutData) {
+    if ((shouldIncludePostLayoutData == IncludePostLayoutDataHint::No || needsLayout) && !requiresPostLayoutData) {
         result.isMissingPostLayoutData = true;
         return;
     }
@@ -3255,7 +3255,7 @@
         if (selectionIsInsideFixedPositionContainer(frame)) {
             // Ensure that the next layer tree commit contains up-to-date caret/selection rects.
             frameView.frame().selection().setCaretRectNeedsUpdate();
-            sendPartialEditorStateAndSchedulePostLayoutUpdate();
+            scheduleFullEditorStateUpdate();
         }
 
         frameView.didUpdateViewportOverrideRects();

Modified: trunk/Tools/ChangeLog (244493 => 244494)


--- trunk/Tools/ChangeLog	2019-04-21 20:14:04 UTC (rev 244493)
+++ trunk/Tools/ChangeLog	2019-04-21 21:10:31 UTC (rev 244494)
@@ -1,3 +1,21 @@
+2019-04-21  Wenson Hsieh  <[email protected]>
+
+        Defer EditorState updates until the next layer tree flush in a few additional circumstances
+        https://bugs.webkit.org/show_bug.cgi?id=197145
+        <rdar://problem/50078170>
+
+        Reviewed by Darin Adler.
+
+        Adjusts several editing API tests to wait for a presentation update following a selection change, programmatic
+        focus, or showing the font manager.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/mac/FontManagerTests.mm:
+        (TestWebKitAPI::TEST):
+
 2019-04-21  Brian Burg  <[email protected]>
 
         WebDriver: add hooks to make it possible to easily run WPT WebDriver web server by itself

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm (244493 => 244494)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm	2019-04-21 20:14:04 UTC (rev 244493)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm	2019-04-21 21:10:31 UTC (rev 244494)
@@ -349,6 +349,7 @@
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     [webView synchronouslyLoadHTMLString:@"<body style=\"caret-color: red;\" contenteditable=\"true\"></body>"];
     [webView stringByEvaluatingJavaScript:@"document.body.focus()"];
+    [webView waitForNextPresentationUpdate];
     UIView<UITextInputTraits_Private> *textInput = (UIView<UITextInputTraits_Private> *) [webView textInputContentView];
     UIColor *insertionPointColor = textInput.insertionPointColor;
     UIColor *redColor = [UIColor redColor];

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm (244493 => 244494)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm	2019-04-21 20:14:04 UTC (rev 244493)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm	2019-04-21 21:10:31 UTC (rev 244494)
@@ -50,6 +50,7 @@
     [webView synchronouslyLoadTestPageNamed:@"rich-and-plain-text"];
     [webView becomeFirstResponder];
     [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
+    [webView waitForNextPresentationUpdate];
 
     // FIXME: Once this test is running in an application, it should instead use
     // -[UIApplication sendAction:to:from:forEvent:] and verify that the action is dispatched to the

Modified: trunk/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm (244493 => 244494)


--- trunk/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm	2019-04-21 20:14:04 UTC (rev 244493)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm	2019-04-21 21:10:31 UTC (rev 244494)
@@ -122,6 +122,7 @@
     auto webView = webViewForFontManagerTesting(fontManager);
 
     [webView selectWord:nil];
+    [webView waitForNextPresentationUpdate];
     [fontManager addFontTrait:menuItemCellForFontAction(NSBoldFontMask).autorelease()];
     EXPECT_WK_STREQ("bold", [webView stylePropertyAtSelectionStart:@"font-weight"]);
     EXPECT_WK_STREQ("bold", [webView stylePropertyAtSelectionEnd:@"font-weight"]);
@@ -153,6 +154,7 @@
 
     // Select "foo" and increase font size.
     [webView selectWord:nil];
+    [webView waitForNextPresentationUpdate];
     [fontManager modifyFont:sizeIncreaseMenuItemCell.get()];
     [fontManager modifyFont:sizeIncreaseMenuItemCell.get()];
 
@@ -159,6 +161,7 @@
     // Now select "baz" and decrease font size.
     [webView moveToEndOfParagraph:nil];
     [webView selectWord:nil];
+    [webView waitForNextPresentationUpdate];
     [fontManager modifyFont:sizeDecreaseMenuItemCell.get()];
     [fontManager modifyFont:sizeDecreaseMenuItemCell.get()];
 
@@ -168,6 +171,7 @@
 
     [webView moveToBeginningOfParagraph:nil];
     [webView selectWord:nil];
+    [webView waitForNextPresentationUpdate];
     EXPECT_WK_STREQ(@"foo", [webView selectedText]);
     EXPECT_WK_STREQ(@"18px", [webView stylePropertyAtSelectionStart:@"font-size"]);
     EXPECT_WK_STREQ(@"18px", [webView stylePropertyAtSelectionEnd:@"font-size"]);
@@ -190,6 +194,7 @@
 
     NSFontPanel *fontPanel = [fontManager fontPanel:YES];
     [fontPanel setIsVisible:YES];
+    [webView waitForNextPresentationUpdate];
 
     NSFont *largeHelveticaFont = [NSFont fontWithName:@"Helvetica" size:20];
     [fontPanel setPanelFont:largeHelveticaFont isMultiple:NO];
@@ -239,6 +244,7 @@
 
     NSFontPanel *fontPanel = [fontManager fontPanel:YES];
     [fontPanel setIsVisible:YES];
+    [webView waitForNextPresentationUpdate];
 
     auto textDecorationsAroundSelection = [webView] {
         NSString *decorationsAtStart = [webView stylePropertyAtSelectionStart:@"-webkit-text-decorations-in-effect"];
@@ -339,6 +345,7 @@
     // 1. Select "foo" and turn it red; verify that the font element is used for fully opaque colors.
     colorPanel.color = [NSColor colorWithRed:1 green:0 blue:0 alpha:1];
     [webView selectWord:nil];
+    [webView waitForNextPresentationUpdate];
     [webView changeColor:colorPanel];
     checkFontColorAtStartAndEndWithInputEvents("rgb(255, 0, 0)");
     EXPECT_TRUE([[webView objectByEvaluatingJavaScript:@"!!foo.querySelector('font')"] boolValue]);
@@ -346,6 +353,7 @@
     // 2. Now select "bar" and try a few different colors, starting with a color with alpha.
     colorPanel.color = [NSColor colorWithWhite:1 alpha:0.2];
     [webView selectNextWord];
+    [webView waitForNextPresentationUpdate];
     [webView changeColor:colorPanel];
     checkFontColorAtStartAndEndWithInputEvents("rgba(255, 255, 255, 0.2)");
     EXPECT_FALSE([[webView objectByEvaluatingJavaScript:@"!!bar.querySelector('font')"] boolValue]);
@@ -460,6 +468,7 @@
     auto webView = webViewForFontManagerTesting(NSFontManager.sharedFontManager);
 
     [webView selectWord:nil];
+    [webView waitForNextPresentationUpdate];
     options.shadowWidth = 3;
     options.shadowHeight = -3;
     options.hasShadow = YES;
@@ -476,6 +485,7 @@
     TestFontOptions *options = TestFontOptions.sharedInstance;
     auto webView = webViewForFontManagerTesting(NSFontManager.sharedFontManager, @"<body contenteditable>hello</body>");
     [webView selectWord:nil];
+    [webView waitForNextPresentationUpdate];
 
     options.backgroundColor = [NSColor colorWithRed:1 green:0 blue:0 alpha:0.2];
     options.foregroundColor = [NSColor colorWithRed:0 green:0 blue:1 alpha:1];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to