Reduce PassRefPtr uses in dom - 4
authorgyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jan 2016 06:13:09 +0000 (06:13 +0000)
committergyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jan 2016 06:13:09 +0000 (06:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153270

Reviewed by Darin Adler.

As a step to remove PassRefPtr uses, this patch reduces the uses in WebCore/dom.

Source/WebCore:

* bindings/js/JSDeviceMotionEventCustom.cpp:
(WebCore::JSDeviceMotionEvent::initDeviceMotionEvent):
* dom/DeviceMotionData.cpp:
(WebCore::DeviceMotionData::create):
(WebCore::DeviceMotionData::DeviceMotionData):
* dom/DeviceMotionData.h:
* dom/Document.cpp:
(WebCore::Document::setBodyOrFrameset):
(WebCore::Document::setFocusedElement):
(WebCore::Document::setDecoder):
(WebCore::Document::pushCurrentScript):
* dom/Document.h:
* dom/Event.cpp:
(WebCore::Event::cloneFor):
* dom/Event.h:
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::cloneFor):
* dom/MouseEvent.h:
* dom/NodeIterator.cpp:
(WebCore::NodeIterator::NodePointer::NodePointer):
(WebCore::NodeIterator::NodeIterator):
* dom/NodeIterator.h:
(WebCore::NodeIterator::create):
* html/RadioInputType.cpp:
(WebCore::RadioInputType::handleKeydownEvent):
* platform/ios/DeviceMotionClientIOS.mm:
(WebCore::DeviceMotionClientIOS::motionChanged):
* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::createDocumentFromSource):

Source/WebKit/win:

* Plugins/PluginView.cpp:
(WebCore::PluginView::focusPluginElement):

Source/WebKit2:

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::focusPluginElement):

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

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp
Source/WebCore/dom/DeviceMotionData.cpp
Source/WebCore/dom/DeviceMotionData.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/Event.h
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseEvent.h
Source/WebCore/dom/NodeIterator.cpp
Source/WebCore/dom/NodeIterator.h
Source/WebCore/html/RadioInputType.cpp
Source/WebCore/platform/ios/DeviceMotionClientIOS.mm
Source/WebCore/xml/XSLTProcessor.cpp
Source/WebKit/win/ChangeLog
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PluginView.cpp

index 8c12a0c..486c49a 100644 (file)
@@ -1,3 +1,42 @@
+2016-01-24  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Reduce PassRefPtr uses in dom - 4
+        https://bugs.webkit.org/show_bug.cgi?id=153270
+
+        Reviewed by Darin Adler.
+
+        As a step to remove PassRefPtr uses, this patch reduces the uses in WebCore/dom.
+
+        * bindings/js/JSDeviceMotionEventCustom.cpp:
+        (WebCore::JSDeviceMotionEvent::initDeviceMotionEvent):
+        * dom/DeviceMotionData.cpp:
+        (WebCore::DeviceMotionData::create):
+        (WebCore::DeviceMotionData::DeviceMotionData):
+        * dom/DeviceMotionData.h:
+        * dom/Document.cpp:
+        (WebCore::Document::setBodyOrFrameset):
+        (WebCore::Document::setFocusedElement):
+        (WebCore::Document::setDecoder):
+        (WebCore::Document::pushCurrentScript):
+        * dom/Document.h:
+        * dom/Event.cpp:
+        (WebCore::Event::cloneFor):
+        * dom/Event.h:
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEvent::cloneFor):
+        * dom/MouseEvent.h:
+        * dom/NodeIterator.cpp:
+        (WebCore::NodeIterator::NodePointer::NodePointer):
+        (WebCore::NodeIterator::NodeIterator):
+        * dom/NodeIterator.h:
+        (WebCore::NodeIterator::create):
+        * html/RadioInputType.cpp:
+        (WebCore::RadioInputType::handleKeydownEvent):
+        * platform/ios/DeviceMotionClientIOS.mm:
+        (WebCore::DeviceMotionClientIOS::motionChanged):
+        * xml/XSLTProcessor.cpp:
+        (WebCore::XSLTProcessor::createDocumentFromSource):
+
 2016-01-24  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [Font Loading] General cleanup
index 73762ca..e8399a5 100644 (file)
@@ -188,8 +188,8 @@ JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState& state)
 
     bool intervalProvided = !state.argument(6).isUndefinedOrNull();
     double interval = state.argument(6).toNumber(&state);
-    RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
-    wrapped().initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get());
+    auto deviceMotionData = DeviceMotionData::create(WTFMove(acceleration), WTFMove(accelerationIncludingGravity), WTFMove(rotationRate), intervalProvided, interval);
+    wrapped().initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.ptr());
     return jsUndefined();
 }
 
index 83ac253..8717b66 100644 (file)
@@ -68,10 +68,9 @@ Ref<DeviceMotionData> DeviceMotionData::create()
     return adoptRef(*new DeviceMotionData);
 }
 
-Ref<DeviceMotionData> DeviceMotionData::create(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
-                                               PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval)
+Ref<DeviceMotionData> DeviceMotionData::create(RefPtr<Acceleration>&& acceleration, RefPtr<Acceleration>&& accelerationIncludingGravity, RefPtr<RotationRate>&& rotationRate, bool canProvideInterval, double interval)
 {
-    return adoptRef(*new DeviceMotionData(acceleration, accelerationIncludingGravity, rotationRate, canProvideInterval, interval));
+    return adoptRef(*new DeviceMotionData(WTFMove(acceleration), WTFMove(accelerationIncludingGravity), WTFMove(rotationRate), canProvideInterval, interval));
 }
 
 DeviceMotionData::DeviceMotionData()
@@ -80,11 +79,10 @@ DeviceMotionData::DeviceMotionData()
 {
 }
 
-DeviceMotionData::DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
-                                   PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval)
-    : m_acceleration(acceleration)
-    , m_accelerationIncludingGravity(accelerationIncludingGravity)
-    , m_rotationRate(rotationRate)
+DeviceMotionData::DeviceMotionData(RefPtr<Acceleration>&& acceleration, RefPtr<Acceleration>&& accelerationIncludingGravity, RefPtr<RotationRate>&& rotationRate, bool canProvideInterval, double interval)
+    : m_acceleration(WTFMove(acceleration))
+    , m_accelerationIncludingGravity(WTFMove(accelerationIncludingGravity))
+    , m_rotationRate(WTFMove(rotationRate))
     , m_canProvideInterval(canProvideInterval)
     , m_interval(interval)
 {
index d5f2773..1e77e21 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef DeviceMotionData_h
 #define DeviceMotionData_h
 
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
@@ -83,8 +82,7 @@ public:
     };
 
     WEBCORE_EXPORT static Ref<DeviceMotionData> create();
-    WEBCORE_EXPORT static Ref<DeviceMotionData> create(PassRefPtr<Acceleration>, PassRefPtr<Acceleration> accelerationIncludingGravity,
-                                        PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval);
+    WEBCORE_EXPORT static Ref<DeviceMotionData> create(RefPtr<Acceleration>&&, RefPtr<Acceleration>&& accelerationIncludingGravity, RefPtr<RotationRate>&&, bool canProvideInterval, double interval);
 
     const Acceleration* acceleration() const { return m_acceleration.get(); }
     const Acceleration* accelerationIncludingGravity() const { return m_accelerationIncludingGravity.get(); }
@@ -94,8 +92,7 @@ public:
 
 private:
     DeviceMotionData();
-    DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
-                     PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval);
+    DeviceMotionData(RefPtr<Acceleration>&&, RefPtr<Acceleration>&& accelerationIncludingGravity, RefPtr<RotationRate>&&, bool canProvideInterval, double interval);
 
     RefPtr<Acceleration> m_acceleration;
     RefPtr<Acceleration> m_accelerationIncludingGravity;
index 5d24705..756d892 100644 (file)
@@ -2586,10 +2586,8 @@ HTMLElement* Document::bodyOrFrameset() const
     return nullptr;
 }
 
-void Document::setBodyOrFrameset(PassRefPtr<HTMLElement> prpNewBody, ExceptionCode& ec)
+void Document::setBodyOrFrameset(RefPtr<HTMLElement>&& newBody, ExceptionCode& ec)
 {
-    RefPtr<HTMLElement> newBody = prpNewBody;
-
     // FIXME: This does not support setting a <frameset> Element, only a <body>. This does
     // not match the HTML specification:
     // https://html.spec.whatwg.org/multipage/dom.html#dom-document-body
@@ -3764,10 +3762,9 @@ void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions)
 }
 #endif
 
-bool Document::setFocusedElement(PassRefPtr<Element> prpNewFocusedElement, FocusDirection direction)
+bool Document::setFocusedElement(Element* element, FocusDirection direction)
 {
-    RefPtr<Element> newFocusedElement = prpNewFocusedElement;
-
+    RefPtr<Element> newFocusedElement = element;
     // Make sure newFocusedElement is actually in this document
     if (newFocusedElement && (&newFocusedElement->document() != this))
         return true;
@@ -4572,9 +4569,9 @@ bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S
     return true;
 }
 
-void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder)
+void Document::setDecoder(RefPtr<TextResourceDecoder>&& decoder)
 {
-    m_decoder = decoder;
+    m_decoder = WTFMove(decoder);
 }
 
 URL Document::completeURL(const String& url, const URL& baseURLOverride) const
@@ -4841,7 +4838,7 @@ String Document::queryCommandValue(const String& commandName)
     return command(this, commandName).value();
 }
 
-void Document::pushCurrentScript(PassRefPtr<HTMLScriptElement> newCurrentScript)
+void Document::pushCurrentScript(HTMLScriptElement* newCurrentScript)
 {
     ASSERT(newCurrentScript);
     m_currentScriptStack.append(newCurrentScript);
index 4fda9a7..3d1c794 100644 (file)
@@ -733,7 +733,7 @@ public:
     String selectedStylesheetSet() const;
     void setSelectedStylesheetSet(const String&);
 
-    WEBCORE_EXPORT bool setFocusedElement(PassRefPtr<Element>, FocusDirection = FocusDirectionNone);
+    WEBCORE_EXPORT bool setFocusedElement(Element*, FocusDirection = FocusDirectionNone);
     Element* focusedElement() const { return m_focusedElement.get(); }
     UserActionElementSet& userActionElements()  { return m_userActionElements; }
     const UserActionElementSet& userActionElements() const { return m_userActionElements; }
@@ -924,7 +924,7 @@ public:
 
     HTMLBodyElement* body() const;
     WEBCORE_EXPORT HTMLElement* bodyOrFrameset() const;
-    void setBodyOrFrameset(PassRefPtr<HTMLElement>, ExceptionCode&);
+    void setBodyOrFrameset(RefPtr<HTMLElement>&&, ExceptionCode&);
 
     Location* location() const;
 
@@ -957,7 +957,7 @@ public:
     JSModuleLoader* moduleLoader() { return m_moduleLoader.get(); }
 
     HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : nullptr; }
-    void pushCurrentScript(PassRefPtr<HTMLScriptElement>);
+    void pushCurrentScript(HTMLScriptElement*);
     void popCurrentScript();
 
 #if ENABLE(XSLT)
@@ -1056,7 +1056,7 @@ public:
     WEBCORE_EXPORT void setShouldCreateRenderers(bool);
     bool shouldCreateRenderers();
 
-    void setDecoder(PassRefPtr<TextResourceDecoder>);
+    void setDecoder(RefPtr<TextResourceDecoder>&&);
     TextResourceDecoder* decoder() const { return m_decoder.get(); }
 
     WEBCORE_EXPORT String displayStringModifiedByEncoding(const String&) const;
index ac565fb..149b04e 100644 (file)
@@ -157,7 +157,7 @@ bool Event::isWheelEvent() const
     return false;
 }
 
-PassRefPtr<Event> Event::cloneFor(HTMLIFrameElement*) const
+Ref<Event> Event::cloneFor(HTMLIFrameElement*) const
 {
     return Event::create(type(), bubbles(), cancelable());
 }
index 7305f60..a139871 100644 (file)
@@ -179,7 +179,7 @@ public:
 
     bool isBeingDispatched() const { return eventPhase(); }
 
-    virtual PassRefPtr<Event> cloneFor(HTMLIFrameElement*) const;
+    virtual Ref<Event> cloneFor(HTMLIFrameElement*) const;
 
     virtual EventTarget* relatedTarget() const { return nullptr; }
 
index 78a922d..950a4b3 100644 (file)
@@ -237,10 +237,10 @@ inline static int adjustedClientY(int innerClientY, HTMLIFrameElement* iframe, F
     return iframe->offsetTop() - frameView->scrollY() + innerClientY;
 }
 
-PassRefPtr<Event> MouseEvent::cloneFor(HTMLIFrameElement* iframe) const
+Ref<Event> MouseEvent::cloneFor(HTMLIFrameElement* iframe) const
 {
     ASSERT(iframe);
-    RefPtr<MouseEvent> clonedMouseEvent = MouseEvent::create();
+    Ref<MouseEvent> clonedMouseEvent = MouseEvent::create();
     Frame* frame = iframe->document().frame();
     FrameView* frameView = frame ? frame->view() : nullptr;
     clonedMouseEvent->initMouseEvent(type(), bubbles(), cancelable(),
@@ -253,7 +253,7 @@ PassRefPtr<Event> MouseEvent::cloneFor(HTMLIFrameElement* iframe) const
         // Nullifies relatedTarget.
         0);
     clonedMouseEvent->setForce(force());
-    return clonedMouseEvent.release();
+    return WTFMove(clonedMouseEvent);
 }
 
 Ref<SimulatedMouseEvent> SimulatedMouseEvent::create(const AtomicString& eventType, AbstractView* view, PassRefPtr<Event> underlyingEvent, Element* target)
index 00787cb..633a1ad 100644 (file)
@@ -104,7 +104,7 @@ public:
 
     virtual int which() const override;
 
-    virtual PassRefPtr<Event> cloneFor(HTMLIFrameElement*) const override;
+    virtual Ref<Event> cloneFor(HTMLIFrameElement*) const override;
 
 protected:
     MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, AbstractView*,
index a79f55d..86dbd0f 100644 (file)
@@ -37,7 +37,7 @@ NodeIterator::NodePointer::NodePointer()
 {
 }
 
-NodeIterator::NodePointer::NodePointer(PassRefPtr<Node> n, bool b)
+NodeIterator::NodePointer::NodePointer(Node* n, bool b)
     : node(n)
     , isPointerBeforeNode(b)
 {
@@ -76,7 +76,7 @@ bool NodeIterator::NodePointer::moveToPrevious(Node* root)
     return node;
 }
 
-NodeIterator::NodeIterator(PassRefPtr<Node> rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
+NodeIterator::NodeIterator(Node* rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
     : NodeIteratorBase(*rootNode, whatToShow, WTFMove(filter))
     , m_referenceNode(root(), true)
 {
index 5c42230..8bfdf6b 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 
     class NodeIterator : public ScriptWrappable, public RefCounted<NodeIterator>, public NodeIteratorBase {
     public:
-        static Ref<NodeIterator> create(PassRefPtr<Node> rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
+        static Ref<NodeIterator> create(Node* rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
         {
             return adoptRef(*new NodeIterator(rootNode, whatToShow, WTFMove(filter)));
         }
@@ -54,13 +54,13 @@ namespace WebCore {
         void nodeWillBeRemoved(Node&);
 
     private:
-        NodeIterator(PassRefPtr<Node>, unsigned long whatToShow, RefPtr<NodeFilter>&&);
+        NodeIterator(Node*, unsigned long whatToShow, RefPtr<NodeFilter>&&);
 
         struct NodePointer {
             RefPtr<Node> node;
             bool isPointerBeforeNode;
             NodePointer();
-            NodePointer(PassRefPtr<Node>, bool);
+            NodePointer(Node*, bool);
             void clear();
             bool moveToNext(Node* root);
             bool moveToPrevious(Node* root);
index 8f276e7..67877ce 100644 (file)
@@ -90,7 +90,7 @@ void RadioInputType::handleKeydownEvent(KeyboardEvent* event)
         if (inputElement->form() != element().form())
             break;
         if (inputElement->isRadioButton() && inputElement->name() == element().name() && inputElement->isFocusable()) {
-            element().document().setFocusedElement(inputElement);
+            element().document().setFocusedElement(inputElement.get());
             inputElement->dispatchSimulatedClick(event, SendNoEvents, DoNotShowPressedLook);
             event->setDefaultHandled();
             return;
index 82ce91a..6c92f41 100644 (file)
@@ -120,7 +120,7 @@ void DeviceMotionClientIOS::motionChanged(double xAcceleration, double yAccelera
     }
 #endif // PLATFORM(IOS_SIMULATOR)
 
-    m_currentDeviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, true, kMotionUpdateInterval);
+    m_currentDeviceMotionData = DeviceMotionData::create(WTFMove(acceleration), WTFMove(accelerationIncludingGravity), WTFMove(rotationRate), true, kMotionUpdateInterval);
     m_controller->didChangeDeviceMotion(m_currentDeviceMotionData.get());
 }
 
index 907e9c7..db6f9ac 100644 (file)
@@ -103,7 +103,7 @@ Ref<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString
 
     RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(sourceMIMEType);
     decoder->setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : TextEncoding(sourceEncoding), TextResourceDecoder::EncodingFromXMLHeader);
-    result->setDecoder(decoder.release());
+    result->setDecoder(WTFMove(decoder));
 
     result->setContent(documentSource);
 
index fbc6b0f..8178f27 100644 (file)
@@ -1,3 +1,15 @@
+2016-01-24  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Reduce PassRefPtr uses in dom - 4
+        https://bugs.webkit.org/show_bug.cgi?id=153270
+
+        Reviewed by Darin Adler.
+
+        As a step to remove PassRefPtr uses, this patch reduces the uses in WebCore/dom.
+
+        * Plugins/PluginView.cpp:
+        (WebCore::PluginView::focusPluginElement):
+
 2016-01-17  Ada Chan  <adachan@apple.com>
 
         Add a mode parameter to MediaControllerInterface::supportsFullscreen() and ChromeClient::supportsVideoFullscreen().
index 16463e6..50cff1c 100644 (file)
@@ -1,3 +1,15 @@
+2016-01-24  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Reduce PassRefPtr uses in dom - 4
+        https://bugs.webkit.org/show_bug.cgi?id=153270
+
+        Reviewed by Darin Adler.
+
+        As a step to remove PassRefPtr uses, this patch reduces the uses in WebCore/dom.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::focusPluginElement):
+
 2016-01-23  Alex Christensen  <achristensen@webkit.org>
 
         CMake build fix after r195494.
index 63bbe60..c5834bf 100644 (file)
@@ -1151,7 +1151,7 @@ void PluginView::focusPluginElement()
     if (Page* page = frame()->page())
         page->focusController().setFocusedElement(m_pluginElement.get(), frame());
     else
-        frame()->document()->setFocusedElement(m_pluginElement);
+        frame()->document()->setFocusedElement(m_pluginElement.get());
 }
 
 void PluginView::pendingURLRequestsTimerFired()