Revert r95673 since it caused hundreds of tests to fail on Leopard / Snow Leopard.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Sep 2011 18:55:35 +0000 (18:55 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Sep 2011 18:55:35 +0000 (18:55 +0000)
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::passMouseDownEventToWidget):
* platform/Widget.h:
* platform/mac/WidgetMac.mm:
(WebCore::Widget::Widget):
(WebCore::Widget::removeFromSuperview):
(WebCore::Widget::beforeMouseDown):
(WebCore::Widget::afterMouseDown):
* rendering/RenderWidget.cpp:

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

Source/WebCore/ChangeLog
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/platform/Widget.h
Source/WebCore/platform/mac/WidgetMac.mm
Source/WebCore/rendering/RenderWidget.cpp

index 4168d27..f715239 100644 (file)
@@ -1,3 +1,17 @@
+2011-09-22  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Revert r95673 since it caused hundreds of tests to fail on Leopard / Snow Leopard.
+
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::passMouseDownEventToWidget):
+        * platform/Widget.h:
+        * platform/mac/WidgetMac.mm:
+        (WebCore::Widget::Widget):
+        (WebCore::Widget::removeFromSuperview):
+        (WebCore::Widget::beforeMouseDown):
+        (WebCore::Widget::afterMouseDown):
+        * rendering/RenderWidget.cpp:
+
 2011-09-22  David Hyatt  <hyatt@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=68638
index 4a02d02..94c8769 100644 (file)
@@ -227,10 +227,15 @@ bool EventHandler::passMouseDownEventToWidget(Widget* pWidget)
 
     ASSERT(!m_sendingEventToSubview);
     m_sendingEventToSubview = true;
+    NSView *outerView = widget->getOuterView();
+    widget->beforeMouseDown(outerView, widget.get());
 
     RenderWidget::suspendWidgetHierarchyUpdates();
     [view mouseDown:currentNSEvent()];
     RenderWidget::resumeWidgetHierarchyUpdates();
+
+    widget->afterMouseDown(outerView, widget.get());
+    m_sendingEventToSubview = false;
     
     if (!wasDeferringLoading)
         page->setDefersLoading(false);
index 46bc3d5..24a0d09 100644 (file)
@@ -208,6 +208,9 @@ public:
 #if PLATFORM(MAC)
     NSView* getOuterView() const;
 
+    static void beforeMouseDown(NSView*, Widget*);
+    static void afterMouseDown(NSView*, Widget*);
+
     void removeFromSuperview();
 #endif
 
index 1c08bef..68ff797 100644 (file)
@@ -65,6 +65,8 @@ public:
     {
     }
 
+    bool mustStayInWindow;
+    bool removeFromSuperviewSoon;
     NSRect previousVisibleRect;
 };
 
@@ -88,6 +90,8 @@ Widget::Widget(NSView *view)
     : m_data(new WidgetPrivate)
 {
     init(view);
+    m_data->mustStayInWindow = false;
+    m_data->removeFromSuperviewSoon = false;
 }
 
 Widget::~Widget()
@@ -272,9 +276,37 @@ void Widget::setIsSelected(bool isSelected)
 
 void Widget::removeFromSuperview()
 {
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    safeRemoveFromSuperview(getOuterView());
-    END_BLOCK_OBJC_EXCEPTIONS;
+    if (m_data->mustStayInWindow)
+        m_data->removeFromSuperviewSoon = true;
+    else {
+        m_data->removeFromSuperviewSoon = false;
+        BEGIN_BLOCK_OBJC_EXCEPTIONS;
+        safeRemoveFromSuperview(getOuterView());
+        END_BLOCK_OBJC_EXCEPTIONS;
+    }
+}
+
+void Widget::beforeMouseDown(NSView *unusedView, Widget* widget)
+{
+    if (widget) {
+        ASSERT_UNUSED(unusedView, unusedView == widget->getOuterView());
+        ASSERT(!widget->m_data->mustStayInWindow);
+        widget->m_data->mustStayInWindow = true;
+    }
+}
+
+void Widget::afterMouseDown(NSView *view, Widget* widget)
+{
+    if (!widget) {
+        BEGIN_BLOCK_OBJC_EXCEPTIONS;
+        safeRemoveFromSuperview(view);
+        END_BLOCK_OBJC_EXCEPTIONS;
+    } else {
+        ASSERT(widget->m_data->mustStayInWindow);
+        widget->m_data->mustStayInWindow = false;
+        if (widget->m_data->removeFromSuperviewSoon)
+            widget->removeFromSuperview();
+    }
 }
 
 // These are here to deal with flipped coords on Mac.
index 7295fe7..5cb7983 100644 (file)
@@ -47,7 +47,7 @@ static HashMap<const Widget*, RenderWidget*>& widgetRendererMap()
     return *staticWidgetRendererMap;
 }
 
-static unsigned widgetHierarchyUpdateSuspendCount;
+static size_t widgetHierarchyUpdateSuspendCount;
 
 typedef HashMap<RefPtr<Widget>, FrameView*> WidgetToParentMap;