Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/53750


Change subject: Correct name of can(Node)HaveGrandchildren functions
......................................................................

Correct name of can(Node)HaveGrandchildren functions

Bug: 43893
Change-Id: I9fd2a1fd6e3ee0a7bdfc357b5d4e4e0fd3efa0a5
---
M modules/ve/ce/ve.ce.BranchNode.js
M modules/ve/ce/ve.ce.Node.js
M modules/ve/ce/ve.ce.SurfaceObserver.js
M modules/ve/dm/ve.dm.Document.js
M modules/ve/dm/ve.dm.Node.js
M modules/ve/dm/ve.dm.NodeFactory.js
M modules/ve/test/ce/ve.ce.BranchNode.test.js
M modules/ve/test/ce/ve.ce.LeafNode.test.js
M modules/ve/test/dm/ve.dm.BranchNode.test.js
M modules/ve/test/dm/ve.dm.LeafNode.test.js
M modules/ve/test/dm/ve.dm.Node.test.js
M modules/ve/test/dm/ve.dm.NodeFactory.test.js
M modules/ve/ve.Document.js
M modules/ve/ve.Node.js
14 files changed, 37 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/50/53750/1

diff --git a/modules/ve/ce/ve.ce.BranchNode.js 
b/modules/ve/ce/ve.ce.BranchNode.js
index f705f18..2bc6c48 100644
--- a/modules/ve/ce/ve.ce.BranchNode.js
+++ b/modules/ve/ce/ve.ce.BranchNode.js
@@ -230,7 +230,7 @@
                delete this.slugs[key];
        }
 
-       if ( this.canHaveGrandchildren() ) {
+       if ( this.canHaveChildrenNotContent() ) {
                $slug = ve.ce.BranchNode.$blockSlugTemplate.clone();
        } else {
                $slug = ve.ce.BranchNode.$inlineSlugTemplate.clone();
diff --git a/modules/ve/ce/ve.ce.Node.js b/modules/ve/ce/ve.ce.Node.js
index 3b9d0f9..6332f14 100644
--- a/modules/ve/ce/ve.ce.Node.js
+++ b/modules/ve/ce/ve.ce.Node.js
@@ -160,15 +160,15 @@
 };
 
 /**
- * Check if the node can have grandchildren.
+ * Check if the node can have children but not content nor be content.
  *
  * This method passes through to the model.
  *
  * @method
- * @returns {boolean} Model node can have grandchildren
+ * @returns {boolean} Model node can have children but not content nor be 
content
  */
-ve.ce.Node.prototype.canHaveGrandchildren = function () {
-       return this.model.canHaveGrandchildren();
+ve.ce.Node.prototype.canHaveChildrenNotContent = function () {
+       return this.model.canHaveChildrenNotContent();
 };
 
 /**
diff --git a/modules/ve/ce/ve.ce.SurfaceObserver.js 
b/modules/ve/ce/ve.ce.SurfaceObserver.js
index 833215d..879f411 100644
--- a/modules/ve/ce/ve.ce.SurfaceObserver.js
+++ b/modules/ve/ce/ve.ce.SurfaceObserver.js
@@ -125,7 +125,7 @@
                $branch = $( rangyRange.anchorNode ).closest( 
'.ve-ce-branchNode' );
                if ( $branch.length ) {
                        node = $branch.data( 'node' );
-                       if ( node.canHaveGrandchildren() ) {
+                       if ( node.canHaveChildrenNotContent() ) {
                                node = null;
                        } else {
                                range = rangyRange.getRange();
diff --git a/modules/ve/dm/ve.dm.Document.js b/modules/ve/dm/ve.dm.Document.js
index c8ba4e0..8d048df 100644
--- a/modules/ve/dm/ve.dm.Document.js
+++ b/modules/ve/dm/ve.dm.Document.js
@@ -353,7 +353,7 @@
                                // Inside empty element
                                '/' + left.type === right.type &&
                                // Both are non-content branches (right is the 
same type)
-                               factory.canNodeHaveGrandchildren( left.type ) &&
+                               factory.canNodeHaveChildrenNotContent( 
left.type ) &&
                                (
                                        // Only apply this rule in unrestricted 
mode
                                        !unrestricted ||
diff --git a/modules/ve/dm/ve.dm.Node.js b/modules/ve/dm/ve.dm.Node.js
index a53b05a..acf357c 100644
--- a/modules/ve/dm/ve.dm.Node.js
+++ b/modules/ve/dm/ve.dm.Node.js
@@ -315,13 +315,13 @@
 };
 
 /**
- * Check if the node can have grandchildren.
+ * Check if the node can have children but not content nor be content.
  *
  * @method
- * @returns {boolean} Node can have grandchildren
+ * @returns {boolean} Node can have children but not content nor be content
  */
-ve.dm.Node.prototype.canHaveGrandchildren = function () {
-       return ve.dm.nodeFactory.canNodeHaveGrandchildren( this.type );
+ve.dm.Node.prototype.canHaveChildrenNotContent = function () {
+       return ve.dm.nodeFactory.canNodeHaveChildrenNotContent( this.type );
 };
 
 /**
diff --git a/modules/ve/dm/ve.dm.NodeFactory.js 
b/modules/ve/dm/ve.dm.NodeFactory.js
index df364e1..b116d31 100644
--- a/modules/ve/dm/ve.dm.NodeFactory.js
+++ b/modules/ve/dm/ve.dm.NodeFactory.js
@@ -108,14 +108,14 @@
 };
 
 /**
- * Check if a node can have grandchildren.
+ * Check if a node can have children but not content nor be content.
  *
  * @method
  * @param {string} type Node type
- * @returns {boolean} The node can have grandchildren
+ * @returns {boolean} The node can have children but not content nor be content
  * @throws {Error} Unknown node type
  */
-ve.dm.NodeFactory.prototype.canNodeHaveGrandchildren = function ( type ) {
+ve.dm.NodeFactory.prototype.canNodeHaveChildrenNotContent = function ( type ) {
        if ( type in this.registry ) {
                return this.canNodeHaveChildren( type ) &&
                        !this.registry[type].static.canContainContent &&
diff --git a/modules/ve/test/ce/ve.ce.BranchNode.test.js 
b/modules/ve/test/ce/ve.ce.BranchNode.test.js
index b695c38..e114dce 100644
--- a/modules/ve/test/ce/ve.ce.BranchNode.test.js
+++ b/modules/ve/test/ce/ve.ce.BranchNode.test.js
@@ -41,10 +41,10 @@
        assert.equal( node.canHaveChildren(), true );
 } );
 
-QUnit.test( 'canHaveGrandchildren', 1, function ( assert ) {
+QUnit.test( 'canHaveChildrenNotContent', 1, function ( assert ) {
        var node = new ve.ce.BranchNodeStub( new ve.dm.BranchNodeStub() );
 
-       assert.equal( node.canHaveGrandchildren(), true );
+       assert.equal( node.canHaveChildrenNotContent(), true );
 } );
 
 QUnit.test( 'updateDomWrapper', 3, function ( assert ) {
diff --git a/modules/ve/test/ce/ve.ce.LeafNode.test.js 
b/modules/ve/test/ce/ve.ce.LeafNode.test.js
index 4ed9f14..83eac8b 100644
--- a/modules/ve/test/ce/ve.ce.LeafNode.test.js
+++ b/modules/ve/test/ce/ve.ce.LeafNode.test.js
@@ -32,7 +32,7 @@
        assert.equal( node.canHaveChildren(), false );
 } );
 
-QUnit.test( 'canHaveGrandchildren', 1, function ( assert ) {
+QUnit.test( 'canHaveChildrenNotContent', 1, function ( assert ) {
        var node = new ve.ce.LeafNodeStub( new ve.dm.LeafNodeStub() );
-       assert.equal( node.canHaveGrandchildren(), false );
+       assert.equal( node.canHaveChildrenNotContent(), false );
 } );
diff --git a/modules/ve/test/dm/ve.dm.BranchNode.test.js 
b/modules/ve/test/dm/ve.dm.BranchNode.test.js
index 3698cb1..56df23a 100644
--- a/modules/ve/test/dm/ve.dm.BranchNode.test.js
+++ b/modules/ve/test/dm/ve.dm.BranchNode.test.js
@@ -29,9 +29,9 @@
        assert.equal( node.canHaveChildren(), true );
 } );
 
-QUnit.test( 'canHaveGrandchildren', 1, function ( assert ) {
+QUnit.test( 'canHaveChildrenNotContent', 1, function ( assert ) {
        var node = new ve.dm.BranchNodeStub();
-       assert.equal( node.canHaveGrandchildren(), true );
+       assert.equal( node.canHaveChildrenNotContent(), true );
 } );
 
 QUnit.test( 'setRoot', 3, function ( assert ) {
diff --git a/modules/ve/test/dm/ve.dm.LeafNode.test.js 
b/modules/ve/test/dm/ve.dm.LeafNode.test.js
index d3f6d00..5e6f342 100644
--- a/modules/ve/test/dm/ve.dm.LeafNode.test.js
+++ b/modules/ve/test/dm/ve.dm.LeafNode.test.js
@@ -29,9 +29,9 @@
        assert.equal( node.canHaveChildren(), false );
 } );
 
-QUnit.test( 'canHaveGrandchildren', 1, function ( assert ) {
+QUnit.test( 'canHaveChildrenNotContent', 1, function ( assert ) {
        var node = new ve.dm.LeafNodeStub();
-       assert.equal( node.canHaveGrandchildren(), false );
+       assert.equal( node.canHaveChildrenNotContent(), false );
 } );
 
 QUnit.test( 'getAnnotations', 3, function ( assert ) {
diff --git a/modules/ve/test/dm/ve.dm.Node.test.js 
b/modules/ve/test/dm/ve.dm.Node.test.js
index 82e22ae..ce2e204 100644
--- a/modules/ve/test/dm/ve.dm.Node.test.js
+++ b/modules/ve/test/dm/ve.dm.Node.test.js
@@ -29,9 +29,9 @@
        assert.equal( node.canHaveChildren(), false );
 } );
 
-QUnit.test( 'canHaveGrandchildren', 1, function ( assert ) {
+QUnit.test( 'canHaveChildrenNotContent', 1, function ( assert ) {
        var node = new ve.dm.NodeStub();
-       assert.equal( node.canHaveGrandchildren(), false );
+       assert.equal( node.canHaveChildrenNotContent(), false );
 } );
 
 QUnit.test( 'getLength', 2, function ( assert ) {
diff --git a/modules/ve/test/dm/ve.dm.NodeFactory.test.js 
b/modules/ve/test/dm/ve.dm.NodeFactory.test.js
index 806a315..1081c1b 100644
--- a/modules/ve/test/dm/ve.dm.NodeFactory.test.js
+++ b/modules/ve/test/dm/ve.dm.NodeFactory.test.js
@@ -72,17 +72,17 @@
        );
 } );
 
-QUnit.test( 'canNodeHaveGrandchildren', 2, function ( assert ) {
+QUnit.test( 'canNodeHaveChildrenNotContent', 2, function ( assert ) {
        var factory = new ve.dm.NodeFactory();
        assert.throws( function () {
-                       factory.canNodeHaveGrandchildren( 
'node-factory-node-stub', 23, { 'bar': 'baz' } );
+                       factory.canNodeHaveChildrenNotContent( 
'node-factory-node-stub', 23, { 'bar': 'baz' } );
                },
                Error,
                'throws an exception when checking if a node of an unregistered 
type can have grandchildren'
        );
        factory.register( ve.dm.NodeFactoryNodeStub );
        assert.strictEqual(
-               factory.canNodeHaveGrandchildren( 'node-factory-node-stub' ),
+               factory.canNodeHaveChildrenNotContent( 'node-factory-node-stub' 
),
                false,
                'gets grandchild rules for registered nodes'
        );
diff --git a/modules/ve/ve.Document.js b/modules/ve/ve.Document.js
index 937027a..171f1f8 100644
--- a/modules/ve/ve.Document.js
+++ b/modules/ve/ve.Document.js
@@ -188,7 +188,7 @@
                        // - we are in branches mode and node is a branch (can 
have grandchildren)
                        if ( ( mode === 'leaves' ||
                                        ( mode === 'covered' && endInside ) ||
-                                       ( mode === 'branches' && 
node.canHaveGrandchildren() ) ) &&
+                                       ( mode === 'branches' && 
node.canHaveChildrenNotContent() ) ) &&
                                node.children && node.children.length
                        ) {
                                // Descend into node
@@ -234,7 +234,7 @@
                        }
                } else if ( startInside && endInside ) {
                        if ( node.children && node.children.length &&
-                               ( mode !== 'branches' || 
node.canHaveGrandchildren() ) ) {
+                               ( mode !== 'branches' || 
node.canHaveChildrenNotContent() ) ) {
                                // Descend into node
                                currentFrame = {
                                        'node': node,
@@ -264,7 +264,7 @@
                } else if ( startInside ) {
                        if ( ( mode === 'leaves' ||
                                        mode === 'covered' ||
-                                       ( mode === 'branches' && 
node.canHaveGrandchildren() ) ) &&
+                                       ( mode === 'branches' && 
node.canHaveChildrenNotContent() ) ) &&
                                node.children && node.children.length
                        ) {
                                // node is a branch node and the start is 
inside it
@@ -302,7 +302,7 @@
                        // all of node, then ends
 
                        if (
-                               ( mode === 'leaves' || ( mode === 'branches' && 
node.canHaveGrandchildren() ) ) &&
+                               ( mode === 'leaves' || ( mode === 'branches' && 
node.canHaveChildrenNotContent() ) ) &&
                                node.children && node.children.length
                        ) {
                                // Descend into node
@@ -335,7 +335,7 @@
                } else if ( endInside ) {
                        if ( ( mode === 'leaves' ||
                                        mode === 'covered' ||
-                                       ( mode === 'branches' && 
node.canHaveGrandchildren() ) ) &&
+                                       ( mode === 'branches' && 
node.canHaveChildrenNotContent() ) ) &&
                                node.children && node.children.length
                        ) {
                                // node is a branch node and the end is inside 
it
@@ -373,7 +373,7 @@
                        // Add the entire node, so no range property
 
                        if (
-                               ( mode === 'leaves' || ( mode === 'branches' && 
node.canHaveGrandchildren() ) ) &&
+                               ( mode === 'leaves' || ( mode === 'branches' && 
node.canHaveChildrenNotContent() ) ) &&
                                node.children && node.children.length
                        ) {
                                // Descend into node
diff --git a/modules/ve/ve.Node.js b/modules/ve/ve.Node.js
index 2e2b871..526ab13 100644
--- a/modules/ve/ve.Node.js
+++ b/modules/ve/ve.Node.js
@@ -61,15 +61,15 @@
 };
 
 /**
- * Check if the node can have grandchildren.
+ * Check if the node can have children but not content nor be content.
  *
  * @method
  * @abstract
- * @returns {boolean} Node can have grandchildren
+ * @returns {boolean} Node can have children but not content nor be content
  * @throws {Error} if not overridden
  */
-ve.Node.prototype.canHaveGrandchildren = function () {
-       throw new Error( 've.Node.canHaveGrandchildren must be overridden in 
subclass' );
+ve.Node.prototype.canHaveChildrenNotContent = function () {
+       throw new Error( 've.Node.canHaveChildrenNotContent must be overridden 
in subclass' );
 };
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/53750
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9fd2a1fd6e3ee0a7bdfc357b5d4e4e0fd3efa0a5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to