Changeset 195927 in webkit


Ignore:
Timestamp:
Jan 31, 2016 4:08:32 AM (8 years ago)
Author:
Gyuyoung Kim
Message:

Reduce PassRefPtr uses in dom - 5
https://bugs.webkit.org/show_bug.cgi?id=153470

Reviewed by Darin Adler.

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

  • dom/Document.cpp:

(WebCore::Document::adoptNode):
(WebCore::Document::implicitClose):
(WebCore::Document::enqueuePopstateEvent):
(WebCore::Document::setInputCursor):

  • dom/Document.h:
  • dom/DocumentMarker.cpp:

(WebCore::DocumentMarkerTextMatch::instanceFor):

  • dom/Event.cpp:

(WebCore::Event::setUnderlyingEvent):

  • dom/Event.h:
  • dom/EventDispatcher.h:
  • dom/GenericEventQueue.cpp:

(WebCore::GenericEventQueue::enqueueEvent):

  • dom/GenericEventQueue.h:
  • dom/MouseEvent.cpp:

(WebCore::SimulatedMouseEvent::SimulatedMouseEvent):

  • dom/Node.cpp:

(WebCore::Node::dispatchDOMActivateEvent):

  • dom/NodeIterator.h:
  • dom/PendingScript.h:
  • dom/PopStateEvent.cpp:

(WebCore::PopStateEvent::create):

  • dom/PopStateEvent.h:
  • dom/ProcessingInstruction.cpp:

(WebCore::ProcessingInstruction::setCSSStyleSheet): Deleted. Nobody calls this function.

  • dom/ProcessingInstruction.h:
  • dom/RangeBoundaryPoint.h:

(WebCore::RangeBoundaryPoint::RangeBoundaryPoint):

  • dom/TextEvent.cpp:

(WebCore::TextEvent::createForFragmentPaste):
(WebCore::TextEvent::TextEvent):

  • dom/TextEvent.h:
  • editing/Editor.cpp:

(WebCore::Editor::pasteAsFragment):

  • editing/Editor.h:
  • editing/mac/EditorMac.mm:

(WebCore::Editor::replaceNodeFromPasteboard):

Location:
trunk/Source
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195925 r195927  
     12016-01-31  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
     2
     3        Reduce PassRefPtr uses in dom - 5
     4        https://bugs.webkit.org/show_bug.cgi?id=153470
     5
     6        Reviewed by Darin Adler.
     7
     8        As a step to remove PassRefPtr, this patch reduces uses of PassRefPtr in WebCore/dom.
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::adoptNode):
     12        (WebCore::Document::implicitClose):
     13        (WebCore::Document::enqueuePopstateEvent):
     14        (WebCore::Document::setInputCursor):
     15        * dom/Document.h:
     16        * dom/DocumentMarker.cpp:
     17        (WebCore::DocumentMarkerTextMatch::instanceFor):
     18        * dom/Event.cpp:
     19        (WebCore::Event::setUnderlyingEvent):
     20        * dom/Event.h:
     21        * dom/EventDispatcher.h:
     22        * dom/GenericEventQueue.cpp:
     23        (WebCore::GenericEventQueue::enqueueEvent):
     24        * dom/GenericEventQueue.h:
     25        * dom/MouseEvent.cpp:
     26        (WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
     27        * dom/Node.cpp:
     28        (WebCore::Node::dispatchDOMActivateEvent):
     29        * dom/NodeIterator.h:
     30        * dom/PendingScript.h:
     31        * dom/PopStateEvent.cpp:
     32        (WebCore::PopStateEvent::create):
     33        * dom/PopStateEvent.h:
     34        * dom/ProcessingInstruction.cpp:
     35        (WebCore::ProcessingInstruction::setCSSStyleSheet): Deleted. Nobody calls this function.
     36        * dom/ProcessingInstruction.h:
     37        * dom/RangeBoundaryPoint.h:
     38        (WebCore::RangeBoundaryPoint::RangeBoundaryPoint):
     39        * dom/TextEvent.cpp:
     40        (WebCore::TextEvent::createForFragmentPaste):
     41        (WebCore::TextEvent::TextEvent):
     42        * dom/TextEvent.h:
     43        * editing/Editor.cpp:
     44        (WebCore::Editor::pasteAsFragment):
     45        * editing/Editor.h:
     46        * editing/mac/EditorMac.mm:
     47        (WebCore::Editor::replaceNodeFromPasteboard):
     48
    1492016-01-31  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
    250
  • trunk/Source/WebCore/dom/Document.cpp

    r195790 r195927  
    10061006
    10071007
    1008 RefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionCode& ec)
     1008RefPtr<Node> Document::adoptNode(Node* source, ExceptionCode& ec)
    10091009{
    10101010    if (!source) {
     
    10451045    }
    10461046
    1047     adoptIfNeeded(source.get());
     1047    adoptIfNeeded(source);
    10481048
    10491049    return source;
     
    27322732    enqueuePageshowEvent(PageshowEventNotPersisted);
    27332733    if (m_pendingStateObject)
    2734         enqueuePopstateEvent(m_pendingStateObject.release());
    2735    
     2734        enqueuePopstateEvent(WTFMove(m_pendingStateObject));
     2735
    27362736    if (f)
    27372737        f->loader().dispatchOnloadEvents();
     
    55515551}
    55525552
    5553 void Document::enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject)
    5554 {
    5555     enqueueWindowEvent(PopStateEvent::create(stateObject, m_domWindow ? m_domWindow->history() : nullptr));
     5553void Document::enqueuePopstateEvent(RefPtr<SerializedScriptValue>&& stateObject)
     5554{
     5555    enqueueWindowEvent(PopStateEvent::create(WTFMove(stateObject), m_domWindow ? m_domWindow->history() : nullptr));
    55565556}
    55575557
     
    68316831void Document::setInputCursor(PassRefPtr<InputCursor> cursor)
    68326832{
    6833     m_inputCursor = cursor;
     6833    m_inputCursor = WTFMove(cursor);
    68346834}
    68356835#endif
  • trunk/Source/WebCore/dom/Document.h

    r195917 r195927  
    467467#endif
    468468
    469     RefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
     469    RefPtr<Node> adoptNode(Node* source, ExceptionCode&);
    470470
    471471    Ref<HTMLCollection> images();
     
    11011101    void enqueuePageshowEvent(PageshowEventPersistence);
    11021102    void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
    1103     void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
     1103    void enqueuePopstateEvent(RefPtr<SerializedScriptValue>&& stateObject);
    11041104    virtual DocumentEventQueue& eventQueue() const override final { return m_eventQueue; }
    11051105
  • trunk/Source/WebCore/dom/DocumentMarker.cpp

    r177733 r195927  
    3838}
    3939
    40 class DocumentMarkerDescription : public DocumentMarkerDetails {
     40class DocumentMarkerDescription final : public DocumentMarkerDetails {
    4141public:
    4242    static Ref<DocumentMarkerDescription> create(const String&);
  • trunk/Source/WebCore/dom/Event.cpp

    r195524 r195927  
    177177}
    178178
    179 void Event::setUnderlyingEvent(PassRefPtr<Event> ue)
     179void Event::setUnderlyingEvent(Event* underlyingEvent)
    180180{
    181181    // Prohibit creation of a cycle -- just do nothing in that case.
    182     for (Event* e = ue.get(); e; e = e->underlyingEvent())
    183         if (e == this)
     182    for (Event* event = underlyingEvent; event; event = event->underlyingEvent()) {
     183        if (event == this)
    184184            return;
    185     m_underlyingEvent = ue;
     185    }
     186    m_underlyingEvent = underlyingEvent;
    186187}
    187188
  • trunk/Source/WebCore/dom/Event.h

    r195524 r195927  
    174174
    175175    Event* underlyingEvent() const { return m_underlyingEvent.get(); }
    176     void setUnderlyingEvent(PassRefPtr<Event>);
     176    void setUnderlyingEvent(Event*);
    177177
    178178    virtual DataTransfer* internalDataTransfer() const { return 0; }
  • trunk/Source/WebCore/dom/EventDispatcher.h

    r192354 r195927  
    2929#include "SimulatedClickOptions.h"
    3030#include <wtf/Forward.h>
    31 #include <wtf/PassRefPtr.h>
    3231
    3332namespace WebCore {
  • trunk/Source/WebCore/dom/GenericEventQueue.cpp

    r192354 r195927  
    4646}
    4747
    48 void GenericEventQueue::enqueueEvent(PassRefPtr<Event> event)
     48void GenericEventQueue::enqueueEvent(RefPtr<Event>&& event)
    4949{
    5050    if (m_isClosed)
     
    5454        event->setTarget(nullptr);
    5555
    56     m_pendingEvents.append(event);
     56    m_pendingEvents.append(WTFMove(event));
    5757
    5858    if (m_isSuspended)
  • trunk/Source/WebCore/dom/GenericEventQueue.h

    r187031 r195927  
    4343    ~GenericEventQueue();
    4444
    45     void enqueueEvent(PassRefPtr<Event>);
     45    void enqueueEvent(RefPtr<Event>&&);
    4646    void close();
    4747
  • trunk/Source/WebCore/dom/MouseEvent.cpp

    r195524 r195927  
    279279        m_metaKey = keyStateEvent->metaKey();
    280280    }
    281     setUnderlyingEvent(underlyingEvent);
     281    setUnderlyingEvent(underlyingEvent.get());
    282282
    283283    if (is<MouseEvent>(this->underlyingEvent())) {
  • trunk/Source/WebCore/dom/Node.cpp

    r195355 r195927  
    21292129    ASSERT_WITH_SECURITY_IMPLICATION(!NoEventDispatchAssertion::isEventDispatchForbidden());
    21302130    Ref<UIEvent> event = UIEvent::create(eventNames().DOMActivateEvent, true, true, document().defaultView(), detail);
    2131     event->setUnderlyingEvent(underlyingEvent);
     2131    event->setUnderlyingEvent(underlyingEvent.get());
    21322132    dispatchScopedEvent(event);
    21332133    return event->defaultHandled();
  • trunk/Source/WebCore/dom/NodeIterator.h

    r195524 r195927  
    2929#include "ScriptWrappable.h"
    3030#include "Traversal.h"
    31 #include <wtf/PassRefPtr.h>
    3231#include <wtf/RefCounted.h>
    3332
  • trunk/Source/WebCore/dom/PendingScript.h

    r195243 r195927  
    3030#include "CachedResourceHandle.h"
    3131#include <wtf/text/TextPosition.h>
    32 #include <wtf/PassRefPtr.h>
    3332#include <wtf/RefPtr.h>
    3433
  • trunk/Source/WebCore/dom/PopStateEvent.cpp

    r191955 r195927  
    6565}
    6666
    67 Ref<PopStateEvent> PopStateEvent::create(PassRefPtr<SerializedScriptValue> serializedState, PassRefPtr<History> history)
     67Ref<PopStateEvent> PopStateEvent::create(RefPtr<SerializedScriptValue>&& serializedState, PassRefPtr<History> history)
    6868{
    69     return adoptRef(*new PopStateEvent(serializedState, history));
     69    return adoptRef(*new PopStateEvent(WTFMove(serializedState), history));
    7070}
    7171
  • trunk/Source/WebCore/dom/PopStateEvent.h

    r186955 r195927  
    4747    virtual ~PopStateEvent();
    4848    static Ref<PopStateEvent> create();
    49     static Ref<PopStateEvent> create(PassRefPtr<SerializedScriptValue>, PassRefPtr<History>);
     49    static Ref<PopStateEvent> create(RefPtr<SerializedScriptValue>&&, PassRefPtr<History>);
    5050    static Ref<PopStateEvent> create(const AtomicString&, const PopStateEventInit&);
    5151
  • trunk/Source/WebCore/dom/ProcessingInstruction.cpp

    r194496 r195927  
    237237}
    238238
    239 void ProcessingInstruction::setCSSStyleSheet(PassRefPtr<CSSStyleSheet> sheet)
    240 {
    241     ASSERT(!m_cachedSheet);
    242     ASSERT(!m_loading);
    243     m_sheet = sheet;
    244     sheet->setTitle(m_title);
    245     sheet->setDisabled(m_alternate);
    246 }
    247 
    248239void ProcessingInstruction::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
    249240{
  • trunk/Source/WebCore/dom/ProcessingInstruction.h

    r191955 r195927  
    4646    const String& localHref() const { return m_localHref; }
    4747    StyleSheet* sheet() const { return m_sheet.get(); }
    48     void setCSSStyleSheet(PassRefPtr<CSSStyleSheet>);
    4948
    5049    bool isCSS() const { return m_isCSS; }
  • trunk/Source/WebCore/dom/RangeBoundaryPoint.h

    r195281 r195927  
    3434class RangeBoundaryPoint {
    3535public:
    36     explicit RangeBoundaryPoint(PassRefPtr<Node> container);
     36    explicit RangeBoundaryPoint(Node* container);
    3737
    3838    explicit RangeBoundaryPoint(const RangeBoundaryPoint&);
     
    6666};
    6767
    68 inline RangeBoundaryPoint::RangeBoundaryPoint(PassRefPtr<Node> container)
     68inline RangeBoundaryPoint::RangeBoundaryPoint(Node* container)
    6969    : m_containerNode(container)
    7070{
  • trunk/Source/WebCore/dom/TextEvent.cpp

    r194896 r195927  
    4848}
    4949
    50 Ref<TextEvent> TextEvent::createForFragmentPaste(AbstractView* view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
     50Ref<TextEvent> TextEvent::createForFragmentPaste(AbstractView* view, RefPtr<DocumentFragment>&& data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
    5151{
    52     return adoptRef(*new TextEvent(view, "", data, shouldSmartReplace, shouldMatchStyle, mailBlockquoteHandling));
     52    return adoptRef(*new TextEvent(view, emptyString(), WTFMove(data), shouldSmartReplace, shouldMatchStyle, mailBlockquoteHandling));
    5353}
    5454
     
    8181}
    8282
    83 TextEvent::TextEvent(AbstractView* view, const String& data, PassRefPtr<DocumentFragment> pastingFragment, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
     83TextEvent::TextEvent(AbstractView* view, const String& data, RefPtr<DocumentFragment>&& pastingFragment, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
    8484    : UIEvent(eventNames().textInputEvent, true, true, view, 0)
    8585    , m_inputType(TextEventInputPaste)
    8686    , m_data(data)
    87     , m_pastingFragment(pastingFragment)
     87    , m_pastingFragment(WTFMove(pastingFragment))
    8888    , m_shouldSmartReplace(shouldSmartReplace)
    8989    , m_shouldMatchStyle(shouldMatchStyle)
  • trunk/Source/WebCore/dom/TextEvent.h

    r194896 r195927  
    4444        static Ref<TextEvent> create(AbstractView*, const String& data, TextEventInputType = TextEventInputKeyboard);
    4545        static Ref<TextEvent> createForPlainTextPaste(AbstractView*, const String& data, bool shouldSmartReplace);
    46         static Ref<TextEvent> createForFragmentPaste(AbstractView*, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
     46        static Ref<TextEvent> createForFragmentPaste(AbstractView*, RefPtr<DocumentFragment>&& data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
    4747        static Ref<TextEvent> createForDrop(AbstractView*, const String& data);
    4848        static Ref<TextEvent> createForDictation(AbstractView*, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
     
    7373
    7474        TextEvent(AbstractView*, const String& data, TextEventInputType = TextEventInputKeyboard);
    75         TextEvent(AbstractView*, const String& data, PassRefPtr<DocumentFragment>, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
     75        TextEvent(AbstractView*, const String& data, RefPtr<DocumentFragment>&&, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
    7676        TextEvent(AbstractView*, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
    7777
  • trunk/Source/WebCore/editing/Editor.cpp

    r195547 r195927  
    465465}
    466466
    467 void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool smartReplace, bool matchStyle, MailBlockquoteHandling respectsMailBlockquote)
     467void Editor::pasteAsFragment(Ref<DocumentFragment>&& pastingFragment, bool smartReplace, bool matchStyle, MailBlockquoteHandling respectsMailBlockquote)
    468468{
    469469    Node* target = findEventTargetFromSelection();
    470470    if (!target)
    471471        return;
    472     target->dispatchEvent(TextEvent::createForFragmentPaste(document().domWindow(), pastingFragment, smartReplace, matchStyle, respectsMailBlockquote));
     472    target->dispatchEvent(TextEvent::createForFragmentPaste(document().domWindow(), WTFMove(pastingFragment), smartReplace, matchStyle, respectsMailBlockquote));
    473473}
    474474
  • trunk/Source/WebCore/editing/Editor.h

    r195078 r195927  
    347347    void dismissCorrectionPanelAsIgnored();
    348348
    349     WEBCORE_EXPORT void pasteAsFragment(PassRefPtr<DocumentFragment>, bool smartReplace, bool matchStyle, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
     349    WEBCORE_EXPORT void pasteAsFragment(Ref<DocumentFragment>&&, bool smartReplace, bool matchStyle, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
    350350    WEBCORE_EXPORT void pasteAsPlainText(const String&, bool smartReplace);
    351351
  • trunk/Source/WebCore/editing/gtk/EditorGtk.cpp

    r174676 r195927  
    7878    RefPtr<DocumentFragment> fragment = createFragmentFromPasteboardData(*pasteboard, m_frame, *range, allowPlainText, chosePlainText);
    7979    if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
    80         pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
     80        pasteAsFragment(fragment.releaseNonNull(), canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
    8181}
    8282
  • trunk/Source/WebCore/editing/ios/EditorIOS.mm

    r194496 r195927  
    547547
    548548    if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
    549         pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);
     549        pasteAsFragment(fragment.releaseNonNull(), canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);
    550550}
    551551
     
    603603        RefPtr<DocumentFragment> fragment = createFragmentAndAddResources(attributedString);
    604604        if (fragment && shouldInsertFragment(fragment, selectedRange(), EditorInsertActionPasted))
    605             pasteAsFragment(fragment, false, false, mailBlockquoteHandling);
     605            pasteAsFragment(fragment.releaseNonNull(), false, false, mailBlockquoteHandling);
    606606    } else {
    607607        String text = [attributedString string];
  • trunk/Source/WebCore/editing/mac/EditorMac.mm

    r194496 r195927  
    9797
    9898    if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
    99         pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);
     99        pasteAsFragment(fragment.releaseNonNull(), canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);
    100100
    101101    client()->setInsertionPasteboard(String());
     
    284284        maybeCopyNodeAttributesToFragment(*node, *fragment);
    285285        if (shouldInsertFragment(fragment, range, EditorInsertActionPasted))
    286             pasteAsFragment(fragment.release(), canSmartReplaceWithPasteboard(pasteboard), false, MailBlockquoteHandling::IgnoreBlockquote);
     286            pasteAsFragment(fragment.releaseNonNull(), canSmartReplaceWithPasteboard(pasteboard), false, MailBlockquoteHandling::IgnoreBlockquote);
    287287    }
    288288
     
    674674        RefPtr<DocumentFragment> fragment = createFragmentAndAddResources(attributedString);
    675675        if (fragment && shouldInsertFragment(fragment, selectedRange(), EditorInsertActionPasted))
    676             pasteAsFragment(fragment, false, false, mailBlockquoteHandling);
     676            pasteAsFragment(fragment.releaseNonNull(), false, false, mailBlockquoteHandling);
    677677    } else {
    678678        String text = [attributedString string];
  • trunk/Source/WebCore/editing/win/EditorWin.cpp

    r174314 r195927  
    4545    RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, *range, allowPlainText, chosePlainText);
    4646    if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
    47         pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
     47        pasteAsFragment(fragment.releaseNonNull(), canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
    4848}
    4949
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r195553 r195927  
    13271327    DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard inContext:range allowPlainText:allowPlainText];
    13281328    if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:range givenAction:WebViewInsertActionPasted])
    1329         coreFrame->editor().pasteAsFragment(core(fragment), [self _canSmartReplaceWithPasteboard:pasteboard], false);
     1329        coreFrame->editor().pasteAsFragment(*core(fragment), [self _canSmartReplaceWithPasteboard:pasteboard], false);
    13301330
    13311331    [webView _setInsertionPasteboard:nil];
Note: See TracChangeset for help on using the changeset viewer.