diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-03-21 02:20:06 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-03-21 02:20:15 +0100 |
commit | 3b35bd273a79f6b01fda7a246aed64aca147ea7a (patch) | |
tree | 5f259026b0771aceb2ad9a88619437ef1841d14c /sources/core/dom | |
parent | 7adcb81e4f83f98c468889aaa5a85558ba88c770 (diff) | |
download | connexionswing-ckeditor-component-master.tar.gz connexionswing-ckeditor-component-master.tar.zst connexionswing-ckeditor-component-master.zip |
Diffstat (limited to 'sources/core/dom')
-rw-r--r-- | sources/core/dom/comment.js | 4 | ||||
-rw-r--r-- | sources/core/dom/document.js | 4 | ||||
-rw-r--r-- | sources/core/dom/documentfragment.js | 2 | ||||
-rw-r--r-- | sources/core/dom/domobject.js | 2 | ||||
-rw-r--r-- | sources/core/dom/element.js | 2 | ||||
-rw-r--r-- | sources/core/dom/elementpath.js | 4 | ||||
-rw-r--r-- | sources/core/dom/event.js | 4 | ||||
-rw-r--r-- | sources/core/dom/iterator.js | 2 | ||||
-rw-r--r-- | sources/core/dom/node.js | 13 | ||||
-rw-r--r-- | sources/core/dom/nodelist.js | 4 | ||||
-rw-r--r-- | sources/core/dom/range.js | 67 | ||||
-rw-r--r-- | sources/core/dom/rangelist.js | 4 | ||||
-rw-r--r-- | sources/core/dom/text.js | 4 | ||||
-rw-r--r-- | sources/core/dom/walker.js | 6 | ||||
-rw-r--r-- | sources/core/dom/window.js | 4 |
15 files changed, 89 insertions, 37 deletions
diff --git a/sources/core/dom/comment.js b/sources/core/dom/comment.js index b4e67833..69828c2e 100644 --- a/sources/core/dom/comment.js +++ b/sources/core/dom/comment.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/document.js b/sources/core/dom/document.js index ea0290f0..f287245e 100644 --- a/sources/core/dom/document.js +++ b/sources/core/dom/document.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/documentfragment.js b/sources/core/dom/documentfragment.js index 5015144d..ffca9e5d 100644 --- a/sources/core/dom/documentfragment.js +++ b/sources/core/dom/documentfragment.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/domobject.js b/sources/core/dom/domobject.js index 21a351d7..607e9f3c 100644 --- a/sources/core/dom/domobject.js +++ b/sources/core/dom/domobject.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/element.js b/sources/core/dom/element.js index d5181282..b586b027 100644 --- a/sources/core/dom/element.js +++ b/sources/core/dom/element.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/elementpath.js b/sources/core/dom/elementpath.js index 55b776d5..1ee551bb 100644 --- a/sources/core/dom/elementpath.js +++ b/sources/core/dom/elementpath.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/event.js b/sources/core/dom/event.js index ee88d78c..7cc1bd80 100644 --- a/sources/core/dom/event.js +++ b/sources/core/dom/event.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/iterator.js b/sources/core/dom/iterator.js index 99491218..41a823c8 100644 --- a/sources/core/dom/iterator.js +++ b/sources/core/dom/iterator.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/node.js b/sources/core/dom/node.js index 5d791319..7818b079 100644 --- a/sources/core/dom/node.js +++ b/sources/core/dom/node.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -373,7 +373,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, { | |||
373 | // The idea is - all empty text nodes will be virtually merged into their adjacent text nodes. | 373 | // The idea is - all empty text nodes will be virtually merged into their adjacent text nodes. |
374 | // If an empty text node does not have an adjacent non-empty text node we can return -1 straight away, | 374 | // If an empty text node does not have an adjacent non-empty text node we can return -1 straight away, |
375 | // because it and all its sibling text nodes will be merged into an empty text node and then totally ignored. | 375 | // because it and all its sibling text nodes will be merged into an empty text node and then totally ignored. |
376 | if ( normalized && current.nodeType == CKEDITOR.NODE_TEXT && !current.nodeValue ) { | 376 | if ( normalized && current.nodeType == CKEDITOR.NODE_TEXT && isEmpty( current ) ) { |
377 | var adjacent = getAdjacentNonEmptyTextNode( current ) || getAdjacentNonEmptyTextNode( current, true ); | 377 | var adjacent = getAdjacentNonEmptyTextNode( current ) || getAdjacentNonEmptyTextNode( current, true ); |
378 | 378 | ||
379 | if ( !adjacent ) | 379 | if ( !adjacent ) |
@@ -382,7 +382,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, { | |||
382 | 382 | ||
383 | do { | 383 | do { |
384 | // Bypass blank node and adjacent text nodes. | 384 | // Bypass blank node and adjacent text nodes. |
385 | if ( normalized && current != this.$ && current.nodeType == CKEDITOR.NODE_TEXT && ( isNormalizing || !current.nodeValue ) ) | 385 | if ( normalized && current != this.$ && current.nodeType == CKEDITOR.NODE_TEXT && ( isNormalizing || isEmpty( current ) ) ) |
386 | continue; | 386 | continue; |
387 | 387 | ||
388 | index++; | 388 | index++; |
@@ -401,7 +401,12 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, { | |||
401 | 401 | ||
402 | // If found a non-empty text node, then return it. | 402 | // If found a non-empty text node, then return it. |
403 | // If not, then continue search. | 403 | // If not, then continue search. |
404 | return sibling.nodeValue ? sibling : getAdjacentNonEmptyTextNode( sibling, lookForward ); | 404 | return isEmpty( sibling ) ? getAdjacentNonEmptyTextNode( sibling, lookForward ) : sibling; |
405 | } | ||
406 | |||
407 | // Checks whether a text node is empty or is FCSeq string (which will be totally removed when normalizing). | ||
408 | function isEmpty( textNode ) { | ||
409 | return !textNode.nodeValue || textNode.nodeValue == CKEDITOR.dom.selection.FILLING_CHAR_SEQUENCE; | ||
405 | } | 410 | } |
406 | }, | 411 | }, |
407 | 412 | ||
diff --git a/sources/core/dom/nodelist.js b/sources/core/dom/nodelist.js index 0bbe3ee6..0f91eaa1 100644 --- a/sources/core/dom/nodelist.js +++ b/sources/core/dom/nodelist.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/range.js b/sources/core/dom/range.js index fe75c550..b5e87363 100644 --- a/sources/core/dom/range.js +++ b/sources/core/dom/range.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -804,12 +804,12 @@ CKEDITOR.dom.range = function( root ) { | |||
804 | var sum = 0; | 804 | var sum = 0; |
805 | 805 | ||
806 | while ( ( node = node.getPrevious() ) && node.type == CKEDITOR.NODE_TEXT ) | 806 | while ( ( node = node.getPrevious() ) && node.type == CKEDITOR.NODE_TEXT ) |
807 | sum += node.getLength(); | 807 | sum += node.getText().replace( CKEDITOR.dom.selection.FILLING_CHAR_SEQUENCE, '' ).length; |
808 | 808 | ||
809 | return sum; | 809 | return sum; |
810 | } | 810 | } |
811 | 811 | ||
812 | function normalize( limit ) { | 812 | function normalizeTextNodes( limit ) { |
813 | var container = limit.container, | 813 | var container = limit.container, |
814 | offset = limit.offset; | 814 | offset = limit.offset; |
815 | 815 | ||
@@ -820,11 +820,13 @@ CKEDITOR.dom.range = function( root ) { | |||
820 | offset = container.getLength(); | 820 | offset = container.getLength(); |
821 | } | 821 | } |
822 | 822 | ||
823 | // Now, if limit is anchored in element and has at least two nodes before it, | 823 | // Now, if limit is anchored in element and has at least one node before it, |
824 | // it may happen that some of them will be merged. Normalize the offset | 824 | // it may happen that some of them will be merged. Normalize the offset |
825 | // by setting it to normalized index of its preceding node. | 825 | // by setting it to normalized index of its preceding, safe node. |
826 | if ( container.type == CKEDITOR.NODE_ELEMENT && offset > 1 ) | 826 | // (safe == one for which getIndex(true) does not return -1, so one which won't disappear). |
827 | offset = container.getChild( offset - 1 ).getIndex( true ) + 1; | 827 | if ( container.type == CKEDITOR.NODE_ELEMENT && offset > 0 ) { |
828 | offset = getPrecedingSafeNodeIndex( container, offset ) + 1; | ||
829 | } | ||
828 | 830 | ||
829 | // The last step - fix the offset inside text node by adding | 831 | // The last step - fix the offset inside text node by adding |
830 | // lengths of preceding text nodes which will be merged with container. | 832 | // lengths of preceding text nodes which will be merged with container. |
@@ -870,6 +872,48 @@ CKEDITOR.dom.range = function( root ) { | |||
870 | limit.offset = offset; | 872 | limit.offset = offset; |
871 | } | 873 | } |
872 | 874 | ||
875 | function normalizeFCSeq( limit, root ) { | ||
876 | var fcseq = root.getCustomData( 'cke-fillingChar' ); | ||
877 | |||
878 | if ( !fcseq ) { | ||
879 | return; | ||
880 | } | ||
881 | |||
882 | var container = limit.container; | ||
883 | |||
884 | if ( fcseq.equals( container ) ) { | ||
885 | limit.offset -= CKEDITOR.dom.selection.FILLING_CHAR_SEQUENCE.length; | ||
886 | |||
887 | // == 0 handles case when limit was at the end of FCS. | ||
888 | // < 0 handles all cases where limit was somewhere in the middle or at the beginning. | ||
889 | // > 0 (the "else" case) means cases where there are some more characters in the FCS node (FCSabc^def). | ||
890 | if ( limit.offset <= 0 ) { | ||
891 | limit.offset = container.getIndex(); | ||
892 | limit.container = container.getParent(); | ||
893 | } | ||
894 | return; | ||
895 | } | ||
896 | |||
897 | // And here goes the funny part - all other cases are handled inside node.getAddress() and getIndex() thanks to | ||
898 | // node.getIndex() being aware of FCS (handling it as an empty node). | ||
899 | } | ||
900 | |||
901 | // Finds a normalized index of a safe node preceding this one. | ||
902 | // Safe == one that will not disappear, so one for which getIndex( true ) does not return -1. | ||
903 | // Return -1 if there's no safe preceding node. | ||
904 | function getPrecedingSafeNodeIndex( container, offset ) { | ||
905 | var index; | ||
906 | |||
907 | while ( offset-- ) { | ||
908 | index = container.getChild( offset ).getIndex( true ); | ||
909 | |||
910 | if ( index >= 0 ) | ||
911 | return index; | ||
912 | } | ||
913 | |||
914 | return -1; | ||
915 | } | ||
916 | |||
873 | return function( normalized ) { | 917 | return function( normalized ) { |
874 | var collapsed = this.collapsed, | 918 | var collapsed = this.collapsed, |
875 | bmStart = { | 919 | bmStart = { |
@@ -882,10 +926,13 @@ CKEDITOR.dom.range = function( root ) { | |||
882 | }; | 926 | }; |
883 | 927 | ||
884 | if ( normalized ) { | 928 | if ( normalized ) { |
885 | normalize( bmStart ); | 929 | normalizeTextNodes( bmStart ); |
930 | normalizeFCSeq( bmStart, this.root ); | ||
886 | 931 | ||
887 | if ( !collapsed ) | 932 | if ( !collapsed ) { |
888 | normalize( bmEnd ); | 933 | normalizeTextNodes( bmEnd ); |
934 | normalizeFCSeq( bmEnd, this.root ); | ||
935 | } | ||
889 | } | 936 | } |
890 | 937 | ||
891 | return { | 938 | return { |
diff --git a/sources/core/dom/rangelist.js b/sources/core/dom/rangelist.js index 9c558b36..d02fc033 100644 --- a/sources/core/dom/rangelist.js +++ b/sources/core/dom/rangelist.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/text.js b/sources/core/dom/text.js index 7c403f90..c3132590 100644 --- a/sources/core/dom/text.js +++ b/sources/core/dom/text.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
diff --git a/sources/core/dom/walker.js b/sources/core/dom/walker.js index 5f2c8f40..746b4067 100644 --- a/sources/core/dom/walker.js +++ b/sources/core/dom/walker.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -388,9 +388,9 @@ | |||
388 | return function( node ) { | 388 | return function( node ) { |
389 | var isWhitespace; | 389 | var isWhitespace; |
390 | if ( node && node.type == CKEDITOR.NODE_TEXT ) { | 390 | if ( node && node.type == CKEDITOR.NODE_TEXT ) { |
391 | // whitespace, as well as the text cursor filler node we used in Webkit. (#9384) | 391 | // Whitespace, as well as the Filling Char Sequence text node used in Webkit. (#9384, #13816) |
392 | isWhitespace = !CKEDITOR.tools.trim( node.getText() ) || | 392 | isWhitespace = !CKEDITOR.tools.trim( node.getText() ) || |
393 | CKEDITOR.env.webkit && node.getText() == '\u200b'; | 393 | CKEDITOR.env.webkit && node.getText() == CKEDITOR.dom.selection.FILLING_CHAR_SEQUENCE; |
394 | } | 394 | } |
395 | 395 | ||
396 | return !!( isReject ^ isWhitespace ); | 396 | return !!( isReject ^ isWhitespace ); |
diff --git a/sources/core/dom/window.js b/sources/core/dom/window.js index 123c981a..edfeb84e 100644 --- a/sources/core/dom/window.js +++ b/sources/core/dom/window.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | 2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | 3 | * For licensing, see LICENSE.md or http://ckeditor.com/license |
4 | */ | 4 | */ |
5 | 5 | ||