- a/Source/WebKit/ChangeLog +23 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2019-04-20  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 NOBODY (OOPS!).
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
1
2019-04-20  Chris Dumez  <cdumez@apple.com>
24
2019-04-20  Chris Dumez  <cdumez@apple.com>
2
25
3
        Unreviewed, fix iOS build with recent SDKs.
26
        Unreviewed, fix iOS build with recent SDKs.
- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp -19 / +6 lines
Lines 1125-1131 void WebPage::updateEditorStateAfterLayoutIfEditabilityChanged() a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec1
1125
    Frame& frame = m_page->focusController().focusedOrMainFrame();
1125
    Frame& frame = m_page->focusController().focusedOrMainFrame();
1126
    EditorStateIsContentEditable editorStateIsContentEditable = frame.selection().selection().isContentEditable() ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
1126
    EditorStateIsContentEditable editorStateIsContentEditable = frame.selection().selection().isContentEditable() ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
1127
    if (m_lastEditorStateWasContentEditable != editorStateIsContentEditable)
1127
    if (m_lastEditorStateWasContentEditable != editorStateIsContentEditable)
1128
        sendPartialEditorStateAndSchedulePostLayoutUpdate();
1128
        scheduleFullEditorStateUpdate();
1129
}
1129
}
1130
1130
1131
String WebPage::renderTreeExternalRepresentation() const
1131
String WebPage::renderTreeExternalRepresentation() const
Lines 2764-2770 void WebPage::setNeedsFontAttributes(bool needsFontAttributes) a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec2
2764
    m_needsFontAttributes = needsFontAttributes;
2764
    m_needsFontAttributes = needsFontAttributes;
2765
2765
2766
    if (m_needsFontAttributes)
2766
    if (m_needsFontAttributes)
2767
        sendPartialEditorStateAndSchedulePostLayoutUpdate();
2767
        scheduleFullEditorStateUpdate();
2768
}
2768
}
2769
2769
2770
void WebPage::restoreSessionInternal(const Vector<BackForwardListItemState>& itemStates, WasRestoredByAPIRequest restoredByAPIRequest, WebBackForwardListProxy::OverwriteExistingItem overwrite)
2770
void WebPage::restoreSessionInternal(const Vector<BackForwardListItemState>& itemStates, WasRestoredByAPIRequest restoredByAPIRequest, WebBackForwardListProxy::OverwriteExistingItem overwrite)
Lines 5287-5301 void WebPage::didChangeContents() a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec3
5287
5287
5288
void WebPage::didChangeOverflowScrollPosition()
5288
void WebPage::didChangeOverflowScrollPosition()
5289
{
5289
{
5290
    didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling::Deferred);
5290
    didChangeSelectionOrOverflowScrollPosition();
5291
}
5291
}
5292
5292
5293
void WebPage::didChangeSelection()
5293
void WebPage::didChangeSelection()
5294
{
5294
{
5295
    didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling::Immediate);
5295
    didChangeSelectionOrOverflowScrollPosition();
5296
}
5296
}
5297
5297
5298
void WebPage::didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling editorStateScheduling)
5298
void WebPage::didChangeSelectionOrOverflowScrollPosition()
5299
{
5299
{
5300
    Frame& frame = m_page->focusController().focusedOrMainFrame();
5300
    Frame& frame = m_page->focusController().focusedOrMainFrame();
5301
    // The act of getting Dictionary Popup info can make selection changes that we should not propagate to the UIProcess.
5301
    // The act of getting Dictionary Popup info can make selection changes that we should not propagate to the UIProcess.
Lines 5338-5347 void WebPage::didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateSchedu a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec4
5338
    }
5338
    }
5339
#endif
5339
#endif
5340
5340
5341
    if (editorStateScheduling == EditorStateUpdateScheduling::Immediate)
5341
    scheduleFullEditorStateUpdate();
5342
        sendPartialEditorStateAndSchedulePostLayoutUpdate();
5343
    else
5344
        scheduleFullEditorStateUpdate();
5345
}
5342
}
5346
5343
5347
void WebPage::resetFocusedElementForFrame(WebFrame* frame)
5344
void WebPage::resetFocusedElementForFrame(WebFrame* frame)
Lines 6024-6039 void WebPage::sendTouchBarMenuItemDataRemovedUpdate(HTMLMenuItemElement& element a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec5
6024
}
6021
}
6025
#endif
6022
#endif
6026
6023
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
6037
void WebPage::flushPendingEditorStateUpdate()
6024
void WebPage::flushPendingEditorStateUpdate()
6038
{
6025
{
6039
    if (!m_hasPendingEditorStateUpdate)
6026
    if (!m_hasPendingEditorStateUpdate)
- a/Source/WebKit/WebProcess/WebPage/WebPage.h -3 / +1 lines
Lines 1113-1119 public: a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec1
1113
1113
1114
    static PluginView* pluginViewForFrame(WebCore::Frame*);
1114
    static PluginView* pluginViewForFrame(WebCore::Frame*);
1115
1115
1116
    void sendPartialEditorStateAndSchedulePostLayoutUpdate();
1117
    void flushPendingEditorStateUpdate();
1116
    void flushPendingEditorStateUpdate();
1118
1117
1119
#if ENABLE(RESOURCE_LOAD_STATISTICS)
1118
#if ENABLE(RESOURCE_LOAD_STATISTICS)
Lines 1272-1279 private: a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec2
1272
    void executeEditCommand(const String&, const String&);
1271
    void executeEditCommand(const String&, const String&);
1273
    void setEditable(bool);
1272
    void setEditable(bool);
1274
1273
1275
    enum class EditorStateUpdateScheduling { Deferred, Immediate };
1274
    void didChangeSelectionOrOverflowScrollPosition();
1276
    void didChangeSelectionOrOverflowScrollPosition(EditorStateUpdateScheduling);
1277
1275
1278
    void increaseListLevel();
1276
    void increaseListLevel();
1279
    void decreaseListLevel();
1277
    void decreaseListLevel();
- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm -2 / +2 lines
Lines 215-221 void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePost a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm_sec1
215
#if !PLATFORM(IOSMAC)
215
#if !PLATFORM(IOSMAC)
216
    requiresPostLayoutData |= m_keyboardIsAttached;
216
    requiresPostLayoutData |= m_keyboardIsAttached;
217
#endif
217
#endif
218
    if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No && needsLayout && !requiresPostLayoutData) {
218
    if ((shouldIncludePostLayoutData == IncludePostLayoutDataHint::No || needsLayout) && !requiresPostLayoutData) {
219
        result.isMissingPostLayoutData = true;
219
        result.isMissingPostLayoutData = true;
220
        return;
220
        return;
221
    }
221
    }
Lines 3255-3261 void WebPage::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visi a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm_sec2
3255
        if (selectionIsInsideFixedPositionContainer(frame)) {
3255
        if (selectionIsInsideFixedPositionContainer(frame)) {
3256
            // Ensure that the next layer tree commit contains up-to-date caret/selection rects.
3256
            // Ensure that the next layer tree commit contains up-to-date caret/selection rects.
3257
            frameView.frame().selection().setCaretRectNeedsUpdate();
3257
            frameView.frame().selection().setCaretRectNeedsUpdate();
3258
            sendPartialEditorStateAndSchedulePostLayoutUpdate();
3258
            scheduleFullEditorStateUpdate();
3259
        }
3259
        }
3260
3260
3261
        frameView.didUpdateViewportOverrideRects();
3261
        frameView.didUpdateViewportOverrideRects();
- a/Tools/ChangeLog +18 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2019-04-20  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 NOBODY (OOPS!).
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
1
2019-04-20  Don Olmstead  <don.olmstead@sony.com>
19
2019-04-20  Don Olmstead  <don.olmstead@sony.com>
2
20
3
        [CMake][Win] Use target oriented design for WebKitLegacy
21
        [CMake][Win] Use target oriented design for WebKitLegacy
- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm +1 lines
Lines 349-354 TEST(EditorStateTests, CaretColorInContentEditable) a/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm_sec1
349
    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
349
    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
350
    [webView synchronouslyLoadHTMLString:@"<body style=\"caret-color: red;\" contenteditable=\"true\"></body>"];
350
    [webView synchronouslyLoadHTMLString:@"<body style=\"caret-color: red;\" contenteditable=\"true\"></body>"];
351
    [webView stringByEvaluatingJavaScript:@"document.body.focus()"];
351
    [webView stringByEvaluatingJavaScript:@"document.body.focus()"];
352
    [webView waitForNextPresentationUpdate];
352
    UIView<UITextInputTraits_Private> *textInput = (UIView<UITextInputTraits_Private> *) [webView textInputContentView];
353
    UIView<UITextInputTraits_Private> *textInput = (UIView<UITextInputTraits_Private> *) [webView textInputContentView];
353
    UIColor *insertionPointColor = textInput.insertionPointColor;
354
    UIColor *insertionPointColor = textInput.insertionPointColor;
354
    UIColor *redColor = [UIColor redColor];
355
    UIColor *redColor = [UIColor redColor];
- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm +1 lines
Lines 50-55 TEST(WebKit, WKContentViewTargetForAction) a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm_sec1
50
    [webView synchronouslyLoadTestPageNamed:@"rich-and-plain-text"];
50
    [webView synchronouslyLoadTestPageNamed:@"rich-and-plain-text"];
51
    [webView becomeFirstResponder];
51
    [webView becomeFirstResponder];
52
    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
52
    [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
53
    [webView waitForNextPresentationUpdate];
53
54
54
    // FIXME: Once this test is running in an application, it should instead use
55
    // FIXME: Once this test is running in an application, it should instead use
55
    // -[UIApplication sendAction:to:from:forEvent:] and verify that the action is dispatched to the
56
    // -[UIApplication sendAction:to:from:forEvent:] and verify that the action is dispatched to the
- a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm +10 lines
Lines 122-127 TEST(FontManagerTests, ToggleBoldAndItalicWithMenuItems) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec1
122
    auto webView = webViewForFontManagerTesting(fontManager);
122
    auto webView = webViewForFontManagerTesting(fontManager);
123
123
124
    [webView selectWord:nil];
124
    [webView selectWord:nil];
125
    [webView waitForNextPresentationUpdate];
125
    [fontManager addFontTrait:menuItemCellForFontAction(NSBoldFontMask).autorelease()];
126
    [fontManager addFontTrait:menuItemCellForFontAction(NSBoldFontMask).autorelease()];
126
    EXPECT_WK_STREQ("bold", [webView stylePropertyAtSelectionStart:@"font-weight"]);
127
    EXPECT_WK_STREQ("bold", [webView stylePropertyAtSelectionStart:@"font-weight"]);
127
    EXPECT_WK_STREQ("bold", [webView stylePropertyAtSelectionEnd:@"font-weight"]);
128
    EXPECT_WK_STREQ("bold", [webView stylePropertyAtSelectionEnd:@"font-weight"]);
Lines 153-164 TEST(FontManagerTests, ChangeFontSizeWithMenuItems) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec2
153
154
154
    // Select "foo" and increase font size.
155
    // Select "foo" and increase font size.
155
    [webView selectWord:nil];
156
    [webView selectWord:nil];
157
    [webView waitForNextPresentationUpdate];
156
    [fontManager modifyFont:sizeIncreaseMenuItemCell.get()];
158
    [fontManager modifyFont:sizeIncreaseMenuItemCell.get()];
157
    [fontManager modifyFont:sizeIncreaseMenuItemCell.get()];
159
    [fontManager modifyFont:sizeIncreaseMenuItemCell.get()];
158
160
159
    // Now select "baz" and decrease font size.
161
    // Now select "baz" and decrease font size.
160
    [webView moveToEndOfParagraph:nil];
162
    [webView moveToEndOfParagraph:nil];
161
    [webView selectWord:nil];
163
    [webView selectWord:nil];
164
    [webView waitForNextPresentationUpdate];
162
    [fontManager modifyFont:sizeDecreaseMenuItemCell.get()];
165
    [fontManager modifyFont:sizeDecreaseMenuItemCell.get()];
163
    [fontManager modifyFont:sizeDecreaseMenuItemCell.get()];
166
    [fontManager modifyFont:sizeDecreaseMenuItemCell.get()];
164
167
Lines 168-173 TEST(FontManagerTests, ChangeFontSizeWithMenuItems) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec3
168
171
169
    [webView moveToBeginningOfParagraph:nil];
172
    [webView moveToBeginningOfParagraph:nil];
170
    [webView selectWord:nil];
173
    [webView selectWord:nil];
174
    [webView waitForNextPresentationUpdate];
171
    EXPECT_WK_STREQ(@"foo", [webView selectedText]);
175
    EXPECT_WK_STREQ(@"foo", [webView selectedText]);
172
    EXPECT_WK_STREQ(@"18px", [webView stylePropertyAtSelectionStart:@"font-size"]);
176
    EXPECT_WK_STREQ(@"18px", [webView stylePropertyAtSelectionStart:@"font-size"]);
173
    EXPECT_WK_STREQ(@"18px", [webView stylePropertyAtSelectionEnd:@"font-size"]);
177
    EXPECT_WK_STREQ(@"18px", [webView stylePropertyAtSelectionEnd:@"font-size"]);
Lines 190-195 TEST(FontManagerTests, ChangeFontWithPanel) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec4
190
194
191
    NSFontPanel *fontPanel = [fontManager fontPanel:YES];
195
    NSFontPanel *fontPanel = [fontManager fontPanel:YES];
192
    [fontPanel setIsVisible:YES];
196
    [fontPanel setIsVisible:YES];
197
    [webView waitForNextPresentationUpdate];
193
198
194
    NSFont *largeHelveticaFont = [NSFont fontWithName:@"Helvetica" size:20];
199
    NSFont *largeHelveticaFont = [NSFont fontWithName:@"Helvetica" size:20];
195
    [fontPanel setPanelFont:largeHelveticaFont isMultiple:NO];
200
    [fontPanel setPanelFont:largeHelveticaFont isMultiple:NO];
Lines 239-244 TEST(FontManagerTests, ChangeAttributesWithFontEffectsBox) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec5
239
244
240
    NSFontPanel *fontPanel = [fontManager fontPanel:YES];
245
    NSFontPanel *fontPanel = [fontManager fontPanel:YES];
241
    [fontPanel setIsVisible:YES];
246
    [fontPanel setIsVisible:YES];
247
    [webView waitForNextPresentationUpdate];
242
248
243
    auto textDecorationsAroundSelection = [webView] {
249
    auto textDecorationsAroundSelection = [webView] {
244
        NSString *decorationsAtStart = [webView stylePropertyAtSelectionStart:@"-webkit-text-decorations-in-effect"];
250
        NSString *decorationsAtStart = [webView stylePropertyAtSelectionStart:@"-webkit-text-decorations-in-effect"];
Lines 339-344 TEST(FontManagerTests, ChangeFontColorWithColorPanel) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec6
339
    // 1. Select "foo" and turn it red; verify that the font element is used for fully opaque colors.
345
    // 1. Select "foo" and turn it red; verify that the font element is used for fully opaque colors.
340
    colorPanel.color = [NSColor colorWithRed:1 green:0 blue:0 alpha:1];
346
    colorPanel.color = [NSColor colorWithRed:1 green:0 blue:0 alpha:1];
341
    [webView selectWord:nil];
347
    [webView selectWord:nil];
348
    [webView waitForNextPresentationUpdate];
342
    [webView changeColor:colorPanel];
349
    [webView changeColor:colorPanel];
343
    checkFontColorAtStartAndEndWithInputEvents("rgb(255, 0, 0)");
350
    checkFontColorAtStartAndEndWithInputEvents("rgb(255, 0, 0)");
344
    EXPECT_TRUE([[webView objectByEvaluatingJavaScript:@"!!foo.querySelector('font')"] boolValue]);
351
    EXPECT_TRUE([[webView objectByEvaluatingJavaScript:@"!!foo.querySelector('font')"] boolValue]);
Lines 346-351 TEST(FontManagerTests, ChangeFontColorWithColorPanel) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec7
346
    // 2. Now select "bar" and try a few different colors, starting with a color with alpha.
353
    // 2. Now select "bar" and try a few different colors, starting with a color with alpha.
347
    colorPanel.color = [NSColor colorWithWhite:1 alpha:0.2];
354
    colorPanel.color = [NSColor colorWithWhite:1 alpha:0.2];
348
    [webView selectNextWord];
355
    [webView selectNextWord];
356
    [webView waitForNextPresentationUpdate];
349
    [webView changeColor:colorPanel];
357
    [webView changeColor:colorPanel];
350
    checkFontColorAtStartAndEndWithInputEvents("rgba(255, 255, 255, 0.2)");
358
    checkFontColorAtStartAndEndWithInputEvents("rgba(255, 255, 255, 0.2)");
351
    EXPECT_FALSE([[webView objectByEvaluatingJavaScript:@"!!bar.querySelector('font')"] boolValue]);
359
    EXPECT_FALSE([[webView objectByEvaluatingJavaScript:@"!!bar.querySelector('font')"] boolValue]);
Lines 460-465 TEST(FontManagerTests, AddFontShadowUsingFontOptions) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec8
460
    auto webView = webViewForFontManagerTesting(NSFontManager.sharedFontManager);
468
    auto webView = webViewForFontManagerTesting(NSFontManager.sharedFontManager);
461
469
462
    [webView selectWord:nil];
470
    [webView selectWord:nil];
471
    [webView waitForNextPresentationUpdate];
463
    options.shadowWidth = 3;
472
    options.shadowWidth = 3;
464
    options.shadowHeight = -3;
473
    options.shadowHeight = -3;
465
    options.hasShadow = YES;
474
    options.hasShadow = YES;
Lines 476-481 TEST(FontManagerTests, AddAndRemoveColorsUsingFontOptions) a/Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm_sec9
476
    TestFontOptions *options = TestFontOptions.sharedInstance;
485
    TestFontOptions *options = TestFontOptions.sharedInstance;
477
    auto webView = webViewForFontManagerTesting(NSFontManager.sharedFontManager, @"<body contenteditable>hello</body>");
486
    auto webView = webViewForFontManagerTesting(NSFontManager.sharedFontManager, @"<body contenteditable>hello</body>");
478
    [webView selectWord:nil];
487
    [webView selectWord:nil];
488
    [webView waitForNextPresentationUpdate];
479
489
480
    options.backgroundColor = [NSColor colorWithRed:1 green:0 blue:0 alpha:0.2];
490
    options.backgroundColor = [NSColor colorWithRed:1 green:0 blue:0 alpha:0.2];
481
    options.foregroundColor = [NSColor colorWithRed:0 green:0 blue:1 alpha:1];
491
    options.foregroundColor = [NSColor colorWithRed:0 green:0 blue:1 alpha:1];

Return to Bug 197145