default container alignment is to pile stuff just up, respecting only
        padding, margin and element's alignment properties
354012
def resize_children(self):
        """"""
        width = self.width - self.horizontal_padding
        height = self.height - self.vertical_padding

        for sprite, props in (get_props(sprite) for sprite in self.sprites if sprite.visible):
            sprite.alloc_w = width
            sprite.alloc_h = height

            w, h = getattr(sprite, "width", 0), getattr(sprite, "height", 0)
            if hasattr(sprite, "get_height_for_width_size"):
                w2, h2 = sprite.get_height_for_width_size()
                w, h = max(w, w2), max(h, h2)

            w = w * sprite.scale_x + props["margin_left"] + props["margin_right"]
            h = h * sprite.scale_y + props["margin_top"] + props["margin_bottom"]

            sprite.x = self.padding_left + props["margin_left"] + (max(sprite.alloc_w * sprite.scale_x, w) - w) * getattr(sprite, "x_align", 0)
            sprite.y = self.padding_top + props["margin_top"] + (max(sprite.alloc_h * sprite.scale_y, h) - h) * getattr(sprite, "y_align", 0)


        self.__dict__['_children_resize_queued'] = False
904117
function (element) {
            var p = this.padding,
                w = this.canvas.width,
                h = this.canvas.height * 0.5;

            // Convert padding percentage to actual padding
            p = p.map(function (a, i) {
                return a * ((i % 2) ? w : h);
            });

            return [
                this.prettify((parseInt($(element).css("left"), 10)    - p[3]) / (w + p[1] + p[3])),
                this.prettify((h - parseInt($(element).css("top"), 10) - p[2]) / (h - p[0] - p[2]))
            ];
        }
339150
function(props) {
  props = defaultValue(props, {});

  this.title = props.title;

  /**
   * Gets or sets the list of items, ordered from bottom to top, with properties:
   * * `color`: CSS color description,
   * * `lineColor`: CSS color description,
   * * `multipleColors`: An array of CSS color descriptions.  A grid of these colors will be displayed in the box to the left of the item label.
   * * `title`: label placed level with middle of box
   * * `titleAbove`: label placed level with top of box
   * * `titleBelow`: label placed level with bottom of box
   * * `imageUrl`: url of image that will be drawn instead of a coloured box
   * * `imageWidth`, `imageHeight`: image dimensions
   * * `spacingAbove`: adds to itemSpacing for this item only.
   * @type {Object[]}
   */
  this.items = defaultValue(props.items, []);

  /**
   * Gets or sets a color map used to draw a smooth gradient instead of discrete color boxes.
   * @type {ColorMap}
   */
  this.gradientColorMap = props.gradientColorMap;

  /**
   * Gets or sets the maximum height of the whole color bar, unless very many items.
   * @type {Number}
   * @default 130
   */
  this.barHeightMax = defaultValue(props.barHeightMax, 130);

  /**
   * Gets or sets the minimum height of the whole color bar.
   * @type {Number}
   * @default 30
   */
  this.barHeightMin = defaultValue(props.barHeightMax, 30);

  /**
   * Gets or sets the width of each color box (and hence, the color bar)
   * @type {Number}
   * @default 30
   */
  this.itemWidth = defaultValue(props.itemWidth, 30);

  /**
   * Gets or sets the asbolute minimum height of each color box, overruling barHeightMax.
   * @type {Number}
   * @default 12
   */
  this.itemHeightMin = defaultValue(props.itemHeightMin, 12);

  /**
   * Gets or sets the forced height of each color box. Better to leave unset.
   * @type {Number}
   * @default the smaller of `props.barHeightMax / props.items.length` and 30.
   */
  this.itemHeight = props.itemHeight;

  /**
   * Gets or sets the gap between each pair of color boxes.
   * @type {Number}
   * @default 0
   */
  this.itemSpacing = defaultValue(props.itemSpacing, 0);

  /**
   * Gets or sets the spacing to the left of the color bar.
   * @type {Number}
   * @default 5
   */
  this.barLeft = defaultValue(props.barLeft, 5);

  /**
   * Gets or sets the spacing between the title and color bar.
   * @type {Number}
   * @default 5
   */
  this.barTop = defaultValue(props.barTop, 5);

  /**
   * Gets or sets the forced total width of the legend.
   * @type {Number}
   * @default 315
   */
  this.width = defaultValue(props.width, 315);

  /**
   * Gets or sets the horizontal offset of variable title.
   * @type {Number}
   * @default 5
   */
  this.variableNameLeft = defaultValue(props.variableNameLeft, 5);

  /**
   * Gets or sets the vertical offset of variable title.
   * @type {Number}
   * @default 17
   */
  this.variableNameTop = defaultValue(props.variableNameTop, 17);

  /**
   * Gets or sets the CSS class that will be applied to the legend when it is displayed.
   * This is used to ensure that the correct font is used when measuring text for word wrapping.
   * @type {String}
   */
  this.cssClass = defaultValue(props.cssClass, "tjs-legend__legend");

  this._svg = undefined;
}
805768
function confineInContainer(position, width, height, api) {
    var viewWidth = api.getWidth();
    var viewHeight = api.getHeight();
    position[0] = Math.min(position[0] + width, viewWidth) - width;
    position[1] = Math.min(position[1] + height, viewHeight) - height;
    position[0] = Math.max(position[0], 0);
    position[1] = Math.max(position[1], 0);
}
648261
function(css, pos) {
			var cssProp = null;
			/** @type EditContainer */
			var cssRule = typeof css === 'string' ? this.parseFromPosition(css, pos, true) : css;
			if (cssRule) {
				cssProp = cssRule.itemFromPosition(pos, true);
				if (!cssProp) {
					// in case user just started writing CSS property
					// and didn't include semicolon–try another approach
					cssProp = utils.find(cssRule.list(), function(elem) {
						return elem.range(true).end == pos;
					});
				}
			}

			return cssProp;
		}
361165
function(align) {
            this.whenPaperReady(function() {
                var dy;
                switch (align) {
                    case 'top':
                        dy = getTextBoundOffset(this).top;
                        break;
                    case 'bottom':
                        dy = getTextBoundOffset(this).bottom;
                        break;
                    case 'middle':
                        dy = getTextBoundOffset(this).middle;
                        break;
                    default:
                        dy = 0;
                }
                if (dy) this.__fixedPosition = true;
                this.node.setAttribute('dy', dy);
            });
            this.verticalAlign = align;
            return this;
        }
989391
void defaults () {
		minWidth = new MinWidthValue<C, T>(layout.toolkit);
		minHeight =new MinHeightValue<C, T>(layout.toolkit);
		prefWidth = new PrefWidthValue<C, T>(layout.toolkit);
		prefHeight = new PrefHeightValue<C, T>(layout.toolkit);
		maxWidth = new MaxWidthValue<C, T>(layout.toolkit);
		maxHeight = new MaxHeightValue<C, T>(layout.toolkit);
		spaceTop = new FixedValue<C, T>(layout.toolkit,0);
		spaceLeft = new FixedValue<C, T>(layout.toolkit,0);
		spaceBottom = new FixedValue<C, T>(layout.toolkit,0);
		spaceRight = new FixedValue<C, T>(layout.toolkit,0);
		padTop = new FixedValue<C, T>(layout.toolkit,0);
		padLeft = new FixedValue<C, T>(layout.toolkit,0);
		padBottom = new FixedValue<C, T>(layout.toolkit,0);
		padRight = new FixedValue<C, T>(layout.toolkit,0);
		fillX = 0f;
		fillY = 0f;
		align = CENTER;
		expandX = 0;
		expandY = 0;
		ignore = false;
		colspan = 1;
		uniformX = null;
		uniformY = null;
	}
497378
function (start) {
        var container, parent, sibling, siblingName, root;

        container = parent = start ? startContainer : endContainer;
        siblingName = start ? 'previousSibling' : 'nextSibling';
        root = dom.getRoot();

        // If it's a text node and the offset is inside the text
        if (container.nodeType === 3 && !isWhiteSpaceNode(container)) {
          if (start ? startOffset > 0 : endOffset < container.nodeValue.length) {
            return container;
          }
        }

        /*eslint no-constant-condition:0 */
        while (true) {
          // Stop expanding on block elements
          if (!format[0].block_expand && dom.isBlock(parent)) {
            return parent;
          }

          // Walk left/right
          for (sibling = parent[siblingName]; sibling; sibling = sibling[siblingName]) {
            if (!isBookmarkNode(sibling) && !isWhiteSpaceNode(sibling) && !isBogusBr(sibling)) {
              return parent;
            }
          }

          // Check if we can move up are we at root level or body level
          if (parent === root || parent.parentNode === root) {
            container = parent;
            break;
          }

          parent = parent.parentNode;
        }

        return container;
      }
1181842
function () {
		var titleOffset = 0,
			title = this.title,
			subtitle = this.subtitle,
			options = this.options,
			titleOptions = options.title,
			subtitleOptions = options.subtitle,
			autoWidth = this.spacingBox.width - 44; // 44 makes room for default context button

		if (title) {
			title
				.css({ width: (titleOptions.width || autoWidth) + PX })
				.align(extend({ y: 15 }, titleOptions), false, 'spacingBox');
			
			if (!titleOptions.floating && !titleOptions.verticalAlign) {
				titleOffset = title.getBBox().height;

				// Adjust for browser consistency + backwards compat after #776 fix
				if (titleOffset >= 18 && titleOffset <= 25) {
					titleOffset = 15; 
				}
			}
		}
		if (subtitle) {
			subtitle
				.css({ width: (subtitleOptions.width || autoWidth) + PX })
				.align(extend({ y: titleOffset + titleOptions.margin }, subtitleOptions), false, 'spacingBox');
			
			if (!subtitleOptions.floating && !subtitleOptions.verticalAlign) {
				titleOffset = mathCeil(titleOffset + subtitle.getBBox().height);
			}
		}

		this.titleOffset = titleOffset; // used in getMargins
	}
1232239
function(pos) {
    var props = {};
    if(pos.indexOf('top') !== -1) {
      props.top = this.options.pos_margin;
    } else if(pos.indexOf('bottom') !== -1) {
      props.bottom = this.options.pos_margin;
    }

    if(pos.indexOf('left') !== -1) {
      props.left = this.options.pos_margin;
    } else if(pos.indexOf('right') !== -1) {
      props.right = this.options.pos_margin;
    }
    this.$el.css(props);

  }
1359972
function () {
        var self = this, style, rect;

        style = self.getEl().style;
        rect = self._layoutRect;

        style.left = rect.x + 'px';
        style.top = rect.y + 'px';
        style.zIndex = 0xFFFF + 0xFFFF;
      }
148062
function() {
		this._el.content_item.style.height = TL.Util.ratio.r16_9({w:this._el.content_item.offsetWidth}) + "px";
	}
922476
function _LayoutCommon_ensureContainerSize(group) {
                    var sizes = this._sizes;
                    if (!sizes.containerSizeLoaded && !this._ensuringContainerSize) {
                        var promise;
                        if ((!this._itemInfo || typeof this._itemInfo !== "function") && this._useDefaultItemInfo) {
                            var margins = sizes.containerMargins;
                            promise = Promise.wrap({
                                width: group.groupInfo.cellWidth - margins.left - margins.right,
                                height: group.groupInfo.cellHeight - margins.top - margins.bottom
                            });

                        } else {
                            promise = this._getItemInfo();
                        }

                        var that = this;
                        this._ensuringContainerSize = promise.then(function (itemSize) {
                            sizes.containerSizeLoaded = true;
                            sizes.containerWidth = itemSize.width + sizes.itemBoxOuterWidth + sizes.containerOuterWidth;
                            sizes.containerHeight = itemSize.height + sizes.itemBoxOuterHeight + sizes.containerOuterHeight;
                            if (!that._inListMode) {
                                that._itemsPerBar = Math.floor(sizes.maxItemsContainerContentSize / sizes.containerCrossSize);
                                if (that.maximumRowsOrColumns) {
                                    that._itemsPerBar = Math.min(that._itemsPerBar, that.maximumRowsOrColumns);
                                }
                                that._itemsPerBar = Math.max(1, that._itemsPerBar);
                            } else {
                                that._itemsPerBar = 1;
                            }
                            that._createContainerStyleRule();
                        });

                        promise.done(
                            function () {
                                that._ensuringContainerSize = null;
                            },
                            function () {
                                that._ensuringContainerSize = null;
                            }
                        );

                        return promise;
                    } else {
                        return this._ensuringContainerSize ? this._ensuringContainerSize : Promise.wrap();
                    }
                }
556914
function() {
		var i,
			totalSplitterSize = (this.contentItems.length - 1) * this._splitterSize,
  		headerSize = this.layoutManager.config.dimensions.headerHeight,
			totalWidth = this.element.width(),
			totalHeight = this.element.height(),
			totalAssigned = 0,
			additionalPixel,
			itemSize,
			itemSizes = [];

		if( this._isColumn ) {
			totalHeight -= totalSplitterSize;
		} else {
			totalWidth -= totalSplitterSize;
		}
		for( i = 0; i < this.contentItems.length; i++ ) {
			if( this._isDocked( i ) )
				if( this._isColumn ) {
					totalHeight -= headerSize - this._splitterSize;
				} else {
					totalWidth -= headerSize - this._splitterSize;
				}
		}

		for( i = 0; i < this.contentItems.length; i++ ) {
			if( this._isColumn ) {
				itemSize = Math.floor( totalHeight * ( this.contentItems[ i ].config.height / 100 ) );
			} else {
				itemSize = Math.floor( totalWidth * (this.contentItems[ i ].config.width / 100) );
			}
			if( this._isDocked( i ) )
				itemSize = headerSize;

			totalAssigned += itemSize;
			itemSizes.push( itemSize );
		}

		additionalPixel = Math.floor( (this._isColumn ? totalHeight : totalWidth) - totalAssigned );

		return {
			itemSizes: itemSizes,
			additionalPixel: additionalPixel,
			totalWidth: totalWidth,
			totalHeight: totalHeight
		};
	}
948805
def layout
      # This assumes that the container overlaps all the children.

      # Move all children if we have moved.
      @children.each.with_index do |child, index|
        child.x = padding_left + x
        child.y = padding_top + y
      end

      # Make us as wrap around the largest child.
      rect.width = (@children.map {|c| c.width }.max || 0) + padding_left + padding_right
      rect.height = (@children.map {|c| c.height }.max || 0) + padding_top + padding_bottom

      super
    end
1021040
public void clear () {
		minWidth = null;
		minHeight = null;
		prefWidth = null;
		prefHeight = null;
		maxWidth = null;
		maxHeight = null;
		spaceTop = null;
		spaceLeft = null;
		spaceBottom = null;
		spaceRight = null;
		padTop = null;
		padLeft = null;
		padBottom = null;
		padRight = null;
		fillX = null;
		fillY = null;
		align = null;
		expandX = null;
		expandY = null;
		ignore = null;
		colspan = null;
		uniformX = null;
		uniformY = null;
	}
710668
private void resetPadding() {
        int[] padding = new int[4];
        System.arraycopy(this.padding, 0, padding, 0, 4);
        switch (arrowSide) {
            case RIGHT_BOTTOM:
            case RIGHT_MIDDLE:
            case RIGHT_TOP:
                padding[2] += arrowHeight;
                break;
            case LEFT_BOTTOM:
            case LEFT_MIDDLE:
            case LEFT_TOP:
                padding[0] += arrowHeight;
                break;
            case TOP_MIDDLE:
            case TOP_LEFT:
            case TOP_RIGHT:
                padding[1] += arrowHeight;
                break;
            case BOTTOM_CENTER:
            case BOTTOM_LEFT:
            case BOTTOM_RIGHT:
                padding[3] += arrowHeight;
                break;
        }
        setPadding(padding[0], padding[1], padding[2], padding[3]);
    }