Title: [180548] trunk/Source/WebCore
Revision
180548
Author
[email protected]
Date
2015-02-23 20:09:21 -0800 (Mon, 23 Feb 2015)

Log Message

EventHandler references deleted Scrollbar
https://bugs.webkit.org/show_bug.cgi?id=141931
<rdar://problem/19915210>

Reviewed by Tim Horton.

Tested by scrollbars/overflow-custom-scrollbar-crash.html

Update the EventHandler class to use a WeakPtr to reference the
last used Scrollbar, rather than retaining the Scrollbar and
artificially extending its life. This keeps the EventHandler
state in proper sync with the state of the render tree, and
avoids cases where we have destroyed a ScrollableArea (and
Scrollbar) but are still sending messages to a fake zombie
version of the element.

* page/EventHandler.cpp:
(WebCore::EventHandler::clear):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::updateMouseEventTargetNode):
(WebCore::EventHandler::updateLastScrollbarUnderMouse):
* page/EventHandler.h:
* platform/Scrollbar.cpp:
(WebCore::Scrollbar::Scrollbar): Initialize WeakPtrFactory.
* platform/Scrollbar.h:
(WebCore::Scrollbar::createWeakPtr): Added,

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (180547 => 180548)


--- trunk/Source/WebCore/ChangeLog	2015-02-24 03:47:29 UTC (rev 180547)
+++ trunk/Source/WebCore/ChangeLog	2015-02-24 04:09:21 UTC (rev 180548)
@@ -1,3 +1,32 @@
+2015-02-23  Brent Fulgham  <[email protected]>
+
+        EventHandler references deleted Scrollbar
+        https://bugs.webkit.org/show_bug.cgi?id=141931
+        <rdar://problem/19915210>
+
+        Reviewed by Tim Horton.
+
+        Tested by scrollbars/overflow-custom-scrollbar-crash.html
+
+        Update the EventHandler class to use a WeakPtr to reference the
+        last used Scrollbar, rather than retaining the Scrollbar and
+        artificially extending its life. This keeps the EventHandler
+        state in proper sync with the state of the render tree, and
+        avoids cases where we have destroyed a ScrollableArea (and
+        Scrollbar) but are still sending messages to a fake zombie
+        version of the element.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::clear):
+        (WebCore::EventHandler::handleMousePressEvent):
+        (WebCore::EventHandler::updateMouseEventTargetNode):
+        (WebCore::EventHandler::updateLastScrollbarUnderMouse):
+        * page/EventHandler.h:
+        * platform/Scrollbar.cpp:
+        (WebCore::Scrollbar::Scrollbar): Initialize WeakPtrFactory.
+        * platform/Scrollbar.h:
+        (WebCore::Scrollbar::createWeakPtr): Added,
+
 2015-02-23  Yusuke Suzuki  <[email protected]>
 
         REGRESSION(r179429): Can't type comments in Facebook

Modified: trunk/Source/WebCore/page/EventHandler.cpp (180547 => 180548)


--- trunk/Source/WebCore/page/EventHandler.cpp	2015-02-24 03:47:29 UTC (rev 180547)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2015-02-24 04:09:21 UTC (rev 180548)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2015 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Alexey Proskuryakov ([email protected])
  * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
  *
@@ -98,6 +98,7 @@
 #include <wtf/CurrentTime.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/TemporaryChange.h>
+#include <wtf/WeakPtr.h>
 
 #if ENABLE(CSS_IMAGE_SET)
 #include "StyleCachedImageSet.h"
@@ -3673,10 +3674,10 @@
 }
 
 // If scrollbar (under mouse) is different from last, send a mouse exited. Set
-// last to scrollbar if setLast is true; else set last to 0.
+// last to scrollbar if setLast is true; else set last to nullptr.
 void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setLast)
 {
-    if (m_lastScrollbarUnderMouse != scrollbar) {
+    if (m_lastScrollbarUnderMouse.get() != scrollbar) {
         // Send mouse exited to the old scrollbar.
         if (m_lastScrollbarUnderMouse)
             m_lastScrollbarUnderMouse->mouseExited();
@@ -3685,7 +3686,10 @@
         if (scrollbar && setLast)
             scrollbar->mouseEntered();
 
-        m_lastScrollbarUnderMouse = setLast ? scrollbar : 0;
+        if (setLast && scrollbar)
+            m_lastScrollbarUnderMouse = scrollbar->createWeakPtr();
+        else
+            m_lastScrollbarUnderMouse = nullptr;
     }
 }
 

Modified: trunk/Source/WebCore/page/EventHandler.h (180547 => 180548)


--- trunk/Source/WebCore/page/EventHandler.h	2015-02-24 03:47:29 UTC (rev 180547)
+++ trunk/Source/WebCore/page/EventHandler.h	2015-02-24 04:09:21 UTC (rev 180548)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,6 +41,7 @@
 #include <memory>
 #include <wtf/Forward.h>
 #include <wtf/RefPtr.h>
+#include <wtf/WeakPtr.h>
 
 #if PLATFORM(IOS)
 #ifdef __OBJC__
@@ -500,7 +501,7 @@
     RefPtr<Element> m_elementUnderMouse;
     RefPtr<Element> m_lastElementUnderMouse;
     RefPtr<Frame> m_lastMouseMoveEventSubframe;
-    RefPtr<Scrollbar> m_lastScrollbarUnderMouse;
+    WeakPtr<Scrollbar> m_lastScrollbarUnderMouse;
     Cursor m_currentMouseCursor;
 
     int m_clickCount;

Modified: trunk/Source/WebCore/platform/Scrollbar.cpp (180547 => 180548)


--- trunk/Source/WebCore/platform/Scrollbar.cpp	2015-02-24 03:47:29 UTC (rev 180547)
+++ trunk/Source/WebCore/platform/Scrollbar.cpp	2015-02-24 04:09:21 UTC (rev 180548)
@@ -57,7 +57,7 @@
 }
 
 Scrollbar::Scrollbar(ScrollableArea& scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize,
-                     ScrollbarTheme* theme, bool isCustomScrollbar)
+    ScrollbarTheme* theme, bool isCustomScrollbar)
     : m_scrollableArea(scrollableArea)
     , m_orientation(orientation)
     , m_controlSize(controlSize)
@@ -81,6 +81,7 @@
     , m_suppressInvalidation(false)
     , m_isAlphaLocked(false)
     , m_isCustomScrollbar(isCustomScrollbar)
+    , m_weakPtrFactory(this)
 {
     if (!m_theme)
         m_theme = ScrollbarTheme::theme();

Modified: trunk/Source/WebCore/platform/Scrollbar.h (180547 => 180548)


--- trunk/Source/WebCore/platform/Scrollbar.h	2015-02-24 03:47:29 UTC (rev 180547)
+++ trunk/Source/WebCore/platform/Scrollbar.h	2015-02-24 04:09:21 UTC (rev 180548)
@@ -31,6 +31,7 @@
 #include "Timer.h"
 #include "Widget.h"
 #include <wtf/PassRefPtr.h>
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
@@ -157,6 +158,8 @@
 
     virtual bool supportsUpdateOnSecondaryThread() const override;
 
+    WeakPtr<Scrollbar> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+
 protected:
     Scrollbar(ScrollableArea&, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0, bool isCustomScrollbar = false);
 
@@ -204,6 +207,8 @@
 
 private:
     virtual bool isScrollbar() const override { return true; }
+
+    WeakPtrFactory<Scrollbar> m_weakPtrFactory;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to