Przeglądaj źródła

Other: Remove redundant Position.createFromPosition calls.

Maciej Gołaszewski 8 lat temu
rodzic
commit
9aaf822e91

+ 1 - 3
packages/ckeditor5-engine/src/model/documentselection.js

@@ -7,7 +7,6 @@
  * @module engine/model/documentselection
  */
 
-import Position from './position';
 import Range from './range';
 import LiveRange from './liverange';
 import Text from './text';
@@ -666,10 +665,9 @@ export default class DocumentSelection extends Selection {
 	_fixGraveyardSelection( liveRange, removedRangeStart ) {
 		// The start of the removed range is the closest position to the `liveRange` - the original selection range.
 		// This is a good candidate for a fixed selection range.
-		const positionCandidate = Position.createFromPosition( removedRangeStart );
 
 		// Find a range that is a correct selection range and is closest to the start of removed range.
-		const selectionRange = this._document.getNearestSelectionRange( positionCandidate );
+		const selectionRange = this._document.getNearestSelectionRange( removedRangeStart );
 
 		// Remove the old selection range before preparing and adding new selection range. This order is important,
 		// because new range, in some cases, may intersect with old range (it depends on `getNearestSelectionRange()` result).

+ 1 - 1
packages/ckeditor5-engine/src/model/operation/insertoperation.js

@@ -37,7 +37,7 @@ export default class InsertOperation extends Operation {
 		 * @readonly
 		 * @member {module:engine/model/position~Position} module:engine/model/operation/insertoperation~InsertOperation#position
 		 */
-		this.position = Position.createFromPosition( position );
+		this.position = position;
 
 		/**
 		 * List of nodes to insert.

+ 2 - 2
packages/ckeditor5-engine/src/model/operation/renameoperation.js

@@ -66,7 +66,7 @@ export default class RenameOperation extends Operation {
 	 * @returns {module:engine/model/operation/renameoperation~RenameOperation} Clone of this operation.
 	 */
 	clone() {
-		return new RenameOperation( Position.createFromPosition( this.position ), this.oldName, this.newName, this.baseVersion );
+		return new RenameOperation( this.position, this.oldName, this.newName, this.baseVersion );
 	}
 
 	/**
@@ -75,7 +75,7 @@ export default class RenameOperation extends Operation {
 	 * @returns {module:engine/model/operation/renameoperation~RenameOperation}
 	 */
 	getReversed() {
-		return new RenameOperation( Position.createFromPosition( this.position ), this.newName, this.oldName, this.baseVersion + 1 );
+		return new RenameOperation( this.position, this.newName, this.oldName, this.baseVersion + 1 );
 	}
 
 	/**

+ 2 - 2
packages/ckeditor5-engine/src/model/selection.js

@@ -240,7 +240,7 @@ export default class Selection {
 	getFirstPosition() {
 		const first = this.getFirstRange();
 
-		return first ? Position.createFromPosition( first.start ) : null;
+		return first ? first.start : null;
 	}
 
 	/**
@@ -255,7 +255,7 @@ export default class Selection {
 	getLastPosition() {
 		const lastRange = this.getLastRange();
 
-		return lastRange ? Position.createFromPosition( lastRange.end ) : null;
+		return lastRange ? lastRange.end : null;
 	}
 
 	/**

+ 2 - 2
packages/ckeditor5-engine/src/model/treewalker.js

@@ -85,9 +85,9 @@ export default class TreeWalker {
 		 * @member {module:engine/model/position~Position} module:engine/model/treewalker~TreeWalker#position
 		 */
 		if ( options.startPosition ) {
-			this.position = Position.createFromPosition( options.startPosition );
+			this.position = options.startPosition;
 		} else {
-			this.position = Position.createFromPosition( this.boundaries[ this.direction == 'backward' ? 'end' : 'start' ] );
+			this.position = this.boundaries[ this.direction == 'backward' ? 'end' : 'start' ];
 		}
 
 		/**