Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 1x 3084x 3084x 1x 1x 1x 1x 1x 1x 1x 2411x 2411x 2411x 10072x 10072x 2411x 1x | /*!
* VisualEditor DataModel DocumentNode class.
*
* @copyright See AUTHORS.txt
*/
/**
* DataModel document node.
*
* @class
* @extends ve.dm.BranchNode
*
* @constructor
* @param {ve.dm.BranchNode[]} [children] Child nodes to attach
*/
ve.dm.DocumentNode = function VeDmDocumentNode( children ) {
// Parent constructor
ve.dm.DocumentNode.super.call( this, null, children );
// Properties
this.root = this;
};
/* Inheritance */
OO.inheritClass( ve.dm.DocumentNode, ve.dm.BranchNode );
/* Static Properties */
ve.dm.DocumentNode.static.name = 'document';
ve.dm.DocumentNode.static.isWrapped = false;
ve.dm.DocumentNode.static.parentNodeTypes = [];
ve.dm.DocumentNode.static.matchTagNames = [];
/* Methods */
ve.dm.DocumentNode.prototype.getElement =
ve.dm.DocumentNode.prototype.getAttribute =
ve.dm.DocumentNode.prototype.getAttributes =
ve.dm.DocumentNode.prototype.getOriginalDomElements =
ve.dm.DocumentNode.prototype.getClonedElement =
ve.dm.DocumentNode.prototype.getHashObject = function () {
throw new Error( 'DocumentNodes do not exist in the linear model' );
};
/**
* Calculates and returns the offsets of every subroot
*
* This is designed to be used with caching. It is much faster to calculate the offset of all
* subroots simultaneously than to calculate each individually.
*
* @see ve.dm.Node#getOffset
* @return {Map} Numerical offset for each subroot node
*/
ve.dm.DocumentNode.prototype.getSubrootOffsets = function () {
let offset = 0;
const subrootOffsets = new Map();
this.children.forEach( ( child ) => {
subrootOffsets.set( child, offset );
offset += child.getOuterLength();
} );
return subrootOffsets;
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.DocumentNode );
|