Changeset 244494 in webkit


Ignore:
Timestamp:
Apr 21, 2019 2:10:31 PM (5 years ago)
Author:
Wenson Hsieh
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):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r244493 r244494  
     12019-04-21  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Defer EditorState updates until the next layer tree flush in a few additional circumstances
     4        https://bugs.webkit.org/show_bug.cgi?id=197145
     5        <rdar://problem/50078170>
     6
     7        Reviewed by Darin Adler.
     8
     9        Gets rid of sendPartialEditorStateAndSchedulePostLayoutUpdate(), in favor of always scheduling a full editor
     10        state update after the next compositing flush.
     11
     12        * WebProcess/WebPage/WebPage.cpp:
     13        (WebKit::WebPage::updateEditorStateAfterLayoutIfEditabilityChanged):
     14        (WebKit::WebPage::setNeedsFontAttributes):
     15        (WebKit::WebPage::didChangeOverflowScrollPosition):
     16        (WebKit::WebPage::didChangeSelection):
     17        (WebKit::WebPage::didChangeSelectionOrOverflowScrollPosition):
     18        (WebKit::WebPage::sendPartialEditorStateAndSchedulePostLayoutUpdate): Deleted.
     19        * WebProcess/WebPage/WebPage.h:
     20        * WebProcess/WebPage/ios/WebPageIOS.mm:
     21        (WebKit::WebPage::platformEditorState const):
     22        (WebKit::WebPage::updateVisibleContentRects):
     23
    1242019-04-21  Chris Dumez  <cdumez@apple.com>
    225
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r244446 r244494  
    11261126    EditorStateIsContentEditable editorStateIsContentEditable = frame.selection().selection().isContentEditable() ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
    11271127    if (m_lastEditorStateWasContentEditable != editorStateIsContentEditable)
    1128         sendPartialEditorStateAndSchedulePostLayoutUpdate();
     1128        scheduleFullEditorStateUpdate();
    11291129}
    11301130
     
    27652765
    27662766    if (m_needsFontAttributes)
    2767         sendPartialEditorStateAndSchedulePostLayoutUpdate();
     2767        scheduleFullEditorStateUpdate();
    27682768}
    27692769
     
    52885288void WebPage::didChangeOverflowScrollPosition()
    52895289{
    5290     didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling::Deferred);
     5290    didChangeSelectionOrOverflowScrollPosition();
    52915291}
    52925292
    52935293void WebPage::didChangeSelection()
    52945294{
    5295     didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling::Immediate);
    5296 }
    5297 
    5298 void WebPage::didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling editorStateScheduling)
     5295    didChangeSelectionOrOverflowScrollPosition();
     5296}
     5297
     5298void WebPage::didChangeSelectionOrOverflowScrollPosition()
    52995299{
    53005300    Frame& frame = m_page->focusController().focusedOrMainFrame();
     
    53395339#endif
    53405340
    5341     if (editorStateScheduling == EditorStateUpdateScheduling::Immediate)
    5342         sendPartialEditorStateAndSchedulePostLayoutUpdate();
    5343     else
    5344         scheduleFullEditorStateUpdate();
     5341    scheduleFullEditorStateUpdate();
    53455342}
    53465343
     
    60256022#endif
    60266023
    6027 void WebPage::sendPartialEditorStateAndSchedulePostLayoutUpdate()
    6028 {
    6029     Frame& frame = m_page->focusController().focusedOrMainFrame();
    6030     if (frame.editor().ignoreSelectionChanges())
    6031         return;
    6032 
    6033     send(Messages::WebPageProxy::EditorStateChanged(editorState(IncludePostLayoutDataHint::No)), pageID());
    6034     scheduleFullEditorStateUpdate();
    6035 }
    6036 
    60376024void WebPage::flushPendingEditorStateUpdate()
    60386025{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r244446 r244494  
    11141114    static PluginView* pluginViewForFrame(WebCore::Frame*);
    11151115
    1116     void sendPartialEditorStateAndSchedulePostLayoutUpdate();
    11171116    void flushPendingEditorStateUpdate();
    11181117
     
    12731272    void setEditable(bool);
    12741273
    1275     enum class EditorStateUpdateScheduling { Deferred, Immediate };
    1276     void didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling);
     1274    void didChangeSelectionOrOverflowScrollPosition();
    12771275
    12781276    void increaseListLevel();
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r244473 r244494  
    216216    requiresPostLayoutData |= m_keyboardIsAttached;
    217217#endif
    218     if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No && needsLayout && !requiresPostLayoutData) {
     218    if ((shouldIncludePostLayoutData == IncludePostLayoutDataHint::No || needsLayout) && !requiresPostLayoutData) {
    219219        result.isMissingPostLayoutData = true;
    220220        return;
     
    32563256            // Ensure that the next layer tree commit contains up-to-date caret/selection rects.
    32573257            frameView.frame().selection().setCaretRectNeedsUpdate();
    3258             sendPartialEditorStateAndSchedulePostLayoutUpdate();
     3258            scheduleFullEditorStateUpdate();
    32593259        }
    32603260
  • trunk/Tools/ChangeLog

    r244492 r244494  
     12019-04-21  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Defer EditorState updates until the next layer tree flush in a few additional circumstances
     4        https://bugs.webkit.org/show_bug.cgi?id=197145
     5        <rdar://problem/50078170>
     6
     7        Reviewed by Darin Adler.
     8
     9        Adjusts several editing API tests to wait for a presentation update following a selection change, programmatic
     10        focus, or showing the font manager.
     11
     12        * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
     13        (TestWebKitAPI::TEST):
     14        * TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm:
     15        (TEST):
     16        * TestWebKitAPI/Tests/mac/FontManagerTests.mm:
     17        (TestWebKitAPI::TEST):
     18
    1192019-04-21  Brian Burg  <bburg@apple.com>
    220
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm

    r242339 r244494  
    350350    [webView synchronouslyLoadHTMLString:@"<body style=\"caret-color: red;\" contenteditable=\"true\"></body>"];
    351351    [webView stringByEvaluatingJavaScript:@"document.body.focus()"];
     352    [webView waitForNextPresentationUpdate];
    352353    UIView<UITextInputTraits_Private> *textInput = (UIView<UITextInputTraits_Private> *) [webView textInputContentView];
    353354    UIColor *insertionPointColor = textInput.insertionPointColor;
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm

    r237266 r244494  
    5151    [webView becomeFirstResponder];
    5252    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
     53    [webView waitForNextPresentationUpdate];
    5354
    5455    // FIXME: Once this test is running in an application, it should instead use
  • trunk/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm

    r242339 r244494  
    123123
    124124    [webView selectWord:nil];
     125    [webView waitForNextPresentationUpdate];
    125126    [fontManager addFontTrait:menuItemCellForFontAction(NSBoldFontMask).autorelease()];
    126127    EXPECT_WK_STREQ("bold", [webView stylePropertyAtSelectionStart:@"font-weight"]);
     
    154155    // Select "foo" and increase font size.
    155156    [webView selectWord:nil];
     157    [webView waitForNextPresentationUpdate];
    156158    [fontManager modifyFont:sizeIncreaseMenuItemCell.get()];
    157159    [fontManager modifyFont:sizeIncreaseMenuItemCell.get()];
     
    160162    [webView moveToEndOfParagraph:nil];
    161163    [webView selectWord:nil];
     164    [webView waitForNextPresentationUpdate];
    162165    [fontManager modifyFont:sizeDecreaseMenuItemCell.get()];
    163166    [fontManager modifyFont:sizeDecreaseMenuItemCell.get()];
     
    169172    [webView moveToBeginningOfParagraph:nil];
    170173    [webView selectWord:nil];
     174    [webView waitForNextPresentationUpdate];
    171175    EXPECT_WK_STREQ(@"foo", [webView selectedText]);
    172176    EXPECT_WK_STREQ(@"18px", [webView stylePropertyAtSelectionStart:@"font-size"]);
     
    191195    NSFontPanel *fontPanel = [fontManager fontPanel:YES];
    192196    [fontPanel setIsVisible:YES];
     197    [webView waitForNextPresentationUpdate];
    193198
    194199    NSFont *largeHelveticaFont = [NSFont fontWithName:@"Helvetica" size:20];
     
    240245    NSFontPanel *fontPanel = [fontManager fontPanel:YES];
    241246    [fontPanel setIsVisible:YES];
     247    [webView waitForNextPresentationUpdate];
    242248
    243249    auto textDecorationsAroundSelection = [webView] {
     
    340346    colorPanel.color = [NSColor colorWithRed:1 green:0 blue:0 alpha:1];
    341347    [webView selectWord:nil];
     348    [webView waitForNextPresentationUpdate];
    342349    [webView changeColor:colorPanel];
    343350    checkFontColorAtStartAndEndWithInputEvents("rgb(255, 0, 0)");
     
    347354    colorPanel.color = [NSColor colorWithWhite:1 alpha:0.2];
    348355    [webView selectNextWord];
     356    [webView waitForNextPresentationUpdate];
    349357    [webView changeColor:colorPanel];
    350358    checkFontColorAtStartAndEndWithInputEvents("rgba(255, 255, 255, 0.2)");
     
    461469
    462470    [webView selectWord:nil];
     471    [webView waitForNextPresentationUpdate];
    463472    options.shadowWidth = 3;
    464473    options.shadowHeight = -3;
     
    477486    auto webView = webViewForFontManagerTesting(NSFontManager.sharedFontManager, @"<body contenteditable>hello</body>");
    478487    [webView selectWord:nil];
     488    [webView waitForNextPresentationUpdate];
    479489
    480490    options.backgroundColor = [NSColor colorWithRed:1 green:0 blue:0 alpha:0.2];
Note: See TracChangeset for help on using the changeset viewer.