Move to using std::unique_ptr for KeyboardEvent, ScriptExecutionContext::PendingException
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Feb 2014 09:57:03 +0000 (09:57 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Feb 2014 09:57:03 +0000 (09:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129061

Reviewed by Andreas Kling.

Replace uses of OwnPtr and PassOwnPtr for KeyboardEvent and ScriptExecutionContext::PendingException
classes with std::unique_ptr. ScriptExecutionContext::Task objects are still handled through OwnPtr,
but this will be addressed later.

* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
* dom/KeyboardEvent.h:
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportException):
(WebCore::ScriptExecutionContext::publicURLManager):
* dom/ScriptExecutionContext.h:
* dom/ScriptRunner.h: Remove an unnecessary PassOwnPtr header inclusion.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164422 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/KeyboardEvent.h
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/dom/ScriptRunner.h

index 182fad9..5bfd9b9 100644 (file)
@@ -1,5 +1,25 @@
 2014-02-20  Zan Dobersek  <zdobersek@igalia.com>
 
+        Move to using std::unique_ptr for KeyboardEvent, ScriptExecutionContext::PendingException
+        https://bugs.webkit.org/show_bug.cgi?id=129061
+
+        Reviewed by Andreas Kling.
+
+        Replace uses of OwnPtr and PassOwnPtr for KeyboardEvent and ScriptExecutionContext::PendingException
+        classes with std::unique_ptr. ScriptExecutionContext::Task objects are still handled through OwnPtr,
+        but this will be addressed later.
+
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::KeyboardEvent):
+        * dom/KeyboardEvent.h:
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::reportException):
+        (WebCore::ScriptExecutionContext::publicURLManager):
+        * dom/ScriptExecutionContext.h:
+        * dom/ScriptRunner.h: Remove an unnecessary PassOwnPtr header inclusion.
+
+2014-02-20  Zan Dobersek  <zdobersek@igalia.com>
+
         Move to using std::unique_ptr for EventListenerMap, EventTarget
         https://bugs.webkit.org/show_bug.cgi?id=129062
 
index 7916908..c011b42 100644 (file)
@@ -108,7 +108,7 @@ KeyboardEvent::KeyboardEvent()
 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* view)
     : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()),
                           true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey())
-    , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key)))
+    , m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key))
     , m_keyIdentifier(key.keyIdentifier())
     , m_location(keyLocationCode(key))
     , m_altGraphKey(false)
index bd2d1fb..216a634 100644 (file)
@@ -25,6 +25,7 @@
 #define KeyboardEvent_h
 
 #include "UIEventWithKeyState.h"
+#include <memory>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -113,7 +114,7 @@ private:
     KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*);
     KeyboardEvent(const AtomicString&, const KeyboardEventInit&);
 
-    OwnPtr<PlatformKeyboardEvent> m_keyEvent;
+    std::unique_ptr<PlatformKeyboardEvent> m_keyEvent;
     String m_keyIdentifier;
     unsigned m_location;
     bool m_altGraphKey : 1;
index 2d74a38..d4ca8b2 100644 (file)
@@ -299,8 +299,8 @@ void ScriptExecutionContext::reportException(const String& errorMessage, int lin
 {
     if (m_inDispatchErrorEvent) {
         if (!m_pendingExceptions)
-            m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException>>());
-        m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, columnNumber, sourceURL, callStack)));
+            m_pendingExceptions = std::make_unique<Vector<std::unique_ptr<PendingException>>>();
+        m_pendingExceptions->append(std::make_unique<PendingException>(errorMessage, lineNumber, columnNumber, sourceURL, callStack));
         return;
     }
 
@@ -311,11 +311,9 @@ void ScriptExecutionContext::reportException(const String& errorMessage, int lin
     if (!m_pendingExceptions)
         return;
 
-    for (size_t i = 0; i < m_pendingExceptions->size(); i++) {
-        PendingException* e = m_pendingExceptions->at(i).get();
-        logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber, e->m_columnNumber, e->m_callStack);
-    }
-    m_pendingExceptions.clear();
+    for (auto& exception : *m_pendingExceptions)
+        logExceptionToConsole(exception->m_errorMessage, exception->m_sourceURL, exception->m_lineNumber, exception->m_columnNumber, exception->m_callStack);
+    m_pendingExceptions.reset();
 }
 
 void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* state, unsigned long requestIdentifier)
@@ -363,7 +361,7 @@ int ScriptExecutionContext::circularSequentialID()
 PublicURLManager& ScriptExecutionContext::publicURLManager()
 {
     if (!m_publicURLManager)
-        m_publicURLManager = PublicURLManager::create(this);
+        m_publicURLManager = std::make_unique<PublicURLManager>(this);
     return *m_publicURLManager;
 }
 #endif
index 64acad8..df0acf3 100644 (file)
@@ -208,7 +208,7 @@ private:
 
     bool m_inDispatchErrorEvent;
     class PendingException;
-    OwnPtr<Vector<OwnPtr<PendingException>>> m_pendingExceptions;
+    std::unique_ptr<Vector<std::unique_ptr<PendingException>>> m_pendingExceptions;
 
     bool m_activeDOMObjectsAreSuspended;
     ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects;
index f23e6da..d7e692c 100644 (file)
@@ -30,7 +30,6 @@
 #include "Timer.h"
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>