Modified: trunk/Source/WebCore/ChangeLog (224951 => 224952)
--- trunk/Source/WebCore/ChangeLog 2017-11-17 01:30:47 UTC (rev 224951)
+++ trunk/Source/WebCore/ChangeLog 2017-11-17 01:34:41 UTC (rev 224952)
@@ -1,3 +1,32 @@
+2017-11-16 Alex Christensen <achristen...@webkit.org>
+
+ Use RunLoop and Mode from NetworkingContext if they are given
+ https://bugs.webkit.org/show_bug.cgi?id=179800
+ <rdar://problem/35519421>
+
+ Reviewed by Brady Eidson.
+
+ We used to call [NSURLConnection scheduleInRunLoop:forMode:] before r224267.
+ That change broke WebKitLegacy clients using custom run loop modes, which I partially fixed in r224687 and r224896,
+ but that hangs if there are any non-scheduled calls to callOnMainThread and it ignores the CFRunLoop part of the SchedulePair.
+ This is a more elegant solution that fixes all known bugs with custom run loop modes and makes the
+ behavior as close to the pre-r224267 behavior as possible by using all parameters in a good way.
+
+ I verified the bug in the radar is fixed, the API test WebKitLegacy.ScheduleInRunLoop still passes,
+ and UIWebView still works on iOS.
+
+ * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
+ (callOnMainThreadOrSchedule):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveAuthenticationChallenge:]):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:canAuthenticateAgainstProtectionSpace:]):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveData:lengthReceived:]):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:]):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didFailWithError:]):
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willCacheResponse:]):
+
2017-11-16 Daniel Bates <daba...@apple.com>
Add feature define for alternative presentation button element
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm (224951 => 224952)
--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm 2017-11-17 01:30:47 UTC (rev 224951)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm 2017-11-17 01:34:41 UTC (rev 224952)
@@ -37,6 +37,7 @@
#import "SynchronousLoaderClient.h"
#import "WebCoreURLResponse.h"
#import <pal/spi/cf/CFNetworkSPI.h>
+#import <wtf/BlockPtr.h>
#import <wtf/MainThread.h>
using namespace WebCore;
@@ -50,6 +51,21 @@
return handle->context()->scheduledRunLoopPairs();
}
+static void callOnMainThreadOrSchedule(Function<void()>&& function, SchedulePairHashSet* pairs)
+{
+ if (pairs && pairs->size()) {
+ auto block = BlockPtr<void()>::fromCallable([alreadyCalled = false, function = WTFMove(function)] () mutable {
+ if (alreadyCalled)
+ return;
+ alreadyCalled = true;
+ function();
+ });
+ for (auto& pair : *pairs)
+ CFRunLoopPerformBlock(pair->runLoop(), pair->mode(), block.get());
+ } else
+ callOnMainThread(WTFMove(function));
+}
+
@implementation WebCoreResourceHandleAsOperationQueueDelegate
- (id)initWithHandle:(ResourceHandle*)handle messageQueue:(MessageQueue<Function<void()>>*)messageQueue
@@ -132,7 +148,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
return m_requestResult.get();
@@ -156,7 +172,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
}
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
@@ -178,7 +194,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
return m_boolResult;
@@ -217,7 +233,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
}
@@ -246,7 +262,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
}
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
@@ -266,7 +282,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
@@ -290,7 +306,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
@@ -314,7 +330,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
}
@@ -338,7 +354,7 @@
if (m_messageQueue)
m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
else
- callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
+ callOnMainThreadOrSchedule(WTFMove(work), scheduledRunLoopPairs(m_handle));
dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
return m_cachedResponseResult.get();