Reviewed by Mark Rowe.
authoralp <alp@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 3 Nov 2007 14:32:43 +0000 (14:32 +0000)
committeralp <alp@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 3 Nov 2007 14:32:43 +0000 (14:32 +0000)
Frame scrolling and invalidation fixes

Make upward scroll events have a positive delta to match other ports.

Fix the invalidation rect offset for frames so that scrolling works properly.

Avoid allocating negative sizes to widgets to avoid GTK+ warnings.

Allow tabbing to all widgets and links.

Fix event returns, improving the focus situation and correcting scroll wheel
behavior.

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

WebCore/ChangeLog
WebCore/page/gtk/EventHandlerGtk.cpp
WebCore/platform/gtk/ScrollViewGtk.cpp
WebCore/platform/gtk/WheelEventGtk.cpp
WebKit/gtk/Api/webkitgtkpage.cpp
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp

index dd47e117ab166a25e57a1249a5a685a76cb85d5a..561c21a8d866bf69e090e916ac9f5311b3ebdfb4 100644 (file)
@@ -1,3 +1,32 @@
+2007-11-03  Alp Toker  <alp@atoker.com>
+
+        Reviewed by Mark Rowe.
+
+        Frame scrolling and invalidation fixes
+
+        Make upward scroll events have a positive delta to match other ports.
+
+        Fix the invalidation rect offset for frames so that scrolling works properly.
+
+        Avoid allocating negative sizes to widgets to avoid GTK+ warnings.
+
+        Allow tabbing to all widgets and links.
+
+        Fix event returns, improving the focus situation and correcting scroll wheel
+        behavior.
+
+        * page/gtk/EventHandlerGtk.cpp:
+        (WebCore::EventHandler::tabsToAllControls):
+        (WebCore::EventHandler::passWheelEventToWidget):
+        * platform/gtk/ScrollViewGtk.cpp:
+        (WebCore::ScrollViewScrollbar::geometryChanged):
+        (WebCore::ScrollView::updateContents):
+        (WebCore::ScrollView::update):
+        (WebCore::ScrollView::wheelEvent):
+        (WebCore::ScrollView::updateScrollbars):
+        * platform/gtk/WheelEventGtk.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+
 2007-11-03  David D. Kilzer  <ddkilzer@webkit.org>
 
         LGPL'ed files contain incorrect FSF address
index ab01471c0637ee5aff9ed804bbb092becfc2b71a..32e08bfa93a6aa2d958723d30fe557ebcf0543db 100644 (file)
@@ -44,17 +44,10 @@ namespace WebCore {
 
 using namespace EventNames;
 
-static bool isKeyboardOptionTab(KeyboardEvent* event)
-{
-    return event
-        && (event->type() == keydownEvent || event->type() == keypressEvent)
-        && event->altKey()
-        && event->keyIdentifier() == "U+0009";
-}
-
 bool EventHandler::tabsToAllControls(KeyboardEvent* event) const
 {
-    return isKeyboardOptionTab(event);
+    // We always allow tabs to all controls
+    return true;
 }
 
 void EventHandler::focusDocumentView()
@@ -93,10 +86,13 @@ bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const
     return false;
 }
 
-bool EventHandler::passWheelEventToWidget(PlatformWheelEvent&, Widget* widget)
+bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& event, Widget* widget)
 {
-    notImplemented();
-    return false;
+    ASSERT(widget);
+    if (!widget->isFrameView())
+        return false;
+
+    return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(event);
 }
 
 Clipboard* EventHandler::createDraggingClipboard() const 
index 5fded5c44aac942793171f296ca204479bb8327e..209c08f3144a2a17cf828afce14cdbeeba90243b 100644 (file)
@@ -126,8 +126,13 @@ void ScrollViewScrollbar::geometryChanged()
     ASSERT(parent()->isFrameView());
 
     FrameView* frameView = static_cast<FrameView*>(parent());
-    IntRect windowRect = IntRect(frameView->convertToContainingWindow(frameGeometry().location()), frameGeometry().size());
-    GtkAllocation allocation = { windowRect.x(), windowRect.y(), windowRect.width(), windowRect.height() };
+    IntPoint loc = frameView->convertToContainingWindow(frameGeometry().location());
+
+    // Don't allow the allocation size to be negative
+    IntSize sz = frameGeometry().size();
+    sz.clampNegativeToZero();
+
+    GtkAllocation allocation = { loc.x(), loc.y(), sz.width(), sz.height() };
     gtk_widget_size_allocate(gtkWidget(), &allocation);
 }
 
@@ -292,10 +297,7 @@ void ScrollView::updateContents(const IntRect& updateRect, bool now)
     IntRect containingWindowRect = updateRect;
     containingWindowRect.setLocation(windowPoint);
 
-    GdkRectangle rect = { containingWindowRect.x(),
-                          containingWindowRect.y(),
-                          containingWindowRect.width(),
-                          containingWindowRect.height() };
+    GdkRectangle rect = containingWindowRect;
     GdkWindow* window = GTK_WIDGET(containingWindow())->window;
 
     if (window)
@@ -312,7 +314,7 @@ void ScrollView::update()
 {
     ASSERT(containingWindow());
 
-    GdkRectangle rect = { 0, 0, m_data->contentsSize.width(), m_data->contentsSize.height() };
+    GdkRectangle rect = frameGeometry();
     gdk_window_invalidate_rect(GTK_WIDGET(containingWindow())->window, &rect, true);
 }
 
@@ -505,7 +507,7 @@ void ScrollView::wheelEvent(PlatformWheelEvent& e)
         (e.deltaY() > 0 && scrollOffset().height() > 0))
         e.accept();
 
-    scrollBy(e.deltaX() * LINE_STEP, e.deltaY() * LINE_STEP);
+    scrollBy(-e.deltaX() * LINE_STEP, -e.deltaY() * LINE_STEP);
 }
 
 void ScrollView::updateScrollbars(const IntSize& desiredOffset)
@@ -574,6 +576,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
         m_data->horizontalAdjustment->page_size = visibleWidth();
         m_data->horizontalAdjustment->step_increment = visibleWidth() / 10.0;
         m_data->horizontalAdjustment->page_increment = visibleWidth() * 0.9;
+        m_data->horizontalAdjustment->lower = 0;
         m_data->horizontalAdjustment->upper = contentsWidth();
         gtk_adjustment_changed(m_data->horizontalAdjustment);
 
@@ -608,6 +611,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
         m_data->verticalAdjustment->page_size = visibleHeight();
         m_data->verticalAdjustment->step_increment = visibleHeight() / 10.0;
         m_data->verticalAdjustment->page_increment = visibleHeight() * 0.9;
+        m_data->verticalAdjustment->lower = 0;
         m_data->verticalAdjustment->upper = contentsHeight();
         gtk_adjustment_changed(m_data->verticalAdjustment);
 
index 6ca981fac7e5a3f32ee6e9fbdaa2638de3ad8f31..f219ad33fb988877e234442912160875885c4ca4 100644 (file)
@@ -34,19 +34,26 @@ namespace WebCore {
 
 PlatformWheelEvent::PlatformWheelEvent(GdkEventScroll* event)
 {
-    static const float delta = 0.25f;
+    static const float delta = 1;
 
     m_deltaX = 0;
     m_deltaY = 0;
 
-    if (event->direction == GDK_SCROLL_UP)
-        m_deltaY = -delta;
-    else if (event->direction == GDK_SCROLL_LEFT)
-        m_deltaX = -delta;
-    else if (event->direction == GDK_SCROLL_RIGHT)
-        m_deltaX = delta;
-    else
-        m_deltaY = delta;
+    // Docs say an upwards scroll (away from the user) has a positive delta
+    switch (event->direction) {
+        case GDK_SCROLL_UP:
+            m_deltaY = delta;
+            break;
+        case GDK_SCROLL_DOWN:
+            m_deltaY = -delta;
+            break;
+        case GDK_SCROLL_LEFT:
+            m_deltaX = -delta;
+            break;
+        case GDK_SCROLL_RIGHT:
+            m_deltaX = delta;
+            break;
+    }
 
     m_position = IntPoint((int)event->x, (int)event->y);
     m_globalPosition = IntPoint((int)event->x_root, (int)event->y_root);
index c92ef7771cc621dd50eb12f8cbf9f2ad09456976..d95a0bb93128e3dfa0a8aa88fcd047bfe445a526 100644 (file)
@@ -81,8 +81,7 @@ static gboolean webkit_page_expose_event(GtkWidget* widget, GdkEventExpose* even
     ctx.setGdkExposeEvent(event);
     if (frame->renderer()) {
         frame->view()->layoutIfNeededRecursive();
-        IntRect rect(clip.x, clip.y, clip.width, clip.height);
-        frame->view()->paint(&ctx, rect);
+        frame->view()->paint(&ctx, clip);
     }
     cairo_destroy(cr);
 
@@ -92,40 +91,36 @@ static gboolean webkit_page_expose_event(GtkWidget* widget, GdkEventExpose* even
 static gboolean webkit_page_key_event(GtkWidget* widget, GdkEventKey* event)
 {
     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
-    frame->eventHandler()->keyEvent(PlatformKeyboardEvent(event));
-    return FALSE;
+    return frame->eventHandler()->keyEvent(PlatformKeyboardEvent(event));
 }
 
 static gboolean webkit_page_button_event(GtkWidget* widget, GdkEventButton* event)
 {
     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
 
-    if (event->type == GDK_BUTTON_RELEASE)
-        frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
-    else {
-        frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
-
-        //FIXME need to keep track of subframe focus for key events!
-        gtk_widget_grab_focus(GTK_WIDGET(widget));
+    switch (event->type) {
+        case GDK_BUTTON_PRESS:
+            // FIXME: need to keep track of subframe focus for key events
+            gtk_widget_grab_focus(GTK_WIDGET(widget));
+            return frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
+        case GDK_BUTTON_RELEASE:
+            return frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
+        default:
+            return FALSE;
     }
-
-    return FALSE;
 }
 
 static gboolean webkit_page_motion_event(GtkWidget* widget, GdkEventMotion* event)
 {
     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
-    frame->eventHandler()->mouseMoved(PlatformMouseEvent(event));
-    return FALSE;
+    return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event));
 }
 
 static gboolean webkit_page_scroll_event(GtkWidget* widget, GdkEventScroll* event)
 {
     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
-
     PlatformWheelEvent wheelEvent(event);
-    frame->eventHandler()->handleWheelEvent(wheelEvent);
-    return FALSE;
+    return frame->eventHandler()->handleWheelEvent(wheelEvent);
 }
 
 static void webkit_page_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
index f09803b1c892fe8e2c58825af4bb3718257d4911..9c06ac86932fb4254ac87563778df04311b2dfaf 100644 (file)
@@ -1,3 +1,23 @@
+2007-11-03  Alp Toker  <alp@atoker.com>
+
+        Reviewed by Mark Rowe.
+
+        Frame scrolling and invalidation fixes
+
+        Make upward scroll events have a positive delta to match other ports.
+
+        Fix the invalidation rect offset for frames so that scrolling works properly.
+
+        Avoid allocating negative sizes to widgets to avoid GTK+ warnings.
+
+        Allow tabbing to all widgets and links.
+
+        Fix event returns, improving the focus situation and correcting scroll wheel
+        behavior.
+
+        * Api/webkitgtkpage.cpp:
+        * WebCoreSupport/ChromeClientGtk.cpp:
+
 2007-10-29  Alp Toker  <alp@atoker.com>
 
         Reviewed by Maciej.
index b922b8a42fbf36dc6020ae350f6db1f516fe1e22..2a7e5831dae8f55247f7229d580b8c186fc23e3d 100644 (file)
@@ -245,8 +245,7 @@ bool ChromeClient::shouldInterruptJavaScript()
 
 bool ChromeClient::tabsToLinks() const
 {
-    notImplemented();
-    return false;
+    return true;
 }
 
 IntRect ChromeClient::windowResizerRect() const