Famous/famous — pull request #445 by gadicc (2014-11-04 13:44:10+00:00)
Title: Fixes for Surface.setSize true, initial no size, and misc cleanup

`Surface.setSize()` doesn't work properly with `true` values, as illustrated here:

```js
s1 = new Surface({ classes: ['red-bg'] });
s1.setContent('s1');
mainContext.add(s1);

window.setTimeout(function() {
// observed: [1080, 528] as expected (but div itself has wrong size)
console.log('s1', s1.getSize());

s1.setSize([200,true]);
window.setTimeout(function() {
// observed: [100, 100], expected: [200, 20] (but div is correctly resized)
console.log('s1', s1.getSize());

s1.setSize([300,true]);
window.setTimeout(function() {
// observed: [100, 100], expected: [300, 20] (and div is not resized)
console.log('s1', s1.getSize());
}, 300);
}, 300);
}, 300);
```

It ended up a being a lot of changes because I cleaned up some things in the process. I spent quite a bit of time trying to figure out if certain things were present or being done in a certain way for a reason, which was not always clear.

I used my common sense as best I could, and will detail the changes below. However, moving forward, it would be great for more comments in the code :) As an example, I wrote a comment about `commit()` needing to run twice and why, which I assumed was part of the intended behaviour for performance reasons, and likewise for `_contentDirty` being handled after the sizing, but I wasn't 100% sure.

1. Changed the `size[0] === true` logic to work as I think was intended.

1. In the `if (size)` branch, `_size_` and _sizeDirty` were set if they changed, but this would happen anyway directly below in `_xyNotEquals(this._size, size)`.

1. `this._size` was checked for before being used, in some places but not others (such as enclosing code). In any case at the bottom of the commit it was set anyway, with values that were never used. So I simply moved it to the top with better initial values and removed all the checks.

1. `_sizeDirty` was never set back to `false`, anywhere.

1. Is the `if (this._contentDirty)` code intentionally after the sizing code to ensure it will only be checked on next run?

I hope this is all clear. I could split cleanup stuff and the actual fix into separate commits if that helps, although a lot of it was related. Is there still no test suite? I did run it through your linter.

Can also try make it update the size in a single pass if that's preferable. Chicken or the egg problem, where the size code uses `target.offset*` when `true` is used and the target update code uses the computed `_size` when `true` is not set. We could separate it with some logic, juts concerned that it's being run on every commit.