83119 - Added support for visibility in GetComputedStyle(). r=heikki,sr=jst.

84000 - Preserve NOFRAMES content - patch submitted by scoda@alias.it. r=me, sr=jst.
65467 - DT is an inline element. r=heikki, sr=jst.
88992 - OBJECT should be able to close unclosed block level elements within it. r=heikki, sr=vidur
84491 - IFRAME should be treated similar to NOFRAMES. r=pollmann, sr=vidur
92530 - FORM should behave as a container if the parent is TD or TH. r=heikki,sr=vidur
88243 - For percentage attribute value do not assume that '%' will always be the last character. r=heikki,sr=vidur.
This commit is contained in:
harishd%netscape.com 2001-08-07 19:05:21 +00:00
Родитель 135d5c8a05
Коммит f01a6e9f3e
9 изменённых файлов: 146 добавлений и 54 удалений

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

@ -2390,7 +2390,7 @@ nsGenericHTMLElement::ParseValueOrPercent(const nsAReadableString& aString,
PRInt32 ec, val = tmp.ToInteger(&ec);
if (NS_OK == ec) {
if (val < 0) val = 0;
if (tmp.Length() && tmp.Last() == '%') {/* XXX not 100% compatible with ebina's code */
if (tmp.Length() && tmp.RFindChar('%') >= 0) {/* XXX not 100% compatible with ebina's code */
if (val > 100) val = 100;
aResult.SetPercentValue(float(val)/100.0f);
} else {
@ -2428,7 +2428,7 @@ nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsAReadableString&
}
if (NS_OK == ec) {
if (val < 0) val = 0;
if (tmp.Length() && tmp.Last() == '%') {/* XXX not 100% compatible with ebina's code */
if (tmp.Length() && tmp.RFindChar('%') >= 0) {/* XXX not 100% compatible with ebina's code */
if (val > 100) val = 100;
aResult.SetPercentValue(float(val)/100.0f);
} else if (tmp.Length() && tmp.Last() == '*') {

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

@ -176,6 +176,9 @@ private:
nsresult GetTextAlign(nsIFrame *aFrame, nsIDOMCSSPrimitiveValue*& aValue);
nsresult GetTextDecoration(nsIFrame *aFrame, nsIDOMCSSPrimitiveValue*& aValue);
// Display properties
nsresult GetVisibility(nsIFrame *aFrame, nsIDOMCSSPrimitiveValue*& aValue);
nsresult GetBehavior(nsIFrame *aFrame, nsIDOMCSSPrimitiveValue*& aValue);
nsROCSSPrimitiveValue* GetROCSSPrimitiveValue();
@ -503,6 +506,7 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAReadableString& aPropertyName,
// Text properties
case eCSSProperty_text_align:
rv = GetTextAlign(frame, *getter_AddRefs(val)); break;
case eCSSProperty_text_decoration:
rv = GetTextDecoration(frame, *getter_AddRefs(val)); break;
@ -510,6 +514,10 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAReadableString& aPropertyName,
case eCSSProperty_list_style_image:
rv = GetListStyleImage(frame, *getter_AddRefs(val)); break;
// Display properties
case eCSSProperty_visibility:
rv = GetVisibility(frame, *getter_AddRefs(val)); break;
// Z-Index property
case eCSSProperty_z_index:
rv = GetZIndex(frame, *getter_AddRefs(val)); break;
@ -1377,6 +1385,30 @@ nsComputedDOMStyle::GetTextDecoration(nsIFrame *aFrame,
(void **)&aValue);
}
nsresult
nsComputedDOMStyle::GetVisibility(nsIFrame *aFrame,
nsIDOMCSSPrimitiveValue*& aValue)
{
nsROCSSPrimitiveValue* val=GetROCSSPrimitiveValue();
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
const nsStyleVisibility* visibility=nsnull;
GetStyleData(eStyleStruct_Visibility,(const nsStyleStruct*&)visibility,aFrame);
if(visibility) {
const nsCString& value=
nsCSSProps::SearchKeywordTable(visibility->mVisible,
nsCSSProps::kVisibilityKTable);
val->SetString(value);
}
else {
val->SetString("");
}
return val->QueryInterface(NS_GET_IID(nsIDOMCSSPrimitiveValue),
(void **)&aValue);
}
#if 0
NS_IMETHODIMP
nsComputedDOMStyle::GetCaptionSide(nsAWritableString& aCaptionSide)

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

@ -3149,12 +3149,15 @@ nsresult CNavDTD::CloseBody(const nsIParserNode *aNode){
*/
nsresult CNavDTD::OpenForm(const nsIParserNode *aNode){
static eHTMLTags gTableElements[]={eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_tr,
eHTMLTag_td,eHTMLTag_th,eHTMLTag_col,
eHTMLTag_tfoot,eHTMLTag_thead,eHTMLTag_colgroup};
eHTMLTag_tfoot,eHTMLTag_thead,
eHTMLTag_col,eHTMLTag_colgroup};
nsresult result=NS_OK;
if(!(mFlags & NS_PARSER_FLAG_HAS_OPEN_FORM)) { // discard nested forms - bug 72639
if(!FindTagInSet(mBodyContext->Last(),gTableElements,sizeof(gTableElements)/sizeof(eHTMLTag_unknown))) {
// Check if the parent is a table, tbody, thead, tfoot, tr, col or
// colgroup. If so, treat form as a leaf content. [ Ex. bug 92530 ]
if(!FindTagInSet(mBodyContext->Last(),gTableElements,
sizeof(gTableElements)/sizeof(eHTMLTag_unknown))) {
mFlags |= NS_PARSER_FLAG_IS_FORM_CONTAINER;
}
@ -3413,6 +3416,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
}
break;
case eHTMLTag_iframe: // Bug 84491
case eHTMLTag_noframes:
done=PR_FALSE;
if(mFlags & NS_PARSER_FLAG_FRAMES_ENABLED) {
@ -3491,6 +3495,7 @@ CNavDTD::CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClo
result=CloseFrameset(aNode);
break;
case eHTMLTag_iframe:
case eHTMLTag_noscript:
case eHTMLTag_noframes:
// switch from alternate content state to regular state

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

@ -492,7 +492,7 @@ void InitializeElementTable(void) {
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags, &gRootTags,
/*autoclose starttags and endtags*/ &gDTCloseTags,0,0,0,
/*parent,incl,exclgroups*/ kDLChild, kFlowEntity-kHeading, kNone,
/*parent,incl,exclgroups*/ kDLChild|kInlineEntity, kFlowEntity-kHeading, kNone, // dt's parent group is inline - bug 65467
/*special props, prop-range*/ (kNoPropagate|kMustCloseSelf),kDefaultPropRange,
/*special parents,kids,skip*/ &gInDL,0,eHTMLTag_unknown);
@ -883,7 +883,7 @@ void InitializeElementTable(void) {
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), (kFlowEntity|kInlineEntity|kSelf), kNone,
/*special props, prop-range*/ 0,kDefaultPropRange,
/*special props, prop-range*/ kNoStyleLeaksOut,kDefaultPropRange,
/*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown);
Initialize(
@ -1593,15 +1593,17 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){
(kHeading==gHTMLElements[aTag].mParentBits));
if(!result) {
// NOBR is a block closure - Ref. Bug# 24462
// DIR is a block closure -- Ref. Bug# 25845
// DIR is a block closure - Ref. Bug# 25845
// TD is a block closure - Ref. Bug# 27490
// TR is a block closure - Ref. Bug# 26488
// OBJECT is a block closure - Ref. Bug# 88992
static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_caption,
//eHTMLTag_dd,eHTMLTag_dt, TESTING!!!! DONT SHIP THIS! WHY ARE THESE HERE?
eHTMLTag_td,eHTMLTag_th,eHTMLTag_tr,
/* eHTMLTag_tfoot, eHTMLTag_thead,*/
eHTMLTag_nobr,eHTMLTag_optgroup,eHTMLTag_ol,eHTMLTag_ul,eHTMLTag_dir};
static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,
eHTMLTag_td,eHTMLTag_th,
eHTMLTag_tr,eHTMLTag_caption,
eHTMLTag_object,eHTMLTag_ol,
eHTMLTag_ul,eHTMLTag_optgroup,
eHTMLTag_nobr,eHTMLTag_dir};
result=FindTagInSet(aTag,gClosers,sizeof(gClosers)/sizeof(eHTMLTag_body));
}

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

@ -743,7 +743,12 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
//XXX - Find a better soution to record content
//Added _plaintext to fix bug 46054.
if((eHTMLTag_textarea==theTag || eHTMLTag_xmp==theTag || eHTMLTag_plaintext==theTag || eHTMLTag_noscript==theTag) && !mRecordTrailingContent) {
if((theTag == eHTMLTag_textarea ||
theTag == eHTMLTag_xmp ||
theTag == eHTMLTag_plaintext ||
theTag == eHTMLTag_noscript ||
theTag == eHTMLTag_noframes) &&
!mRecordTrailingContent) {
mRecordTrailingContent=PR_TRUE;
}
@ -813,10 +818,12 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne
if(NS_SUCCEEDED(result)) {
eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID();
if(((theTag==eHTMLTag_textarea) ||
(theTag==eHTMLTag_xmp) ||
(theTag==eHTMLTag_plaintext) ||
(theTag==eHTMLTag_noscript)) && mRecordTrailingContent) {
if((theTag == eHTMLTag_textarea ||
theTag == eHTMLTag_xmp ||
theTag == eHTMLTag_plaintext ||
theTag == eHTMLTag_noscript ||
theTag == eHTMLTag_noframes) &&
mRecordTrailingContent) {
mRecordTrailingContent=PR_FALSE;
}
}

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

@ -176,6 +176,9 @@ private:
nsresult GetTextAlign(nsIFrame *aFrame, nsIDOMCSSPrimitiveValue*& aValue);
nsresult GetTextDecoration(nsIFrame *aFrame, nsIDOMCSSPrimitiveValue*& aValue);
// Display properties
nsresult GetVisibility(nsIFrame *aFrame, nsIDOMCSSPrimitiveValue*& aValue);
nsresult GetBehavior(nsIFrame *aFrame, nsIDOMCSSPrimitiveValue*& aValue);
nsROCSSPrimitiveValue* GetROCSSPrimitiveValue();
@ -503,6 +506,7 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAReadableString& aPropertyName,
// Text properties
case eCSSProperty_text_align:
rv = GetTextAlign(frame, *getter_AddRefs(val)); break;
case eCSSProperty_text_decoration:
rv = GetTextDecoration(frame, *getter_AddRefs(val)); break;
@ -510,6 +514,10 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAReadableString& aPropertyName,
case eCSSProperty_list_style_image:
rv = GetListStyleImage(frame, *getter_AddRefs(val)); break;
// Display properties
case eCSSProperty_visibility:
rv = GetVisibility(frame, *getter_AddRefs(val)); break;
// Z-Index property
case eCSSProperty_z_index:
rv = GetZIndex(frame, *getter_AddRefs(val)); break;
@ -1377,6 +1385,30 @@ nsComputedDOMStyle::GetTextDecoration(nsIFrame *aFrame,
(void **)&aValue);
}
nsresult
nsComputedDOMStyle::GetVisibility(nsIFrame *aFrame,
nsIDOMCSSPrimitiveValue*& aValue)
{
nsROCSSPrimitiveValue* val=GetROCSSPrimitiveValue();
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
const nsStyleVisibility* visibility=nsnull;
GetStyleData(eStyleStruct_Visibility,(const nsStyleStruct*&)visibility,aFrame);
if(visibility) {
const nsCString& value=
nsCSSProps::SearchKeywordTable(visibility->mVisible,
nsCSSProps::kVisibilityKTable);
val->SetString(value);
}
else {
val->SetString("");
}
return val->QueryInterface(NS_GET_IID(nsIDOMCSSPrimitiveValue),
(void **)&aValue);
}
#if 0
NS_IMETHODIMP
nsComputedDOMStyle::GetCaptionSide(nsAWritableString& aCaptionSide)

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

@ -3149,12 +3149,15 @@ nsresult CNavDTD::CloseBody(const nsIParserNode *aNode){
*/
nsresult CNavDTD::OpenForm(const nsIParserNode *aNode){
static eHTMLTags gTableElements[]={eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_tr,
eHTMLTag_td,eHTMLTag_th,eHTMLTag_col,
eHTMLTag_tfoot,eHTMLTag_thead,eHTMLTag_colgroup};
eHTMLTag_tfoot,eHTMLTag_thead,
eHTMLTag_col,eHTMLTag_colgroup};
nsresult result=NS_OK;
if(!(mFlags & NS_PARSER_FLAG_HAS_OPEN_FORM)) { // discard nested forms - bug 72639
if(!FindTagInSet(mBodyContext->Last(),gTableElements,sizeof(gTableElements)/sizeof(eHTMLTag_unknown))) {
// Check if the parent is a table, tbody, thead, tfoot, tr, col or
// colgroup. If so, treat form as a leaf content. [ Ex. bug 92530 ]
if(!FindTagInSet(mBodyContext->Last(),gTableElements,
sizeof(gTableElements)/sizeof(eHTMLTag_unknown))) {
mFlags |= NS_PARSER_FLAG_IS_FORM_CONTAINER;
}
@ -3413,6 +3416,7 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,eHTMLTags aTag,PRBool aClosedB
}
break;
case eHTMLTag_iframe: // Bug 84491
case eHTMLTag_noframes:
done=PR_FALSE;
if(mFlags & NS_PARSER_FLAG_FRAMES_ENABLED) {
@ -3491,6 +3495,7 @@ CNavDTD::CloseContainer(const nsCParserNode *aNode,eHTMLTags aTarget,PRBool aClo
result=CloseFrameset(aNode);
break;
case eHTMLTag_iframe:
case eHTMLTag_noscript:
case eHTMLTag_noframes:
// switch from alternate content state to regular state

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

@ -492,7 +492,7 @@ void InitializeElementTable(void) {
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags, &gRootTags,
/*autoclose starttags and endtags*/ &gDTCloseTags,0,0,0,
/*parent,incl,exclgroups*/ kDLChild, kFlowEntity-kHeading, kNone,
/*parent,incl,exclgroups*/ kDLChild|kInlineEntity, kFlowEntity-kHeading, kNone, // dt's parent group is inline - bug 65467
/*special props, prop-range*/ (kNoPropagate|kMustCloseSelf),kDefaultPropRange,
/*special parents,kids,skip*/ &gInDL,0,eHTMLTag_unknown);
@ -883,7 +883,7 @@ void InitializeElementTable(void) {
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), (kFlowEntity|kInlineEntity|kSelf), kNone,
/*special props, prop-range*/ 0,kDefaultPropRange,
/*special props, prop-range*/ kNoStyleLeaksOut,kDefaultPropRange,
/*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown);
Initialize(
@ -1593,15 +1593,17 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){
(kHeading==gHTMLElements[aTag].mParentBits));
if(!result) {
// NOBR is a block closure - Ref. Bug# 24462
// DIR is a block closure -- Ref. Bug# 25845
// DIR is a block closure - Ref. Bug# 25845
// TD is a block closure - Ref. Bug# 27490
// TR is a block closure - Ref. Bug# 26488
// OBJECT is a block closure - Ref. Bug# 88992
static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_caption,
//eHTMLTag_dd,eHTMLTag_dt, TESTING!!!! DONT SHIP THIS! WHY ARE THESE HERE?
eHTMLTag_td,eHTMLTag_th,eHTMLTag_tr,
/* eHTMLTag_tfoot, eHTMLTag_thead,*/
eHTMLTag_nobr,eHTMLTag_optgroup,eHTMLTag_ol,eHTMLTag_ul,eHTMLTag_dir};
static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,
eHTMLTag_td,eHTMLTag_th,
eHTMLTag_tr,eHTMLTag_caption,
eHTMLTag_object,eHTMLTag_ol,
eHTMLTag_ul,eHTMLTag_optgroup,
eHTMLTag_nobr,eHTMLTag_dir};
result=FindTagInSet(aTag,gClosers,sizeof(gClosers)/sizeof(eHTMLTag_body));
}

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

@ -743,7 +743,12 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
//XXX - Find a better soution to record content
//Added _plaintext to fix bug 46054.
if((eHTMLTag_textarea==theTag || eHTMLTag_xmp==theTag || eHTMLTag_plaintext==theTag || eHTMLTag_noscript==theTag) && !mRecordTrailingContent) {
if((theTag == eHTMLTag_textarea ||
theTag == eHTMLTag_xmp ||
theTag == eHTMLTag_plaintext ||
theTag == eHTMLTag_noscript ||
theTag == eHTMLTag_noframes) &&
!mRecordTrailingContent) {
mRecordTrailingContent=PR_TRUE;
}
@ -813,10 +818,12 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne
if(NS_SUCCEEDED(result)) {
eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID();
if(((theTag==eHTMLTag_textarea) ||
(theTag==eHTMLTag_xmp) ||
(theTag==eHTMLTag_plaintext) ||
(theTag==eHTMLTag_noscript)) && mRecordTrailingContent) {
if((theTag == eHTMLTag_textarea ||
theTag == eHTMLTag_xmp ||
theTag == eHTMLTag_plaintext ||
theTag == eHTMLTag_noscript ||
theTag == eHTMLTag_noframes) &&
mRecordTrailingContent) {
mRecordTrailingContent=PR_FALSE;
}
}