1
Description: Fix selection autoscroll with maximized windows
2
Author: Chris Coulson <chris.coulson@canonical.com>
3
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=644621
4
Bug-Ubuntu: https://launchpad.net/bugs/744580
5
Forwarded: https://bug644621.bugzilla.mozilla.org/attachment.cgi?id=525563
7
diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp
8
--- a/layout/generic/nsSelection.cpp
9
+++ b/layout/generic/nsSelection.cpp
10
@@ -4720,18 +4720,20 @@ nsTypedSelection::DoAutoScroll(nsIFrame
11
nsRootPresContext* rootPC = presContext->GetRootPresContext();
14
nsIFrame* rootmostFrame = rootPC->PresShell()->FrameManager()->GetRootFrame();
15
// Get the point relative to the root most frame because the scroll we are
16
// about to do will change the coordinates of aFrame.
17
nsPoint globalPoint = aPoint + aFrame->GetOffsetToCrossDoc(rootmostFrame);
19
+ nsRect rect = nsIntRect(-20, -20, 40, 40).
20
+ ToAppUnits(presContext->AppUnitsPerDevPixel());
21
PRBool didScroll = presContext->PresShell()->
22
- ScrollFrameRectIntoView(aFrame, nsRect(aPoint, nsSize(1,1)),
23
+ ScrollFrameRectIntoView(aFrame, rect + aPoint,
24
NS_PRESSHELL_SCROLL_ANYWHERE,
25
NS_PRESSHELL_SCROLL_ANYWHERE, 0);
28
// Start the AutoScroll timer if necessary.
31
if (didScroll && mAutoScrollTimer)
32
diff --git a/layout/generic/test/Makefile.in b/layout/generic/test/Makefile.in
33
--- a/layout/generic/test/Makefile.in
34
+++ b/layout/generic/test/Makefile.in
35
@@ -124,16 +124,17 @@ _TEST_FILES = \
41
bug633762_iframe.html \
42
$(srcdir)/../../reftests/backgrounds/blue-32x32.png \
43
$(srcdir)/../../reftests/backgrounds/fuchsia-32x32.png \
44
+ test_drag_selection_autoscroll.html \
48
test_bug514732-2.xul \
49
file_bug514732_window.xul \
53
diff --git a/layout/generic/test/test_drag_selection_autoscroll.html b/layout/generic/test/test_drag_selection_autoscroll.html
56
+++ b/layout/generic/test/test_drag_selection_autoscroll.html
61
+ <title>Test for autoscrolling the selection into view, when dragging</title>
62
+ <script type="text/javascript" src="/MochiKit/packed.js"></script>
63
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
64
+ <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
65
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
69
+<div id="target" style="overflow:auto; width:200px; height:200px; position:absolute; top:200px; left:0;">
70
+ <div style="height:400px; width:400px;"></div>
71
+ <div><span style="display:inline-block; vertical-align:top; height:20px;">Test</span></div>
72
+ <div style="height:400px;"></div>
76
+<script class="testbody" type="text/javascript">
83
+const SCROLLED = "scrolled";
84
+const NOT_SCROLLED = "not_scrolled";
85
+const operators = {not_scrolled: is, scrolled: isnot };
93
+ { direction: DOWN, scrollStartX: 0, scrollStartY: 0, pointerDestFromEdge: 21, duration: 50, checkType: NOT_SCROLLED },
94
+ { direction: UP, scrollStartX: 0, scrollStartY: 100, pointerDestFromEdge: 21, duration: 50, checkType: NOT_SCROLLED },
95
+ { direction: RIGHT, scrollStartX: 0, scrollStartY: 0, pointerDestFromEdge: 21, duration: 50, checkType: NOT_SCROLLED },
96
+ { direction: LEFT, scrollStartX: 100, scrollStartY: 0, pointerDestFromEdge: 21, duration: 50, checkType: NOT_SCROLLED },
97
+ { direction: DOWN, scrollStartX: 0, scrollStartY: 0, pointerDestFromEdge: 19, duration: 50, checkType: SCROLLED },
98
+ { direction: UP, scrollStartX: 0, scrollStartY: 100, pointerDestFromEdge: 19, duration: 50, checkType: SCROLLED },
99
+ { direction: RIGHT, scrollStartX: 0, scrollStartY: 0, pointerDestFromEdge: 19, duration: 50, checkType: SCROLLED },
100
+ { direction: LEFT, scrollStartX: 100, scrollStartY: 0, pointerDestFromEdge: 19, duration: 50, checkType: SCROLLED },
101
+ { direction: DOWN, scrollStartX: 0, scrollStartY: 0, pointerDestFromEdge: 0, duration: 50, checkType: SCROLLED },
102
+ { direction: UP, scrollStartX: 0, scrollStartY: 100, pointerDestFromEdge: 0, duration: 50, checkType: SCROLLED },
103
+ { direction: RIGHT, scrollStartX: 0, scrollStartY: 0, pointerDestFromEdge: 0, duration: 50, checkType: SCROLLED },
104
+ { direction: LEFT, scrollStartX: 100, scrollStartY: 0, pointerDestFromEdge: 0, duration: 50, checkType: SCROLLED },
105
+ { direction: DOWN, scrollStartX: 0, scrollStartY: 0, pointerDestFromEdge: -19, duration: 50, checkType: SCROLLED },
106
+ { direction: UP, scrollStartX: 0, scrollStartY: 100, pointerDestFromEdge: -19, duration: 50, checkType: SCROLLED },
107
+ { direction: RIGHT, scrollStartX: 0, scrollStartY: 0, pointerDestFromEdge: -19, duration: 50, checkType: SCROLLED },
108
+ { direction: LEFT, scrollStartX: 100, scrollStartY: 0, pointerDestFromEdge: -19, duration: 50, checkType: SCROLLED }
112
+ target = document.getElementById("target");
113
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
114
+ var selection = window.getSelection().QueryInterface(Components.interfaces.nsISelection2);
115
+ selection.collapse(target, 0);
117
+ target.scrollTop = params["scrollStartY"];
118
+ target.scrollLeft = params["scrollStartX"];
120
+ switch (params["direction"])
123
+ pointerDestX = target.clientWidth / 2;
124
+ pointerDestY = params["pointerDestFromEdge"];
128
+ pointerDestX = target.clientWidth / 2;
129
+ pointerDestY = target.clientHeight - params["pointerDestFromEdge"];
133
+ pointerDestX = params["pointerDestFromEdge"];
134
+ pointerDestY = target.clientHeight / 2;
138
+ pointerDestX = target.clientWidth - params["pointerDestFromEdge"];
139
+ pointerDestY = target.clientHeight / 2;
143
+ throw "Invalid test direction";
147
+ window.setTimeout(function() {
148
+ var target = document.getElementById("target");
149
+ synthesizeMouse(target, target.clientWidth / 2, target.clientHeight / 2, { type: "mousedown" });
150
+ synthesizeMouse(target, pointerDestX, pointerDestY, { type: "mousemove" });
152
+ window.setTimeout(function() {
153
+ var target = document.getElementById("target");
154
+ synthesizeMouse(target, pointerDestX, pointerDestY, { type: "mouseup" });
156
+ if (params["direction"] == UP || params["direction"] == DOWN) {
157
+ operators[params["checkType"]](target.scrollTop, params["scrollStartY"], "Test + " + iter + ": checking if Y axis position changed");
158
+ is(target.scrollLeft, params["scrollStartX"], "Test + " + iter + ": checking if X axis position changed");
159
+ } else if (params["direction"] == LEFT || params["direction"] == RIGHT) {
160
+ operators[params["checkType"]](target.scrollLeft, params["scrollStartX"], "Test + " + iter + ": checking if X axis position changed");
161
+ is(target.scrollTop, params["scrollStartY"], "Test + " + iter + ": checking if Y axis position changed");
163
+ throw "Invalid test direction";
167
+ }, params["duration"]);
171
+function prepareNextTest() {
172
+ if (iter <= testMatrix.length - 1) {
173
+ params = testMatrix[iter++];
177
+ SimpleTest.finish();
181
+SimpleTest.waitForExplicitFinish();
182
+addLoadEvent(prepareNextTest);