<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[145415] trunk/Source/WebKit/blackberry</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/145415">145415</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2013-03-11 15:25:51 -0700 (Mon, 11 Mar 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>[BlackBerry] Add a method to find the ScrollView for a text selection.
https://bugs.webkit.org/show_bug.cgi?id=112061

Patch by Genevieve Mak &lt;gmak@rim.com&gt; on 2013-03-11
Reviewed by Rob Buis.

Internally reviewed by Mike Fenton and Jakob Petsovits.
PR #278490

Refactor the code in InRegionScroller so that we can add a method to find
the InRegionScrollableArea for a text selection.

* Api/InRegionScroller.cpp:
(BlackBerry::WebKit::InRegionScrollerPrivate::clipToRect):
    - Pull out recursive clipping code into its own function.
(WebKit):
(BlackBerry::WebKit::InRegionScrollerPrivate::calculateInRegionScrollableAreasForPoint):
(BlackBerry::WebKit::InRegionScrollerPrivate::firstScrollableInRegionForNode):
    - This new method allows us to get just the first scrollable region instead of looking
      for more nested ones. We may want to refactor in the future because some of the code is
      very similar to calculateInRegionScrollableAreasForPoint.
(BlackBerry::WebKit::InRegionScrollerPrivate::clipAndCreateInRegionScrollableArea):
    - Add a convenience method for the previous function
* Api/InRegionScroller.h:
(WebKit):
* Api/InRegionScroller_p.h:
(InRegionScrollerPrivate):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitblackberryApiInRegionScrollercpp">trunk/Source/WebKit/blackberry/Api/InRegionScroller.cpp</a></li>
<li><a href="#trunkSourceWebKitblackberryApiInRegionScrollerh">trunk/Source/WebKit/blackberry/Api/InRegionScroller.h</a></li>
<li><a href="#trunkSourceWebKitblackberryApiInRegionScroller_ph">trunk/Source/WebKit/blackberry/Api/InRegionScroller_p.h</a></li>
<li><a href="#trunkSourceWebKitblackberryChangeLog">trunk/Source/WebKit/blackberry/ChangeLog</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitblackberryApiInRegionScrollercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/blackberry/Api/InRegionScroller.cpp (145414 => 145415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/blackberry/Api/InRegionScroller.cpp        2013-03-11 22:22:33 UTC (rev 145414)
+++ trunk/Source/WebKit/blackberry/Api/InRegionScroller.cpp        2013-03-11 22:25:51 UTC (rev 145415)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
</del><ins>+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Lesser General Public
</span><span class="lines">@@ -203,6 +203,34 @@
</span><span class="cx">     m_needsActiveScrollableAreaCalculation = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WebCore::IntRect InRegionScrollerPrivate::clipToRect(const WebCore::IntRect&amp; clippingRect, InRegionScrollableArea* scrollable)
+{
+    RenderLayer* layer = scrollable-&gt;layer();
+    if (!layer)
+        return clippingRect;
+
+    if (layer-&gt;renderer()-&gt;isRenderView()) { // #document case
+        FrameView* view = toRenderView(layer-&gt;renderer())-&gt;frameView();
+        ASSERT(view);
+        ASSERT(canScrollInnerFrame(view-&gt;frame()));
+
+        WebCore::IntRect frameWindowRect = m_webPage-&gt;mapToTransformed(m_webPage-&gt;getRecursiveVisibleWindowRect(view));
+        frameWindowRect.intersect(clippingRect);
+        return frameWindowRect;
+    }
+
+    RenderBox* box = layer-&gt;renderBox();
+    ASSERT(box);
+    ASSERT(canScrollRenderBox(box));
+
+    // We want the window rect in pixel viewport coordinates clipped to the clipping rect.
+    WebCore::IntRect visibleWindowRect = enclosingIntRect(box-&gt;absoluteClippedOverflowRect());
+    visibleWindowRect = box-&gt;frame()-&gt;view()-&gt;contentsToWindow(visibleWindowRect);
+    visibleWindowRect = m_webPage-&gt;mapToTransformed(visibleWindowRect);
+    visibleWindowRect.intersect(clippingRect);
+    return visibleWindowRect;
+}
+
</ins><span class="cx"> void InRegionScrollerPrivate::calculateInRegionScrollableAreasForPoint(const WebCore::IntPoint&amp; documentPoint)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_activeInRegionScrollableAreas.empty());
</span><span class="lines">@@ -216,10 +244,12 @@
</span><span class="cx">     RenderLayer* layer = node-&gt;renderer()-&gt;enclosingLayer();
</span><span class="cx">     if (!layer)
</span><span class="cx">         return;
</span><ins>+
</ins><span class="cx">     do {
</span><ins>+
</ins><span class="cx">         RenderObject* renderer = layer-&gt;renderer();
</span><span class="cx"> 
</span><del>-        if (renderer-&gt;isRenderView()) {
</del><ins>+        if (renderer &amp;&amp; renderer-&gt;isRenderView()) {
</ins><span class="cx">             if (RenderView* renderView = toRenderView(renderer)) {
</span><span class="cx">                 FrameView* view = renderView-&gt;frameView();
</span><span class="cx">                 if (!view) {
</span><span class="lines">@@ -258,41 +288,60 @@
</span><span class="cx">     // we account for all and any clipping rects.
</span><span class="cx">     WebCore::IntRect recursiveClippingRect(WebCore::IntPoint::zero(), m_webPage-&gt;transformedViewportSize());
</span><span class="cx"> 
</span><del>-    std::vector&lt;Platform::ScrollViewBase*&gt;::reverse_iterator rend = m_activeInRegionScrollableAreas.rend();
-    for (std::vector&lt;Platform::ScrollViewBase*&gt;::reverse_iterator rit = m_activeInRegionScrollableAreas.rbegin(); rit != rend; ++rit) {
</del><ins>+    for (int i = m_activeInRegionScrollableAreas.size() - 1; i &gt;= 0; --i) {
+        InRegionScrollableArea* scrollable = static_cast&lt;InRegionScrollableArea*&gt;(m_activeInRegionScrollableAreas[i]);
+        scrollable-&gt;setVisibleWindowRect(clipToRect(recursiveClippingRect, scrollable));
+        recursiveClippingRect = scrollable-&gt;visibleWindowRect();
+    }
+}
</ins><span class="cx"> 
</span><del>-        InRegionScrollableArea* curr = static_cast&lt;InRegionScrollableArea*&gt;(*rit);
-        RenderLayer* layer = curr-&gt;layer();
-        if (!layer)
-            continue;
</del><ins>+Platform::ScrollViewBase* InRegionScrollerPrivate::firstScrollableInRegionForNode(const Node* node)
+{
+    if (!node || !node-&gt;renderer())
+        return 0;
</ins><span class="cx"> 
</span><del>-        if (layer-&gt;renderer()-&gt;isRenderView()) { // #document case
-            FrameView* view = toRenderView(layer-&gt;renderer())-&gt;frameView();
-            ASSERT(view);
-            ASSERT(canScrollInnerFrame(view-&gt;frame()));
</del><ins>+    RenderLayer* layer = node-&gt;renderer()-&gt;enclosingLayer();
+    if (!layer)
+        return 0;
+    do {
+        RenderObject* renderer = layer-&gt;renderer();
</ins><span class="cx"> 
</span><del>-            WebCore::IntRect frameWindowRect = m_webPage-&gt;mapToTransformed(m_webPage-&gt;getRecursiveVisibleWindowRect(view));
-            frameWindowRect.intersect(recursiveClippingRect);
-            curr-&gt;setVisibleWindowRect(frameWindowRect);
-            recursiveClippingRect = frameWindowRect;
</del><ins>+        if (renderer-&gt;isRenderView()) {
+            if (RenderView* renderView = toRenderView(renderer)) {
+                FrameView* view = renderView-&gt;frameView();
+                if (!view) {
+                    reset();
+                    return 0;
+                }
</ins><span class="cx"> 
</span><del>-        } else { // RenderBox-based elements case (scrollable boxes (div's, p's, textarea's, etc)).
</del><ins>+                if (!renderView-&gt;compositor()-&gt;scrollLayer())
+                    continue;
</ins><span class="cx"> 
</span><del>-            RenderBox* box = layer-&gt;renderBox();
-            ASSERT(box);
-            ASSERT(canScrollRenderBox(box));
</del><ins>+                if (canScrollInnerFrame(view-&gt;frame()))
+                    return clipAndCreateInRegionScrollableArea(layer);
+            }
+        } else if (canScrollRenderBox(layer-&gt;renderBox()))
+            return clipAndCreateInRegionScrollableArea(layer);
</ins><span class="cx"> 
</span><del>-            WebCore::IntRect visibleWindowRect = enclosingIntRect(box-&gt;absoluteClippedOverflowRect());
-            visibleWindowRect = box-&gt;frame()-&gt;view()-&gt;contentsToWindow(visibleWindowRect);
-            visibleWindowRect = m_webPage-&gt;mapToTransformed(visibleWindowRect);
-            visibleWindowRect.intersect(recursiveClippingRect);
</del><ins>+        // If we run into a fix positioned layer, set the last scrollable in-region object
+        // as not able to propagate scroll to its parent scrollable.
+        if (isNonRenderViewFixedPositionedContainer(layer) &amp;&amp; m_activeInRegionScrollableAreas.size()) {
+            Platform::ScrollViewBase* end = m_activeInRegionScrollableAreas.back();
+            end-&gt;setCanPropagateScrollingToEnclosingScrollable(false);
+        }
</ins><span class="cx"> 
</span><del>-            curr-&gt;setVisibleWindowRect(visibleWindowRect);
-            recursiveClippingRect = visibleWindowRect;
-        }
-    }
</del><ins>+    } while (layer = parentLayer(layer));
+    return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Platform::ScrollViewBase* InRegionScrollerPrivate::clipAndCreateInRegionScrollableArea(RenderLayer* layer)
+{
+    WebCore::IntRect recursiveClippingRect(WebCore::IntPoint::zero(), m_webPage-&gt;transformedViewportSize());
+    InRegionScrollableArea* scrollable = new InRegionScrollableArea(m_webPage, layer);
+    scrollable-&gt;setVisibleWindowRect(clipToRect(recursiveClippingRect, scrollable));
+    return scrollable;
+}
+
</ins><span class="cx"> const std::vector&lt;Platform::ScrollViewBase*&gt;&amp; InRegionScrollerPrivate::activeInRegionScrollableAreas() const
</span><span class="cx"> {
</span><span class="cx">     return m_activeInRegionScrollableAreas;
</span></span></pre></div>
<a id="trunkSourceWebKitblackberryApiInRegionScrollerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/blackberry/Api/InRegionScroller.h (145414 => 145415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/blackberry/Api/InRegionScroller.h        2013-03-11 22:22:33 UTC (rev 145414)
+++ trunk/Source/WebKit/blackberry/Api/InRegionScroller.h        2013-03-11 22:25:51 UTC (rev 145415)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> class InRegionScrollerPrivate;
</span><span class="cx"> class TouchEventHandler;
</span><span class="cx"> class WebPagePrivate;
</span><ins>+class SelectionHandler;
</ins><span class="cx"> 
</span><span class="cx"> class BLACKBERRY_EXPORT InRegionScroller {
</span><span class="cx"> public:
</span><span class="lines">@@ -44,6 +45,7 @@
</span><span class="cx"> private:
</span><span class="cx">     friend class WebPagePrivate;
</span><span class="cx">     friend class TouchEventHandler;
</span><ins>+    friend class SelectionHandler;
</ins><span class="cx">     InRegionScrollerPrivate *d;
</span><span class="cx">     DISABLE_COPY(InRegionScroller)
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKitblackberryApiInRegionScroller_ph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/blackberry/Api/InRegionScroller_p.h (145414 => 145415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/blackberry/Api/InRegionScroller_p.h        2013-03-11 22:22:33 UTC (rev 145414)
+++ trunk/Source/WebKit/blackberry/Api/InRegionScroller_p.h        2013-03-11 22:25:51 UTC (rev 145415)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> 
</span><span class="cx">     void calculateInRegionScrollableAreasForPoint(const WebCore::IntPoint&amp;);
</span><span class="cx">     const std::vector&lt;Platform::ScrollViewBase*&gt;&amp; activeInRegionScrollableAreas() const;
</span><ins>+    Platform::ScrollViewBase* firstScrollableInRegionForNode(const WebCore::Node*);
</ins><span class="cx"> 
</span><span class="cx">     void clearDocumentData(const WebCore::Document*);
</span><span class="cx"> 
</span><span class="lines">@@ -69,9 +70,11 @@
</span><span class="cx">     void pushBackInRegionScrollable(InRegionScrollableArea*);
</span><span class="cx"> 
</span><span class="cx">     void adjustScrollDelta(const WebCore::IntPoint&amp; maxOffset, const WebCore::IntPoint&amp; currentOffset, WebCore::IntSize&amp; delta) const;
</span><ins>+    Platform::ScrollViewBase* clipAndCreateInRegionScrollableArea(WebCore::RenderLayer*);
</ins><span class="cx"> 
</span><span class="cx">     bool isValidScrollableLayerWebKitThread(WebCore::LayerWebKitThread*) const;
</span><span class="cx">     bool isValidScrollableNode(WebCore::Node*) const;
</span><ins>+    WebCore::IntRect clipToRect(const WebCore::IntRect&amp;, InRegionScrollableArea*);
</ins><span class="cx">     std::vector&lt;Platform::ScrollViewBase*&gt; m_activeInRegionScrollableAreas;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitblackberryChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/blackberry/ChangeLog (145414 => 145415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/blackberry/ChangeLog        2013-03-11 22:22:33 UTC (rev 145414)
+++ trunk/Source/WebKit/blackberry/ChangeLog        2013-03-11 22:25:51 UTC (rev 145415)
</span><span class="lines">@@ -1,5 +1,34 @@
</span><span class="cx"> 2013-03-11  Genevieve Mak  &lt;gmak@rim.com&gt;
</span><span class="cx"> 
</span><ins>+        [BlackBerry] Add a method to find the ScrollView for a text selection.
+        https://bugs.webkit.org/show_bug.cgi?id=112061
+
+        Reviewed by Rob Buis.
+
+        Internally reviewed by Mike Fenton and Jakob Petsovits.
+        PR #278490
+
+        Refactor the code in InRegionScroller so that we can add a method to find
+        the InRegionScrollableArea for a text selection.
+
+        * Api/InRegionScroller.cpp:
+        (BlackBerry::WebKit::InRegionScrollerPrivate::clipToRect):
+            - Pull out recursive clipping code into its own function.
+        (WebKit):
+        (BlackBerry::WebKit::InRegionScrollerPrivate::calculateInRegionScrollableAreasForPoint):
+        (BlackBerry::WebKit::InRegionScrollerPrivate::firstScrollableInRegionForNode):
+            - This new method allows us to get just the first scrollable region instead of looking
+              for more nested ones. We may want to refactor in the future because some of the code is
+              very similar to calculateInRegionScrollableAreasForPoint.
+        (BlackBerry::WebKit::InRegionScrollerPrivate::clipAndCreateInRegionScrollableArea):
+            - Add a convenience method for the previous function
+        * Api/InRegionScroller.h:
+        (WebKit):
+        * Api/InRegionScroller_p.h:
+        (InRegionScrollerPrivate):
+
+2013-03-11  Genevieve Mak  &lt;gmak@rim.com&gt;
+
</ins><span class="cx">         [BlackBerry] Set the documentViewportRect and viewport size.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=112056
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>