~ubuntu-branches/ubuntu/natty/firefox/natty

« back to all changes in this revision

Viewing changes to debian/patches/fix-selection-drag-autoscroll.patch

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson, Felix Geyer, Chris Coulson
  • Date: 2011-04-19 17:10:50 UTC
  • Revision ID: james.westby@ubuntu.com-20110419171050-12nnjoybyec0a04c
Tags: 4.0+nobinonly-0ubuntu3
[ Felix Geyer <debfx@ubuntu.com> ]
* Fix LP: #572772 - can't save files in KDE
  - update debian/patches/mozilla-kde.patch

[ Chris Coulson ]
* Fix LP: #766151 - popuphiding and popuphidden events aren't dispatched
  when a menu is closed, leading to exceptions being thrown in
  browserPlacesViews.js (visible from the error console)
  - update globalmenu-extension to 1.0.2
* Fix LP: #744580 - Firefox doesn't autoscroll when selecting content
  downwards
  - add debian/patches/fix-selection-drag-autoscroll.patch
  - update debian/patches/series

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
6
 
 
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();
 
12
   if (!rootPC)
 
13
     return NS_OK;
 
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);
 
18
 
 
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);
 
26
 
 
27
   //
 
28
   // Start the AutoScroll timer if necessary.
 
29
   //
 
30
 
 
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 = \
 
36
                test_bug522632.html \
 
37
                test_bug589621.html \
 
38
                test_bug589623.html \
 
39
                test_bug632379.xul \
 
40
                test_bug633762.html \
 
41
                bug633762_iframe.html \
 
42
                $(srcdir)/../../reftests/backgrounds/blue-32x32.png \
 
43
                $(srcdir)/../../reftests/backgrounds/fuchsia-32x32.png \
 
44
+               test_drag_selection_autoscroll.html \
 
45
                $(NULL)
 
46
 
 
47
 _CHROME_FILES = \
 
48
                test_bug514732-2.xul \
 
49
                file_bug514732_window.xul \
 
50
                $(NULL)
 
51
 
 
52
 libs:: $(_TEST_FILES)
 
53
diff --git a/layout/generic/test/test_drag_selection_autoscroll.html b/layout/generic/test/test_drag_selection_autoscroll.html
 
54
new file mode 100644
 
55
--- /dev/null
 
56
+++ b/layout/generic/test/test_drag_selection_autoscroll.html
 
57
@@ -0,0 +1,130 @@
 
58
+<!DOCTYPE HTML>
 
59
+<html>
 
60
+<head>
 
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" />
 
66
+</head>
 
67
+<body>
 
68
+
 
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>
 
73
+</div>
 
74
+
 
75
+<pre id="test">
 
76
+<script class="testbody" type="text/javascript">
 
77
+
 
78
+const UP = 0;
 
79
+const DOWN = 1;
 
80
+const LEFT = 2;
 
81
+const RIGHT = 3;
 
82
+
 
83
+const SCROLLED = "scrolled";
 
84
+const NOT_SCROLLED = "not_scrolled";
 
85
+const operators = {not_scrolled: is, scrolled: isnot };
 
86
+
 
87
+var params = null;
 
88
+var iter = 0;
 
89
+var pointerDestX;
 
90
+var pointerDestY;
 
91
+
 
92
+const testMatrix = [
 
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 }
 
109
+]
 
110
+
 
111
+function doTest() {
 
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);
 
116
+
 
117
+  target.scrollTop = params["scrollStartY"];
 
118
+  target.scrollLeft = params["scrollStartX"];
 
119
+
 
120
+  switch (params["direction"])
 
121
+  {
 
122
+  case UP:
 
123
+    pointerDestX = target.clientWidth / 2;
 
124
+    pointerDestY = params["pointerDestFromEdge"];
 
125
+    break;
 
126
+
 
127
+  case DOWN:
 
128
+    pointerDestX = target.clientWidth / 2;
 
129
+    pointerDestY = target.clientHeight - params["pointerDestFromEdge"];
 
130
+    break;
 
131
+
 
132
+  case LEFT:
 
133
+    pointerDestX = params["pointerDestFromEdge"];
 
134
+    pointerDestY = target.clientHeight / 2;
 
135
+    break;
 
136
+
 
137
+  case RIGHT:
 
138
+    pointerDestX = target.clientWidth - params["pointerDestFromEdge"];
 
139
+    pointerDestY = target.clientHeight / 2;
 
140
+    break;
 
141
+
 
142
+  default:
 
143
+    throw "Invalid test direction";
 
144
+    break;
 
145
+  }
 
146
+
 
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" });
 
151
+
 
152
+    window.setTimeout(function() {
 
153
+      var target = document.getElementById("target");
 
154
+      synthesizeMouse(target, pointerDestX, pointerDestY, { type: "mouseup" });
 
155
+
 
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");
 
162
+      } else {
 
163
+        throw "Invalid test direction";
 
164
+      }
 
165
+
 
166
+      prepareNextTest();
 
167
+    }, params["duration"]);
 
168
+  }, 0);
 
169
+}
 
170
+
 
171
+function prepareNextTest() {
 
172
+  if (iter <= testMatrix.length - 1) {
 
173
+    params = testMatrix[iter++];
 
174
+
 
175
+    doTest();
 
176
+  } else {
 
177
+    SimpleTest.finish();
 
178
+  }
 
179
+}
 
180
+
 
181
+SimpleTest.waitForExplicitFinish();
 
182
+addLoadEvent(prepareNextTest);
 
183
+
 
184
+</script>
 
185
+</pre>
 
186
+</body>
 
187
+</html>
 
188