Changeset 201497 in webkit
- Timestamp:
- May 29, 2016, 11:53:36 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
-
ChangeLog (modified) (1 diff)
-
dom/ActiveDOMCallbackMicrotask.cpp (modified) (1 diff)
-
dom/ActiveDOMCallbackMicrotask.h (modified) (4 diffs)
-
html/HTMLMediaElement.cpp (modified) (1 diff)
-
page/FrameView.cpp (modified) (2 diffs)
-
page/FrameView.h (modified) (6 diffs)
-
platform/GenericTaskQueue.cpp (modified) (2 diffs)
-
platform/GenericTaskQueue.h (modified) (8 diffs)
-
style/StyleTreeResolver.cpp (modified) (2 diffs)
-
style/StyleTreeResolver.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r201496 r201497 1 2016-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 1 35 2016-05-29 Brady Eidson <beidson@apple.com> 2 36 -
trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp
r194496 r201497 29 29 namespace WebCore { 30 30 31 ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask(MicrotaskQueue& queue, ScriptExecutionContext& scriptExecutionContext, std::function<void()>&& task)31 ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask(MicrotaskQueue& queue, ScriptExecutionContext& scriptExecutionContext, NoncopyableFunction<void()>&& task) 32 32 : ActiveDOMCallback(&scriptExecutionContext) 33 33 , m_queue(queue) -
trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h
r199735 r201497 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef ActiveDOMCallbackMicrotask_h 27 #define ActiveDOMCallbackMicrotask_h 26 #pragma once 28 27 29 28 #include "ActiveDOMCallback.h" 30 29 #include "Microtasks.h" 31 #include < functional>30 #include <wtf/NoncopyableFunction.h> 32 31 33 32 namespace WebCore { … … 36 35 WTF_MAKE_FAST_ALLOCATED; 37 36 public: 38 WEBCORE_EXPORT ActiveDOMCallbackMicrotask(MicrotaskQueue&, ScriptExecutionContext&, std::function<void()>&&);37 WEBCORE_EXPORT ActiveDOMCallbackMicrotask(MicrotaskQueue&, ScriptExecutionContext&, NoncopyableFunction<void()>&&); 39 38 WEBCORE_EXPORT virtual ~ActiveDOMCallbackMicrotask(); 40 39 … … 48 47 // queue. 49 48 MicrotaskQueue& m_queue; 50 std::function<void()> m_task;49 NoncopyableFunction<void()> m_task; 51 50 }; 52 51 53 52 } // namespace WebCore 54 55 #endif // ActiveDOMCallbackMicrotask_h -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r201474 r201497 3995 3995 { 3996 3996 #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()) 4000 3999 root->dispatchEvent(Event::create("resize", false, false)); 4001 4000 }; 4002 m_resizeTaskQueue.enqueueTask( task);4001 m_resizeTaskQueue.enqueueTask(WTFMove(task)); 4003 4002 #endif 4004 4003 } -
trunk/Source/WebCore/page/FrameView.cpp
r201205 r201497 3134 3134 } 3135 3135 3136 void FrameView::queuePostLayoutCallback( std::function<void()>callback)3137 { 3138 m_postLayoutCallbackQueue.append( callback);3136 void FrameView::queuePostLayoutCallback(NoncopyableFunction<void()>&& callback) 3137 { 3138 m_postLayoutCallbackQueue.append(WTFMove(callback)); 3139 3139 } 3140 3140 … … 3147 3147 return; 3148 3148 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(); 3153 3152 } 3154 3153 -
trunk/Source/WebCore/page/FrameView.h
r200342 r201497 5 5 (C) 1999 Lars Knoll (knoll@kde.org) 6 6 (C) 1999 Antti Koivisto (koivisto@kde.org) 7 Copyright (C) 2004-2009, 2014-201 5Apple Inc. All rights reserved.7 Copyright (C) 2004-2009, 2014-2016 Apple Inc. All rights reserved. 8 8 9 9 This library is free software; you can redistribute it and/or … … 23 23 */ 24 24 25 #ifndef FrameView_h 26 #define FrameView_h 25 #pragma once 27 26 28 27 #include "AdjustViewSizeOrNot.h" … … 39 38 #include <wtf/HashSet.h> 40 39 #include <wtf/ListHashSet.h> 40 #include <wtf/NoncopyableFunction.h> 41 41 #include <wtf/text/WTFString.h> 42 42 … … 112 112 void scheduleRelayoutOfSubtree(RenderElement&); 113 113 void unscheduleRelayout(); 114 void queuePostLayoutCallback( std::function<void()>);114 void queuePostLayoutCallback(NoncopyableFunction<void()>&&); 115 115 bool layoutPending() const; 116 116 bool isInLayout() const { return m_layoutPhase != OutsideLayout; } … … 829 829 830 830 IntRect* m_cachedWindowClipRect { nullptr }; 831 Vector< std::function<void()>> m_postLayoutCallbackQueue;831 Vector<NoncopyableFunction<void()>> m_postLayoutCallbackQueue; 832 832 }; 833 833 … … 855 855 856 856 SPECIALIZE_TYPE_TRAITS_WIDGET(FrameView, isFrameView()) 857 858 #endif // FrameView_h -
trunk/Source/WebCore/platform/GenericTaskQueue.cpp
r200638 r201497 37 37 } 38 38 39 void TaskDispatcher<Timer>::postTask( std::function<void()>function)39 void TaskDispatcher<Timer>::postTask(NoncopyableFunction<void()>&& function) 40 40 { 41 41 m_pendingTasks.append(WTFMove(function)); … … 78 78 { 79 79 ASSERT(!m_pendingTasks.isEmpty()); 80 std::function<void()>task = m_pendingTasks.takeFirst();80 auto task = m_pendingTasks.takeFirst(); 81 81 task(); 82 82 } -
trunk/Source/WebCore/platform/GenericTaskQueue.h
r200638 r201497 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef GenericTaskQueue_h 27 #define GenericTaskQueue_h 26 #pragma once 28 27 29 28 #include "Timer.h" 30 29 #include <wtf/Deque.h> 30 #include <wtf/NoncopyableFunction.h> 31 31 #include <wtf/WeakPtr.h> 32 32 … … 41 41 } 42 42 43 void postTask( std::function<void()>f)43 void postTask(NoncopyableFunction<void()>&& f) 44 44 { 45 m_context.postTask( f);45 m_context.postTask(WTFMove(f)); 46 46 } 47 47 … … 54 54 public: 55 55 TaskDispatcher(); 56 void postTask( std::function<void()>);56 void postTask(NoncopyableFunction<void()>&&); 57 57 58 58 private: … … 64 64 65 65 WeakPtrFactory<TaskDispatcher> m_weakPtrFactory; 66 Deque< std::function<void()>> m_pendingTasks;66 Deque<NoncopyableFunction<void()>> m_pendingTasks; 67 67 }; 68 68 … … 82 82 } 83 83 84 typedef std::function<void()> TaskFunction;84 typedef NoncopyableFunction<void()> TaskFunction; 85 85 86 void enqueueTask(TaskFunction task)86 void enqueueTask(TaskFunction&& task) 87 87 { 88 88 if (m_isClosed) … … 91 91 ++m_pendingTasks; 92 92 auto weakThis = m_weakPtrFactory.createWeakPtr(); 93 m_dispatcher.postTask([weakThis, task ] {93 m_dispatcher.postTask([weakThis, task = WTFMove(task)] { 94 94 if (!weakThis) 95 95 return; … … 121 121 122 122 } 123 124 #endif -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r201205 r201497 522 522 } 523 523 524 static Vector< std::function<void ()>>& postResolutionCallbackQueue()525 { 526 static NeverDestroyed<Vector< std::function<void ()>>> vector;524 static Vector<NoncopyableFunction<void ()>>& postResolutionCallbackQueue() 525 { 526 static NeverDestroyed<Vector<NoncopyableFunction<void ()>>> vector; 527 527 return vector; 528 528 } 529 529 530 void queuePostResolutionCallback( std::function<void ()>callback)531 { 532 postResolutionCallbackQueue().append( callback);530 void queuePostResolutionCallback(NoncopyableFunction<void ()>&& callback) 531 { 532 postResolutionCallbackQueue().append(WTFMove(callback)); 533 533 } 534 534 … … 541 541 page->setMemoryCacheClientCallsEnabled(false); 542 542 543 RefPtr<MainFrame> protectedMainFrame = &page->mainFrame(); 544 postResolutionCallbackQueue().append([protectedMainFrame]{ 543 postResolutionCallbackQueue().append([protectedMainFrame = Ref<MainFrame>(page->mainFrame())] { 545 544 if (Page* page = protectedMainFrame->page()) 546 545 page->setMemoryCacheClientCallsEnabled(true); -
trunk/Source/WebCore/style/StyleTreeResolver.h
r200381 r201497 24 24 */ 25 25 26 #ifndef StyleTreeResolver_h 27 #define StyleTreeResolver_h 26 #pragma once 28 27 29 28 #include "RenderStyleConstants.h" … … 36 35 #include <functional> 37 36 #include <wtf/HashMap.h> 37 #include <wtf/NoncopyableFunction.h> 38 38 #include <wtf/RefPtr.h> 39 39 … … 111 111 }; 112 112 113 void queuePostResolutionCallback( std::function<void ()>);113 void queuePostResolutionCallback(NoncopyableFunction<void ()>&&); 114 114 bool postResolutionCallbacksAreSuspended(); 115 115 … … 125 125 126 126 } 127 128 #endif
Note:
See TracChangeset
for help on using the changeset viewer.