Title: [107990] trunk/Source/WebKit/blackberry
Revision
107990
Author
[email protected]
Date
2012-02-16 16:04:11 -0800 (Thu, 16 Feb 2012)

Log Message

2012-02-16 Antonio Gomes <[email protected]>

        [BlackBerry] Upstream touch handling related classes (Part III: InRegionScrollableArea)
        https://bugs.webkit.org/show_bug.cgi?id=78509

        Reviewed by Adam Treat and Rob Buis.

        InRegionScrollableArea specializes the BlackBerry specific ScrollViewBase,
        working as a read-only wrapper object for a scrollable areas in the page.
        It is used in our client side to control in-region scrolling (scrollable boxes,
        inner frames, etc).

        Initial upstream.

        * WebKitSupport/InRegionScrollableArea.cpp: Added.
        (WebKit):
        (BlackBerry::WebKit::InRegionScrollableArea::InRegionScrollableArea):
        (BlackBerry::WebKit::InRegionScrollableArea::calculateMinimumScrollPosition):
        (BlackBerry::WebKit::InRegionScrollableArea::calculateMaximumScrollPosition):
        (BlackBerry::WebKit::InRegionScrollableArea::layer):
        (BlackBerry):
        * WebKitSupport/InRegionScrollableArea.h: Added.
        (WebCore):
        (WebKit):
        (InRegionScrollableArea):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (107989 => 107990)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-02-16 23:59:27 UTC (rev 107989)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-02-17 00:04:11 UTC (rev 107990)
@@ -3,7 +3,7 @@
         [BlackBerry] Upstream touch handling related classes
         https://bugs.webkit.org/show_bug.cgi?id=78509
 
-        Reviewed by Rob Buis.
+        Reviewed by Adam Treat and Rob Buis.
 
         FatFingers is the class responsible to the whole touch
         accuracy of the BlackBerry port. Initial upstream.
@@ -48,7 +48,7 @@
         [BlackBerry] Upstream touch handling related classes
         https://bugs.webkit.org/show_bug.cgi?id=78509
 
-        Reviewed by Rob Buis.
+        Reviewed by Adam Treat.
 
         Initial upstream of the Blackberry specific single touch event
         handler class.
@@ -62,6 +62,32 @@
         (BlackBerry::WebKit::TouchEventHandler::TouchEventHandler):
         (BlackBerry::WebKit::TouchEventHandler::~TouchEventHandler):
         (BlackBerry::WebKit::TouchEventHandler::shouldSuppressMouseDownOnTouchDown):
+        [BlackBerry] Upstream touch handling related classes
+        https://bugs.webkit.org/show_bug.cgi?id=78509
+
+        Reviewed by Rob Buis.
+
+        InRegionScrollableArea specializes the BlackBerry specific ScrollViewBase,
+        working as a read-only wrapper object for a scrollable areas in the page.
+        It is used in our client side to control in-region scrolling (scrollable boxes,
+        inner frames, etc).
+
+        Initial upstream.
+
+        * WebKitSupport/InRegionScrollableArea.cpp: Added.
+        (WebKit):
+        (BlackBerry::WebKit::InRegionScrollableArea::InRegionScrollableArea):
+        (BlackBerry::WebKit::InRegionScrollableArea::calculateMinimumScrollPosition):
+        (BlackBerry::WebKit::InRegionScrollableArea::calculateMaximumScrollPosition):
+        (BlackBerry::WebKit::InRegionScrollableArea::layer):
+        (BlackBerry):
+        * WebKitSupport/InRegionScrollableArea.h: Added.
+        (WebCore):
+        (WebKit):
+        (InRegionScrollableArea):
+
+2012-02-16  Antonio Gomes  <[email protected]>
+
         (BlackBerry::WebKit::TouchEventHandler::touchEventCancel):
         (BlackBerry::WebKit::TouchEventHandler::touchHoldEvent):
         (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):

Added: trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.cpp (0 => 107990)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.cpp	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.cpp	2012-02-17 00:04:11 UTC (rev 107990)
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "InRegionScrollableArea.h"
+
+#include "Frame.h"
+#include "NotImplemented.h"
+#include "RenderBox.h"
+#include "RenderLayer.h"
+#include "RenderObject.h"
+#include "RenderView.h"
+#include "WebPage_p.h"
+
+using namespace WebCore;
+
+namespace BlackBerry {
+namespace WebKit {
+
+InRegionScrollableArea::InRegionScrollableArea()
+    : m_webPage(0)
+    , m_layer(0)
+{
+}
+
+InRegionScrollableArea::InRegionScrollableArea(WebPagePrivate* webPage, RenderLayer* layer)
+    : m_webPage(webPage)
+    , m_layer(layer)
+{
+    ASSERT(webPage);
+    ASSERT(layer);
+    m_isNull = false;
+
+    // FIXME: Add an ASSERT here as the 'layer' must be scrollable.
+
+    RenderObject* layerRenderer = layer->renderer();
+    ASSERT(layerRenderer);
+
+    if (layerRenderer->isRenderView()) { // #document case
+
+        FrameView* view = toRenderView(layerRenderer)->frameView();
+        ASSERT(view);
+
+        Frame* frame = view->frame();
+        ASSERT_UNUSED(frame, frame);
+
+        m_scrollPosition = m_webPage->mapToTransformed(view->scrollPosition());
+        m_contentsSize = m_webPage->mapToTransformed(view->contentsSize());
+        m_viewportRect = m_webPage->mapToTransformed(view->visibleContentRect(false /*includeScrollbars*/));
+
+        m_visibleWindowRect = m_webPage->mapToTransformed(m_webPage->getRecursiveVisibleWindowRect(view));
+        IntRect transformedWindowRect = IntRect(IntPoint::zero(), m_webPage->transformedViewportSize());
+        m_visibleWindowRect.intersect(transformedWindowRect);
+
+        m_scrollsHorizontally = view->contentsWidth() > view->visibleWidth();
+        m_scrollsVertically = view->contentsHeight() > view->visibleHeight();
+
+        m_minimumScrollPosition = m_webPage->mapToTransformed(calculateMinimumScrollPosition(
+            view->visibleContentRect().size(),
+            0.0 /*overscrollLimit*/));
+        m_maximumScrollPosition = m_webPage->mapToTransformed(calculateMaximumScrollPosition(
+            view->visibleContentRect().size(),
+            view->contentsSize(),
+            0.0 /*overscrollLimit*/));
+
+    } else { // RenderBox-based elements case (scrollable boxes (div's, p's, textarea's, etc)).
+
+        RenderBox* box = m_layer->renderBox();
+        ASSERT(box);
+        ASSERT(box->canBeScrolledAndHasScrollableArea());
+
+        ScrollableArea* scrollableArea = static_cast<ScrollableArea*>(m_layer);
+        m_scrollPosition = m_webPage->mapToTransformed(scrollableArea->scrollPosition());
+        m_contentsSize = m_webPage->mapToTransformed(scrollableArea->contentsSize());
+        m_viewportRect = m_webPage->mapToTransformed(scrollableArea->visibleContentRect(false /*includeScrollbars*/));
+
+        m_visibleWindowRect = m_layer->renderer()->absoluteClippedOverflowRect();
+        m_visibleWindowRect = m_layer->renderer()->frame()->view()->contentsToWindow(m_visibleWindowRect);
+        IntRect visibleFrameWindowRect = m_webPage->getRecursiveVisibleWindowRect(m_layer->renderer()->frame()->view());
+        m_visibleWindowRect.intersect(visibleFrameWindowRect);
+        m_visibleWindowRect = m_webPage->mapToTransformed(m_visibleWindowRect);
+        IntRect transformedWindowRect = IntRect(IntPoint::zero(), m_webPage->transformedViewportSize());
+        m_visibleWindowRect.intersect(transformedWindowRect);
+
+        m_scrollsHorizontally = box->scrollWidth() != box->clientWidth() && box->scrollsOverflowX();
+        m_scrollsVertically = box->scrollHeight() != box->clientHeight() && box->scrollsOverflowY();
+
+        m_minimumScrollPosition = m_webPage->mapToTransformed(calculateMinimumScrollPosition(
+            Platform::IntSize(box->clientWidth(), box->clientHeight()),
+            0.0 /*overscrollLimit*/));
+        m_maximumScrollPosition = m_webPage->mapToTransformed(calculateMaximumScrollPosition(
+            Platform::IntSize(box->clientWidth(), box->clientHeight()),
+            Platform::IntSize(box->scrollWidth(), box->scrollHeight()),
+            0.0 /*overscrollLimit*/));
+    }
+}
+
+Platform::IntPoint InRegionScrollableArea::calculateMinimumScrollPosition(const Platform::IntSize& viewportSize, float overscrollLimitFactor) const
+{
+    // FIXME: Eventually we should support overscroll like iOS5 does.
+    ASSERT(!allowsOverscroll());
+
+    return Platform::IntPoint(-(viewportSize.width() * overscrollLimitFactor),
+                              -(viewportSize.height() * overscrollLimitFactor));
+}
+
+Platform::IntPoint InRegionScrollableArea::calculateMaximumScrollPosition(const Platform::IntSize& viewportSize, const Platform::IntSize& contentsSize, float overscrollLimitFactor) const
+{
+    // FIXME: Eventually we should support overscroll like iOS5 does.
+    ASSERT(!allowsOverscroll());
+
+    return Platform::IntPoint(std::max(contentsSize.width() - viewportSize.width(), 0) + overscrollLimitFactor,
+                              std::max(contentsSize.height() - viewportSize.height(), 0) + overscrollLimitFactor);
+}
+
+RenderLayer* InRegionScrollableArea::layer() const
+{
+    ASSERT(!m_isNull);
+    return m_layer;
+}
+}
+
+}

Added: trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.h (0 => 107990)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.h	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InRegionScrollableArea.h	2012-02-17 00:04:11 UTC (rev 107990)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef InRegionScrollableArea_h
+#define InRegionScrollableArea_h
+
+#include <BlackBerryPlatformPrimitives.h>
+#include <interaction/ScrollViewBase.h>
+
+namespace WebCore {
+class RenderLayer;
+}
+
+namespace BlackBerry {
+namespace WebKit {
+
+class WebPagePrivate;
+
+class InRegionScrollableArea : public Platform::ScrollViewBase {
+public:
+
+    InRegionScrollableArea();
+    InRegionScrollableArea(WebPagePrivate*, WebCore::RenderLayer*);
+
+    WebCore::RenderLayer* layer() const;
+
+private:
+    Platform::IntPoint calculateMinimumScrollPosition(const Platform::IntSize& viewportSize, float overscrollLimitFactor) const;
+    Platform::IntPoint calculateMaximumScrollPosition(const Platform::IntSize& viewportSize, const Platform::IntSize& contentsSize, float overscrollLimitFactor) const;
+
+    WebPagePrivate* m_webPage;
+    WebCore::RenderLayer* m_layer;
+};
+
+}
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to