WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
46091
Add WebKit2 API to load a string as plain text
https://bugs.webkit.org/show_bug.cgi?id=46091
Summary
Add WebKit2 API to load a string as plain text
Sam Weinig
Reported
2010-09-20 07:56:47 PDT
Add WebKit2 API to load a string as plain text
Attachments
Patch
(7.34 KB, patch)
2010-09-20 07:57 PDT
,
Sam Weinig
aroben
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2010-09-20 07:57:57 PDT
Created
attachment 68083
[details]
Patch
Adam Roben (:aroben)
Comment 2
2010-09-20 08:03:13 PDT
Comment on
attachment 68083
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=68083&action=review
> WebKit2/WebProcess/WebPage/WebPage.cpp:257 > +void WebPage::commonLoadData(PassRefPtr<SharedBuffer> sharedBuffer, const String& MIMEType, const String& encodingName, const KURL& baseURL, const KURL& failingURL) > +{ > + ResourceRequest request(baseURL); > + SubstituteData substituteData(sharedBuffer, MIMEType, encodingName, failingURL); > + m_mainFrame->coreFrame()->loader()->load(request, substituteData, false); > +}
I don't think there's any need for "common" in this function name.
> WebKit2/WebProcess/WebPage/WebPage.cpp:270 > void WebPage::loadHTMLString(const String& htmlString, const String& baseURLString) > { > RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar)); > - String MIMEType("text/html"); > - String encodingName("utf-16"); > KURL baseURL = baseURLString.isEmpty() ? blankURL() : KURL(KURL(), baseURLString); > - KURL failingURL; > - > - ResourceRequest request(baseURL); > - SubstituteData substituteData(sharedBuffer.release(), MIMEType, encodingName, failingURL); > + commonLoadData(sharedBuffer, "text/html", "utf-16", baseURL, KURL()); > +} > > - m_mainFrame->coreFrame()->loader()->load(request, substituteData, false); > +void WebPage::loadPlainTextString(const String& string) > +{ > + RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(string.characters()), string.length() * sizeof(UChar)); > + commonLoadData(sharedBuffer, "text/plain", "utf-16", blankURL(), KURL()); > }
Neither of these functions seems prepared to handle sharedBuffer outliving the string it's constructed from. Is that a problem?
Sam Weinig
Comment 3
2010-09-20 08:08:20 PDT
(In reply to
comment #2
)
> (From update of
attachment 68083
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=68083&action=review
> > > WebKit2/WebProcess/WebPage/WebPage.cpp:257 > > +void WebPage::commonLoadData(PassRefPtr<SharedBuffer> sharedBuffer, const String& MIMEType, const String& encodingName, const KURL& baseURL, const KURL& failingURL) > > +{ > > + ResourceRequest request(baseURL); > > + SubstituteData substituteData(sharedBuffer, MIMEType, encodingName, failingURL); > > + m_mainFrame->coreFrame()->loader()->load(request, substituteData, false); > > +} > > I don't think there's any need for "common" in this function name.
Changed to loadData.
> > > WebKit2/WebProcess/WebPage/WebPage.cpp:270 > > void WebPage::loadHTMLString(const String& htmlString, const String& baseURLString) > > { > > RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar)); > > - String MIMEType("text/html"); > > - String encodingName("utf-16"); > > KURL baseURL = baseURLString.isEmpty() ? blankURL() : KURL(KURL(), baseURLString); > > - KURL failingURL; > > - > > - ResourceRequest request(baseURL); > > - SubstituteData substituteData(sharedBuffer.release(), MIMEType, encodingName, failingURL); > > + commonLoadData(sharedBuffer, "text/html", "utf-16", baseURL, KURL()); > > +} > > > > - m_mainFrame->coreFrame()->loader()->load(request, substituteData, false); > > +void WebPage::loadPlainTextString(const String& string) > > +{ > > + RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(string.characters()), string.length() * sizeof(UChar)); > > + commonLoadData(sharedBuffer, "text/plain", "utf-16", blankURL(), KURL()); > > } > > Neither of these functions seems prepared to handle sharedBuffer outliving the string it's constructed from. Is that a problem?
No, it is not a problem. SharedBuffer will copy the string. We should consider adding a way for the sharedBuffer to adopt an existing buffer (such as one released from a string) though,
Sam Weinig
Comment 4
2010-09-20 08:08:57 PDT
Landed in
r67849
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug