[webkit-changes] cvs commit: WebCore/manual-tests
caretScrolling.html
Justin
justing at opensource.apple.com
Tue Nov 1 11:04:26 PST 2005
justing 05/11/01 11:04:26
Modified: . ChangeLog
khtml/editing SelectionController.cpp SelectionController.h
kwq KWQKHTMLPart.mm KWQRect.h
Added: manual-tests caretScrolling.html
Log:
Reviewed by harrison
Fixed <rdar://problem/3690705> caret does not move when scrolling overflow: auto editable area
* manual-tests/caretScrolling.html: Added.
* khtml/editing/SelectionController.cpp:
(khtml::SelectionController::SelectionController): Removed the unused expectedVisibleRect
(khtml::SelectionController::operator=): Ditto.
(khtml::SelectionController::layout): Save the caret's absolute position on layout.
(khtml::SelectionController::caretRect): Adjust the returned caret rect for offset due to scrolling since the last layout.
(khtml::SelectionController::paintCaret):
* khtml/editing/SelectionController.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::nextKeyViewInFrame): Small tweak to a previous change.
* kwq/KWQRect.h:
(QRect::moveTopLeft): Added.
Revision Changes Path
1.322 +20 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.321
retrieving revision 1.322
diff -u -r1.321 -r1.322
--- ChangeLog 1 Nov 2005 18:36:24 -0000 1.321
+++ ChangeLog 1 Nov 2005 19:04:18 -0000 1.322
@@ -1,3 +1,23 @@
+2005-11-01 Justin Garcia <justin.garcia at apple.com>
+
+ Reviewed by harrison
+
+ Fixed <rdar://problem/3690705> caret does not move when scrolling overflow: auto editable area
+
+ * manual-tests/caretScrolling.html: Added.
+
+ * khtml/editing/SelectionController.cpp:
+ (khtml::SelectionController::SelectionController): Removed the unused expectedVisibleRect
+ (khtml::SelectionController::operator=): Ditto.
+ (khtml::SelectionController::layout): Save the caret's absolute position on layout.
+ (khtml::SelectionController::caretRect): Adjust the returned caret rect for offset due to scrolling since the last layout.
+ (khtml::SelectionController::paintCaret):
+ * khtml/editing/SelectionController.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::nextKeyViewInFrame): Small tweak to a previous change.
+ * kwq/KWQRect.h:
+ (QRect::moveTopLeft): Added.
+
2005-11-01 Mitz Pettel <opendarwin.org at mitzpettel.com>
Reviewed by Dave Hyatt.
1.99 +19 -35 WebCore/khtml/editing/SelectionController.cpp
Index: SelectionController.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/SelectionController.cpp,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- SelectionController.cpp 7 Oct 2005 01:21:41 -0000 1.98
+++ SelectionController.cpp 1 Nov 2005 19:04:21 -0000 1.99
@@ -117,7 +117,6 @@
// and the old rectangle needs to be repainted.
if (!m_needsLayout) {
m_caretRect = o.m_caretRect;
- m_expectedVisibleRect = o.m_expectedVisibleRect;
}
}
@@ -152,7 +151,6 @@
// and the old rectangle needs to be repainted.
if (!m_needsLayout) {
m_caretRect = o.m_caretRect;
- m_expectedVisibleRect = o.m_expectedVisibleRect;
}
return *this;
@@ -669,11 +667,12 @@
{
if (isNone() || !m_start.node()->inDocument() || !m_end.node()->inDocument()) {
m_caretRect = QRect();
- m_expectedVisibleRect = QRect();
return;
}
m_start.node()->getDocument()->updateRendering();
+
+ m_caretRect = QRect();
if (isCaret()) {
Position pos = m_start;
@@ -688,29 +687,12 @@
if (pos.isNotNull()) {
ASSERT(pos.node()->renderer());
m_caretRect = pos.node()->renderer()->caretRect(pos.offset(), m_affinity);
- m_expectedVisibleRect = m_caretRect;
- }
- else {
- m_caretRect = QRect();
- m_expectedVisibleRect = QRect();
+
+ int x, y;
+ pos.node()->renderer()->absolutePosition(x, y);
+ m_caretPositionOnLayout = QPoint(x, y);
}
}
- else {
- // Calculate which position to use based on whether the base is the start.
- // We want the position, start or end, that was calculated using the extent.
- // This makes the selection follow the extent position while scrolling as a
- // result of arrow navigation.
- //
- // Note: no need to get additional help from VisiblePosition. The m_start and
- // m_end positions should already be visible, and we're only interested in
- // a rectangle for m_expectedVisibleRect, hence affinity is not a factor
- // like it is when drawing a caret.
- //
- Position pos = m_baseIsStart ? m_end : m_start;
- ASSERT(pos.node()->renderer());
- m_expectedVisibleRect = pos.node()->renderer()->caretRect(pos.offset(), m_affinity);
- m_caretRect = QRect();
- }
m_needsLayout = false;
}
@@ -720,17 +702,17 @@
if (m_needsLayout) {
const_cast<SelectionController *>(this)->layout();
}
-
- return m_caretRect;
-}
-
-QRect SelectionController::expectedVisibleRect() const
-{
- if (m_needsLayout) {
- const_cast<SelectionController *>(this)->layout();
+
+ QRect caret = m_caretRect;
+
+ if (m_start.node() && m_start.node()->renderer()) {
+ int x, y;
+ m_start.node()->renderer()->absolutePosition(x, y);
+ QPoint diff = QPoint(x, y) - m_caretPositionOnLayout;
+ caret.moveTopLeft(diff);
}
- return m_expectedVisibleRect;
+ return caret;
}
QRect SelectionController::caretRepaintRect() const
@@ -782,9 +764,11 @@
if (m_needsLayout)
layout();
+
+ QRect caret = caretRect();
- if (m_caretRect.isValid())
- p->fillRect(m_caretRect & rect, QBrush());
+ if (caret.isValid())
+ p->fillRect(caret & rect, QBrush());
}
void SelectionController::adjustExtentForEditableContent()
1.43 +2 -2 WebCore/khtml/editing/SelectionController.h
Index: SelectionController.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/SelectionController.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- SelectionController.h 7 Oct 2005 01:21:42 -0000 1.42
+++ SelectionController.h 1 Nov 2005 19:04:21 -0000 1.43
@@ -95,7 +95,6 @@
Position end() const { return m_end; }
QRect caretRect() const;
- QRect expectedVisibleRect() const;
void setNeedsLayout(bool flag = true);
void clearModifyBias() { m_modifyBiasSet = false; }
@@ -146,7 +145,8 @@
EAffinity m_affinity; // the upstream/downstream affinity of the selection
QRect m_caretRect; // caret coordinates, size, and position
- QRect m_expectedVisibleRect; // rectangle used to update scroll position as selection changes
+ QPoint m_caretPositionOnLayout; // When asked for caretRect(), we correct m_caretRect for offset due to scrolling.
+ // This is faster than recalcuating m_caretRect.
bool m_baseIsStart : 1; // true if base node is before the extent node
bool m_needsLayout : 1; // true if the caret and expectedVisible rectangles need to be calculated
1.681 +2 -2 WebCore/kwq/KWQKHTMLPart.mm
Index: KWQKHTMLPart.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
retrieving revision 1.680
retrieving revision 1.681
diff -u -r1.680 -r1.681
--- KWQKHTMLPart.mm 26 Oct 2005 21:47:38 -0000 1.680
+++ KWQKHTMLPart.mm 1 Nov 2005 19:04:22 -0000 1.681
@@ -1266,8 +1266,8 @@
doc->setFocusNode(node);
if (node->isEditableBlock()) {
SelectionController sel(Position(node, 0), DOWNSTREAM, Position(node, node->maxDeepOffset()), DOWNSTREAM);
- if (((KHTMLPart *)this)->shouldChangeSelection(sel))
- setSelection(sel);
+ if (KHTMLPart::shouldChangeSelection(sel))
+ setSelection(sel);
}
if (node->renderer() && !node->renderer()->isRoot()) {
1.34 +2 -0 WebCore/kwq/KWQRect.h
Index: KWQRect.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQRect.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- KWQRect.h 30 Sep 2005 04:04:57 -0000 1.33
+++ KWQRect.h 1 Nov 2005 19:04:23 -0000 1.34
@@ -64,6 +64,8 @@
QPoint topRight() const;
QPoint bottomRight() const;
QPoint bottomLeft() const;
+
+ void moveTopLeft(const QPoint &p) { xp += p.x(); yp += p.y(); }
QSize size() const;
void setX(int x) { xp = x; }
1.1 WebCore/manual-tests/caretScrolling.html
Index: caretScrolling.html
===================================================================
<html>
<p>Manual test for fix for <a href="rdar://problem/3690705">rdar://problem/3690705></a> "caret does not move when scrolling overflow: auto editable area"</p>
<p>
Click inside the block below, a caret should appear. Grab the block's scroll handle and scroll down. The caret blinks, try to grab the scroll handle while the caret is visible. The caret should scroll and disappear when it reaches the block's border.
</p>
<div contentEditable style="border: 1px solid blue; height: 100px; overflow:scroll;">
one<br>
two<br>
three<br>
four<br>
five<br>
six<br>
seven<br>
eight<br>
</div>
</html>
More information about the webkit-changes
mailing list