Bug 695222 - Implement column-fill part of CSS3 multicol spec. r=roc,dbaron

This commit is contained in:
Scott Johnson 2011-12-19 23:11:54 -06:00
Родитель 44f74a5432
Коммит 35fbd86079
43 изменённых файлов: 194 добавлений и 11 удалений

Просмотреть файл

@ -51,7 +51,7 @@
* http://www.w3.org/TR/DOM-Level-2-Style
*/
[builtinclass, scriptable, uuid(0a6fc4c6-a62a-4f52-9ab6-3d398b958843)]
[builtinclass, scriptable, uuid(b4afb8f4-d9ab-44d9-9d0c-f765c47d57c2)]
interface nsIDOMCSS2Properties : nsISupports
{
attribute DOMString background;
@ -532,6 +532,9 @@ interface nsIDOMCSS2Properties : nsISupports
attribute DOMString MozColumnWidth;
// raises(DOMException) on setting
attribute DOMString MozColumnFill;
// raises(DOMException) on setting
attribute DOMString MozColumnGap;
// raises(DOMException) on setting

Просмотреть файл

@ -789,6 +789,9 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_COLUMN_COUNT_AUTO 0
#define NS_STYLE_COLUMN_COUNT_UNLIMITED (-1)
#define NS_STYLE_COLUMN_FILL_AUTO 0
#define NS_STYLE_COLUMN_FILL_BALANCE 1
// See nsStyleUIReset
#define NS_STYLE_IME_MODE_AUTO 0
#define NS_STYLE_IME_MODE_NORMAL 1

Просмотреть файл

@ -17,6 +17,7 @@ body {
width: 300px;
-moz-column-width: 50px;
-moz-column-gap: 1px;
-moz-column-fill: auto;
}
</style>

Просмотреть файл

@ -13,7 +13,7 @@
}
</script>
</head>
<body style="-moz-column-width: 1px;" onload="boom();">
<body style="-moz-column-width: 1px; -moz-column-fill: auto;" onload="boom();">
<hr size="100" color="blue"><div style="position: absolute;"></div><div id="x" style="height: 5px;"></div>
</body>
</html>

Просмотреть файл

@ -416,18 +416,22 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
expectedWidthLeftOver = extraSpace - (extraToColumns*numColumns);
}
// NOTE that the non-balancing behavior for non-auto computed height
// is not in the CSS3 columns draft as of 18 January 2001
if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
// If column-fill is set to 'balance', then we want to balance the columns.
if (colStyle->mColumnFill == NS_STYLE_COLUMN_FILL_BALANCE) {
// Balancing!
if (numColumns <= 0) {
// Hmm, auto column count, column width or available width is unknown,
// and balancing is required. Let's just use one column then.
numColumns = 1;
}
colHeight = NS_MIN(mLastBalanceHeight, GetAvailableContentHeight(aReflowState));
colHeight = NS_MIN(mLastBalanceHeight,
GetAvailableContentHeight(aReflowState));
} else {
// This is the case when the column-fill property is set to 'auto'.
// No balancing, so don't limit the column count
numColumns = PR_INT32_MAX;
}

Просмотреть файл

@ -5,7 +5,7 @@
</head>
<body>
<div style="-moz-column-count: 2; column-count: 2; height: 3.5em; background:yellow">
<div style="-moz-column-count: 2; column-count: 2; -moz-column-fill: auto; height: 3.5em; background:yellow">
<div style="margin: 7px 1% 2px 2em; border: medium dotted; border-width: 2px 3px 4px 5px;">
<div style="background: url(repeatable-diagonal-gradient.png);">

Просмотреть файл

@ -5,7 +5,7 @@
</head>
<body>
<div style="-moz-column-count: 2; column-count: 2; height: 3.5em; background:yellow">
<div style="-moz-column-count: 2; column-count: 2; -moz-column-fill: auto; height: 3.5em; background:yellow">
<div>
<div style="background: url(repeatable-diagonal-gradient.png); background-clip: padding-box; background-clip: padding; background-origin: padding-box; background-origin: padding; margin: 7px 1% 2px 2em; border: medium dotted; border-width: 2px 3px 4px 5px; padding: 8px 6px 4px 2px;">

Просмотреть файл

@ -41,6 +41,7 @@
width: 300pt;
-moz-column-width: 100pt;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid gray;
position: relative;
}

Просмотреть файл

@ -48,6 +48,7 @@
width: 300pt;
-moz-column-width: 100pt;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid gray;
}
</style>

Просмотреть файл

@ -48,6 +48,7 @@
width: 300pt;
-moz-column-width: 100pt;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid gray;
}
</style>

Просмотреть файл

@ -1,6 +1,6 @@
<!DOCTYPE HTML>
<title>Test for pushing of floats to next column when float breaking in columns is disabled</title>
<body style="-moz-column-width: 200px; margin: 0; -moz-column-gap: 0; height: 200px;">
<body style="-moz-column-width: 200px; -moz-column-fill: auto; margin: 0; -moz-column-gap: 0; height: 200px;">
<div style="float: left;">
<div style="display: inline-block; vertical-align: top; height: 150px; width: 200px; background: yellow"></div>
</div>

Просмотреть файл

@ -1,6 +1,6 @@
<!DOCTYPE HTML>
<title>Test for pushing of floats to next column when float breaking in columns is disabled</title>
<body style="-moz-column-width: 200px; margin: 0; -moz-column-gap: 0; height: 200px;">
<body style="-moz-column-width: 200px; margin: 0; -moz-column-fill: auto; -moz-column-gap: 0; height: 200px;">
<div style="float: left;">
<div style="display: inline-block; vertical-align: top; height: 150px; width: 200px; background: yellow"></div>
</div>

Просмотреть файл

@ -0,0 +1,4 @@
@font-face {
font-family: "Ahem";
src: url(../fonts/Ahem.ttf);
}

Просмотреть файл

@ -0,0 +1,33 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="ahem.css" />
<style>
td.text {
width: 33.33%;
text-align: left;
font-family: ahem;
padding-right: 1px;
font-size: 12pt;
line-height: 1.1;
}
table {
width: 100%;
font-family: ahem;
font-size: 12pt;
line-height: 1.1;
}
</style>
</head>
<body>
<table cellpadding=0 cellspacing=0>
<tr>
<td class="text" valign="top">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat libero vel diam.</td>
<td class="text" valign="top">Pellentesque pulvinar commodo lacus. Sed fringilla. Sed lectus. Praesent laoreet orci</td>
<td valign="top">vitae nisi. Duis venenatis tristique massa. Sed commodo diam at mauris.</td>
</tr>
</table>
</body>

Просмотреть файл

@ -0,0 +1,17 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="ahem.css" />
</head>
<body>
<div style="-moz-column-count: 3;
-moz-column-gap: 0px;
-moz-column-fill: auto;
height: 120px;
font-family: ahem;
font-size: 12pt;
line-height: 1.1;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat libero vel diam. Pellentesque pulvinar commodo lacus. Sed fringilla. Sed lectus. Praesent laoreet orci vitae nisi. Duis venenatis tristique massa. Sed commodo diam at mauris.
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,33 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="ahem.css" />
<style>
td {
width: 200px;
font-family: ahem;
}
table {
width: 100%;
height: 100px;
padding-bottom: 0;
margin-bottom: 0;
font-family: ahem;
}
</style>
</head>
<body>
<table cellpadding=0 cellspacing=0>
<tr>
<td valign="top">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat libero vel diam.
</td>
<td valign="top">Pellentesque pulvinar commodo lacus. Sed fringilla. Sed lectus. Praesent laoreet orci
</td>
<td valign="top">vitae nisi. Duis venenatis tristique massa. Sed commodo diam at mauris.
</td>
</tr>
</table>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="ahem.css" />
</head>
<body>
<div style="-moz-column-width: 200px;
-moz-column-gap: 0px;
-moz-column-fill: balance;
height: 100px;
margin-bottom: 0;
padding-bottom: 0;
font-family: ahem;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat libero vel diam. Pellentesque pulvinar commodo lacus. Sed fringilla. Sed lectus. Praesent laoreet orci vitae nisi. Duis venenatis tristique massa. Sed commodo diam at mauris.
</div>
</body>
</html>

Просмотреть файл

@ -16,6 +16,9 @@
== column-balancing-002.html column-balancing-002.ref.html
== column-balancing-003.html column-balancing-000.ref.html
== column-balancing-004.html column-balancing-004.ref.html
HTTP(..) == columnfill-balance.html columnfill-balance-ref.html
HTTP(..) == columnfill-auto.html columnfill-auto-ref.html
HTTP(..) == columnfill-change.html columnfill-change-ref.html
== columnrule-basic.html columnrule-basic-ref.html
== columnrule-complex.html columnrule-complex-ref.html
!= columnrule-linestyles.html columnrule-linestyles-notref.html

Просмотреть файл

@ -34,6 +34,7 @@
height: 2in;
-moz-column-count: 3;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: silver 2pt;
border-style: none solid;
}

Просмотреть файл

@ -25,6 +25,7 @@
width: 300px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid silver;
border-style: none solid;
}

Просмотреть файл

@ -20,6 +20,7 @@
width: 300px;
-moz-column-width: 100px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid silver;
border-style: none solid;
background: yellow;

Просмотреть файл

@ -49,6 +49,7 @@
width: 300px;
-moz-column-width: 100px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid silver;
border-style: none solid;
}

Просмотреть файл

@ -16,6 +16,7 @@
width: 300px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid silver;
}
</style>

Просмотреть файл

@ -17,6 +17,7 @@
width: 300px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid silver;
}
</style>

Просмотреть файл

@ -20,6 +20,7 @@
width: 300px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: solid silver;
}
</style>

Просмотреть файл

@ -13,6 +13,7 @@
width: 450px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: 3px solid silver;
}

Просмотреть файл

@ -13,6 +13,7 @@
width: 450px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: 3px solid silver;
}

Просмотреть файл

@ -13,6 +13,7 @@
width: 450px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: 3px solid silver;
}

Просмотреть файл

@ -13,6 +13,7 @@
width: 450px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: 3px solid silver;
}

Просмотреть файл

@ -13,6 +13,7 @@
width: 450px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: 3px solid silver;
}

Просмотреть файл

@ -13,6 +13,7 @@
width: 450px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: 3px solid silver;
}

Просмотреть файл

@ -13,6 +13,7 @@
width: 450px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: 3px solid silver;
}

Просмотреть файл

@ -13,6 +13,7 @@
width: 450px;
-moz-column-width: 150px;
-moz-column-gap: 0;
-moz-column-fill: auto;
border: 3px solid silver;
}

Просмотреть файл

@ -198,6 +198,7 @@ CSS_KEY(auto, auto)
CSS_KEY(avoid, avoid)
CSS_KEY(background, background)
CSS_KEY(backwards, backwards)
CSS_KEY(balance, balance)
CSS_KEY(baseline, baseline)
CSS_KEY(bidi-override, bidi_override)
CSS_KEY(blink, blink)

Просмотреть файл

@ -1256,6 +1256,15 @@ CSS_PROP_COLUMN(
nsnull,
offsetof(nsStyleColumn, mColumnCount),
eStyleAnimType_Custom)
CSS_PROP_COLUMN(
-moz-column-fill,
_moz_column_fill,
CSS_PROP_DOMPROP_PREFIXED(ColumnFill),
CSS_PROPERTY_PARSE_VALUE,
VARIANT_HK,
kColumnFillKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_COLUMN(
-moz-column-width,
_moz_column_width,

Просмотреть файл

@ -1468,6 +1468,12 @@ const PRInt32 nsCSSProps::kColorInterpolationKTable[] = {
eCSSKeyword_UNKNOWN, -1
};
const PRInt32 nsCSSProps::kColumnFillKTable[] = {
eCSSKeyword_auto, NS_STYLE_COLUMN_FILL_AUTO,
eCSSKeyword_balance, NS_STYLE_COLUMN_FILL_BALANCE,
eCSSKeyword_UNKNOWN, -1
};
bool
nsCSSProps::FindKeyword(nsCSSKeyword aKeyword, const PRInt32 aTable[], PRInt32& aResult)
{

Просмотреть файл

@ -359,6 +359,7 @@ public:
static const PRInt32 kTextAnchorKTable[];
static const PRInt32 kTextRenderingKTable[];
static const PRInt32 kColorInterpolationKTable[];
static const PRInt32 kColumnFillKTable[];
static const PRInt32 kBoxPropSourceKTable[];
static const PRInt32 kBoxShadowTypeKTable[];
static const PRInt32 kBoxSizingKTable[];

Просмотреть файл

@ -740,6 +740,16 @@ nsComputedDOMStyle::DoGetColumnGap()
return val;
}
nsIDOMCSSValue*
nsComputedDOMStyle::DoGetColumnFill()
{
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(GetStyleColumn()->mColumnFill,
nsCSSProps::kColumnFillKTable));
return val;
}
nsIDOMCSSValue*
nsComputedDOMStyle::DoGetColumnRuleWidth()
{
@ -4570,6 +4580,7 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
COMPUTED_STYLE_MAP_ENTRY(box_pack, BoxPack),
COMPUTED_STYLE_MAP_ENTRY(box_sizing, BoxSizing),
COMPUTED_STYLE_MAP_ENTRY(_moz_column_count, ColumnCount),
COMPUTED_STYLE_MAP_ENTRY(_moz_column_fill, ColumnFill),
COMPUTED_STYLE_MAP_ENTRY(_moz_column_gap, ColumnGap),
//// COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule, ColumnRule),
COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_color, ColumnRuleColor),

Просмотреть файл

@ -365,6 +365,7 @@ private:
/* Column properties */
nsIDOMCSSValue* DoGetColumnCount();
nsIDOMCSSValue* DoGetColumnFill();
nsIDOMCSSValue* DoGetColumnWidth();
nsIDOMCSSValue* DoGetColumnGap();
nsIDOMCSSValue* DoGetColumnRuleWidth();

Просмотреть файл

@ -6496,6 +6496,13 @@ nsRuleNode::ComputeColumnData(void* aStartStruct,
column->mColumnRuleColorIsForeground = false;
}
// column-fill: enum
SetDiscrete(*aRuleData->ValueForColumnFill(),
column->mColumnFill, canStoreInRuleTree,
SETDSC_ENUMERATED, parent->mColumnFill,
NS_STYLE_COLUMN_FILL_BALANCE,
0, 0, 0, 0);
COMPUTE_END_RESET(Column, column)
}

Просмотреть файл

@ -776,6 +776,7 @@ nsStyleColumn::nsStyleColumn(nsPresContext* aPresContext)
mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO;
mColumnWidth.SetAutoValue();
mColumnGap.SetNormalValue();
mColumnFill = NS_STYLE_COLUMN_FILL_BALANCE;
mColumnRuleWidth = (aPresContext->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
mColumnRuleStyle = NS_STYLE_BORDER_STYLE_NONE;
@ -807,7 +808,8 @@ nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
if (mColumnWidth != aOther.mColumnWidth ||
mColumnGap != aOther.mColumnGap)
mColumnGap != aOther.mColumnGap ||
mColumnFill != aOther.mColumnFill)
return NS_STYLE_HINT_REFLOW;
if (GetComputedColumnRuleWidth() != aOther.GetComputedColumnRuleWidth() ||

Просмотреть файл

@ -2085,6 +2085,8 @@ struct nsStyleColumn {
nscolor mColumnRuleColor; // [reset]
PRUint8 mColumnRuleStyle; // [reset]
PRUint8 mColumnFill; // [reset] see nsStyleConsts.h
// See https://bugzilla.mozilla.org/show_bug.cgi?id=271586#c43 for why
// this is hard to replace with 'currentColor'.
bool mColumnRuleColorIsForeground;

Просмотреть файл

@ -491,6 +491,14 @@ var gCSSProperties = {
// negative and zero invalid per editor's draft
invalid_values: [ "-1", "0", "3px" ]
},
"-moz-column-fill": {
domProp: "MozColumnFill",
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "balance" ],
other_values: [ "auto" ],
invalid_values: [ "2px", "dotted", "5em" ]
},
"-moz-column-gap": {
domProp: "MozColumnGap",
inherited: false,