diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index b0c8ee6ce1e..3bbcace5649 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -3572,12 +3572,7 @@ nsCSSFrameConstructor::AdjustParentFrame(nsFrameConstructorState& aState, (!IsTableRelated(aChildStyle->GetStyleDisplay()->mDisplay, PR_TRUE) || // Also need to create a pseudo-parent if the child is going to end up // with a frame based on something other than display. - IsSpecialContent(aChildContent, aTag, aNameSpaceID, aChildStyle)) && - // XXXbz evil hack for HTML forms.... see similar in - // nsCSSFrameConstructor::TableProcessChild. It should just go away. - (!aChildContent->IsNodeOfType(nsINode::eHTML) || - !aChildContent->NodeInfo()->Equals(nsHTMLAtoms::form, - kNameSpaceID_None))) { + IsSpecialContent(aChildContent, aTag, aNameSpaceID, aChildStyle))) { nsTableCreator tableCreator(aState.mPresShell); nsresult rv = GetPseudoCellFrame(tableCreator, aState, *aParentFrame); if (NS_FAILED(rv)) { @@ -4331,27 +4326,6 @@ nsCSSFrameConstructor::TableProcessChild(nsFrameConstructorState& aState, default: { - - // if
's parent is //// in html, - // NOT create pseudoframe for it. - // see bug 159359 - nsINodeInfo *childNodeInfo = aChildContent->NodeInfo(); - // Sometimes aChildContent is a #text node. In those cases we want to - // construct a foreign frame for it in any case. - if (aChildContent->IsNodeOfType(nsINode::eHTML) && - childNodeInfo->Equals(nsHTMLAtoms::form, kNameSpaceID_None) && - aParentContent->IsNodeOfType(nsINode::eHTML)) { - nsINodeInfo *parentNodeInfo = aParentContent->NodeInfo(); - - if (parentNodeInfo->Equals(nsHTMLAtoms::table) || - parentNodeInfo->Equals(nsHTMLAtoms::tr) || - parentNodeInfo->Equals(nsHTMLAtoms::tbody) || - parentNodeInfo->Equals(nsHTMLAtoms::thead) || - parentNodeInfo->Equals(nsHTMLAtoms::tfoot)) { - break; - } - } - // ConstructTableForeignFrame puts the frame in the right child list and all that return ConstructTableForeignFrame(aState, aChildContent, aParentFrame, childStyleContext, aTableCreator, diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index fdc22b6fd6f..3662d3973b5 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -66,6 +66,7 @@ #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsCSSAnonBoxes.h" +#include "nsITextContent.h" #include "nsRuleWalker.h" #include "nsRuleData.h" #include "nsContentErrors.h" @@ -90,6 +91,27 @@ nsHTMLStyleSheet::HTMLColorRule::List(FILE* out, PRInt32 aIndent) const } #endif + +NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::TableFormRule, nsIStyleRule) + +NS_IMETHODIMP +nsHTMLStyleSheet::TableFormRule::MapRuleInfoInto(nsRuleData* aRuleData) +{ + if (aRuleData->mSID == eStyleStruct_Display) { + nsCSSValue none(NS_STYLE_DISPLAY_NONE, eCSSUnit_Enumerated); + aRuleData->mDisplayData->mDisplay = none; + } + return NS_OK; +} + +#ifdef DEBUG +NS_IMETHODIMP +nsHTMLStyleSheet::TableFormRule::List(FILE* out, PRInt32 aIndent) const +{ + return NS_OK; +} +#endif + NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::GenericTableRule, nsIStyleRule) NS_IMETHODIMP @@ -330,7 +352,8 @@ nsHTMLStyleSheet::nsHTMLStyleSheet(void) mLinkRule(nsnull), mVisitedRule(nsnull), mActiveRule(nsnull), - mDocumentColorRule(nsnull) + mDocumentColorRule(nsnull), + mTableFormRule(nsnull) { mMappedAttrTable.ops = nsnull; } @@ -363,6 +386,10 @@ nsHTMLStyleSheet::Init() return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(mTableTHRule); + mTableFormRule = new TableFormRule(); + if (!mTableFormRule) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(mTableFormRule); return NS_OK; } @@ -374,6 +401,7 @@ nsHTMLStyleSheet::~nsHTMLStyleSheet() NS_IF_RELEASE(mVisitedRule); NS_IF_RELEASE(mActiveRule); NS_IF_RELEASE(mDocumentColorRule); + NS_IF_RELEASE(mTableFormRule); NS_IF_RELEASE(mTableTbodyRule); NS_IF_RELEASE(mTableRowRule); NS_IF_RELEASE(mTableColgroupRule); @@ -470,6 +498,25 @@ nsHTMLStyleSheet::RulesMatching(ElementRuleProcessorData* aData) ruleWalker->Forward(mDocumentColorRule); } } + else if (tag == nsHTMLAtoms::form) { + // suppress in html documents empty forms inside tables, + // they have been used as a hack + // to avoid the form top and bottom margin + nsIDocument* doc = content->GetOwnerDoc(); + nsIContent* parent = content->GetParent(); + if (!content->GetChildCount() && // form is empty + doc && !doc->IsCaseSensitive() && // document is not XHTML + parent && parent->IsNodeOfType(nsINode::eHTML)) { // parent is HTML + nsIAtom* parentTag = parent->Tag(); + if ((nsHTMLAtoms::table == parentTag) || + (nsHTMLAtoms::tr == parentTag) || + (nsHTMLAtoms::tbody == parentTag) || + (nsHTMLAtoms::thead == parentTag) || + (nsHTMLAtoms::tfoot == parentTag)) { + ruleWalker->Forward(mTableFormRule); + } + } + } } // end html element // just get the style rules from the content @@ -660,6 +707,7 @@ nsHTMLStyleSheet::Reset(nsIURI* aURL) NS_IF_RELEASE(mVisitedRule); NS_IF_RELEASE(mActiveRule); NS_IF_RELEASE(mDocumentColorRule); + NS_IF_RELEASE(mTableFormRule); if (mMappedAttrTable.ops) { PL_DHashTableFinish(&mMappedAttrTable); diff --git a/mozilla/layout/style/nsHTMLStyleSheet.h b/mozilla/layout/style/nsHTMLStyleSheet.h index ac1e6b2dcb8..152d804d490 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.h +++ b/mozilla/layout/style/nsHTMLStyleSheet.h @@ -124,6 +124,24 @@ private: nscolor mColor; }; + + // this rule supresses forms inside table tags in html + class TableFormRule; + friend class TableFormRule; + class TableFormRule: public nsIStyleRule { + public: + TableFormRule() {} + + NS_DECL_ISUPPORTS + + // nsIStyleRule interface + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + #ifdef DEBUG + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + #endif + }; + + class GenericTableRule; friend class GenericTableRule; class GenericTableRule: public nsIStyleRule { @@ -196,6 +214,7 @@ private: HTMLColorRule* mVisitedRule; HTMLColorRule* mActiveRule; HTMLColorRule* mDocumentColorRule; + TableFormRule* mTableFormRule; TableTbodyRule* mTableTbodyRule; TableRowRule* mTableRowRule; TableColgroupRule* mTableColgroupRule;