Diff
Modified: trunk/Source/WebCore/ChangeLog (167364 => 167365)
--- trunk/Source/WebCore/ChangeLog 2014-04-16 18:09:56 UTC (rev 167364)
+++ trunk/Source/WebCore/ChangeLog 2014-04-16 18:15:04 UTC (rev 167365)
@@ -1,3 +1,23 @@
+2014-04-15 Brent Fulgham <bfulg...@apple.com>
+
+ [Win] Eliminate use of deleteAllValues in Windows Files
+ https://bugs.webkit.org/show_bug.cgi?id=131631
+
+ Reviewed by Darin Adler.
+
+ Update to use std::unique_ptr for object lifetime. Get rid of
+ deleteAllValues now that it is no loner needed. Use ranged for
+ loops where possible.
+
+ * platform/win/WCDataObject.cpp:
+ (WebCore::WCEnumFormatEtc::WCEnumFormatEtc):
+ (WebCore::WCDataObject::~WCDataObject):
+ (WebCore::WCDataObject::GetData):
+ (WebCore::WCDataObject::QueryGetData):
+ (WebCore::WCDataObject::SetData):
+ (WebCore::WCDataObject::clearData):
+ * platform/win/WCDataObject.h:
+
2014-04-16 Chris Fleizach <cfleiz...@apple.com>
AX: Accessing a table cell with an invalid column header crashes
Modified: trunk/Source/WebCore/platform/win/WCDataObject.cpp (167364 => 167365)
--- trunk/Source/WebCore/platform/win/WCDataObject.cpp 2014-04-16 18:09:56 UTC (rev 167364)
+++ trunk/Source/WebCore/platform/win/WCDataObject.cpp 2014-04-16 18:15:04 UTC (rev 167365)
@@ -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
@@ -36,7 +36,7 @@
{
public:
WCEnumFormatEtc(const Vector<FORMATETC>& formats);
- WCEnumFormatEtc(const Vector<FORMATETC*>& formats);
+ WCEnumFormatEtc(const Vector<std::unique_ptr<FORMATETC>>& formats);
//IUnknown members
STDMETHOD(QueryInterface)(REFIID, void**);
@@ -55,8 +55,6 @@
size_t m_current;
};
-
-
WCEnumFormatEtc::WCEnumFormatEtc(const Vector<FORMATETC>& formats)
: m_ref(1)
, m_current(0)
@@ -65,12 +63,12 @@
m_formats.append(formats[i]);
}
-WCEnumFormatEtc::WCEnumFormatEtc(const Vector<FORMATETC*>& formats)
-: m_ref(1)
-, m_current(0)
+WCEnumFormatEtc::WCEnumFormatEtc(const Vector<std::unique_ptr<FORMATETC>>& formats)
+ : m_ref(1)
+ , m_current(0)
{
- for(size_t i = 0; i < formats.size(); ++i)
- m_formats.append(*formats[i]);
+ for (auto& format : formats)
+ m_formats.append(*format);
}
STDMETHODIMP WCEnumFormatEtc::QueryInterface(REFIID riid, void** ppvObject)
@@ -178,15 +176,6 @@
{
}
-WCDataObject::~WCDataObject()
-{
- for(size_t i = 0; i < m_medium.size(); ++i) {
- ReleaseStgMedium(m_medium[i]);
- delete m_medium[i];
- }
- WTF::deprecatedDeleteAllValues(m_formats);
-}
-
STDMETHODIMP WCDataObject::QueryInterface(REFIID riid,void** ppvObject)
{
*ppvObject = 0;
@@ -220,12 +209,12 @@
return E_POINTER;
pmedium->hGlobal = 0;
- for(size_t i=0; i < m_formats.size(); ++i) {
+ for (size_t i = 0; i < m_formats.size(); ++i) {
if(/*pformatetcIn->tymed & m_formats[i]->tymed &&*/ // tymed can be 0 (TYMED_NULL) - but it can have a medium that contains an pUnkForRelease
pformatetcIn->lindex == m_formats[i]->lindex &&
pformatetcIn->dwAspect == m_formats[i]->dwAspect &&
pformatetcIn->cfFormat == m_formats[i]->cfFormat) {
- CopyMedium(pmedium, m_medium[i], m_formats[i]);
+ CopyMedium(pmedium, m_medium[i].get(), m_formats[i].get());
return S_OK;
}
}
@@ -245,12 +234,12 @@
if (!(DVASPECT_CONTENT & pformatetc->dwAspect))
return (DV_E_DVASPECT);
HRESULT hr = DV_E_TYMED;
- for(size_t i = 0; i < m_formats.size(); ++i) {
- if(pformatetc->tymed & m_formats[i]->tymed) {
- if(pformatetc->cfFormat == m_formats[i]->cfFormat)
+ for (auto& format : m_formats) {
+ if (pformatetc->tymed & format->tymed) {
+ if (pformatetc->cfFormat == format->cfFormat)
return S_OK;
- else
- hr = DV_E_CLIPFORMAT;
+
+ hr = DV_E_CLIPFORMAT;
}
else
hr = DV_E_TYMED;
@@ -268,28 +257,20 @@
if(!pformatetc || !pmedium)
return E_POINTER;
- FORMATETC* fetc=new FORMATETC;
- if (!fetc)
- return E_OUTOFMEMORY;
+ auto fetc = std::make_unique<FORMATETC>();
+ std::unique_ptr<STGMEDIUM, StgMediumDeleter> pStgMed(new STGMEDIUM);
- STGMEDIUM* pStgMed = new STGMEDIUM;
+ ZeroMemory(fetc.get(), sizeof(FORMATETC));
+ ZeroMemory(pStgMed.get(), sizeof(STGMEDIUM));
- if(!pStgMed) {
- delete fetc;
- return E_OUTOFMEMORY;
- }
-
- ZeroMemory(fetc,sizeof(FORMATETC));
- ZeroMemory(pStgMed,sizeof(STGMEDIUM));
-
*fetc = *pformatetc;
- m_formats.append(fetc);
+ m_formats.append(std::move(fetc));
if(fRelease)
*pStgMed = *pmedium;
else
- CopyMedium(pStgMed, pmedium, pformatetc);
- m_medium.append(pStgMed);
+ CopyMedium(pStgMed.get(), pmedium, pformatetc);
+ m_medium.append(std::move(pStgMed));
return S_OK;
}
@@ -376,17 +357,10 @@
size_t ptr = 0;
while (ptr < m_formats.size()) {
if (m_formats[ptr]->cfFormat == format) {
- FORMATETC* current = m_formats[ptr];
- m_formats[ptr] = m_formats[m_formats.size() - 1];
- m_formats[m_formats.size() - 1] = 0;
+ m_formats[ptr] = std::move(m_formats[m_formats.size() - 1]);
m_formats.removeLast();
- delete current;
- STGMEDIUM* medium = m_medium[ptr];
- m_medium[ptr] = m_medium[m_medium.size() - 1];
- m_medium[m_medium.size() - 1] = 0;
+ m_medium[ptr] = std::move(m_medium[m_medium.size() - 1]);
m_medium.removeLast();
- ReleaseStgMedium(medium);
- delete medium;
continue;
}
ptr++;
Modified: trunk/Source/WebCore/platform/win/WCDataObject.h (167364 => 167365)
--- trunk/Source/WebCore/platform/win/WCDataObject.h 2014-04-16 18:09:56 UTC (rev 167364)
+++ trunk/Source/WebCore/platform/win/WCDataObject.h 2014-04-16 18:15:04 UTC (rev 167365)
@@ -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
@@ -34,6 +34,13 @@
namespace WebCore {
+struct StgMediumDeleter {
+ void operator()(STGMEDIUM* medium)
+ {
+ ::ReleaseStgMedium(medium);
+ }
+};
+
class WCDataObject : public IDataObject {
public:
void CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc);
@@ -60,10 +67,9 @@
static HRESULT createInstance(WCDataObject**, const DragDataMap&);
private:
WCDataObject();
- virtual ~WCDataObject();
long m_ref;
- Vector<FORMATETC*> m_formats;
- Vector<STGMEDIUM*> m_medium;
+ Vector<std::unique_ptr<FORMATETC>> m_formats;
+ Vector<std::unique_ptr<STGMEDIUM, StgMediumDeleter>> m_medium;
};
}
Modified: trunk/Tools/ChangeLog (167364 => 167365)
--- trunk/Tools/ChangeLog 2014-04-16 18:09:56 UTC (rev 167364)
+++ trunk/Tools/ChangeLog 2014-04-16 18:15:04 UTC (rev 167365)
@@ -1,3 +1,35 @@
+2014-04-15 Brent Fulgham <bfulg...@apple.com>
+
+ [Win] Eliminate use of deleteAllValues in Windows Files
+ https://bugs.webkit.org/show_bug.cgi?id=131631
+
+ Reviewed by Darin Adler.
+
+ Switch to std::unique_ptr for memory lifetime. Get rid of
+ deleteAllValues now that it is no longer needed. Use ranged
+ for loops where possible.
+
+ * DumpRenderTree/win/DRTDataObject.cpp:
+ (WCEnumFormatEtc::WCEnumFormatEtc):
+ (DRTDataObject::~DRTDataObject):
+ (DRTDataObject::GetData):
+ (DRTDataObject::QueryGetData):
+ (DRTDataObject::SetData):
+ (DRTDataObject::clearData):
+ * DumpRenderTree/win/DRTDataObject.h:
+ * DumpRenderTree/win/UIDelegate.cpp:
+ (DRTUndoObject::DRTUndoObject):
+ (DRTUndoObject::~DRTUndoObject):
+ (DRTUndoStack::~DRTUndoStack):
+ (DRTUndoStack::clear):
+ (DRTUndoStack::pop):
+ (DRTUndoManager::DRTUndoManager):
+ (DRTUndoManager::redo):
+ (DRTUndoManager::undo):
+ (UIDelegate::UIDelegate):
+ (UIDelegate::resetUndoManager):
+ * DumpRenderTree/win/UIDelegate.h:
+
2014-04-16 Carlos Alberto Lopez Perez <clo...@igalia.com>
[GTK] Unreviewed GTK gardening.
Modified: trunk/Tools/DumpRenderTree/win/DRTDataObject.cpp (167364 => 167365)
--- trunk/Tools/DumpRenderTree/win/DRTDataObject.cpp 2014-04-16 18:09:56 UTC (rev 167364)
+++ trunk/Tools/DumpRenderTree/win/DRTDataObject.cpp 2014-04-16 18:15:04 UTC (rev 167365)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2014 Apple Inc. All rights reserved.
* Copyright (C) 2012 Baidu Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@
class WCEnumFormatEtc : public IEnumFORMATETC {
public:
explicit WCEnumFormatEtc(const Vector<FORMATETC>& formats);
- explicit WCEnumFormatEtc(const Vector<FORMATETC*>& formats);
+ explicit WCEnumFormatEtc(const Vector<std::unique_ptr<FORMATETC>>& formats);
// IUnknown members
STDMETHOD(QueryInterface)(REFIID, void**);
@@ -76,12 +76,12 @@
{
}
-WCEnumFormatEtc::WCEnumFormatEtc(const Vector<FORMATETC*>& formats)
+WCEnumFormatEtc::WCEnumFormatEtc(const Vector<std::unique_ptr<FORMATETC>>& formats)
: m_ref(1)
, m_current(0)
{
- for (size_t i = 0; i < formats.size(); ++i)
- m_formats.append(*formats[i]);
+ for (auto& format : formats)
+ m_formats.append(*format);
}
STDMETHODIMP WCEnumFormatEtc::QueryInterface(REFIID riid, void** ppvObject)
@@ -175,15 +175,6 @@
{
}
-DRTDataObject::~DRTDataObject()
-{
- for (size_t i = 0; i < m_medium.size(); ++i) {
- ReleaseStgMedium(m_medium[i]);
- delete m_medium[i];
- }
- WTF::deprecatedDeleteAllValues(m_formats);
-}
-
STDMETHODIMP DRTDataObject::QueryInterface(REFIID riid, void** ppvObject)
{
*ppvObject = 0;
@@ -218,7 +209,7 @@
for (size_t i = 0; i < m_formats.size(); ++i) {
if (pformatetcIn->lindex == m_formats[i]->lindex && pformatetcIn->dwAspect == m_formats[i]->dwAspect && pformatetcIn->cfFormat == m_formats[i]->cfFormat) {
- CopyMedium(pmedium, m_medium[i], m_formats[i]);
+ CopyMedium(pmedium, m_medium[i].get(), m_formats[i].get());
return S_OK;
}
}
@@ -238,9 +229,9 @@
if (!(DVASPECT_CONTENT & pformatetc->dwAspect))
return (DV_E_DVASPECT);
- for (size_t i = 0; i < m_formats.size(); ++i) {
- if (pformatetc->tymed & m_formats[i]->tymed) {
- if (pformatetc->cfFormat == m_formats[i]->cfFormat)
+ for (auto& format : m_formats) {
+ if (pformatetc->tymed & format->tymed) {
+ if (pformatetc->cfFormat == format->cfFormat)
return S_OK;
}
}
@@ -257,28 +248,20 @@
if (!pformatetc || !pmedium)
return E_POINTER;
- FORMATETC* formatetc = new FORMATETC;
- if (!formatetc)
- return E_OUTOFMEMORY;
+ auto formatetc = std::make_unique<FORMATETC>();
+ std::unique_ptr<STGMEDIUM, StgMediumDeleter> pStgMed(new STGMEDIUM);
- STGMEDIUM* pStgMed = new STGMEDIUM;
+ ZeroMemory(formatetc.get(), sizeof(FORMATETC));
+ ZeroMemory(pStgMed.get(), sizeof(STGMEDIUM));
- if (!pStgMed) {
- delete formatetc;
- return E_OUTOFMEMORY;
- }
-
- ZeroMemory(formatetc, sizeof(FORMATETC));
- ZeroMemory(pStgMed, sizeof(STGMEDIUM));
-
*formatetc = *pformatetc;
- m_formats.append(formatetc);
+ m_formats.append(std::move(formatetc));
if (fRelease)
*pStgMed = *pmedium;
else
- CopyMedium(pStgMed, pmedium, pformatetc);
- m_medium.append(pStgMed);
+ CopyMedium(pStgMed.get(), pmedium, pformatetc);
+ m_medium.append(std::move(pStgMed));
return S_OK;
}
@@ -363,17 +346,10 @@
size_t position = 0;
while (position < m_formats.size()) {
if (m_formats[position]->cfFormat == format) {
- FORMATETC* current = m_formats[position];
- m_formats[position] = m_formats[m_formats.size() - 1];
- m_formats[m_formats.size() - 1] = 0;
+ m_formats[position] = std::move(m_formats[m_formats.size() - 1]);
m_formats.removeLast();
- delete current;
- STGMEDIUM* medium = m_medium[position];
- m_medium[position] = m_medium[m_medium.size() - 1];
- m_medium[m_medium.size() - 1] = 0;
+ m_medium[position] = std::move(m_medium[m_medium.size() - 1]);
m_medium.removeLast();
- ReleaseStgMedium(medium);
- delete medium;
continue;
}
position++;
Modified: trunk/Tools/DumpRenderTree/win/DRTDataObject.h (167364 => 167365)
--- trunk/Tools/DumpRenderTree/win/DRTDataObject.h 2014-04-16 18:09:56 UTC (rev 167364)
+++ trunk/Tools/DumpRenderTree/win/DRTDataObject.h 2014-04-16 18:15:04 UTC (rev 167365)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2014 Apple Inc. All rights reserved.
* Copyright (C) 2012 Baidu Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,13 @@
FORMATETC* cfUrlWFormat();
+struct StgMediumDeleter {
+ void operator()(STGMEDIUM* medium)
+ {
+ ::ReleaseStgMedium(medium);
+ }
+};
+
class DRTDataObject : public IDataObject {
public:
void CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc);
@@ -62,10 +69,9 @@
static HRESULT createInstance(DRTDataObject**);
private:
DRTDataObject();
- ~DRTDataObject();
long m_ref;
- Vector<FORMATETC*> m_formats;
- Vector<STGMEDIUM*> m_medium;
+ Vector<std::unique_ptr<FORMATETC>> m_formats;
+ Vector<std::unique_ptr<STGMEDIUM, StgMediumDeleter>> m_medium;
};
#endif // DRTDataObject_h
Modified: trunk/Tools/DumpRenderTree/win/UIDelegate.cpp (167364 => 167365)
--- trunk/Tools/DumpRenderTree/win/UIDelegate.cpp 2014-04-16 18:09:56 UTC (rev 167364)
+++ trunk/Tools/DumpRenderTree/win/UIDelegate.cpp 2014-04-16 18:15:04 UTC (rev 167365)
@@ -36,7 +36,6 @@
#include "TestRunner.h"
#include <WebCore/COMPtr.h>
#include <wtf/Assertions.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/Platform.h>
#include <wtf/Vector.h>
#include <_javascript_Core/_javascript_Core.h>
@@ -51,14 +50,13 @@
public:
DRTUndoObject(IWebUndoTarget* target, BSTR actionName, IUnknown* obj)
: m_target(target)
- , m_actionName(SysAllocString(actionName))
+ , m_actionName(actionName)
, m_obj(obj)
{
}
~DRTUndoObject()
{
- SysFreeString(m_actionName);
}
void invoke()
@@ -68,22 +66,20 @@
private:
IWebUndoTarget* m_target;
- BSTR m_actionName;
+ _bstr_t m_actionName;
COMPtr<IUnknown> m_obj;
};
class DRTUndoStack {
public:
- ~DRTUndoStack() { deprecatedDeleteAllValues(m_undoVector); }
-
bool isEmpty() const { return m_undoVector.isEmpty(); }
- void clear() { deprecatedDeleteAllValues(m_undoVector); m_undoVector.clear(); }
+ void clear() { m_undoVector.clear(); }
void push(DRTUndoObject* undoObject) { m_undoVector.append(undoObject); }
- DRTUndoObject* pop() { DRTUndoObject* top = m_undoVector.last(); m_undoVector.removeLast(); return top; }
+ std::unique_ptr<DRTUndoObject> pop() { std::unique_ptr<DRTUndoObject> top = std::move(m_undoVector.last()); m_undoVector.removeLast(); return std::move(top); }
private:
- Vector<DRTUndoObject*> m_undoVector;
+ Vector<std::unique_ptr<DRTUndoObject>> m_undoVector;
};
class DRTUndoManager {
@@ -98,15 +94,15 @@
bool canUndo() { return !m_undoStack->isEmpty(); }
private:
- OwnPtr<DRTUndoStack> m_redoStack;
- OwnPtr<DRTUndoStack> m_undoStack;
+ std::unique_ptr<DRTUndoStack> m_redoStack;
+ std::unique_ptr<DRTUndoStack> m_undoStack;
bool m_isRedoing;
bool m_isUndoing;
};
DRTUndoManager::DRTUndoManager()
- : m_redoStack(adoptPtr(new DRTUndoStack))
- , m_undoStack(adoptPtr(new DRTUndoStack))
+ : m_redoStack(std::make_unique<DRTUndoStack>())
+ , m_undoStack(std::make_unique<DRTUndoStack>())
, m_isRedoing(false)
, m_isUndoing(false)
{
@@ -134,9 +130,7 @@
m_isRedoing = true;
- DRTUndoObject* redoObject = m_redoStack->pop();
- redoObject->invoke();
- delete redoObject;
+ m_redoStack->pop()->invoke();
m_isRedoing = false;
}
@@ -148,16 +142,14 @@
m_isUndoing = true;
- DRTUndoObject* undoObject = m_undoStack->pop();
- undoObject->invoke();
- delete undoObject;
+ m_undoStack->pop()->invoke();
m_isUndoing = false;
}
UIDelegate::UIDelegate()
: m_refCount(1)
- , m_undoManager(adoptPtr(new DRTUndoManager))
+ , m_undoManager(std::make_unique<DRTUndoManager>())
, m_desktopNotifications(new DRTDesktopNotificationPresenter)
{
m_frame.bottom = 0;
@@ -168,7 +160,7 @@
void UIDelegate::resetUndoManager()
{
- m_undoManager = adoptPtr(new DRTUndoManager);
+ m_undoManager = std::make_unique<DRTUndoManager>();
}
HRESULT UIDelegate::QueryInterface(REFIID riid, void** ppvObject)
Modified: trunk/Tools/DumpRenderTree/win/UIDelegate.h (167364 => 167365)
--- trunk/Tools/DumpRenderTree/win/UIDelegate.h 2014-04-16 18:09:56 UTC (rev 167364)
+++ trunk/Tools/DumpRenderTree/win/UIDelegate.h 2014-04-16 18:15:04 UTC (rev 167365)
@@ -407,7 +407,7 @@
private:
RECT m_frame;
- OwnPtr<DRTUndoManager> m_undoManager;
+ std::unique_ptr<DRTUndoManager> m_undoManager;
COMPtr<IWebDesktopNotificationsDelegate> m_desktopNotifications;
};