Chromium Code Reviews| Index: Source/core/editing/VisibleSelection.cpp |
| diff --git a/Source/core/editing/VisibleSelection.cpp b/Source/core/editing/VisibleSelection.cpp |
| index a490dbbd042cb4b9b481e79d4f207a8f97a3de04..e49fe93aef7b0154de70e372bdccfc7d8d14ee77 100644 |
| --- a/Source/core/editing/VisibleSelection.cpp |
| +++ b/Source/core/editing/VisibleSelection.cpp |
| @@ -30,7 +30,6 @@ |
| #include "core/dom/Document.h" |
| #include "core/dom/Element.h" |
| #include "core/dom/Range.h" |
| -#include "core/editing/VisibleUnits.h" |
| #include "core/editing/htmlediting.h" |
| #include "core/editing/iterators/CharacterIterator.h" |
| #include "core/layout/LayoutObject.h" |
| @@ -350,7 +349,7 @@ void VisibleSelection::setBaseAndExtentToDeepEquivalents() |
| m_baseIsFirst = comparePositions(m_base, m_extent) <= 0; |
| } |
| -void VisibleSelection::setStartRespectingGranularity(TextGranularity granularity) |
| +void VisibleSelection::setStartRespectingGranularity(TextGranularity granularity, EWordSide defaultWordSide) |
|
yosin_UTC9
2015/04/16 04:11:26
I feel strange that using term default for paramet
mfomitchev1
2015/04/17 00:13:51
Removed 'default'
|
| { |
| m_start = m_baseIsFirst ? m_base : m_extent; |
| @@ -359,13 +358,14 @@ void VisibleSelection::setStartRespectingGranularity(TextGranularity granularity |
| // Don't do any expansion. |
| break; |
| case WordGranularity: { |
| - // General case: Select the word the caret is positioned inside of, or at the start of (RightWordIfOnBoundary). |
| + // General case: Select the word the caret is positioned inside of. |
| + // If the caret is on the word boundary, select the word according to |defaultWordSide|. |
| // Edge case: If the caret is after the last word in a soft-wrapped line or the last word in |
| // the document, select that last word (LeftWordIfOnBoundary). |
| // Edge case: If the caret is after the last word in a paragraph, select from the the end of the |
| // last word to the line break (also RightWordIfOnBoundary); |
| VisiblePosition visibleStart = VisiblePosition(m_start, m_affinity); |
| - EWordSide side = RightWordIfOnBoundary; |
| + EWordSide side = defaultWordSide; |
| if (isEndOfEditableOrNonEditableContent(visibleStart) || (isEndOfLine(visibleStart) && !isStartOfLine(visibleStart) && !isEndOfParagraph(visibleStart))) |
| side = LeftWordIfOnBoundary; |
| m_start = startOfWord(visibleStart, side).deepEquivalent(); |
| @@ -405,7 +405,7 @@ void VisibleSelection::setStartRespectingGranularity(TextGranularity granularity |
| m_start = m_end; |
| } |
| -void VisibleSelection::setEndRespectingGranularity(TextGranularity granularity) |
| +void VisibleSelection::setEndRespectingGranularity(TextGranularity granularity, EWordSide defaultWordSide) |
| { |
| m_end = m_baseIsFirst ? m_extent : m_base; |
| @@ -414,13 +414,14 @@ void VisibleSelection::setEndRespectingGranularity(TextGranularity granularity) |
| // Don't do any expansion. |
| break; |
| case WordGranularity: { |
| - // General case: Select the word the caret is positioned inside of, or at the start of (RightWordIfOnBoundary). |
| + // General case: Select the word the caret is positioned inside of. |
| + // If the caret is on the word boundary, select the word according to |defaultWordSide|. |
| // Edge case: If the caret is after the last word in a soft-wrapped line or the last word in |
| // the document, select that last word (LeftWordIfOnBoundary). |
| // Edge case: If the caret is after the last word in a paragraph, select from the the end of the |
| // last word to the line break (also RightWordIfOnBoundary); |
| VisiblePosition originalEnd(m_end, m_affinity); |
| - EWordSide side = RightWordIfOnBoundary; |
| + EWordSide side = defaultWordSide; |
| if (isEndOfEditableOrNonEditableContent(originalEnd) || (isEndOfLine(originalEnd) && !isStartOfLine(originalEnd) && !isEndOfParagraph(originalEnd))) |
| side = LeftWordIfOnBoundary; |