Title: [103008] trunk
Revision
103008
Author
[email protected]
Date
2011-12-15 18:00:43 -0800 (Thu, 15 Dec 2011)

Log Message

Source/_javascript_Core: Regression (r102866): Navigating away from or closing a page with a plugin crashes
https://bugs.webkit.org/show_bug.cgi?id=74655
<rdar://problem/10590024>

Reviewed by Sam Weinig.

Rewrite HasRefAndDeref to work if ref and deref are implemented in base classes,
using a modified version of the technique described here:
http://groups.google.com/group/comp.lang.c++.moderated/msg/e5fbc9305539f699

* wtf/Functional.h:

Tools: Regression (r102866): Navigating away from or closing a page with a plugin crashes
https://bugs.webkit.org/show_bug.cgi?id=74655

Reviewed by Sam Weinig.

Add a bunch of tests.

* TestWebKitAPI/Tests/WTF/Functional.cpp:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (103007 => 103008)


--- trunk/Source/_javascript_Core/ChangeLog	2011-12-16 01:50:47 UTC (rev 103007)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-12-16 02:00:43 UTC (rev 103008)
@@ -1,3 +1,17 @@
+2011-12-15  Anders Carlsson  <[email protected]>
+
+        Regression (r102866): Navigating away from or closing a page with a plugin crashes
+        https://bugs.webkit.org/show_bug.cgi?id=74655
+        <rdar://problem/10590024>
+
+        Reviewed by Sam Weinig.
+
+        Rewrite HasRefAndDeref to work if ref and deref are implemented in base classes,
+        using a modified version of the technique described here:
+        http://groups.google.com/group/comp.lang.c++.moderated/msg/e5fbc9305539f699
+        
+        * wtf/Functional.h:
+
 2011-12-15  Andy Wingo  <[email protected]>
 
         Warnings fixes in Interpreter.cpp and PrivateExecute.cpp

Modified: trunk/Source/_javascript_Core/wtf/Functional.h (103007 => 103008)


--- trunk/Source/_javascript_Core/wtf/Functional.h	2011-12-16 01:50:47 UTC (rev 103007)
+++ trunk/Source/_javascript_Core/wtf/Functional.h	2011-12-16 02:00:43 UTC (rev 103008)
@@ -46,16 +46,26 @@
         char padding[8];
     };
 
-    template<typename U, U, U> struct TypeChecker { };
+    struct BaseMixin {
+        void deref();
+        void ref();
+    };
 
+    struct Base : public T, public BaseMixin { };
+
+    template<typename U, U> struct
+    TypeChecker { };
+
     template<typename U>
-    static YesType refAndDerefCheck(TypeChecker<void (U::*)(), &U::ref, &U::deref>*);
+    static NoType refCheck(U*, TypeChecker<void (BaseMixin::*)(), &U::ref>* = 0);
+    static YesType refCheck(...);
 
     template<typename U>
-    static NoType refAndDerefCheck(...);
+    static NoType derefCheck(U*, TypeChecker<void (BaseMixin::*)(), &U::deref>* = 0);
+    static YesType derefCheck(...);
 
 public:
-    static const bool value = sizeof(refAndDerefCheck<T>(0)) == sizeof(YesType);
+    static const bool value = sizeof(refCheck(static_cast<Base*>(0))) == sizeof(YesType) && sizeof(derefCheck(static_cast<Base*>(0))) == sizeof(YesType);
 };
 
 // A FunctionWrapper is a class template that can wrap a function pointer or a member function pointer and

Modified: trunk/Tools/ChangeLog (103007 => 103008)


--- trunk/Tools/ChangeLog	2011-12-16 01:50:47 UTC (rev 103007)
+++ trunk/Tools/ChangeLog	2011-12-16 02:00:43 UTC (rev 103008)
@@ -1,3 +1,14 @@
+2011-12-15  Anders Carlsson  <[email protected]>
+
+        Regression (r102866): Navigating away from or closing a page with a plugin crashes
+        https://bugs.webkit.org/show_bug.cgi?id=74655
+
+        Reviewed by Sam Weinig.
+
+        Add a bunch of tests.
+
+        * TestWebKitAPI/Tests/WTF/Functional.cpp:
+
 2011-12-15  Stephanie Lewis  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=74469

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/Functional.cpp (103007 => 103008)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/Functional.cpp	2011-12-16 01:50:47 UTC (rev 103007)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/Functional.cpp	2011-12-16 02:00:43 UTC (rev 103008)
@@ -151,4 +151,24 @@
 
 }
 
+namespace RefAndDerefTests {
+    
+    template<typename T> struct RefCounted {
+        void ref();
+        void deref();
+    };
+    struct Connection : RefCounted<Connection> { };
+    COMPILE_ASSERT(WTF::HasRefAndDeref<Connection>::value, class_has_ref_and_deref);
+    
+    struct NoRefOrDeref { };
+    COMPILE_ASSERT(!WTF::HasRefAndDeref<NoRefOrDeref>::value, class_has_no_ref_or_deref);
+    
+    struct RefOnly { void ref(); };
+    COMPILE_ASSERT(!WTF::HasRefAndDeref<RefOnly>::value, class_has_ref_only);
+    
+    struct DerefOnly { void deref(); };
+    COMPILE_ASSERT(!WTF::HasRefAndDeref<DerefOnly>::value, class_has_deref_only);
+
+}
+
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to