⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 201497 in webkit


Ignore:
Timestamp:
May 29, 2016, 11:53:36 PM (10 years ago)
Author:
beidson@apple.com
Message:

Transition various Task/Function queues from std::function to NoncopyableFunction.
​https://bugs.webkit.org/show_bug.cgi?id=158196

Reviewed by Chris Dumez.

No new tests (Refactor, no behavior change).

  • dom/ActiveDOMCallbackMicrotask.cpp:

(WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask):

  • dom/ActiveDOMCallbackMicrotask.h:
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::layoutSizeChanged):

  • page/FrameView.cpp:

(WebCore::FrameView::queuePostLayoutCallback):
(WebCore::FrameView::flushPostLayoutTasksQueue):

  • page/FrameView.h:
  • platform/GenericTaskQueue.cpp:

(WebCore::TaskDispatcher<Timer>::postTask):
(WebCore::TaskDispatcher<Timer>::dispatchOneTask):

  • platform/GenericTaskQueue.h:

(WebCore::TaskDispatcher::postTask):
(WebCore::GenericTaskQueue::enqueueTask):

  • style/StyleTreeResolver.cpp:

(WebCore::Style::postResolutionCallbackQueue):
(WebCore::Style::queuePostResolutionCallback):
(WebCore::Style::suspendMemoryCacheClientCalls):

  • style/StyleTreeResolver.h:
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201496 r201497  
     12016-05-29  Brady Eidson  <beidson@apple.com>
     2
     3        Transition various Task/Function queues from std::function to NoncopyableFunction.
     4        https://bugs.webkit.org/show_bug.cgi?id=158196
     5
     6        Reviewed by Chris Dumez.
     7
     8        No new tests (Refactor, no behavior change).
     9
     10        * dom/ActiveDOMCallbackMicrotask.cpp:
     11        (WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask):
     12        * dom/ActiveDOMCallbackMicrotask.h:
     13
     14        * html/HTMLMediaElement.cpp:
     15        (WebCore::HTMLMediaElement::layoutSizeChanged):
     16
     17        * page/FrameView.cpp:
     18        (WebCore::FrameView::queuePostLayoutCallback):
     19        (WebCore::FrameView::flushPostLayoutTasksQueue):
     20        * page/FrameView.h:
     21
     22        * platform/GenericTaskQueue.cpp:
     23        (WebCore::TaskDispatcher<Timer>::postTask):
     24        (WebCore::TaskDispatcher<Timer>::dispatchOneTask):
     25        * platform/GenericTaskQueue.h:
     26        (WebCore::TaskDispatcher::postTask):
     27        (WebCore::GenericTaskQueue::enqueueTask):
     28
     29        * style/StyleTreeResolver.cpp:
     30        (WebCore::Style::postResolutionCallbackQueue):
     31        (WebCore::Style::queuePostResolutionCallback):
     32        (WebCore::Style::suspendMemoryCacheClientCalls):
     33        * style/StyleTreeResolver.h:
     34
    1352016-05-29  Brady Eidson  <beidson@apple.com>
    236
  • trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp

    r194496 r201497  
    2929namespace WebCore {
    3030
    31 ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask(MicrotaskQueue& queue, ScriptExecutionContext& scriptExecutionContext, std::function<void()>&& task)
     31ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask(MicrotaskQueue& queue, ScriptExecutionContext& scriptExecutionContext, NoncopyableFunction<void()>&& task)
    3232    : ActiveDOMCallback(&scriptExecutionContext)
    3333    , m_queue(queue)
  • trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h

    r199735 r201497  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2424 */
    2525
    26 #ifndef ActiveDOMCallbackMicrotask_h
    27 #define ActiveDOMCallbackMicrotask_h
     26#pragma once
    2827
    2928#include "ActiveDOMCallback.h"
    3029#include "Microtasks.h"
    31 #include <functional>
     30#include <wtf/NoncopyableFunction.h>
    3231
    3332namespace WebCore {
    … …  
    3635    WTF_MAKE_FAST_ALLOCATED;
    3736public:
    38     WEBCORE_EXPORT ActiveDOMCallbackMicrotask(MicrotaskQueue&, ScriptExecutionContext&, std::function<void()>&&);
     37    WEBCORE_EXPORT ActiveDOMCallbackMicrotask(MicrotaskQueue&, ScriptExecutionContext&, NoncopyableFunction<void()>&&);
    3938    WEBCORE_EXPORT virtual ~ActiveDOMCallbackMicrotask();
    4039
    … …  
    4847    // queue.
    4948    MicrotaskQueue& m_queue;
    50     std::function<void()> m_task;
     49    NoncopyableFunction<void()> m_task;
    5150};
    5251
    5352} // namespace WebCore
    54 
    55 #endif // ActiveDOMCallbackMicrotask_h
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r201474 r201497  
    39953995{
    39963996#if ENABLE(MEDIA_CONTROLS_SCRIPT)
    3997     RefPtr<HTMLMediaElement> strongThis = this;
    3998     std::function<void()> task = [strongThis] {
    3999         if (ShadowRoot* root = strongThis->userAgentShadowRoot())
     3997    auto task = [this, protectedThis = Ref<Element>(*this)] {
     3998        if (ShadowRoot* root = userAgentShadowRoot())
    40003999            root->dispatchEvent(Event::create("resize", false, false));
    40014000    };
    4002     m_resizeTaskQueue.enqueueTask(task);
     4001    m_resizeTaskQueue.enqueueTask(WTFMove(task));
    40034002#endif
    40044003}
  • trunk/Source/WebCore/page/FrameView.cpp

    r201205 r201497  
    31343134}
    31353135
    3136 void FrameView::queuePostLayoutCallback(std::function<void()> callback)
    3137 {
    3138     m_postLayoutCallbackQueue.append(callback);
     3136void FrameView::queuePostLayoutCallback(NoncopyableFunction<void()>&& callback)
     3137{
     3138    m_postLayoutCallbackQueue.append(WTFMove(callback));
    31393139}
    31403140
    … …  
    31473147        return;
    31483148
    3149     const auto queue = m_postLayoutCallbackQueue;
    3150     m_postLayoutCallbackQueue.clear();
    3151     for (size_t i = 0; i < queue.size(); ++i)
    3152         queue[i]();
     3149    Vector<NoncopyableFunction<void()>> queue = WTFMove(m_postLayoutCallbackQueue);
     3150    for (auto& task : queue)
     3151        task();
    31533152}
    31543153
  • trunk/Source/WebCore/page/FrameView.h

    r200342 r201497  
    55             (C) 1999 Lars Knoll (knoll@kde.org)
    66             (C) 1999 Antti Koivisto (koivisto@kde.org)
    7    Copyright (C) 2004-2009, 2014-2015 Apple Inc. All rights reserved.
     7   Copyright (C) 2004-2009, 2014-2016 Apple Inc. All rights reserved.
    88
    99   This library is free software; you can redistribute it and/or
    … …  
    2323*/
    2424
    25 #ifndef FrameView_h
    26 #define FrameView_h
     25#pragma once
    2726
    2827#include "AdjustViewSizeOrNot.h"
    … …  
    3938#include <wtf/HashSet.h>
    4039#include <wtf/ListHashSet.h>
     40#include <wtf/NoncopyableFunction.h>
    4141#include <wtf/text/WTFString.h>
    4242
    … …  
    112112    void scheduleRelayoutOfSubtree(RenderElement&);
    113113    void unscheduleRelayout();
    114     void queuePostLayoutCallback(std::function<void()>);
     114    void queuePostLayoutCallback(NoncopyableFunction<void()>&&);
    115115    bool layoutPending() const;
    116116    bool isInLayout() const { return m_layoutPhase != OutsideLayout; }
    … …  
    829829
    830830    IntRect* m_cachedWindowClipRect { nullptr };
    831     Vector<std::function<void()>> m_postLayoutCallbackQueue;
     831    Vector<NoncopyableFunction<void()>> m_postLayoutCallbackQueue;
    832832};
    833833
    … …  
    855855
    856856SPECIALIZE_TYPE_TRAITS_WIDGET(FrameView, isFrameView())
    857 
    858 #endif // FrameView_h
  • trunk/Source/WebCore/platform/GenericTaskQueue.cpp

    r200638 r201497  
    3737}
    3838
    39 void TaskDispatcher<Timer>::postTask(std::function<void()> function)
     39void TaskDispatcher<Timer>::postTask(NoncopyableFunction<void()>&& function)
    4040{
    4141    m_pendingTasks.append(WTFMove(function));
    … …  
    7878{
    7979    ASSERT(!m_pendingTasks.isEmpty());
    80     std::function<void()> task = m_pendingTasks.takeFirst();
     80    auto task = m_pendingTasks.takeFirst();
    8181    task();
    8282}
  • trunk/Source/WebCore/platform/GenericTaskQueue.h

    r200638 r201497  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2424 */
    2525
    26 #ifndef GenericTaskQueue_h
    27 #define GenericTaskQueue_h
     26#pragma once
    2827
    2928#include "Timer.h"
    3029#include <wtf/Deque.h>
     30#include <wtf/NoncopyableFunction.h>
    3131#include <wtf/WeakPtr.h>
    3232
    … …  
    4141    }
    4242
    43     void postTask(std::function<void()> f)
     43    void postTask(NoncopyableFunction<void()>&& f)
    4444    {
    45         m_context.postTask(f);
     45        m_context.postTask(WTFMove(f));
    4646    }
    4747
    … …  
    5454public:
    5555    TaskDispatcher();
    56     void postTask(std::function<void()>);
     56    void postTask(NoncopyableFunction<void()>&&);
    5757
    5858private:
    … …  
    6464
    6565    WeakPtrFactory<TaskDispatcher> m_weakPtrFactory;
    66     Deque<std::function<void()>> m_pendingTasks;
     66    Deque<NoncopyableFunction<void()>> m_pendingTasks;
    6767};
    6868
    … …  
    8282    }
    8383
    84     typedef std::function<void()> TaskFunction;
     84    typedef NoncopyableFunction<void()> TaskFunction;
    8585
    86     void enqueueTask(TaskFunction task)
     86    void enqueueTask(TaskFunction&& task)
    8787    {
    8888        if (m_isClosed)
    … …  
    9191        ++m_pendingTasks;
    9292        auto weakThis = m_weakPtrFactory.createWeakPtr();
    93         m_dispatcher.postTask([weakThis, task] {
     93        m_dispatcher.postTask([weakThis, task = WTFMove(task)] {
    9494            if (!weakThis)
    9595                return;
    … …  
    121121
    122122}
    123 
    124 #endif
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r201205 r201497  
    522522}
    523523
    524 static Vector<std::function<void ()>>& postResolutionCallbackQueue()
    525 {
    526     static NeverDestroyed<Vector<std::function<void ()>>> vector;
     524static Vector<NoncopyableFunction<void ()>>& postResolutionCallbackQueue()
     525{
     526    static NeverDestroyed<Vector<NoncopyableFunction<void ()>>> vector;
    527527    return vector;
    528528}
    529529
    530 void queuePostResolutionCallback(std::function<void ()> callback)
    531 {
    532     postResolutionCallbackQueue().append(callback);
     530void queuePostResolutionCallback(NoncopyableFunction<void ()>&& callback)
     531{
     532    postResolutionCallbackQueue().append(WTFMove(callback));
    533533}
    534534
    … …  
    541541    page->setMemoryCacheClientCallsEnabled(false);
    542542
    543     RefPtr<MainFrame> protectedMainFrame = &page->mainFrame();
    544     postResolutionCallbackQueue().append([protectedMainFrame]{
     543    postResolutionCallbackQueue().append([protectedMainFrame = Ref<MainFrame>(page->mainFrame())] {
    545544        if (Page* page = protectedMainFrame->page())
    546545            page->setMemoryCacheClientCallsEnabled(true);
  • trunk/Source/WebCore/style/StyleTreeResolver.h

    r200381 r201497  
    2424 */
    2525
    26 #ifndef StyleTreeResolver_h
    27 #define StyleTreeResolver_h
     26#pragma once
    2827
    2928#include "RenderStyleConstants.h"
    … …  
    3635#include <functional>
    3736#include <wtf/HashMap.h>
     37#include <wtf/NoncopyableFunction.h>
    3838#include <wtf/RefPtr.h>
    3939
    … …  
    111111};
    112112
    113 void queuePostResolutionCallback(std::function<void ()>);
     113void queuePostResolutionCallback(NoncopyableFunction<void ()>&&);
    114114bool postResolutionCallbacksAreSuspended();
    115115
    … …  
    125125
    126126}
    127 
    128 #endif
Note: See TracChangeset for help on using the changeset viewer.