⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267487 in webkit


Ignore:
Timestamp:
Sep 23, 2020, 10:07:50 AM (6 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r267439. rdar://problem/69441287

REGRESSION(r266075): WebContent process crashes at TextManipulationController::getPath
https://bugs.webkit.org/show_bug.cgi?id=216846

Reviewed by Wenson Hsieh.

Source/WebCore:

TextIterator does not visit node that has no renderer, so if node has become hidden, TextManipulationController
will not find content node in paragraph range during replacement.

API Test: TextManipulation.CompleteTextManipulationParagraphBecomesHidden

  • editing/TextManipulationController.cpp: (WebCore::TextManipulationController::replace):

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm: (TestWebKitAPI::TEST):

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

Location:
branches/safari-611.1.1-branch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-611.1.1-branch/Source/WebCore/ChangeLog

    r267325 r267487  
     12020-09-23  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r267439. rdar://problem/69441287
     4
     5    REGRESSION(r266075): WebContent process crashes at TextManipulationController::getPath
     6    https://bugs.webkit.org/show_bug.cgi?id=216846
     7   
     8    Reviewed by Wenson Hsieh.
     9   
     10    Source/WebCore:
     11   
     12    TextIterator does not visit node that has no renderer, so if node has become hidden, TextManipulationController
     13    will not find content node in paragraph range during replacement.
     14   
     15    API Test: TextManipulation.CompleteTextManipulationParagraphBecomesHidden
     16   
     17    * editing/TextManipulationController.cpp:
     18    (WebCore::TextManipulationController::replace):
     19   
     20    Tools:
     21   
     22    * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
     23    (TestWebKitAPI::TEST):
     24   
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2020-09-22  Sihui Liu  <sihui_liu@apple.com>
     29
     30            REGRESSION(r266075): WebContent process crashes at TextManipulationController::getPath
     31            https://bugs.webkit.org/show_bug.cgi?id=216846
     32
     33            Reviewed by Wenson Hsieh.
     34
     35            TextIterator does not visit node that has no renderer, so if node has become hidden, TextManipulationController
     36            will not find content node in paragraph range during replacement.
     37
     38            API Test: TextManipulation.CompleteTextManipulationParagraphBecomesHidden
     39
     40            * editing/TextManipulationController.cpp:
     41            (WebCore::TextManipulationController::replace):
     42
    1432020-09-20  Zalan Bujtas  <zalan@apple.com>
    244
  • branches/safari-611.1.1-branch/Source/WebCore/editing/TextManipulationController.cpp

    r266993 r267487  
    829829    }
    830830
     831    if (!firstContentNode)
     832        return ManipulationFailureType::ContentChanged;
     833
    831834    while (lastChildOfCommonAncestorInRange && lastChildOfCommonAncestorInRange->parentNode() != commonAncestor)
    832835        lastChildOfCommonAncestorInRange = lastChildOfCommonAncestorInRange->parentNode();
  • branches/safari-611.1.1-branch/Tools/ChangeLog

    r267323 r267487  
     12020-09-23  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r267439. rdar://problem/69441287
     4
     5    REGRESSION(r266075): WebContent process crashes at TextManipulationController::getPath
     6    https://bugs.webkit.org/show_bug.cgi?id=216846
     7   
     8    Reviewed by Wenson Hsieh.
     9   
     10    Source/WebCore:
     11   
     12    TextIterator does not visit node that has no renderer, so if node has become hidden, TextManipulationController
     13    will not find content node in paragraph range during replacement.
     14   
     15    API Test: TextManipulation.CompleteTextManipulationParagraphBecomesHidden
     16   
     17    * editing/TextManipulationController.cpp:
     18    (WebCore::TextManipulationController::replace):
     19   
     20    Tools:
     21   
     22    * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
     23    (TestWebKitAPI::TEST):
     24   
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2020-09-22  Sihui Liu  <sihui_liu@apple.com>
     29
     30            REGRESSION(r266075): WebContent process crashes at TextManipulationController::getPath
     31            https://bugs.webkit.org/show_bug.cgi?id=216846
     32
     33            Reviewed by Wenson Hsieh.
     34
     35            * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
     36            (TestWebKitAPI::TEST):
     37
    1382020-09-19  Lauro Moura  <lmoura@igalia.com>
    239
  • branches/safari-611.1.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm

    r266993 r267487  
    31963196}
    31973197
     3198TEST(TextManipulation, CompleteTextManipulationParagraphBecomesHidden)
     3199{
     3200    auto delegate = adoptNS([[TextManipulationDelegate alloc] init]);
     3201    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
     3202    [webView _setTextManipulationDelegate:delegate.get()];
     3203    [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html>"
     3204        "<head><style> .hidden { display: none; } </style></head>"
     3205        "<body><span>hello</span></body>"];
     3206
     3207    done = false;
     3208    [webView _startTextManipulationsWithConfiguration:nil completion:^{
     3209        done = true;
     3210    }];
     3211    TestWebKitAPI::Util::run(&done);
     3212
     3213    auto items = [delegate items];
     3214    EXPECT_EQ(items.count, 1UL);
     3215    EXPECT_EQ(items[0].tokens.count, 1UL);
     3216    EXPECT_WK_STREQ("hello", items[0].tokens[0].content);
     3217
     3218    done = false;
     3219    [webView evaluateJavaScript:@"document.querySelector('span').classList.add('hidden');" completionHandler:^(id result, NSError *) {
     3220        EXPECT_NULL(result);
     3221        done = true;
     3222    }];
     3223
     3224    done = false;
     3225    __block auto item = createItem(items[0].identifier, {{ items[0].tokens[0].identifier, @"Hello" }});
     3226    [webView _completeTextManipulationForItems:@[item.get()] completion:^(NSArray<NSError *> *errors) {
     3227        EXPECT_EQ(errors.count, 1UL);
     3228        EXPECT_EQ(errors.firstObject.domain, _WKTextManipulationItemErrorDomain);
     3229        EXPECT_EQ(errors.firstObject.code, _WKTextManipulationItemErrorContentChanged);
     3230        EXPECT_EQ(errors.firstObject.userInfo[_WKTextManipulationItemErrorItemKey], item.get());
     3231        done = true;
     3232    }];
     3233    TestWebKitAPI::Util::run(&done);
     3234
     3235    EXPECT_WK_STREQ("<span class=\"hidden\">hello</span>", [webView stringByEvaluatingJavaScript:@"document.body.innerHTML"]);
     3236}
     3237
    31983238TEST(TextManipulation, TextManipulationTokenDebugDescription)
    31993239{
Note: See TracChangeset for help on using the changeset viewer.