Commit 7598f1fd authored by Hixie's avatar Hixie

Examples: move markAsLaidOut() to just before the return, so the asserts work

Specs: introduce layoutDescendants() to avoid work when a layout
manager is unaffected by its childrens' intrinsic dimensions
Examples: update for layoutDescendants() change
Specs: add "lifetime" to resolver settings so that a transition can
avoid having to dirty every consumer of the property every frame when
it only needs to update the objects that are changing that frame
Specs: expose the parents on AbstractStyleDeclarationList subclasses
Specs: fix documentation around autoreap
Specs: fix definition of setProperty()
Specs: clean up the dimension-related logic of layout managers

Review URL: https://codereview.chromium.org/850593003
parent 6646821d
...@@ -7,7 +7,6 @@ SKY MODULE ...@@ -7,7 +7,6 @@ SKY MODULE
<script> <script>
module.exports.BlockLayoutManager = class BlockLayoutManager extends sky.LayoutManager { module.exports.BlockLayoutManager = class BlockLayoutManager extends sky.LayoutManager {
function layout(width, height) { function layout(width, height) {
this.markAsLaidOut();
if (width == null) if (width == null)
width = this.getIntrinsicWidth().value; width = this.getIntrinsicWidth().value;
let autoHeight = false; let autoHeight = false;
...@@ -31,11 +30,15 @@ SKY MODULE ...@@ -31,11 +30,15 @@ SKY MODULE
} }
if (autoHeight) if (autoHeight)
height = y; height = y;
this.markAsLaidOut();
return { return {
width: width, width: width,
height: height, height: height,
} }
} }
function layoutDescendants() {
this.layout(node.width, node.height);
}
function getIntrinsicWidth() { function getIntrinsicWidth() {
let width = this.node.getProperty('width'); let width = this.node.getProperty('width');
if (typeof width != 'number') { if (typeof width != 'number') {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<script> <script>
class BeehiveLayoutManager extends sky.LayoutManager { class BeehiveLayoutManager extends sky.LayoutManager {
function layout(width, height) { function layout(width, height) {
this.markAsLaidOut();
if (width == null) if (width == null)
width = this.getIntrinsicWidth().value; width = this.getIntrinsicWidth().value;
let autoHeight = false; let autoHeight = false;
...@@ -20,10 +19,13 @@ ...@@ -20,10 +19,13 @@
let y = 0; let y = 0;
while (!loop.done) { while (!loop.done) {
let child = loop.value; let child = loop.value;
if (child.needsLayout || child.descendantNeedsLayout) { if (child.needsLayout) {
child.layoutManager.layout(cellDim, cellDim); child.layoutManager.layout(cellDim, cellDim);
// we ignore the size the child reported from layout(), and force it to the cell dimensions // we ignore the size the child reported from layout(), and force it to the cell dimensions
this.setChildSize(child, cellDim, cellDim); this.setChildSize(child, cellDim, cellDim);
} else if (child.descendantNeedsLayout) {
child.layoutManager.layoutDescendants();
this.setChildSize(child, cellDim, cellDim);
} }
this.setChildPosition(child, x * cellDim + (y % 2) * cellDim/2, y * 3/4 * cellDim); this.setChildPosition(child, x * cellDim + (y % 2) * cellDim/2, y * 3/4 * cellDim);
x += 1; x += 1;
...@@ -35,6 +37,7 @@ ...@@ -35,6 +37,7 @@
} }
if (height == 0) if (height == 0)
height = (1 + y * 3/4) * cellDim; height = (1 + y * 3/4) * cellDim;
this.markAsLaidOut();
return { return {
width: width, width: width,
height: height, height: height,
......
...@@ -23,7 +23,6 @@ SKY MODULE ...@@ -23,7 +23,6 @@ SKY MODULE
this.overflowChild = null; this.overflowChild = null;
} }
function layout(width, height) { function layout(width, height) {
this.markAsLaidOut();
let children = null; let children = null;
let loop = null; let loop = null;
if (height == null) if (height == null)
...@@ -58,7 +57,7 @@ SKY MODULE ...@@ -58,7 +57,7 @@ SKY MODULE
childHeight = childHeight.value; childHeight = childHeight.value;
else else
childHeight = height; childHeight = height;
dims = child.layoutManager.layout(width, height); dims = child.layoutManager.layout(null, height);
this.setChildSize(child, dims.width, dims.height); this.setChildSize(child, dims.width, dims.height);
} else { } else {
dims = { dims = {
...@@ -125,11 +124,15 @@ SKY MODULE ...@@ -125,11 +124,15 @@ SKY MODULE
else else
this.firstSkippedChild = this.overflowChild; this.firstSkippedChild = this.overflowChild;
this.markAsLaidOut();
return { return {
width: width, width: width,
height: height, height: height,
} }
} }
function layoutDescendants() {
this.layout(node.width, node.height);
}
function getIntrinsicWidth() { function getIntrinsicWidth() {
let width = this.node.getProperty('width'); let width = this.node.getProperty('width');
if (typeof width != 'number') { if (typeof width != 'number') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment