WebKit Bugzilla
Attachment 368830 Details for
Bug 197523
: NSAttributedString conversion in a loop returns nil and WKUnknownError every other time
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197523-20190502154353.patch (text/plain), 5.06 KB, created by
Timothy Hatcher
on 2019-05-02 15:43:54 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Timothy Hatcher
Created:
2019-05-02 15:43:54 PDT
Size:
5.06 KB
patch
obsolete
>Subversion Revision: 244808 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c1ca7a22d5a7c6189503ad8f29bb231dfbb5f54f..bafcb58e85a0c63f8561f3efc428598c4d6791c2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,14 @@ >+2019-05-02 Timothy Hatcher <timothy@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-04-30 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r244773. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 1f6cb44e17f455c96cc0ba221c67d8f6bebc675c..177ada11eb763d932e3cbab31b2196e52a5de54f 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,25 @@ >+2019-05-02 Timothy Hatcher <timothy@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-04-30 Chris Dumez <cdumez@apple.com> > > Regression(PSON) URL scheme handlers can no longer respond asynchronously >diff --git a/Source/WebCore/editing/cocoa/HTMLConverter.mm b/Source/WebCore/editing/cocoa/HTMLConverter.mm >index b7ab890bf22ade85e6488a8ed9dcacfe0482c5b7..1f38019f253f8822e7516bf4c688265b915c1f78 100644 >--- a/Source/WebCore/editing/cocoa/HTMLConverter.mm >+++ b/Source/WebCore/editing/cocoa/HTMLConverter.mm >@@ -407,8 +407,6 @@ NSAttributedString *HTMLConverter::convert(NSDictionary** documentAttributes) > ASSERT(commonAncestorContainer); > > m_dataSource = commonAncestorContainer->document().frame()->loader().documentLoader(); >- if (!m_dataSource) >- return nil; > > Document& document = commonAncestorContainer->document(); > if (auto* body = document.bodyOrFrameset()) { >diff --git a/Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm b/Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm >index 10a76952370fb3bbcc451f45ad7aa74fae07b6ac..78f5a3a0ba96fdc9cc8ee60ddd130fde1a9cbd2a 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm >@@ -170,9 +170,6 @@ + (void)cacheWebView:(WKWebView *)webView > 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 >diff --git a/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm b/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm >index ac042460280abf10e249818963db19c5ff998511..3b58dc13f8ca45d7f0f03097c54fe5417329bdb4 100644 >--- a/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm >+++ b/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm >@@ -205,10 +205,8 @@ WebPaymentCoordinator* WebPage::paymentCoordinator() > > 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 @@ void WebPage::getContentsAsAttributedString(CompletionHandler<void(const Attribu > NSDictionary* documentAttributes = nil; > > AttributedString result; >- result.string = attributedStringFromRange(*range, &documentAttributes); >+ result.string = attributedStringFromRange(rangeOfContents(*documentElement), &documentAttributes); > result.documentAttributes = documentAttributes; > > completionHandler({ result });
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197523
:
368812
| 368830