Skip to content
Snippets Groups Projects
Commit 73e2871f authored by Tim Nguyen's avatar Tim Nguyen
Browse files

Bug 1525737 - Remove layout/xul/grid directory. r=emilio

parent eb259473
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 2166 deletions
......@@ -34,8 +34,6 @@ FRAME_CLASSES = [
Frame("nsIFrame", "None", NOT_LEAF),
Frame("nsGfxButtonControlFrame", "GfxButtonControl", LEAF),
Frame("nsGridContainerFrame", "GridContainer", NOT_LEAF),
Frame("nsGridRowGroupFrame", "Box", NOT_LEAF),
Frame("nsGridRowLeafFrame", "Box", NOT_LEAF),
Frame("nsHTMLButtonControlFrame", "HTMLButtonControl", NOT_LEAF),
Frame("nsHTMLCanvasFrame", "HTMLCanvas", NOT_LEAF),
Frame("nsHTMLFramesetBlankFrame", "None", LEAF),
......
......@@ -419,9 +419,6 @@ skip-if(Android) include xul/reftest.list
# xul (no XUL theme on Android)
skip-if(Android) include ../xul/reftest/reftest.list
# xul grid (no XUL theme on Android)
skip-if(Android) include ../xul/grid/reftests/reftest.list
# -webkit-box & associated properties (mapped to modern flexbox)
include webkit-box/reftest.list
......
......@@ -18,7 +18,6 @@ reftest.jar:
content/text-shadow (../../reftests/text-shadow/*)
content/xul-document-load (../../reftests/xul-document-load/*)
content/xul (../../reftests/xul/*)
content/grid (../../xul/grid/reftests/*)
content/xul/reftest (../../xul/reftest/*)
content/fonts/fira (../../reftests/fonts/fira/*)
content/fonts/sil (../../reftests/fonts/sil/*)
......@@ -38,7 +37,6 @@ reftest.jar:
content/crashtests/layout/base/crashtests (../../../layout/base/crashtests/*)
content/crashtests/layout/xul/tree/crashtests (../../../layout/xul/tree/crashtests/*)
content/crashtests/layout/xul/crashtests (../../../layout/xul/crashtests/*)
content/crashtests/layout/xul/grid/crashtests (../../../layout/xul/grid/crashtests/*)
content/crashtests/layout/generic/crashtests (../../../layout/generic/crashtests/*)
content/crashtests/layout/style/crashtests (../../../layout/style/crashtests/*)
content/crashtests/gfx/tests/crashtests (../../../gfx/tests/crashtests/*)
......
<?xml version="1.0"?>
<!DOCTYPE window>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<tabbox>
<tabs>
<tab label="full grid" />
<tab label="grid alone" />
<tab label="columns alone" />
<tab label="rows alone" />
<tab label="column alone" />
<tab label="row alone" />
<tab label="wacky" />
</tabs>
<tabpanels>
<tabpanel>
<grid>
<rows style="color: blue">
<row>
<label value="row 1,1" />
<label value="row 1,2" />
</row>
<row>
<label value="row 2,1" />
<label value="row 2,2" />
</row>
</rows>
<columns style="color: fuchsia; opacity: 0.7">
<column>
<label value="column 1,1" />
<label value="column 1,2" />
</column>
<column>
<label value="column 2,1" />
<label value="column 2,2" />
</column>
</columns>
</grid>
</tabpanel>
<tabpanel>
<grid>
<label value="Text inside grid" />
</grid>
</tabpanel>
<tabpanel>
<columns>
<label value="Text inside columns" />
</columns>
</tabpanel>
<tabpanel>
<rows>
<label value="Text inside rows" />
</rows>
</tabpanel>
<tabpanel>
<column>
<label value="Text inside column" />
</column>
</tabpanel>
<tabpanel>
<row>
<label value="Text inside row" />
</row>
</tabpanel>
<tabpanel>
<grid>
<label value="Text inside grid one" />
<rows style="color: blue">
<label value="Text inside rows #1" />
<row>
<label value="row 1,1" />
<label value="row 1,2" />
</row>
<label value="Text inside rows #2" />
<row>
<label value="row 2,1" />
<label value="row 2,2" />
</row>
<label value="Text inside rows #3" />
</rows>
<label value="Text inside grid two" style="opacity: 0.7" />
<columns style="color: fuchsia; opacity: 0.7">
<label value="Text inside columns #1" />
<column>
<label value="column 1,1" />
<label value="column 1,2" />
</column>
<label value="Text inside columns #2" />
<column>
<label value="column 2,1" />
<label value="column 2,2" />
</column>
<label value="Text inside columns #3" />
</columns>
<label value="Text inside grid three" style="opacity: 0.4" />
</grid>
</tabpanel>
</tabpanels>
</tabbox>
</window>
<?xml version="1.0"?>
<!-- vim:sw=4:ts=4:noet:
-->
<!DOCTYPE window>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<tabbox>
<tabs>
<tab label="no group" />
<tab label="wacky orientations" />
</tabs>
<tabpanels>
<tabpanel>
<grid>
<row>
<label value="row 1,1" />
<label value="row 1,2" />
</row>
<row>
<label value="row 2,1" />
<label value="row 2,2" />
</row>
<column>
<label value="column 1,1" />
<label value="column 1,2" />
</column>
<column>
<label value="column 2,1" />
<label value="column 2,2" />
</column>
</grid>
</tabpanel>
<tabpanel>
<grid>
<rows style="color: green">
<row>
<label value="rows+row 1" />
<label value="rows+row 2" />
</row>
<column>
<label value="rows+column 1" />
<label value="rows+column 2" />
</column>
<rows style="color: purple">
<row>
<label value="rows+rows+row 1" />
<label value="rows+rows+row 2" />
</row>
<column>
<label value="rows+rows+column 1" />
<label value="rows+rows+column 2" />
</column>
</rows>
<columns style="color: blue">
<row>
<label value="rows+columns+row 1" />
<label value="rows+columns+row 2" />
</row>
<column>
<label value="rows+columns+column 1" />
<label value="rows+columns+column 2" />
</column>
</columns>
</rows>
<columns style="opacity: 0.7; color: lime">
<row>
<label value="columns+row 1" />
<label value="columns+row 2" />
</row>
<column>
<label value="columns+column 1" />
<label value="columns+column 2" />
</column>
<rows style="color: fuchsia">
<row>
<label value="columns+rows+row 1" />
<label value="columns+rows+row 2" />
</row>
<column>
<label value="columns+rows+column 1" />
<label value="columns+rows+column 2" />
</column>
</rows>
<columns style="color: aqua">
<row>
<label value="columns+columns+row 1" />
<label value="columns+columns+row 2" />
</row>
<column>
<label value="columns+columns+column 1" />
<label value="columns+columns+column 2" />
</column>
</columns>
</columns>
</grid>
</tabpanel>
</tabpanels>
</tabbox>
</window>
<window title="Testcase bug 311710 - Evil xul testcase, using display:-moz-grid-group causes crash [@ nsGridRow::IsCollapsed]"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/x-javascript">
function clickit() {
var button = document.getElementById('button');
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
button.dispatchEvent(evt);
}
window.addEventListener('load', clickit, false);
</script>
<grid>
<rows>
<row>
<separator/>
</row>
</rows>
</grid>
<button id="button" onclick="document.getElementsByTagName('row')[0].style.display='-moz-grid-group'" label="Mozilla should not crash, when clicking this button"/>
</window>
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-JavaScript">
function crash() {
document.getElementById("test").style.display = "none";
}
function clickit() {
var button = document.getElementById('button');
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
button.dispatchEvent(evt);
}
window.onload = clickit;
</script>
<grid>
<columns>
<column/>
</columns>
<rows id="test">
<row><button label="placeholder"/></row>
</rows>
</grid>
<button id="button" label="Crash me" onclick="crash()"/>
</window>
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<window title="Testcase bug - Crash with evil xul testcase, using -moz-grid/table-caption"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<grid flex="1">
<columns>
<column flex="1"/>
</columns>
<rows>
<row>
</row>
</rows>
</grid>
<html:script>
function doe(){
document.getElementsByTagName('columns')[0].style.display='table-caption';
setTimeout(doe2,20);
}
function doe2(){
document.getElementsByTagName('columns')[0].style.display='-moz-grid';
}
function clickit() {
var button = document.getElementById('button');
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
button.dispatchEvent(evt);
setTimeout('clickit();', 20);
}
window.addEventListener('load', clickit, false);
</html:script>
<html:button id="button" onclick="doe()" label="click">Clicking this should not crash Mozilla</html:button>
</window>
<html class="reftest-wait">
<head>
<script>
setTimeout('document.documentElement.className = ""', 500);
</script>
<body>
<iframe src="313173-1-inner.xhtml"></iframe>
</body>
</html>
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<grid>
<rows>
<column/>
</rows>
</grid>
</window>
<?xml version="1.0"?>
<window xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<grid>
<columns>
<column id="col1" flex="1"/>
<column id="col2" flex="1"/>
<column id="col3" flex="P-2"/>
</columns>
</grid>
</window>
load chrome://reftest/content/crashtests/layout/xul/grid/crashtests/306911-grid-testcases.xhtml
load chrome://reftest/content/crashtests/layout/xul/grid/crashtests/306911-grid-testcases2.xhtml
load chrome://reftest/content/crashtests/layout/xul/grid/crashtests/311710-1.xhtml
load chrome://reftest/content/crashtests/layout/xul/grid/crashtests/312784-1.xhtml
load 313173-1.html
load chrome://reftest/content/crashtests/layout/xul/grid/crashtests/321066-1.xhtml
load chrome://reftest/content/crashtests/layout/xul/grid/crashtests/423802-crash.xhtml
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files("**"):
BUG_COMPONENT = ("Core", "XUL")
EXPORTS += [
"nsGrid.h",
"nsGridCell.h",
"nsGridLayout2.h",
"nsGridRow.h",
"nsGridRowGroupLayout.h",
"nsGridRowLayout.h",
"nsGridRowLeafFrame.h",
"nsGridRowLeafLayout.h",
"nsIGridPart.h",
]
UNIFIED_SOURCES += [
"nsGrid.cpp",
"nsGridCell.cpp",
"nsGridLayout2.cpp",
"nsGridRow.cpp",
"nsGridRowGroupFrame.cpp",
"nsGridRowGroupLayout.cpp",
"nsGridRowLayout.cpp",
"nsGridRowLeafFrame.cpp",
"nsGridRowLeafLayout.cpp",
]
FINAL_LIBRARY = "xul"
LOCAL_INCLUDES += [
"..",
"../../forms",
"../../generic",
"../../style",
]
if CONFIG["CC_TYPE"] in ("clang", "gcc"):
CXXFLAGS += ["-Wno-error=shadow"]
This diff is collapsed.
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsGrid_h___
#define nsGrid_h___
#include "nsStackLayout.h"
#include "nsIGridPart.h"
#include "nsCOMPtr.h"
#include "mozilla/UniquePtr.h"
class nsBoxLayoutState;
class nsGridCell;
//#define DEBUG_grid 1
/**
* The grid data structure, i.e., the grid cellmap.
*/
class nsGrid {
public:
nsGrid();
~nsGrid();
nsGridRow* GetColumnAt(int32_t aIndex, bool aIsHorizontal = true);
nsGridRow* GetRowAt(int32_t aIndex, bool aIsHorizontal = true);
nsGridCell* GetCellAt(int32_t aX, int32_t aY);
void NeedsRebuild(nsBoxLayoutState& aBoxLayoutState);
void RebuildIfNeeded();
// For all the methods taking an aIsHorizontal parameter:
// * When aIsHorizontal is true, the words "rows" and (for
// GetColumnCount) "columns" refer to their normal meanings.
// * When aIsHorizontal is false, the meanings are flipped.
// FIXME: Maybe eliminate GetColumnCount and change aIsHorizontal to
// aIsRows? (Calling it horizontal doesn't really make sense because
// row groups and columns have vertical orientation, whereas column
// groups and rows are horizontal.)
nsSize GetPrefRowSize(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex,
bool aIsHorizontal = true);
nsSize GetMinRowSize(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex,
bool aIsHorizontal = true);
nsSize GetMaxRowSize(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex,
bool aIsHorizontal = true);
nscoord GetRowFlex(int32_t aRowIndex, bool aIsHorizontal = true);
nscoord GetPrefRowHeight(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex,
bool aIsHorizontal = true);
nscoord GetMinRowHeight(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex,
bool aIsHorizontal = true);
nscoord GetMaxRowHeight(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex,
bool aIsHorizontal = true);
void GetRowOffsets(int32_t aIndex, nscoord& aTop, nscoord& aBottom,
bool aIsHorizontal = true);
void RowAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, int32_t aIndex,
bool aIsHorizontal = true);
void CellAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, int32_t aIndex,
bool aIsHorizontal = true);
void DirtyRows(nsIFrame* aRowBox, nsBoxLayoutState& aState);
#ifdef DEBUG_grid
void PrintCellMap();
#endif
int32_t GetExtraColumnCount(bool aIsHorizontal = true);
int32_t GetExtraRowCount(bool aIsHorizontal = true);
// accessors
void SetBox(nsIFrame* aBox) { mBox = aBox; }
nsIFrame* GetBox() { return mBox; }
nsIFrame* GetRowsBox() { return mRowsBox; }
nsIFrame* GetColumnsBox() { return mColumnsBox; }
int32_t GetRowCount(int32_t aIsHorizontal = true);
int32_t GetColumnCount(int32_t aIsHorizontal = true);
static nsIFrame* GetScrolledBox(nsIFrame* aChild);
static nsIFrame* GetScrollBox(nsIFrame* aChild);
static nsIGridPart* GetPartFromBox(nsIFrame* aBox);
void GetFirstAndLastRow(int32_t& aFirstIndex, int32_t& aLastIndex,
nsGridRow*& aFirstRow, nsGridRow*& aLastRow,
bool aIsHorizontal);
private:
nsMargin GetBoxTotalMargin(nsIFrame* aBox, bool aIsHorizontal = true);
void FreeMap();
void FindRowsAndColumns(nsIFrame** aRows, nsIFrame** aColumns);
mozilla::UniquePtr<nsGridRow[]> BuildRows(nsIFrame* aBox, int32_t aSize,
bool aIsHorizontal = true);
mozilla::UniquePtr<nsGridCell[]> BuildCellMap(int32_t aRows,
int32_t aColumns);
void PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, int32_t aRowCount,
int32_t aColumnCount, bool aIsHorizontal = true);
void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount,
int32_t& aComputedColumnCount);
void SetLargestSize(nsSize& aSize, nscoord aHeight,
bool aIsHorizontal = true);
void SetSmallestSize(nsSize& aSize, nscoord aHeight,
bool aIsHorizontal = true);
bool IsGrid(nsIFrame* aBox);
// the box that implement the <grid> tag
nsIFrame* mBox;
// an array of row object
mozilla::UniquePtr<nsGridRow[]> mRows;
// an array of columns objects.
mozilla::UniquePtr<nsGridRow[]> mColumns;
// the first in the <grid> that implements the <rows> tag.
nsIFrame* mRowsBox;
// the first in the <grid> that implements the <columns> tag.
nsIFrame* mColumnsBox;
// a flag that is false tells us to rebuild the who grid
bool mNeedsRebuild;
// number of rows and columns as defined by the XUL
int32_t mRowCount;
int32_t mColumnCount;
// number of rows and columns that are implied but not
// explicitly defined int he XUL
int32_t mExtraRowCount;
int32_t mExtraColumnCount;
// x,y array of cells in the rows and columns
mozilla::UniquePtr<nsGridCell[]> mCellMap;
// a flag that when true suppresses all other MarkDirties. This
// prevents lots of extra work being done.
bool mMarkingDirty;
};
#endif
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsGridCell.h"
#include "nsIFrame.h"
#include "nsGridLayout2.h"
nsGridCell::nsGridCell() : mBoxInColumn(nullptr), mBoxInRow(nullptr) {
MOZ_COUNT_CTOR(nsGridCell);
}
nsGridCell::~nsGridCell() { MOZ_COUNT_DTOR(nsGridCell); }
nsSize nsGridCell::GetXULPrefSize(nsBoxLayoutState& aState) {
nsSize sum(0, 0);
// take our 2 children and add them up.
// we are as wide as the widest child plus its left offset
// we are tall as the tallest child plus its top offset
if (mBoxInColumn) {
nsSize pref = mBoxInColumn->GetXULPrefSize(aState);
nsIFrame::AddXULMargin(mBoxInColumn, pref);
nsBoxLayout::AddLargestSize(sum, pref);
}
if (mBoxInRow) {
nsSize pref = mBoxInRow->GetXULPrefSize(aState);
nsIFrame::AddXULMargin(mBoxInRow, pref);
nsBoxLayout::AddLargestSize(sum, pref);
}
return sum;
}
nsSize nsGridCell::GetXULMinSize(nsBoxLayoutState& aState) {
nsSize sum(0, 0);
// take our 2 children and add them up.
// we are as wide as the widest child plus its left offset
// we are tall as the tallest child plus its top offset
if (mBoxInColumn) {
nsSize min = mBoxInColumn->GetXULMinSize(aState);
nsIFrame::AddXULMargin(mBoxInColumn, min);
nsBoxLayout::AddLargestSize(sum, min);
}
if (mBoxInRow) {
nsSize min = mBoxInRow->GetXULMinSize(aState);
nsIFrame::AddXULMargin(mBoxInRow, min);
nsBoxLayout::AddLargestSize(sum, min);
}
return sum;
}
nsSize nsGridCell::GetXULMaxSize(nsBoxLayoutState& aState) {
nsSize sum(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
// take our 2 children and add them up.
// we are as wide as the smallest child plus its left offset
// we are tall as the shortest child plus its top offset
if (mBoxInColumn) {
nsSize max = mBoxInColumn->GetXULMaxSize(aState);
nsIFrame::AddXULMargin(mBoxInColumn, max);
nsBoxLayout::AddSmallestSize(sum, max);
}
if (mBoxInRow) {
nsSize max = mBoxInRow->GetXULMaxSize(aState);
nsIFrame::AddXULMargin(mBoxInRow, max);
nsBoxLayout::AddSmallestSize(sum, max);
}
return sum;
}
bool nsGridCell::IsXULCollapsed() {
return ((mBoxInColumn && mBoxInColumn->IsXULCollapsed()) ||
(mBoxInRow && mBoxInRow->IsXULCollapsed()));
}
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
Author:
Eric D Vaughan
**/
#ifndef nsGridCell_h___
#define nsGridCell_h___
#include "mozilla/Attributes.h"
class nsBoxLayoutState;
struct nsSize;
class nsIFrame;
/*
* Grid cell is what makes up the cellmap in the grid. Each GridCell contains
* 2 pointers. One to the matching box in the columns and one to the matching
* box in the rows. Remember that you can put content in both rows and columns.
* When asked for preferred/min/max sizes it works like a stack and takes the
* biggest sizes.
*/
class nsGridCell final {
public:
nsGridCell();
~nsGridCell();
nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState);
nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState);
nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState);
bool IsXULCollapsed();
// accessors
nsIFrame* GetBoxInColumn() { return mBoxInColumn; }
nsIFrame* GetBoxInRow() { return mBoxInRow; }
void SetBoxInRow(nsIFrame* aBox) { mBoxInRow = aBox; }
void SetBoxInColumn(nsIFrame* aBox) { mBoxInColumn = aBox; }
private:
nsIFrame* mBoxInColumn;
nsIFrame* mBoxInRow;
};
#endif
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsGridLayout2.h"
#include "nsGridRowGroupLayout.h"
#include "nsGridRow.h"
#include "nsIScrollableFrame.h"
#include "nsSprocketLayout.h"
#include "mozilla/ReflowInput.h"
nsresult NS_NewGridLayout2(nsBoxLayout** aNewLayout) {
*aNewLayout = new nsGridLayout2();
NS_IF_ADDREF(*aNewLayout);
return NS_OK;
}
NS_IMETHODIMP
nsGridLayout2::XULLayout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) {
// XXX This should be set a better way!
mGrid.SetBox(aBox);
NS_ASSERTION(aBox->GetXULLayoutManager() == this, "setting incorrect box");
nsresult rv = nsStackLayout::XULLayout(aBox, aBoxLayoutState);
#ifdef DEBUG_grid
mGrid.PrintCellMap();
#endif
return rv;
}
void nsGridLayout2::IntrinsicISizesDirty(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) {
nsStackLayout::IntrinsicISizesDirty(aBox, aBoxLayoutState);
// XXXldb We really don't need to do all the work that NeedsRebuild
// does; we just need to mark intrinsic widths dirty on the
// (row/column)(s/-groups).
mGrid.NeedsRebuild(aBoxLayoutState);
}
nsGrid* nsGridLayout2::GetGrid(nsIFrame* aBox, int32_t* aIndex,
nsGridRowLayout* aRequestor) {
// XXX This should be set a better way!
mGrid.SetBox(aBox);
NS_ASSERTION(aBox->GetXULLayoutManager() == this, "setting incorrect box");
return &mGrid;
}
void nsGridLayout2::AddWidth(nsSize& aSize, nscoord aSize2,
bool aIsHorizontal) {
nscoord& size = GET_WIDTH(aSize, aIsHorizontal);
if (size != NS_UNCONSTRAINEDSIZE) {
if (aSize2 == NS_UNCONSTRAINEDSIZE)
size = NS_UNCONSTRAINEDSIZE;
else
size += aSize2;
}
}
nsSize nsGridLayout2::GetXULMinSize(nsIFrame* aBox, nsBoxLayoutState& aState) {
nsSize minSize = nsStackLayout::GetXULMinSize(aBox, aState);
// if there are no <rows> tags that will sum up our columns,
// sum up our columns here.
nsSize total(0, 0);
nsIFrame* rowsBox = mGrid.GetRowsBox();
nsIFrame* columnsBox = mGrid.GetColumnsBox();
if (!rowsBox || !columnsBox) {
if (!rowsBox) {
// max height is the sum of our rows
int32_t rows = mGrid.GetRowCount();
for (int32_t i = 0; i < rows; i++) {
nscoord height = mGrid.GetMinRowHeight(aState, i, true);
AddWidth(total, height, false); // AddHeight
}
}
if (!columnsBox) {
// max height is the sum of our rows
int32_t columns = mGrid.GetColumnCount();
for (int32_t i = 0; i < columns; i++) {
nscoord width = mGrid.GetMinRowHeight(aState, i, false);
AddWidth(total, width, true); // AddWidth
}
}
AddXULMargin(aBox, total);
AddLargestSize(minSize, total);
}
return minSize;
}
nsSize nsGridLayout2::GetXULPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState) {
nsSize pref = nsStackLayout::GetXULPrefSize(aBox, aState);
// if there are no <rows> tags that will sum up our columns,
// sum up our columns here.
nsSize total(0, 0);
nsIFrame* rowsBox = mGrid.GetRowsBox();
nsIFrame* columnsBox = mGrid.GetColumnsBox();
if (!rowsBox || !columnsBox) {
if (!rowsBox) {
// max height is the sum of our rows
int32_t rows = mGrid.GetRowCount();
for (int32_t i = 0; i < rows; i++) {
nscoord height = mGrid.GetPrefRowHeight(aState, i, true);
AddWidth(total, height, false); // AddHeight
}
}
if (!columnsBox) {
// max height is the sum of our rows
int32_t columns = mGrid.GetColumnCount();
for (int32_t i = 0; i < columns; i++) {
nscoord width = mGrid.GetPrefRowHeight(aState, i, false);
AddWidth(total, width, true); // AddWidth
}
}
AddXULMargin(aBox, total);
AddLargestSize(pref, total);
}
return pref;
}
nsSize nsGridLayout2::GetXULMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState) {
nsSize maxSize = nsStackLayout::GetXULMaxSize(aBox, aState);
// if there are no <rows> tags that will sum up our columns,
// sum up our columns here.
nsSize total(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
nsIFrame* rowsBox = mGrid.GetRowsBox();
nsIFrame* columnsBox = mGrid.GetColumnsBox();
if (!rowsBox || !columnsBox) {
if (!rowsBox) {
total.height = 0;
// max height is the sum of our rows
int32_t rows = mGrid.GetRowCount();
for (int32_t i = 0; i < rows; i++) {
nscoord height = mGrid.GetMaxRowHeight(aState, i, true);
AddWidth(total, height, false); // AddHeight
}
}
if (!columnsBox) {
total.width = 0;
// max height is the sum of our rows
int32_t columns = mGrid.GetColumnCount();
for (int32_t i = 0; i < columns; i++) {
nscoord width = mGrid.GetMaxRowHeight(aState, i, false);
AddWidth(total, width, true); // AddWidth
}
}
AddXULMargin(aBox, total);
AddSmallestSize(maxSize, total);
}
return maxSize;
}
int32_t nsGridLayout2::BuildRows(nsIFrame* aBox, nsGridRow* aRows) {
if (aBox) {
aRows[0].Init(aBox, true);
return 1;
}
return 0;
}
nsMargin nsGridLayout2::GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal) {
nsMargin margin(0, 0, 0, 0);
return margin;
}
void nsGridLayout2::ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
nsIFrame* aPrevBox,
const nsFrameList::Slice& aNewChildren) {
mGrid.NeedsRebuild(aState);
}
void nsGridLayout2::ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState,
const nsFrameList::Slice& aNewChildren) {
mGrid.NeedsRebuild(aState);
}
void nsGridLayout2::ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState,
nsIFrame* aChildList) {
mGrid.NeedsRebuild(aState);
}
void nsGridLayout2::ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState,
nsIFrame* aChildList) {
mGrid.NeedsRebuild(aState);
}
NS_IMPL_ADDREF_INHERITED(nsGridLayout2, nsStackLayout)
NS_IMPL_RELEASE_INHERITED(nsGridLayout2, nsStackLayout)
NS_INTERFACE_MAP_BEGIN(nsGridLayout2)
NS_INTERFACE_MAP_ENTRY(nsIGridPart)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIGridPart)
NS_INTERFACE_MAP_END_INHERITING(nsStackLayout)
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsGridLayout2_h___
#define nsGridLayout2_h___
#include "mozilla/Attributes.h"
#include "nsStackLayout.h"
#include "nsIGridPart.h"
#include "nsCoord.h"
#include "nsGrid.h"
class nsGridRowGroupLayout;
class nsGridRowLayout;
class nsGridRow;
class nsBoxLayoutState;
/**
* The nsBoxLayout implementation for a grid.
*/
class nsGridLayout2 final : public nsStackLayout, public nsIGridPart {
public:
friend nsresult NS_NewGridLayout2(nsBoxLayout** aNewLayout);
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD XULLayout(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual void IntrinsicISizesDirty(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual nsGridRowGroupLayout* CastToRowGroupLayout() override {
return nullptr;
}
virtual nsGridLayout2* CastToGridLayout() override { return this; }
virtual nsGrid* GetGrid(nsIFrame* aBox, int32_t* aIndex,
nsGridRowLayout* aRequestor = nullptr) override;
virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox,
nsIFrame** aParentBox) override {
MOZ_ASSERT_UNREACHABLE("Should not be called");
return nullptr;
}
virtual nsSize GetXULMinSize(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual nsSize GetXULMaxSize(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual nsSize GetXULPrefSize(nsIFrame* aBox,
nsBoxLayoutState& aBoxLayoutState) override;
virtual void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount,
int32_t& aComputedColumnCount) override {
aRowCount++;
}
virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState) override {}
virtual int32_t BuildRows(nsIFrame* aBox, nsGridRow* aRows) override;
virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal) override;
virtual Type GetType() override { return eGrid; }
virtual void ChildrenInserted(
nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aPrevBox,
const nsFrameList::Slice& aNewChildren) override;
virtual void ChildrenAppended(
nsIFrame* aBox, nsBoxLayoutState& aState,
const nsFrameList::Slice& aNewChildren) override;
virtual void ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState,
nsIFrame* aChildList) override;
virtual void ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState,
nsIFrame* aChildList) override;
virtual nsIGridPart* AsGridPart() override { return this; }
protected:
explicit nsGridLayout2() = default;
virtual ~nsGridLayout2() = default;
nsGrid mGrid;
private:
void AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal);
}; // class nsGridLayout2
#endif
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsGridRow.h"
#include "nsBoxLayoutState.h"
#include "nsIFrame.h"
nsGridRow::nsGridRow()
: mIsBogus(false),
mBox(nullptr),
mFlex(-1),
mPref(-1),
mMin(-1),
mMax(-1),
mTop(-1),
mBottom(-1),
mTopMargin(0),
mBottomMargin(0)
{
MOZ_COUNT_CTOR(nsGridRow);
}
void nsGridRow::Init(nsIFrame* aBox, bool aIsBogus) {
mBox = aBox;
mIsBogus = aIsBogus;
mFlex = -1;
mPref = -1;
mMin = -1;
mMax = -1;
mTop = -1;
mBottom = -1;
mTopMargin = 0;
mBottomMargin = 0;
}
nsGridRow::~nsGridRow() { MOZ_COUNT_DTOR(nsGridRow); }
bool nsGridRow::IsXULCollapsed() { return mBox && mBox->IsXULCollapsed(); }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment