Title: [244893] trunk/Source
- Revision
- 244893
- Author
- timo...@apple.com
- Date
- 2019-05-02 16:22:40 -0700 (Thu, 02 May 2019)
Log Message
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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (244892 => 244893)
--- trunk/Source/WebCore/ChangeLog 2019-05-02 22:24:27 UTC (rev 244892)
+++ trunk/Source/WebCore/ChangeLog 2019-05-02 23:22:40 UTC (rev 244893)
@@ -1,3 +1,14 @@
+2019-05-02 Timothy Hatcher <timo...@apple.com>
+
+ 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.
+
+ * 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.
+
2019-05-02 Chris Dumez <cdu...@apple.com>
Setting a frame's src to a _javascript_ URL should not run it synchronously
Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (244892 => 244893)
--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2019-05-02 22:24:27 UTC (rev 244892)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2019-05-02 23:22:40 UTC (rev 244893)
@@ -407,8 +407,6 @@
ASSERT(commonAncestorContainer);
m_dataSource = commonAncestorContainer->document().frame()->loader().documentLoader();
- if (!m_dataSource)
- return nil;
Document& document = commonAncestorContainer->document();
if (auto* body = document.bodyOrFrameset()) {
Modified: trunk/Source/WebKit/ChangeLog (244892 => 244893)
--- trunk/Source/WebKit/ChangeLog 2019-05-02 22:24:27 UTC (rev 244892)
+++ trunk/Source/WebKit/ChangeLog 2019-05-02 23:22:40 UTC (rev 244893)
@@ -1,3 +1,25 @@
+2019-05-02 Timothy Hatcher <timo...@apple.com>
+
+ 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.
+
+ 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.
+
2019-05-02 John Wilander <wilan...@apple.com>
Make both filterForRegistrableDomains() in WebKit::NetworkProcess use WebCore::RegistrableDomain::uncheckedCreateFromHost()
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm (244892 => 244893)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm 2019-05-02 22:24:27 UTC (rev 244892)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm 2019-05-02 23:22:40 UTC (rev 244893)
@@ -170,9 +170,6 @@
return;
[cache addObject:webView];
-
- // Load a blank page to clear anything loaded while in the cache.
- [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
}
+ (void)resetPurgeDelay
Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (244892 => 244893)
--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2019-05-02 22:24:27 UTC (rev 244892)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2019-05-02 23:22:40 UTC (rev 244893)
@@ -205,10 +205,8 @@
void WebPage::getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&& completionHandler)
{
- Frame& frame = m_page->mainFrame();
-
- RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame.document()->documentElement(), 0, INT_MAX);
- if (!range) {
+ auto* documentElement = m_page->mainFrame().document()->documentElement();
+ if (!documentElement) {
completionHandler({ });
return;
}
@@ -216,7 +214,7 @@
NSDictionary* documentAttributes = nil;
AttributedString result;
- result.string = attributedStringFromRange(*range, &documentAttributes);
+ result.string = attributedStringFromRange(rangeOfContents(*documentElement), &documentAttributes);
result.documentAttributes = documentAttributes;
completionHandler({ result });
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes