Unreviewed, rolling out r128809.

http://trac.webkit.org/changeset/128809
https://bugs.webkit.org/show_bug.cgi?id=96958

Broke the Windows build. (Requested by andersca on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-09-17

Source/WebCore:

* platform/win/BString.cpp:
(WebCore::BString::~BString):
(WebCore::BString::adoptBSTR):
* platform/win/BString.h:
(BString):

Source/WebKit/win:

* DefaultPolicyDelegate.cpp:
(DefaultPolicyDelegate::decidePolicyForNavigationAction):
(DefaultPolicyDelegate::decidePolicyForMIMEType):
(DefaultPolicyDelegate::unableToImplementPolicyWithError):
* MarshallingHelpers.cpp:
(MarshallingHelpers::KURLToBSTR):
(MarshallingHelpers::CFStringRefToBSTR):
(MarshallingHelpers::stringArrayToSafeArray):
(MarshallingHelpers::safeArrayToStringArray):
* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::runJavaScriptPrompt):
* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::checkGrammarOfString):
(WebEditorClient::getGuessesForWord):
* WebFrame.cpp:
(WebFrame::canProvideDocumentSource):
* WebHistory.cpp:
(WebHistory::removeItem):
(WebHistory::addItem):
* WebIconDatabase.cpp:
(WebIconDatabase::startUpIconDatabase):
* WebNotificationCenter.cpp:
(WebNotificationCenter::postNotification):
* WebPreferences.cpp:
(WebPreferences::setStringValue):
* WebView.cpp:
(PreferencesChangedOrRemovedObserver::onNotify):
(WebView::close):
(WebView::canShowMIMEType):
(WebView::initWithFrame):
(WebView::setApplicationNameForUserAgent):
(WebView::setCustomUserAgent):
(WebView::userAgentForURL):
(WebView::setCustomTextEncodingName):
(WebView::customTextEncodingName):
(WebView::setPreferences):
(WebView::searchFor):
(WebView::executeCoreCommandByName):
(WebView::markAllMatchesForText):
(WebView::setGroupName):
(WebView::registerURLSchemeAsLocal):
(WebView::replaceSelectionWithText):
(WebView::onNotify):
(WebView::notifyPreferencesChanged):
(WebView::MIMETypeForExtension):
(WebView::standardUserAgentWithApplicationName):
(WebView::addAdditionalPluginDirectory):
(WebView::registerEmbeddedViewMIMEType):
(toString):
(toKURL):
(WebView::addOriginAccessWhitelistEntry):
(WebView::removeOriginAccessWhitelistEntry):
(WebView::geolocationDidFailWithError):
(WebView::setDomainRelaxationForbiddenForURLScheme):
(WebView::setCompositionForTesting):
(WebView::confirmCompositionForTesting):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@128812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 02b30b04
2012-09-17 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r128809.
http://trac.webkit.org/changeset/128809
https://bugs.webkit.org/show_bug.cgi?id=96958
Broke the Windows build. (Requested by andersca on #webkit).
* platform/win/BString.cpp:
(WebCore::BString::~BString):
(WebCore::BString::adoptBSTR):
* platform/win/BString.h:
(BString):
2012-09-17 Patrick Gansterer <paroga@webkit.org>
[WIN] Use BString in favour of BSTR to improve memory management
......@@ -106,7 +106,7 @@ BString::BString(CFStringRef cfstr)
BString::~BString()
{
clear();
SysFreeString(m_bstr);
}
BString::BString(const BString& other)
......@@ -119,15 +119,11 @@ BString::BString(const BString& other)
void BString::adoptBSTR(BSTR bstr)
{
clear();
if (m_bstr)
SysFreeString(m_bstr);
m_bstr = bstr;
}
void BString::clear()
{
SysFreeString(m_bstr);
}
BString& BString::operator=(const BString& other)
{
if (this != &other)
......
......@@ -52,13 +52,11 @@ namespace WebCore {
~BString();
void adoptBSTR(BSTR);
void clear();
BString(const BString&);
BString& operator=(const BString&);
BString& operator=(const BSTR&);
BSTR* operator&() { ASSERT(!m_bstr); return &m_bstr; }
operator BSTR() const { return m_bstr; }
BSTR release() { BSTR result = m_bstr; m_bstr = 0; return result; }
......
2012-09-17 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r128809.
http://trac.webkit.org/changeset/128809
https://bugs.webkit.org/show_bug.cgi?id=96958
Broke the Windows build. (Requested by andersca on #webkit).
* DefaultPolicyDelegate.cpp:
(DefaultPolicyDelegate::decidePolicyForNavigationAction):
(DefaultPolicyDelegate::decidePolicyForMIMEType):
(DefaultPolicyDelegate::unableToImplementPolicyWithError):
* MarshallingHelpers.cpp:
(MarshallingHelpers::KURLToBSTR):
(MarshallingHelpers::CFStringRefToBSTR):
(MarshallingHelpers::stringArrayToSafeArray):
(MarshallingHelpers::safeArrayToStringArray):
* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::runJavaScriptPrompt):
* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::checkGrammarOfString):
(WebEditorClient::getGuessesForWord):
* WebFrame.cpp:
(WebFrame::canProvideDocumentSource):
* WebHistory.cpp:
(WebHistory::removeItem):
(WebHistory::addItem):
* WebIconDatabase.cpp:
(WebIconDatabase::startUpIconDatabase):
* WebNotificationCenter.cpp:
(WebNotificationCenter::postNotification):
* WebPreferences.cpp:
(WebPreferences::setStringValue):
* WebView.cpp:
(PreferencesChangedOrRemovedObserver::onNotify):
(WebView::close):
(WebView::canShowMIMEType):
(WebView::initWithFrame):
(WebView::setApplicationNameForUserAgent):
(WebView::setCustomUserAgent):
(WebView::userAgentForURL):
(WebView::setCustomTextEncodingName):
(WebView::customTextEncodingName):
(WebView::setPreferences):
(WebView::searchFor):
(WebView::executeCoreCommandByName):
(WebView::markAllMatchesForText):
(WebView::setGroupName):
(WebView::registerURLSchemeAsLocal):
(WebView::replaceSelectionWithText):
(WebView::onNotify):
(WebView::notifyPreferencesChanged):
(WebView::MIMETypeForExtension):
(WebView::standardUserAgentWithApplicationName):
(WebView::addAdditionalPluginDirectory):
(WebView::registerEmbeddedViewMIMEType):
(toString):
(toKURL):
(WebView::addOriginAccessWhitelistEntry):
(WebView::removeOriginAccessWhitelistEntry):
(WebView::geolocationDidFailWithError):
(WebView::setDomainRelaxationForbiddenForURLScheme):
(WebView::setCompositionForTesting):
(WebView::confirmCompositionForTesting):
2012-09-16 Mark Lam <mark.lam@apple.com>
Added MSVC project changes to enable building the llint.
......
......@@ -27,7 +27,6 @@
#include "WebKitDLL.h"
#include "DefaultPolicyDelegate.h"
#include <WebCore/BString.h>
#include <WebCore/COMPtr.h>
#include <wtf/text/WTFString.h>
......@@ -117,7 +116,7 @@ HRESULT STDMETHODCALLTYPE DefaultPolicyDelegate::decidePolicyForNavigationAction
else if (navType == WebNavigationTypePlugInRequest)
listener->use();
else {
BString url;
BSTR url;
// A file URL shouldn't fall through to here, but if it did,
// it would be a security risk to open it.
if (SUCCEEDED(request->URL(&url)) && !String(url, SysStringLen(url)).startsWith("file:")) {
......@@ -125,6 +124,7 @@ HRESULT STDMETHODCALLTYPE DefaultPolicyDelegate::decidePolicyForNavigationAction
;
}
listener->ignore();
SysFreeString(url);
}
}
return S_OK;
......@@ -152,7 +152,7 @@ HRESULT STDMETHODCALLTYPE DefaultPolicyDelegate::decidePolicyForMIMEType(
if (FAILED(webView->canShowMIMEType(type, &canShowMIMEType)))
canShowMIMEType = FALSE;
BString url;
BSTR url;
request->URL(&url);
if (String(url, SysStringLen(url)).startsWith("file:")) {
......@@ -171,6 +171,7 @@ HRESULT STDMETHODCALLTYPE DefaultPolicyDelegate::decidePolicyForMIMEType(
listener->use();
else
listener->ignore();
SysFreeString(url);
return S_OK;
}
......@@ -179,13 +180,15 @@ HRESULT STDMETHODCALLTYPE DefaultPolicyDelegate::unableToImplementPolicyWithErro
/*[in]*/ IWebError* error,
/*[in]*/ IWebFrame* frame)
{
BString errorStr;
BSTR errorStr;
error->localizedDescription(&errorStr);
BString frameName;
BSTR frameName;
frame->name(&frameName);
LOG_ERROR("called unableToImplementPolicyWithError:%S inFrame:%S", errorStr ? errorStr : TEXT(""), frameName ? frameName : TEXT(""));
SysFreeString(errorStr);
SysFreeString(frameName);
return S_OK;
}
......@@ -27,7 +27,6 @@
#include "WebKitDLL.h"
#include "MarshallingHelpers.h"
#include <WebCore/BString.h>
#include <WebCore/IntRect.h>
#include <WebCore/KURL.h>
#include <wtf/MathExtras.h>
......@@ -47,7 +46,7 @@ KURL MarshallingHelpers::BSTRToKURL(BSTR urlStr)
BSTR MarshallingHelpers::KURLToBSTR(const KURL& url)
{
return BString(url.string()).release();
return SysAllocStringLen(url.string().characters(), url.string().length());
}
CFURLRef MarshallingHelpers::PathStringToFileCFURLRef(const String& string)
......@@ -90,7 +89,20 @@ CFStringRef MarshallingHelpers::LPCOLESTRToCFStringRef(LPCOLESTR str)
BSTR MarshallingHelpers::CFStringRefToBSTR(CFStringRef str)
{
return BString(str).release();
if (!str)
return 0;
const UniChar* uniChars = CFStringGetCharactersPtr(str);
if (uniChars)
return SysAllocStringLen((LPCTSTR)uniChars, CFStringGetLength(str));
CFIndex length = CFStringGetLength(str);
BSTR bstr = SysAllocStringLen(0, length);
if (bstr) {
CFStringGetCharacters(str, CFRangeMake(0, length), (UniChar*)bstr);
bstr[length] = 0;
}
return bstr;
}
int MarshallingHelpers::CFNumberRefToInt(CFNumberRef num)
......@@ -147,8 +159,9 @@ SAFEARRAY* MarshallingHelpers::stringArrayToSafeArray(CFArrayRef inArray)
long count = 0;
for (CFIndex i=0; i<size; i++) {
CFStringRef item = (CFStringRef) CFArrayGetValueAtIndex(inArray, i);
BString bstr(item);
::SafeArrayPutElement(sa, &count, bstr); // SafeArrayPutElement() copies the string correctly.
BSTR bstr = CFStringRefToBSTR(item);
::SafeArrayPutElement(sa, &count, bstr);
SysFreeString(bstr); // SafeArrayPutElement() should make a copy of the string
count++;
}
return sa;
......@@ -219,9 +232,10 @@ CFArrayRef MarshallingHelpers::safeArrayToStringArray(SAFEARRAY* inArray)
if (len > 0) {
items = new CFStringRef[len];
for (; lBound <= uBound; lBound++) {
BString str;
BSTR str;
hr = ::SafeArrayGetElement(inArray, &lBound, &str);
items[lBound] = BSTRToCFStringRef(str);
SysFreeString(str);
}
}
CFArrayRef result = CFArrayCreate(0, (const void**)items, len, &kCFTypeArrayCallBacks);
......
......@@ -410,15 +410,17 @@ bool WebChromeClient::runJavaScriptPrompt(Frame*, const String& message, const S
TimerBase::fireTimersInNestedEventLoop();
BString resultBSTR;
BSTR resultBSTR = 0;
if (FAILED(ui->runJavaScriptTextInputPanelWithPrompt(m_webView, BString(message), BString(defaultValue), &resultBSTR)))
return false;
if (!resultBSTR)
return false;
if (resultBSTR) {
result = String(resultBSTR, SysStringLen(resultBSTR));
SysFreeString(resultBSTR);
return true;
}
result = String(resultBSTR, SysStringLen(resultBSTR));
return true;
return false;
}
void WebChromeClient::setStatusbarText(const String& statusText)
......
......@@ -695,19 +695,21 @@ void WebEditorClient::checkGrammarOfString(const UChar* text, int length, Vector
continue;
if (FAILED(detailObj->location(&detail.location)))
continue;
BString userDesc;
BSTR userDesc;
if (FAILED(detailObj->userDescription(&userDesc)))
continue;
detail.userDescription = String(userDesc, SysStringLen(userDesc));
SysFreeString(userDesc);
COMPtr<IEnumSpellingGuesses> enumGuessesObj;
if (FAILED(detailObj->guesses(&enumGuessesObj)))
continue;
while (true) {
BString guess;
BSTR guess;
if (enumGuessesObj->Next(1, &guess, &fetched) != S_OK)
break;
detail.guesses.append(String(guess, SysStringLen(guess)));
SysFreeString(guess);
}
details.append(detail);
......@@ -776,10 +778,11 @@ void WebEditorClient::getGuessesForWord(const String& word, const String& contex
while (true) {
ULONG fetched;
BString guess;
BSTR guess;
if (enumGuessesObj->Next(1, &guess, &fetched) != S_OK)
break;
guesses.append(String(guess, SysStringLen(guess)));
SysFreeString(guess);
}
}
......
......@@ -1442,10 +1442,11 @@ HRESULT WebFrame::canProvideDocumentSource(bool* result)
COMPtr<IWebURLResponse> urlResponse;
hr = dataSource->response(&urlResponse);
if (SUCCEEDED(hr) && urlResponse) {
BString mimeTypeBStr;
BSTR mimeTypeBStr;
if (SUCCEEDED(urlResponse->MIMEType(&mimeTypeBStr))) {
String mimeType(mimeTypeBStr, SysStringLen(mimeTypeBStr));
*result = mimeType == "text/html" || WebCore::DOMImplementation::isXMLMIMEType(mimeType);
SysFreeString(mimeTypeBStr);
}
}
return hr;
......
......@@ -36,7 +36,6 @@
#include "WebNotificationCenter.h"
#include "WebPreferences.h"
#include <CoreFoundation/CoreFoundation.h>
#include <WebCore/BString.h>
#include <WebCore/HistoryItem.h>
#include <WebCore/HistoryPropertyList.h>
#include <WebCore/KURL.h>
......@@ -613,13 +612,14 @@ HRESULT STDMETHODCALLTYPE WebHistory::historyAgeInDaysLimit(
HRESULT WebHistory::removeItem(IWebHistoryItem* entry)
{
HRESULT hr = S_OK;
BString urlBStr;
BSTR urlBStr = 0;
hr = entry->URLString(&urlBStr);
if (FAILED(hr))
return hr;
RetainPtr<CFStringRef> urlString(AdoptCF, MarshallingHelpers::BSTRToCFStringRef(urlBStr));
SysFreeString(urlBStr);
// If this exact object isn't stored, then make no change.
// FIXME: Is this the right behavior if this entry isn't present, but another entry for the same URL is?
......@@ -646,12 +646,13 @@ HRESULT WebHistory::addItem(IWebHistoryItem* entry, bool discardDuplicate, bool*
if (!entry)
return E_FAIL;
BString urlBStr;
BSTR urlBStr = 0;
hr = entry->URLString(&urlBStr);
if (FAILED(hr))
return hr;
RetainPtr<CFStringRef> urlString(AdoptCF, MarshallingHelpers::BSTRToCFStringRef(urlBStr));
SysFreeString(urlBStr);
COMPtr<IWebHistoryItem> oldEntry((IWebHistoryItem*) CFDictionaryGetValue(
m_entriesByURL.get(), urlString.get()));
......
......@@ -84,11 +84,12 @@ void WebIconDatabase::startUpIconDatabase()
iconDatabase().setClient(this);
BString prefDatabasePath;
BSTR prefDatabasePath = 0;
if (FAILED(standardPrefs->iconDatabaseLocation(&prefDatabasePath)))
LOG_ERROR("Unable to get icon database location preference");
String databasePath(prefDatabasePath, SysStringLen(prefDatabasePath));
SysFreeString(prefDatabasePath);
if (databasePath.isEmpty()) {
databasePath = localUserSpecificStorageDirectory();
......
......@@ -28,7 +28,6 @@
#include "WebNotificationCenter.h"
#include "WebNotification.h"
#include <WebCore/BString.h>
#include <WebCore/COMPtr.h>
#include <utility>
#include <wchar.h>
......@@ -161,7 +160,7 @@ HRESULT STDMETHODCALLTYPE WebNotificationCenter::addObserver(
HRESULT STDMETHODCALLTYPE WebNotificationCenter::postNotification(
/* [in] */ IWebNotification* notification)
{
BString name;
BSTR name;
HRESULT hr = notification->name(&name);
if (FAILED(hr))
return hr;
......@@ -172,6 +171,7 @@ HRESULT STDMETHODCALLTYPE WebNotificationCenter::postNotification(
return hr;
postNotificationInternal(notification, name, obj.get());
SysFreeString(name);
return hr;
}
......
......@@ -349,10 +349,10 @@ LONGLONG WebPreferences::longlongValueForKey(CFStringRef key)
void WebPreferences::setStringValue(CFStringRef key, LPCTSTR value)
{
BString val;
val.adoptBSTR(stringValueForKey(key));
BSTR val = stringValueForKey(key);
if (val && !wcscmp(val, value))
return;
SysFreeString(val);
RetainPtr<CFStringRef> valueRef(AdoptCF,
CFStringCreateWithCharactersNoCopy(0, (UniChar*)_wcsdup(value), (CFIndex)wcslen(value), kCFAllocatorMalloc));
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment