diff --git a/mozilla/layout/style/html.css b/mozilla/layout/style/html.css
index 569c92d6758..c5cd9cbfed7 100644
--- a/mozilla/layout/style/html.css
+++ b/mozilla/layout/style/html.css
@@ -252,6 +252,13 @@ th {
padding: 1px;
}
+tr > form:-moz-is-html, tbody > form:-moz-is-html,
+thead > form:-moz-is-html, tfoot > form:-moz-is-html,
+table > form:-moz-is-html {
+ /* Important: don't show these forms in HTML */
+ display: none !important;
+}
+
/* inlines */
q:before {
diff --git a/mozilla/layout/style/nsCSSPseudoClassList.h b/mozilla/layout/style/nsCSSPseudoClassList.h
index aa44821b531..17fe8fb4608 100644
--- a/mozilla/layout/style/nsCSSPseudoClassList.h
+++ b/mozilla/layout/style/nsCSSPseudoClassList.h
@@ -76,6 +76,9 @@ CSS_PSEUDO_CLASS(lastChild, ":last-child")
CSS_PSEUDO_CLASS(lastNode, ":-moz-last-node")
CSS_PSEUDO_CLASS(onlyChild, ":only-child")
+// Match nodes that are HTML but not XHTML
+CSS_PSEUDO_CLASS(mozIsHTML, ":-moz-is-html")
+
// CSS 3 UI
// http://www.w3.org/TR/2004/CR-css3-ui-20040511/#pseudo-classes
CSS_PSEUDO_CLASS(required, ":required")
diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp
index fc999a2916a..326eb74574a 100644
--- a/mozilla/layout/style/nsCSSStyleSheet.cpp
+++ b/mozilla/layout/style/nsCSSStyleSheet.cpp
@@ -3158,6 +3158,12 @@ static PRBool SelectorMatches(RuleProcessorData &data,
else if (nsCSSPseudoClasses::mozReadWrite == pseudoClass->mAtom) {
result = STATE_CHECK(NS_EVENT_STATE_MOZ_READWRITE);
}
+ else if (nsCSSPseudoClasses::mozIsHTML == pseudoClass->mAtom) {
+ result =
+ (data.mIsHTMLContent &&
+ data.mContent->GetNameSpaceID() == kNameSpaceID_None) ? localTrue :
+ localFalse;
+ }
else {
NS_ERROR("CSS parser parsed a pseudo-class that we do not handle");
result = PR_FALSE; // unknown pseudo class
diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp
index b6048ad9455..b9ec9e509a6 100644
--- a/mozilla/layout/style/nsHTMLStyleSheet.cpp
+++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp
@@ -85,28 +85,7 @@ 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 &&
- aRuleData->mDisplayData->mDisplay.GetUnit() == eCSSUnit_Null) {
- 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
@@ -347,8 +326,7 @@ nsHTMLStyleSheet::nsHTMLStyleSheet(void)
mLinkRule(nsnull),
mVisitedRule(nsnull),
mActiveRule(nsnull),
- mDocumentColorRule(nsnull),
- mTableFormRule(nsnull)
+ mDocumentColorRule(nsnull)
{
mMappedAttrTable.ops = nsnull;
}
@@ -380,11 +358,6 @@ nsHTMLStyleSheet::Init()
if (!mTableTHRule)
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;
}
@@ -396,7 +369,6 @@ 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);
@@ -494,26 +466,6 @@ 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 = styledContent->GetOwnerDoc();
- nsIContent* parent = styledContent->GetParent();
- if (!styledContent->GetChildCount() && // form is empty
- doc && !doc->IsCaseSensitive() && // document is not XHTML
- parent && parent->IsContentOfType(nsIContent::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
@@ -704,7 +656,6 @@ 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 f6f599419ab..8e109f361f1 100644
--- a/mozilla/layout/style/nsHTMLStyleSheet.h
+++ b/mozilla/layout/style/nsHTMLStyleSheet.h
@@ -119,23 +119,6 @@ private:
};
- // 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 {
@@ -208,7 +191,6 @@ private:
HTMLColorRule* mVisitedRule;
HTMLColorRule* mActiveRule;
HTMLColorRule* mDocumentColorRule;
- TableFormRule* mTableFormRule;
TableTbodyRule* mTableTbodyRule;
TableRowRule* mTableRowRule;
TableColgroupRule* mTableColgroupRule;