+ function normalizeFCSeq( limit, root ) {
+ var fcseq = root.getCustomData( 'cke-fillingChar' );
+
+ if ( !fcseq ) {
+ return;
+ }
+
+ var container = limit.container;
+
+ if ( fcseq.equals( container ) ) {
+ limit.offset -= CKEDITOR.dom.selection.FILLING_CHAR_SEQUENCE.length;
+
+ // == 0 handles case when limit was at the end of FCS.
+ // < 0 handles all cases where limit was somewhere in the middle or at the beginning.
+ // > 0 (the "else" case) means cases where there are some more characters in the FCS node (FCSabc^def).
+ if ( limit.offset <= 0 ) {
+ limit.offset = container.getIndex();
+ limit.container = container.getParent();
+ }
+ return;
+ }
+
+ // And here goes the funny part - all other cases are handled inside node.getAddress() and getIndex() thanks to
+ // node.getIndex() being aware of FCS (handling it as an empty node).
+ }
+
+ // Finds a normalized index of a safe node preceding this one.
+ // Safe == one that will not disappear, so one for which getIndex( true ) does not return -1.
+ // Return -1 if there's no safe preceding node.
+ function getPrecedingSafeNodeIndex( container, offset ) {
+ var index;
+
+ while ( offset-- ) {
+ index = container.getChild( offset ).getIndex( true );
+
+ if ( index >= 0 )
+ return index;
+ }
+
+ return -1;
+ }
+