- fixed <rdar://problem/
3818305> REGRESSION (Mail): Shift + page up has no effect; should modify selection
* khtml/editing/selection.cpp: (khtml::Selection::modify): Fix problem where vertical distance
was used as a distance threshold, but was a negative number. Now make it positive at the start
of the function (and make a couple related changes).
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7735
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-09-30 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by me, coded by Darin
+
+ - fixed <rdar://problem/3818305> REGRESSION (Mail): Shift + page up has no effect; should modify selection
+
+ * khtml/editing/selection.cpp: (khtml::Selection::modify): Fix problem where vertical distance
+ was used as a distance threshold, but was a negative number. Now make it positive at the start
+ of the function (and make a couple related changes).
+
2004-09-29 Richard Williamson <rjw@apple.com>
Fixed <rdar://problem/3779998> bringing window to front or sending to back does not send focus/blur events to JavaScript window object
bool Selection::modify(EAlter alter, int verticalDistance)
{
- if (verticalDistance == 0) {
+ if (verticalDistance == 0)
return false;
- }
- setModifyBias(alter, verticalDistance > 0 ? FORWARD : BACKWARD);
+ bool up = verticalDistance < 0;
+ if (up)
+ verticalDistance = -verticalDistance;
- VisiblePosition pos;
+ setModifyBias(alter, up ? BACKWARD : FORWARD);
+ VisiblePosition pos;
int xPos = 0; /* initialized only to make compiler happy */
+
switch (alter) {
case MOVE:
- pos = VisiblePosition(verticalDistance > 0 ? m_end : m_start);
- xPos = xPosForVerticalArrowNavigation(verticalDistance > 0 ? END : START, isRange());
+ pos = VisiblePosition(up ? m_start : m_end);
+ xPos = xPosForVerticalArrowNavigation(up ? START : END, isRange());
break;
case EXTEND:
pos = VisiblePosition(m_extent);
int startY;
if (!caretY(pos, startY))
return false;
- if (verticalDistance < 0)
+ if (up)
startY = -startY;
int lastY = startY;
VisiblePosition next;
for (VisiblePosition p = pos; ; p = next) {
- next = verticalDistance > 0
- ? nextLinePosition(p, xPos)
- : previousLinePosition(p, xPos);
+ next = (up ? previousLinePosition : nextLinePosition)(p, xPos);
if (next.isNull() || next == p)
break;
int nextY;
if (!caretY(next, nextY))
break;
- if (verticalDistance < 0)
+ if (up)
nextY = -nextY;
if (nextY - startY > verticalDistance)
break;
bool Selection::modify(EAlter alter, int verticalDistance)
{
- if (verticalDistance == 0) {
+ if (verticalDistance == 0)
return false;
- }
- setModifyBias(alter, verticalDistance > 0 ? FORWARD : BACKWARD);
+ bool up = verticalDistance < 0;
+ if (up)
+ verticalDistance = -verticalDistance;
- VisiblePosition pos;
+ setModifyBias(alter, up ? BACKWARD : FORWARD);
+ VisiblePosition pos;
int xPos = 0; /* initialized only to make compiler happy */
+
switch (alter) {
case MOVE:
- pos = VisiblePosition(verticalDistance > 0 ? m_end : m_start);
- xPos = xPosForVerticalArrowNavigation(verticalDistance > 0 ? END : START, isRange());
+ pos = VisiblePosition(up ? m_start : m_end);
+ xPos = xPosForVerticalArrowNavigation(up ? START : END, isRange());
break;
case EXTEND:
pos = VisiblePosition(m_extent);
int startY;
if (!caretY(pos, startY))
return false;
- if (verticalDistance < 0)
+ if (up)
startY = -startY;
int lastY = startY;
VisiblePosition next;
for (VisiblePosition p = pos; ; p = next) {
- next = verticalDistance > 0
- ? nextLinePosition(p, xPos)
- : previousLinePosition(p, xPos);
+ next = (up ? previousLinePosition : nextLinePosition)(p, xPos);
if (next.isNull() || next == p)
break;
int nextY;
if (!caretY(next, nextY))
break;
- if (verticalDistance < 0)
+ if (up)
nextY = -nextY;
if (nextY - startY > verticalDistance)
break;