Skip to content

Commit

Permalink
Remove native call "insertChild"
Browse files Browse the repository at this point in the history
This is a native call that was planned to eventually replace the parent
property. It was never implemented by the clients, but caused issues
with unnecessary layout flushs generating thousands of set operations.

Change-Id: Ic25ebe3cf80c228a69ac0f0bc8afb6ed092190ae
  • Loading branch information
tbuschto committed Aug 28, 2017
1 parent dfdd617 commit 007e7e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/tabris/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export default class Widget extends NativeObject {
index = this._children.push(child) - 1;
}
super._trigger('addChild', {child, index});
this._nativeCall('insertChild', {child: child.cid, index});
}

_removeChild(child) {
Expand Down
36 changes: 12 additions & 24 deletions test/tabris/Widget.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,10 @@ describe('Widget', function() {
result = widget.append(child1);
});

it("sets the child's parent and calls native `insertChild` method", function() {
it("sets the child's parent", function() {
let calls = client.calls();
expect(calls.length).to.equal(2);
expect(calls.length).to.equal(1);
expect(calls[0]).to.eql({op: 'set', id: child1.cid, properties: {parent: widget.cid}});
expect(calls[1]).to.eql({op: 'call', id: widget.cid, method: 'insertChild',
parameters: {child: child1.cid, index: 0}});
});

it('returns self to allow chaining', function() {
Expand Down Expand Up @@ -413,12 +411,10 @@ describe('Widget', function() {
result = widget.append(child1, child2);
});

it("sets the children's parent and calls native `insertChild` method", function() {
it("sets the children's parent", function() {
let calls = client.calls();
expect(calls.length).to.equal(4);
expect(calls.length).to.equal(2);
expect(calls[0]).to.eql({op: 'set', id: child1.cid, properties: {parent: widget.cid}});
expect(calls[1]).to.eql({op: 'call', id: widget.cid, method: 'insertChild',
parameters: {child: child1.cid, index: 0}});
});

it('returns self to allow chaining', function() {
Expand All @@ -443,15 +439,11 @@ describe('Widget', function() {
result = widget.append([child1, child2]);
});

it("sets the widgets' parent and calls native `insertChild` method", function() {
it("sets the widgets' parent", function() {
let calls = client.calls();
expect(calls.length).to.equal(4);
expect(calls.length).to.equal(2);
expect(calls[0]).to.eql({op: 'set', id: child1.cid, properties: {parent: widget.cid}});
expect(calls[1]).to.eql({op: 'call', id: widget.cid, method: 'insertChild',
parameters: {child: child1.cid, index: 0}});
expect(calls[2]).to.eql({op: 'set', id: child2.cid, properties: {parent: widget.cid}});
expect(calls[3]).to.eql({op: 'call', id: widget.cid, method: 'insertChild',
parameters: {child: child2.cid, index: 1}});
expect(calls[1]).to.eql({op: 'set', id: child2.cid, properties: {parent: widget.cid}});
});

it('adds the widgets to children list', function() {
Expand All @@ -470,15 +462,11 @@ describe('Widget', function() {
result = widget.append(new WidgetCollection([child1, child2]));
});

it("sets the widgets' native parent and calls native `insertChild`", function() {
it("sets the widgets' native parent`", function() {
let calls = client.calls();
expect(calls.length).to.equal(4);
expect(calls.length).to.equal(2);
expect(calls[0]).to.eql({op: 'set', id: child1.cid, properties: {parent: widget.cid}});
expect(calls[1]).to.eql({op: 'call', id: widget.cid, method: 'insertChild',
parameters: {child: child1.cid, index: 0}});
expect(calls[2]).to.eql({op: 'set', id: child2.cid, properties: {parent: widget.cid}});
expect(calls[3]).to.eql({op: 'call', id: widget.cid, method: 'insertChild',
parameters: {child: child2.cid, index: 1}});
expect(calls[1]).to.eql({op: 'set', id: child2.cid, properties: {parent: widget.cid}});
});

it('adds the widgets to children list', function() {
Expand Down Expand Up @@ -1146,8 +1134,8 @@ describe('Widget', function() {
widget.appendTo(parent);

let setCalls = client.calls({op: 'set'});
expect(setCalls.length).to.equal(2);
expect(setCalls[1].properties.layoutData).to.eql({right: [other.cid, 0]});
expect(setCalls.length).to.equal(1);
expect(setCalls[0].properties.layoutData).to.eql({right: [other.cid, 0]});
});

});
Expand Down

0 comments on commit 007e7e5

Please sign in to comment.