Title: [197269] releases/WebKitGTK/webkit-2.4/Source
Revision
197269
Author
[email protected]
Date
2016-02-28 02:35:02 -0800 (Sun, 28 Feb 2016)

Log Message

Merge r180548 - 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: releases/WebKitGTK/webkit-2.4/Source/WTF/wtf/WeakPtr.h (197268 => 197269)


--- releases/WebKitGTK/webkit-2.4/Source/WTF/wtf/WeakPtr.h	2016-02-28 10:01:03 UTC (rev 197268)
+++ releases/WebKitGTK/webkit-2.4/Source/WTF/wtf/WeakPtr.h	2016-02-28 10:35:02 UTC (rev 197269)
@@ -104,6 +104,8 @@
 
     T* operator->() const { return m_ref->get(); }
 
+    WeakPtr& operator=(std::nullptr_t) { m_ref = WeakReference<T>::create(nullptr); return *this; }
+
 private:
     RefPtr<WeakReference<T>> m_ref;
 };

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (197268 => 197269)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2016-02-28 10:01:03 UTC (rev 197268)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog	2016-02-28 10:35:02 UTC (rev 197269)
@@ -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-03-16  Brady Eidson  <[email protected]>
 
         URLs visited during private browsing show up in WebpageIcons.db

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/page/EventHandler.cpp (197268 => 197269)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/page/EventHandler.cpp	2016-02-28 10:01:03 UTC (rev 197268)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/page/EventHandler.cpp	2016-02-28 10:35:02 UTC (rev 197269)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2013 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)
  *
@@ -92,6 +92,7 @@
 #include <wtf/CurrentTime.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/TemporaryChange.h>
+#include <wtf/WeakPtr.h>
 
 #if ENABLE(SVG)
 #include "SVGDocument.h"
@@ -413,7 +414,7 @@
     m_lastInstanceUnderMouse = 0;
 #endif
     m_lastMouseMoveEventSubframe = 0;
-    m_lastScrollbarUnderMouse = 0;
+    m_lastScrollbarUnderMouse = nullptr;
     m_clickCount = 0;
     m_clickNode = 0;
 #if ENABLE(IOS_GESTURE_EVENTS)
@@ -1635,7 +1636,7 @@
         HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
         mev = m_frame.document()->prepareMouseEvent(request, documentPoint, mouseEvent);
         if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get())
-            m_lastScrollbarUnderMouse = 0;
+            m_lastScrollbarUnderMouse = nullptr;
     }
 
     if (swallowEvent) {
@@ -2365,7 +2366,7 @@
 
         if (m_lastElementUnderMouse && &m_lastElementUnderMouse->document() != m_frame.document()) {
             m_lastElementUnderMouse = nullptr;
-            m_lastScrollbarUnderMouse = 0;
+            m_lastScrollbarUnderMouse = nullptr;
 #if ENABLE(SVG)
             m_lastInstanceUnderMouse = 0;
 #endif
@@ -3514,10 +3515,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();
@@ -3526,7 +3527,10 @@
         if (scrollbar && setLast)
             scrollbar->mouseEntered();
 
-        m_lastScrollbarUnderMouse = setLast ? scrollbar : 0;
+        if (setLast && scrollbar)
+            m_lastScrollbarUnderMouse = scrollbar->createWeakPtr();
+        else
+            m_lastScrollbarUnderMouse = nullptr;
     }
 }
 

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/page/EventHandler.h (197268 => 197269)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/page/EventHandler.h	2016-02-28 10:01:03 UTC (rev 197268)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/page/EventHandler.h	2016-02-28 10:35:02 UTC (rev 197269)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2009, 2010, 2011, 2013 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 <wtf/Forward.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
+#include <wtf/WeakPtr.h>
 
 #if PLATFORM(IOS)
 #ifdef __OBJC__
@@ -484,7 +485,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: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/Scrollbar.cpp (197268 => 197269)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/Scrollbar.cpp	2016-02-28 10:01:03 UTC (rev 197268)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/Scrollbar.cpp	2016-02-28 10:35:02 UTC (rev 197269)
@@ -56,7 +56,7 @@
 }
 
 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize,
-                     ScrollbarTheme* theme)
+    ScrollbarTheme* theme)
     : m_scrollableArea(scrollableArea)
     , m_orientation(orientation)
     , m_controlSize(controlSize)
@@ -79,6 +79,7 @@
     , m_overlapsResizer(false)
     , m_suppressInvalidation(false)
     , m_isAlphaLocked(false)
+    , m_weakPtrFactory(this)
 {
     if (!m_theme)
         m_theme = ScrollbarTheme::theme();

Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/Scrollbar.h (197268 => 197269)


--- releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/Scrollbar.h	2016-02-28 10:01:03 UTC (rev 197268)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/platform/Scrollbar.h	2016-02-28 10:35:02 UTC (rev 197269)
@@ -32,6 +32,7 @@
 #include "Widget.h"
 #include <wtf/MathExtras.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
@@ -156,6 +157,8 @@
 
     virtual bool supportsUpdateOnSecondaryThread() const;
 
+    WeakPtr<Scrollbar> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+
 protected:
     Scrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0);
 
@@ -201,6 +204,8 @@
 
 private:
     virtual bool isScrollbar() const override { return true; }
+
+    WeakPtrFactory<Scrollbar> m_weakPtrFactory;
 };
 
 WIDGET_TYPE_CASTS(Scrollbar, isScrollbar());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to