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));
......
......@@ -199,21 +199,6 @@ WebView* kit(Page* page)
return page ? static_cast<WebView*>(static_cast<WebChromeClient*>(page->chrome()->client())->webView()) : 0;
}
static inline AtomicString toAtomicString(BSTR bstr)
{
return AtomicString(bstr, SysStringLen(bstr));
}
static inline String toString(BSTR bstr)
{
return String(bstr, SysStringLen(bstr));
}
static inline KURL toKURL(BSTR bstr)
{
return KURL(KURL(), toString(bstr));
}
class PreferencesChangedOrRemovedObserver : public IWebNotificationObserver {
public:
static PreferencesChangedOrRemovedObserver* sharedInstance();
......@@ -260,10 +245,12 @@ HRESULT PreferencesChangedOrRemovedObserver::onNotify(IWebNotification* notifica
if (FAILED(hr))
return hr;
BString name;
hr = notification->name(&name);
BSTR nameBSTR;
hr = notification->name(&nameBSTR);
if (FAILED(hr))
return hr;
BString name;
name.adoptBSTR(nameBSTR);
if (wcscmp(name, WebPreferences::webPreferencesChangedNotification()) == 0)
return notifyPreferencesChanged(cacheModel);
......@@ -739,15 +726,17 @@ HRESULT STDMETHODCALLTYPE WebView::close()
notifyCenter->removeObserver(this, WebPreferences::webPreferencesChangedNotification(), static_cast<IWebPreferences*>(m_preferences.get()));
if (COMPtr<WebPreferences> preferences = m_preferences) {
BString identifier;
BSTR identifier = 0;
preferences->identifier(&identifier);
m_preferences = 0;
preferences->didRemoveFromWebView();
// Make sure we release the reference, since WebPreferences::removeReferenceForIdentifier will check for last reference to WebPreferences
preferences = 0;
if (identifier)
if (identifier) {
WebPreferences::removeReferenceForIdentifier(identifier);
SysFreeString(identifier);
}
}
deleteBackingStore();
......@@ -2524,7 +2513,7 @@ HRESULT STDMETHODCALLTYPE WebView::canShowMIMEType(
/* [in] */ BSTR mimeType,
/* [retval][out] */ BOOL* canShow)
{
String mimeTypeStr = toString(mimeType);
String mimeTypeStr(mimeType, SysStringLen(mimeType));
if (!canShow)
return E_POINTER;
......@@ -2691,14 +2680,18 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame(
m_page = new Page(pageClients);
provideGeolocationTo(m_page, new WebGeolocationClient(this));
BString localStoragePath;
if (SUCCEEDED(m_preferences->localStorageDatabasePath(&localStoragePath)))
m_page->settings()->setLocalStorageDatabasePath(toString(localStoragePath));
BSTR localStoragePath;
if (SUCCEEDED(m_preferences->localStorageDatabasePath(&localStoragePath))) {
m_page->settings()->setLocalStorageDatabasePath(String(localStoragePath, SysStringLen(localStoragePath)));
SysFreeString(localStoragePath);
}
if (m_uiDelegate) {
BString path;
if (SUCCEEDED(m_uiDelegate->ftpDirectoryTemplatePath(this, &path)))
m_page->settings()->setFTPDirectoryTemplatePath(toString(path));
BSTR path;
if (SUCCEEDED(m_uiDelegate->ftpDirectoryTemplatePath(this, &path))) {
m_page->settings()->setFTPDirectoryTemplatePath(String(path, SysStringLen(path)));
SysFreeString(path);
}
}
WebFrame* webFrame = WebFrame::createInstance();
......@@ -2706,7 +2699,7 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame(
m_mainFrame = webFrame;
webFrame->Release(); // The WebFrame is owned by the Frame, so release our reference to it.
coreFrame->tree()->setName(toString(frameName));
coreFrame->tree()->setName(String(frameName, SysStringLen(frameName)));
coreFrame->init();
setGroupName(groupName);
......@@ -3064,7 +3057,7 @@ float WebView::zoomMultiplier(bool isTextOnly)
HRESULT STDMETHODCALLTYPE WebView::setApplicationNameForUserAgent(
/* [in] */ BSTR applicationName)
{
m_applicationName = toString(applicationName);
m_applicationName = String(applicationName, SysStringLen(applicationName));
m_userAgentStandard = String();
return S_OK;
}
......@@ -3082,7 +3075,7 @@ HRESULT STDMETHODCALLTYPE WebView::setCustomUserAgent(
/* [in] */ BSTR userAgentString)
{
m_userAgentOverridden = userAgentString;
m_userAgentCustom = toString(userAgentString);
m_userAgentCustom = String(userAgentString, SysStringLen(userAgentString));
return S_OK;
}
......@@ -3103,7 +3096,7 @@ HRESULT STDMETHODCALLTYPE WebView::userAgentForURL(
/* [retval][out] */ BSTR* userAgent)
{
String userAgentString = userAgentForKURL(MarshallingHelpers::BSTRToKURL(url));
*userAgent = BString(userAgentString).release();
*userAgent = SysAllocStringLen(userAgentString.characters(), userAgentString.length());
if (!*userAgent && userAgentString.length())
return E_OUTOFMEMORY;
return S_OK;
......@@ -3123,14 +3116,14 @@ HRESULT STDMETHODCALLTYPE WebView::setCustomTextEncodingName(
return E_FAIL;
HRESULT hr;
BString oldEncoding;
BSTR oldEncoding;
hr = customTextEncodingName(&oldEncoding);
if (FAILED(hr))
return hr;
if (oldEncoding != encodingName && (!oldEncoding || !encodingName || wcscmp(oldEncoding, encodingName))) {
if (Frame* coreFrame = core(m_mainFrame))
coreFrame->loader()->reloadWithOverrideEncoding(toString(encodingName));
coreFrame->loader()->reloadWithOverrideEncoding(String(encodingName, SysStringLen(encodingName)));
}
return S_OK;
......@@ -3162,7 +3155,7 @@ HRESULT STDMETHODCALLTYPE WebView::customTextEncodingName(
return hr;
if (!*encodingName)
*encodingName = BString(m_overrideEncoding).release();
*encodingName = SysAllocStringLen(m_overrideEncoding.characters(), m_overrideEncoding.length());
if (!*encodingName && m_overrideEncoding.length())
return E_OUTOFMEMORY;
......@@ -3237,15 +3230,17 @@ HRESULT STDMETHODCALLTYPE WebView::setPreferences(
IWebNotificationCenter* nc = WebNotificationCenter::defaultCenterInternal();
nc->removeObserver(this, WebPreferences::webPreferencesChangedNotification(), static_cast<IWebPreferences*>(m_preferences.get()));
BString identifier;
BSTR identifier = 0;
oldPrefs->identifier(&identifier);
oldPrefs->didRemoveFromWebView();
oldPrefs = 0; // Make sure we release the reference, since WebPreferences::removeReferenceForIdentifier will check for last reference to WebPreferences
m_preferences = webPrefs;
if (identifier)
if (identifier) {
WebPreferences::removeReferenceForIdentifier(identifier);
SysFreeString(identifier);
}
nc->addObserver(this, WebPreferences::webPreferencesChangedNotification(), static_cast<IWebPreferences*>(m_preferences.get()));
......@@ -3393,7 +3388,7 @@ HRESULT STDMETHODCALLTYPE WebView::searchFor(
if (!str || !SysStringLen(str))
return E_INVALIDARG;
*found = m_page->findString(toString(str), caseFlag ? TextCaseSensitive : TextCaseInsensitive, forward ? FindDirectionForward : FindDirectionBackward, wrapFlag);
*found = m_page->findString(String(str, SysStringLen(str)), caseFlag ? TextCaseSensitive : TextCaseInsensitive, forward ? FindDirectionForward : FindDirectionBackward, wrapFlag);
return S_OK;
}
......@@ -3423,9 +3418,12 @@ HRESULT STDMETHODCALLTYPE WebView::updateFocusedAndActiveState()
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebView::executeCoreCommandByName(BSTR name, BSTR value)
HRESULT STDMETHODCALLTYPE WebView::executeCoreCommandByName(BSTR bName, BSTR bValue)
{
m_page->focusController()->focusedOrMainFrame()->editor()->command(toString(name)).execute(toString(value));
String name(bName, SysStringLen(bName));
String value(bValue, SysStringLen(bValue));
m_page->focusController()->focusedOrMainFrame()->editor()->command(name).execute(value);
return S_OK;
}
......@@ -3449,7 +3447,7 @@ HRESULT STDMETHODCALLTYPE WebView::markAllMatchesForText(
if (!str || !SysStringLen(str))
return E_INVALIDARG;
*matches = m_page->markAllMatchesForText(toString(str), caseSensitive ? TextCaseSensitive : TextCaseInsensitive, highlight, limit);
*matches = m_page->markAllMatchesForText(String(str, SysStringLen(str)), caseSensitive ? TextCaseSensitive : TextCaseInsensitive, highlight, limit);
return S_OK;
}
......@@ -3532,7 +3530,7 @@ HRESULT STDMETHODCALLTYPE WebView::setGroupName(
{
if (!m_page)
return S_OK;
m_page->setGroupName(toString(groupName));
m_page->setGroupName(String(groupName, SysStringLen(groupName)));
return S_OK;
}
......@@ -3766,7 +3764,7 @@ HRESULT STDMETHODCALLTYPE WebView::registerURLSchemeAsLocal(
if (!scheme)
return E_POINTER;
SchemeRegistry::registerURLSchemeAsLocal(toString(scheme));
SchemeRegistry::registerURLSchemeAsLocal(String(scheme, ::SysStringLen(scheme)));
return S_OK;
}
......@@ -4317,8 +4315,9 @@ HRESULT STDMETHODCALLTYPE WebView::replaceSelectionWithNode(
HRESULT STDMETHODCALLTYPE WebView::replaceSelectionWithText(