From 8201188d7be9ada5dee894e4726df3b47bbff9cc Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Thu, 5 Dec 2013 20:07:18 +0100 Subject: [PATCH] * Use the new isInlineRoot method in OdfUtils, to determine walkability around annotations via the TextPositionFilter. - In checkLeftRight, now that positions to the left and right of an annotation are walkable by default, block the position to the right of an annotation if there is a grouping element (span, annotation highlight, etc) to the right. - Thus, now you can step to both the left and right of a rangeless annotaiton. If the annotaiton has a highlighted range, the cursor won't be able to step between the element and it's annotationHighlight, so there can be no strange text insertion there, and no rewrapping is required over the newly inserted text as it goes straight into the highlighted span like everywhere else. * Add tests to OdtDocumentTests for cursor positions around annotations. * Add tests to operationtests.xml (mostly bumping up the positions of SplitParagraph operations after adding annotations, now that 1 new position is exposed. --- webodf/lib/ops/TextPositionFilter.js | 3 +++ webodf/tests/ops/OdtDocumentTests.js | 7 ++++++- webodf/tests/ops/operationtests.xml | 12 ++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/webodf/lib/ops/TextPositionFilter.js b/webodf/lib/ops/TextPositionFilter.js index e136a10b..a5ae9e9e 100644 --- a/webodf/lib/ops/TextPositionFilter.js +++ b/webodf/lib/ops/TextPositionFilter.js @@ -64,6 +64,9 @@ ops.TextPositionFilter = function TextPositionFilter(getRootNode) { var r, firstPos, rightOfChar; // accept if there is a character immediately to the left if (leftNode) { + if (odfUtils.isInlineRoot(leftNode) && odfUtils.isGroupingElement(rightNode)) { + return FILTER_REJECT; + } r = odfUtils.lookLeftForCharacter(leftNode); if (r === 1) {// non-whitespace character or a character element return FILTER_ACCEPT; diff --git a/webodf/tests/ops/OdtDocumentTests.js b/webodf/tests/ops/OdtDocumentTests.js index fc5ecb4f..0b7d5af0 100644 --- a/webodf/tests/ops/OdtDocumentTests.js +++ b/webodf/tests/ops/OdtDocumentTests.js @@ -509,8 +509,12 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) { testCursorPositions("|data|"); } function testAvailablePositions_Annotations() { - testCursorPositions('|a|b||c|d|1|2|'); + testCursorPositions('|a|b|||c|d|1|2|'); } + function testAvailablePositions_BetweenAnnotationAndSpan() { + testCursorPositions('|a|b||c|d|e|1|2|'); + } + function getTextNodeAtStep_BeginningOfTextNode() { var doc = createOdtDocument("ABCD"); @@ -768,6 +772,7 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) { testAvailablePositions_SpaceElements, testAvailablePositions_DrawElements, testAvailablePositions_Annotations, + testAvailablePositions_BetweenAnnotationAndSpan, getTextNodeAtStep_BeginningOfTextNode, getTextNodeAtStep_EndOfTextNode, diff --git a/webodf/tests/ops/operationtests.xml b/webodf/tests/ops/operationtests.xml index 9169b51d..5d64737b 100644 --- a/webodf/tests/ops/operationtests.xml +++ b/webodf/tests/ops/operationtests.xml @@ -1289,7 +1289,7 @@ - abAlice2013-08-05T12:34:07.061Zcd + abAlice2013-08-05T12:34:07.061Zcd @@ -1300,7 +1300,7 @@ - + abAlice2013-08-05T12:34:07.061Zcd @@ -1326,8 +1326,8 @@ - - + + abAlice2013-08-05T12:34:07.061Zc12d @@ -1340,8 +1340,8 @@ - - + + abAlice2013-08-05T12:34:07.061Zcd12