зеркало из https://github.com/mozilla/gecko-dev.git
Properly ignore the 'float' property for generated content. Rename NS_STYLE_POSITION_NORMAL to NS_STYLE_POSITION_STATIC. Patch from Mats Palmgren <mats.palmgren@bredband.net>. r=dbaron sr=bzbarsky b=93227
This commit is contained in:
Родитель
29c30c5f3e
Коммит
12c92754b3
|
@ -2721,6 +2721,11 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
|||
parentContext->GetStyleData(eStyleStruct_Display));
|
||||
PRBool inherited = aInherited;
|
||||
|
||||
nsCOMPtr<nsIAtom> pseudoTag;
|
||||
aContext->GetPseudoType(*getter_AddRefs(pseudoTag));
|
||||
PRBool generatedContent = (pseudoTag == nsCSSAtoms::beforePseudo ||
|
||||
pseudoTag == nsCSSAtoms::afterPseudo);
|
||||
|
||||
// display: enum, none, inherit
|
||||
if (eCSSUnit_Enumerated == displayData.mDisplay.GetUnit()) {
|
||||
display->mDisplay = displayData.mDisplay.GetIntValue();
|
||||
|
@ -2760,14 +2765,6 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
|||
// position: enum, inherit
|
||||
if (eCSSUnit_Enumerated == displayData.mPosition.GetUnit()) {
|
||||
display->mPosition = displayData.mPosition.GetIntValue();
|
||||
if (display->mPosition != NS_STYLE_POSITION_NORMAL) {
|
||||
// :before and :after elts cannot be positioned. We need to check for this
|
||||
// case.
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aContext->GetPseudoType(*getter_AddRefs(tag));
|
||||
if (tag && tag.get() == nsCSSAtoms::beforePseudo || tag.get() == nsCSSAtoms::afterPseudo)
|
||||
display->mPosition = NS_STYLE_POSITION_NORMAL;
|
||||
}
|
||||
}
|
||||
else if (eCSSUnit_Inherit == displayData.mPosition.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
|
@ -2889,12 +2886,20 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
|||
}
|
||||
|
||||
// CSS2 specified fixups:
|
||||
// :before and :after elements must not be positioned or floated (CSS2 12.1).
|
||||
if (generatedContent) {
|
||||
if (display->mPosition != NS_STYLE_POSITION_STATIC)
|
||||
display->mPosition = NS_STYLE_POSITION_STATIC;
|
||||
if (display->mFloats != NS_STYLE_FLOAT_NONE)
|
||||
display->mFloats = NS_STYLE_FLOAT_NONE;
|
||||
}
|
||||
|
||||
// 1) if float is not none, and display is not none, then we must set display to block
|
||||
// XXX - there are problems with following the spec here: what we will do instead of
|
||||
// following the letter of the spec is to make sure that floated elements are
|
||||
// some kind of block, not strictly 'block' - see EnsureBlockDisplay method
|
||||
if (display->mDisplay != NS_STYLE_DISPLAY_NONE &&
|
||||
display->mFloats != NS_STYLE_FLOAT_NONE )
|
||||
display->mFloats != NS_STYLE_FLOAT_NONE)
|
||||
EnsureBlockDisplay(display->mDisplay);
|
||||
|
||||
// 2) if position is 'absolute' or 'fixed' then display must be 'block and float must be 'none'
|
||||
|
@ -2907,9 +2912,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
|||
display->mFloats = NS_STYLE_FLOAT_NONE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aContext->GetPseudoType(*getter_AddRefs(tag));
|
||||
if (tag && tag.get() == nsCSSAtoms::beforePseudo || tag.get() == nsCSSAtoms::afterPseudo) {
|
||||
if (generatedContent) {
|
||||
PRUint8 displayValue = display->mDisplay;
|
||||
if (parentDisplay->IsBlockLevel()) {
|
||||
// For block-level elements the only allowed 'display' values are:
|
||||
|
|
|
@ -2479,7 +2479,7 @@ nsComputedDOMStyle::GetPosition(nsIFrame *aFrame,
|
|||
|
||||
if (display) {
|
||||
switch (display->mPosition) {
|
||||
case NS_STYLE_POSITION_NORMAL:
|
||||
case NS_STYLE_POSITION_STATIC:
|
||||
val->SetIdent(NS_LITERAL_STRING("static"));
|
||||
break;
|
||||
case NS_STYLE_POSITION_RELATIVE:
|
||||
|
@ -3067,7 +3067,7 @@ nsComputedDOMStyle::GetOffsetWidthFor(PRUint8 aSide, nsIFrame* aFrame,
|
|||
nsresult rv = NS_OK;
|
||||
if (display) {
|
||||
switch (display->mPosition) {
|
||||
case NS_STYLE_POSITION_NORMAL:
|
||||
case NS_STYLE_POSITION_STATIC:
|
||||
rv = GetStaticOffset(aSide, aFrame, aValue);
|
||||
break;
|
||||
case NS_STYLE_POSITION_RELATIVE:
|
||||
|
|
|
@ -634,7 +634,7 @@ const PRInt32 nsCSSProps::kPlayDuringKTable[] = {
|
|||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kPositionKTable[] = {
|
||||
eCSSKeyword_static, NS_STYLE_POSITION_NORMAL,
|
||||
eCSSKeyword_static, NS_STYLE_POSITION_STATIC,
|
||||
eCSSKeyword_relative, NS_STYLE_POSITION_RELATIVE,
|
||||
eCSSKeyword_absolute, NS_STYLE_POSITION_ABSOLUTE,
|
||||
eCSSKeyword_fixed, NS_STYLE_POSITION_FIXED,
|
||||
|
|
|
@ -1021,7 +1021,7 @@ nsStyleDisplay::nsStyleDisplay()
|
|||
mAppearance = 0;
|
||||
mDisplay = NS_STYLE_DISPLAY_INLINE;
|
||||
mOriginalDisplay = NS_STYLE_DISPLAY_NONE;
|
||||
mPosition = NS_STYLE_POSITION_NORMAL;
|
||||
mPosition = NS_STYLE_POSITION_STATIC;
|
||||
mFloats = NS_STYLE_FLOAT_NONE;
|
||||
mBreakType = NS_STYLE_CLEAR_NONE;
|
||||
mBreakBefore = PR_FALSE;
|
||||
|
|
|
@ -395,7 +395,7 @@
|
|||
#define NS_STYLE_FONT_FIELD 16
|
||||
|
||||
// See nsStylePosition.mPosition
|
||||
#define NS_STYLE_POSITION_NORMAL 0
|
||||
#define NS_STYLE_POSITION_STATIC 0
|
||||
#define NS_STYLE_POSITION_RELATIVE 1
|
||||
#define NS_STYLE_POSITION_ABSOLUTE 2
|
||||
#define NS_STYLE_POSITION_FIXED 3
|
||||
|
|
|
@ -395,7 +395,7 @@
|
|||
#define NS_STYLE_FONT_FIELD 16
|
||||
|
||||
// See nsStylePosition.mPosition
|
||||
#define NS_STYLE_POSITION_NORMAL 0
|
||||
#define NS_STYLE_POSITION_STATIC 0
|
||||
#define NS_STYLE_POSITION_RELATIVE 1
|
||||
#define NS_STYLE_POSITION_ABSOLUTE 2
|
||||
#define NS_STYLE_POSITION_FIXED 3
|
||||
|
|
|
@ -2630,7 +2630,7 @@ NS_IMETHODIMP nsFrame::IsPercentageBase(PRBool& aBase) const
|
|||
const nsStyleDisplay* display;
|
||||
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
||||
|
||||
if (display->mPosition != NS_STYLE_POSITION_NORMAL) {
|
||||
if (display->mPosition != NS_STYLE_POSITION_STATIC) {
|
||||
aBase = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -2630,7 +2630,7 @@ NS_IMETHODIMP nsFrame::IsPercentageBase(PRBool& aBase) const
|
|||
const nsStyleDisplay* display;
|
||||
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
||||
|
||||
if (display->mPosition != NS_STYLE_POSITION_NORMAL) {
|
||||
if (display->mPosition != NS_STYLE_POSITION_STATIC) {
|
||||
aBase = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -634,7 +634,7 @@ const PRInt32 nsCSSProps::kPlayDuringKTable[] = {
|
|||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kPositionKTable[] = {
|
||||
eCSSKeyword_static, NS_STYLE_POSITION_NORMAL,
|
||||
eCSSKeyword_static, NS_STYLE_POSITION_STATIC,
|
||||
eCSSKeyword_relative, NS_STYLE_POSITION_RELATIVE,
|
||||
eCSSKeyword_absolute, NS_STYLE_POSITION_ABSOLUTE,
|
||||
eCSSKeyword_fixed, NS_STYLE_POSITION_FIXED,
|
||||
|
|
|
@ -2479,7 +2479,7 @@ nsComputedDOMStyle::GetPosition(nsIFrame *aFrame,
|
|||
|
||||
if (display) {
|
||||
switch (display->mPosition) {
|
||||
case NS_STYLE_POSITION_NORMAL:
|
||||
case NS_STYLE_POSITION_STATIC:
|
||||
val->SetIdent(NS_LITERAL_STRING("static"));
|
||||
break;
|
||||
case NS_STYLE_POSITION_RELATIVE:
|
||||
|
@ -3067,7 +3067,7 @@ nsComputedDOMStyle::GetOffsetWidthFor(PRUint8 aSide, nsIFrame* aFrame,
|
|||
nsresult rv = NS_OK;
|
||||
if (display) {
|
||||
switch (display->mPosition) {
|
||||
case NS_STYLE_POSITION_NORMAL:
|
||||
case NS_STYLE_POSITION_STATIC:
|
||||
rv = GetStaticOffset(aSide, aFrame, aValue);
|
||||
break;
|
||||
case NS_STYLE_POSITION_RELATIVE:
|
||||
|
|
|
@ -2721,6 +2721,11 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
|||
parentContext->GetStyleData(eStyleStruct_Display));
|
||||
PRBool inherited = aInherited;
|
||||
|
||||
nsCOMPtr<nsIAtom> pseudoTag;
|
||||
aContext->GetPseudoType(*getter_AddRefs(pseudoTag));
|
||||
PRBool generatedContent = (pseudoTag == nsCSSAtoms::beforePseudo ||
|
||||
pseudoTag == nsCSSAtoms::afterPseudo);
|
||||
|
||||
// display: enum, none, inherit
|
||||
if (eCSSUnit_Enumerated == displayData.mDisplay.GetUnit()) {
|
||||
display->mDisplay = displayData.mDisplay.GetIntValue();
|
||||
|
@ -2760,14 +2765,6 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
|||
// position: enum, inherit
|
||||
if (eCSSUnit_Enumerated == displayData.mPosition.GetUnit()) {
|
||||
display->mPosition = displayData.mPosition.GetIntValue();
|
||||
if (display->mPosition != NS_STYLE_POSITION_NORMAL) {
|
||||
// :before and :after elts cannot be positioned. We need to check for this
|
||||
// case.
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aContext->GetPseudoType(*getter_AddRefs(tag));
|
||||
if (tag && tag.get() == nsCSSAtoms::beforePseudo || tag.get() == nsCSSAtoms::afterPseudo)
|
||||
display->mPosition = NS_STYLE_POSITION_NORMAL;
|
||||
}
|
||||
}
|
||||
else if (eCSSUnit_Inherit == displayData.mPosition.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
|
@ -2889,12 +2886,20 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
|||
}
|
||||
|
||||
// CSS2 specified fixups:
|
||||
// :before and :after elements must not be positioned or floated (CSS2 12.1).
|
||||
if (generatedContent) {
|
||||
if (display->mPosition != NS_STYLE_POSITION_STATIC)
|
||||
display->mPosition = NS_STYLE_POSITION_STATIC;
|
||||
if (display->mFloats != NS_STYLE_FLOAT_NONE)
|
||||
display->mFloats = NS_STYLE_FLOAT_NONE;
|
||||
}
|
||||
|
||||
// 1) if float is not none, and display is not none, then we must set display to block
|
||||
// XXX - there are problems with following the spec here: what we will do instead of
|
||||
// following the letter of the spec is to make sure that floated elements are
|
||||
// some kind of block, not strictly 'block' - see EnsureBlockDisplay method
|
||||
if (display->mDisplay != NS_STYLE_DISPLAY_NONE &&
|
||||
display->mFloats != NS_STYLE_FLOAT_NONE )
|
||||
display->mFloats != NS_STYLE_FLOAT_NONE)
|
||||
EnsureBlockDisplay(display->mDisplay);
|
||||
|
||||
// 2) if position is 'absolute' or 'fixed' then display must be 'block and float must be 'none'
|
||||
|
@ -2907,9 +2912,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, const nsCSSStruct& a
|
|||
display->mFloats = NS_STYLE_FLOAT_NONE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aContext->GetPseudoType(*getter_AddRefs(tag));
|
||||
if (tag && tag.get() == nsCSSAtoms::beforePseudo || tag.get() == nsCSSAtoms::afterPseudo) {
|
||||
if (generatedContent) {
|
||||
PRUint8 displayValue = display->mDisplay;
|
||||
if (parentDisplay->IsBlockLevel()) {
|
||||
// For block-level elements the only allowed 'display' values are:
|
||||
|
|
|
@ -1021,7 +1021,7 @@ nsStyleDisplay::nsStyleDisplay()
|
|||
mAppearance = 0;
|
||||
mDisplay = NS_STYLE_DISPLAY_INLINE;
|
||||
mOriginalDisplay = NS_STYLE_DISPLAY_NONE;
|
||||
mPosition = NS_STYLE_POSITION_NORMAL;
|
||||
mPosition = NS_STYLE_POSITION_STATIC;
|
||||
mFloats = NS_STYLE_FLOAT_NONE;
|
||||
mBreakType = NS_STYLE_CLEAR_NONE;
|
||||
mBreakBefore = PR_FALSE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче