Changeset 128988 in webkit
- Timestamp:
- Sep 19, 2012 4:15:33 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128987 r128988 1 2012-09-19 Patrick Gansterer <paroga@webkit.org> 2 3 [WIN] Use BString in favour of BSTR to improve memory management 4 https://bugs.webkit.org/show_bug.cgi?id=93128 5 6 Reviewed by Anders Carlsson. 7 8 BString automatically calls SysFreeString() in its destructor which helps 9 avoiding memory leaks. So it should be used instead of BSTR directly. 10 Add operator& to BString to allow its usage for out parameters too (like COMPtr). 11 This fixes already a few memory leaks in the existing code. 12 13 * platform/win/BString.cpp: 14 (WebCore::BString::~BString): 15 (WebCore::BString::adoptBSTR): 16 (WebCore::BString::clear): 17 (WebCore): 18 * platform/win/BString.h: 19 (BString): 20 (WebCore::BString::operator&): 21 1 22 2012-09-19 Simon Hausmann <simon.hausmann@digia.com> 2 23 -
trunk/Source/WebCore/platform/win/BString.cpp
r128812 r128988 107 107 BString::~BString() 108 108 { 109 SysFreeString(m_bstr);109 clear(); 110 110 } 111 111 … … 120 120 void BString::adoptBSTR(BSTR bstr) 121 121 { 122 if (m_bstr) 123 SysFreeString(m_bstr); 122 clear(); 124 123 m_bstr = bstr; 124 } 125 126 void BString::clear() 127 { 128 SysFreeString(m_bstr); 125 129 } 126 130 -
trunk/Source/WebCore/platform/win/BString.h
r128812 r128988 53 53 54 54 void adoptBSTR(BSTR); 55 void clear(); 55 56 56 57 BString(const BString&); … … 58 59 BString& operator=(const BSTR&); 59 60 61 BSTR* operator&() { ASSERT(!m_bstr); return &m_bstr; } 60 62 operator BSTR() const { return m_bstr; } 61 63 -
trunk/Source/WebKit/win/ChangeLog
r128812 r128988 1 2012-09-19 Patrick Gansterer <paroga@webkit.org> 2 3 [WIN] Use BString in favour of BSTR to improve memory management 4 https://bugs.webkit.org/show_bug.cgi?id=93128 5 6 Reviewed by Anders Carlsson. 7 8 BString automatically calls SysFreeString() in its destructor which helps 9 avoiding memory leaks. So it should be used instead of BSTR directly. 10 Add operator& to BString to allow its usage for out parameters too (like COMPtr). 11 This fixes already a few memory leaks in the existing code. 12 13 * DefaultPolicyDelegate.cpp: 14 (DefaultPolicyDelegate::decidePolicyForNavigationAction): 15 (DefaultPolicyDelegate::decidePolicyForMIMEType): 16 (DefaultPolicyDelegate::unableToImplementPolicyWithError): 17 * MarshallingHelpers.cpp: 18 (MarshallingHelpers::KURLToBSTR): 19 (MarshallingHelpers::CFStringRefToBSTR): 20 (MarshallingHelpers::stringArrayToSafeArray): 21 (MarshallingHelpers::safeArrayToStringArray): 22 * WebCoreSupport/WebChromeClient.cpp: 23 (WebChromeClient::runJavaScriptPrompt): 24 * WebCoreSupport/WebEditorClient.cpp: 25 (WebEditorClient::checkGrammarOfString): 26 (WebEditorClient::getGuessesForWord): 27 * WebFrame.cpp: 28 (WebFrame::canProvideDocumentSource): 29 * WebHistory.cpp: 30 (WebHistory::removeItem): 31 (WebHistory::addItem): 32 * WebIconDatabase.cpp: 33 (WebIconDatabase::startUpIconDatabase): 34 * WebNotificationCenter.cpp: 35 (WebNotificationCenter::postNotification): 36 * WebPreferences.cpp: 37 (WebPreferences::setStringValue): 38 * WebView.cpp: 39 (toAtomicString): 40 (toString): 41 (toKURL): 42 (PreferencesChangedOrRemovedObserver::onNotify): 43 (WebView::close): 44 (WebView::canShowMIMEType): 45 (WebView::initWithFrame): 46 (WebView::setApplicationNameForUserAgent): 47 (WebView::setCustomUserAgent): 48 (WebView::userAgentForURL): 49 (WebView::setCustomTextEncodingName): 50 (WebView::customTextEncodingName): 51 (WebView::setPreferences): 52 (WebView::searchFor): 53 (WebView::executeCoreCommandByName): 54 (WebView::markAllMatchesForText): 55 (WebView::setGroupName): 56 (WebView::registerURLSchemeAsLocal): 57 (WebView::replaceSelectionWithText): 58 (WebView::onNotify): 59 (WebView::notifyPreferencesChanged): 60 (WebView::MIMETypeForExtension): 61 (WebView::standardUserAgentWithApplicationName): 62 (WebView::addAdditionalPluginDirectory): 63 (WebView::registerEmbeddedViewMIMEType): 64 (WebView::addOriginAccessWhitelistEntry): 65 (WebView::removeOriginAccessWhitelistEntry): 66 (WebView::geolocationDidFailWithError): 67 (WebView::setDomainRelaxationForbiddenForURLScheme): 68 (WebView::setCompositionForTesting): 69 (WebView::confirmCompositionForTesting): 70 1 71 2012-09-17 Sheriff Bot <webkit.review.bot@gmail.com> 2 72 -
trunk/Source/WebKit/win/DefaultPolicyDelegate.cpp
r128812 r128988 28 28 #include "DefaultPolicyDelegate.h" 29 29 30 #include <WebCore/BString.h> 30 31 #include <WebCore/COMPtr.h> 31 32 #include <wtf/text/WTFString.h> 33 34 using namespace WebCore; 32 35 33 36 // FIXME: move this enum to a separate header file when other code begins to use it. … … 117 120 listener->use(); 118 121 else { 119 BS TRurl;122 BString url; 120 123 // A file URL shouldn't fall through to here, but if it did, 121 124 // it would be a security risk to open it. … … 125 128 } 126 129 listener->ignore(); 127 SysFreeString(url);128 130 } 129 131 } … … 153 155 canShowMIMEType = FALSE; 154 156 155 BS TRurl;157 BString url; 156 158 request->URL(&url); 157 159 … … 172 174 else 173 175 listener->ignore(); 174 SysFreeString(url);175 176 return S_OK; 176 177 } … … 181 182 /*[in]*/ IWebFrame* frame) 182 183 { 183 BS TRerrorStr;184 BString errorStr; 184 185 error->localizedDescription(&errorStr); 185 186 186 BS TRframeName;187 BString frameName; 187 188 frame->name(&frameName); 188 189 189 190 LOG_ERROR("called unableToImplementPolicyWithError:%S inFrame:%S", errorStr ? errorStr : TEXT(""), frameName ? frameName : TEXT("")); 190 SysFreeString(errorStr);191 SysFreeString(frameName);192 191 193 192 return S_OK; -
trunk/Source/WebKit/win/MarshallingHelpers.cpp
r128812 r128988 28 28 #include "MarshallingHelpers.h" 29 29 30 #include <WebCore/BString.h> 30 31 #include <WebCore/IntRect.h> 31 32 #include <WebCore/KURL.h> … … 47 48 BSTR MarshallingHelpers::KURLToBSTR(const KURL& url) 48 49 { 49 return SysAllocStringLen(url.string().characters(), url.string().length());50 return BString(url.string()).release(); 50 51 } 51 52 … … 90 91 BSTR MarshallingHelpers::CFStringRefToBSTR(CFStringRef str) 91 92 { 92 if (!str) 93 return 0; 94 95 const UniChar* uniChars = CFStringGetCharactersPtr(str); 96 if (uniChars) 97 return SysAllocStringLen((LPCTSTR)uniChars, CFStringGetLength(str)); 98 99 CFIndex length = CFStringGetLength(str); 100 BSTR bstr = SysAllocStringLen(0, length); 101 if (bstr) { 102 CFStringGetCharacters(str, CFRangeMake(0, length), (UniChar*)bstr); 103 bstr[length] = 0; 104 } 105 return bstr; 93 return BString(str).release(); 106 94 } 107 95 … … 160 148 for (CFIndex i=0; i<size; i++) { 161 149 CFStringRef item = (CFStringRef) CFArrayGetValueAtIndex(inArray, i); 162 BSTR bstr = CFStringRefToBSTR(item); 163 ::SafeArrayPutElement(sa, &count, bstr); 164 SysFreeString(bstr); // SafeArrayPutElement() should make a copy of the string 150 BString bstr(item); 151 ::SafeArrayPutElement(sa, &count, bstr); // SafeArrayPutElement() copies the string correctly. 165 152 count++; 166 153 } … … 233 220 items = new CFStringRef[len]; 234 221 for (; lBound <= uBound; lBound++) { 235 BS TRstr;222 BString str; 236 223 hr = ::SafeArrayGetElement(inArray, &lBound, &str); 237 224 items[lBound] = BSTRToCFStringRef(str); 238 SysFreeString(str);239 225 } 240 226 } -
trunk/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
r128812 r128988 411 411 TimerBase::fireTimersInNestedEventLoop(); 412 412 413 BS TR resultBSTR = 0;413 BString resultBSTR; 414 414 if (FAILED(ui->runJavaScriptTextInputPanelWithPrompt(m_webView, BString(message), BString(defaultValue), &resultBSTR))) 415 415 return false; 416 416 417 if (resultBSTR) { 418 result = String(resultBSTR, SysStringLen(resultBSTR)); 419 SysFreeString(resultBSTR); 420 return true; 421 } 422 423 return false; 417 if (!resultBSTR) 418 return false; 419 420 result = String(resultBSTR, SysStringLen(resultBSTR)); 421 return true; 424 422 } 425 423 -
trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp
r128812 r128988 696 696 if (FAILED(detailObj->location(&detail.location))) 697 697 continue; 698 BS TRuserDesc;698 BString userDesc; 699 699 if (FAILED(detailObj->userDescription(&userDesc))) 700 700 continue; 701 701 detail.userDescription = String(userDesc, SysStringLen(userDesc)); 702 SysFreeString(userDesc);703 702 704 703 COMPtr<IEnumSpellingGuesses> enumGuessesObj; … … 706 705 continue; 707 706 while (true) { 708 BS TRguess;707 BString guess; 709 708 if (enumGuessesObj->Next(1, &guess, &fetched) != S_OK) 710 709 break; 711 710 detail.guesses.append(String(guess, SysStringLen(guess))); 712 SysFreeString(guess);713 711 } 714 712 … … 779 777 while (true) { 780 778 ULONG fetched; 781 BS TRguess;779 BString guess; 782 780 if (enumGuessesObj->Next(1, &guess, &fetched) != S_OK) 783 781 break; 784 782 guesses.append(String(guess, SysStringLen(guess))); 785 SysFreeString(guess);786 783 } 787 784 } -
trunk/Source/WebKit/win/WebFrame.cpp
r128812 r128988 1443 1443 hr = dataSource->response(&urlResponse); 1444 1444 if (SUCCEEDED(hr) && urlResponse) { 1445 BS TRmimeTypeBStr;1445 BString mimeTypeBStr; 1446 1446 if (SUCCEEDED(urlResponse->MIMEType(&mimeTypeBStr))) { 1447 1447 String mimeType(mimeTypeBStr, SysStringLen(mimeTypeBStr)); 1448 1448 *result = mimeType == "text/html" || WebCore::DOMImplementation::isXMLMIMEType(mimeType); 1449 SysFreeString(mimeTypeBStr);1450 1449 } 1451 1450 } -
trunk/Source/WebKit/win/WebHistory.cpp
r128812 r128988 37 37 #include "WebPreferences.h" 38 38 #include <CoreFoundation/CoreFoundation.h> 39 #include <WebCore/BString.h> 39 40 #include <WebCore/HistoryItem.h> 40 41 #include <WebCore/HistoryPropertyList.h> … … 613 614 { 614 615 HRESULT hr = S_OK; 615 BS TR urlBStr = 0;616 BString urlBStr; 616 617 617 618 hr = entry->URLString(&urlBStr); … … 620 621 621 622 RetainPtr<CFStringRef> urlString(AdoptCF, MarshallingHelpers::BSTRToCFStringRef(urlBStr)); 622 SysFreeString(urlBStr);623 623 624 624 // If this exact object isn't stored, then make no change. … … 647 647 return E_FAIL; 648 648 649 BS TR urlBStr = 0;649 BString urlBStr; 650 650 hr = entry->URLString(&urlBStr); 651 651 if (FAILED(hr)) … … 653 653 654 654 RetainPtr<CFStringRef> urlString(AdoptCF, MarshallingHelpers::BSTRToCFStringRef(urlBStr)); 655 SysFreeString(urlBStr);656 655 657 656 COMPtr<IWebHistoryItem> oldEntry((IWebHistoryItem*) CFDictionaryGetValue( -
trunk/Source/WebKit/win/WebIconDatabase.cpp
r128812 r128988 85 85 iconDatabase().setClient(this); 86 86 87 BS TR prefDatabasePath = 0;87 BString prefDatabasePath; 88 88 if (FAILED(standardPrefs->iconDatabaseLocation(&prefDatabasePath))) 89 89 LOG_ERROR("Unable to get icon database location preference"); 90 90 91 91 String databasePath(prefDatabasePath, SysStringLen(prefDatabasePath)); 92 SysFreeString(prefDatabasePath);93 92 94 93 if (databasePath.isEmpty()) { -
trunk/Source/WebKit/win/WebNotificationCenter.cpp
r128812 r128988 29 29 30 30 #include "WebNotification.h" 31 #include <WebCore/BString.h> 31 32 #include <WebCore/COMPtr.h> 32 33 #include <utility> … … 39 40 #include <wtf/text/WTFString.h> 40 41 42 using namespace WebCore; 43 41 44 typedef std::pair<COMPtr<IUnknown>, COMPtr<IWebNotificationObserver> > ObjectObserverPair; 42 45 typedef Vector<ObjectObserverPair> ObjectObserverList; … … 161 164 /* [in] */ IWebNotification* notification) 162 165 { 163 BS TRname;166 BString name; 164 167 HRESULT hr = notification->name(&name); 165 168 if (FAILED(hr)) … … 172 175 173 176 postNotificationInternal(notification, name, obj.get()); 174 SysFreeString(name);175 177 176 178 return hr; -
trunk/Source/WebKit/win/WebPreferences.cpp
r128812 r128988 350 350 void WebPreferences::setStringValue(CFStringRef key, LPCTSTR value) 351 351 { 352 BSTR val = stringValueForKey(key); 352 BString val; 353 val.adoptBSTR(stringValueForKey(key)); 353 354 if (val && !wcscmp(val, value)) 354 355 return; 355 SysFreeString(val);356 356 357 357 RetainPtr<CFStringRef> valueRef(AdoptCF, -
trunk/Source/WebKit/win/WebView.cpp
r128812 r128988 200 200 } 201 201 202 static inline AtomicString toAtomicString(BSTR bstr) 203 { 204 return AtomicString(bstr, SysStringLen(bstr)); 205 } 206 207 static inline String toString(BSTR bstr) 208 { 209 return String(bstr, SysStringLen(bstr)); 210 } 211 212 static inline KURL toKURL(BSTR bstr) 213 { 214 return KURL(KURL(), toString(bstr)); 215 } 216 202 217 class PreferencesChangedOrRemovedObserver : public IWebNotificationObserver { 203 218 public: … … 246 261 return hr; 247 262 248 BSTR nameBSTR;249 hr = notification->name(&nameBSTR);250 if (FAILED(hr))251 return hr;252 263 BString name; 253 name.adoptBSTR(nameBSTR); 264 hr = notification->name(&name); 265 if (FAILED(hr)) 266 return hr; 254 267 255 268 if (wcscmp(name, WebPreferences::webPreferencesChangedNotification()) == 0) … … 727 740 728 741 if (COMPtr<WebPreferences> preferences = m_preferences) { 729 BS TR identifier = 0;742 BString identifier; 730 743 preferences->identifier(&identifier); 731 744 … … 734 747 // Make sure we release the reference, since WebPreferences::removeReferenceForIdentifier will check for last reference to WebPreferences 735 748 preferences = 0; 736 if (identifier) {749 if (identifier) 737 750 WebPreferences::removeReferenceForIdentifier(identifier); 738 SysFreeString(identifier);739 }740 751 } 741 752 … … 2514 2525 /* [retval][out] */ BOOL* canShow) 2515 2526 { 2516 String mimeTypeStr (mimeType, SysStringLen(mimeType));2527 String mimeTypeStr = toString(mimeType); 2517 2528 2518 2529 if (!canShow) … … 2681 2692 provideGeolocationTo(m_page, new WebGeolocationClient(this)); 2682 2693 2683 BSTR localStoragePath; 2684 if (SUCCEEDED(m_preferences->localStorageDatabasePath(&localStoragePath))) { 2685 m_page->settings()->setLocalStorageDatabasePath(String(localStoragePath, SysStringLen(localStoragePath))); 2686 SysFreeString(localStoragePath); 2687 } 2694 BString localStoragePath; 2695 if (SUCCEEDED(m_preferences->localStorageDatabasePath(&localStoragePath))) 2696 m_page->settings()->setLocalStorageDatabasePath(toString(localStoragePath)); 2688 2697 2689 2698 if (m_uiDelegate) { 2690 BSTR path; 2691 if (SUCCEEDED(m_uiDelegate->ftpDirectoryTemplatePath(this, &path))) { 2692 m_page->settings()->setFTPDirectoryTemplatePath(String(path, SysStringLen(path))); 2693 SysFreeString(path); 2694 } 2699 BString path; 2700 if (SUCCEEDED(m_uiDelegate->ftpDirectoryTemplatePath(this, &path))) 2701 m_page->settings()->setFTPDirectoryTemplatePath(toString(path)); 2695 2702 } 2696 2703 … … 2700 2707 webFrame->Release(); // The WebFrame is owned by the Frame, so release our reference to it. 2701 2708 2702 coreFrame->tree()->setName( String(frameName, SysStringLen(frameName)));2709 coreFrame->tree()->setName(toString(frameName)); 2703 2710 coreFrame->init(); 2704 2711 setGroupName(groupName); … … 3058 3065 /* [in] */ BSTR applicationName) 3059 3066 { 3060 m_applicationName = String(applicationName, SysStringLen(applicationName));3067 m_applicationName = toString(applicationName); 3061 3068 m_userAgentStandard = String(); 3062 3069 return S_OK; … … 3076 3083 { 3077 3084 m_userAgentOverridden = userAgentString; 3078 m_userAgentCustom = String(userAgentString, SysStringLen(userAgentString));3085 m_userAgentCustom = toString(userAgentString); 3079 3086 return S_OK; 3080 3087 } … … 3097 3104 { 3098 3105 String userAgentString = userAgentForKURL(MarshallingHelpers::BSTRToKURL(url)); 3099 *userAgent = SysAllocStringLen(userAgentString.characters(), userAgentString.length());3106 *userAgent = BString(userAgentString).release(); 3100 3107 if (!*userAgent && userAgentString.length()) 3101 3108 return E_OUTOFMEMORY; … … 3117 3124 3118 3125 HRESULT hr; 3119 BS TRoldEncoding;3126 BString oldEncoding; 3120 3127 hr = customTextEncodingName(&oldEncoding); 3121 3128 if (FAILED(hr)) … … 3124 3131 if (oldEncoding != encodingName && (!oldEncoding || !encodingName || wcscmp(oldEncoding, encodingName))) { 3125 3132 if (Frame* coreFrame = core(m_mainFrame)) 3126 coreFrame->loader()->reloadWithOverrideEncoding( String(encodingName, SysStringLen(encodingName)));3133 coreFrame->loader()->reloadWithOverrideEncoding(toString(encodingName)); 3127 3134 } 3128 3135 … … 3156 3163 3157 3164 if (!*encodingName) 3158 *encodingName = SysAllocStringLen(m_overrideEncoding.characters(), m_overrideEncoding.length());3165 *encodingName = BString(m_overrideEncoding).release(); 3159 3166 3160 3167 if (!*encodingName && m_overrideEncoding.length()) … … 3231 3238 nc->removeObserver(this, WebPreferences::webPreferencesChangedNotification(), static_cast<IWebPreferences*>(m_preferences.get())); 3232 3239 3233 BS TR identifier = 0;3240 BString identifier; 3234 3241 oldPrefs->identifier(&identifier); 3235 3242 oldPrefs->didRemoveFromWebView(); … … 3238 3245 m_preferences = webPrefs; 3239 3246 3240 if (identifier) {3247 if (identifier) 3241 3248 WebPreferences::removeReferenceForIdentifier(identifier); 3242 SysFreeString(identifier);3243 }3244 3249 3245 3250 nc->addObserver(this, WebPreferences::webPreferencesChangedNotification(), static_cast<IWebPreferences*>(m_preferences.get())); … … 3389 3394 return E_INVALIDARG; 3390 3395 3391 *found = m_page->findString( String(str, SysStringLen(str)), caseFlag ? TextCaseSensitive : TextCaseInsensitive, forward ? FindDirectionForward : FindDirectionBackward, wrapFlag);3396 *found = m_page->findString(toString(str), caseFlag ? TextCaseSensitive : TextCaseInsensitive, forward ? FindDirectionForward : FindDirectionBackward, wrapFlag); 3392 3397 return S_OK; 3393 3398 } … … 3419 3424 } 3420 3425 3421 HRESULT STDMETHODCALLTYPE WebView::executeCoreCommandByName(BSTR bName, BSTR bValue) 3422 { 3423 String name(bName, SysStringLen(bName)); 3424 String value(bValue, SysStringLen(bValue)); 3425 3426 m_page->focusController()->focusedOrMainFrame()->editor()->command(name).execute(value); 3426 HRESULT STDMETHODCALLTYPE WebView::executeCoreCommandByName(BSTR name, BSTR value) 3427 { 3428 m_page->focusController()->focusedOrMainFrame()->editor()->command(toString(name)).execute(toString(value)); 3427 3429 3428 3430 return S_OK; … … 3448 3450 return E_INVALIDARG; 3449 3451 3450 *matches = m_page->markAllMatchesForText( String(str, SysStringLen(str)), caseSensitive ? TextCaseSensitive : TextCaseInsensitive, highlight, limit);3452 *matches = m_page->markAllMatchesForText(toString(str), caseSensitive ? TextCaseSensitive : TextCaseInsensitive, highlight, limit); 3451 3453 return S_OK; 3452 3454 } … … 3531 3533 if (!m_page) 3532 3534 return S_OK; 3533 m_page->setGroupName( String(groupName, SysStringLen(groupName)));3535 m_page->setGroupName(toString(groupName)); 3534 3536 return S_OK; 3535 3537 } … … 3765 3767 return E_POINTER; 3766 3768 3767 SchemeRegistry::registerURLSchemeAsLocal( String(scheme, ::SysStringLen(scheme)));3769 SchemeRegistry::registerURLSchemeAsLocal(toString(scheme)); 3768 3770 3769 3771 return S_OK; … … 4316 4318 /* [in] */ BSTR text) 4317 4319 { 4318 String textString(text, ::SysStringLen(text));4319 4320 Position start = m_page->mainFrame()->selection()->selection().start(); 4320 m_page->focusController()->focusedOrMainFrame()->editor()->insertText(t extString, 0);4321 m_page->focusController()->focusedOrMainFrame()->editor()->insertText(toString(text), 0); 4321 4322 m_page->mainFrame()->selection()->setBase(start); 4322 4323 return S_OK; … … 4537 4538 /* [in] */ IWebNotification* notification) 4538 4539 { 4539 BSTR nameBSTR;4540 HRESULT hr = notification->name(&nameBSTR);4541 if (FAILED(hr))4542 return hr;4543 4544 4540 BString name; 4545 name.adoptBSTR(nameBSTR); 4541 HRESULT hr = notification->name(&name); 4542 if (FAILED(hr)) 4543 return hr; 4546 4544 4547 4545 if (!wcscmp(name, WebIconDatabase::iconDatabaseDidAddIconNotification())) … … 4569 4567 ASSERT(preferences == m_preferences); 4570 4568 4571 BS TRstr;4569 BString str; 4572 4570 int size; 4573 4571 BOOL enabled; … … 4578 4576 if (FAILED(hr)) 4579 4577 return hr; 4580 settings->setCursiveFontFamily( AtomicString(str, SysStringLen(str)));4581 SysFreeString(str);4578 settings->setCursiveFontFamily(toAtomicString(str)); 4579 str.clear(); 4582 4580 4583 4581 hr = preferences->defaultFixedFontSize(&size); … … 4590 4588 return hr; 4591 4589 settings->setDefaultFontSize(size); 4592 4590 4593 4591 hr = preferences->defaultTextEncodingName(&str); 4594 4592 if (FAILED(hr)) 4595 4593 return hr; 4596 settings->setDefaultTextEncodingName( String(str, SysStringLen(str)));4597 SysFreeString(str);4594 settings->setDefaultTextEncodingName(toString(str)); 4595 str.clear(); 4598 4596 4599 4597 hr = preferences->fantasyFontFamily(&str); 4600 4598 if (FAILED(hr)) 4601 4599 return hr; 4602 settings->setFantasyFontFamily( AtomicString(str, SysStringLen(str)));4603 SysFreeString(str);4600 settings->setFantasyFontFamily(toAtomicString(str)); 4601 str.clear(); 4604 4602 4605 4603 hr = preferences->fixedFontFamily(&str); 4606 4604 if (FAILED(hr)) 4607 4605 return hr; 4608 settings->setFixedFontFamily( AtomicString(str, SysStringLen(str)));4609 SysFreeString(str);4606 settings->setFixedFontFamily(toAtomicString(str)); 4607 str.clear(); 4610 4608 4611 4609 #if ENABLE(VIDEO_TRACK) … … 4631 4629 if (FAILED(hr)) 4632 4630 return hr; 4633 settings->setLocalStorageDatabasePath( String(str, SysStringLen(str)));4634 SysFreeString(str);4631 settings->setLocalStorageDatabasePath(toString(str)); 4632 str.clear(); 4635 4633 } 4636 4634 … … 4638 4636 if (FAILED(hr)) 4639 4637 return hr; 4640 settings->setPictographFontFamily( AtomicString(str, SysStringLen(str)));4641 SysFreeString(str);4638 settings->setPictographFontFamily(toAtomicString(str)); 4639 str.clear(); 4642 4640 4643 4641 hr = preferences->isJavaEnabled(&enabled); … … 4684 4682 if (FAILED(hr)) 4685 4683 return hr; 4686 settings->setSansSerifFontFamily( AtomicString(str, SysStringLen(str)));4687 SysFreeString(str);4684 settings->setSansSerifFontFamily(toAtomicString(str)); 4685 str.clear(); 4688 4686 4689 4687 hr = preferences->serifFontFamily(&str); 4690 4688 if (FAILED(hr)) 4691 4689 return hr; 4692 settings->setSerifFontFamily( AtomicString(str, SysStringLen(str)));4693 SysFreeString(str);4690 settings->setSerifFontFamily(toAtomicString(str)); 4691 str.clear(); 4694 4692 4695 4693 hr = preferences->standardFontFamily(&str); 4696 4694 if (FAILED(hr)) 4697 4695 return hr; 4698 settings->setStandardFontFamily( AtomicString(str, SysStringLen(str)));4699 SysFreeString(str);4696 settings->setStandardFontFamily(toAtomicString(str)); 4697 str.clear(); 4700 4698 4701 4699 hr = preferences->loadsImagesAutomatically(&enabled); … … 4712 4710 return hr; 4713 4711 4714 RetainPtr<CFStringRef> urlString(AdoptCF, String(str, SysStringLen(str)).createCFString());4712 RetainPtr<CFStringRef> urlString(AdoptCF, toString(str).createCFString()); 4715 4713 RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithString(kCFAllocatorDefault, urlString.get(), 0)); 4716 4714 … … 4730 4728 4731 4729 settings->setUserStyleSheetLocation(url.get()); 4732 SysFreeString(str);4733 } else {4730 str.clear(); 4731 } else 4734 4732 settings->setUserStyleSheetLocation(KURL()); 4735 }4736 4733 4737 4734 hr = preferences->shouldPrintBackgrounds(&enabled); … … 4979 4976 return E_POINTER; 4980 4977 4981 String extensionStr(extension, SysStringLen(extension)); 4982 4983 *mimeType = BString(MIMETypeRegistry::getMIMETypeForExtension(extensionStr)).release(); 4978 *mimeType = BString(MIMETypeRegistry::getMIMETypeForExtension(toString(extension))).release(); 4984 4979 4985 4980 return S_OK; … … 5229 5224 } 5230 5225 5231 BString applicationNameBString(applicationName); 5232 *groupName = BString(standardUserAgentWithApplicationName(String(applicationNameBString, SysStringLen(applicationNameBString)))).release(); 5226 *groupName = BString(standardUserAgentWithApplicationName(toString(applicationName))).release(); 5233 5227 return S_OK; 5234 5228 } … … 5285 5279 /* [in] */ BSTR directory) 5286 5280 { 5287 PluginDatabase::installedPlugins()->addExtraPluginDirectory( String(directory, SysStringLen(directory)));5281 PluginDatabase::installedPlugins()->addExtraPluginDirectory(toString(directory)); 5288 5282 return S_OK; 5289 5283 } … … 6119 6113 m_embeddedViewMIMETypes = adoptPtr(new HashSet<String>); 6120 6114 6121 m_embeddedViewMIMETypes->add( String(mimeType, ::SysStringLen(mimeType)));6115 m_embeddedViewMIMETypes->add(toString(mimeType)); 6122 6116 return S_OK; 6123 6117 } … … 6189 6183 m_page->setCanStartMedia(canStartPlugins); 6190 6184 return S_OK; 6191 }6192 6193 static String toString(BSTR bstr)6194 {6195 return String(bstr, SysStringLen(bstr));6196 }6197 6198 static KURL toKURL(BSTR bstr)6199 {6200 return KURL(KURL(), toString(bstr));6201 6185 } 6202 6186 … … 6416 6400 HRESULT WebView::addOriginAccessWhitelistEntry(BSTR sourceOrigin, BSTR destinationProtocol, BSTR destinationHost, BOOL allowDestinationSubdomains) 6417 6401 { 6418 SecurityPolicy::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString( String(sourceOrigin, SysStringLen(sourceOrigin))), String(destinationProtocol, SysStringLen(destinationProtocol)), String(destinationHost, SysStringLen(destinationHost)), allowDestinationSubdomains);6402 SecurityPolicy::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(toString(sourceOrigin)), toString(destinationProtocol), toString(destinationHost), allowDestinationSubdomains); 6419 6403 return S_OK; 6420 6404 } … … 6422 6406 HRESULT WebView::removeOriginAccessWhitelistEntry(BSTR sourceOrigin, BSTR destinationProtocol, BSTR destinationHost, BOOL allowDestinationSubdomains) 6423 6407 { 6424 SecurityPolicy::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString( String(sourceOrigin, SysStringLen(sourceOrigin))), String(destinationProtocol, SysStringLen(destinationProtocol)), String(destinationHost, SysStringLen(destinationHost)), allowDestinationSubdomains);6408 SecurityPolicy::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(toString(sourceOrigin)), toString(destinationProtocol), toString(destinationHost), allowDestinationSubdomains); 6425 6409 return S_OK; 6426 6410 } … … 6599 6583 return E_POINTER; 6600 6584 6601 BSTR descriptionBSTR; 6602 if (FAILED(error->localizedDescription(&descriptionBSTR))) 6603 return E_FAIL; 6604 String descriptionString(descriptionBSTR, SysStringLen(descriptionBSTR)); 6605 SysFreeString(descriptionBSTR); 6606 6607 RefPtr<GeolocationError> geolocationError = GeolocationError::create(GeolocationError::PositionUnavailable, descriptionString); 6585 BString description; 6586 if (FAILED(error->localizedDescription(&description))) 6587 return E_FAIL; 6588 6589 RefPtr<GeolocationError> geolocationError = GeolocationError::create(GeolocationError::PositionUnavailable, toString(description)); 6608 6590 GeolocationController::from(m_page)->errorOccurred(geolocationError.get()); 6609 6591 return S_OK; … … 6612 6594 HRESULT WebView::setDomainRelaxationForbiddenForURLScheme(BOOL forbidden, BSTR scheme) 6613 6595 { 6614 SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(forbidden, String(scheme, SysStringLen(scheme)));6596 SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(forbidden, toString(scheme)); 6615 6597 return S_OK; 6616 6598 } … … 6907 6889 return E_FAIL; 6908 6890 6909 String compositionStr (composition, SysStringLen(composition));6891 String compositionStr = toString(composition); 6910 6892 6911 6893 Vector<CompositionUnderline> underlines; … … 6939 6921 return E_FAIL; 6940 6922 6941 String compositionStr (composition, SysStringLen(composition));6923 String compositionStr = toString(composition); 6942 6924 6943 6925 if (compositionStr.isNull())
Note: See TracChangeset
for help on using the changeset viewer.