[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

hyatt at apple.com hyatt at apple.com
Wed Dec 22 18:32:15 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a60d0cea6c5df9c9fab7d9809875b4776b01cd91
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 13 20:14:28 2010 +0000

    WebCore: https://bugs.webkit.org/show_bug.cgi?id=48545, Home/End, PageUp/PageDwn should respect writing-mode.
    
    Reviewed by Sam Weinig.
    
    Add logical scrolling to WebCore.  It basically mirrors physical scrolling but works in abstract logical
    directions and only converts to physical when it's time to attempt the scroll.
    
    Also fixed bugs in scrollRecursively and logicalScrollRecursively where overflow sections in containing
    frames got skipped over.
    
    Made the resetting of the inline axis scroll position on Home/End Mac-specific for overflow sections.
    
    * WebCore.exp.in:
    * page/EventHandler.cpp:
    (WebCore::EventHandler::logicalScrollOverflow):
    (WebCore::EventHandler::scrollRecursively):
    (WebCore::EventHandler::logicalScrollRecursively):
    * page/EventHandler.h:
    * page/FrameView.cpp:
    (WebCore::FrameView::isVerticalDocument):
    (WebCore::FrameView::isFlippedDocument):
    * page/FrameView.h:
    * platform/ScrollTypes.h:
    (WebCore::logicalToPhysical):
    * platform/ScrollView.cpp:
    (WebCore::ScrollView::scroll):
    (WebCore::ScrollView::logicalScroll):
    * platform/ScrollView.h:
    (WebCore::ScrollView::isVerticalDocument):
    (WebCore::ScrollView::isFlippedDocument):
    * rendering/RenderBox.cpp:
    (WebCore::RenderBox::logicalScroll):
    * rendering/RenderBox.h:
    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::scroll):
    * rendering/RenderListBox.cpp:
    (WebCore::RenderListBox::logicalScroll):
    * rendering/RenderListBox.h:
    * rendering/RenderTextControlSingleLine.cpp:
    (WebCore::RenderTextControlSingleLine::logicalScroll):
    * rendering/RenderTextControlSingleLine.h:
    
    WebKit2: https://bugs.webkit.org/show_bug.cgi?id=48545, Home/End, PageUp/PageDwn should respect writing-mode.  Use
    logical scrolling instead of physical scrolling for those keys in WebKit2.
    
    Reviewed by Sam Weinig.
    
    * WebProcess/WebPage/mac/WebPageMac.mm:
    (WebKit::logicalScroll):
    (WebKit::WebPage::performDefaultBehaviorForKeyEvent):
    * WebProcess/WebPage/qt/WebPageQt.cpp:
    (WebKit::logicalScroll):
    (WebKit::WebPage::performDefaultBehaviorForKeyEvent):
    * WebProcess/WebPage/win/WebPageWin.cpp:
    (WebKit::logicalScroll):
    (WebKit::WebPage::performDefaultBehaviorForKeyEvent):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73941 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d1ace3c..89d885c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-12-13  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=48545, Home/End, PageUp/PageDwn should respect writing-mode. 
+
+        Add logical scrolling to WebCore.  It basically mirrors physical scrolling but works in abstract logical
+        directions and only converts to physical when it's time to attempt the scroll.
+        
+        Also fixed bugs in scrollRecursively and logicalScrollRecursively where overflow sections in containing
+        frames got skipped over.
+        
+        Made the resetting of the inline axis scroll position on Home/End Mac-specific for overflow sections.
+        
+        * WebCore.exp.in:
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::logicalScrollOverflow):
+        (WebCore::EventHandler::scrollRecursively):
+        (WebCore::EventHandler::logicalScrollRecursively):
+        * page/EventHandler.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::isVerticalDocument):
+        (WebCore::FrameView::isFlippedDocument):
+        * page/FrameView.h:
+        * platform/ScrollTypes.h:
+        (WebCore::logicalToPhysical):
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::scroll):
+        (WebCore::ScrollView::logicalScroll):
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::isVerticalDocument):
+        (WebCore::ScrollView::isFlippedDocument):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::logicalScroll):
+        * rendering/RenderBox.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scroll):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::logicalScroll):
+        * rendering/RenderListBox.h:
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::logicalScroll):
+        * rendering/RenderTextControlSingleLine.h:
+
 2010-12-13  Yury Semikhatsky  <yurys at chromium.org>
 
         Unreviewed. Rollout 73914, 73915, 73917, 73920 and 73921.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 4b1e663..f9480aa 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -223,6 +223,7 @@ __ZN7WebCore12EventHandler15handleAccessKeyERKNS_21PlatformKeyboardEventE
 __ZN7WebCore12EventHandler15sendScrollEventEv
 __ZN7WebCore12EventHandler16handleWheelEventERNS_18PlatformWheelEventE
 __ZN7WebCore12EventHandler17scrollRecursivelyENS_15ScrollDirectionENS_17ScrollGranularityEPNS_4NodeE
+__ZN7WebCore12EventHandler24logicalScrollRecursivelyENS_22ScrollLogicalDirectionENS_17ScrollGranularityEPNS_4NodeE
 __ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_8IntPointEbbNS_17HitTestScrollbarsEjRKNS_7IntSizeE
 __ZN7WebCore12EventHandler21handleMousePressEventERKNS_18PlatformMouseEventE
 __ZN7WebCore12EventHandler23handleMouseReleaseEventERKNS_18PlatformMouseEventE
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index a767849..662fc6e 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -997,22 +997,71 @@ bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g
     return false;
 }
 
+bool EventHandler::logicalScrollOverflow(ScrollLogicalDirection direction, ScrollGranularity granularity, Node* startingNode)
+{
+    Node* node = startingNode;
+
+    if (!node)
+        node = m_frame->document()->focusedNode();
+
+    if (!node)
+        node = m_mousePressNode.get();
+    
+    if (node) {
+        RenderObject* r = node->renderer();
+        if (r && !r->isListBox() && r->enclosingBox()->logicalScroll(direction, granularity)) {
+            setFrameWasScrolledByUser();
+            return true;
+        }
+    }
+
+    return false;
+}
+
 bool EventHandler::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity, Node* startingNode)
 {
     // The layout needs to be up to date to determine if we can scroll. We may be
     // here because of an onLoad event, in which case the final layout hasn't been performed yet.
     m_frame->document()->updateLayoutIgnorePendingStylesheets();
-    bool handled = scrollOverflow(direction, granularity, startingNode);
-    if (!handled) {
-        Frame* frame = m_frame;
-        do {
-            FrameView* view = frame->view();
-            handled = view ? view->scroll(direction, granularity) : false;
-            frame = frame->tree()->parent();
-        } while (!handled && frame);
-     }
+    if (scrollOverflow(direction, granularity, startingNode))
+        return true;    
+    Frame* frame = m_frame;
+    FrameView* view = frame->view();
+    if (view && view->scroll(direction, granularity))
+        return true;
+    frame = frame->tree()->parent();
+    if (!frame)
+        return false;
+    return frame->eventHandler()->scrollRecursively(direction, granularity, m_frame->document()->ownerElement());
+}
 
-    return handled;
+bool EventHandler::logicalScrollRecursively(ScrollLogicalDirection direction, ScrollGranularity granularity, Node* startingNode)
+{
+    // The layout needs to be up to date to determine if we can scroll. We may be
+    // here because of an onLoad event, in which case the final layout hasn't been performed yet.
+    m_frame->document()->updateLayoutIgnorePendingStylesheets();
+    if (logicalScrollOverflow(direction, granularity, startingNode))
+        return true;    
+    Frame* frame = m_frame;
+    FrameView* view = frame->view();
+    
+    bool scrolled = false;
+#if PLATFORM(MAC)
+    // Mac also resets the scroll position in the inline direction.
+    if (granularity == ScrollByDocument && view && view->logicalScroll(ScrollInlineDirectionBackward, ScrollByDocument))
+        scrolled = true;
+#endif
+    if (view && view->logicalScroll(direction, granularity))
+        scrolled = true;
+    
+    if (scrolled)
+        return true;
+    
+    frame = frame->tree()->parent();
+    if (!frame)
+        return false;
+
+    return frame->eventHandler()->logicalScrollRecursively(direction, granularity, m_frame->document()->ownerElement());
 }
 
 IntPoint EventHandler::currentMousePosition() const
diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h
index ca19a0c..65695c2 100644
--- a/WebCore/page/EventHandler.h
+++ b/WebCore/page/EventHandler.h
@@ -133,8 +133,10 @@ public:
     static Frame* subframeForTargetNode(Node*);
 
     bool scrollOverflow(ScrollDirection, ScrollGranularity, Node* startingNode = 0);
+    bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = 0);
 
     bool scrollRecursively(ScrollDirection, ScrollGranularity, Node* startingNode = 0);
+    bool logicalScrollRecursively(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = 0);
 
 #if ENABLE(DRAG_SUPPORT)
     bool shouldDragAutoNode(Node*, const IntPoint&) const; // -webkit-user-drag == auto
diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp
index fdd6e93..37049b8 100644
--- a/WebCore/page/FrameView.cpp
+++ b/WebCore/page/FrameView.cpp
@@ -2437,4 +2437,30 @@ void FrameView::setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(d
     s_deferredRepaintDelayIncrementDuringLoading = p;
 }
 
+bool FrameView::isVerticalDocument() const
+{
+    if (!m_frame)
+        return true;
+    Document* doc = m_frame->document();
+    if (!doc)
+        return true;
+    RenderObject* renderView = doc->renderer();
+    if (!renderView)
+        return true;
+    return renderView->style()->isHorizontalWritingMode();
+}
+
+bool FrameView::isFlippedDocument() const
+{
+    if (!m_frame)
+        return false;
+    Document* doc = m_frame->document();
+    if (!doc)
+        return false;
+    RenderObject* renderView = doc->renderer();
+    if (!renderView)
+        return false;
+    return renderView->style()->isFlippedBlocksWritingMode();
+}
+    
 } // namespace WebCore
diff --git a/WebCore/page/FrameView.h b/WebCore/page/FrameView.h
index 42b2096..d132916 100644
--- a/WebCore/page/FrameView.h
+++ b/WebCore/page/FrameView.h
@@ -250,6 +250,9 @@ protected:
     virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
     virtual void scrollContentsSlowPath(const IntRect& updateRect);
 
+    virtual bool isVerticalDocument() const;
+    virtual bool isFlippedDocument() const;
+
 private:
     FrameView(Frame*);
 
diff --git a/WebCore/platform/ScrollTypes.h b/WebCore/platform/ScrollTypes.h
index eba9055..f07fb1a 100644
--- a/WebCore/platform/ScrollTypes.h
+++ b/WebCore/platform/ScrollTypes.h
@@ -35,6 +35,72 @@ namespace WebCore {
         ScrollRight
     };
 
+    enum ScrollLogicalDirection {
+        ScrollBlockDirectionBackward,
+        ScrollBlockDirectionForward,
+        ScrollInlineDirectionBackward,
+        ScrollInlineDirectionForward
+    };
+    
+    
+    inline ScrollDirection logicalToPhysical(ScrollLogicalDirection direction, bool isVertical, bool isFlipped) 
+    {
+        switch (direction) {
+        case ScrollBlockDirectionBackward: {
+            if (isVertical) {
+                if (!isFlipped)
+                    return ScrollUp;
+                return ScrollDown;
+            } else {
+                if (!isFlipped)
+                    return ScrollLeft;
+                return ScrollRight;
+            }
+            break;
+        }
+        case ScrollBlockDirectionForward: {
+            if (isVertical) {
+                if (!isFlipped)
+                    return ScrollDown;
+                return ScrollUp;
+            } else {
+                if (!isFlipped)
+                    return ScrollRight;
+                return ScrollLeft;
+            }
+            break;
+        }
+        case ScrollInlineDirectionBackward: {
+            if (isVertical) {
+                if (!isFlipped)
+                    return ScrollLeft;
+                return ScrollRight;
+            } else {
+                if (!isFlipped)
+                    return ScrollUp;
+                return ScrollDown;
+            }
+            break;
+        }
+        case ScrollInlineDirectionForward: {
+            if (isVertical) {
+                if (!isFlipped)
+                    return ScrollRight;
+                return ScrollLeft;
+            } else {
+                if (!isFlipped)
+                    return ScrollDown;
+                return ScrollUp;
+            }
+            break;
+        }
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+        }
+        return ScrollUp;
+    }
+
     enum ScrollGranularity {
         ScrollByLine,
         ScrollByPage,
diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp
index ca9e336..7d9e792 100644
--- a/WebCore/platform/ScrollView.cpp
+++ b/WebCore/platform/ScrollView.cpp
@@ -372,7 +372,7 @@ bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity
 {
     if (platformWidget())
         return platformScroll(direction, granularity);
-
+    
     if (direction == ScrollUp || direction == ScrollDown) {
         if (m_verticalScrollbar)
             return m_verticalScrollbar->scroll(direction, granularity);
@@ -383,6 +383,11 @@ bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity
     return false;
 }
 
+bool ScrollView::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity)
+{
+    return scroll(logicalToPhysical(direction, isVerticalDocument(), isFlippedDocument()), granularity);
+}
+
 void ScrollView::windowResizerRectChanged()
 {
     if (platformWidget())
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
index 7e846bc..ed33098 100644
--- a/WebCore/platform/ScrollView.h
+++ b/WebCore/platform/ScrollView.h
@@ -172,7 +172,10 @@ public:
 
     // This function scrolls by lines, pages or pixels.
     bool scroll(ScrollDirection, ScrollGranularity);
-        
+    
+    // A logical scroll that just ends up calling the corresponding physical scroll() based off the document's writing mode.
+    bool logicalScroll(ScrollLogicalDirection, ScrollGranularity);
+
     // Scroll the actual contents of the view (either blitting or invalidating as needed).
     void scrollContents(const IntSize& scrollDelta);
 
@@ -285,6 +288,10 @@ protected:
     void setScrollOrigin(const IntPoint&, bool updatePosition);
     IntPoint scrollOrigin() { return m_scrollOrigin; }
 
+    // Subclassed by FrameView to check the writing-mode of the document.
+    virtual bool isVerticalDocument() const { return true; }
+    virtual bool isFlippedDocument() const { return false; }
+
 private:
     RefPtr<Scrollbar> m_horizontalScrollbar;
     RefPtr<Scrollbar> m_verticalScrollbar;
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index aa845d5..b932a33 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -585,6 +585,36 @@ bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity,
     return false;
 }
 
+bool RenderBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
+{
+    bool scrolled = false;
+    
+    RenderLayer* l = layer();
+    if (l) {
+#if PLATFORM(MAC)
+        // On Mac only we reset the inline direction position when doing a document scroll (e.g., hitting Home/End).
+        if (granularity == ScrollByDocument)
+            scrolled = l->scroll(logicalToPhysical(ScrollInlineDirectionBackward, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), ScrollByDocument, multiplier);
+#endif
+        if (l->scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier))
+            scrolled = true;
+        
+        if (scrolled) {
+            if (stopNode)
+                *stopNode = node();
+            return true;
+        }
+    }
+
+    if (stopNode && *stopNode && *stopNode == node())
+        return true;
+
+    RenderBlock* b = containingBlock();
+    if (b && !b->isRenderView())
+        return b->logicalScroll(direction, granularity, multiplier, stopNode);
+    return false;
+}
+
 bool RenderBox::canBeScrolledAndHasScrollableArea() const
 {
     return canBeProgramaticallyScrolled(false) && (scrollHeight() != clientHeight() || scrollWidth() != clientWidth());
diff --git a/WebCore/rendering/RenderBox.h b/WebCore/rendering/RenderBox.h
index 0cbe535..d68d174 100644
--- a/WebCore/rendering/RenderBox.h
+++ b/WebCore/rendering/RenderBox.h
@@ -312,6 +312,7 @@ public:
     int horizontalScrollbarHeight() const;
     int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
+    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
     bool canBeScrolledAndHasScrollableArea() const;
     virtual bool canBeProgramaticallyScrolled(bool) const;
     virtual void autoscroll();
diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp
index 84dbd8f..6b97e57 100644
--- a/WebCore/rendering/RenderLayer.cpp
+++ b/WebCore/rendering/RenderLayer.cpp
@@ -2305,14 +2305,9 @@ bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularit
 {
     bool didHorizontalScroll = false;
     bool didVerticalScroll = false;
-    
-    if (m_hBar) {
-        // Special-case for the ScrollByDocument granularity. A document scroll
-        // can only be up or down and in both cases the horizontal bar goes all
-        // the way to the left.
-        didHorizontalScroll = m_hBar->scroll((granularity == ScrollByDocument) ? ScrollLeft : direction, granularity, multiplier);
-    }
 
+    if (m_hBar)
+        didHorizontalScroll = m_hBar->scroll(direction, granularity, multiplier);
     if (m_vBar)
         didVerticalScroll = m_vBar->scroll(direction, granularity, multiplier);
 
diff --git a/WebCore/rendering/RenderListBox.cpp b/WebCore/rendering/RenderListBox.cpp
index 5717871..ed7f8ee 100644
--- a/WebCore/rendering/RenderListBox.cpp
+++ b/WebCore/rendering/RenderListBox.cpp
@@ -515,6 +515,11 @@ bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granular
     return m_vBar && m_vBar->scroll(direction, granularity, multiplier);
 }
 
+bool RenderListBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node**)
+{
+    return m_vBar && m_vBar->scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier);
+}
+
 void RenderListBox::valueChanged(unsigned listIndex)
 {
     Element* element = static_cast<Element*>(node());
diff --git a/WebCore/rendering/RenderListBox.h b/WebCore/rendering/RenderListBox.h
index 69acb57..1fbff0d 100644
--- a/WebCore/rendering/RenderListBox.h
+++ b/WebCore/rendering/RenderListBox.h
@@ -69,6 +69,7 @@ private:
     virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
 
     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
+    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
 
     virtual void computePreferredLogicalWidths();
     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
diff --git a/WebCore/rendering/RenderTextControlSingleLine.cpp b/WebCore/rendering/RenderTextControlSingleLine.cpp
index 93d34ee..c815be1 100644
--- a/WebCore/rendering/RenderTextControlSingleLine.cpp
+++ b/WebCore/rendering/RenderTextControlSingleLine.cpp
@@ -1086,6 +1086,14 @@ bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranul
     return RenderBlock::scroll(direction, granularity, multiplier, stopNode);
 }
 
+bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
+{
+    RenderLayer* layer = innerTextElement()->renderBox()->layer();
+    if (layer && layer->scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier))
+        return true;
+    return RenderBlock::logicalScroll(direction, granularity, multiplier, stopNode);
+}
+
 PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize)
 {
     RefPtr<Scrollbar> widget;
diff --git a/WebCore/rendering/RenderTextControlSingleLine.h b/WebCore/rendering/RenderTextControlSingleLine.h
index 3dd25ef..51509c0 100644
--- a/WebCore/rendering/RenderTextControlSingleLine.h
+++ b/WebCore/rendering/RenderTextControlSingleLine.h
@@ -87,6 +87,7 @@ private:
     virtual void setScrollLeft(int);
     virtual void setScrollTop(int);
     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
+    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
 
     int textBlockWidth() const;
     virtual float getAvgCharWidth(AtomicString family);
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 18eb39f..b685bb2 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,20 @@
+2010-12-13  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=48545, Home/End, PageUp/PageDwn should respect writing-mode.  Use
+        logical scrolling instead of physical scrolling for those keys in WebKit2.
+
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::logicalScroll):
+        (WebKit::WebPage::performDefaultBehaviorForKeyEvent):
+        * WebProcess/WebPage/qt/WebPageQt.cpp:
+        (WebKit::logicalScroll):
+        (WebKit::WebPage::performDefaultBehaviorForKeyEvent):
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::logicalScroll):
+        (WebKit::WebPage::performDefaultBehaviorForKeyEvent):
+
 2010-12-13  Brian Weinstein  <bweinstein at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm b/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
index 022e2a0..1e80522 100644
--- a/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
+++ b/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
@@ -243,6 +243,11 @@ static inline void scroll(Page* page, ScrollDirection direction, ScrollGranulari
     page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
 }
 
+static inline void logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
+{
+    page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
+}
+
 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
 {
     if (keyboardEvent.type() != WebEvent::KeyDown)
@@ -259,23 +264,21 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
         break;
     case VK_SPACE:
         if (keyboardEvent.shiftKey())
-            scroll(m_page.get(), ScrollUp, ScrollByPage);
+            logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByPage);
         else
-            scroll(m_page.get(), ScrollDown, ScrollByPage);
+            logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByPage);
         break;
     case VK_PRIOR:
-        scroll(m_page.get(), ScrollUp, ScrollByPage);
+        logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByPage);
         break;
     case VK_NEXT:
-        scroll(m_page.get(), ScrollDown, ScrollByPage);
+        logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByPage);
         break;
     case VK_HOME:
-        scroll(m_page.get(), ScrollUp, ScrollByDocument);
-        scroll(m_page.get(), ScrollLeft, ScrollByDocument);
+        logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByDocument);
         break;
     case VK_END:
-        scroll(m_page.get(), ScrollDown, ScrollByDocument);
-        scroll(m_page.get(), ScrollLeft, ScrollByDocument);
+        logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByDocument);
         break;
     case VK_UP:
         if (keyboardEvent.shiftKey())
diff --git a/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp b/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp
index 2562583..b65fa18 100644
--- a/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp
+++ b/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp
@@ -213,6 +213,11 @@ static inline void scroll(Page* page, ScrollDirection direction, ScrollGranulari
     page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
 }
 
+static inline void logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
+{
+    page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
+}
+
 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
 {
     if (keyboardEvent.type() != WebEvent::KeyDown && keyboardEvent.type() != WebEvent::RawKeyDown)
@@ -226,7 +231,7 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
             m_page->goBack();
         break;
     case VK_SPACE:
-        scroll(m_page.get(), keyboardEvent.shiftKey() ? ScrollUp : ScrollDown, ScrollByPage);
+        logicalScroll(m_page.get(), keyboardEvent.shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward, ScrollByPage);
         break;
     case VK_LEFT:
         scroll(m_page.get(), ScrollLeft, ScrollByLine);
@@ -241,16 +246,16 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
         scroll(m_page.get(), ScrollDown, ScrollByLine);
         break;
     case VK_HOME:
-        scroll(m_page.get(), ScrollUp, ScrollByDocument);
+        logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByDocument);
         break;
     case VK_END:
-        scroll(m_page.get(), ScrollDown, ScrollByDocument);
+        logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByDocument);
         break;
     case VK_PRIOR:
-        scroll(m_page.get(), ScrollUp, ScrollByPage);
+        logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByPage);
         break;
     case VK_NEXT:
-        scroll(m_page.get(), ScrollDown, ScrollByPage);
+        logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByPage);
         break;
     default:
         return false;
diff --git a/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp b/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
index 0e4a047..9027b58 100644
--- a/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
+++ b/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
@@ -188,6 +188,11 @@ static inline void scroll(Page* page, ScrollDirection direction, ScrollGranulari
     page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
 }
 
+static inline void logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
+{
+    page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
+}
+
 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
 {
     if (keyboardEvent.type() != WebEvent::KeyDown && keyboardEvent.type() != WebEvent::RawKeyDown)
@@ -200,6 +205,9 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
         else
             m_page->goBack();
         break;
+    case VK_SPACE:
+        logicalScroll(m_page.get(), keyboardEvent.shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward, ScrollByPage);
+        break;
     case VK_LEFT:
         scroll(m_page.get(), ScrollLeft, ScrollByLine);
         break;
@@ -213,16 +221,16 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
         scroll(m_page.get(), ScrollDown, ScrollByLine);
         break;
     case VK_HOME:
-        scroll(m_page.get(), ScrollUp, ScrollByDocument);
+        logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByDocument);
         break;
     case VK_END:
-        scroll(m_page.get(), ScrollDown, ScrollByDocument);
+        logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByDocument);
         break;
     case VK_PRIOR:
-        scroll(m_page.get(), ScrollUp, ScrollByPage);
+        logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByPage);
         break;
     case VK_NEXT:
-        scroll(m_page.get(), ScrollDown, ScrollByPage);
+        logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByPage);
         break;
     default:
         return false;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list