Add thread violation checks to WebView public APIs.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Feb 2016 17:41:12 +0000 (17:41 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Feb 2016 17:41:12 +0000 (17:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154183

Reviewed by Timothy Hatcher.

Source/WebCore:

No new tests.  Just adding a new thread violation round.

* platform/ThreadCheck.h:
* platform/mac/ThreadCheck.mm:
- Adding WebCoreThreadViolationCheckRoundThree().

Source/WebKit/mac:

Re-landing r196527 with a newly added WebCoreThreadViolationCheckRoundThree().
Previously was using WebCoreThreadViolationCheckRoundTwo().

* Misc/WebKitVersionChecks.h:
* WebView/WebFrameView.mm:
(-[WebFrameView initWithFrame:]):
* WebView/WebView.mm:
(-[WebView setCustomTextEncodingName:]):
(-[WebView stringByEvaluatingJavaScriptFromString:]):
(-[WebView windowScriptObject]):
(-[WebView setGroupName:]):
(-[WebView setMainFrameURL:]):
(-[WebView mainFrameTitle]):
(-[WebView mainFrameIcon]):
(-[WebView setDrawsBackground:]):
(-[WebView setShouldUpdateWhileOffscreen:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196551 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/ThreadCheck.h
Source/WebCore/platform/mac/ThreadCheck.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebKitVersionChecks.h
Source/WebKit/mac/WebView/WebFrameView.mm
Source/WebKit/mac/WebView/WebView.mm

index 759993a..482fc0a 100644 (file)
@@ -1,3 +1,16 @@
+2016-02-13  Mark Lam  <mark.lam@apple.com>
+
+        Add thread violation checks to WebView public APIs.
+        https://bugs.webkit.org/show_bug.cgi?id=154183
+
+        Reviewed by Timothy Hatcher.
+
+        No new tests.  Just adding a new thread violation round.
+
+        * platform/ThreadCheck.h:
+        * platform/mac/ThreadCheck.mm:
+        - Adding WebCoreThreadViolationCheckRoundThree().
+
 2016-02-12  Nan Wang  <n_wang@apple.com>
 
         AX: Implement paragraph related text marker functions using TextIterator
index a265a97..91f136d 100644 (file)
@@ -37,6 +37,7 @@ namespace WebCore {
     enum ThreadViolationRound {
         ThreadViolationRoundOne = 0,
         ThreadViolationRoundTwo,
+        ThreadViolationRoundThree,
         MaximumThreadViolationRound
     };
     WEBCORE_EXPORT void setDefaultThreadViolationBehavior(ThreadViolationBehavior, ThreadViolationRound);
@@ -47,9 +48,11 @@ extern "C" void WebCoreReportThreadViolation(const char* function, WebCore::Thre
 
 #define WebCoreThreadViolationCheckRoundOne() ::WebCore::reportThreadViolation(WTF_PRETTY_FUNCTION, WebCore::ThreadViolationRoundOne)
 #define WebCoreThreadViolationCheckRoundTwo() ::WebCore::reportThreadViolation(WTF_PRETTY_FUNCTION, WebCore::ThreadViolationRoundTwo)
+#define WebCoreThreadViolationCheckRoundThree() ::WebCore::reportThreadViolation(WTF_PRETTY_FUNCTION, WebCore::ThreadViolationRoundThree)
 #else
 #define WebCoreThreadViolationCheckRoundOne() do { } while (0)
 #define WebCoreThreadViolationCheckRoundTwo() do { } while (0)
+#define WebCoreThreadViolationCheckRoundThree() do { } while (0)
 #endif // PLATFORM(IOS)
 
 #endif
index c284add..ec0b999 100644 (file)
@@ -35,7 +35,7 @@ namespace WebCore {
 
 static bool didReadThreadViolationBehaviorFromUserDefaults = false;
 static bool threadViolationBehaviorIsDefault = true;
-static ThreadViolationBehavior threadViolationBehavior[MaximumThreadViolationRound] = { RaiseExceptionOnThreadViolation, RaiseExceptionOnThreadViolation };
+static ThreadViolationBehavior threadViolationBehavior[MaximumThreadViolationRound] = { RaiseExceptionOnThreadViolation, RaiseExceptionOnThreadViolation, RaiseExceptionOnThreadViolation };
 
 static void readThreadViolationBehaviorFromUserDefaults()
 {
index f438e7f..81e7737 100644 (file)
@@ -1,3 +1,27 @@
+2016-02-13  Mark Lam  <mark.lam@apple.com>
+
+        Add thread violation checks to WebView public APIs.
+        https://bugs.webkit.org/show_bug.cgi?id=154183
+
+        Reviewed by Timothy Hatcher.
+
+        Re-landing r196527 with a newly added WebCoreThreadViolationCheckRoundThree().
+        Previously was using WebCoreThreadViolationCheckRoundTwo().
+
+        * Misc/WebKitVersionChecks.h:
+        * WebView/WebFrameView.mm:
+        (-[WebFrameView initWithFrame:]):
+        * WebView/WebView.mm:
+        (-[WebView setCustomTextEncodingName:]):
+        (-[WebView stringByEvaluatingJavaScriptFromString:]):
+        (-[WebView windowScriptObject]):
+        (-[WebView setGroupName:]):
+        (-[WebView setMainFrameURL:]):
+        (-[WebView mainFrameTitle]):
+        (-[WebView mainFrameIcon]):
+        (-[WebView setDrawsBackground:]):
+        (-[WebView setShouldUpdateWhileOffscreen:]):
+
 2016-02-12  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r196527.
index b533354..392c44b 100644 (file)
@@ -51,6 +51,7 @@
 #define WEBKIT_FIRST_VERSION_WITH_MORE_STRICT_LOCAL_RESOURCE_SECURITY_RESTRICTION 0x02100200 // 528.2.0
 #define WEBKIT_FIRST_VERSION_WITHOUT_WEBVIEW_INIT_THREAD_WORKAROUND 0x02100700 // 528.7.0
 #define WEBKIT_FIRST_VERSION_WITH_ROUND_TWO_MAIN_THREAD_EXCEPTIONS 0x02120400 // 530.4.0
+#define WEBKIT_FIRST_VERSION_WITH_ROUND_THREE_MAIN_THREAD_EXCEPTIONS 0x025A0113 // 602.1.19
 #define WEBKIT_FIRST_VERSION_WITHOUT_BUMPERCAR_BACK_FORWARD_QUIRK 0x02120700 // 530.7.0
 #define WEBKIT_FIRST_VERSION_WITHOUT_CONTENT_SNIFFING_FOR_FILE_URLS 0x02120A00 // 530.10.0
 #define WEBKIT_FIRST_VERSION_WITHOUT_LINK_ELEMENT_TEXT_CSS_QUIRK 0x02130200 // 531.2.0
index b60f9df..c690841 100644 (file)
@@ -381,6 +381,10 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
         bool throwExceptionsForRoundTwo = WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_ROUND_TWO_MAIN_THREAD_EXCEPTIONS);
         if (!throwExceptionsForRoundTwo)
             setDefaultThreadViolationBehavior(LogOnFirstThreadViolation, ThreadViolationRoundTwo);
+
+        bool throwExceptionsForRoundThree = WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_ROUND_THREE_MAIN_THREAD_EXCEPTIONS);
+        if (!throwExceptionsForRoundThree)
+            setDefaultThreadViolationBehavior(LogOnFirstThreadViolation, ThreadViolationRoundThree);
 #endif
     }
 
index 5402363..d11c23b 100644 (file)
@@ -5843,6 +5843,8 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 
 - (void)setCustomTextEncodingName:(NSString *)encoding
 {
+    WebCoreThreadViolationCheckRoundThree();
+
     NSString *oldEncoding = [self customTextEncodingName];
     if (encoding == oldEncoding || [encoding isEqualToString:oldEncoding])
         return;
@@ -5867,6 +5869,8 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 
 - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
 {
+    WebCoreThreadViolationCheckRoundThree();
+
 #if !PLATFORM(IOS)
     // Return statements are only valid in a function but some applications pass in scripts
     // prefixed with return (<rdar://problems/5103720&4616860>) since older WebKit versions
@@ -5889,6 +5893,8 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 
 - (WebScriptObject *)windowScriptObject
 {
+    WebCoreThreadViolationCheckRoundThree();
+
     Frame* coreFrame = [self _mainCoreFrame];
     if (!coreFrame)
         return nil;
@@ -6154,6 +6160,8 @@ static WebFrame *incrementFrame(WebFrame *frame, WebFindOptions options = 0)
 
 - (void)setGroupName:(NSString *)groupName
 {
+    WebCoreThreadViolationCheckRoundThree();
+
     if (_private->group)
         _private->group->removeWebView(self);
 
@@ -6244,6 +6252,8 @@ static WebFrame *incrementFrame(WebFrame *frame, WebFindOptions options = 0)
 
 - (void)setMainFrameURL:(NSString *)URLString
 {
+    WebCoreThreadViolationCheckRoundThree();
+
     NSURL *url;
     if ([URLString hasPrefix:@"/"])
         url = [NSURL fileURLWithPath:URLString];
@@ -6270,6 +6280,8 @@ static WebFrame *incrementFrame(WebFrame *frame, WebFindOptions options = 0)
 
 - (NSString *)mainFrameTitle
 {
+    WebCoreThreadViolationCheckRoundThree();
+
     NSString *mainFrameTitle = [[[self mainFrame] _dataSource] pageTitle];
     return (mainFrameTitle != nil) ? mainFrameTitle : (NSString *)@"";
 }
@@ -6277,6 +6289,8 @@ static WebFrame *incrementFrame(WebFrame *frame, WebFindOptions options = 0)
 #if !PLATFORM(IOS)
 - (NSImage *)mainFrameIcon
 {
+    WebCoreThreadViolationCheckRoundThree();
+
     return [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[self mainFrame] _dataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
 }
 #else
@@ -6303,6 +6317,8 @@ static WebFrame *incrementFrame(WebFrame *frame, WebFindOptions options = 0)
 
 - (void)setDrawsBackground:(BOOL)drawsBackground
 {
+    WebCoreThreadViolationCheckRoundThree();
+
     if (_private->drawsBackground == drawsBackground)
         return;
     _private->drawsBackground = drawsBackground;
@@ -6318,6 +6334,8 @@ static WebFrame *incrementFrame(WebFrame *frame, WebFindOptions options = 0)
 
 - (void)setShouldUpdateWhileOffscreen:(BOOL)updateWhileOffscreen
 {
+    WebCoreThreadViolationCheckRoundThree();
+
     if (_private->shouldUpdateWhileOffscreen == updateWhileOffscreen)
         return;
     _private->shouldUpdateWhileOffscreen = updateWhileOffscreen;