NSAttributedString conversion in a loop returns nil and WKUnknownError every other...
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 May 2019 23:22:40 +0000 (23:22 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 May 2019 23:22:40 +0000 (23:22 +0000)
commitc3765246bf65419710eadefc05441b6431e7d174
tree2a29076121a6d44d1b8011dc72b2b1863533394c
parent75e7ae64856eda538924026c39eef440c71ebd96
NSAttributedString conversion in a loop returns nil and WKUnknownError every other time.
https://bugs.webkit.org/show_bug.cgi?id=197523

Reviewed by Darin Adler.

Source/WebCore:

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::convert): Don't return early if m_dataSource is nil. This is already null
checked later and only needed in specific cases, it shouldn't fail the whole conversion.

Source/WebKit:

Caching the WKWebView was loading about:blank to unload the previous content.
This was causing subsequent rapid conversions to fail since the blank load
would be confused with the real content loading. Loading a blank page wasn't
really needed, it just helped keep the cached view in a cleaner state. Instead
of adding complexity to track the extra navigation, we can eliminate the blank load.
Ultimately a process swap will likely happen on the next navigation, and unused
cached views are closed quickly -- so stale content isn't held around too long.
This also avoids extra work and speeds up conversions a bit.

* UIProcess/API/Cocoa/NSAttributedString.mm:
(+[_WKAttributedStringWebViewCache cacheWebView:]): Don't load about:blank when caching.
* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::getContentsAsAttributedString): Use rangeOfContents() for a fail
safe way to get the range needed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm
Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm