[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/khtml
From: Leo Savernik <l.savernik () aon ! at>
Date: 2003-11-21 19:28:43
[Download RAW message or body]
CVS commit by savernik:
Fix for taking care that caret stays visible after:
- switching to caret mode
- switching to design mode
- setting new position of caret
Tested by: Nicolas Deschildre
Reviewed by: Dirk Müller
M +7 -4 khtml_part.cpp 1.942
M +7 -0 khtmlview.cpp 1.586
M +5 -0 khtmlview.h 1.198
--- kdelibs/khtml/khtml_part.cpp #1.941:1.942
@@ -2281,7 +2281,8 @@ void KHTMLPart::setCaretMode(bool enable
// FIXME: this won't work on frames as expected
if (!isEditable()) {
- if (enable)
+ if (enable) {
view()->initCaret(true);
- else
+ view()->ensureCaretVisible();
+ } else
view()->caretOff();
}/*end if*/
@@ -2301,7 +2302,8 @@ void KHTMLPart::setEditable(bool enable)
// FIXME: this won't work on frames as expected
if (!isCaretMode()) {
- if (enable)
+ if (enable) {
view()->initCaret(true);
- else
+ view()->ensureCaretVisible();
+ } else
view()->caretOff();
}/*end if*/
@@ -2319,4 +2321,5 @@ void KHTMLPart::setCaretPosition(DOM::No
if (view()->moveCaretTo(node.handle(), offset, !extendSelection))
emitSelectionChanged();
+ view()->ensureCaretVisible();
#endif // KHTML_NO_CARET
}
--- kdelibs/khtml/khtmlview.cpp #1.585:1.586
@@ -2479,4 +2479,11 @@ bool KHTMLView::placeCaret(InlineBox *hi
}
+void KHTMLView::ensureCaretVisible()
+{
+ CaretViewContext *cv = d->m_caretViewContext;
+ if (!cv) return;
+ ensureVisible(cv->x, cv->y, cv->width, cv->height);
+ d->scrollBarMoved = false;
+}
bool KHTMLView::extendSelection(NodeImpl *oldStartSel, long oldStartOfs,
--- kdelibs/khtml/khtmlview.h #1.197:1.198
@@ -323,4 +323,9 @@ private:
*/
void hideCaret();
+ /** shifts the viewport to ensure that the caret is visible.
+ *
+ * Note: this will also work if the caret is hidden.
+ */
+ void ensureCaretVisible();
/** folds the selection to the current caret position.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic