Title: [159178] trunk/Source/WebCore
Revision
159178
Author
[email protected]
Date
2013-11-12 22:52:14 -0800 (Tue, 12 Nov 2013)

Log Message

Manage XMLHttpRequestUpload, XSLImportRule, XMLErrors, XML pending callback classes through std::unique_ptr
https://bugs.webkit.org/show_bug.cgi?id=124224

Reviewed by Anders Carlsson.

Use std::unique_ptr to handle objects of various XML classes that were previously managed by OwnPtr.
This removes usage of OwnPtr and PassOwnPtr under Source/WebCore/xml/.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::upload):
* xml/XMLHttpRequest.h:
* xml/XMLHttpRequestUpload.h:
* xml/XSLImportRule.h:
* xml/XSLStyleSheet.h:
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::loadChildSheet):
* xml/parser/XMLDocumentParser.cpp:
(WebCore::XMLDocumentParser::handleError):
* xml/parser/XMLDocumentParser.h:
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::PendingCallbacks::PendingCallbacks):
(WebCore::PendingCallbacks::appendStartElementNSCallback):
(WebCore::PendingCallbacks::appendEndElementNSCallback):
(WebCore::PendingCallbacks::appendCharactersCallback):
(WebCore::PendingCallbacks::appendProcessingInstructionCallback):
(WebCore::PendingCallbacks::appendCDATABlockCallback):
(WebCore::PendingCallbacks::appendCommentCallback):
(WebCore::PendingCallbacks::appendInternalSubsetCallback):
(WebCore::PendingCallbacks::appendErrorCallback):
(WebCore::PendingCallbacks::callAndRemoveFirstCallback):
(WebCore::XMLDocumentParser::XMLDocumentParser):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (159177 => 159178)


--- trunk/Source/WebCore/ChangeLog	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/ChangeLog	2013-11-13 06:52:14 UTC (rev 159178)
@@ -1,3 +1,37 @@
+2013-11-12  Zan Dobersek  <[email protected]>
+
+        Manage XMLHttpRequestUpload, XSLImportRule, XMLErrors, XML pending callback classes through std::unique_ptr
+        https://bugs.webkit.org/show_bug.cgi?id=124224
+
+        Reviewed by Anders Carlsson.
+
+        Use std::unique_ptr to handle objects of various XML classes that were previously managed by OwnPtr.
+        This removes usage of OwnPtr and PassOwnPtr under Source/WebCore/xml/.
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::upload):
+        * xml/XMLHttpRequest.h:
+        * xml/XMLHttpRequestUpload.h:
+        * xml/XSLImportRule.h:
+        * xml/XSLStyleSheet.h:
+        * xml/XSLStyleSheetLibxslt.cpp:
+        (WebCore::XSLStyleSheet::loadChildSheet):
+        * xml/parser/XMLDocumentParser.cpp:
+        (WebCore::XMLDocumentParser::handleError):
+        * xml/parser/XMLDocumentParser.h:
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::PendingCallbacks::PendingCallbacks):
+        (WebCore::PendingCallbacks::appendStartElementNSCallback):
+        (WebCore::PendingCallbacks::appendEndElementNSCallback):
+        (WebCore::PendingCallbacks::appendCharactersCallback):
+        (WebCore::PendingCallbacks::appendProcessingInstructionCallback):
+        (WebCore::PendingCallbacks::appendCDATABlockCallback):
+        (WebCore::PendingCallbacks::appendCommentCallback):
+        (WebCore::PendingCallbacks::appendInternalSubsetCallback):
+        (WebCore::PendingCallbacks::appendErrorCallback):
+        (WebCore::PendingCallbacks::callAndRemoveFirstCallback):
+        (WebCore::XMLDocumentParser::XMLDocumentParser):
+
 2013-11-12  Brady Eidson  <[email protected]>
 
         Move basic IDBBackingStoreTransaction operations to IDBServerConnection

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (159177 => 159178)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2013-11-13 06:52:14 UTC (rev 159178)
@@ -412,7 +412,7 @@
 XMLHttpRequestUpload* XMLHttpRequest::upload()
 {
     if (!m_upload)
-        m_upload = XMLHttpRequestUpload::create(this);
+        m_upload = std::make_unique<XMLHttpRequestUpload>(this);
     return m_upload.get();
 }
 

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.h (159177 => 159178)


--- trunk/Source/WebCore/xml/XMLHttpRequest.h	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.h	2013-11-13 06:52:14 UTC (rev 159178)
@@ -31,7 +31,6 @@
 #include "ScriptWrappable.h"
 #include "ThreadableLoaderClient.h"
 #include "XMLHttpRequestProgressEventThrottle.h"
-#include <wtf/OwnPtr.h>
 #include <wtf/text/AtomicStringHash.h>
 #include <wtf/text/StringBuilder.h>
 
@@ -209,7 +208,7 @@
 
     bool shouldDecodeResponse() const { return m_responseTypeCode < FirstBinaryResponseType; }
 
-    OwnPtr<XMLHttpRequestUpload> m_upload;
+    std::unique_ptr<XMLHttpRequestUpload> m_upload;
 
     URL m_url;
     String m_method;

Modified: trunk/Source/WebCore/xml/XMLHttpRequestUpload.h (159177 => 159178)


--- trunk/Source/WebCore/xml/XMLHttpRequestUpload.h	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/XMLHttpRequestUpload.h	2013-11-13 06:52:14 UTC (rev 159178)
@@ -32,7 +32,6 @@
 #include "XMLHttpRequest.h"
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
@@ -45,10 +44,7 @@
 
     class XMLHttpRequestUpload FINAL : public EventTargetWithInlineData {
     public:
-        static PassOwnPtr<XMLHttpRequestUpload> create(XMLHttpRequest* xmlHttpRequest)
-        {
-            return adoptPtr(new XMLHttpRequestUpload(xmlHttpRequest));
-        }
+        explicit XMLHttpRequestUpload(XMLHttpRequest*);
 
         void ref() { m_xmlHttpRequest->ref(); }
         void deref() { m_xmlHttpRequest->deref(); }
@@ -67,8 +63,6 @@
         void dispatchEventAndLoadEnd(PassRefPtr<Event>);
 
     private:
-        explicit XMLHttpRequestUpload(XMLHttpRequest*);
-
         virtual void refEventTarget() OVERRIDE FINAL { ref(); }
         virtual void derefEventTarget() OVERRIDE FINAL { deref(); }
 

Modified: trunk/Source/WebCore/xml/XSLImportRule.h (159177 => 159178)


--- trunk/Source/WebCore/xml/XSLImportRule.h	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/XSLImportRule.h	2013-11-13 06:52:14 UTC (rev 159178)
@@ -28,7 +28,6 @@
 #include "CachedResourceHandle.h"
 #include "CachedStyleSheetClient.h"
 #include "XSLStyleSheet.h"
-#include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
@@ -37,11 +36,7 @@
 class XSLImportRule : private CachedStyleSheetClient {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassOwnPtr<XSLImportRule> create(XSLStyleSheet* parentSheet, const String& href)
-    {
-        return adoptPtr(new XSLImportRule(parentSheet, href));
-    }
-
+    XSLImportRule(XSLStyleSheet* parentSheet, const String& href);
     virtual ~XSLImportRule();
     
     const String& href() const { return m_strHref; }
@@ -54,8 +49,6 @@
     void loadSheet();
     
 private:
-    XSLImportRule(XSLStyleSheet* parentSheet, const String& href);
-
     virtual void setXSLStyleSheet(const String& href, const URL& baseURL, const String& sheet);
     
     XSLStyleSheet* m_parentStyleSheet;

Modified: trunk/Source/WebCore/xml/XSLStyleSheet.h (159177 => 159178)


--- trunk/Source/WebCore/xml/XSLStyleSheet.h	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/XSLStyleSheet.h	2013-11-13 06:52:14 UTC (rev 159178)
@@ -108,7 +108,7 @@
     URL m_finalURL;
     bool m_isDisabled;
 
-    Vector<OwnPtr<XSLImportRule>> m_children;
+    Vector<std::unique_ptr<XSLImportRule>> m_children;
 
     bool m_embedded;
     bool m_processed;

Modified: trunk/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp (159177 => 159178)


--- trunk/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp	2013-11-13 06:52:14 UTC (rev 159178)
@@ -236,7 +236,7 @@
 
 void XSLStyleSheet::loadChildSheet(const String& href)
 {
-    OwnPtr<XSLImportRule> childRule = XSLImportRule::create(this, href);
+    auto childRule = std::make_unique<XSLImportRule>(this, href);
     XSLImportRule* c = childRule.get();
     m_children.append(childRule.release());
     c->loadSheet();

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp (159177 => 159178)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp	2013-11-13 06:52:14 UTC (rev 159178)
@@ -133,7 +133,7 @@
 void XMLDocumentParser::handleError(XMLErrors::ErrorType type, const char* m, TextPosition position)
 {
     if (!m_xmlErrors)
-        m_xmlErrors = adoptPtr(new XMLErrors(document()));
+        m_xmlErrors = std::make_unique<XMLErrors>(document());
     m_xmlErrors->handleError(type, m, position);
     if (type != XMLErrors::warning)
         m_sawError = true;

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.h (159177 => 159178)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.h	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.h	2013-11-13 06:52:14 UTC (rev 159178)
@@ -32,7 +32,6 @@
 #include "SegmentedString.h"
 #include "XMLErrors.h"
 #include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
 #include <wtf/text/AtomicStringHash.h>
 #include <wtf/text/CString.h>
 
@@ -160,7 +159,7 @@
 
         xmlParserCtxtPtr context() const { return m_context ? m_context->context() : 0; };
         RefPtr<XMLParserContext> m_context;
-        OwnPtr<PendingCallbacks> m_pendingCallbacks;
+        std::unique_ptr<PendingCallbacks> m_pendingCallbacks;
         Vector<xmlChar> m_bufferedText;
         int m_depthTriggeringEntityExpansion;
         bool m_isParsingEntityDeclaration;
@@ -179,7 +178,7 @@
         bool m_requestingScript;
         bool m_finishCalled;
 
-        OwnPtr<XMLErrors> m_xmlErrors;
+        std::unique_ptr<XMLErrors> m_xmlErrors;
 
         CachedResourceHandle<CachedScript> m_pendingScript;
         RefPtr<Element> m_scriptElement;

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (159177 => 159178)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2013-11-13 03:59:48 UTC (rev 159177)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2013-11-13 06:52:14 UTC (rev 159178)
@@ -98,16 +98,13 @@
 class PendingCallbacks {
     WTF_MAKE_NONCOPYABLE(PendingCallbacks); WTF_MAKE_FAST_ALLOCATED;
 public:
+    PendingCallbacks() { }
     ~PendingCallbacks() { }
-    static PassOwnPtr<PendingCallbacks> create()
-    {
-        return adoptPtr(new PendingCallbacks);
-    }
-    
+
     void appendStartElementNSCallback(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
                                       const xmlChar** namespaces, int nb_attributes, int nb_defaulted, const xmlChar** attributes)
     {
-        OwnPtr<PendingStartElementNSCallback> callback = adoptPtr(new PendingStartElementNSCallback);
+        auto callback = std::make_unique<PendingStartElementNSCallback>();
 
         callback->xmlLocalName = xmlStrdup(xmlLocalName);
         callback->xmlPrefix = xmlStrdup(xmlPrefix);
@@ -132,87 +129,85 @@
             callback->attributes[i * 5 + 4] = callback->attributes[i * 5 + 3] + len;
         }
 
-        m_callbacks.append(callback.release());
+        m_callbacks.append(std::move(callback));
     }
 
     void appendEndElementNSCallback()
     {
-        m_callbacks.append(adoptPtr(new PendingEndElementNSCallback));
+        m_callbacks.append(std::make_unique<PendingEndElementNSCallback>());
     }
 
     void appendCharactersCallback(const xmlChar* s, int len)
     {
-        OwnPtr<PendingCharactersCallback> callback = adoptPtr(new PendingCharactersCallback);
+        auto callback = std::make_unique<PendingCharactersCallback>();
 
         callback->s = xmlStrndup(s, len);
         callback->len = len;
 
-        m_callbacks.append(callback.release());
+        m_callbacks.append(std::move(callback));
     }
 
     void appendProcessingInstructionCallback(const xmlChar* target, const xmlChar* data)
     {
-        OwnPtr<PendingProcessingInstructionCallback> callback = adoptPtr(new PendingProcessingInstructionCallback);
+        auto callback = std::make_unique<PendingProcessingInstructionCallback>();
 
         callback->target = xmlStrdup(target);
         callback->data = ""
 
-        m_callbacks.append(callback.release());
+        m_callbacks.append(std::move(callback));
     }
 
     void appendCDATABlockCallback(const xmlChar* s, int len)
     {
-        OwnPtr<PendingCDATABlockCallback> callback = adoptPtr(new PendingCDATABlockCallback);
+        auto callback = std::make_unique<PendingCDATABlockCallback>();
 
         callback->s = xmlStrndup(s, len);
         callback->len = len;
 
-        m_callbacks.append(callback.release());
+        m_callbacks.append(std::move(callback));
     }
 
     void appendCommentCallback(const xmlChar* s)
     {
-        OwnPtr<PendingCommentCallback> callback = adoptPtr(new PendingCommentCallback);
+        auto callback = std::make_unique<PendingCommentCallback>();
 
         callback->s = xmlStrdup(s);
 
-        m_callbacks.append(callback.release());
+        m_callbacks.append(std::move(callback));
     }
 
     void appendInternalSubsetCallback(const xmlChar* name, const xmlChar* externalID, const xmlChar* systemID)
     {
-        OwnPtr<PendingInternalSubsetCallback> callback = adoptPtr(new PendingInternalSubsetCallback);
+        auto callback = std::make_unique<PendingInternalSubsetCallback>();
 
         callback->name = xmlStrdup(name);
         callback->externalID = xmlStrdup(externalID);
         callback->systemID = xmlStrdup(systemID);
 
-        m_callbacks.append(callback.release());
+        m_callbacks.append(std::move(callback));
     }
 
     void appendErrorCallback(XMLErrors::ErrorType type, const xmlChar* message, OrdinalNumber lineNumber, OrdinalNumber columnNumber)
     {
-        OwnPtr<PendingErrorCallback> callback = adoptPtr(new PendingErrorCallback);
+        auto callback = std::make_unique<PendingErrorCallback>();
 
         callback->message = xmlStrdup(message);
         callback->type = type;
         callback->lineNumber = lineNumber;
         callback->columnNumber = columnNumber;
 
-        m_callbacks.append(callback.release());
+        m_callbacks.append(std::move(callback));
     }
 
     void callAndRemoveFirstCallback(XMLDocumentParser* parser)
     {
-        OwnPtr<PendingCallback> callback = m_callbacks.takeFirst();
+        std::unique_ptr<PendingCallback> callback = m_callbacks.takeFirst();
         callback->call(parser);
     }
 
     bool isEmpty() const { return m_callbacks.isEmpty(); }
 
 private:
-    PendingCallbacks() { }
-
     struct PendingCallback {
         virtual ~PendingCallback() { }
         virtual void call(XMLDocumentParser* parser) = 0;
@@ -352,7 +347,7 @@
         OrdinalNumber columnNumber;
     };
 
-    Deque<OwnPtr<PendingCallback>> m_callbacks;
+    Deque<std::unique_ptr<PendingCallback>> m_callbacks;
 };
 // --------------------------------
 
@@ -578,7 +573,7 @@
     : ScriptableDocumentParser(document)
     , m_view(frameView)
     , m_context(0)
-    , m_pendingCallbacks(PendingCallbacks::create())
+    , m_pendingCallbacks(std::make_unique<PendingCallbacks>())
     , m_depthTriggeringEntityExpansion(-1)
     , m_isParsingEntityDeclaration(false)
     , m_currentNode(&document)
@@ -600,7 +595,7 @@
     : ScriptableDocumentParser(fragment.document(), parserContentPolicy)
     , m_view(0)
     , m_context(0)
-    , m_pendingCallbacks(PendingCallbacks::create())
+    , m_pendingCallbacks(std::make_unique<PendingCallbacks>())
     , m_depthTriggeringEntityExpansion(-1)
     , m_isParsingEntityDeclaration(false)
     , m_currentNode(&fragment)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to