diff options
author | Ben Murdoch <benm@google.com> | 2009-08-11 17:01:47 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-08-11 18:21:02 +0100 |
commit | 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch) | |
tree | 2943df35f62d885c89d01063cc528dd73b480fea /WebCore/editing/SelectionController.cpp | |
parent | 7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff) | |
download | external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2 |
Merge in WebKit r47029.
Diffstat (limited to 'WebCore/editing/SelectionController.cpp')
-rw-r--r-- | WebCore/editing/SelectionController.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/WebCore/editing/SelectionController.cpp b/WebCore/editing/SelectionController.cpp index d0427c0..b6874d6 100644 --- a/WebCore/editing/SelectionController.cpp +++ b/WebCore/editing/SelectionController.cpp @@ -100,6 +100,8 @@ void SelectionController::moveTo(const Position &base, const Position &extent, E void SelectionController::setSelection(const VisibleSelection& s, bool closeTyping, bool clearTypingStyle, bool userTriggered) { + m_lastChangeWasHorizontalExtension = false; + if (m_isDragCaretController) { invalidateCaretRect(); m_sel = s; @@ -223,34 +225,30 @@ void SelectionController::nodeWillBeRemoved(Node *node) void SelectionController::willBeModified(EAlteration alter, EDirection direction) { - switch (alter) { - case MOVE: - m_lastChangeWasHorizontalExtension = false; + if (alter != EXTEND) + return; + if (m_lastChangeWasHorizontalExtension) + return; + + Position start = m_sel.start(); + Position end = m_sel.end(); + // FIXME: This is probably not correct for right and left when the direction is RTL. + switch (direction) { + case RIGHT: + case FORWARD: + m_sel.setBase(start); + m_sel.setExtent(end); break; - case EXTEND: - if (!m_lastChangeWasHorizontalExtension) { - m_lastChangeWasHorizontalExtension = true; - Position start = m_sel.start(); - Position end = m_sel.end(); - switch (direction) { - // FIXME: right for bidi? - case RIGHT: - case FORWARD: - m_sel.setBase(start); - m_sel.setExtent(end); - break; - case LEFT: - case BACKWARD: - m_sel.setBase(end); - m_sel.setExtent(start); - break; - } - } + case LEFT: + case BACKWARD: + m_sel.setBase(end); + m_sel.setExtent(start); break; } } -TextDirection SelectionController::directionOfEnclosingBlock() { +TextDirection SelectionController::directionOfEnclosingBlock() +{ Node* n = m_sel.extent().node(); Node* enclosingBlockNode = enclosingBlock(n); if (!enclosingBlockNode) @@ -559,8 +557,8 @@ bool SelectionController::modify(EAlteration alter, EDirection dir, TextGranular { if (userTriggered) { SelectionController trialSelectionController; - trialSelectionController.setLastChangeWasHorizontalExtension(m_lastChangeWasHorizontalExtension); trialSelectionController.setSelection(m_sel); + trialSelectionController.setLastChangeWasHorizontalExtension(m_lastChangeWasHorizontalExtension); trialSelectionController.modify(alter, dir, granularity, false); bool change = m_frame->shouldChangeSelection(trialSelectionController.selection()); @@ -633,6 +631,8 @@ bool SelectionController::modify(EAlteration alter, EDirection dir, TextGranular setNeedsLayout(); + m_lastChangeWasHorizontalExtension = alter == EXTEND; + return true; } @@ -654,6 +654,7 @@ bool SelectionController::modify(EAlteration alter, int verticalDistance, bool u if (userTriggered) { SelectionController trialSelectionController; trialSelectionController.setSelection(m_sel); + trialSelectionController.setLastChangeWasHorizontalExtension(m_lastChangeWasHorizontalExtension); trialSelectionController.modify(alter, verticalDistance, false); bool change = m_frame->shouldChangeSelection(trialSelectionController.selection()); @@ -1267,7 +1268,7 @@ void SelectionController::focusedOrActiveStateChanged() node->setNeedsStyleRecalc(); if (RenderObject* renderer = node->renderer()) if (renderer && renderer->style()->hasAppearance()) - theme()->stateChanged(renderer, FocusState); + renderer->theme()->stateChanged(renderer, FocusState); } // Secure keyboard entry is set by the active frame. |