Source/WebKit/mac: Remove all deprecatedCharacters use from WebKit directory
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Mar 2014 02:44:57 +0000 (02:44 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Mar 2014 02:44:57 +0000 (02:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130305

Reviewed by Andreas Kling.

* History/BinaryPropertyList.cpp:
(BinaryPropertyListSerializer::appendStringObject): Use operator[]
instead of deprecatedCharacters.

Source/WebKit/win: Remove all deprecatedCharacters use from WebKit
https://bugs.webkit.org/show_bug.cgi?id=130305

Reviewed by Andreas Kling.

* AccessibleTextImpl.cpp:
(AccessibleText::get_text): Use BString instead of SysAllocStringLen,
which handles String directly.
(AccessibleText::get_textBeforeOffset): Ditto.
(AccessibleText::get_textAfterOffset): Ditto.
(AccessibleText::get_textAtOffset): Ditto.
(AccessibleText::get_attributes): Ditto.
* DOMCSSClasses.cpp:
(DOMCSSStyleDeclaration::getPropertyValue): Ditto.
* DOMCoreClasses.cpp:
(DOMNode::nodeValue): Ditto.
(DOMElement::getAttribute): Ditto.
(DOMElement::font): Rework this to leak a string, since it returns a
pointer to a font family name's characters with no defined lifetime.

* DOMHTMLClasses.cpp:
(DOMHTMLElement::innerText): Use BString's String-based constructor,
instead of explicitly passing a character pointer.
(DOMHTMLFormElement::action): Ditto.
(DOMHTMLFormElement::method): Ditto.
(DOMHTMLInputElement::value): Ditto.
(DOMHTMLTextAreaElement::value): Ditto.

* MarshallingHelpers.cpp:
(MarshallingHelpers::PathStringToFileCFURLRef): Use String::createCFString.

* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::checkSpellingOfString): Use StringView::upconvertedCharacters.
(WebEditorClient::checkGrammarOfString): Ditto.

* WebDataSource.cpp:
(WebDataSource::unreachableURL): Use BString's String-based constructor,
instead of explicitly passing a character pointer.

* WebDownload.cpp:
(WebDownload::bundlePathForTargetPath): Use BString instead of SysAllocStringLen.

* WebDownloadCFNet.cpp:
(WebDownload::didFinish): Use BString's String-based constructor,
instead of explicitly passing a character pointer.
* WebDownloadCurl.cpp:
(WebDownload::didReceiveResponse): Ditto.

* WebElementPropertyBag.cpp:
(convertStringToVariant): Use BString instead of SysAllocStringLen.
* WebFrame.cpp:
(WebFrame::searchForLabelsBeforeElement): Ditto.
(WebFrame::matchLabelsAgainstElement): Ditto.

* WebHistory.cpp:
(WebHistory::addVisitedLinksToPageGroup): Use a better loop and call
visitedLinkHash, since it can take a String.

* WebKitGraphics.cpp:
(CenterTruncateStringToWidth): Use StringView::getCharactersWithUpconvert.
(RightTruncateStringToWidth): Ditto.

* WebView.cpp:
(WebView::applicationNameForUserAgent): Use BString instead of SysAllocStringLen.
(WebView::customUserAgent): Ditto.
(WebView::groupName): Ditto.
(WebView::selectedText): Ditto.
(WebView::onIMERequestReconvertString): Use StringView::getCharactersWithUpconvert.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165715 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/History/BinaryPropertyList.cpp
Source/WebKit/win/AccessibleTextImpl.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMCSSClasses.cpp
Source/WebKit/win/DOMCoreClasses.cpp
Source/WebKit/win/DOMHTMLClasses.cpp
Source/WebKit/win/MarshallingHelpers.cpp
Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp
Source/WebKit/win/WebDataSource.cpp
Source/WebKit/win/WebDownload.cpp
Source/WebKit/win/WebDownloadCFNet.cpp
Source/WebKit/win/WebDownloadCurl.cpp
Source/WebKit/win/WebElementPropertyBag.cpp
Source/WebKit/win/WebFrame.cpp
Source/WebKit/win/WebHistory.cpp
Source/WebKit/win/WebKitGraphics.cpp
Source/WebKit/win/WebView.cpp

index ff4e986..c1a2da1 100644 (file)
@@ -1,3 +1,14 @@
+2014-03-16  Darin Adler  <darin@apple.com>
+
+        Remove all deprecatedCharacters use from WebKit directory
+        https://bugs.webkit.org/show_bug.cgi?id=130305
+
+        Reviewed by Andreas Kling.
+
+        * History/BinaryPropertyList.cpp:
+        (BinaryPropertyListSerializer::appendStringObject): Use operator[]
+        instead of deprecatedCharacters.
+
 2014-03-14  Mark Rowe  <mrowe@apple.com>
 
         Fix the production build.
index 9309825..4954a54 100644 (file)
@@ -691,9 +691,8 @@ void BinaryPropertyListSerializer::appendInteger(size_t integer)
 void BinaryPropertyListSerializer::appendStringObject(const String& string)
 {
     startObject();
-    const UChar* characters = string.deprecatedCharacters();
     unsigned length = string.length();
-    if (charactersAreAllASCII(characters, length)) {
+    if (string.containsOnlyASCII()) {
         if (length <= maxLengthInMarkerByte)
             appendByte(static_cast<unsigned char>(asciiStringMarkerByte | length));
         else {
@@ -701,7 +700,7 @@ void BinaryPropertyListSerializer::appendStringObject(const String& string)
             appendInteger(length);
         }
         for (unsigned i = 0; i < length; ++i)
-            appendByte(characters[i]);
+            appendByte(string[i]);
     } else {
         if (length <= maxLengthInMarkerByte)
             appendByte(static_cast<unsigned char>(unicodeStringMarkerByte | length));
@@ -710,8 +709,8 @@ void BinaryPropertyListSerializer::appendStringObject(const String& string)
             appendInteger(length);
         }
         for (unsigned i = 0; i < length; ++i) {
-            appendByte(characters[i] >> 8);
-            appendByte(characters[i]);
+            appendByte(string[i] >> 8);
+            appendByte(string[i]);
         }
     }
 }
index 2edc366..0d70b5c 100644 (file)
@@ -192,7 +192,7 @@ HRESULT AccessibleText::get_text(long startOffset, long endOffset, BSTR* text)
     endOffset = convertSpecialOffset(endOffset);
     WTF::String substringText = m_object->stringValue().substring(startOffset, endOffset - startOffset);
 
-    *text = SysAllocStringLen(substringText.deprecatedCharacters(), substringText.length());
+    *text = BString(substringText).release();
     if (substringText.length() && !*text)
         return E_OUTOFMEMORY;
 
@@ -256,7 +256,7 @@ HRESULT AccessibleText::get_textBeforeOffset(long offset, enum IA2TextBoundaryTy
         return S_FALSE;
 
     WTF::String substringText = m_object->text().substring(*startOffset, *endOffset - *startOffset);
-    *text = SysAllocStringLen(substringText.deprecatedCharacters(), substringText.length());
+    *text = BString(substringText).release();
 
     if (substringText.length() && !*text)
         return E_OUTOFMEMORY;
@@ -324,7 +324,7 @@ HRESULT AccessibleText::get_textAfterOffset(long offset, enum IA2TextBoundaryTyp
         return S_FALSE;
 
     WTF::String substringText = m_object->text().substring(*startOffset, *endOffset - *startOffset);
-    *text = SysAllocStringLen(substringText.deprecatedCharacters(), substringText.length());
+    *text = BString(substringText).release();
     if (substringText.length() && !*text)
         return E_OUTOFMEMORY;
 
@@ -384,7 +384,7 @@ HRESULT AccessibleText::get_textAtOffset(long offset, enum IA2TextBoundaryType b
         return S_FALSE;
 
     WTF::String substringText = m_object->text().substring(*startOffset, *endOffset - *startOffset);
-    *text = SysAllocStringLen(substringText.deprecatedCharacters(), substringText.length());
+    *text = BString(substringText).release();
 
     if (substringText.length() && !*text)
         return E_OUTOFMEMORY;
@@ -674,7 +674,7 @@ HRESULT AccessibleText::setAttributes(long startOffset, long endOffset, BSTR* at
 HRESULT AccessibleText::get_attributes(BSTR* attributes)
 {
     WTF::String text("text-model:a1");
-    *attributes = SysAllocStringLen(text.deprecatedCharacters(), text.length());
+    *attributes = BString(text).release();
     return S_OK;
 }
 
index 051bf12..c4e02ee 100644 (file)
@@ -1,3 +1,74 @@
+2014-03-16  Darin Adler  <darin@apple.com>
+
+        Remove all deprecatedCharacters use from WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=130305
+
+        Reviewed by Andreas Kling.
+
+        * AccessibleTextImpl.cpp:
+        (AccessibleText::get_text): Use BString instead of SysAllocStringLen,
+        which handles String directly.
+        (AccessibleText::get_textBeforeOffset): Ditto.
+        (AccessibleText::get_textAfterOffset): Ditto.
+        (AccessibleText::get_textAtOffset): Ditto.
+        (AccessibleText::get_attributes): Ditto.
+        * DOMCSSClasses.cpp:
+        (DOMCSSStyleDeclaration::getPropertyValue): Ditto.
+        * DOMCoreClasses.cpp:
+        (DOMNode::nodeValue): Ditto.
+        (DOMElement::getAttribute): Ditto.
+        (DOMElement::font): Rework this to leak a string, since it returns a
+        pointer to a font family name's characters with no defined lifetime.
+
+        * DOMHTMLClasses.cpp:
+        (DOMHTMLElement::innerText): Use BString's String-based constructor,
+        instead of explicitly passing a character pointer.
+        (DOMHTMLFormElement::action): Ditto.
+        (DOMHTMLFormElement::method): Ditto.
+        (DOMHTMLInputElement::value): Ditto.
+        (DOMHTMLTextAreaElement::value): Ditto.
+
+        * MarshallingHelpers.cpp:
+        (MarshallingHelpers::PathStringToFileCFURLRef): Use String::createCFString.
+
+        * WebCoreSupport/WebEditorClient.cpp:
+        (WebEditorClient::checkSpellingOfString): Use StringView::upconvertedCharacters.
+        (WebEditorClient::checkGrammarOfString): Ditto.
+
+        * WebDataSource.cpp:
+        (WebDataSource::unreachableURL): Use BString's String-based constructor,
+        instead of explicitly passing a character pointer.
+
+        * WebDownload.cpp:
+        (WebDownload::bundlePathForTargetPath): Use BString instead of SysAllocStringLen.
+
+        * WebDownloadCFNet.cpp:
+        (WebDownload::didFinish): Use BString's String-based constructor,
+        instead of explicitly passing a character pointer.
+        * WebDownloadCurl.cpp:
+        (WebDownload::didReceiveResponse): Ditto.
+
+        * WebElementPropertyBag.cpp:
+        (convertStringToVariant): Use BString instead of SysAllocStringLen.
+        * WebFrame.cpp:
+        (WebFrame::searchForLabelsBeforeElement): Ditto.
+        (WebFrame::matchLabelsAgainstElement): Ditto.
+
+        * WebHistory.cpp:
+        (WebHistory::addVisitedLinksToPageGroup): Use a better loop and call
+        visitedLinkHash, since it can take a String.
+
+        * WebKitGraphics.cpp:
+        (CenterTruncateStringToWidth): Use StringView::getCharactersWithUpconvert.
+        (RightTruncateStringToWidth): Ditto.
+
+        * WebView.cpp:
+        (WebView::applicationNameForUserAgent): Use BString instead of SysAllocStringLen.
+        (WebView::customUserAgent): Ditto.
+        (WebView::groupName): Ditto.
+        (WebView::selectedText): Ditto.
+        (WebView::onIMERequestReconvertString): Use StringView::getCharactersWithUpconvert.
+
 2014-03-14  Maciej Stachowiak  <mjs@apple.com>
 
         Replace "Apple Computer, Inc." with "Apple Inc." in copyright headers
index 8a5780c..7435fe2 100644 (file)
@@ -27,6 +27,7 @@
 #include "WebKitDLL.h"
 #include "DOMCSSClasses.h"
 
+#include <WebCore/BString.h>
 #include <wtf/text/WTFString.h>
 
 // DOMCSSStyleDeclaration - DOMCSSStyleDeclaration ----------------------------
@@ -102,7 +103,7 @@ HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyValue(
 {
     WTF::String propertyNameString(propertyName);
     WTF::String value = m_style->getPropertyValue(propertyNameString);
-    *result = SysAllocStringLen(value.deprecatedCharacters(), value.length());
+    *result = WebCore::BString(value).release();
     if (value.length() && !*result)
         return E_OUTOFMEMORY;
     return S_OK;
index ecaf29a..8b9d52e 100644 (file)
@@ -122,7 +122,7 @@ HRESULT STDMETHODCALLTYPE DOMNode::nodeValue(
     if (!m_node)
         return E_FAIL;
     WTF::String nodeValueStr = m_node->nodeValue();
-    *result = SysAllocStringLen(nodeValueStr.deprecatedCharacters(), nodeValueStr.length());
+    *result = BString(nodeValueStr).release();
     if (nodeValueStr.length() && !*result)
         return E_OUTOFMEMORY;
     return S_OK;
@@ -1033,7 +1033,7 @@ HRESULT STDMETHODCALLTYPE DOMElement::getAttribute(
         return E_FAIL;
     WTF::String nameString(name, SysStringLen(name));
     WTF::String& attrValueString = (WTF::String&) m_element->getAttribute(nameString);
-    *result = SysAllocStringLen(attrValueString.deprecatedCharacters(), attrValueString.length());
+    *result = BString(attrValueString).release();
     if (attrValueString.length() && !*result)
         return E_OUTOFMEMORY;
     return S_OK;
@@ -1257,7 +1257,12 @@ HRESULT STDMETHODCALLTYPE DOMElement::font(WebFontDescription* webFontDescriptio
 
     FontDescription fontDescription = renderer->style().font().fontDescription();
     AtomicString family = fontDescription.firstFamily();
-    webFontDescription->family = family.string().deprecatedCharacters();
+
+    // FIXME: This leaks. Delete this whole function to get rid of the leak.
+    UChar* familyCharactersBuffer = new UChar[family.length()];
+    StringView(family.string()).getCharactersWithUpconvert(familyCharactersBuffer);
+
+    webFontDescription->family = familyCharactersBuffer;
     webFontDescription->familyLength = family.length();
     webFontDescription->size = fontDescription.computedSize();
     webFontDescription->bold = fontDescription.weight() >= WebCore::FontWeight600;
index a2f082c..b38c77a 100644 (file)
@@ -483,7 +483,7 @@ HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerText(
 {
     ASSERT(m_element && m_element->isHTMLElement());
     WTF::String innerTextString = toHTMLElement(m_element)->innerText();
-    *result = BString(innerTextString.deprecatedCharacters(), innerTextString.length()).release();
+    *result = BString(innerTextString).release();
     return S_OK;
 }
         
@@ -561,7 +561,7 @@ HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::action(
 {
     ASSERT(m_element && isHTMLFormElement(m_element));
     WTF::String actionString = toHTMLFormElement(m_element)->action();
-    *result = BString(actionString.deprecatedCharacters(), actionString.length()).release();
+    *result = BString(actionString).release();
     return S_OK;
 }
     
@@ -591,7 +591,7 @@ HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::method(
 {
     ASSERT(m_element && isHTMLFormElement(m_element));
     WTF::String methodString = toHTMLFormElement(m_element)->method();
-    *result = BString(methodString.deprecatedCharacters(), methodString.length()).release();
+    *result = BString(methodString).release();
     return S_OK;
 }
     
@@ -1210,7 +1210,7 @@ HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::value(
     ASSERT(m_element && isHTMLInputElement(m_element));
     HTMLInputElement* inputElement = toHTMLInputElement(m_element);
     WTF::String valueString = inputElement->value();
-    *result = BString(valueString.deprecatedCharacters(), valueString.length()).release();
+    *result = BString(valueString).release();
     if (valueString.length() && !*result)
         return E_OUTOFMEMORY;
     return S_OK;
@@ -1547,7 +1547,7 @@ HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::value(
     ASSERT(m_element && isHTMLTextAreaElement(m_element));
     HTMLTextAreaElement* textareaElement = toHTMLTextAreaElement(m_element);
     WTF::String valueString = textareaElement->value();
-    *result = BString(valueString.deprecatedCharacters(), valueString.length()).release();
+    *result = BString(valueString).release();
     if (valueString.length() && !*result)
         return E_OUTOFMEMORY;
     return S_OK;
index e523731..3320011 100644 (file)
@@ -51,10 +51,7 @@ BSTR MarshallingHelpers::URLToBSTR(const URL& url)
 
 CFURLRef MarshallingHelpers::PathStringToFileCFURLRef(const String& string)
 {
-    CFStringRef cfPath = CFStringCreateWithCharactersNoCopy(0, (const UniChar*)string.deprecatedCharacters(), string.length(), kCFAllocatorNull);
-    CFURLRef pathURL = CFURLCreateWithFileSystemPath(0, cfPath, kCFURLWindowsPathStyle, false);
-    CFRelease(cfPath);
-    return pathURL;
+    return CFURLCreateWithFileSystemPath(0, string.createCFString().get(), kCFURLWindowsPathStyle, false);
 }
 
 String MarshallingHelpers::FileCFURLRefToPathString(CFURLRef fileURL)
index 3a44491..31bbc06 100644 (file)
@@ -668,7 +668,7 @@ void WebEditorClient::checkSpellingOfString(StringView text, int* misspellingLoc
         return;
 
     initViewSpecificSpelling(m_webView);
-    ed->checkSpellingOfString(m_webView, text.toStringWithoutCopying().deprecatedCharacters(), text.length(), misspellingLocation, misspellingLength);
+    ed->checkSpellingOfString(m_webView, text.upconvertedCharacters(), text.length(), misspellingLocation, misspellingLength);
 }
 
 String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String& inputWord)
@@ -690,7 +690,7 @@ void WebEditorClient::checkGrammarOfString(StringView text, Vector<GrammarDetail
 
     initViewSpecificSpelling(m_webView);
     COMPtr<IEnumWebGrammarDetails> enumDetailsObj;
-    if (FAILED(ed->checkGrammarOfString(m_webView, text.toStringWithoutCopying().deprecatedCharacters(), text.length(), &enumDetailsObj, badGrammarLocation, badGrammarLength)))
+    if (FAILED(ed->checkGrammarOfString(m_webView, text.upconvertedCharacters(), text.length(), &enumDetailsObj, badGrammarLocation, badGrammarLength)))
         return;
 
     while (true) {
index 5dd2bbd..8fee8eb 100644 (file)
@@ -255,7 +255,7 @@ HRESULT STDMETHODCALLTYPE WebDataSource::unreachableURL(
     /* [retval][out] */ BSTR* url)
 {
     URL unreachableURL = m_loader->unreachableURL();
-    BString urlString((LPOLESTR)unreachableURL.string().deprecatedCharacters(), unreachableURL.string().length());
+    BString urlString(unreachableURL.string());
 
     *url = urlString.release();
     return S_OK;
index ec0634b..d820cf5 100644 (file)
@@ -149,7 +149,7 @@ HRESULT STDMETHODCALLTYPE WebDownload::bundlePathForTargetPath(
         bundle.truncate(1);
 
     bundle.append(DownloadBundle::fileExtension());
-    *bundlePath = SysAllocStringLen(bundle.deprecatedCharacters(), bundle.length());
+    *bundlePath = BString(bundle).release();
     if (!*bundlePath)
        return E_FAIL;
     return S_OK;
index 0f6feef..5dfba29 100644 (file)
@@ -482,7 +482,7 @@ void WebDownload::didFinish()
         
         bool reportBundlePathAsFinalPath = true;
 
-        BString destinationBSTR(m_destination.deprecatedCharacters(), m_destination.length());
+        BString destinationBSTR(m_destination);
         if (FAILED(m_delegate->decideDestinationWithSuggestedFilename(this, destinationBSTR)))
             LOG_ERROR("delegate->decideDestinationWithSuggestedFilename() failed");
 
index affea67..263b757 100644 (file)
@@ -180,7 +180,7 @@ void WebDownload::didReceiveResponse()
         if (suggestedFilename.isEmpty())
             suggestedFilename = pathGetFileName(response.url().string());
         suggestedFilename = decodeURLEscapeSequences(suggestedFilename);
-        BString suggestedFilenameBSTR(suggestedFilename.deprecatedCharacters(), suggestedFilename.length());
+        BString suggestedFilenameBSTR(suggestedFilename);
         m_delegate->decideDestinationWithSuggestedFilename(this, suggestedFilenameBSTR);
     }
 }
index 4a03b78..132ad93 100644 (file)
@@ -31,6 +31,7 @@
 #include "DOMCoreClasses.h"
 #include "WebFrame.h"
 #include "WebFrameLoaderClient.h"
+#include <WebCore/BString.h>
 #include <WebCore/Document.h>
 #include <WebCore/Frame.h>
 #include <WebCore/HitTestResult.h>
@@ -102,7 +103,7 @@ static bool isEqual(LPCWSTR s1, LPCWSTR s2)
 static HRESULT convertStringToVariant(VARIANT* pVar, const String& string)
 {
     V_VT(pVar) = VT_BSTR;
-    V_BSTR(pVar) = SysAllocStringLen(string.deprecatedCharacters(), string.length());
+    V_BSTR(pVar) = BString(string).release();
     if (string.length() && !V_BSTR(pVar))
         return E_OUTOFMEMORY;
 
index c31ff00..80c63a6 100644 (file)
@@ -1366,7 +1366,7 @@ HRESULT WebFrame::searchForLabelsBeforeElement(const BSTR* labels, unsigned cLab
     bool resultIsInCellAbove;
     String label = coreFrame->searchForLabelsBeforeElement(labelStrings, coreElement, &resultDistance, &resultIsInCellAbove);
     
-    *result = SysAllocStringLen(label.deprecatedCharacters(), label.length());
+    *result = BString(label).release();
     if (label.length() && !*result)
         return E_OUTOFMEMORY;
     if (outResultDistance)
@@ -1404,7 +1404,7 @@ HRESULT WebFrame::matchLabelsAgainstElement(const BSTR* labels, int cLabels, IDO
 
     String label = coreFrame->matchLabelsAgainstElement(labelStrings, coreElement);
     
-    *result = SysAllocStringLen(label.deprecatedCharacters(), label.length());
+    *result = BString(label).release();
     if (label.length() && !*result)
         return E_OUTOFMEMORY;
     return S_OK;
index 28af6cb..218fa44 100644 (file)
@@ -565,8 +565,6 @@ COMPtr<IWebHistoryItem> WebHistory::itemForURLString(const String& urlString) co
 
 void WebHistory::addVisitedLinksToPageGroup(PageGroup& group)
 {
-    for (auto it = m_entriesByURL.begin(); it != m_entriesByURL.end(); ++it) {
-        const String& url = it->key;
-        group.addVisitedLink(url.deprecatedCharacters(), url.length());
-    }
+    for (auto& url : m_entriesByURL.keys())
+        group.addVisitedLinkHash(visitedLinkHash(url));
 }
index 1609a50..c6f290d 100644 (file)
@@ -38,6 +38,7 @@
 #include <WebCore/GraphicsContext.h>
 #include <WebCore/StringTruncator.h>
 #include <WebCore/WebCoreTextRenderer.h>
+#include <wtf/text/StringView.h>
 #include <wtf/text/WTFString.h>
 #include <wtf/unicode/CharacterNames.h>
 
@@ -117,7 +118,7 @@ unsigned CenterTruncateStringToWidth(LPCTSTR text, int length, const WebFontDesc
     FontCachePurgePreventer fontCachePurgePreventer;
 
     String result = StringTruncator::centerTruncate(String(text, length), width, makeFont(description), StringTruncator::EnableRoundingHacks);
-    memcpy(buffer, result.deprecatedCharacters(), result.length() * sizeof(UChar));
+    StringView(result).getCharactersWithUpconvert(buffer);
     buffer[result.length()] = '\0';
     return result.length();
 }
@@ -129,7 +130,7 @@ unsigned RightTruncateStringToWidth(LPCTSTR text, int length, const WebFontDescr
     FontCachePurgePreventer fontCachePurgePreventer;
 
     String result = StringTruncator::rightTruncate(String(text, length), width, makeFont(description), StringTruncator::EnableRoundingHacks);
-    memcpy(buffer, result.deprecatedCharacters(), result.length() * sizeof(UChar));
+    StringView(result).getCharactersWithUpconvert(buffer);
     buffer[result.length()] = '\0';
     return result.length();
 }
index 9f6bb1f..604583b 100644 (file)
@@ -3178,7 +3178,7 @@ HRESULT STDMETHODCALLTYPE WebView::setApplicationNameForUserAgent(
 HRESULT STDMETHODCALLTYPE WebView::applicationNameForUserAgent( 
     /* [retval][out] */ BSTR* applicationName)
 {
-    *applicationName = SysAllocStringLen(m_applicationName.deprecatedCharacters(), m_applicationName.length());
+    *applicationName = BString(m_applicationName).release();
     if (!*applicationName && m_applicationName.length())
         return E_OUTOFMEMORY;
     return S_OK;
@@ -3198,7 +3198,7 @@ HRESULT STDMETHODCALLTYPE WebView::customUserAgent(
     *userAgentString = 0;
     if (!m_userAgentOverridden)
         return S_OK;
-    *userAgentString = SysAllocStringLen(m_userAgentCustom.deprecatedCharacters(), m_userAgentCustom.length());
+    *userAgentString = BString(m_userAgentCustom).release();
     if (!*userAgentString && m_userAgentCustom.length())
         return E_OUTOFMEMORY;
     return S_OK;
@@ -3646,7 +3646,7 @@ HRESULT STDMETHODCALLTYPE WebView::groupName(
     if (!m_page)
         return S_OK;
     String groupNameString = m_page->groupName();
-    *groupName = SysAllocStringLen(groupNameString.deprecatedCharacters(), groupNameString.length());
+    *groupName = BString(groupNameString).release();
     if (!*groupName && groupNameString.length())
         return E_OUTOFMEMORY;
     return S_OK;
@@ -3756,7 +3756,7 @@ HRESULT STDMETHODCALLTYPE WebView::selectedText(
         return E_FAIL;
 
     String frameSelectedText = focusedFrame->editor().selectedText();
-    *text = SysAllocStringLen(frameSelectedText.deprecatedCharacters(), frameSelectedText.length());
+    *text = BString(frameSelectedText).release();
     if (!*text && frameSelectedText.length())
         return E_OUTOFMEMORY;
     return S_OK;
@@ -5827,7 +5827,7 @@ LRESULT WebView::onIMERequestReconvertString(Frame* targetFrame, RECONVERTSTRING
     reconvertString->dwStrLen = text.length();
     reconvertString->dwTargetStrLen = text.length();
     reconvertString->dwStrOffset = sizeof(RECONVERTSTRING);
-    memcpy(reconvertString + 1, text.deprecatedCharacters(), text.length() * sizeof(UChar));
+    StringView(text).getCharactersWithUpconvert(reinterpret_cast<UChar*>(reconvertString + 1));
     return totalSize;
 }