Diff
Modified: trunk/Source/WebCore/ChangeLog (164756 => 164757)
--- trunk/Source/WebCore/ChangeLog 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebCore/ChangeLog 2014-02-27 00:19:19 UTC (rev 164757)
@@ -1,3 +1,56 @@
+2014-02-26 Andy Estes <aes...@apple.com>
+
+ [iOS] Support network state notification using CPNetworkObserver
+ https://bugs.webkit.org/show_bug.cgi?id=129358
+
+ Reviewed by Dan Bernstein.
+
+ Add iOS support for navigator.onLine and online/offline events. Since
+ it can be expensive to query CPNetworkObserver, wait to do so until
+ someone calls NetworkStateObserver::onLine() or
+ NetworkStateObserver::addNetworkStateChangeListener(). For clients that
+ don't wish to observe network reachability at all, add a global opt-out.
+ These clients will only pay the cost of CPNetworkObserver if they load
+ a page that explicitly accesses navigator.onLine.
+
+ No new tests. Covered by existing tests.
+
+ * WebCore.exp.in: Stopped exporting NetworkStateNotifier::setIsOnLine()
+ and started exporting Settings::gShouldOptOutOfNetworkStateObservation.
+ * WebCore.xcodeproj/project.pbxproj: Renamed NetworkStateNotifierIOS.cpp
+ to NetworkStateNotifierIOS.mm.
+ * page/Settings.cpp: Defaulted gShouldOptOutOfNetworkStateObservation
+ to false.
+ * page/Settings.h:
+ (WebCore::Settings::setShouldOptOutOfNetworkStateObservation):
+ (WebCore::Settings::shouldOptOutOfNetworkStateObservation):
+ * platform/network/NetworkStateNotifier.cpp:
+ (WebCore::NetworkStateNotifier::addNetworkStateChangeListener): Ignored
+ the listener if Settings::shouldOptOutOfNetworkStateObservation().
+ Called registerObserverIfNecessary() and added the listener otherwise.
+ (WebCore::NetworkStateNotifier::notifyNetworkStateChange): Const qualified.
+ * platform/network/NetworkStateNotifier.h
+ (NetworkStateNotifier::onLine):
+ * platform/network/ios/NetworkStateNotifierIOS.cpp: Removed.
+ * platform/network/ios/NetworkStateNotifierIOS.mm: Added.
+ (-[NetworkStateObserver initWithNotifier:WebCore::]): Registered self
+ as a network reachable observer on CPNetworkObserver.
+ (-[NetworkStateObserver dealloc]): Removed self as a network reachable
+ observer.
+ (-[NetworkStateObserver networkStateChanged:]): Called setOnLine() on
+ the web thread, passing the reachability value from the notification.
+ (WebCore::NetworkStateNotifier::NetworkStateNotifier):
+ (WebCore::NetworkStateNotifier::~NetworkStateNotifier): Cleared
+ m_observer's pointer back to us.
+ (WebCore::NetworkStateNotifier::registerObserverIfNecessary): Initialized
+ m_observer if necessary.
+ (WebCore::NetworkStateNotifier::onLine): Called
+ registerObserverIfNecessary() and set an initial value for m_isOnLine
+ if m_isOnLineInitialized is false. Returned m_isOnLine.
+ (WebCore::setOnLine): Set m_isOnLine and called
+ notifyNetworkStateChange() if needed. Unconditionally set
+ m_isOnLineInitialized to true.
+
2014-02-26 Brian Burg <bb...@apple.com>
Unreviewed build fix for !ENABLE(CONTEXT_MENUS).
Modified: trunk/Source/WebCore/WebCore.exp.in (164756 => 164757)
--- trunk/Source/WebCore/WebCore.exp.in 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-02-27 00:19:19 UTC (rev 164757)
@@ -2449,7 +2449,6 @@
__ZN7WebCore19ResourceRequestBase22setDefaultAllowCookiesEb
__ZN7WebCore19applicationIsWebAppEv
__ZN7WebCore19asciiLineBreakTableE
-__ZN7WebCore20NetworkStateNotifier11setIsOnLineEb
__ZN7WebCore20PlatformEventFactory27createPlatformKeyboardEventEP8WebEvent
__ZN7WebCore20ResourceHandleClient22willCacheResponseAsyncEPNS_14ResourceHandleEPK20_CFCachedURLResponse
__ZN7WebCore20applicationIsOkCupidEv
@@ -2555,6 +2554,7 @@
__ZN7WebCore8Settings23setNetworkInterfaceNameERKN3WTF6StringE
__ZN7WebCore8Settings31setAudioSessionCategoryOverrideEj
__ZN7WebCore8Settings34setNetworkDataUsageTrackingEnabledEb
+__ZN7WebCore8Settings38gShouldOptOutOfNetworkStateObservationE
__ZN7WebCore9FontCache17getCachedFontDataERKNS_15FontDescriptionERKN3WTF12AtomicStringEbNS0_12ShouldRetainE
__ZN7WebCore9FontCache25getLastResortFallbackFontERKNS_15FontDescriptionENS0_12ShouldRetainE
__ZN7WebCore9FrameView20setWasScrolledByUserEb
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (164756 => 164757)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-02-27 00:19:19 UTC (rev 164757)
@@ -1484,7 +1484,7 @@
44311CD812E4E24B000A8D19 /* DOMDocumentPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 44311CD512E4E22D000A8D19 /* DOMDocumentPrivate.h */; };
44311CD912E4E257000A8D19 /* DOMDocumentFragmentPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 44311CD412E4E22D000A8D19 /* DOMDocumentFragmentPrivate.h */; };
44311F8212E4E66C000A8D19 /* DOMDocumentFragmentInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711450AC5D5340053270F /* DOMDocumentFragmentInternal.h */; };
- 443F04270E75C8FB007E5407 /* NetworkStateNotifierIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.cpp */; };
+ 443F04270E75C8FB007E5407 /* NetworkStateNotifierIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.mm */; };
444D4E230F708B2E003158E0 /* WebCoreURLResponseIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 444D4E210F708B2E003158E0 /* WebCoreURLResponseIOS.mm */; };
4476531B133170990006B789 /* SSLKeyGeneratorIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4476531A133170990006B789 /* SSLKeyGeneratorIOS.cpp */; };
447958041643B49A001E0A7F /* ParsedContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 447958031643B47B001E0A7F /* ParsedContentType.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8350,7 +8350,7 @@
442AF7A8102CDDEA008FD4D3 /* QuickLook.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLook.mm; sourceTree = "<group>"; };
44311CD412E4E22D000A8D19 /* DOMDocumentFragmentPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMDocumentFragmentPrivate.h; sourceTree = "<group>"; };
44311CD512E4E22D000A8D19 /* DOMDocumentPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMDocumentPrivate.h; sourceTree = "<group>"; };
- 443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkStateNotifierIOS.cpp; sourceTree = "<group>"; };
+ 443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkStateNotifierIOS.mm; sourceTree = "<group>"; };
444D4E210F708B2E003158E0 /* WebCoreURLResponseIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreURLResponseIOS.mm; sourceTree = "<group>"; };
4476531A133170990006B789 /* SSLKeyGeneratorIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SSLKeyGeneratorIOS.cpp; path = ios/SSLKeyGeneratorIOS.cpp; sourceTree = "<group>"; };
447958021643B47B001E0A7F /* ParsedContentType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentType.cpp; sourceTree = "<group>"; };
@@ -15290,7 +15290,7 @@
4497D58C0EBA854F00A10552 /* ios */ = {
isa = PBXGroup;
children = (
- 443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.cpp */,
+ 443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.mm */,
442AF7A7102CDDEA008FD4D3 /* QuickLook.h */,
442AF7A8102CDDEA008FD4D3 /* QuickLook.mm */,
7E428CE413E3407F003B661C /* ResourceHandleIOS.mm */,
@@ -28149,7 +28149,7 @@
5D874F130D161D3200796C3B /* NetscapePlugInStreamLoader.cpp in Sources */,
59C27F05138D28C10079B7E2 /* NetworkResourcesData.cpp in Sources */,
1A7FA61B0DDA3BBE0028F8A5 /* NetworkStateNotifier.cpp in Sources */,
- 443F04270E75C8FB007E5407 /* NetworkStateNotifierIOS.cpp in Sources */,
+ 443F04270E75C8FB007E5407 /* NetworkStateNotifierIOS.mm in Sources */,
1A7FA6490DDA3CBA0028F8A5 /* NetworkStateNotifierMac.cpp in Sources */,
E13EF34916850C470034C83F /* NetworkStorageSessionCFNet.cpp in Sources */,
BCEF43E00E674110001C1287 /* NinePieceImage.cpp in Sources */,
Modified: trunk/Source/WebCore/page/Settings.cpp (164756 => 164757)
--- trunk/Source/WebCore/page/Settings.cpp 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebCore/page/Settings.cpp 2014-02-27 00:19:19 UTC (rev 164757)
@@ -99,6 +99,7 @@
#if PLATFORM(IOS)
bool Settings::gNetworkDataUsageTrackingEnabled = false;
bool Settings::gAVKitEnabled = false;
+bool Settings::gShouldOptOutOfNetworkStateObservation = false;
#endif
// NOTEs
Modified: trunk/Source/WebCore/page/Settings.h (164756 => 164757)
--- trunk/Source/WebCore/page/Settings.h 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebCore/page/Settings.h 2014-02-27 00:19:19 UTC (rev 164757)
@@ -271,6 +271,9 @@
static void setAVKitEnabled(bool flag) { gAVKitEnabled = flag; }
static bool avKitEnabled() { return gAVKitEnabled; }
+
+ static void setShouldOptOutOfNetworkStateObservation(bool flag) { gShouldOptOutOfNetworkStateObservation = flag; }
+ static bool shouldOptOutOfNetworkStateObservation() { return gShouldOptOutOfNetworkStateObservation; }
#endif
private:
@@ -353,6 +356,7 @@
#if PLATFORM(IOS)
static bool gNetworkDataUsageTrackingEnabled;
static bool gAVKitEnabled;
+ static bool gShouldOptOutOfNetworkStateObservation;
#endif
static double gHiddenPageDOMTimerAlignmentInterval;
Modified: trunk/Source/WebCore/platform/network/NetworkStateNotifier.cpp (164756 => 164757)
--- trunk/Source/WebCore/platform/network/NetworkStateNotifier.cpp 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebCore/platform/network/NetworkStateNotifier.cpp 2014-02-27 00:19:19 UTC (rev 164757)
@@ -26,6 +26,7 @@
#include "config.h"
#include "NetworkStateNotifier.h"
+#include "Settings.h"
#include <mutex>
#include <wtf/Assertions.h>
#include <wtf/StdLibExtras.h>
@@ -47,11 +48,16 @@
void NetworkStateNotifier::addNetworkStateChangeListener(std::function<void (bool)> listener)
{
ASSERT(listener);
+#if PLATFORM(IOS)
+ if (Settings::shouldOptOutOfNetworkStateObservation())
+ return;
+ registerObserverIfNecessary();
+#endif
m_listeners.append(std::move(listener));
}
-void NetworkStateNotifier::notifyNetworkStateChange()
+void NetworkStateNotifier::notifyNetworkStateChange() const
{
for (const auto& listener : m_listeners)
listener(m_isOnLine);
Modified: trunk/Source/WebCore/platform/network/NetworkStateNotifier.h (164756 => 164757)
--- trunk/Source/WebCore/platform/network/NetworkStateNotifier.h 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebCore/platform/network/NetworkStateNotifier.h 2014-02-27 00:19:19 UTC (rev 164757)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2014 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -48,6 +48,11 @@
typedef struct _Ecore_Fd_Handler Ecore_Fd_Handler;
typedef unsigned char Eina_Bool;
+#elif PLATFORM(IOS)
+
+#include <wtf/RetainPtr.h>
+OBJC_CLASS WebNetworkStateObserver;
+
#endif
namespace WebCore {
@@ -56,22 +61,20 @@
WTF_MAKE_NONCOPYABLE(NetworkStateNotifier); WTF_MAKE_FAST_ALLOCATED;
public:
NetworkStateNotifier();
-#if PLATFORM(EFL)
+#if PLATFORM(EFL) || PLATFORM(IOS)
~NetworkStateNotifier();
#endif
void addNetworkStateChangeListener(std::function<void (bool isOnLine)>);
- bool onLine() const { return m_isOnLine; }
-
-#if PLATFORM(IOS)
- void setIsOnLine(bool);
-#endif
+ bool onLine() const;
private:
+#if !PLATFORM(IOS)
bool m_isOnLine;
+#endif
Vector<std::function<void (bool)>> m_listeners;
- void notifyNetworkStateChange();
+ void notifyNetworkStateChange() const;
void updateState();
#if PLATFORM(MAC)
@@ -97,6 +100,14 @@
int m_netlinkSocket;
Ecore_Fd_Handler* m_fdHandler;
+
+#elif PLATFORM(IOS)
+ void registerObserverIfNecessary() const;
+ friend void setOnLine(const NetworkStateNotifier*, bool);
+
+ mutable bool m_isOnLine;
+ mutable bool m_isOnLineInitialized;
+ mutable RetainPtr<WebNetworkStateObserver> m_observer;
#endif
};
@@ -111,8 +122,15 @@
#endif
+#if !PLATFORM(IOS)
+inline bool NetworkStateNotifier::onLine() const
+{
+ return m_isOnLine;
+}
+#endif
+
NetworkStateNotifier& networkStateNotifier();
-};
+} // namespace WebCore
#endif // NetworkStateNotifier_h
Deleted: trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.cpp (164756 => 164757)
--- trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.cpp 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.cpp 2014-02-27 00:19:19 UTC (rev 164757)
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NetworkStateNotifier.h"
-
-namespace WebCore {
-
-NetworkStateNotifier::NetworkStateNotifier()
- : m_isOnLine(false)
-{
-}
-
-void NetworkStateNotifier::setIsOnLine(bool isOnLine)
-{
- if (m_isOnLine == isOnLine)
- return;
- m_isOnLine = isOnLine;
- notifyNetworkStateChange();
-}
-
-}
Added: trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.mm (0 => 164757)
--- trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.mm (rev 0)
+++ trunk/Source/WebCore/platform/network/ios/NetworkStateNotifierIOS.mm 2014-02-27 00:19:19 UTC (rev 164757)
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2008, 2014 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "NetworkStateNotifier.h"
+
+#import "SoftLinking.h"
+#import "WebCoreThreadRun.h"
+
+#if defined(__has_include) && __has_include(<AppSupport/CPNetworkObserver.h>)
+#import <AppSupport/CPNetworkObserver.h>
+#else
+extern NSString * const CPNetworkObserverReachable;
+@interface CPNetworkObserver : NSObject
++ (CPNetworkObserver *)sharedNetworkObserver;
+- (void)addNetworkReachableObserver:(id)observer selector:(SEL)selector;
+- (void)removeNetworkReachableObserver:(id)observer;
+- (BOOL)isNetworkReachable;
+@end
+#endif
+
+SOFT_LINK_PRIVATE_FRAMEWORK(AppSupport);
+SOFT_LINK_CLASS(AppSupport, CPNetworkObserver);
+SOFT_LINK_POINTER(AppSupport, CPNetworkObserverReachable, NSString *);
+
+@interface WebNetworkStateObserver : NSObject
+@property (nonatomic) const WebCore::NetworkStateNotifier* notifier;
+- (id)initWithNotifier:(const WebCore::NetworkStateNotifier*)notifier;
+- (void)networkStateChanged:(NSNotification *)notification;
+@end
+
+@implementation WebNetworkStateObserver
+
+- (id)initWithNotifier:(const WebCore::NetworkStateNotifier*)notifier
+{
+ ASSERT_ARG(notifier, notifier);
+ if (!(self = [super init]))
+ return nil;
+ _notifier = notifier;
+ [[getCPNetworkObserverClass() sharedNetworkObserver] addNetworkReachableObserver:self selector:@selector(networkStateChanged:)];
+ return self;
+}
+
+- (void)dealloc
+{
+ [[getCPNetworkObserverClass() sharedNetworkObserver] removeNetworkReachableObserver:self];
+ [super dealloc];
+}
+
+- (void)networkStateChanged:(NSNotification *)notification
+{
+ ASSERT_ARG(notification, notification);
+ WebThreadRun(^{
+ setOnLine(_notifier, [[[notification userInfo] objectForKey:getCPNetworkObserverReachable()] boolValue]);
+ });
+}
+
+@end
+
+namespace WebCore {
+
+NetworkStateNotifier::NetworkStateNotifier()
+ : m_isOnLine(false)
+ , m_isOnLineInitialized(false)
+{
+}
+
+NetworkStateNotifier::~NetworkStateNotifier()
+{
+ [m_observer setNotifier:nullptr];
+}
+
+void NetworkStateNotifier::registerObserverIfNecessary() const
+{
+ if (!m_observer)
+ m_observer = adoptNS([[WebNetworkStateObserver alloc] initWithNotifier:this]);
+}
+
+bool NetworkStateNotifier::onLine() const
+{
+ registerObserverIfNecessary();
+ if (!m_isOnLineInitialized) {
+ m_isOnLine = [[getCPNetworkObserverClass() sharedNetworkObserver] isNetworkReachable];
+ m_isOnLineInitialized = true;
+ }
+ return m_isOnLine;
+}
+
+void setOnLine(const NetworkStateNotifier* notifier, bool onLine)
+{
+ ASSERT_ARG(notifier, notifier);
+ notifier->m_isOnLineInitialized = true;
+ if (_onLine_ == notifier->m_isOnLine)
+ return;
+ notifier->m_isOnLine = onLine;
+ notifier->notifyNetworkStateChange();
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebKit/mac/ChangeLog (164756 => 164757)
--- trunk/Source/WebKit/mac/ChangeLog 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebKit/mac/ChangeLog 2014-02-27 00:19:19 UTC (rev 164757)
@@ -1,3 +1,19 @@
+2014-02-26 Andy Estes <aes...@apple.com>
+
+ [iOS] Support network state notification using CPNetworkObserver
+ https://bugs.webkit.org/show_bug.cgi?id=129358
+
+ Reviewed by Dan Bernstein.
+
+ * WebView/WebView.mm:
+ (-[WebView _setNetworkStateIsOnline:]): Retained an empty
+ implementation for binary compatibility for UIKit.
+ (+[WebView _doNotStartObservingNetworkReachability]): Called
+ Settings::setShouldOptOutOfNetworkStateObservation(true).
+ * WebView/WebViewPrivate.h: Removed declaration of
+ _setNetworkStateIsOnline: and declared
+ _doNotStartObservingNetworkReachability.
+
2014-02-25 Anders Carlsson <ander...@apple.com>
Get rid of VisitedLinkStrategy
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (164756 => 164757)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2014-02-27 00:19:19 UTC (rev 164757)
@@ -3607,11 +3607,9 @@
return _private->allowsMessaging;
}
+// FIXME: Remove once this is no longer necessary for UIKit binary compatibility.
- (void)_setNetworkStateIsOnline:(BOOL)isOnLine
{
- WebThreadRun(^{
- networkStateNotifier().setIsOnLine(isOnLine);
- });
}
- (void)_setFixedLayoutSize:(CGSize)size
@@ -3700,6 +3698,11 @@
frame->overflowScrollPositionChangedForNode(roundedIntPoint(offset), node, userScroll);
}
+
++ (void)_doNotStartObservingNetworkReachability
+{
+ Settings::setShouldOptOutOfNetworkStateObservation(true);
+}
#endif // PLATFORM(IOS)
#if ENABLE(TOUCH_EVENTS)
Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (164756 => 164757)
--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h 2014-02-26 23:48:33 UTC (rev 164756)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h 2014-02-27 00:19:19 UTC (rev 164757)
@@ -572,8 +572,6 @@
- (void)_setAllowsMessaging:(BOOL)aFlag;
- (BOOL)_allowsMessaging;
-- (void)_setNetworkStateIsOnline:(BOOL)isOnLine;
-
- (void)_setCustomFixedPositionLayoutRectInWebThread:(CGRect)rect synchronize:(BOOL)synchronize;
- (void)_setCustomFixedPositionLayoutRect:(CGRect)rect;
@@ -583,6 +581,13 @@
- (void)_overflowScrollPositionChangedTo:(CGPoint)offset forNode:(DOMNode *)node isUserScroll:(BOOL)userScroll;
- (NSArray *)_touchEventRegions;
+
+/*!
+ @method _doNotStartObservingNetworkReachability
+ @abstract Does not start observation of network reachability in any WebView.
+ @discussion To take effect, this method must be called before the first WebView is created.
+ */
++ (void)_doNotStartObservingNetworkReachability;
#endif
#if !TARGET_OS_IPHONE