浏览代码

Renamed view Selection to DocumentSelection.

Szymon Kupś 7 年之前
父节点
当前提交
8018084066

+ 3 - 3
packages/ckeditor5-engine/src/dev-utils/view.js

@@ -15,7 +15,7 @@ import View from '../view/view';
 import ViewDocumentFragment from '../view/documentfragment';
 import XmlDataProcessor from '../dataprocessor/xmldataprocessor';
 import ViewElement from '../view/element';
-import Selection from '../view/selection';
+import DocumentSelection from '../view/documentselection';
 import Range from '../view/range';
 import Position from '../view/position';
 import AttributeElement from '../view/attributeelement';
@@ -220,7 +220,7 @@ export function stringify( node, selectionOrPositionOrRange = null, options = {}
 		selectionOrPositionOrRange instanceof Position ||
 		selectionOrPositionOrRange instanceof Range
 	) {
-		selection = new Selection( selectionOrPositionOrRange );
+		selection = new DocumentSelection( selectionOrPositionOrRange );
 	} else {
 		selection = selectionOrPositionOrRange;
 	}
@@ -340,7 +340,7 @@ export function parse( data, options = {} ) {
 
 	// When ranges are present - return object containing view, and selection.
 	if ( ranges.length ) {
-		const selection = new Selection( ranges, { backward: !!options.lastRangeBackward } );
+		const selection = new DocumentSelection( ranges, { backward: !!options.lastRangeBackward } );
 
 		return {
 			view,

+ 2 - 2
packages/ckeditor5-engine/src/view/document.js

@@ -7,7 +7,7 @@
  * @module engine/view/document
  */
 
-import Selection from './selection';
+import DocumentSelection from './documentselection';
 import Collection from '@ckeditor/ckeditor5-utils/src/collection';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
@@ -29,7 +29,7 @@ export default class Document {
 		 * @readonly
 		 * @member {module:engine/view/selection~Selection} module:engine/view/document~Document#selection
 		 */
-		this.selection = new Selection();
+		this.selection = new DocumentSelection();
 
 		/**
 		 * Roots of the view tree. Collection of the {module:engine/view/element~Element view elements}.

+ 18 - 16
packages/ckeditor5-engine/src/view/selection.js

@@ -4,7 +4,7 @@
  */
 
 /**
- * @module engine/view/selection
+ * @module engine/view/documentselection
  */
 
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
@@ -21,18 +21,20 @@ import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
  * Class representing selection in tree view.
  *
  * Selection can consist of {@link module:engine/view/range~Range ranges} that can be set using
- * {@link module:engine/view/selection~Selection#_setTo} method.
+ * {@link module:engine/view/documentselection~DocumentSelection#_setTo} method.
  * That method create copies of provided ranges and store those copies internally. Further modifications to passed
  * ranges will not change selection's state.
- * Selection's ranges can be obtained via {@link module:engine/view/selection~Selection#getRanges getRanges},
- * {@link module:engine/view/selection~Selection#getFirstRange getFirstRange}
- * and {@link module:engine/view/selection~Selection#getLastRange getLastRange}
+ * Selection's ranges can be obtained via {@link module:engine/view/documentselection~DocumentSelection#getRanges getRanges},
+ * {@link module:engine/view/documentselection~DocumentSelection#getFirstRange getFirstRange}
+ * and {@link module:engine/view/documentselection~DocumentSelection#getLastRange getLastRange}
  * methods, which return copies of ranges stored inside selection. Modifications made on these copies will not change
- * selection's state. Similar situation occurs when getting {@link module:engine/view/selection~Selection#anchor anchor},
- * {@link module:engine/view/selection~Selection#focus focus}, {@link module:engine/view/selection~Selection#getFirstPosition first} and
- * {@link module:engine/view/selection~Selection#getLastPosition last} positions - all will return copies of requested positions.
+ * selection's state. Similar situation occurs when getting {@link module:engine/view/documentselection~DocumentSelection#anchor anchor},
+ * {@link module:engine/view/documentselection~DocumentSelection#focus focus},
+ * {@link module:engine/view/documentselection~DocumentSelection#getFirstPosition first} and
+ * {@link module:engine/view/documentselection~DocumentSelection#getLastPosition last} positions - all will return
+ * copies of requested positions.
  */
-export default class Selection {
+export default class DocumentSelection {
 	/**
 	 * Creates new selection instance.
 	 *
@@ -82,7 +84,7 @@ export default class Selection {
 	 *		// Creates fake selection with label.
 	 *		const selection = new Selection( range, { fake: true, label: 'foo' } );
 	 *
-	 * @param {module:engine/view/selection~Selection|module:engine/view/position~Position|
+	 * @param {module:engine/view/documentselection~DocumentSelection|module:engine/view/position~Position|
 	 * Iterable.<module:engine/view/range~Range>|module:engine/view/range~Range|module:engine/view/item~Item|null} [selectable=null]
 	 * @param {Number|'before'|'end'|'after'|'on'|'in'} [placeOrOffset] Offset or place when selectable is an `Item`.
 	 * @param {Object} [options]
@@ -303,7 +305,7 @@ export default class Selection {
 	 * Checks whether, this selection is equal to given selection. Selections are equal if they have same directions,
 	 * same number of ranges and all ranges from one selection equal to a range from other selection.
 	 *
-	 * @param {module:engine/view/selection~Selection} otherSelection Selection to compare with.
+	 * @param {module:engine/view/documentselection~DocumentSelection} otherSelection Selection to compare with.
 	 * @returns {Boolean} `true` if selections are equal, `false` otherwise.
 	 */
 	isEqual( otherSelection ) {
@@ -348,7 +350,7 @@ export default class Selection {
 	 * number of ranges, and all {@link module:engine/view/range~Range#getTrimmed trimmed} ranges from one selection are
 	 * equal to any trimmed range from other selection.
 	 *
-	 * @param {module:engine/view/selection~Selection} otherSelection Selection to compare with.
+	 * @param {module:engine/view/documentselection~DocumentSelection} otherSelection Selection to compare with.
 	 * @returns {Boolean} `true` if selections are similar, `false` otherwise.
 	 */
 	isSimilar( otherSelection ) {
@@ -415,7 +417,7 @@ export default class Selection {
 
 	/**
 	 * Sets this selection's ranges and direction to the specified location based on the given
-	 * {@link module:engine/view/selection~Selection selection}, {@link module:engine/view/position~Position position},
+	 * {@link module:engine/view/documentselection~DocumentSelection selection}, {@link module:engine/view/position~Position position},
 	 * {@link module:engine/view/item~Item item}, {@link module:engine/view/range~Range range},
 	 * an iterable of {@link module:engine/view/range~Range ranges} or null.
 	 *
@@ -467,7 +469,7 @@ export default class Selection {
 	 *
 	 * @protected
 	 * @fires change
-	 * @param {module:engine/view/selection~Selection|module:engine/view/position~Position|
+	 * @param {module:engine/view/documentselection~DocumentSelection|module:engine/view/position~Position|
 	 * Iterable.<module:engine/view/range~Range>|module:engine/view/range~Range|module:engine/view/item~Item|null} selectable
 	 * @param {Number|'before'|'end'|'after'|'on'|'in'} [placeOrOffset] Sets place or offset of the selection.
 	 * @param {Object} [options]
@@ -479,7 +481,7 @@ export default class Selection {
 		if ( selectable === null ) {
 			this._setRanges( [] );
 			this._setFakeOptions( placeOrOffset );
-		} else if ( selectable instanceof Selection ) {
+		} else if ( selectable instanceof DocumentSelection ) {
 			this._setRanges( selectable.getRanges(), selectable.isBackward );
 			this._setFakeOptions( { fake: selectable.isFake, label: selectable.fakeSelectionLabel } );
 		} else if ( selectable instanceof Range ) {
@@ -669,7 +671,7 @@ export default class Selection {
 	}
 }
 
-mix( Selection, EmitterMixin );
+mix( DocumentSelection, EmitterMixin );
 
 /**
  * Fired whenever selection ranges are changed through {@link ~Selection Selection API}.

+ 3 - 3
packages/ckeditor5-engine/src/view/domconverter.js

@@ -13,7 +13,7 @@ import ViewText from './text';
 import ViewElement from './element';
 import ViewPosition from './position';
 import ViewRange from './range';
-import ViewSelection from './selection';
+import ViewDocumentSelection from './documentselection';
 import ViewDocumentFragment from './documentfragment';
 import ViewTreeWalker from './treewalker';
 import { BR_FILLER, INLINE_FILLER_LENGTH, isBlockFiller, isInlineFiller, startsWithFiller, getDataWithoutFiller } from './filler';
@@ -111,7 +111,7 @@ export default class DomConverter {
 	 * @param {module:engine/view/selection~Selection} viewSelection
 	 */
 	bindFakeSelection( domElement, viewSelection ) {
-		this._fakeSelectionMapping.set( domElement, new ViewSelection( viewSelection ) );
+		this._fakeSelectionMapping.set( domElement, new ViewDocumentSelection( viewSelection ) );
 	}
 
 	/**
@@ -488,7 +488,7 @@ export default class DomConverter {
 			}
 		}
 
-		return new ViewSelection( viewRanges, { backward: isBackward } );
+		return new ViewDocumentSelection( viewRanges, { backward: isBackward } );
 	}
 
 	/**

+ 2 - 2
packages/ckeditor5-engine/src/view/observer/fakeselectionobserver.js

@@ -8,7 +8,7 @@
  */
 
 import Observer from './observer';
-import ViewSelection from '../selection';
+import ViewDocumentSelection from '../documentselection';
 import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
 import debounce from '@ckeditor/ckeditor5-utils/src/lib/lodash/debounce';
 
@@ -82,7 +82,7 @@ export default class FakeSelectionObserver extends Observer {
 	 */
 	_handleSelectionMove( keyCode ) {
 		const selection = this.document.selection;
-		const newSelection = new ViewSelection( selection.getRanges(), { backward: selection.isBackward, fake: false } );
+		const newSelection = new ViewDocumentSelection( selection.getRanges(), { backward: selection.isBackward, fake: false } );
 
 		// Left or up arrow pressed - move selection to start.
 		if ( keyCode == keyCodes.arrowleft || keyCode == keyCodes.arrowup ) {

+ 2 - 2
packages/ckeditor5-engine/src/view/observer/mutationobserver.js

@@ -10,7 +10,7 @@
 /* globals window */
 
 import Observer from './observer';
-import ViewSelection from '../selection';
+import DocumentViewSelection from '../documentselection';
 import { startsWithFiller, getDataWithoutFiller } from '../filler';
 import isEqualWith from '@ckeditor/ckeditor5-utils/src/lib/lodash/isEqualWith';
 
@@ -239,7 +239,7 @@ export default class MutationObserver extends Observer {
 
 			// Anchor and focus has to be properly mapped to view.
 			if ( viewSelectionAnchor && viewSelectionFocus ) {
-				viewSelection = new ViewSelection( viewSelectionAnchor );
+				viewSelection = new DocumentViewSelection( viewSelectionAnchor );
 				viewSelection._setFocus( viewSelectionFocus );
 			}
 		}

+ 6 - 6
packages/ckeditor5-engine/tests/conversion/upcast-selection-converters.js

@@ -4,7 +4,7 @@
  */
 
 import View from '../../src/view/view';
-import ViewSelection from '../../src/view/selection';
+import ViewDocumentSelection from '../../src/view/documentselection';
 import ViewRange from '../../src/view/range';
 import createViewRoot from '../view/_utils/createroot';
 
@@ -45,7 +45,7 @@ describe( 'convertSelectionChange', () => {
 	} );
 
 	it( 'should convert collapsed selection', () => {
-		const viewSelection = new ViewSelection();
+		const viewSelection = new ViewDocumentSelection();
 		viewSelection._setTo( ViewRange.createFromParentsAndOffsets(
 			viewRoot.getChild( 0 ).getChild( 0 ), 1, viewRoot.getChild( 0 ).getChild( 0 ), 1 ) );
 
@@ -62,7 +62,7 @@ describe( 'convertSelectionChange', () => {
 		// Re-bind elements that were just re-set.
 		mapper.bindElements( modelRoot.getChild( 0 ), viewRoot.getChild( 0 ) );
 
-		const viewSelection = new ViewSelection( [
+		const viewSelection = new ViewDocumentSelection( [
 			ViewRange.createFromParentsAndOffsets( viewRoot.getChild( 0 ).getChild( 0 ), 2, viewRoot.getChild( 0 ).getChild( 0 ), 6 )
 		] );
 
@@ -72,7 +72,7 @@ describe( 'convertSelectionChange', () => {
 	} );
 
 	it( 'should convert multi ranges selection', () => {
-		const viewSelection = new ViewSelection( [
+		const viewSelection = new ViewDocumentSelection( [
 			ViewRange.createFromParentsAndOffsets(
 				viewRoot.getChild( 0 ).getChild( 0 ), 1, viewRoot.getChild( 0 ).getChild( 0 ), 2 ),
 			ViewRange.createFromParentsAndOffsets(
@@ -99,7 +99,7 @@ describe( 'convertSelectionChange', () => {
 	} );
 
 	it( 'should convert reverse selection', () => {
-		const viewSelection = new ViewSelection( [
+		const viewSelection = new ViewDocumentSelection( [
 			ViewRange.createFromParentsAndOffsets(
 				viewRoot.getChild( 0 ).getChild( 0 ), 1, viewRoot.getChild( 0 ).getChild( 0 ), 2 ),
 			ViewRange.createFromParentsAndOffsets(
@@ -113,7 +113,7 @@ describe( 'convertSelectionChange', () => {
 	} );
 
 	it( 'should not enqueue changes if selection has not changed', () => {
-		const viewSelection = new ViewSelection( [
+		const viewSelection = new ViewDocumentSelection( [
 			ViewRange.createFromParentsAndOffsets(
 				viewRoot.getChild( 0 ).getChild( 0 ), 1, viewRoot.getChild( 0 ).getChild( 0 ), 1 )
 		] );

+ 10 - 10
packages/ckeditor5-engine/tests/dev-utils/view.js

@@ -14,7 +14,7 @@ import ContainerElement from '../../src/view/containerelement';
 import EmptyElement from '../../src/view/emptyelement';
 import UIElement from '../../src/view/uielement';
 import Text from '../../src/view/text';
-import Selection from '../../src/view/selection';
+import DocumentSelection from '../../src/view/documentselection';
 import Range from '../../src/view/range';
 import View from '../../src/view/view';
 import XmlDataProcessor from '../../src/dataprocessor/xmldataprocessor';
@@ -167,7 +167,7 @@ describe( 'view test utils', () => {
 			const b2 = new Element( 'b', null, text2 );
 			const p = new Element( 'p', null, [ b1, b2 ] );
 			const range = Range.createFromParentsAndOffsets( p, 1, p, 2 );
-			const selection = new Selection( [ range ] );
+			const selection = new DocumentSelection( [ range ] );
 			expect( stringify( p, selection ) ).to.equal( '<p><b>foobar</b>[<b>bazqux</b>]</p>' );
 		} );
 
@@ -176,7 +176,7 @@ describe( 'view test utils', () => {
 			const b = new Element( 'b', null, text );
 			const p = new Element( 'p', null, b );
 			const range = Range.createFromParentsAndOffsets( p, 0, text, 4 );
-			const selection = new Selection( [ range ] );
+			const selection = new DocumentSelection( [ range ] );
 
 			expect( stringify( p, selection ) ).to.equal( '<p>[<b>நிலை}க்கு</b></p>' );
 		} );
@@ -185,7 +185,7 @@ describe( 'view test utils', () => {
 			const text = new Text( 'foobar' );
 			const p = new Element( 'p', null, text );
 			const range = Range.createFromParentsAndOffsets( p, 0, p, 0 );
-			const selection = new Selection( [ range ] );
+			const selection = new DocumentSelection( [ range ] );
 			expect( stringify( p, selection ) ).to.equal( '<p>[]foobar</p>' );
 		} );
 
@@ -196,7 +196,7 @@ describe( 'view test utils', () => {
 			const b2 = new Element( 'b', null, text2 );
 			const p = new Element( 'p', null, [ b1, b2 ] );
 			const range = Range.createFromParentsAndOffsets( text1, 1, text1, 5 );
-			const selection = new Selection( [ range ] );
+			const selection = new DocumentSelection( [ range ] );
 			expect( stringify( p, selection ) ).to.equal( '<p><b>f{ooba}r</b><b>bazqux</b></p>' );
 		} );
 
@@ -207,7 +207,7 @@ describe( 'view test utils', () => {
 			const b2 = new Element( 'b', null, text2 );
 			const p = new Element( 'p', null, [ b1, b2 ] );
 			const range = Range.createFromParentsAndOffsets( text1, 1, text1, 5 );
-			const selection = new Selection( [ range ] );
+			const selection = new DocumentSelection( [ range ] );
 			expect( stringify( p, selection, { sameSelectionCharacters: true } ) )
 				.to.equal( '<p><b>f[ooba]r</b><b>bazqux</b></p>' );
 		} );
@@ -216,7 +216,7 @@ describe( 'view test utils', () => {
 			const text = new Text( 'foobar' );
 			const p = new Element( 'p', null, text );
 			const range = Range.createFromParentsAndOffsets( text, 0, text, 0 );
-			const selection = new Selection( [ range ] );
+			const selection = new DocumentSelection( [ range ] );
 			expect( stringify( p, selection ) ).to.equal( '<p>{}foobar</p>' );
 		} );
 
@@ -227,7 +227,7 @@ describe( 'view test utils', () => {
 			const b2 = new Element( 'b', null, text2 );
 			const p = new Element( 'p', null, [ b1, b2 ] );
 			const range = Range.createFromParentsAndOffsets( p, 0, text2, 5 );
-			const selection = new Selection( [ range ] );
+			const selection = new DocumentSelection( [ range ] );
 			expect( stringify( p, selection ) ).to.equal( '<p>[<b>foobar</b><b>bazqu}x</b></p>' );
 		} );
 
@@ -307,7 +307,7 @@ describe( 'view test utils', () => {
 			const p = new Element( 'p', null, [ b1, b2 ] );
 			const range1 = Range.createFromParentsAndOffsets( p, 0, p, 1 );
 			const range2 = Range.createFromParentsAndOffsets( p, 1, p, 1 );
-			const selection = new Selection( [ range2, range1 ] );
+			const selection = new DocumentSelection( [ range2, range1 ] );
 
 			expect( stringify( p, selection ) ).to.equal( '<p>[<b>foobar</b>][]<b>bazqux</b></p>' );
 		} );
@@ -321,7 +321,7 @@ describe( 'view test utils', () => {
 			const range2 = Range.createFromParentsAndOffsets( text2, 0, text2, 3 );
 			const range3 = Range.createFromParentsAndOffsets( text2, 3, text2, 4 );
 			const range4 = Range.createFromParentsAndOffsets( p, 1, p, 1 );
-			const selection = new Selection( [ range1, range2, range3, range4 ] );
+			const selection = new DocumentSelection( [ range1, range2, range3, range4 ] );
 
 			expect( stringify( p, selection ) ).to.equal( '<p>[<b>foobar</b>][]{baz}{q}ux</p>' );
 		} );

+ 2 - 2
packages/ckeditor5-engine/tests/view/_utils/createdocumentmock.js

@@ -4,7 +4,7 @@
  */
 
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
-import Selection from '../../../src/view/selection';
+import DocumentSelection from '../../../src/view/documentselection';
 
 /**
  * Creates {@link module:engine/view/document~Document view Document} mock.
@@ -15,7 +15,7 @@ export default function createDocumentMock() {
 	const doc = Object.create( ObservableMixin );
 	doc.set( 'isFocused', false );
 	doc.set( 'isReadOnly', false );
-	doc.selection = new Selection();
+	doc.selection = new DocumentSelection();
 
 	return doc;
 }

+ 36 - 36
packages/ckeditor5-engine/tests/view/selection.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md.
  */
 
-import Selection from '../../src/view/selection';
+import DocumentSelection from '../../src/view/documentselection';
 import Range from '../../src/view/range';
 import Document from '../../src/view/document';
 import Element from '../../src/view/element';
@@ -21,7 +21,7 @@ describe( 'Selection', () => {
 		const text = new Text( 'xxxxxxxxxxxxxxxxxxxx' );
 		el = new Element( 'p', null, text );
 
-		selection = new Selection();
+		selection = new DocumentSelection();
 
 		range1 = Range.createFromParentsAndOffsets( text, 5, text, 10 );
 		range2 = Range.createFromParentsAndOffsets( text, 1, text, 2 );
@@ -30,27 +30,27 @@ describe( 'Selection', () => {
 
 	describe( 'constructor()', () => {
 		it( 'should be able to create an empty selection', () => {
-			const selection = new Selection();
+			const selection = new DocumentSelection();
 
 			expect( Array.from( selection.getRanges() ) ).to.deep.equal( [] );
 		} );
 
 		it( 'should be able to create a selection from the given ranges', () => {
 			const ranges = [ range1, range2, range3 ];
-			const selection = new Selection( ranges );
+			const selection = new DocumentSelection( ranges );
 
 			expect( Array.from( selection.getRanges() ) ).to.deep.equal( ranges );
 		} );
 
 		it( 'should be able to create a selection from the given ranges and isLastBackward flag', () => {
 			const ranges = [ range1, range2, range3 ];
-			const selection = new Selection( ranges, { backward: true } );
+			const selection = new DocumentSelection( ranges, { backward: true } );
 
 			expect( selection.isBackward ).to.be.true;
 		} );
 
 		it( 'should be able to create a selection from the given range and isLastBackward flag', () => {
-			const selection = new Selection( range1, { backward: true } );
+			const selection = new DocumentSelection( range1, { backward: true } );
 
 			expect( Array.from( selection.getRanges() ) ).to.deep.equal( [ range1 ] );
 			expect( selection.isBackward ).to.be.true;
@@ -58,7 +58,7 @@ describe( 'Selection', () => {
 
 		it( 'should be able to create a selection from the given iterable of ranges and isLastBackward flag', () => {
 			const ranges = new Set( [ range1, range2, range3 ] );
-			const selection = new Selection( ranges, { backward: false } );
+			const selection = new DocumentSelection( ranges, { backward: false } );
 
 			expect( Array.from( selection.getRanges() ) ).to.deep.equal( [ range1, range2, range3 ] );
 			expect( selection.isBackward ).to.be.false;
@@ -66,7 +66,7 @@ describe( 'Selection', () => {
 
 		it( 'should be able to create a collapsed selection at the given position', () => {
 			const position = range1.start;
-			const selection = new Selection( position );
+			const selection = new DocumentSelection( position );
 
 			expect( Array.from( selection.getRanges() ).length ).to.equal( 1 );
 			expect( selection.getFirstRange().start ).to.deep.equal( position );
@@ -76,7 +76,7 @@ describe( 'Selection', () => {
 
 		it( 'should be able to create a collapsed selection at the given position', () => {
 			const position = range1.start;
-			const selection = new Selection( position );
+			const selection = new DocumentSelection( position );
 
 			expect( Array.from( selection.getRanges() ).length ).to.equal( 1 );
 			expect( selection.getFirstRange().start ).to.deep.equal( position );
@@ -85,16 +85,16 @@ describe( 'Selection', () => {
 		} );
 
 		it( 'should be able to create a selection from the other selection', () => {
-			const otherSelection = new Selection( [ range2, range3 ], { backward: true } );
-			const selection = new Selection( otherSelection );
+			const otherSelection = new DocumentSelection( [ range2, range3 ], { backward: true } );
+			const selection = new DocumentSelection( otherSelection );
 
 			expect( Array.from( selection.getRanges() ) ).to.deep.equal( [ range2, range3 ] );
 			expect( selection.isBackward ).to.be.true;
 		} );
 
 		it( 'should be able to create a fake selection from the other fake selection', () => {
-			const otherSelection = new Selection( [ range2, range3 ], { fake: true, label: 'foo bar baz' } );
-			const selection = new Selection( otherSelection );
+			const otherSelection = new DocumentSelection( [ range2, range3 ], { fake: true, label: 'foo bar baz' } );
+			const selection = new DocumentSelection( otherSelection );
 
 			expect( selection.isFake ).to.be.true;
 			expect( selection.fakeSelectionLabel ).to.equal( 'foo bar baz' );
@@ -103,7 +103,7 @@ describe( 'Selection', () => {
 		it( 'should throw an error when range is invalid', () => {
 			expect( () => {
 				// eslint-disable-next-line no-new
-				new Selection( [ { invalid: 'range' } ] );
+				new DocumentSelection( [ { invalid: 'range' } ] );
 			} ).to.throw( CKEditorError, 'view-selection-invalid-range: Invalid Range.' );
 		} );
 
@@ -113,14 +113,14 @@ describe( 'Selection', () => {
 
 			expect( () => {
 				// eslint-disable-next-line no-new
-				new Selection( [ range1, range2 ] );
+				new DocumentSelection( [ range1, range2 ] );
 			} ).to.throw( CKEditorError, 'view-selection-range-intersects' );
 		} );
 
 		it( 'should throw an error when trying to set to not selectable', () => {
 			expect( () => {
 				// eslint-disable-next-line no-new
-				new Selection( {} );
+				new DocumentSelection( {} );
 			} ).to.throw( /view-selection-setTo-not-selectable/ );
 		} );
 	} );
@@ -470,7 +470,7 @@ describe( 'Selection', () => {
 		it( 'should return true if selections equal', () => {
 			selection._setTo( [ range1, range2 ] );
 
-			const otherSelection = new Selection();
+			const otherSelection = new DocumentSelection();
 			otherSelection._setTo( [ range1, range2 ] );
 
 			expect( selection.isEqual( otherSelection ) ).to.be.true;
@@ -479,7 +479,7 @@ describe( 'Selection', () => {
 		it( 'should return true if backward selections equal', () => {
 			selection._setTo( range1, { backward: true } );
 
-			const otherSelection = new Selection( [ range1 ], { backward: true } );
+			const otherSelection = new DocumentSelection( [ range1 ], { backward: true } );
 
 			expect( selection.isEqual( otherSelection ) ).to.be.true;
 		} );
@@ -487,7 +487,7 @@ describe( 'Selection', () => {
 		it( 'should return false if ranges count does not equal', () => {
 			selection._setTo( [ range1, range2 ] );
 
-			const otherSelection = new Selection( [ range1 ] );
+			const otherSelection = new DocumentSelection( [ range1 ] );
 
 			expect( selection.isEqual( otherSelection ) ).to.be.false;
 		} );
@@ -495,7 +495,7 @@ describe( 'Selection', () => {
 		it( 'should return false if ranges (other than the last added one) do not equal', () => {
 			selection._setTo( [ range1, range3 ] );
 
-			const otherSelection = new Selection( [ range2, range3 ] );
+			const otherSelection = new DocumentSelection( [ range2, range3 ] );
 
 			expect( selection.isEqual( otherSelection ) ).to.be.false;
 		} );
@@ -503,33 +503,33 @@ describe( 'Selection', () => {
 		it( 'should return false if directions do not equal', () => {
 			selection._setTo( range1 );
 
-			const otherSelection = new Selection( [ range1 ], { backward: true } );
+			const otherSelection = new DocumentSelection( [ range1 ], { backward: true } );
 
 			expect( selection.isEqual( otherSelection ) ).to.be.false;
 		} );
 
 		it( 'should return false if one selection is fake', () => {
-			const otherSelection = new Selection( null, { fake: true } );
+			const otherSelection = new DocumentSelection( null, { fake: true } );
 
 			expect( selection.isEqual( otherSelection ) ).to.be.false;
 		} );
 
 		it( 'should return true if both selection are fake', () => {
-			const otherSelection = new Selection( range1, { fake: true } );
+			const otherSelection = new DocumentSelection( range1, { fake: true } );
 			selection._setTo( range1, { fake: true } );
 
 			expect( selection.isEqual( otherSelection ) ).to.be.true;
 		} );
 
 		it( 'should return false if both selection are fake but have different label', () => {
-			const otherSelection = new Selection( [ range1 ], { fake: true, label: 'foo bar baz' } );
+			const otherSelection = new DocumentSelection( [ range1 ], { fake: true, label: 'foo bar baz' } );
 			selection._setTo( range1, { fake: true, label: 'foo' } );
 
 			expect( selection.isEqual( otherSelection ) ).to.be.false;
 		} );
 
 		it( 'should return true if both selections are empty', () => {
-			const otherSelection = new Selection();
+			const otherSelection = new DocumentSelection();
 
 			expect( selection.isEqual( otherSelection ) ).to.be.true;
 		} );
@@ -539,7 +539,7 @@ describe( 'Selection', () => {
 		it( 'should return true if selections equal', () => {
 			selection._setTo( [ range1, range2 ] );
 
-			const otherSelection = new Selection( [ range1, range2 ] );
+			const otherSelection = new DocumentSelection( [ range1, range2 ] );
 
 			expect( selection.isSimilar( otherSelection ) ).to.be.true;
 		} );
@@ -547,7 +547,7 @@ describe( 'Selection', () => {
 		it( 'should return false if ranges count does not equal', () => {
 			selection._setTo( [ range1, range2 ] );
 
-			const otherSelection = new Selection( [ range1 ] );
+			const otherSelection = new DocumentSelection( [ range1 ] );
 
 			expect( selection.isSimilar( otherSelection ) ).to.be.false;
 		} );
@@ -555,7 +555,7 @@ describe( 'Selection', () => {
 		it( 'should return false if trimmed ranges (other than the last added one) are not equal', () => {
 			selection._setTo( [ range1, range3 ] );
 
-			const otherSelection = new Selection( [ range2, range3 ] );
+			const otherSelection = new DocumentSelection( [ range2, range3 ] );
 
 			expect( selection.isSimilar( otherSelection ) ).to.be.false;
 		} );
@@ -563,13 +563,13 @@ describe( 'Selection', () => {
 		it( 'should return false if directions are not equal', () => {
 			selection._setTo( range1 );
 
-			const otherSelection = new Selection( [ range1 ], { backward: true } );
+			const otherSelection = new DocumentSelection( [ range1 ], { backward: true } );
 
 			expect( selection.isSimilar( otherSelection ) ).to.be.false;
 		} );
 
 		it( 'should return true if both selections are empty', () => {
-			const otherSelection = new Selection();
+			const otherSelection = new DocumentSelection();
 
 			expect( selection.isSimilar( otherSelection ) ).to.be.true;
 		} );
@@ -593,7 +593,7 @@ describe( 'Selection', () => {
 
 			selection._setTo( [ rangeA1, rangeA2 ] );
 
-			const otherSelection = new Selection( [ rangeB2, rangeB1 ] );
+			const otherSelection = new DocumentSelection( [ rangeB2, rangeB1 ] );
 
 			expect( selection.isSimilar( otherSelection ) ).to.be.true;
 			expect( otherSelection.isSimilar( selection ) ).to.be.true;
@@ -608,7 +608,7 @@ describe( 'Selection', () => {
 			it( 'should set selection ranges from the given selection', () => {
 				selection._setTo( range1 );
 
-				const otherSelection = new Selection( [ range2, range3 ], { backward: true } );
+				const otherSelection = new DocumentSelection( [ range2, range3 ], { backward: true } );
 
 				selection._setTo( otherSelection );
 
@@ -651,14 +651,14 @@ describe( 'Selection', () => {
 					done();
 				} );
 
-				const otherSelection = new Selection( [ range1 ] );
+				const otherSelection = new DocumentSelection( [ range1 ] );
 
 				selection._setTo( otherSelection );
 			} );
 
 			it( 'should set fake state and label', () => {
 				const label = 'foo bar baz';
-				const otherSelection = new Selection( null, { fake: true, label } );
+				const otherSelection = new DocumentSelection( null, { fake: true, label } );
 				selection._setTo( otherSelection );
 
 				expect( selection.isFake ).to.be.true;
@@ -666,7 +666,7 @@ describe( 'Selection', () => {
 			} );
 
 			it( 'should throw an error when trying to set to not selectable', () => {
-				const otherSelection = new Selection();
+				const otherSelection = new DocumentSelection();
 
 				expect( () => {
 					otherSelection._setTo( {} );
@@ -674,7 +674,7 @@ describe( 'Selection', () => {
 			} );
 
 			it( 'should throw an error when trying to set to not selectable #2', () => {
-				const otherSelection = new Selection();
+				const otherSelection = new DocumentSelection();
 
 				expect( () => {
 					otherSelection._setTo();

+ 3 - 3
packages/ckeditor5-engine/tests/view/domconverter/binding.js

@@ -6,7 +6,7 @@
 /* globals document */
 
 import ViewElement from '../../../src/view/element';
-import ViewSelection from '../../../src/view/selection';
+import ViewDocumentSelection from '../../../src/view/documentselection';
 import DomConverter from '../../../src/view/domconverter';
 import ViewDocumentFragment from '../../../src/view/documentfragment';
 import { INLINE_FILLER } from '../../../src/view/filler';
@@ -269,7 +269,7 @@ describe( 'DomConverter', () => {
 		beforeEach( () => {
 			viewElement = new ViewElement();
 			domEl = document.createElement( 'div' );
-			selection = new ViewSelection( viewElement, 'in' );
+			selection = new ViewDocumentSelection( viewElement, 'in' );
 			converter.bindFakeSelection( domEl, selection );
 		} );
 
@@ -280,7 +280,7 @@ describe( 'DomConverter', () => {
 		} );
 
 		it( 'should keep a copy of selection', () => {
-			const selectionCopy = new ViewSelection( selection );
+			const selectionCopy = new ViewDocumentSelection( selection );
 
 			selection._setTo( new ViewElement(), 'in', { backward: true } );
 			const bindSelection = converter.fakeSelectionToView( domEl );

+ 3 - 3
packages/ckeditor5-engine/tests/view/domconverter/dom-to-view.js

@@ -6,7 +6,7 @@
 /* globals document */
 
 import ViewElement from '../../../src/view/element';
-import ViewSelection from '../../../src/view/selection';
+import ViewDocumentSelection from '../../../src/view/documentselection';
 import DomConverter from '../../../src/view/domconverter';
 import ViewDocumentFragment from '../../../src/view/documentfragment';
 import { INLINE_FILLER, INLINE_FILLER_LENGTH, NBSP_FILLER } from '../../../src/view/filler';
@@ -882,7 +882,7 @@ describe( 'DomConverter', () => {
 			domContainer.innerHTML = 'fake selection container';
 			document.body.appendChild( domContainer );
 
-			const viewSelection = new ViewSelection( new ViewElement(), 'in' );
+			const viewSelection = new ViewDocumentSelection( new ViewElement(), 'in' );
 			converter.bindFakeSelection( domContainer, viewSelection );
 
 			const domRange = document.createRange();
@@ -903,7 +903,7 @@ describe( 'DomConverter', () => {
 			domContainer.innerHTML = 'fake selection container';
 			document.body.appendChild( domContainer );
 
-			const viewSelection = new ViewSelection( new ViewElement(), 'in' );
+			const viewSelection = new ViewDocumentSelection( new ViewElement(), 'in' );
 			converter.bindFakeSelection( domContainer, viewSelection );
 
 			const domRange = document.createRange();

+ 1 - 1
packages/ckeditor5-engine/tests/view/observer/selectionobserver.js

@@ -7,7 +7,7 @@
 
 import ViewRange from '../../../src/view/range';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
-import ViewSelection from '../../../src/view/selection';
+import ViewSelection from '../../../src/view/documentselection';
 import View from '../../../src/view/view';
 import SelectionObserver from '../../../src/view/observer/selectionobserver';
 import FocusObserver from '../../../src/view/observer/focusobserver';

+ 2 - 2
packages/ckeditor5-engine/tests/view/renderer.js

@@ -12,7 +12,7 @@ import ViewAttributeElement from '../../src/view/attributeelement';
 import ViewText from '../../src/view/text';
 import ViewRange from '../../src/view/range';
 import ViewPosition from '../../src/view/position';
-import Selection from '../../src/view/selection';
+import DocumentSelection from '../../src/view/documentselection';
 import DomConverter from '../../src/view/domconverter';
 import Renderer from '../../src/view/renderer';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
@@ -29,7 +29,7 @@ describe( 'Renderer', () => {
 	let selection, domConverter, renderer;
 
 	beforeEach( () => {
-		selection = new Selection();
+		selection = new DocumentSelection();
 		domConverter = new DomConverter();
 		renderer = new Renderer( domConverter, selection );
 		renderer.domDocuments.add( document );