From: bfulgham@apple.com Date: Wed, 9 Apr 2014 20:21:36 +0000 (+0000) Subject: [Win] Various DumpRenderTree Fixes. X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=01d33bf20639784b79169dc11963ac398e415da8 [Win] Various DumpRenderTree Fixes. https://bugs.webkit.org/show_bug.cgi?id=131446. Reviewed by Tim Horton. * DumpRenderTree/win/AccessibilityUIElementWin.cpp: (AccessibilityUIElement::title): Switch to _bstr_t. Use JSStringCreateWithBSTR. (AccessibilityUIElement::description): Ditto. (AccessibilityUIElement::helpText): Ditto. (AccessibilityUIElement::intValue): Ditto. (AccessibilityUIElement::isPressActionSupported): Ditto. (AccessibilityUIElement::accessibilityValue): Ditto. * DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp: (DRTDesktopNotificationPresenter::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. (DRTDesktopNotificationPresenter::AddRef): Ditto. (DRTDesktopNotificationPresenter::Release): Ditto. (DRTDesktopNotificationPresenter::showDesktopNotification): Switch to _bstr_t. Use JSStringCreateWithBSTR. (DRTDesktopNotificationPresenter::cancelDesktopNotification): Ditto. (DRTDesktopNotificationPresenter::notificationDestroyed): Ditto. (DRTDesktopNotificationPresenter::checkNotificationPermission): Ditto. (DRTDesktopNotificationPresenter::requestNotificationPermission): Ditto. * DumpRenderTree/win/DRTDesktopNotificationPresenter.h: * DumpRenderTree/win/DumpRenderTree.cpp: (dumpFrameScrollPosition): Ditto. (dumpFramesAsText): Ditto. (compareHistoryItems): Ditto. (dumpHistoryItem): Ditto. (dump): Ditto. (resetDefaultsToConsistentValues): Ditto. (resetWebViewToConsistentStateBeforeTesting): Ditto. (runTest): Ditto. (createWebViewAndOffscreenWindow): Ditto. * DumpRenderTree/win/EditingDelegate.cpp: (EditingDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. (EditingDelegate::AddRef): Ditto. (EditingDelegate::Release): Ditto. (dumpPath): Switch to _bstr_t. Use JSStringCreateWithBSTR (EditingDelegate::shouldBeginEditingInDOMRange): Get rid of uneeded STDMETHODCALLTYPE declaration. (EditingDelegate::shouldEndEditingInDOMRange): Ditto. (EditingDelegate::shouldInsertNode): Ditto. (EditingDelegate::shouldInsertText): Ditto. (EditingDelegate::shouldDeleteDOMRange): Ditto. (EditingDelegate::shouldChangeSelectedDOMRange): Ditto. (EditingDelegate::shouldApplyStyle): Ditto. (EditingDelegate::shouldChangeTypingStyle): Ditto. (EditingDelegate::doPlatformCommand): Ditto. (EditingDelegate::webViewDidBeginEditing): Switch to _bstr_t. Use JSStringCreateWithBSTR. (EditingDelegate::webViewDidChange): Ditto. (EditingDelegate::webViewDidEndEditing): Ditto. (EditingDelegate::webViewDidChangeTypingStyle): Ditto. (EditingDelegate::webViewDidChangeSelection): Ditto. (EditingDelegate::checkSpellingOfString): Ditto. * DumpRenderTree/win/FrameLoadDelegate.cpp: (descriptionSuitableForTestResult): Switch to _bstr_t. Use JSStringCreateWithBSTR. (FrameLoadDelegate::FrameLoadDelegate): Ditto. (FrameLoadDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. (FrameLoadDelegate::AddRef): Ditto. (FrameLoadDelegate::Release): Ditto. (FrameLoadDelegate::didStartProvisionalLoadForFrame): Switch to _bstr_t. Use JSStringCreateWithBSTR. (FrameLoadDelegate::didReceiveServerRedirectForProvisionalLoadForFrame): Ditto. (FrameLoadDelegate::didFailProvisionalLoadWithError): Ditto. (FrameLoadDelegate::didCommitLoadForFrame): Ditto. (FrameLoadDelegate::didReceiveTitle): Ditto. (FrameLoadDelegate::didChangeIcons): Ditto. (delegatesWithDelayedWork): Ditto. (FrameLoadDelegate::didFinishLoadForFrame): Ditto. (FrameLoadDelegate::didFailLoadWithError): Ditto. (FrameLoadDelegate::willPerformClientRedirectToURL): Ditto. (FrameLoadDelegate::didCancelClientRedirectForFrame): Ditto. (FrameLoadDelegate::willCloseFrame): Ditto. (FrameLoadDelegate::didFinishDocumentLoadForFrame): Ditto. (FrameLoadDelegate::didHandleOnloadEventsForFrame): Ditto. (FrameLoadDelegate::didFirstVisuallyNonEmptyLayoutInFrame): Ditto. (FrameLoadDelegate::didDisplayInsecureContent): Ditto. (FrameLoadDelegate::didRunInsecureContent): Ditto. * DumpRenderTree/win/FrameLoadDelegate.h: * DumpRenderTree/win/HistoryDelegate.cpp: (HistoryDelegate::didNavigateWithNavigationData): Switch to _bstr_t. Use JSStringCreateWithBSTR. (HistoryDelegate::updateHistoryTitle): Ditto. (HistoryDelegate::populateVisitedLinksForWebView): Ditto. * DumpRenderTree/win/PolicyDelegate.cpp: (dumpPath): (PolicyDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. (PolicyDelegate::AddRef): Ditto. (PolicyDelegate::Release): Ditto. (PolicyDelegate::decidePolicyForNavigationAction): Switch to _bstr_t. Use JSStringCreateWithBSTR. (PolicyDelegate::unableToImplementPolicyWithError): Ditto. * DumpRenderTree/win/ResourceLoadDelegate.cpp: (ResourceLoadDelegate::descriptionSuitableForTestResult): Switch to _bstr_t. Use JSStringCreateWithBSTR. (ResourceLoadDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. (ResourceLoadDelegate::AddRef): Ditto. (ResourceLoadDelegate::Release): Ditto. (ResourceLoadDelegate::identifierForInitialRequest): Switch to _bstr_t. Use JSStringCreateWithBSTR. (ResourceLoadDelegate::removeIdentifierForRequest): Ditto. (ResourceLoadDelegate::willSendRequest): Ditto. (ResourceLoadDelegate::didReceiveAuthenticationChallenge): Ditto. (ResourceLoadDelegate::didReceiveResponse): Ditto. (ResourceLoadDelegate::didFinishLoadingFromDataSource): Ditto. (ResourceLoadDelegate::didFailLoadingWithError): Ditto. * DumpRenderTree/win/TestRunnerWin.cpp: Ditto. (TestRunner::queueLoad): Switch to _bstr_t. Use JSStringCreateWithBSTR. (TestRunner::setUserStyleSheetLocation): Ditto. (TestRunner::execCommand): Ditto. (TestRunner::overridePreference): Ditto. (TestRunner::evaluateScriptInIsolatedWorld): Ditto. * DumpRenderTree/win/TextInputControllerWin.cpp: Ditto. (TextInputController::setMarkedText): Switch to _bstr_t. Use JSStringCreateWithBSTR. (TextInputController::insertText): Ditto. * DumpRenderTree/win/UIDelegate.cpp: (UIDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. (UIDelegate::AddRef): Ditto. (UIDelegate::Release): Ditto. (UIDelegate::hasCustomMenuImplementation): Switch to _bstr_t. Use JSStringCreateWithBSTR. (UIDelegate::trackCustomPopupMenu): Ditto. (UIDelegate::registerUndoWithTarget): Ditto. (UIDelegate::removeAllActionsWithTarget): Ditto. (UIDelegate::setActionTitle): Ditto. (UIDelegate::undo): Ditto. (UIDelegate::redo): Ditto. (UIDelegate::canUndo): Ditto. (UIDelegate::canRedo): Ditto. (UIDelegate::printFrame): Ditto. (UIDelegate::ftpDirectoryTemplatePath): Ditto. (UIDelegate::webViewHeaderHeight): Ditto. (UIDelegate::webViewFooterHeight): Ditto. (UIDelegate::drawHeaderInRect): Ditto. (UIDelegate::drawFooterInRect): Ditto. (UIDelegate::webViewPrintingMarginRect): Ditto. (UIDelegate::canRunModal): Ditto. (UIDelegate::createModalDialog): Ditto. (UIDelegate::runModal): Ditto. (UIDelegate::isMenuBarVisible): Ditto. (UIDelegate::setMenuBarVisible): Ditto. (UIDelegate::runDatabaseSizeLimitPrompt): Ditto. (UIDelegate::paintCustomScrollbar): Ditto. (UIDelegate::paintCustomScrollCorner): Ditto. (UIDelegate::setFrame): Ditto. (UIDelegate::webViewFrame): Ditto. (UIDelegate::runJavaScriptAlertPanelWithMessage): Ditto. (UIDelegate::runJavaScriptConfirmPanelWithMessage): Ditto. (UIDelegate::runJavaScriptTextInputPanelWithPrompt): Ditto. (UIDelegate::runBeforeUnloadConfirmPanelWithMessage): Ditto. (UIDelegate::webViewAddMessageToConsole): Ditto. (UIDelegate::doDragDrop): Ditto. (UIDelegate::webViewGetDlgCode): Ditto. (UIDelegate::createWebViewWithRequest): Ditto. (UIDelegate::webViewClose): Ditto. (UIDelegate::webViewFocus): Ditto. (UIDelegate::webViewUnfocus): Ditto. (UIDelegate::webViewPainted): Ditto. (UIDelegate::exceededDatabaseQuota): Ditto. (UIDelegate::embeddedViewWithArguments): Ditto. (UIDelegate::webViewClosing): Ditto. (UIDelegate::webViewSetCursor): Ditto. (UIDelegate::webViewDidInvalidate): Ditto. (UIDelegate::setStatusText): Ditto. (UIDelegate::desktopNotificationsDelegate): Ditto. (UIDelegate::drawBackground): Ditto. (UIDelegate::decidePolicyForGeolocationRequest): Ditto. (UIDelegate::didPressMissingPluginButton): Ditto. * DumpRenderTree/win/WorkQueueItemWin.cpp: Ditto. (LoadItem::invoke): Switch to _bstr_t. Use JSStringCreateWithBSTR. (LoadHTMLStringItem::invoke): Ditto. (ScriptItem::invoke): Ditto. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167030 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 9a914cf..a3668e0 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,170 @@ +2014-04-09 Brent Fulgham + + [Win] Various DumpRenderTree Fixes. + https://bugs.webkit.org/show_bug.cgi?id=131446. + + Reviewed by Tim Horton. + + * DumpRenderTree/win/AccessibilityUIElementWin.cpp: + (AccessibilityUIElement::title): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (AccessibilityUIElement::description): Ditto. + (AccessibilityUIElement::helpText): Ditto. + (AccessibilityUIElement::intValue): Ditto. + (AccessibilityUIElement::isPressActionSupported): Ditto. + (AccessibilityUIElement::accessibilityValue): Ditto. + * DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp: + (DRTDesktopNotificationPresenter::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. + (DRTDesktopNotificationPresenter::AddRef): Ditto. + (DRTDesktopNotificationPresenter::Release): Ditto. + (DRTDesktopNotificationPresenter::showDesktopNotification): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (DRTDesktopNotificationPresenter::cancelDesktopNotification): Ditto. + (DRTDesktopNotificationPresenter::notificationDestroyed): Ditto. + (DRTDesktopNotificationPresenter::checkNotificationPermission): Ditto. + (DRTDesktopNotificationPresenter::requestNotificationPermission): Ditto. + * DumpRenderTree/win/DRTDesktopNotificationPresenter.h: + * DumpRenderTree/win/DumpRenderTree.cpp: + (dumpFrameScrollPosition): Ditto. + (dumpFramesAsText): Ditto. + (compareHistoryItems): Ditto. + (dumpHistoryItem): Ditto. + (dump): Ditto. + (resetDefaultsToConsistentValues): Ditto. + (resetWebViewToConsistentStateBeforeTesting): Ditto. + (runTest): Ditto. + (createWebViewAndOffscreenWindow): Ditto. + * DumpRenderTree/win/EditingDelegate.cpp: + (EditingDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. + (EditingDelegate::AddRef): Ditto. + (EditingDelegate::Release): Ditto. + (dumpPath): Switch to _bstr_t. Use JSStringCreateWithBSTR + (EditingDelegate::shouldBeginEditingInDOMRange): Get rid of uneeded STDMETHODCALLTYPE declaration. + (EditingDelegate::shouldEndEditingInDOMRange): Ditto. + (EditingDelegate::shouldInsertNode): Ditto. + (EditingDelegate::shouldInsertText): Ditto. + (EditingDelegate::shouldDeleteDOMRange): Ditto. + (EditingDelegate::shouldChangeSelectedDOMRange): Ditto. + (EditingDelegate::shouldApplyStyle): Ditto. + (EditingDelegate::shouldChangeTypingStyle): Ditto. + (EditingDelegate::doPlatformCommand): Ditto. + (EditingDelegate::webViewDidBeginEditing): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (EditingDelegate::webViewDidChange): Ditto. + (EditingDelegate::webViewDidEndEditing): Ditto. + (EditingDelegate::webViewDidChangeTypingStyle): Ditto. + (EditingDelegate::webViewDidChangeSelection): Ditto. + (EditingDelegate::checkSpellingOfString): Ditto. + * DumpRenderTree/win/FrameLoadDelegate.cpp: + (descriptionSuitableForTestResult): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (FrameLoadDelegate::FrameLoadDelegate): Ditto. + (FrameLoadDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. + (FrameLoadDelegate::AddRef): Ditto. + (FrameLoadDelegate::Release): Ditto. + (FrameLoadDelegate::didStartProvisionalLoadForFrame): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (FrameLoadDelegate::didReceiveServerRedirectForProvisionalLoadForFrame): Ditto. + (FrameLoadDelegate::didFailProvisionalLoadWithError): Ditto. + (FrameLoadDelegate::didCommitLoadForFrame): Ditto. + (FrameLoadDelegate::didReceiveTitle): Ditto. + (FrameLoadDelegate::didChangeIcons): Ditto. + (delegatesWithDelayedWork): Ditto. + (FrameLoadDelegate::didFinishLoadForFrame): Ditto. + (FrameLoadDelegate::didFailLoadWithError): Ditto. + (FrameLoadDelegate::willPerformClientRedirectToURL): Ditto. + (FrameLoadDelegate::didCancelClientRedirectForFrame): Ditto. + (FrameLoadDelegate::willCloseFrame): Ditto. + (FrameLoadDelegate::didFinishDocumentLoadForFrame): Ditto. + (FrameLoadDelegate::didHandleOnloadEventsForFrame): Ditto. + (FrameLoadDelegate::didFirstVisuallyNonEmptyLayoutInFrame): Ditto. + (FrameLoadDelegate::didDisplayInsecureContent): Ditto. + (FrameLoadDelegate::didRunInsecureContent): Ditto. + * DumpRenderTree/win/FrameLoadDelegate.h: + * DumpRenderTree/win/HistoryDelegate.cpp: + (HistoryDelegate::didNavigateWithNavigationData): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (HistoryDelegate::updateHistoryTitle): Ditto. + (HistoryDelegate::populateVisitedLinksForWebView): Ditto. + * DumpRenderTree/win/PolicyDelegate.cpp: + (dumpPath): + (PolicyDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. + (PolicyDelegate::AddRef): Ditto. + (PolicyDelegate::Release): Ditto. + (PolicyDelegate::decidePolicyForNavigationAction): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (PolicyDelegate::unableToImplementPolicyWithError): Ditto. + * DumpRenderTree/win/ResourceLoadDelegate.cpp: + (ResourceLoadDelegate::descriptionSuitableForTestResult): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (ResourceLoadDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. + (ResourceLoadDelegate::AddRef): Ditto. + (ResourceLoadDelegate::Release): Ditto. + (ResourceLoadDelegate::identifierForInitialRequest): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (ResourceLoadDelegate::removeIdentifierForRequest): Ditto. + (ResourceLoadDelegate::willSendRequest): Ditto. + (ResourceLoadDelegate::didReceiveAuthenticationChallenge): Ditto. + (ResourceLoadDelegate::didReceiveResponse): Ditto. + (ResourceLoadDelegate::didFinishLoadingFromDataSource): Ditto. + (ResourceLoadDelegate::didFailLoadingWithError): Ditto. + * DumpRenderTree/win/TestRunnerWin.cpp: Ditto. + (TestRunner::queueLoad): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (TestRunner::setUserStyleSheetLocation): Ditto. + (TestRunner::execCommand): Ditto. + (TestRunner::overridePreference): Ditto. + (TestRunner::evaluateScriptInIsolatedWorld): Ditto. + * DumpRenderTree/win/TextInputControllerWin.cpp: Ditto. + (TextInputController::setMarkedText): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (TextInputController::insertText): Ditto. + * DumpRenderTree/win/UIDelegate.cpp: + (UIDelegate::QueryInterface): Get rid of uneeded STDMETHODCALLTYPE declaration. + (UIDelegate::AddRef): Ditto. + (UIDelegate::Release): Ditto. + (UIDelegate::hasCustomMenuImplementation): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (UIDelegate::trackCustomPopupMenu): Ditto. + (UIDelegate::registerUndoWithTarget): Ditto. + (UIDelegate::removeAllActionsWithTarget): Ditto. + (UIDelegate::setActionTitle): Ditto. + (UIDelegate::undo): Ditto. + (UIDelegate::redo): Ditto. + (UIDelegate::canUndo): Ditto. + (UIDelegate::canRedo): Ditto. + (UIDelegate::printFrame): Ditto. + (UIDelegate::ftpDirectoryTemplatePath): Ditto. + (UIDelegate::webViewHeaderHeight): Ditto. + (UIDelegate::webViewFooterHeight): Ditto. + (UIDelegate::drawHeaderInRect): Ditto. + (UIDelegate::drawFooterInRect): Ditto. + (UIDelegate::webViewPrintingMarginRect): Ditto. + (UIDelegate::canRunModal): Ditto. + (UIDelegate::createModalDialog): Ditto. + (UIDelegate::runModal): Ditto. + (UIDelegate::isMenuBarVisible): Ditto. + (UIDelegate::setMenuBarVisible): Ditto. + (UIDelegate::runDatabaseSizeLimitPrompt): Ditto. + (UIDelegate::paintCustomScrollbar): Ditto. + (UIDelegate::paintCustomScrollCorner): Ditto. + (UIDelegate::setFrame): Ditto. + (UIDelegate::webViewFrame): Ditto. + (UIDelegate::runJavaScriptAlertPanelWithMessage): Ditto. + (UIDelegate::runJavaScriptConfirmPanelWithMessage): Ditto. + (UIDelegate::runJavaScriptTextInputPanelWithPrompt): Ditto. + (UIDelegate::runBeforeUnloadConfirmPanelWithMessage): Ditto. + (UIDelegate::webViewAddMessageToConsole): Ditto. + (UIDelegate::doDragDrop): Ditto. + (UIDelegate::webViewGetDlgCode): Ditto. + (UIDelegate::createWebViewWithRequest): Ditto. + (UIDelegate::webViewClose): Ditto. + (UIDelegate::webViewFocus): Ditto. + (UIDelegate::webViewUnfocus): Ditto. + (UIDelegate::webViewPainted): Ditto. + (UIDelegate::exceededDatabaseQuota): Ditto. + (UIDelegate::embeddedViewWithArguments): Ditto. + (UIDelegate::webViewClosing): Ditto. + (UIDelegate::webViewSetCursor): Ditto. + (UIDelegate::webViewDidInvalidate): Ditto. + (UIDelegate::setStatusText): Ditto. + (UIDelegate::desktopNotificationsDelegate): Ditto. + (UIDelegate::drawBackground): Ditto. + (UIDelegate::decidePolicyForGeolocationRequest): Ditto. + (UIDelegate::didPressMissingPluginButton): Ditto. + * DumpRenderTree/win/WorkQueueItemWin.cpp: Ditto. + (LoadItem::invoke): Switch to _bstr_t. Use JSStringCreateWithBSTR. + (LoadHTMLStringItem::invoke): Ditto. + (ScriptItem::invoke): Ditto. + 2014-04-09 Gergo Balogh Stylechecker: False positive on inline asm code. diff --git a/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp b/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp index 257d9a4..1814ed3 100644 --- a/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp +++ b/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2013 Apple Inc. All Rights Reserved. + * Copyright (C) 2008, 2013, 2014 Apple Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,6 +30,7 @@ #include "DumpRenderTree.h" #include "FrameLoadDelegate.h" #include +#include #include #include #include @@ -296,12 +297,11 @@ JSStringRef AccessibilityUIElement::title() if (!m_element) return JSStringCreateWithCharacters(0, 0); - BSTR titleBSTR; - if (FAILED(m_element->get_accName(self(), &titleBSTR)) || !titleBSTR) + _bstr_t titleBSTR; + if (FAILED(m_element->get_accName(self(), &titleBSTR.GetBSTR())) || !titleBSTR.length()) return JSStringCreateWithCharacters(0, 0); - wstring title(titleBSTR, SysStringLen(titleBSTR)); - ::SysFreeString(titleBSTR); - return JSStringCreateWithCharacters(title.data(), title.length()); + + return JSStringCreateWithBSTR(titleBSTR); } JSStringRef AccessibilityUIElement::description() @@ -309,12 +309,10 @@ JSStringRef AccessibilityUIElement::description() if (!m_element) return JSStringCreateWithCharacters(0, 0); - BSTR descriptionBSTR; - if (FAILED(m_element->get_accDescription(self(), &descriptionBSTR)) || !descriptionBSTR) + _bstr_t descriptionBSTR; + if (FAILED(m_element->get_accDescription(self(), &descriptionBSTR.GetBSTR())) || !descriptionBSTR.length()) return JSStringCreateWithCharacters(0, 0); - wstring description(descriptionBSTR, SysStringLen(descriptionBSTR)); - ::SysFreeString(descriptionBSTR); - return JSStringCreateWithCharacters(description.data(), description.length()); + return JSStringCreateWithBSTR(descriptionBSTR); } JSStringRef AccessibilityUIElement::stringValue() @@ -332,12 +330,10 @@ JSStringRef AccessibilityUIElement::helpText() const if (!m_element) return JSStringCreateWithCharacters(0, 0); - BSTR helpTextBSTR; - if (FAILED(m_element->get_accHelp(self(), &helpTextBSTR)) || !helpTextBSTR) + _bstr_t helpTextBSTR; + if (FAILED(m_element->get_accHelp(self(), &helpTextBSTR.GetBSTR())) || !helpTextBSTR.length()) return JSStringCreateWithCharacters(0, 0); - wstring helpText(helpTextBSTR, SysStringLen(helpTextBSTR)); - ::SysFreeString(helpTextBSTR); - return JSStringCreateWithCharacters(helpText.data(), helpText.length()); + return JSStringCreateWithBSTR(helpTextBSTR); } double AccessibilityUIElement::x() @@ -472,13 +468,12 @@ double AccessibilityUIElement::intValue() const if (!m_element) return 0; - BSTR valueBSTR; - if (FAILED(m_element->get_accValue(self(), &valueBSTR)) || !valueBSTR) + _bstr_t valueBSTR; + if (FAILED(m_element->get_accValue(self(), &valueBSTR.GetBSTR())) || !valueBSTR.length()) return 0; - wstring value(valueBSTR, SysStringLen(valueBSTR)); - ::SysFreeString(valueBSTR); + TCHAR* ignored; - return _tcstod(value.data(), &ignored); + return _tcstod(static_cast(valueBSTR), &ignored); } double AccessibilityUIElement::minValue() @@ -496,11 +491,11 @@ bool AccessibilityUIElement::isPressActionSupported() if (!m_element) return 0; - BSTR valueBSTR; - if (FAILED(m_element->get_accDefaultAction(self(), &valueBSTR) || !valueBSTR)) + _bstr_t valueBSTR; + if (FAILED(m_element->get_accDefaultAction(self(), &valueBSTR.GetBSTR()))) return false; - if (!::SysStringLen(valueBSTR)) + if (!valueBSTR.length()) return false; return true; @@ -725,14 +720,11 @@ JSStringRef AccessibilityUIElement::accessibilityValue() const if (!m_element) return JSStringCreateWithCharacters(0, 0); - BSTR valueBSTR; - if (FAILED(m_element->get_accValue(self(), &valueBSTR)) || !valueBSTR) + _bstr_t valueBSTR; + if (FAILED(m_element->get_accValue(self(), &valueBSTR.GetBSTR())) || !valueBSTR.length()) return JSStringCreateWithCharacters(0, 0); - wstring value(valueBSTR, SysStringLen(valueBSTR)); - ::SysFreeString(valueBSTR); - - return JSStringCreateWithCharacters(value.data(), value.length()); + return JSStringCreateWithBSTR(valueBSTR); } diff --git a/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp b/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp index a7bfc6d..b5711a1 100644 --- a/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp +++ b/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -36,11 +37,12 @@ #include #include #include +#include DRTDesktopNotificationPresenter::DRTDesktopNotificationPresenter() : m_refCount(1) {} -HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::QueryInterface(REFIID riid, void** ppvObject) +HRESULT DRTDesktopNotificationPresenter::QueryInterface(REFIID riid, void** ppvObject) { *ppvObject = 0; if (IsEqualGUID(riid, IID_IUnknown)) @@ -54,12 +56,12 @@ HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::QueryInterface(REFIID return S_OK; } -ULONG STDMETHODCALLTYPE DRTDesktopNotificationPresenter::AddRef() +ULONG DRTDesktopNotificationPresenter::AddRef() { return ++m_refCount; } -ULONG STDMETHODCALLTYPE DRTDesktopNotificationPresenter::Release() +ULONG DRTDesktopNotificationPresenter::Release() { ULONG newRef = --m_refCount; if (!newRef) @@ -68,23 +70,19 @@ ULONG STDMETHODCALLTYPE DRTDesktopNotificationPresenter::Release() return newRef; } -HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::showDesktopNotification( - /* [in] */ IWebDesktopNotification* notification) +HRESULT DRTDesktopNotificationPresenter::showDesktopNotification(IWebDesktopNotification* notification) { - BSTR title, text, url; + _bstr_t title, text, url; BOOL html; if (!notification->isHTML(&html) && html) { - notification->contentsURL(&url); - printf("DESKTOP NOTIFICATION: contents at %S\n", url ? url : L""); + notification->contentsURL(&url.GetBSTR()); + printf("DESKTOP NOTIFICATION: contents at %S\n", static_cast(url)); } else { - notification->iconURL(&url); - notification->title(&title); - notification->text(&text); - printf("DESKTOP NOTIFICATION: icon %S, title %S, text %S\n", - url ? url : L"", - title ? title : L"", - text ? text : L""); + notification->iconURL(&url.GetBSTR()); + notification->title(&title.GetBSTR()); + notification->text(&text.GetBSTR()); + printf("DESKTOP NOTIFICATION: icon %S, title %S, text %S\n", static_cast(url), static_cast(title), static_cast(text)); } // In this stub implementation, the notification is displayed immediately; @@ -94,34 +92,30 @@ HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::showDesktopNotificati return S_OK; } -HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::cancelDesktopNotification( - /* [in] */ IWebDesktopNotification* notification) +HRESULT DRTDesktopNotificationPresenter::cancelDesktopNotification(IWebDesktopNotification* notification) { - BSTR identifier; + _bstr_t identifier; BOOL html; notification->isHTML(&html); if (html) - notification->contentsURL(&identifier); + notification->contentsURL(&identifier.GetBSTR()); else - notification->title(&identifier); + notification->title(&identifier.GetBSTR()); - printf("DESKTOP NOTIFICATION CLOSED: %S\n", identifier ? identifier : L""); + printf("DESKTOP NOTIFICATION CLOSED: %S\n", static_cast(identifier)); notification->notifyClose(false); return S_OK; } -HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::notificationDestroyed( - /* [in] */ IWebDesktopNotification* notification) +HRESULT DRTDesktopNotificationPresenter::notificationDestroyed(IWebDesktopNotification* /*notification*/) { // Since in these tests events happen immediately, we don't hold on to // Notification pointers. So there's no cleanup to do. return S_OK; } -HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::checkNotificationPermission( - /* [in] */ BSTR origin, - /* [out, retval] */ int* result) +HRESULT DRTDesktopNotificationPresenter::checkNotificationPermission(BSTR /*origin*/, int* /*result*/) { #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) JSStringRef jsOrigin = JSStringCreateWithBSTR(origin); @@ -137,8 +131,7 @@ HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::checkNotificationPerm return S_OK; } -HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::requestNotificationPermission( - /* [in] */ BSTR origin) +HRESULT DRTDesktopNotificationPresenter::requestNotificationPermission(BSTR origin) { printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %S\n", origin ? origin : L""); return S_OK; diff --git a/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.h b/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.h index bedfcde..d2f17a6 100644 --- a/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.h +++ b/Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.h @@ -30,7 +30,6 @@ #define DRTDesktopNotificationPresenter_h #include -#include #include class DRTDesktopNotificationPresenter : public IWebDesktopNotificationsDelegate { diff --git a/Tools/DumpRenderTree/win/DumpRenderTree.cpp b/Tools/DumpRenderTree/win/DumpRenderTree.cpp index 9612092..b4454ee 100644 --- a/Tools/DumpRenderTree/win/DumpRenderTree.cpp +++ b/Tools/DumpRenderTree/win/DumpRenderTree.cpp @@ -402,11 +402,10 @@ void dumpFrameScrollPosition(IWebFrame* frame) if (FAILED(frame->parentFrame(&parent))) return; if (parent) { - BSTR name; - if (FAILED(frame->name(&name))) + _bstr_t name; + if (FAILED(frame->name(&name.GetBSTR()))) return; - printf("frame '%S' ", name ? name : L""); - SysFreeString(name); + printf("frame '%S' ", static_cast(name)); } printf("scrolled to %.f,%.f\n", (double)scrollPosition.cx, (double)scrollPosition.cy); } @@ -447,27 +446,23 @@ static wstring dumpFramesAsText(IWebFrame* frame) if (FAILED(frame->parentFrame(&parent))) return L""; if (parent) { - BSTR name = L""; - if (FAILED(frame->name(&name))) + _bstr_t name; + if (FAILED(frame->name(&name.GetBSTR()))) return L""; result.append(L"\n--------\nFrame: '"); - result.append(name ? name : L"", SysStringLen(name)); + result.append(static_cast(name), name.length()); result.append(L"'\n--------\n"); - - SysFreeString(name); } - BSTR innerText = 0; + _bstr_t innerText; COMPtr docPrivate; if (SUCCEEDED(documentElement->QueryInterface(&docPrivate))) - docPrivate->innerText(&innerText); + docPrivate->innerText(&innerText.GetBSTR()); - result.append(innerText ? innerText : L"", SysStringLen(innerText)); + result.append(static_cast(innerText), innerText.length()); result.append(L"\n"); - SysFreeString(innerText); - if (::gTestRunner->dumpChildFramesAsText()) { COMPtr enumKids; if (FAILED(frame->childFrames(&enumKids))) @@ -496,20 +491,15 @@ static int compareHistoryItems(const void* item1, const void* item2) if (FAILED((*(COMPtr*)item2)->QueryInterface(&itemB))) return 0; - BSTR targetA; - if (FAILED(itemA->target(&targetA))) + _bstr_t targetA; + if (FAILED(itemA->target(&targetA.GetBSTR()))) return 0; - BSTR targetB; - if (FAILED(itemB->target(&targetB))) { - SysFreeString(targetA); + _bstr_t targetB; + if (FAILED(itemB->target(&targetB.GetBSTR()))) return 0; - } - int result = wcsicmp(wstring(targetA, SysStringLen(targetA)).c_str(), wstring(targetB, SysStringLen(targetB)).c_str()); - SysFreeString(targetA); - SysFreeString(targetB); - return result; + return wcsicmp(static_cast(targetA), static_cast(targetB)); } static void dumpHistoryItem(IWebHistoryItem* item, int indent, bool current) @@ -524,40 +514,37 @@ static void dumpHistoryItem(IWebHistoryItem* item, int indent, bool current) for (int i = start; i < indent; i++) putchar(' '); - BSTR url; - if (FAILED(item->URLString(&url))) + _bstr_t url; + if (FAILED(item->URLString(&url.GetBSTR()))) return; - if (wcsstr(url, L"file:/") == url) { + if (wcsstr(static_cast(url), L"file:/") == static_cast(url)) { static wchar_t* layoutTestsString = L"/LayoutTests/"; static wchar_t* fileTestString = L"(file test):"; - wchar_t* result = wcsstr(url, layoutTestsString); + wchar_t* result = wcsstr(static_cast(url), layoutTestsString); if (result == NULL) return; wchar_t* start = result + wcslen(layoutTestsString); - BSTR newURL = SysAllocStringLen(NULL, SysStringLen(url)); - wcscpy(newURL, fileTestString); - wcscpy(newURL + wcslen(fileTestString), start); + _bstr_t newURL(SysAllocStringLen(0, SysStringLen(url)), false); + wcscpy(static_cast(newURL), fileTestString); + wcscpy(static_cast(newURL) + wcslen(fileTestString), start); - SysFreeString(url); url = newURL; } - printf("%S", url ? url : L""); - SysFreeString(url); + printf("%S", static_cast(url)); COMPtr itemPrivate; if (FAILED(item->QueryInterface(&itemPrivate))) return; - BSTR target; - if (FAILED(itemPrivate->target(&target))) + _bstr_t target; + if (FAILED(itemPrivate->target(&target.GetBSTR()))) return; - if (SysStringLen(target)) - printf(" (in frame \"%S\")", target); - SysFreeString(target); + if (target.length()) + printf(" (in frame \"%S\")", static_cast(target)); BOOL isTargetItem = FALSE; if (FAILED(itemPrivate->isTargetItem(&isTargetItem))) return; @@ -698,52 +685,49 @@ void dump() if (SUCCEEDED(frame->dataSource(&dataSource))) { COMPtr response; if (SUCCEEDED(dataSource->response(&response)) && response) { - BSTR mimeType; - if (SUCCEEDED(response->MIMEType(&mimeType)) && !_tcscmp(mimeType, TEXT("text/plain"))) { + _bstr_t mimeType; + if (SUCCEEDED(response->MIMEType(&mimeType.GetBSTR())) && !_tcscmp(static_cast(mimeType), TEXT("text/plain"))) { ::gTestRunner->setDumpAsText(true); ::gTestRunner->setGeneratePixelResults(false); } - SysFreeString(mimeType); } } - BSTR resultString = 0; + _bstr_t resultString; if (dumpTree) { ::InvalidateRect(webViewWindow, 0, TRUE); ::SendMessage(webViewWindow, WM_PAINT, 0, 0); if (::gTestRunner->dumpAsText()) { - wstring result = dumpFramesAsText(frame); - resultString = SysAllocStringLen(result.data(), result.size()); + resultString = dumpFramesAsText(frame).data(); } else { COMPtr framePrivate; if (FAILED(frame->QueryInterface(&framePrivate))) goto fail; - framePrivate->renderTreeAsExternalRepresentation(gTestRunner->isPrinting(), &resultString); + framePrivate->renderTreeAsExternalRepresentation(gTestRunner->isPrinting(), &resultString.GetBSTR()); } - - if (!resultString) - printf("ERROR: nil result from %s", ::gTestRunner->dumpAsText() ? "IDOMElement::innerText" : "IFrameViewPrivate::renderTreeAsExternalRepresentation"); - else { - unsigned stringLength = SysStringLen(resultString); + + if (resultString.length()) { + unsigned stringLength = resultString.length(); int bufferSize = ::WideCharToMultiByte(CP_UTF8, 0, resultString, stringLength, 0, 0, 0, 0); char* buffer = (char*)malloc(bufferSize + 1); ::WideCharToMultiByte(CP_UTF8, 0, resultString, stringLength, buffer, bufferSize + 1, 0, 0); fwrite(buffer, 1, bufferSize, stdout); free(buffer); - if (!::gTestRunner->dumpAsText()) + + if (!::gTestRunner->dumpAsText() && !::gTestRunner->dumpDOMAsWebArchive() && !::gTestRunner->dumpSourceAsWebArchive() && !::gTestRunner->dumpAsAudio()) dumpFrameScrollPosition(frame); - } - if (::gTestRunner->dumpBackForwardList()) - dumpBackForwardListForAllWindows(); - } - if (printSeparators) { - puts("#EOF"); // terminate the content block - fputs("#EOF\n", stderr); - fflush(stdout); - fflush(stderr); + if (::gTestRunner->dumpBackForwardList()) + dumpBackForwardListForAllWindows(); + } else + printf("ERROR: nil result from %s", ::gTestRunner->dumpAsText() ? "IDOMElement::innerText" : "IFrameViewPrivate::renderTreeAsExternalRepresentation"); + + if (printSeparators) { + puts("#EOF"); // terminate the content block + fputs("#EOF\n", stderr); + } } if (dumpPixelsForCurrentTest @@ -754,6 +738,7 @@ void dump() printf("#EOF\n"); // terminate the (possibly empty) pixels block fflush(stdout); + fflush(stderr); fail: SysFreeString(resultString); @@ -785,19 +770,19 @@ static bool shouldEnableDeveloperExtras(const char* pathOrURL) static void resetDefaultsToConsistentValues(IWebPreferences* preferences) { #ifdef USE_MAC_FONTS - static BSTR standardFamily = SysAllocString(TEXT("Times")); - static BSTR fixedFamily = SysAllocString(TEXT("Courier")); - static BSTR sansSerifFamily = SysAllocString(TEXT("Helvetica")); - static BSTR cursiveFamily = SysAllocString(TEXT("Apple Chancery")); - static BSTR fantasyFamily = SysAllocString(TEXT("Papyrus")); - static BSTR pictographFamily = SysAllocString(TEXT("Apple Color Emoji")); + static _bstr_t standardFamily(TEXT("Times")); + static _bstr_t fixedFamily(TEXT("Courier")); + static _bstr_t sansSerifFamily(TEXT("Helvetica")); + static _bstr_t cursiveFamily(TEXT("Apple Chancery")); + static _bstr_t fantasyFamily(TEXT("Papyrus")); + static _bstr_t pictographFamily(TEXT("Apple Color Emoji")); #else - static BSTR standardFamily = SysAllocString(TEXT("Times New Roman")); - static BSTR fixedFamily = SysAllocString(TEXT("Courier New")); - static BSTR sansSerifFamily = SysAllocString(TEXT("Arial")); - static BSTR cursiveFamily = SysAllocString(TEXT("Comic Sans MS")); // Not actually cursive, but it's what IE and Firefox use. - static BSTR fantasyFamily = SysAllocString(TEXT("Times New Roman")); - static BSTR pictographFamily = SysAllocString(TEXT("Times New Roman")); + static _bstr_t standardFamily(TEXT("Times New Roman")); + static _bstr_t fixedFamily(TEXT("Courier New")); + static _bstr_t sansSerifFamily(TEXT("Arial")); + static _bstr_t cursiveFamily(TEXT("Comic Sans MS")); // Not actually cursive, but it's what IE and Firefox use. + static _bstr_t fantasyFamily(TEXT("Times New Roman")); + static _bstr_t pictographFamily(TEXT("Times New Roman")); #endif preferences->setStandardFontFamily(standardFamily); @@ -832,9 +817,8 @@ static void resetDefaultsToConsistentValues(IWebPreferences* preferences) if (persistentUserStyleSheetLocation) { Vector urlCharacters(CFStringGetLength(persistentUserStyleSheetLocation.get())); CFStringGetCharacters(persistentUserStyleSheetLocation.get(), CFRangeMake(0, CFStringGetLength(persistentUserStyleSheetLocation.get())), (UniChar *)urlCharacters.data()); - BSTR url = SysAllocStringLen(urlCharacters.data(), urlCharacters.size()); + _bstr_t url(urlCharacters.data()); preferences->setUserStyleSheetLocation(url); - SysFreeString(url); preferences->setUserStyleSheetEnabled(TRUE); } else preferences->setUserStyleSheetEnabled(FALSE); @@ -901,11 +885,9 @@ static void resetWebViewToConsistentStateBeforeTesting() webViewPrivate->clearMainFrameName(); webViewPrivate->resetOriginAccessWhitelists(); - BSTR groupName; - if (SUCCEEDED(webView->groupName(&groupName))) { + _bstr_t groupName; + if (SUCCEEDED(webView->groupName(&groupName.GetBSTR()))) webViewPrivate->removeAllUserContentFromGroup(groupName); - SysFreeString(groupName); - } sharedUIDelegate->resetUndoManager(); @@ -1004,14 +986,14 @@ static void removeFontFallbackIfPresent(const String& fontFallbackPath) static void runTest(const string& inputLine) { + ASSERT(!inputLine.empty()); + TestCommand command = parseInputLine(inputLine); const string& pathOrURL = command.pathOrURL; dumpPixelsForCurrentTest = command.shouldDumpPixels || dumpPixelsForAllTests; - static BSTR methodBStr = SysAllocString(TEXT("GET")); + static _bstr_t methodBStr(TEXT("GET")); - BSTR urlBStr; - CFStringRef str = CFStringCreateWithCString(0, pathOrURL.c_str(), kCFStringEncodingWindowsLatin1); CFURLRef url = CFURLCreateWithString(0, str, 0); @@ -1025,17 +1007,20 @@ static void runTest(const string& inputLine) str = CFURLGetString(url); CFIndex length = CFStringGetLength(str); - UniChar* buffer = new UniChar[length]; + UniChar* buffer = new UniChar[length + 1]; CFStringGetCharacters(str, CFRangeMake(0, length), buffer); - urlBStr = SysAllocStringLen((OLECHAR*)buffer, length); + buffer[length] = 0; + + _bstr_t urlBStr((OLECHAR*)buffer); + ASSERT(urlBStr.length() == length); delete[] buffer; CFRelease(url); ::gTestRunner = TestRunner::create(pathOrURL, command.expectedPixelHash); - done = false; topLoadingFrame = 0; + done = false; addFontFallbackIfPresent(fallbackPath); @@ -1062,12 +1047,12 @@ static void runTest(const string& inputLine) resetWebViewToConsistentStateBeforeTesting(); - if (shouldEnableDeveloperExtras(pathOrURL.c_str())) + if (shouldEnableDeveloperExtras(pathOrURL.c_str())) { gTestRunner->setDeveloperExtrasEnabled(true); - - if (shouldDumpAsText(pathOrURL.c_str())) { - gTestRunner->setDumpAsText(true); - gTestRunner->setGeneratePixelResults(false); + if (shouldDumpAsText(pathOrURL.c_str())) { + gTestRunner->setDumpAsText(true); + gTestRunner->setGeneratePixelResults(false); + } } prevTestBFItem = 0; @@ -1135,7 +1120,6 @@ static void runTest(const string& inputLine) exit: removeFontFallbackIfPresent(fallbackPath); - SysFreeString(urlBStr); ::gTestRunner.clear(); return; @@ -1173,10 +1157,8 @@ IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow) RECT clientRect; clientRect.bottom = clientRect.left = clientRect.top = clientRect.right = 0; - BSTR groupName = SysAllocString(L"org.webkit.DumpRenderTree"); - bool failed = FAILED(webView->initWithFrame(clientRect, 0, groupName)); - SysFreeString(groupName); - if (failed) + _bstr_t groupName(L"org.webkit.DumpRenderTree"); + if (FAILED(webView->initWithFrame(clientRect, 0, groupName))) return 0; COMPtr viewPrivate; @@ -1186,12 +1168,10 @@ IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow) viewPrivate->setShouldApplyMacFontAscentHack(TRUE); viewPrivate->setAlwaysUsesComplexTextCodePath(forceComplexText); - BSTR pluginPath = SysAllocStringLen(0, exePath().length() + _tcslen(TestPluginDir)); - _tcscpy(pluginPath, exePath().c_str()); - _tcscat(pluginPath, TestPluginDir); - failed = FAILED(viewPrivate->addAdditionalPluginDirectory(pluginPath)); - SysFreeString(pluginPath); - if (failed) + _bstr_t pluginPath(SysAllocStringLen(0, exePath().length() + _tcslen(TestPluginDir)), false); + _tcscpy(static_cast(pluginPath), exePath().c_str()); + _tcscat(static_cast(pluginPath), TestPluginDir); + if (FAILED(viewPrivate->addAdditionalPluginDirectory(pluginPath))) return 0; HWND viewWindow; diff --git a/Tools/DumpRenderTree/win/EditingDelegate.cpp b/Tools/DumpRenderTree/win/EditingDelegate.cpp index 99cd85d..baebcad 100644 --- a/Tools/DumpRenderTree/win/EditingDelegate.cpp +++ b/Tools/DumpRenderTree/win/EditingDelegate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,6 +29,7 @@ #include "config.h" #include "EditingDelegate.h" +#include #include "DumpRenderTree.h" #include "TestRunner.h" #include @@ -46,7 +47,7 @@ EditingDelegate::EditingDelegate() } // IUnknown -HRESULT STDMETHODCALLTYPE EditingDelegate::QueryInterface(REFIID riid, void** ppvObject) +HRESULT EditingDelegate::QueryInterface(REFIID riid, void** ppvObject) { *ppvObject = 0; if (IsEqualGUID(riid, IID_IUnknown)) @@ -60,12 +61,12 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::QueryInterface(REFIID riid, void** pp return S_OK; } -ULONG STDMETHODCALLTYPE EditingDelegate::AddRef(void) +ULONG EditingDelegate::AddRef(void) { return ++m_refCount; } -ULONG STDMETHODCALLTYPE EditingDelegate::Release(void) +ULONG EditingDelegate::Release(void) { ULONG newRef = --m_refCount; if (!newRef) @@ -80,11 +81,10 @@ static wstring dumpPath(IDOMNode* node) wstring result; - BSTR name; - if (FAILED(node->nodeName(&name))) + _bstr_t name; + if (FAILED(node->nodeName(&name.GetBSTR()))) return result; - result.assign(name, SysStringLen(name)); - SysFreeString(name); + result.assign(static_cast(name), name.length()); COMPtr parent; if (SUCCEEDED(node->parentNode(&parent))) @@ -118,10 +118,7 @@ static wstring dump(IDOMRange* range) return buffer; } -HRESULT STDMETHODCALLTYPE EditingDelegate::shouldBeginEditingInDOMRange( - /* [in] */ IWebView* webView, - /* [in] */ IDOMRange* range, - /* [retval][out] */ BOOL* result) +HRESULT EditingDelegate::shouldBeginEditingInDOMRange(IWebView* /*webView*/, IDOMRange* range, BOOL* result) { if (!result) { ASSERT_NOT_REACHED(); @@ -135,10 +132,7 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::shouldBeginEditingInDOMRange( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::shouldEndEditingInDOMRange( - /* [in] */ IWebView* webView, - /* [in] */ IDOMRange* range, - /* [retval][out] */ BOOL* result) +HRESULT EditingDelegate::shouldEndEditingInDOMRange(IWebView* /*webView*/, IDOMRange* range, BOOL* result) { if (!result) { ASSERT_NOT_REACHED(); @@ -152,11 +146,7 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::shouldEndEditingInDOMRange( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::shouldInsertNode( - /* [in] */ IWebView* webView, - /* [in] */ IDOMNode* node, - /* [in] */ IDOMRange* range, - /* [in] */ WebViewInsertAction action) +HRESULT EditingDelegate::shouldInsertNode(IWebView* /*webView*/, IDOMNode* node, IDOMRange* range, WebViewInsertAction action) { static LPCTSTR insertactionstring[] = { TEXT("WebViewInsertActionTyped"), @@ -170,12 +160,7 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::shouldInsertNode( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::shouldInsertText( - /* [in] */ IWebView* webView, - /* [in] */ BSTR text, - /* [in] */ IDOMRange* range, - /* [in] */ WebViewInsertAction action, - /* [retval][out] */ BOOL* result) +HRESULT EditingDelegate::shouldInsertText(IWebView* /*webView*/, BSTR text, IDOMRange* range, WebViewInsertAction action, BOOL* result) { if (!result) { ASSERT_NOT_REACHED(); @@ -195,10 +180,7 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::shouldInsertText( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::shouldDeleteDOMRange( - /* [in] */ IWebView* webView, - /* [in] */ IDOMRange* range, - /* [retval][out] */ BOOL* result) +HRESULT EditingDelegate::shouldDeleteDOMRange(IWebView* /*webView*/, IDOMRange* range, BOOL* result) { if (!result) { ASSERT_NOT_REACHED(); @@ -212,13 +194,8 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::shouldDeleteDOMRange( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::shouldChangeSelectedDOMRange( - /* [in] */ IWebView* webView, - /* [in] */ IDOMRange* currentRange, - /* [in] */ IDOMRange* proposedRange, - /* [in] */ WebSelectionAffinity selectionAffinity, - /* [in] */ BOOL stillSelecting, - /* [retval][out] */ BOOL* result) +HRESULT EditingDelegate::shouldChangeSelectedDOMRange(IWebView* /*webView*/, IDOMRange* currentRange, IDOMRange* proposedRange, + WebSelectionAffinity selectionAffinity, BOOL stillSelecting, BOOL* result) { if (!result) { ASSERT_NOT_REACHED(); @@ -241,11 +218,7 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::shouldChangeSelectedDOMRange( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::shouldApplyStyle( - /* [in] */ IWebView* webView, - /* [in] */ IDOMCSSStyleDeclaration* style, - /* [in] */ IDOMRange* range, - /* [retval][out] */ BOOL* result) +HRESULT EditingDelegate::shouldApplyStyle(IWebView* /*webView*/, IDOMCSSStyleDeclaration* style, IDOMRange* range, BOOL* result) { if (!result) { ASSERT_NOT_REACHED(); @@ -259,11 +232,7 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::shouldApplyStyle( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::shouldChangeTypingStyle( - /* [in] */ IWebView* webView, - /* [in] */ IDOMCSSStyleDeclaration* currentStyle, - /* [in] */ IDOMCSSStyleDeclaration* proposedStyle, - /* [retval][out] */ BOOL* result) +HRESULT EditingDelegate::shouldChangeTypingStyle(IWebView* /*webView*/, IDOMCSSStyleDeclaration* currentStyle, IDOMCSSStyleDeclaration* proposedStyle, BOOL* result) { if (!result) { ASSERT_NOT_REACHED(); @@ -277,10 +246,7 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::shouldChangeTypingStyle( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::doPlatformCommand( - /* [in] */ IWebView *webView, - /* [in] */ BSTR command, - /* [retval][out] */ BOOL *result) +HRESULT EditingDelegate::doPlatformCommand(IWebView* /*webView*/, BSTR command, BOOL* result) { if (!result) { ASSERT_NOT_REACHED(); @@ -294,62 +260,52 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::doPlatformCommand( return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::webViewDidBeginEditing( - /* [in] */ IWebNotification* notification) +HRESULT EditingDelegate::webViewDidBeginEditing(IWebNotification* notification) { if (::gTestRunner->dumpEditingCallbacks() && !done) { - BSTR name; - notification->name(&name); - _tprintf(TEXT("EDITING DELEGATE: webViewDidBeginEditing:%s\n"), name ? name : TEXT("")); - SysFreeString(name); + _bstr_t name; + notification->name(&name.GetBSTR()); + _tprintf(TEXT("EDITING DELEGATE: webViewDidBeginEditing:%s\n"), static_cast(name)); } return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::webViewDidChange( - /* [in] */ IWebNotification *notification) +HRESULT EditingDelegate::webViewDidChange(IWebNotification* notification) { if (::gTestRunner->dumpEditingCallbacks() && !done) { - BSTR name; - notification->name(&name); - _tprintf(TEXT("EDITING DELEGATE: webViewDidBeginEditing:%s\n"), name ? name : TEXT("")); - SysFreeString(name); + _bstr_t name; + notification->name(&name.GetBSTR()); + _tprintf(TEXT("EDITING DELEGATE: webViewDidBeginEditing:%s\n"), static_cast(name)); } return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::webViewDidEndEditing( - /* [in] */ IWebNotification *notification) +HRESULT EditingDelegate::webViewDidEndEditing(IWebNotification* notification) { if (::gTestRunner->dumpEditingCallbacks() && !done) { - BSTR name; - notification->name(&name); - _tprintf(TEXT("EDITING DELEGATE: webViewDidEndEditing:%s\n"), name ? name : TEXT("")); - SysFreeString(name); + _bstr_t name; + notification->name(&name.GetBSTR()); + _tprintf(TEXT("EDITING DELEGATE: webViewDidEndEditing:%s\n"), static_cast(name)); } return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::webViewDidChangeTypingStyle( - /* [in] */ IWebNotification *notification) +HRESULT EditingDelegate::webViewDidChangeTypingStyle(IWebNotification* notification) { if (::gTestRunner->dumpEditingCallbacks() && !done) { - BSTR name; - notification->name(&name); - _tprintf(TEXT("EDITING DELEGATE: webViewDidChangeTypingStyle:%s\n"), name ? name : TEXT("")); - SysFreeString(name); + _bstr_t name; + notification->name(&name.GetBSTR()); + _tprintf(TEXT("EDITING DELEGATE: webViewDidChangeTypingStyle:%s\n"), static_cast(name)); } return S_OK; } -HRESULT STDMETHODCALLTYPE EditingDelegate::webViewDidChangeSelection( - /* [in] */ IWebNotification *notification) +HRESULT EditingDelegate::webViewDidChangeSelection(IWebNotification* notification) { if (::gTestRunner->dumpEditingCallbacks() && !done) { - BSTR name; - notification->name(&name); - _tprintf(TEXT("EDITING DELEGATE: webViewDidChangeSelection:%s\n"), name ? name : TEXT("")); - SysFreeString(name); + _bstr_t name; + notification->name(&name.GetBSTR()); + _tprintf(TEXT("EDITING DELEGATE: webViewDidChangeSelection:%s\n"), static_cast(name)); } return S_OK; } @@ -370,7 +326,7 @@ static int wordLength(const TCHAR* text) return cursor - text; }; -HRESULT STDMETHODCALLTYPE EditingDelegate::checkSpellingOfString( +HRESULT EditingDelegate::checkSpellingOfString( /* [in] */ IWebView* view, /* [in] */ LPCTSTR text, /* [in] */ int length, diff --git a/Tools/DumpRenderTree/win/FrameLoadDelegate.cpp b/Tools/DumpRenderTree/win/FrameLoadDelegate.cpp index 72ccc26..036d8eb 100644 --- a/Tools/DumpRenderTree/win/FrameLoadDelegate.cpp +++ b/Tools/DumpRenderTree/win/FrameLoadDelegate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2006, 2007, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2006, 2007, 2009, 2014 Apple Inc. All rights reserved. * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,7 @@ #include "FrameLoadDelegate.h" #include "AccessibilityController.h" +#include #include "DumpRenderTree.h" #include "EventSender.h" #include "GCController.h" @@ -45,7 +46,7 @@ #include #include #include -#include +#include #include using std::string; @@ -62,22 +63,21 @@ string descriptionSuitableForTestResult(IWebFrame* webFrame) if (FAILED(webView->mainFrame(&mainFrame))) return string(); - BSTR frameNameBSTR; - if (FAILED(webFrame->name(&frameNameBSTR)) || toUTF8(frameNameBSTR).empty()) + _bstr_t frameNameBSTR; + if (FAILED(webFrame->name(&frameNameBSTR.GetBSTR())) || !frameNameBSTR.length()) return (webFrame == mainFrame) ? "main frame" : string(); string frameName = (webFrame == mainFrame) ? "main frame" : "frame"; frameName += " \"" + toUTF8(frameNameBSTR) + "\""; - SysFreeString(frameNameBSTR); return frameName; } FrameLoadDelegate::FrameLoadDelegate() : m_refCount(1) - , m_gcController(adoptPtr(new GCController)) - , m_accessibilityController(adoptPtr(new AccessibilityController)) - , m_textInputController(adoptPtr(new TextInputController)) + , m_gcController(std::make_unique()) + , m_accessibilityController(std::make_unique()) + , m_textInputController(std::make_unique()) { } @@ -85,7 +85,7 @@ FrameLoadDelegate::~FrameLoadDelegate() { } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::QueryInterface(REFIID riid, void** ppvObject) +HRESULT FrameLoadDelegate::QueryInterface(REFIID riid, void** ppvObject) { *ppvObject = 0; if (IsEqualGUID(riid, IID_IUnknown)) @@ -103,12 +103,12 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::QueryInterface(REFIID riid, void** return S_OK; } -ULONG STDMETHODCALLTYPE FrameLoadDelegate::AddRef(void) +ULONG FrameLoadDelegate::AddRef(void) { return ++m_refCount; } -ULONG STDMETHODCALLTYPE FrameLoadDelegate::Release(void) +ULONG FrameLoadDelegate::Release(void) { ULONG newRef = --m_refCount; if (!newRef) @@ -118,9 +118,7 @@ ULONG STDMETHODCALLTYPE FrameLoadDelegate::Release(void) } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didStartProvisionalLoadForFrame( - /* [in] */ IWebView* webView, - /* [in] */ IWebFrame* frame) +HRESULT FrameLoadDelegate::didStartProvisionalLoadForFrame(IWebView* /*webView*/, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didStartProvisionalLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str()); @@ -133,9 +131,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didStartProvisionalLoadForFrame( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didReceiveServerRedirectForProvisionalLoadForFrame( - /* [in] */ IWebView *webView, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::didReceiveServerRedirectForProvisionalLoadForFrame(IWebView* /*webView*/, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didReceiveServerRedirectForProvisionalLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str()); @@ -143,10 +139,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didReceiveServerRedirectForProvisio return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFailProvisionalLoadWithError( - /* [in] */ IWebView *webView, - /* [in] */ IWebError *error, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::didFailProvisionalLoadWithError(IWebView* /*webView*/, IWebError* error, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didFailProvisionalLoadWithError\n", descriptionSuitableForTestResult(frame).c_str()); @@ -155,9 +148,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFailProvisionalLoadWithError( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didCommitLoadForFrame( - /* [in] */ IWebView *webView, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::didCommitLoadForFrame(IWebView* webView, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didCommitLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str()); @@ -171,10 +162,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didCommitLoadForFrame( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didReceiveTitle( - /* [in] */ IWebView *webView, - /* [in] */ BSTR title, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::didReceiveTitle(IWebView* /*webView*/, BSTR title, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didReceiveTitle: %S\n", descriptionSuitableForTestResult(frame).c_str(), title); @@ -184,7 +172,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didReceiveTitle( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didChangeIcons( +HRESULT FrameLoadDelegate::didChangeIcons( /* [in] */ IWebView* webView, /* [in] */ IWebFrame* frame) { @@ -213,7 +201,7 @@ void FrameLoadDelegate::resetToConsistentState() typedef Vector > DelegateVector; static DelegateVector& delegatesWithDelayedWork() { - DEPRECATED_DEFINE_STATIC_LOCAL(DelegateVector, delegates, ()); + static NeverDestroyed delegates; return delegates; } @@ -253,9 +241,7 @@ void FrameLoadDelegate::locationChangeDone(IWebError*, IWebFrame* frame) dump(); } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFinishLoadForFrame( - /* [in] */ IWebView* webView, - /* [in] */ IWebFrame* frame) +HRESULT FrameLoadDelegate::didFinishLoadForFrame(IWebView* /*webView*/, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didFinishLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str()); @@ -264,10 +250,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFinishLoadForFrame( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFailLoadWithError( - /* [in] */ IWebView* webView, - /* [in] */ IWebError* error, - /* [in] */ IWebFrame* frame) +HRESULT FrameLoadDelegate::didFailLoadWithError(IWebView* /*webView*/, IWebError* error, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didFailLoadWithError\n", descriptionSuitableForTestResult(frame).c_str()); @@ -276,12 +259,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFailLoadWithError( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::willPerformClientRedirectToURL( - /* [in] */ IWebView *webView, - /* [in] */ BSTR url, - /* [in] */ double delaySeconds, - /* [in] */ DATE fireDate, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::willPerformClientRedirectToURL(IWebView* /*webView*/, BSTR url, double /*delaySeconds*/, DATE /*fireDate*/, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - willPerformClientRedirectToURL: %S \n", descriptionSuitableForTestResult(frame).c_str(), @@ -290,9 +268,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::willPerformClientRedirectToURL( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didCancelClientRedirectForFrame( - /* [in] */ IWebView *webView, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::didCancelClientRedirectForFrame(IWebView* /*webView*/, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didCancelClientRedirectForFrame\n", descriptionSuitableForTestResult(frame).c_str()); @@ -301,9 +277,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didCancelClientRedirectForFrame( } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::willCloseFrame( - /* [in] */ IWebView *webView, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::willCloseFrame(IWebView* /*webView*/, IWebFrame* /*frame*/) { return E_NOTIMPL; } @@ -380,9 +354,7 @@ void FrameLoadDelegate::didClearWindowObjectForFrameInStandardWorld(IWebFrame* f WebCoreTestSupport::injectInternalsObject(context); } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFinishDocumentLoadForFrame( - /* [in] */ IWebView *sender, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::didFinishDocumentLoadForFrame(IWebView* /*sender*/, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didFinishDocumentLoadForFrame\n", @@ -404,9 +376,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFinishDocumentLoadForFrame( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didHandleOnloadEventsForFrame( - /* [in] */ IWebView *sender, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::didHandleOnloadEventsForFrame(IWebView* /*sender*/, IWebFrame* frame) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("%s - didHandleOnloadEventsForFrame\n", @@ -415,15 +385,12 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didHandleOnloadEventsForFrame( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFirstVisuallyNonEmptyLayoutInFrame( - /* [in] */ IWebView *sender, - /* [in] */ IWebFrame *frame) +HRESULT FrameLoadDelegate::didFirstVisuallyNonEmptyLayoutInFrame(IWebView* /*sender*/, IWebFrame* /*frame*/) { return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didDisplayInsecureContent( - /* [in] */ IWebView *sender) +HRESULT FrameLoadDelegate::didDisplayInsecureContent(IWebView* /*sender*/) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("didDisplayInsecureContent\n"); @@ -431,13 +398,10 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didDisplayInsecureContent( return S_OK; } -HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didRunInsecureContent( - /* [in] */ IWebView *sender, - /* [in] */ IWebSecurityOrigin *origin) +HRESULT FrameLoadDelegate::didRunInsecureContent(IWebView* /*sender*/, IWebSecurityOrigin* /*origin*/) { if (!done && gTestRunner->dumpFrameLoadCallbacks()) printf("didRunInsecureContent\n"); return S_OK; } - diff --git a/Tools/DumpRenderTree/win/FrameLoadDelegate.h b/Tools/DumpRenderTree/win/FrameLoadDelegate.h index e63fb20..028d36b 100644 --- a/Tools/DumpRenderTree/win/FrameLoadDelegate.h +++ b/Tools/DumpRenderTree/win/FrameLoadDelegate.h @@ -30,7 +30,6 @@ #define FrameLoadDelegate_h #include -#include class AccessibilityController; class TextInputController; @@ -169,9 +168,9 @@ private: void locationChangeDone(IWebError*, IWebFrame*); ULONG m_refCount; - OwnPtr m_gcController; - OwnPtr m_accessibilityController; - OwnPtr m_textInputController; + std::unique_ptr m_gcController; + std::unique_ptr m_accessibilityController; + std::unique_ptr m_textInputController; }; #endif // FrameLoadDelegate_h diff --git a/Tools/DumpRenderTree/win/HistoryDelegate.cpp b/Tools/DumpRenderTree/win/HistoryDelegate.cpp index e33b248..33d040b9 100644 --- a/Tools/DumpRenderTree/win/HistoryDelegate.cpp +++ b/Tools/DumpRenderTree/win/HistoryDelegate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,6 +29,7 @@ #include "DumpRenderTree.h" #include "DumpRenderTreeWin.h" #include "TestRunner.h" +#include #include #include @@ -83,33 +84,24 @@ HRESULT HistoryDelegate::didNavigateWithNavigationData(IWebView* webView, IWebNa if (!gTestRunner->dumpHistoryDelegateCallbacks()) return S_OK; - BSTR urlBSTR; - if (FAILED(navigationData->url(&urlBSTR))) + _bstr_t urlBSTR; + if (FAILED(navigationData->url(&urlBSTR.GetBSTR()))) return E_FAIL; wstring url; - if (urlBSTR) + if (urlBSTR.length()) url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR)); - SysFreeString(urlBSTR); - BSTR titleBSTR; - if (FAILED(navigationData->title(&titleBSTR))) + _bstr_t titleBSTR; + if (FAILED(navigationData->title(&titleBSTR.GetBSTR()))) return E_FAIL; - wstring title; - if (titleBSTR) - title = wstringFromBSTR(titleBSTR); - SysFreeString(titleBSTR); COMPtr request; if (FAILED(navigationData->originalRequest(&request))) return E_FAIL; - BSTR httpMethodBSTR; - if (FAILED(request->HTTPMethod(&httpMethodBSTR))) + _bstr_t httpMethodBSTR; + if (FAILED(request->HTTPMethod(&httpMethodBSTR.GetBSTR()))) return E_FAIL; - wstring httpMethod; - if (httpMethodBSTR) - httpMethod = wstringFromBSTR(httpMethodBSTR); - SysFreeString(httpMethodBSTR); COMPtr response; if (FAILED(navigationData->response(&response))) @@ -127,21 +119,20 @@ HRESULT HistoryDelegate::didNavigateWithNavigationData(IWebView* webView, IWebNa if (FAILED(navigationData->hasSubstituteData(&hasSubstituteData))) return E_FAIL; - BSTR clientRedirectSourceBSTR; - if (FAILED(navigationData->clientRedirectSource(&clientRedirectSourceBSTR))) + _bstr_t clientRedirectSourceBSTR; + if (FAILED(navigationData->clientRedirectSource(&clientRedirectSourceBSTR.GetBSTR()))) return E_FAIL; - bool hasClientRedirect = clientRedirectSourceBSTR && SysStringLen(clientRedirectSourceBSTR); + bool hasClientRedirect = clientRedirectSourceBSTR.length(); wstring redirectSource; - if (clientRedirectSourceBSTR) + if (clientRedirectSourceBSTR.length()) redirectSource = urlSuitableForTestResult(wstringFromBSTR(clientRedirectSourceBSTR)); - SysFreeString(clientRedirectSourceBSTR); bool wasFailure = hasSubstituteData || (httpResponse && statusCode >= 400); printf("WebView navigated to url \"%S\" with title \"%S\" with HTTP equivalent method \"%S\". The navigation was %s and was %s%S.\n", url.c_str(), - title.c_str(), - httpMethod.c_str(), + static_cast(titleBSTR), + static_cast(httpMethodBSTR), wasFailure ? "a failure" : "successful", hasClientRedirect ? "a client redirect from " : "not a client redirect", redirectSource.c_str()); @@ -192,11 +183,7 @@ HRESULT HistoryDelegate::updateHistoryTitle(IWebView* webView, BSTR titleBSTR, B if (urlBSTR) url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR)); - wstring title; - if (titleBSTR) - title = wstringFromBSTR(titleBSTR); - - printf("WebView updated the title for history URL \"%S\" to \"%S\".\n", url.c_str(), title.c_str()); + printf("WebView updated the title for history URL \"%S\" to \"%S\".\n", url.c_str(), titleBSTR ? titleBSTR : L""); return S_OK; } @@ -205,14 +192,13 @@ HRESULT HistoryDelegate::populateVisitedLinksForWebView(IWebView* webView) if (!gTestRunner->dumpHistoryDelegateCallbacks()) return S_OK; - BSTR urlBSTR; - if (FAILED(webView->mainFrameURL(&urlBSTR))) + _bstr_t urlBSTR; + if (FAILED(webView->mainFrameURL(&urlBSTR.GetBSTR()))) return E_FAIL; wstring url; - if (urlBSTR) + if (urlBSTR.length()) url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR)); - SysFreeString(urlBSTR); if (gTestRunner->dumpVisitedLinksCallback()) printf("Asked to populate visited links for WebView \"%S\"\n", url.c_str()); diff --git a/Tools/DumpRenderTree/win/PolicyDelegate.cpp b/Tools/DumpRenderTree/win/PolicyDelegate.cpp index 6edbd47..35f440c 100644 --- a/Tools/DumpRenderTree/win/PolicyDelegate.cpp +++ b/Tools/DumpRenderTree/win/PolicyDelegate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,6 +31,7 @@ #include "DumpRenderTree.h" #include "TestRunner.h" +#include #include using std::wstring; @@ -41,11 +42,10 @@ static wstring dumpPath(IDOMNode* node) wstring result; - BSTR name; - if (FAILED(node->nodeName(&name))) + _bstr_t name; + if (FAILED(node->nodeName(&name.GetBSTR()))) return result; - result.assign(name, SysStringLen(name)); - SysFreeString(name); + result.assign(name, name.length()); COMPtr parent; if (SUCCEEDED(node->parentNode(&parent))) @@ -62,7 +62,7 @@ PolicyDelegate::PolicyDelegate() } // IUnknown -HRESULT STDMETHODCALLTYPE PolicyDelegate::QueryInterface(REFIID riid, void** ppvObject) +HRESULT PolicyDelegate::QueryInterface(REFIID riid, void** ppvObject) { *ppvObject = 0; if (IsEqualGUID(riid, IID_IUnknown)) @@ -76,12 +76,12 @@ HRESULT STDMETHODCALLTYPE PolicyDelegate::QueryInterface(REFIID riid, void** ppv return S_OK; } -ULONG STDMETHODCALLTYPE PolicyDelegate::AddRef(void) +ULONG PolicyDelegate::AddRef(void) { return ++m_refCount; } -ULONG STDMETHODCALLTYPE PolicyDelegate::Release(void) +ULONG PolicyDelegate::Release(void) { ULONG newRef = --m_refCount; if (!newRef) @@ -90,16 +90,16 @@ ULONG STDMETHODCALLTYPE PolicyDelegate::Release(void) return newRef; } -HRESULT STDMETHODCALLTYPE PolicyDelegate::decidePolicyForNavigationAction( +HRESULT PolicyDelegate::decidePolicyForNavigationAction( /*[in]*/ IWebView* /*webView*/, /*[in]*/ IPropertyBag* actionInformation, /*[in]*/ IWebURLRequest* request, /*[in]*/ IWebFrame* frame, /*[in]*/ IWebPolicyDecisionListener* listener) { - BSTR url; - request->URL(&url); - wstring wurl = urlSuitableForTestResult(wstring(url, SysStringLen(url))); + _bstr_t url; + request->URL(&url.GetBSTR()); + wstring wurl = urlSuitableForTestResult(wstring(url, url.length())); int navType = 0; VARIANT var; @@ -146,8 +146,6 @@ HRESULT STDMETHODCALLTYPE PolicyDelegate::decidePolicyForNavigationAction( printf("%S\n", message.c_str()); - SysFreeString(url); - if (m_permissiveDelegate) listener->use(); else @@ -162,26 +160,21 @@ HRESULT STDMETHODCALLTYPE PolicyDelegate::decidePolicyForNavigationAction( } -HRESULT STDMETHODCALLTYPE PolicyDelegate::unableToImplementPolicyWithError( +HRESULT PolicyDelegate::unableToImplementPolicyWithError( /*[in]*/ IWebView* /*webView*/, /*[in]*/ IWebError* error, /*[in]*/ IWebFrame* frame) { - BSTR domainStr; - error->domain(&domainStr); - wstring domainMessage = domainStr; + _bstr_t domainStr; + error->domain(&domainStr.GetBSTR()); int code; error->code(&code); - BSTR frameName; - frame->name(&frameName); - wstring frameNameMessage = frameName; - - printf("Policy delegate: unable to implement policy with error domain '%S', error code %d, in frame '%S'", domainMessage.c_str(), code, frameNameMessage.c_str()); + _bstr_t frameName; + frame->name(&frameName.GetBSTR()); - SysFreeString(domainStr); - SysFreeString(frameName); + printf("Policy delegate: unable to implement policy with error domain '%S', error code %d, in frame '%S'", static_cast(domainStr), code, static_cast(frameName)); return S_OK; } diff --git a/Tools/DumpRenderTree/win/ResourceLoadDelegate.cpp b/Tools/DumpRenderTree/win/ResourceLoadDelegate.cpp index 2acfbbb..d647905 100644 --- a/Tools/DumpRenderTree/win/ResourceLoadDelegate.cpp +++ b/Tools/DumpRenderTree/win/ResourceLoadDelegate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -74,28 +74,23 @@ wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLRequest* r if (!request) return L"(null)"; - BSTR urlBSTR; - if (FAILED(request->URL(&urlBSTR))) + _bstr_t urlBSTR; + if (FAILED(request->URL(&urlBSTR.GetBSTR()))) return wstring(); wstring url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR)); - ::SysFreeString(urlBSTR); - BSTR mainDocumentURLBSTR; - if (FAILED(request->mainDocumentURL(&mainDocumentURLBSTR))) + _bstr_t mainDocumentURLBSTR; + if (FAILED(request->mainDocumentURL(&mainDocumentURLBSTR.GetBSTR()))) return wstring(); wstring mainDocumentURL = urlSuitableForTestResult(wstringFromBSTR(mainDocumentURLBSTR)); - ::SysFreeString(mainDocumentURLBSTR); - BSTR httpMethodBSTR; - if (FAILED(request->HTTPMethod(&httpMethodBSTR))) + _bstr_t httpMethodBSTR; + if (FAILED(request->HTTPMethod(&httpMethodBSTR.GetBSTR()))) return wstring(); - wstring httpMethod = wstringFromBSTR(httpMethodBSTR); - ::SysFreeString(httpMethodBSTR); - - return L""; + return L"(httpMethodBSTR) + L">"; } wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLResponse* response) @@ -103,12 +98,11 @@ wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLResponse* if (!response) return L"(null)"; - BSTR urlBSTR; - if (FAILED(response->URL(&urlBSTR))) + _bstr_t urlBSTR; + if (FAILED(response->URL(&urlBSTR.GetBSTR()))) return wstring(); wstring url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR)); - ::SysFreeString(urlBSTR); int statusCode = 0; COMPtr httpResponse; @@ -122,12 +116,11 @@ wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebError* error, { wstring result = L"domain(&domainSTR))) + _bstr_t domainSTR; + if (FAILED(error->domain(&domainSTR.GetBSTR()))) return wstring(); wstring domain = wstringFromBSTR(domainSTR); - ::SysFreeString(domainSTR); int code; if (FAILED(error->code(&code))) @@ -150,14 +143,12 @@ wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebError* error, result += L"domain " + domain; result += L", code " + wstringFromInt(code); - BSTR failingURLSTR; - if (FAILED(error->failingURL(&failingURLSTR))) + _bstr_t failingURLSTR; + if (FAILED(error->failingURL(&failingURLSTR.GetBSTR()))) return wstring(); - if (failingURLSTR) { + if (failingURLSTR.length()) result += L", failing URL \"" + urlSuitableForTestResult(wstringFromBSTR(failingURLSTR)) + L"\""; - ::SysFreeString(failingURLSTR); - } result += L">"; @@ -173,7 +164,7 @@ ResourceLoadDelegate::~ResourceLoadDelegate() { } -HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::QueryInterface(REFIID riid, void** ppvObject) +HRESULT ResourceLoadDelegate::QueryInterface(REFIID riid, void** ppvObject) { *ppvObject = 0; if (IsEqualGUID(riid, IID_IUnknown)) @@ -189,12 +180,12 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::QueryInterface(REFIID riid, void return S_OK; } -ULONG STDMETHODCALLTYPE ResourceLoadDelegate::AddRef(void) +ULONG ResourceLoadDelegate::AddRef(void) { return ++m_refCount; } -ULONG STDMETHODCALLTYPE ResourceLoadDelegate::Release(void) +ULONG ResourceLoadDelegate::Release(void) { ULONG newRef = --m_refCount; if (!newRef) @@ -203,15 +194,11 @@ ULONG STDMETHODCALLTYPE ResourceLoadDelegate::Release(void) return newRef; } -HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::identifierForInitialRequest( - /* [in] */ IWebView* webView, - /* [in] */ IWebURLRequest* request, - /* [in] */ IWebDataSource* dataSource, - /* [in] */ unsigned long identifier) +HRESULT ResourceLoadDelegate::identifierForInitialRequest(IWebView* webView, IWebURLRequest* request, IWebDataSource* dataSource, unsigned long identifier) { if (!done && gTestRunner->dumpResourceLoadCallbacks()) { - BSTR urlStr; - if (FAILED(request->URL(&urlStr))) + _bstr_t urlStr; + if (FAILED(request->URL(&urlStr.GetBSTR()))) return E_FAIL; ASSERT(!urlMap().contains(identifier)); @@ -221,7 +208,7 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::identifierForInitialRequest( return S_OK; } -HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::removeIdentifierForRequest( +HRESULT ResourceLoadDelegate::removeIdentifierForRequest( /* [in] */ IWebView* webView, /* [in] */ unsigned long identifier) { @@ -230,13 +217,8 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::removeIdentifierForRequest( return S_OK; } -HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::willSendRequest( - /* [in] */ IWebView* webView, - /* [in] */ unsigned long identifier, - /* [in] */ IWebURLRequest* request, - /* [in] */ IWebURLResponse* redirectResponse, - /* [in] */ IWebDataSource* dataSource, - /* [retval][out] */ IWebURLRequest **newRequest) +HRESULT ResourceLoadDelegate::willSendRequest(IWebView* webView, unsigned long identifier, IWebURLRequest* request, + IWebURLResponse* redirectResponse, IWebDataSource* dataSource, IWebURLRequest** newRequest) { if (!done && gTestRunner->dumpResourceLoadCallbacks()) { printf("%S - willSendRequest %S redirectResponse %S\n", @@ -267,20 +249,15 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::willSendRequest( request->mutableCopy(&requestCopy); const set& clearHeaders = gTestRunner->willSendRequestClearHeaders(); for (set::const_iterator header = clearHeaders.begin(); header != clearHeaders.end(); ++header) { - BSTR bstrHeader = BSTRFromString(*header); - requestCopy->setValue(0, bstrHeader); - SysFreeString(bstrHeader); + _bstr_t bstrHeader(header->data()); + requestCopy->setValue(0, bstrHeader); } *newRequest = requestCopy; return S_OK; } -HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didReceiveAuthenticationChallenge( - /* [in] */ IWebView *webView, - /* [in] */ unsigned long identifier, - /* [in] */ IWebURLAuthenticationChallenge *challenge, - /* [in] */ IWebDataSource *dataSource) +HRESULT ResourceLoadDelegate::didReceiveAuthenticationChallenge(IWebView* webView, unsigned long identifier, IWebURLAuthenticationChallenge* challenge, IWebDataSource* dataSource) { COMPtr sender; if (!challenge || FAILED(challenge->sender(&sender))) @@ -306,7 +283,7 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didReceiveAuthenticationChalleng return S_OK; } -HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didReceiveResponse( +HRESULT ResourceLoadDelegate::didReceiveResponse( /* [in] */ IWebView* webView, /* [in] */ unsigned long identifier, /* [in] */ IWebURLResponse* response, @@ -318,31 +295,24 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didReceiveResponse( descriptionSuitableForTestResult(response).c_str()); } if (!done && gTestRunner->dumpResourceResponseMIMETypes()) { - BSTR mimeTypeBSTR; - if (FAILED(response->MIMEType(&mimeTypeBSTR))) + _bstr_t mimeTypeBSTR; + if (FAILED(response->MIMEType(&mimeTypeBSTR.GetBSTR()))) E_FAIL; - wstring mimeType = wstringFromBSTR(mimeTypeBSTR); - ::SysFreeString(mimeTypeBSTR); - - BSTR urlBSTR; - if (FAILED(response->URL(&urlBSTR))) + _bstr_t urlBSTR; + if (FAILED(response->URL(&urlBSTR.GetBSTR()))) E_FAIL; wstring url = wstringFromBSTR(urlBSTR); - ::SysFreeString(urlBSTR); - printf("%S has MIME type %S\n", lastPathComponent(url).c_str(), mimeType.c_str()); + printf("%S has MIME type %S\n", lastPathComponent(url).c_str(), static_cast(mimeTypeBSTR)); } return S_OK; } -HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFinishLoadingFromDataSource( - /* [in] */ IWebView* webView, - /* [in] */ unsigned long identifier, - /* [in] */ IWebDataSource* dataSource) +HRESULT ResourceLoadDelegate::didFinishLoadingFromDataSource(IWebView* webView, unsigned long identifier, IWebDataSource* dataSource) { if (!done && gTestRunner->dumpResourceLoadCallbacks()) { printf("%S - didFinishLoading\n", @@ -354,11 +324,7 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFinishLoadingFromDataSource( return S_OK; } -HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFailLoadingWithError( - /* [in] */ IWebView* webView, - /* [in] */ unsigned long identifier, - /* [in] */ IWebError* error, - /* [in] */ IWebDataSource* dataSource) +HRESULT ResourceLoadDelegate::didFailLoadingWithError(IWebView* webView, unsigned long identifier, IWebError* error, IWebDataSource* dataSource) { if (!done && gTestRunner->dumpResourceLoadCallbacks()) { printf("%S - didFailLoadingWithError: %S\n", diff --git a/Tools/DumpRenderTree/win/TestRunnerWin.cpp b/Tools/DumpRenderTree/win/TestRunnerWin.cpp index 64a107e..39eae47 100644 --- a/Tools/DumpRenderTree/win/TestRunnerWin.cpp +++ b/Tools/DumpRenderTree/win/TestRunnerWin.cpp @@ -233,11 +233,10 @@ void TestRunner::queueLoad(JSStringRef url, JSStringRef target) if (FAILED(dataSource->response(&response)) || !response) return; - BSTR responseURLBSTR; - if (FAILED(response->URL(&responseURLBSTR))) + _bstr_t responseURLBSTR; + if (FAILED(response->URL(&responseURLBSTR.GetBSTR()))) return; - wstring responseURL(responseURLBSTR, SysStringLen(responseURLBSTR)); - SysFreeString(responseURLBSTR); + wstring responseURL(responseURLBSTR, responseURLBSTR.length()); // FIXME: We should do real relative URL resolution here. int lastSlash = responseURL.rfind('/'); @@ -656,9 +655,8 @@ void TestRunner::setUserStyleSheetLocation(JSStringRef jsURL) resultPath = cfStringRefToWString(CFURLGetString(url.get())); - BSTR resultPathBSTR = SysAllocStringLen(resultPath.data(), resultPath.size()); + _bstr_t resultPathBSTR(resultPath.data()); preferences->setUserStyleSheetLocation(resultPathBSTR); - SysFreeString(resultPathBSTR); } void TestRunner::setValueForUser(JSContextRef context, JSValueRef element, JSStringRef value) @@ -738,9 +736,6 @@ int TestRunner::windowCount() void TestRunner::execCommand(JSStringRef name, JSStringRef value) { - wstring wName = jsStringRefToWString(name); - wstring wValue = jsStringRefToWString(value); - COMPtr webView; if (FAILED(frame->webView(&webView))) return; @@ -749,12 +744,9 @@ void TestRunner::execCommand(JSStringRef name, JSStringRef value) if (FAILED(webView->QueryInterface(&viewPrivate))) return; - BSTR nameBSTR = SysAllocStringLen((OLECHAR*)wName.c_str(), wName.length()); - BSTR valueBSTR = SysAllocStringLen((OLECHAR*)wValue.c_str(), wValue.length()); + _bstr_t nameBSTR(JSStringCopyBSTR(name), false); + _bstr_t valueBSTR(JSStringCopyBSTR(value), false); viewPrivate->executeCoreCommandByName(nameBSTR, valueBSTR); - - SysFreeString(nameBSTR); - SysFreeString(valueBSTR); } bool TestRunner::findString(JSContextRef /* context */, JSStringRef /* target */, JSObjectRef /* optionsArray */) @@ -822,11 +814,9 @@ void TestRunner::overridePreference(JSStringRef key, JSStringRef value) if (!prefsPrivate) return; - BSTR keyBSTR = JSStringCopyBSTR(key); - BSTR valueBSTR = JSStringCopyBSTR(value); + _bstr_t keyBSTR(JSStringCopyBSTR(key), false); + _bstr_t valueBSTR(JSStringCopyBSTR(value), false); prefsPrivate->setPreferenceForTest(keyBSTR, valueBSTR); - SysFreeString(keyBSTR); - SysFreeString(valueBSTR); } void TestRunner::setDatabaseQuota(unsigned long long quota) @@ -1036,10 +1026,9 @@ void TestRunner::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef glo world = worldSlot; } - BSTR result; - if (FAILED(framePrivate->stringByEvaluatingJavaScriptInScriptWorld(world.get(), globalObject, bstrT(script).GetBSTR(), &result))) + _bstr_t result; + if (FAILED(framePrivate->stringByEvaluatingJavaScriptInScriptWorld(world.get(), globalObject, bstrT(script).GetBSTR(), &result.GetBSTR()))) return; - SysFreeString(result); } void TestRunner::removeAllVisitedLinks() diff --git a/Tools/DumpRenderTree/win/TextInputControllerWin.cpp b/Tools/DumpRenderTree/win/TextInputControllerWin.cpp index 89898a2..72da00b 100755 --- a/Tools/DumpRenderTree/win/TextInputControllerWin.cpp +++ b/Tools/DumpRenderTree/win/TextInputControllerWin.cpp @@ -30,6 +30,7 @@ #include "TextInputController.h" #include "DumpRenderTree.h" +#include #include #include #include @@ -47,7 +48,7 @@ void TextInputController::setMarkedText(JSStringRef text, unsigned int from, uns if (FAILED(webView->QueryInterface(&viewPrivate))) return; - _bstr_t bstr(wstring(JSStringGetCharactersPtr(text), JSStringGetLength(text)).data()); + _bstr_t bstr(JSStringCopyBSTR(text), false); viewPrivate->setCompositionForTesting(bstr, from, length); } @@ -115,7 +116,7 @@ void TextInputController::insertText(JSStringRef text) if (FAILED(webView->QueryInterface(&viewPrivate))) return; - _bstr_t bstr(wstring(JSStringGetCharactersPtr(text), JSStringGetLength(text)).data()); + _bstr_t bstr(JSStringCopyBSTR(text), false); viewPrivate->confirmCompositionForTesting(bstr); } diff --git a/Tools/DumpRenderTree/win/UIDelegate.cpp b/Tools/DumpRenderTree/win/UIDelegate.cpp index 30bfbfb..6840640 100644 --- a/Tools/DumpRenderTree/win/UIDelegate.cpp +++ b/Tools/DumpRenderTree/win/UIDelegate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2006, 2007, 2008, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,6 +42,7 @@ #include #include #include +#include #include using std::wstring; @@ -170,7 +171,7 @@ void UIDelegate::resetUndoManager() m_undoManager = adoptPtr(new DRTUndoManager); } -HRESULT STDMETHODCALLTYPE UIDelegate::QueryInterface(REFIID riid, void** ppvObject) +HRESULT UIDelegate::QueryInterface(REFIID riid, void** ppvObject) { *ppvObject = 0; if (IsEqualGUID(riid, IID_IUnknown)) @@ -192,12 +193,12 @@ HRESULT STDMETHODCALLTYPE UIDelegate::QueryInterface(REFIID riid, void** ppvObje return S_OK; } -ULONG STDMETHODCALLTYPE UIDelegate::AddRef() +ULONG UIDelegate::AddRef() { return ++m_refCount; } -ULONG STDMETHODCALLTYPE UIDelegate::Release() +ULONG UIDelegate::Release() { ULONG newRef = --m_refCount; if (!newRef) @@ -206,61 +207,51 @@ ULONG STDMETHODCALLTYPE UIDelegate::Release() return newRef; } -HRESULT STDMETHODCALLTYPE UIDelegate::hasCustomMenuImplementation( - /* [retval][out] */ BOOL *hasCustomMenus) +HRESULT UIDelegate::hasCustomMenuImplementation(BOOL* hasCustomMenus) { *hasCustomMenus = TRUE; return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::trackCustomPopupMenu( - /* [in] */ IWebView *sender, - /* [in] */ OLE_HANDLE menu, - /* [in] */ LPPOINT point) +HRESULT UIDelegate::trackCustomPopupMenu(IWebView* /*sender*/, OLE_HANDLE /*menu*/, LPPOINT /*point*/) { // Do nothing return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::registerUndoWithTarget( - /* [in] */ IWebUndoTarget* target, - /* [in] */ BSTR actionName, - /* [in] */ IUnknown* actionArg) +HRESULT UIDelegate::registerUndoWithTarget(IWebUndoTarget* target, BSTR actionName, IUnknown* actionArg) { m_undoManager->registerUndoWithTarget(target, actionName, actionArg); return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::removeAllActionsWithTarget( - /* [in] */ IWebUndoTarget*) +HRESULT UIDelegate::removeAllActionsWithTarget(IWebUndoTarget*) { m_undoManager->removeAllActions(); return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::setActionTitle( - /* [in] */ BSTR actionTitle) +HRESULT UIDelegate::setActionTitle(BSTR /*actionTitle*/) { // It is not neccessary to implement this for DRT because there is // menu to write out the title to. return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::undo() +HRESULT UIDelegate::undo() { m_undoManager->undo(); return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::redo() +HRESULT UIDelegate::redo() { m_undoManager->redo(); return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::canUndo( - /* [retval][out] */ BOOL* result) +HRESULT UIDelegate::canUndo(BOOL* result) { if (!result) return E_POINTER; @@ -269,8 +260,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::canUndo( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::canRedo( - /* [retval][out] */ BOOL* result) +HRESULT UIDelegate::canRedo(BOOL* result) { if (!result) return E_POINTER; @@ -279,16 +269,12 @@ HRESULT STDMETHODCALLTYPE UIDelegate::canRedo( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::printFrame( - /* [in] */ IWebView *webView, - /* [in] */ IWebFrame *frame) +HRESULT UIDelegate::printFrame(IWebView* /*webView*/, IWebFrame* /*frame*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::ftpDirectoryTemplatePath( - /* [in] */ IWebView *webView, - /* [retval][out] */ BSTR *path) +HRESULT UIDelegate::ftpDirectoryTemplatePath(IWebView* /*webView*/, BSTR* path) { if (!path) return E_POINTER; @@ -297,9 +283,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::ftpDirectoryTemplatePath( } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewHeaderHeight( - /* [in] */ IWebView *webView, - /* [retval][out] */ float *result) +HRESULT UIDelegate::webViewHeaderHeight(IWebView* /*webView*/, float* result) { if (!result) return E_POINTER; @@ -307,9 +291,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::webViewHeaderHeight( return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewFooterHeight( - /* [in] */ IWebView *webView, - /* [retval][out] */ float *result) +HRESULT UIDelegate::webViewFooterHeight(IWebView* /*webView*/, float* result) { if (!result) return E_POINTER; @@ -317,55 +299,37 @@ HRESULT STDMETHODCALLTYPE UIDelegate::webViewFooterHeight( return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::drawHeaderInRect( - /* [in] */ IWebView *webView, - /* [in] */ RECT *rect, - /* [in] */ OLE_HANDLE drawingContext) +HRESULT UIDelegate::drawHeaderInRect(IWebView* /*webView*/, RECT* /*rect*/, OLE_HANDLE /*drawingContext*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::drawFooterInRect( - /* [in] */ IWebView *webView, - /* [in] */ RECT *rect, - /* [in] */ OLE_HANDLE drawingContext, - /* [in] */ UINT pageIndex, - /* [in] */ UINT pageCount) +HRESULT UIDelegate::drawFooterInRect(IWebView* /*webView*/, RECT* /*rect*/, OLE_HANDLE /*drawingContext*/, UINT /*pageIndex*/, UINT /*pageCount*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewPrintingMarginRect( - /* [in] */ IWebView *webView, - /* [retval][out] */ RECT *rect) +HRESULT UIDelegate::webViewPrintingMarginRect(IWebView* /*webView*/, RECT* /*rect*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::canRunModal( - /* [in] */ IWebView *webView, - /* [retval][out] */ BOOL *canRunBoolean) +HRESULT UIDelegate::canRunModal(IWebView* /*webView*/, BOOL* /*canRunBoolean*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::createModalDialog( - /* [in] */ IWebView *sender, - /* [in] */ IWebURLRequest *request, - /* [retval][out] */ IWebView **newWebView) +HRESULT UIDelegate::createModalDialog(IWebView* /*sender*/, IWebURLRequest* /*request*/, IWebView** /*newWebView*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::runModal( - /* [in] */ IWebView *webView) +HRESULT UIDelegate::runModal(IWebView* /*webView*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::isMenuBarVisible( - /* [in] */ IWebView *webView, - /* [retval][out] */ BOOL *visible) +HRESULT UIDelegate::isMenuBarVisible(IWebView* /*webView*/, BOOL* visible) { if (!visible) return E_POINTER; @@ -373,18 +337,12 @@ HRESULT STDMETHODCALLTYPE UIDelegate::isMenuBarVisible( return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::setMenuBarVisible( - /* [in] */ IWebView *webView, - /* [in] */ BOOL visible) +HRESULT UIDelegate::setMenuBarVisible(IWebView* /*webView*/, BOOL /*visible*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::runDatabaseSizeLimitPrompt( - /* [in] */ IWebView *webView, - /* [in] */ BSTR displayName, - /* [in] */ IWebFrame *initiatedByFrame, - /* [retval][out] */ BOOL *allowed) +HRESULT UIDelegate::runDatabaseSizeLimitPrompt(IWebView* /*webView*/, BSTR /*displayName*/, IWebFrame* /*initiatedByFrame*/, BOOL* allowed) { if (!allowed) return E_POINTER; @@ -392,48 +350,30 @@ HRESULT STDMETHODCALLTYPE UIDelegate::runDatabaseSizeLimitPrompt( return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::paintCustomScrollbar( - /* [in] */ IWebView *webView, - /* [in] */ HDC hDC, - /* [in] */ RECT rect, - /* [in] */ WebScrollBarControlSize size, - /* [in] */ WebScrollbarControlState state, - /* [in] */ WebScrollbarControlPart pressedPart, - /* [in] */ BOOL vertical, - /* [in] */ float value, - /* [in] */ float proportion, - /* [in] */ WebScrollbarControlPartMask parts) +HRESULT UIDelegate::paintCustomScrollbar(IWebView* /*webView*/, HDC /*hDC*/, RECT /*rect*/, WebScrollBarControlSize /*size*/, WebScrollbarControlState /*state*/, + WebScrollbarControlPart /*pressedPart*/, BOOL /*vertical*/, float /*value*/, float /*proportion*/, WebScrollbarControlPartMask /*parts*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::paintCustomScrollCorner( - /* [in] */ IWebView *webView, - /* [in] */ HDC hDC, - /* [in] */ RECT rect) +HRESULT UIDelegate::paintCustomScrollCorner(IWebView* /*webView*/, HDC /*hDC*/, RECT /*rect*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::setFrame( - /* [in] */ IWebView* /*sender*/, - /* [in] */ RECT* frame) +HRESULT UIDelegate::setFrame(IWebView* /*sender*/, RECT* frame) { m_frame = *frame; return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewFrame( - /* [in] */ IWebView* /*sender*/, - /* [retval][out] */ RECT* frame) +HRESULT UIDelegate::webViewFrame(IWebView* /*sender*/, RECT* frame) { *frame = m_frame; return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptAlertPanelWithMessage( - /* [in] */ IWebView* /*sender*/, - /* [in] */ BSTR message) +HRESULT UIDelegate::runJavaScriptAlertPanelWithMessage(IWebView* /*sender*/, BSTR message) { printf("ALERT: %S\n", message ? message : L""); fflush(stdout); @@ -441,10 +381,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptAlertPanelWithMessage( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptConfirmPanelWithMessage( - /* [in] */ IWebView* sender, - /* [in] */ BSTR message, - /* [retval][out] */ BOOL* result) +HRESULT UIDelegate::runJavaScriptConfirmPanelWithMessage(IWebView* /*sender*/, BSTR message, BOOL* result) { printf("CONFIRM: %S\n", message ? message : L""); *result = TRUE; @@ -452,11 +389,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptConfirmPanelWithMessage( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptTextInputPanelWithPrompt( - /* [in] */ IWebView *sender, - /* [in] */ BSTR message, - /* [in] */ BSTR defaultText, - /* [retval][out] */ BSTR *result) +HRESULT UIDelegate::runJavaScriptTextInputPanelWithPrompt(IWebView* /*sender*/, BSTR message, BSTR defaultText, BSTR* result) { printf("PROMPT: %S, default text: %S\n", message ? message : L"", defaultText ? defaultText : L""); *result = SysAllocString(defaultText); @@ -464,11 +397,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptTextInputPanelWithPrompt( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::runBeforeUnloadConfirmPanelWithMessage( - /* [in] */ IWebView* /*sender*/, - /* [in] */ BSTR message, - /* [in] */ IWebFrame* /*initiatedByFrame*/, - /* [retval][out] */ BOOL* result) +HRESULT UIDelegate::runBeforeUnloadConfirmPanelWithMessage(IWebView* /*sender*/, BSTR message, IWebFrame* /*initiatedByFrame*/, BOOL* result) { if (!result) return E_POINTER; @@ -477,12 +406,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::runBeforeUnloadConfirmPanelWithMessage( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewAddMessageToConsole( - /* [in] */ IWebView* sender, - /* [in] */ BSTR message, - /* [in] */ int lineNumber, - /* [in] */ BSTR url, - /* [in] */ BOOL isError) +HRESULT UIDelegate::webViewAddMessageToConsole(IWebView* /*sender*/, BSTR message, int lineNumber, BSTR url, BOOL isError) { wstring newMessage; if (message) { @@ -499,12 +423,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::webViewAddMessageToConsole( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::doDragDrop( - /* [in] */ IWebView* sender, - /* [in] */ IDataObject* object, - /* [in] */ IDropSource* source, - /* [in] */ DWORD okEffect, - /* [retval][out] */ DWORD* performedEffect) +HRESULT UIDelegate::doDragDrop(IWebView* /*sender*/, IDataObject* object, IDropSource* source, DWORD /*okEffect*/, DWORD* performedEffect) { if (!performedEffect) return E_POINTER; @@ -522,10 +441,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::doDragDrop( return oleDragAndDropReturnValue; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewGetDlgCode( - /* [in] */ IWebView* /*sender*/, - /* [in] */ UINT /*keyCode*/, - /* [retval][out] */ LONG_PTR *code) +HRESULT UIDelegate::webViewGetDlgCode(IWebView* /*sender*/, UINT /*keyCode*/, LONG_PTR* code) { if (!code) return E_POINTER; @@ -533,10 +449,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::webViewGetDlgCode( return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::createWebViewWithRequest( - /* [in] */ IWebView *sender, - /* [in] */ IWebURLRequest *request, - /* [retval][out] */ IWebView **newWebView) +HRESULT UIDelegate::createWebViewWithRequest(IWebView* /*sender*/, IWebURLRequest* /*request*/, IWebView** newWebView) { if (!::gTestRunner->canOpenWindows()) return E_FAIL; @@ -544,8 +457,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::createWebViewWithRequest( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewClose( - /* [in] */ IWebView *sender) +HRESULT UIDelegate::webViewClose(IWebView* sender) { HWND hostWindow; sender->hostWindow(reinterpret_cast(&hostWindow)); @@ -553,8 +465,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::webViewClose( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewFocus( - /* [in] */ IWebView *sender) +HRESULT UIDelegate::webViewFocus(IWebView* sender) { HWND hostWindow; sender->hostWindow(reinterpret_cast(&hostWindow)); @@ -562,39 +473,30 @@ HRESULT STDMETHODCALLTYPE UIDelegate::webViewFocus( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewUnfocus( - /* [in] */ IWebView *sender) +HRESULT UIDelegate::webViewUnfocus(IWebView* /*sender*/) { SetForegroundWindow(GetDesktopWindow()); return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewPainted( - /* [in] */ IWebView *sender) +HRESULT UIDelegate::webViewPainted(IWebView* /*sender*/) { return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::exceededDatabaseQuota( - /* [in] */ IWebView *sender, - /* [in] */ IWebFrame *frame, - /* [in] */ IWebSecurityOrigin *origin, - /* [in] */ BSTR databaseIdentifier) +HRESULT UIDelegate::exceededDatabaseQuota(IWebView* sender, IWebFrame* frame, IWebSecurityOrigin* origin, BSTR databaseIdentifier) { - BSTR protocol; - BSTR host; + _bstr_t protocol; + _bstr_t host; unsigned short port; - origin->protocol(&protocol); - origin->host(&host); + origin->protocol(&protocol.GetBSTR()); + origin->host(&host.GetBSTR()); origin->port(&port); if (!done && gTestRunner->dumpDatabaseCallbacks()) printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%S, %S, %i} database:%S\n", protocol, host, port, databaseIdentifier); - SysFreeString(protocol); - SysFreeString(host); - unsigned long long defaultQuota = 5 * 1024 * 1024; double testDefaultQuota = gTestRunner->databaseDefaultQuota(); if (testDefaultQuota >= 0) @@ -633,11 +535,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::exceededDatabaseQuota( return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::embeddedViewWithArguments( - /* [in] */ IWebView *sender, - /* [in] */ IWebFrame *frame, - /* [in] */ IPropertyBag *arguments, - /* [retval][out] */ IWebEmbeddedView **view) +HRESULT UIDelegate::embeddedViewWithArguments(IWebView* /*sender*/, IWebFrame* /*frame*/, IPropertyBag* /*arguments*/, IWebEmbeddedView** view) { if (!view) return E_POINTER; @@ -645,54 +543,50 @@ HRESULT STDMETHODCALLTYPE UIDelegate::embeddedViewWithArguments( return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewClosing( - /* [in] */ IWebView *sender) +HRESULT UIDelegate::webViewClosing(IWebView* /*sender*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewSetCursor( - /* [in] */ IWebView *sender, - /* [in] */ OLE_HANDLE cursor) +HRESULT UIDelegate::webViewSetCursor(IWebView* /*sender*/, OLE_HANDLE /*cursor*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::webViewDidInvalidate( - /* [in] */ IWebView *sender) +HRESULT UIDelegate::webViewDidInvalidate(IWebView* /*sender*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::setStatusText(IWebView*, BSTR text) +HRESULT UIDelegate::setStatusText(IWebView*, BSTR text) { if (gTestRunner->dumpStatusCallbacks()) - printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", text ? toUTF8(text).c_str() : ""); + printf("UI DELEGATE STATUS CALLBACK: setStatusText:%S\n", text ? text : L""); return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::desktopNotificationsDelegate(IWebDesktopNotificationsDelegate** result) +HRESULT UIDelegate::desktopNotificationsDelegate(IWebDesktopNotificationsDelegate** result) { m_desktopNotifications.copyRefTo(result); return S_OK; } -HRESULT STDMETHODCALLTYPE UIDelegate::createWebViewWithRequest(IWebView* sender, IWebURLRequest* request, IPropertyBag* windowFeatures, IWebView** newWebView) +HRESULT UIDelegate::createWebViewWithRequest(IWebView* /*sender*/, IWebURLRequest* /*request*/, IPropertyBag* /*windowFeatures*/, IWebView** /*newWebView*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::drawBackground(IWebView* sender, OLE_HANDLE hdc, const RECT* dirtyRect) +HRESULT UIDelegate::drawBackground(IWebView* /*sender*/, OLE_HANDLE hdc, const RECT* dirtyRect) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::decidePolicyForGeolocationRequest(IWebView* sender, IWebFrame* frame, IWebSecurityOrigin* origin, IWebGeolocationPolicyListener* listener) +HRESULT UIDelegate::decidePolicyForGeolocationRequest(IWebView* /*sender*/, IWebFrame* frame, IWebSecurityOrigin* /*origin*/, IWebGeolocationPolicyListener* /*listener*/) { return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE UIDelegate::didPressMissingPluginButton(IDOMElement* element) +HRESULT UIDelegate::didPressMissingPluginButton(IDOMElement* /*element*/) { printf("MISSING PLUGIN BUTTON PRESSED\n"); return S_OK; diff --git a/Tools/DumpRenderTree/win/WorkQueueItemWin.cpp b/Tools/DumpRenderTree/win/WorkQueueItemWin.cpp index 0c2fcbf..19831f0 100644 --- a/Tools/DumpRenderTree/win/WorkQueueItemWin.cpp +++ b/Tools/DumpRenderTree/win/WorkQueueItemWin.cpp @@ -29,11 +29,13 @@ #include "config.h" #include "WorkQueueItem.h" +#include #include "DumpRenderTree.h" #include #include #include #include +#include #include #include #include @@ -53,28 +55,20 @@ static wstring jsStringRefToWString(JSStringRef jsStr) bool LoadItem::invoke() const { - wstring targetString = jsStringRefToWString(m_target.get()); + _bstr_t targetBSTR(JSStringCopyBSTR(m_target.get()), false); COMPtr targetFrame; - if (targetString.empty()) + if (!targetBSTR.length()) targetFrame = frame; - else { - BSTR targetBSTR = SysAllocString(targetString.c_str()); - bool failed = FAILED(frame->findFrameNamed(targetBSTR, &targetFrame)); - SysFreeString(targetBSTR); - if (failed) - return false; - } + else if (FAILED(frame->findFrameNamed(targetBSTR, &targetFrame))) + return false; COMPtr request; if (FAILED(WebKitCreateInstance(CLSID_WebURLRequest, 0, IID_IWebURLRequest, (void**)&request))) return false; - wstring urlString = jsStringRefToWString(m_url.get()); - BSTR urlBSTR = SysAllocString(urlString.c_str()); - bool failed = FAILED(request->initWithURL(urlBSTR, WebURLRequestUseProtocolCachePolicy, 60)); - SysFreeString(urlBSTR); - if (failed) + _bstr_t urlBSTR(JSStringCopyBSTR(m_url.get()), false); + if (FAILED(request->initWithURL(urlBSTR, WebURLRequestUseProtocolCachePolicy, 60))) return false; targetFrame->loadRequest(request.get()); @@ -83,27 +77,17 @@ bool LoadItem::invoke() const bool LoadHTMLStringItem::invoke() const { - wstring content = jsStringRefToWString(m_content.get()); - wstring baseURL = jsStringRefToWString(m_baseURL.get()); - - BSTR contentBSTR = SysAllocString(content.c_str()); - BSTR baseURLBSTR = SysAllocString(baseURL.c_str()); + _bstr_t contentBSTR(JSStringCopyBSTR(m_content.get()), false); + _bstr_t baseURLBSTR(JSStringCopyBSTR(m_baseURL.get()), false); if (m_unreachableURL) { - wstring unreachableURL = jsStringRefToWString(m_unreachableURL.get()); - BSTR unreachableURLBSTR = SysAllocString(unreachableURL.c_str()); + _bstr_t unreachableURLBSTR(JSStringCopyBSTR(m_unreachableURL.get()), false); frame->loadAlternateHTMLString(contentBSTR, baseURLBSTR, unreachableURLBSTR); - SysFreeString(contentBSTR); - SysFreeString(baseURLBSTR); - SysFreeString(unreachableURLBSTR); return true; } frame->loadHTMLString(contentBSTR, baseURLBSTR); - SysFreeString(contentBSTR); - SysFreeString(baseURLBSTR); - return true; } @@ -127,13 +111,10 @@ bool ScriptItem::invoke() const if (FAILED(frame->webView(&webView))) return false; - wstring scriptString = jsStringRefToWString(m_script.get()); + _bstr_t scriptBSTR(JSStringCopyBSTR(m_script.get()), false); - BSTR result; - BSTR scriptBSTR = SysAllocString(scriptString.c_str()); - webView->stringByEvaluatingJavaScriptFromString(scriptBSTR, &result); - SysFreeString(result); - SysFreeString(scriptBSTR); + _bstr_t result; + webView->stringByEvaluatingJavaScriptFromString(scriptBSTR, &result.GetBSTR()); return true; }