Make nsBox more careful about accepting XUL attributes only on XUL elements. (Bug 102440) r=bzbarsky

This commit is contained in:
L. David Baron 2011-04-22 18:36:24 -07:00
parent 8d027dddb3
commit bf6088c149
20 changed files with 354 additions and 30 deletions

View File

@ -64,7 +64,7 @@
<children/>
<html:input anonid="input"
class="autocomplete-textbox urlbar-input textbox-input uri-element-right-align"
flex="1" allowevents="true"
allowevents="true"
xbl:inherits="tooltiptext=inputtooltiptext,onfocus,onblur,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey"/>
</xul:hbox>
<children includes="hbox"/>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test that XUL attributes are not supported on non-XUL elements</title>
<style type="text/css">
<![CDATA[
html, body {
display: -moz-box;
margin: 0; padding: 0;
width: 100%; height: 100%;
}
body > div {
display: -moz-box;
background: yellow;
-moz-box-flex: 1;
-moz-box-orient: horizontal;
}
div > div {
display: -moz-box;
-moz-box-flex: 1;
border: 1px solid blue;
}
]]>
</style>
</head>
<body>
<div>
<div>2</div>
<div>1</div>
<div>width</div>
<div>height</div>
<div>minwidth</div>
<div>minheight</div>
<div>maxwidth</div>
<div>maxheight</div>
<div>flex</div>
</div>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test that XUL attributes are not supported on non-XUL elements</title>
<style type="text/css">
<![CDATA[
html, body {
display: -moz-box;
margin: 0; padding: 0;
width: 100%; height: 100%;
}
body > div {
display: -moz-box;
background: yellow;
-moz-box-flex: 1;
-moz-box-orient: horizontal;
}
div > div {
display: -moz-box;
-moz-box-flex: 1;
border: 1px solid blue;
}
]]>
</style>
</head>
<body>
<div>
<div ordinal="2">2</div>
<div ordinal="1">1</div>
<div width="100">width</div>
<div height="100">height</div>
<div minwidth="100">minwidth</div>
<div minheight="100">minheight</div>
<div maxwidth="50">maxwidth</div>
<div maxheight="15">maxheight</div>
<div flex="100">flex</div>
</div>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test that XUL attributes are not supported on non-XUL elements</title>
<style type="text/css">
<![CDATA[
html, body {
display: -moz-box;
margin: 0; padding: 0;
width: 100%; height: 100%;
}
body > div {
display: -moz-box;
background: yellow;
-moz-box-flex: 1;
-moz-box-orient: vertical;
}
div > div {
display: -moz-box;
-moz-box-flex: 1;
border: 1px solid blue;
}
]]>
</style>
</head>
<body>
<div>
<div>2</div>
<div>1</div>
<div>width</div>
<div>height</div>
<div>minwidth</div>
<div>minheight</div>
<div>maxwidth</div>
<div>maxheight</div>
<div>flex</div>
</div>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test that XUL attributes are not supported on non-XUL elements</title>
<style type="text/css">
<![CDATA[
html, body {
display: -moz-box;
margin: 0; padding: 0;
width: 100%; height: 100%;
}
body > div {
display: -moz-box;
background: yellow;
-moz-box-flex: 1;
-moz-box-orient: vertical;
}
div > div {
display: -moz-box;
-moz-box-flex: 1;
border: 1px solid blue;
}
]]>
</style>
</head>
<body>
<div>
<div ordinal="2">2</div>
<div ordinal="1">1</div>
<div width="100">width</div>
<div height="100">height</div>
<div minwidth="100">minwidth</div>
<div minheight="100">minheight</div>
<div maxwidth="50">maxwidth</div>
<div maxheight="15">maxheight</div>
<div flex="100">flex</div>
</div>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test that XUL attributes are not supported on non-XUL elements</title>
<style type="text/css">
<![CDATA[
html, body {
display: -moz-box;
margin: 0; padding: 0;
width: 100%; height: 100%;
}
body > div {
display: -moz-box;
background: yellow;
-moz-box-flex: 1;
-moz-box-orient: horizontal;
}
]]>
</style>
</head>
<body>
<div>
<input type="text" value="2" />
<input type="text" value="1" />
<input type="text" value="width" />
<input type="text" value="height" />
<input type="text" value="minwidth" />
<input type="text" value="minheight" />
<input type="text" value="maxwidth" />
<input type="text" value="maxheight" />
<input type="text" value="flex" />
</div>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test that XUL attributes are not supported on non-XUL elements</title>
<style type="text/css">
<![CDATA[
html, body {
display: -moz-box;
margin: 0; padding: 0;
width: 100%; height: 100%;
}
body > div {
display: -moz-box;
background: yellow;
-moz-box-flex: 1;
-moz-box-orient: horizontal;
}
]]>
</style>
</head>
<body>
<div>
<input type="text" ordinal="2" value="2" />
<input type="text" ordinal="1" value="1" />
<input type="text" width="100" value="width" />
<input type="text" height="100" value="height" />
<input type="text" minwidth="100" value="minwidth" />
<input type="text" minheight="100" value="minheight" />
<input type="text" maxwidth="50" value="maxwidth" />
<input type="text" maxheight="15" value="maxheight" />
<input type="text" flex="100" value="flex" />
</div>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test that XUL attributes are not supported on non-XUL elements</title>
<style type="text/css">
<![CDATA[
html, body {
display: -moz-box;
margin: 0; padding: 0;
width: 100%; height: 100%;
}
body > div {
display: -moz-box;
background: yellow;
-moz-box-flex: 1;
-moz-box-orient: vertical;
}
]]>
</style>
</head>
<body>
<div>
<input type="text" value="2" />
<input type="text" value="1" />
<input type="text" value="width" />
<input type="text" value="height" />
<input type="text" value="minwidth" />
<input type="text" value="minheight" />
<input type="text" value="maxwidth" />
<input type="text" value="maxheight" />
<input type="text" value="flex" />
</div>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test that XUL attributes are not supported on non-XUL elements</title>
<style type="text/css">
<![CDATA[
html, body {
display: -moz-box;
margin: 0; padding: 0;
width: 100%; height: 100%;
}
body > div {
display: -moz-box;
background: yellow;
-moz-box-flex: 1;
-moz-box-orient: vertical;
}
]]>
</style>
</head>
<body>
<div>
<input type="text" ordinal="2" value="2" />
<input type="text" ordinal="1" value="1" />
<input type="text" width="100" value="width" />
<input type="text" height="100" value="height" />
<input type="text" minwidth="100" value="minwidth" />
<input type="text" minheight="100" value="minheight" />
<input type="text" maxwidth="50" value="maxwidth" />
<input type="text" maxheight="5" value="maxheight" />
<input type="text" flex="100" value="flex" />
</div>
</body>
</html>

View File

@ -0,0 +1,4 @@
== flexbox-attributes-no-box-horizontal.xhtml flexbox-attributes-no-box-horizontal-ref.xhtml
== flexbox-attributes-no-box-vertical.xhtml flexbox-attributes-no-box-vertical-ref.xhtml
== flexbox-attributes-no-input-horizontal.xhtml flexbox-attributes-no-input-horizontal-ref.xhtml
== flexbox-attributes-no-input-vertical.xhtml flexbox-attributes-no-input-vertical-ref.xhtml

View File

@ -134,6 +134,9 @@ skip-if(Android) include first-letter/reftest.list
# first-line/
include first-line/reftest.list
# flexbox/
include flexbox/reftest.list
# floats/
include floats/reftest.list

View File

@ -518,7 +518,7 @@ nsIFrame::GetOrdinal(nsBoxLayoutState& aState)
// When present, attribute value overrides CSS.
nsIContent* content = GetContent();
if (content) {
if (content && content->IsXUL()) {
PRInt32 error;
nsAutoString value;
@ -812,7 +812,7 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize,
// calc() with percentage is treated like '0' (unset)
nsIContent* content = aBox->GetContent();
if (content) {
if (content && content->IsXUL()) {
nsAutoString value;
PRInt32 error;
@ -875,7 +875,7 @@ nsIBox::AddCSSMaxSize(nsIBox* aBox, nsSize& aSize, PRBool &aWidthSet, PRBool &aH
// percentages and calc() with percentages are treated like 'none'
nsIContent* content = aBox->GetContent();
if (content) {
if (content && content->IsXUL()) {
nsAutoString value;
PRInt32 error;
@ -910,8 +910,11 @@ nsIBox::AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex)
PRBool flexSet = PR_FALSE;
// get the flexibility
aFlex = aBox->GetStyleXUL()->mBoxFlex;
// attribute value overrides CSS
nsIContent* content = aBox->GetContent();
if (content) {
if (content && content->IsXUL()) {
PRInt32 error;
nsAutoString value;
@ -921,15 +924,6 @@ nsIBox::AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex)
aFlex = value.ToInteger(&error);
flexSet = PR_TRUE;
}
else {
// No attribute value. Check CSS.
const nsStyleXUL* boxInfo = aBox->GetStyleXUL();
if (boxInfo->mBoxFlex > 0.0f) {
// The flex was defined in CSS.
aFlex = (nscoord)boxInfo->mBoxFlex;
flexSet = PR_TRUE;
}
}
}
if (aFlex < 0)
@ -937,7 +931,7 @@ nsIBox::AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex)
if (aFlex >= nscoord_MAX)
aFlex = nscoord_MAX - 1;
return flexSet;
return flexSet || aFlex > 0;
}
void

View File

@ -3,4 +3,5 @@
html|*.menulist-editable-input {
-moz-appearance: none !important;
background: transparent ! important;
-moz-box-flex: 1;
}

View File

@ -6,12 +6,14 @@ html|*.textbox-input {
text-align: inherit;
text-shadow: inherit;
-moz-box-sizing: border-box;
-moz-box-flex: 1;
}
html|*.textbox-textarea {
-moz-appearance: none !important;
text-shadow: inherit;
-moz-box-sizing: border-box;
-moz-box-flex: 1;
}
/*

View File

@ -69,7 +69,7 @@
<xul:hbox anonid="textbox-input-box" class="textbox-input-box" flex="1" xbl:inherits="tooltiptext=inputtooltiptext">
<children/>
<html:input anonid="input" class="autocomplete-textbox textbox-input"
flex="1" allowevents="true"
allowevents="true"
xbl:inherits="tooltiptext=inputtooltiptext,onfocus,onblur,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint"/>
</xul:hbox>
<children includes="hbox"/>

View File

@ -62,24 +62,24 @@
xbl:inherits="context">
<xul:hbox class="textbox-input-box datetimepicker-input-subbox" align="center">
<html:input class="datetimepicker-input textbox-input" anonid="input-one"
size="2" maxlength="2" flex="1"
size="2" maxlength="2"
xbl:inherits="disabled,readonly"/>
</xul:hbox>
<xul:label anonid="sep-first" class="datetimepicker-separator" value=":"/>
<xul:hbox class="textbox-input-box datetimepicker-input-subbox" align="center">
<html:input class="datetimepicker-input textbox-input" anonid="input-two"
size="2" maxlength="2" flex="1"
size="2" maxlength="2"
xbl:inherits="disabled,readonly"/>
</xul:hbox>
<xul:label anonid="sep-second" class="datetimepicker-separator" value=":"/>
<xul:hbox class="textbox-input-box datetimepicker-input-subbox" align="center">
<html:input class="datetimepicker-input textbox-input" anonid="input-three"
size="2" maxlength="2" flex="1"
size="2" maxlength="2"
xbl:inherits="disabled,readonly"/>
</xul:hbox>
<xul:hbox class="textbox-input-box datetimepicker-input-subbox" align="center">
<html:input class="datetimepicker-input textbox-input" anonid="input-ampm"
size="2" maxlength="2" flex="1"
size="2" maxlength="2"
xbl:inherits="disabled,readonly"/>
</xul:hbox>
</xul:hbox>
@ -1244,24 +1244,24 @@
allowevents="true" xbl:inherits="context">
<xul:hbox class="datetimepicker-input-subbox" align="baseline">
<html:input class="datetimepicker-input textbox-input" anonid="input-one"
size="2" maxlength="2" flex="1"
size="2" maxlength="2"
xbl:inherits="disabled,readonly"/>
</xul:hbox>
<xul:label anonid="sep-first" class="datetimepicker-separator" value=":"/>
<xul:hbox class="datetimepicker-input-subbox" align="baseline">
<html:input class="datetimepicker-input textbox-input" anonid="input-two"
size="2" maxlength="2" flex="1"
size="2" maxlength="2"
xbl:inherits="disabled,readonly"/>
</xul:hbox>
<xul:label anonid="sep-second" class="datetimepicker-separator" value=":"/>
<xul:hbox class="datetimepicker-input-subbox" align="center">
<html:input class="datetimepicker-input textbox-input" anonid="input-three"
size="2" maxlength="2" flex="1"
size="2" maxlength="2"
xbl:inherits="disabled,readonly"/>
</xul:hbox>
<xul:hbox class="datetimepicker-input-subbox" align="center">
<html:input class="datetimepicker-input textbox-input" anonid="input-ampm"
size="2" maxlength="2" flex="1"
size="2" maxlength="2"
xbl:inherits="disabled,readonly"/>
</xul:hbox>
</xul:hbox>

View File

@ -411,7 +411,7 @@
<binding id="menulist-editable" extends="chrome://global/content/bindings/menulist.xml#menulist">
<content sizetopopup="pref">
<xul:hbox class="menulist-editable-box textbox-input-box" xbl:inherits="context,disabled,readonly,focused" flex="1">
<html:input class="menulist-editable-input" flex="1" anonid="input" allowevents="true"
<html:input class="menulist-editable-input" anonid="input" allowevents="true"
xbl:inherits="value=label,value,disabled,tabindex,readonly,placeholder"/>
</xul:hbox>
<xul:dropmarker class="menulist-dropmarker" type="menu"

View File

@ -15,7 +15,7 @@
<content>
<xul:hbox class="textbox-input-box numberbox-input-box" flex="1" xbl:inherits="context,disabled,focused">
<html:input class="numberbox-input textbox-input" flex="1" anonid="input"
<html:input class="numberbox-input textbox-input" anonid="input"
xbl:inherits="onfocus,onblur,value,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey"/>
</xul:hbox>
<xul:spinbuttons anonid="buttons" xbl:inherits="disabled,hidden=hidespinbuttons"/>

View File

@ -20,7 +20,7 @@
<content>
<children/>
<xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context,spellcheck">
<html:input class="textbox-input" flex="1" anonid="input"
<html:input class="textbox-input" anonid="input"
xbl:inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,noinitialfocus,mozactionhint,spellcheck"/>
</xul:hbox>
</content>
@ -307,7 +307,7 @@
<content>
<children/>
<xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context,spellcheck" align="center">
<html:input class="textbox-input" flex="1" anonid="input" mozactionhint="search"
<html:input class="textbox-input" anonid="input" mozactionhint="search"
xbl:inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint,spellcheck"/>
<xul:deck class="textbox-search-icons" anonid="search-icons">
<xul:image class="textbox-search-icon"
@ -434,7 +434,7 @@
<binding id="textarea" extends="chrome://global/content/bindings/textbox.xml#textbox">
<content>
<xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context,spellcheck">
<html:textarea class="textbox-textarea" flex="1" anonid="input"
<html:textarea class="textbox-textarea" anonid="input"
xbl:inherits="onfocus,onblur,xbl:text=value,disabled,tabindex,rows,cols,readonly,wrap,placeholder,mozactionhint,spellcheck"><children/></html:textarea>
</xul:hbox>
</content>

View File

@ -22,7 +22,7 @@
<xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context,tooltiptext=inputtooltiptext">
<children/>
<html:input anonid="input" class="autocomplete-textbox textbox-input"
flex="1" allowevents="true"
allowevents="true"
xbl:inherits="tooltiptext=inputtooltiptext,onfocus,onblur,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint,userAction"/>
</xul:hbox>
<children includes="hbox"/>