Changeset 117018 in webkit
- Timestamp:
- May 14, 2012 5:05:12 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117016 r117018 1 2012-05-14 Andy Estes <aestes@apple.com> 2 3 Move the parts of RunLoopMac.mm that aren't Mac-specific into RunLoopCF.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=86411 5 6 Reviewed by Anders Carlsson. 7 8 Most of RunLoopMac.mm was written in terms of CF API. Move these bits 9 to a new file called RunLoopCF.cpp, leaving only the bits dealing with 10 NSApplication. 11 12 * WebCore.xcodeproj/project.pbxproj: Xcode decided to give 13 VisitedLinks.* new UUIDs. I'll allow it. 14 * platform/cf/RunLoopCF.cpp: Copied from Source/WebCore/platform/mac/RunLoopMac.mm. 15 * platform/mac/RunLoopMac.mm: 16 1 17 2012-05-14 Erik Arvidsson <arv@chromium.org> 2 18 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r116974 r117018 724 724 293EAE211356B32E0067ACF9 /* RuntimeApplicationChecks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 293EAE201356B32E0067ACF9 /* RuntimeApplicationChecks.cpp */; }; 725 725 29489FC712C00F0300D83F0F /* AccessibilityScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 29489FC512C00F0300D83F0F /* AccessibilityScrollView.h */; }; 726 29A309AC1561C99B00BBD8E5 /* RunLoopCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29A309AB1561C99B00BBD8E5 /* RunLoopCF.cpp */; }; 727 29A309B01561CAC400BBD8E5 /* VisitedLinks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29A309AE1561CAC400BBD8E5 /* VisitedLinks.cpp */; }; 728 29A309B11561CAC400BBD8E5 /* VisitedLinks.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A309AF1561CAC400BBD8E5 /* VisitedLinks.h */; }; 726 729 29A8122B0FBB9C1D00510293 /* AccessibilityTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A8120D0FBB9C1D00510293 /* AccessibilityTable.h */; }; 727 730 29A8122C0FBB9C1D00510293 /* AccessibilityList.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A8120E0FBB9C1D00510293 /* AccessibilityList.h */; }; … … 7651 7654 2981CAAE131822EC00D12F2A /* AccessibilityTableRow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityTableRow.cpp; sourceTree = "<group>"; }; 7652 7655 2981CAAF131822EC00D12F2A /* AXObjectCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AXObjectCache.cpp; sourceTree = "<group>"; }; 7656 29A309AB1561C99B00BBD8E5 /* RunLoopCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopCF.cpp; sourceTree = "<group>"; }; 7657 29A309AE1561CAC400BBD8E5 /* VisitedLinks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinks.cpp; sourceTree = "<group>"; }; 7658 29A309AF1561CAC400BBD8E5 /* VisitedLinks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinks.h; sourceTree = "<group>"; }; 7653 7659 29A8120D0FBB9C1D00510293 /* AccessibilityTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityTable.h; sourceTree = "<group>"; }; 7654 7660 29A8120E0FBB9C1D00510293 /* AccessibilityList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityList.h; sourceTree = "<group>"; }; … … 14166 14172 5160306B0CC4362300C8AC25 /* FileSystemCF.cpp */, 14167 14173 1A98956A0AA78F80005EF5EF /* KURLCFNet.cpp */, 14174 29A309AB1561C99B00BBD8E5 /* RunLoopCF.cpp */, 14168 14175 1C63A2470F71646600C09D5A /* RunLoopTimerCF.cpp */, 14169 14176 1CEFC9B80D78DC8C007D2579 /* SchedulePair.cpp */, … … 20396 20403 2E3BBF061162DA1100B9409A /* UUID.h */, 20397 20404 515788C01207852C00A37C4A /* VisitedLinkStrategy.h */, 20398 D6FDAEF2149C06190037B1E5 /* VisitedLinks.cpp */,20399 D630E2AB149BF344005B2F97/* VisitedLinks.h */,20405 29A309AE1561CAC400BBD8E5 /* VisitedLinks.cpp */, 20406 29A309AF1561CAC400BBD8E5 /* VisitedLinks.h */, 20400 20407 9380F47109A11AB4001FDB34 /* Widget.cpp */, 20401 20408 9380F47209A11AB4001FDB34 /* Widget.h */, … … 24722 24729 A883DF280F3D045D00F19BF6 /* VisibleSelection.h in Headers */, 24723 24730 515788C11207852C00A37C4A /* VisitedLinkStrategy.h in Headers */, 24724 D630E2AC149BF344005B2F97 /* VisitedLinks.h in Headers */,24725 24731 E44613B60CD6344E00FADA75 /* VoidCallback.h in Headers */, 24726 24732 FD7F299213D4C0CB00AD9535 /* WaveShaperDSPKernel.h in Headers */, … … 24888 24894 B658FFA21522EF3A00DD5595 /* JSRadioNodeList.h in Headers */, 24889 24895 B658FFA61522EFAA00DD5595 /* RadioNodeList.h in Headers */, 24896 29A309B11561CAC400BBD8E5 /* VisitedLinks.h in Headers */, 24890 24897 ); 24891 24898 runOnlyForDeploymentPostprocessing = 0; … … 27761 27768 93309E1F099E64920056E581 /* VisiblePosition.cpp in Sources */, 27762 27769 A883DF270F3D045D00F19BF6 /* VisibleSelection.cpp in Sources */, 27763 D6FDAEF3149C06190037B1E5 /* VisitedLinks.cpp in Sources */,27764 27770 FD7F299113D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp in Sources */, 27765 27771 FD7F299313D4C0CB00AD9535 /* WaveShaperNode.cpp in Sources */, … … 27910 27916 B658FFA11522EF3A00DD5595 /* JSRadioNodeList.cpp in Sources */, 27911 27917 B658FFA51522EFAA00DD5595 /* RadioNodeList.cpp in Sources */, 27918 29A309AC1561C99B00BBD8E5 /* RunLoopCF.cpp in Sources */, 27919 29A309B01561CAC400BBD8E5 /* VisitedLinks.cpp in Sources */, 27912 27920 ); 27913 27921 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/cf/RunLoopCF.cpp
r117016 r117018 1 1 /* 2 * Copyright (C) 201 0Apple Inc. All rights reserved.2 * Copyright (C) 2012 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 #i mport"config.h"27 #i mport"RunLoop.h"26 #include "config.h" 27 #include "RunLoop.h" 28 28 29 #import <dispatch/dispatch.h> 29 #include "AutodrainedPool.h" 30 #include <CoreFoundation/CoreFoundation.h> 31 #include <dispatch/dispatch.h> 30 32 31 33 namespace WebCore { 32 34 33 35 static RunLoop* s_mainRunLoop; 34 36 … … 45 47 if (pthread_main_np()) 46 48 return RunLoop::main(); 47 49 48 50 DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop>, runLoopData, ()); 49 51 return &*runLoopData; … … 58 60 void RunLoop::performWork(void* context) 59 61 { 60 // Wrap main thread in an Autorelease pool. 62 // Wrap main thread in an Autorelease pool. Sending messages can call 61 63 // into objc code and accumulate memory. 62 64 if (current() == main()) { 63 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];65 AutodrainedPool pool; 64 66 static_cast<RunLoop*>(context)->performWork(); 65 [pool drain];66 67 } else 67 68 static_cast<RunLoop*>(context)->performWork(); … … 93 94 } 94 95 95 void RunLoop::run()96 {97 current()->m_nestingLevel++;98 if (current() == main() && current()->m_nestingLevel == 1) {99 // Use -[NSApplication run] for the main run loop.100 [NSApp run];101 } else {102 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];103 CFRunLoopRun();104 [pool drain];105 }106 current()->m_nestingLevel--;107 }108 109 96 void RunLoop::runForDuration(double duration) 110 97 { 111 98 CFRunLoopRunInMode(kCFRunLoopDefaultMode, duration, true); 112 }113 114 void RunLoop::stop()115 {116 ASSERT(m_runLoop == CFRunLoopGetCurrent());117 118 if (m_runLoop == main()->m_runLoop && m_nestingLevel == 1) {119 [[NSApplication sharedApplication] stop:nil];120 NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined121 location:NSMakePoint(0, 0)122 modifierFlags:0123 timestamp:0.0124 windowNumber:0125 context:nil126 subtype: 0127 data1:0128 data2:0];129 [NSApp postEvent:event atStart:true];130 } else131 CFRunLoopStop(m_runLoop);132 99 } 133 100 … … 138 105 } 139 106 107 #if !PLATFORM(MAC) || PLATFORM(IOS) 108 void RunLoop::run() 109 { 110 current()->m_nestingLevel++; 111 112 { 113 AutodrainedPool pool; 114 CFRunLoopRun(); 115 } 116 117 current()->m_nestingLevel--; 118 } 119 120 void RunLoop::stop() 121 { 122 ASSERT(m_runLoop == CFRunLoopGetCurrent()); 123 CFRunLoopStop(m_runLoop); 124 } 125 #endif 126 140 127 // RunLoop::Timer 141 128 … … 144 131 TimerBase* timer = static_cast<TimerBase*>(context); 145 132 146 // Wrap main thread in an Autorelease pool. 133 // Wrap main thread in an Autorelease pool. The timer can call 147 134 // into objc code and accumulate memory outside of the main event loop. 148 135 if (current() == main()) { 149 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];136 AutodrainedPool pool; 150 137 timer->fired(); 151 [pool drain];152 138 } else 153 139 timer->fired(); … … 169 155 if (m_timer) 170 156 stop(); 171 157 172 158 CFRunLoopTimerContext context = { 0, this, 0, 0, 0 }; 173 159 CFTimeInterval repeatInterval = repeat ? nextFireInterval : 0; … … 180 166 if (!m_timer) 181 167 return; 182 168 183 169 CFRunLoopTimerInvalidate(m_timer); 184 170 CFRelease(m_timer); -
trunk/Source/WebCore/platform/mac/RunLoopMac.mm
r110277 r117018 27 27 #import "RunLoop.h" 28 28 29 #import <dispatch/dispatch.h>30 31 29 namespace WebCore { 32 33 static RunLoop* s_mainRunLoop;34 35 void RunLoop::initializeMainRunLoop()36 {37 static dispatch_once_t onceToken;38 dispatch_once(&onceToken, ^{39 s_mainRunLoop = new RunLoop(CFRunLoopGetMain());40 });41 }42 43 RunLoop* RunLoop::current()44 {45 if (pthread_main_np())46 return RunLoop::main();47 48 DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop>, runLoopData, ());49 return &*runLoopData;50 }51 52 RunLoop* RunLoop::main()53 {54 ASSERT(s_mainRunLoop);55 return s_mainRunLoop;56 }57 58 void RunLoop::performWork(void* context)59 {60 // Wrap main thread in an Autorelease pool. Sending messages can call61 // into objc code and accumulate memory.62 if (current() == main()) {63 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];64 static_cast<RunLoop*>(context)->performWork();65 [pool drain];66 } else67 static_cast<RunLoop*>(context)->performWork();68 }69 70 RunLoop::RunLoop()71 : m_runLoop(CFRunLoopGetCurrent())72 , m_nestingLevel(0)73 {74 CFRunLoopSourceContext context = { 0, this, 0, 0, 0, 0, 0, 0, 0, performWork };75 m_runLoopSource = CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context);76 CFRunLoopAddSource(m_runLoop, m_runLoopSource, kCFRunLoopCommonModes);77 }78 79 RunLoop::RunLoop(CFRunLoopRef runLoop)80 : m_runLoop(runLoop)81 , m_nestingLevel(0)82 {83 CFRunLoopSourceContext context = { 0, this, 0, 0, 0, 0, 0, 0, 0, performWork };84 m_runLoopSource = CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context);85 CFRunLoopAddSource(m_runLoop, m_runLoopSource, kCFRunLoopCommonModes);86 }87 88 RunLoop::~RunLoop()89 {90 // FIXME: Tear down the work item queue here.91 CFRunLoopSourceInvalidate(m_runLoopSource);92 CFRelease(m_runLoopSource);93 }94 30 95 31 void RunLoop::run() … … 105 41 } 106 42 current()->m_nestingLevel--; 107 }108 109 void RunLoop::runForDuration(double duration)110 {111 CFRunLoopRunInMode(kCFRunLoopDefaultMode, duration, true);112 43 } 113 44 … … 132 63 } 133 64 134 void RunLoop::wakeUp()135 {136 CFRunLoopSourceSignal(m_runLoopSource);137 CFRunLoopWakeUp(m_runLoop);138 }139 140 // RunLoop::Timer141 142 void RunLoop::TimerBase::timerFired(CFRunLoopTimerRef, void* context)143 {144 TimerBase* timer = static_cast<TimerBase*>(context);145 146 // Wrap main thread in an Autorelease pool. The timer can call147 // into objc code and accumulate memory outside of the main event loop.148 if (current() == main()) {149 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];150 timer->fired();151 [pool drain];152 } else153 timer->fired();154 }155 156 RunLoop::TimerBase::TimerBase(RunLoop* runLoop)157 : m_runLoop(runLoop)158 , m_timer(0)159 {160 }161 162 RunLoop::TimerBase::~TimerBase()163 {164 stop();165 }166 167 void RunLoop::TimerBase::start(double nextFireInterval, bool repeat)168 {169 if (m_timer)170 stop();171 172 CFRunLoopTimerContext context = { 0, this, 0, 0, 0 };173 CFTimeInterval repeatInterval = repeat ? nextFireInterval : 0;174 m_timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + nextFireInterval, repeatInterval, 0, 0, timerFired, &context);175 CFRunLoopAddTimer(m_runLoop->m_runLoop, m_timer, kCFRunLoopCommonModes);176 }177 178 void RunLoop::TimerBase::stop()179 {180 if (!m_timer)181 return;182 183 CFRunLoopTimerInvalidate(m_timer);184 CFRelease(m_timer);185 m_timer = 0;186 }187 188 bool RunLoop::TimerBase::isActive() const189 {190 return m_timer && CFRunLoopTimerIsValid(m_timer);191 }192 193 65 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.