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

Changeset 267439 in webkit


Ignore:
Timestamp:
Sep 22, 2020, 3:21:43 PM (6 years ago)
Author:
sihui_liu@apple.com
Message:

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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267437 r267439  
     12020-09-22  Sihui Liu  <sihui_liu@apple.com>
     2
     3        REGRESSION(r266075): WebContent process crashes at TextManipulationController::getPath
     4        https://bugs.webkit.org/show_bug.cgi?id=216846
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        TextIterator does not visit node that has no renderer, so if node has become hidden, TextManipulationController
     9        will not find content node in paragraph range during replacement.
     10
     11        API Test: TextManipulation.CompleteTextManipulationParagraphBecomesHidden
     12
     13        * editing/TextManipulationController.cpp:
     14        (WebCore::TextManipulationController::replace):
     15
    1162020-09-22  Zalan Bujtas  <zalan@apple.com>
    217
  • trunk/Source/WebCore/editing/TextManipulationController.cpp

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

    r267424 r267439  
     12020-09-22  Sihui Liu  <sihui_liu@apple.com>
     2
     3        REGRESSION(r266075): WebContent process crashes at TextManipulationController::getPath
     4        https://bugs.webkit.org/show_bug.cgi?id=216846
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
     9        (TestWebKitAPI::TEST):
     10
    1112020-09-22  Keith Rollin  <krollin@apple.com>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm

    r266993 r267439  
    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.