in src/Clients/Web/winjs/js/winjs.js [75375:75478]
_measure: function NavBarContainer_measure() {
if (!this._measured) {
this._resizeImpl();
this._writeProfilerMark("measure,StartTM");
var sizes = this._sizes;
sizes.rtl = _Global.getComputedStyle(this._element).direction === "rtl";
var itemCount = this._surfaceEl.children.length;
if (itemCount > 0) {
if (!this._sizes.itemMeasured) {
this._writeProfilerMark("measureItem,StartTM");
var elementToMeasure = this._surfaceEl.firstElementChild;
// Clear inline margins set by NavBarContainer before measuring.
elementToMeasure.style.margin = "";
elementToMeasure.style.width = "";
var elementComputedStyle = _Global.getComputedStyle(elementToMeasure);
sizes.itemOffsetWidth = parseFloat(_Global.getComputedStyle(elementToMeasure).width);
if (elementToMeasure.offsetWidth === 0) {
sizes.itemOffsetWidth = 0;
}
sizes.itemMarginLeft = parseFloat(elementComputedStyle.marginLeft);
sizes.itemMarginRight = parseFloat(elementComputedStyle.marginRight);
sizes.itemWidth = sizes.itemOffsetWidth + sizes.itemMarginLeft + sizes.itemMarginRight;
sizes.itemOffsetHeight = parseFloat(_Global.getComputedStyle(elementToMeasure).height);
if (elementToMeasure.offsetHeight === 0) {
sizes.itemOffsetHeight = 0;
}
sizes.itemMarginTop = parseFloat(elementComputedStyle.marginTop);
sizes.itemMarginBottom = parseFloat(elementComputedStyle.marginBottom);
sizes.itemHeight = sizes.itemOffsetHeight + sizes.itemMarginTop + sizes.itemMarginBottom;
if (sizes.itemOffsetWidth > 0 && sizes.itemOffsetHeight > 0) {
sizes.itemMeasured = true;
}
this._writeProfilerMark("measureItem,StopTM");
}
sizes.viewportOffsetWidth = parseFloat(_Global.getComputedStyle(this._viewportEl).width);
if (this._viewportEl.offsetWidth === 0) {
sizes.viewportOffsetWidth = 0;
}
sizes.viewportOffsetHeight = parseFloat(_Global.getComputedStyle(this._viewportEl).height);
if (this._viewportEl.offsetHeight === 0) {
sizes.viewportOffsetHeight = 0;
}
if (sizes.viewportOffsetWidth === 0 || sizes.itemOffsetHeight === 0) {
this._measured = false;
} else {
this._measured = true;
}
if (this.layout === _UI.Orientation.horizontal) {
this._scrollPosition = _ElementUtilities.getScrollPosition(this._viewportEl).scrollLeft;
sizes.leadingEdge = this._leftArrowEl.offsetWidth + parseInt(_Global.getComputedStyle(this._leftArrowEl).marginLeft) + parseInt(_Global.getComputedStyle(this._leftArrowEl).marginRight);
var usableSpace = sizes.viewportOffsetWidth - sizes.leadingEdge * 2;
sizes.maxColumns = sizes.itemWidth ? Math.max(1, Math.floor(usableSpace / sizes.itemWidth)) : 1;
sizes.rowsPerPage = Math.min(this.maxRows, Math.ceil(itemCount / sizes.maxColumns));
sizes.columnsPerPage = Math.min(sizes.maxColumns, itemCount);
sizes.pages = Math.ceil(itemCount / (sizes.columnsPerPage * sizes.rowsPerPage));
sizes.trailingEdge = sizes.leadingEdge;
sizes.extraSpace = usableSpace - (sizes.columnsPerPage * sizes.itemWidth);
this._scrollLength = sizes.viewportOffsetWidth * sizes.pages;
this._keyboardBehavior.fixedSize = sizes.rowsPerPage;
this._keyboardBehavior.fixedDirection = _KeyboardBehavior._KeyboardBehavior.FixedDirection.height;
this._surfaceEl.style.height = (sizes.itemHeight * sizes.rowsPerPage) + "px";
this._surfaceEl.style.width = this._scrollLength + "px";
} else {
this._scrollPosition = this._viewportEl.scrollTop;
sizes.leadingEdge = 0;
sizes.rowsPerPage = itemCount;
sizes.columnsPerPage = 1;
sizes.pages = 1;
sizes.trailingEdge = 0;
// Reminder there is margin collapsing so just use scrollHeight instead of itemHeight * itemCount
this._scrollLength = this._viewportEl.scrollHeight;
this._keyboardBehavior.fixedSize = sizes.columnsPerPage;
this._keyboardBehavior.fixedDirection = _KeyboardBehavior._KeyboardBehavior.FixedDirection.width;
this._surfaceEl.style.height = "";
this._surfaceEl.style.width = "";
}
this._updateGridStyles();
} else {
sizes.pages = 1;
this._hasPreviousContent = false;
this._hasNextContent = false;
this._surfaceEl.style.height = "";
this._surfaceEl.style.width = "";
}
this._writeProfilerMark("measure,StopTM");
}
},