From fef1fc5b4d753930a8f171bd4f771038999b9697 Mon Sep 17 00:00:00 2001 From: "nisheeth%netscape.com" Date: Thu, 10 Dec 1998 23:49:13 +0000 Subject: [PATCH] Changed nsHTMLStyleSheetImpl::AttributeChanged() so that it asks the content objects for style change hint. Removed tag specific code in this function. git-svn-id: svn://10.0.0.236/trunk@16184 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/style/src/nsHTMLStyleSheet.cpp | 125 ++++-------------- .../html/style/src/nsHTMLStyleSheet.cpp | 125 ++++-------------- mozilla/layout/style/nsHTMLStyleSheet.cpp | 125 ++++-------------- 3 files changed, 69 insertions(+), 306 deletions(-) diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index a44e0960c6e..c504e929043 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -2525,39 +2525,6 @@ HTMLStyleSheetImpl::ContentChanged(nsIPresContext* aPresContext, NS_RELEASE(shell); return rv; } - -PRBool HTMLStyleSheetImpl::AttributeRequiresReflow(nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::align || - aAttribute==nsHTMLAtoms::border || - aAttribute==nsHTMLAtoms::cellpadding || - aAttribute==nsHTMLAtoms::cellspacing || - aAttribute==nsHTMLAtoms::ch || - aAttribute==nsHTMLAtoms::choff || - aAttribute==nsHTMLAtoms::colspan || - aAttribute==nsHTMLAtoms::face || - aAttribute==nsHTMLAtoms::frame || - aAttribute==nsHTMLAtoms::height || - aAttribute==nsHTMLAtoms::nowrap || - aAttribute==nsHTMLAtoms::rowspan || - aAttribute==nsHTMLAtoms::rules || - aAttribute==nsHTMLAtoms::span || - aAttribute==nsHTMLAtoms::valign || - aAttribute==nsHTMLAtoms::width); -} - -PRBool HTMLStyleSheetImpl::AttributeRequiresRepaint(nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and a repaint, but not a reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::bgcolor || - aAttribute==nsHTMLAtoms::color); -} - NS_IMETHODIMP HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, @@ -2582,78 +2549,32 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, aContent, ContentTag(aContent, 0), frame)); #endif - if (PR_TRUE==AttributeRequiresReflow(aAttribute)) { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - else if (PR_TRUE==AttributeRequiresRepaint(aAttribute)) { - restyle = PR_TRUE; - render = PR_TRUE; - } - // the style tag has its own interpretation based on aHint - else if (nsHTMLAtoms::style==aAttribute) { - switch (aHint) { - default: - case NS_STYLE_HINT_UNKNOWN: - case NS_STYLE_HINT_FRAMECHANGE: - reframe = PR_TRUE; - case NS_STYLE_HINT_REFLOW: - reflow = PR_TRUE; - case NS_STYLE_HINT_VISUAL: - render = PR_TRUE; - case NS_STYLE_HINT_CONTENT: - restyle = PR_TRUE; - break; - case NS_STYLE_HINT_AURAL: - break; - } - } - - // this is the hook for specifying behavior of an attribute based on the tag - else - { + // the style tag has its own interpretation based on aHint + if ((nsHTMLAtoms::style != aAttribute) && (NS_STYLE_HINT_UNKNOWN == aHint)) { nsIHTMLContent* htmlContent; result = aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent); + + if (NS_OK == result) { + // Get style hint from HTML content object. + htmlContent->GetStyleHintForAttributeChange(aContent, aAttribute, &aHint); + NS_RELEASE(htmlContent); + } + } - if (NS_OK == result) { - nsIAtom* tag; - htmlContent->GetTag(tag); - - // handle specific attributes by tag - if (nsHTMLAtoms::table==tag) - { - if (nsHTMLAtoms::summary!=aAttribute) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - } - else if (nsHTMLAtoms::col==tag || - nsHTMLAtoms::colgroup==tag || - nsHTMLAtoms::tr==tag || - nsHTMLAtoms::tbody==tag || - nsHTMLAtoms::thead==tag || - nsHTMLAtoms::tfoot==tag) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - else if (nsHTMLAtoms::td==tag || - nsHTMLAtoms::th==tag) - { - if (nsHTMLAtoms::abbr!=aAttribute && - nsHTMLAtoms::axis!=aAttribute && - nsHTMLAtoms::headers!=aAttribute && - nsHTMLAtoms::scope!=aAttribute) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - } - - NS_IF_RELEASE(tag); - NS_RELEASE(htmlContent); - } + switch (aHint) { + default: + case NS_STYLE_HINT_UNKNOWN: + case NS_STYLE_HINT_FRAMECHANGE: + reframe = PR_TRUE; + case NS_STYLE_HINT_REFLOW: + reflow = PR_TRUE; + case NS_STYLE_HINT_VISUAL: + render = PR_TRUE; + case NS_STYLE_HINT_CONTENT: + restyle = PR_TRUE; + break; + case NS_STYLE_HINT_AURAL: + break; } // apply changes diff --git a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp index a44e0960c6e..c504e929043 100644 --- a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -2525,39 +2525,6 @@ HTMLStyleSheetImpl::ContentChanged(nsIPresContext* aPresContext, NS_RELEASE(shell); return rv; } - -PRBool HTMLStyleSheetImpl::AttributeRequiresReflow(nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::align || - aAttribute==nsHTMLAtoms::border || - aAttribute==nsHTMLAtoms::cellpadding || - aAttribute==nsHTMLAtoms::cellspacing || - aAttribute==nsHTMLAtoms::ch || - aAttribute==nsHTMLAtoms::choff || - aAttribute==nsHTMLAtoms::colspan || - aAttribute==nsHTMLAtoms::face || - aAttribute==nsHTMLAtoms::frame || - aAttribute==nsHTMLAtoms::height || - aAttribute==nsHTMLAtoms::nowrap || - aAttribute==nsHTMLAtoms::rowspan || - aAttribute==nsHTMLAtoms::rules || - aAttribute==nsHTMLAtoms::span || - aAttribute==nsHTMLAtoms::valign || - aAttribute==nsHTMLAtoms::width); -} - -PRBool HTMLStyleSheetImpl::AttributeRequiresRepaint(nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and a repaint, but not a reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::bgcolor || - aAttribute==nsHTMLAtoms::color); -} - NS_IMETHODIMP HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, @@ -2582,78 +2549,32 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, aContent, ContentTag(aContent, 0), frame)); #endif - if (PR_TRUE==AttributeRequiresReflow(aAttribute)) { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - else if (PR_TRUE==AttributeRequiresRepaint(aAttribute)) { - restyle = PR_TRUE; - render = PR_TRUE; - } - // the style tag has its own interpretation based on aHint - else if (nsHTMLAtoms::style==aAttribute) { - switch (aHint) { - default: - case NS_STYLE_HINT_UNKNOWN: - case NS_STYLE_HINT_FRAMECHANGE: - reframe = PR_TRUE; - case NS_STYLE_HINT_REFLOW: - reflow = PR_TRUE; - case NS_STYLE_HINT_VISUAL: - render = PR_TRUE; - case NS_STYLE_HINT_CONTENT: - restyle = PR_TRUE; - break; - case NS_STYLE_HINT_AURAL: - break; - } - } - - // this is the hook for specifying behavior of an attribute based on the tag - else - { + // the style tag has its own interpretation based on aHint + if ((nsHTMLAtoms::style != aAttribute) && (NS_STYLE_HINT_UNKNOWN == aHint)) { nsIHTMLContent* htmlContent; result = aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent); + + if (NS_OK == result) { + // Get style hint from HTML content object. + htmlContent->GetStyleHintForAttributeChange(aContent, aAttribute, &aHint); + NS_RELEASE(htmlContent); + } + } - if (NS_OK == result) { - nsIAtom* tag; - htmlContent->GetTag(tag); - - // handle specific attributes by tag - if (nsHTMLAtoms::table==tag) - { - if (nsHTMLAtoms::summary!=aAttribute) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - } - else if (nsHTMLAtoms::col==tag || - nsHTMLAtoms::colgroup==tag || - nsHTMLAtoms::tr==tag || - nsHTMLAtoms::tbody==tag || - nsHTMLAtoms::thead==tag || - nsHTMLAtoms::tfoot==tag) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - else if (nsHTMLAtoms::td==tag || - nsHTMLAtoms::th==tag) - { - if (nsHTMLAtoms::abbr!=aAttribute && - nsHTMLAtoms::axis!=aAttribute && - nsHTMLAtoms::headers!=aAttribute && - nsHTMLAtoms::scope!=aAttribute) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - } - - NS_IF_RELEASE(tag); - NS_RELEASE(htmlContent); - } + switch (aHint) { + default: + case NS_STYLE_HINT_UNKNOWN: + case NS_STYLE_HINT_FRAMECHANGE: + reframe = PR_TRUE; + case NS_STYLE_HINT_REFLOW: + reflow = PR_TRUE; + case NS_STYLE_HINT_VISUAL: + render = PR_TRUE; + case NS_STYLE_HINT_CONTENT: + restyle = PR_TRUE; + break; + case NS_STYLE_HINT_AURAL: + break; } // apply changes diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index a44e0960c6e..c504e929043 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -2525,39 +2525,6 @@ HTMLStyleSheetImpl::ContentChanged(nsIPresContext* aPresContext, NS_RELEASE(shell); return rv; } - -PRBool HTMLStyleSheetImpl::AttributeRequiresReflow(nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::align || - aAttribute==nsHTMLAtoms::border || - aAttribute==nsHTMLAtoms::cellpadding || - aAttribute==nsHTMLAtoms::cellspacing || - aAttribute==nsHTMLAtoms::ch || - aAttribute==nsHTMLAtoms::choff || - aAttribute==nsHTMLAtoms::colspan || - aAttribute==nsHTMLAtoms::face || - aAttribute==nsHTMLAtoms::frame || - aAttribute==nsHTMLAtoms::height || - aAttribute==nsHTMLAtoms::nowrap || - aAttribute==nsHTMLAtoms::rowspan || - aAttribute==nsHTMLAtoms::rules || - aAttribute==nsHTMLAtoms::span || - aAttribute==nsHTMLAtoms::valign || - aAttribute==nsHTMLAtoms::width); -} - -PRBool HTMLStyleSheetImpl::AttributeRequiresRepaint(nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and a repaint, but not a reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::bgcolor || - aAttribute==nsHTMLAtoms::color); -} - NS_IMETHODIMP HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, @@ -2582,78 +2549,32 @@ HTMLStyleSheetImpl::AttributeChanged(nsIPresContext* aPresContext, aContent, ContentTag(aContent, 0), frame)); #endif - if (PR_TRUE==AttributeRequiresReflow(aAttribute)) { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - else if (PR_TRUE==AttributeRequiresRepaint(aAttribute)) { - restyle = PR_TRUE; - render = PR_TRUE; - } - // the style tag has its own interpretation based on aHint - else if (nsHTMLAtoms::style==aAttribute) { - switch (aHint) { - default: - case NS_STYLE_HINT_UNKNOWN: - case NS_STYLE_HINT_FRAMECHANGE: - reframe = PR_TRUE; - case NS_STYLE_HINT_REFLOW: - reflow = PR_TRUE; - case NS_STYLE_HINT_VISUAL: - render = PR_TRUE; - case NS_STYLE_HINT_CONTENT: - restyle = PR_TRUE; - break; - case NS_STYLE_HINT_AURAL: - break; - } - } - - // this is the hook for specifying behavior of an attribute based on the tag - else - { + // the style tag has its own interpretation based on aHint + if ((nsHTMLAtoms::style != aAttribute) && (NS_STYLE_HINT_UNKNOWN == aHint)) { nsIHTMLContent* htmlContent; result = aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent); + + if (NS_OK == result) { + // Get style hint from HTML content object. + htmlContent->GetStyleHintForAttributeChange(aContent, aAttribute, &aHint); + NS_RELEASE(htmlContent); + } + } - if (NS_OK == result) { - nsIAtom* tag; - htmlContent->GetTag(tag); - - // handle specific attributes by tag - if (nsHTMLAtoms::table==tag) - { - if (nsHTMLAtoms::summary!=aAttribute) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - } - else if (nsHTMLAtoms::col==tag || - nsHTMLAtoms::colgroup==tag || - nsHTMLAtoms::tr==tag || - nsHTMLAtoms::tbody==tag || - nsHTMLAtoms::thead==tag || - nsHTMLAtoms::tfoot==tag) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - else if (nsHTMLAtoms::td==tag || - nsHTMLAtoms::th==tag) - { - if (nsHTMLAtoms::abbr!=aAttribute && - nsHTMLAtoms::axis!=aAttribute && - nsHTMLAtoms::headers!=aAttribute && - nsHTMLAtoms::scope!=aAttribute) - { - restyle = PR_TRUE; - reflow = PR_TRUE; - } - } - - NS_IF_RELEASE(tag); - NS_RELEASE(htmlContent); - } + switch (aHint) { + default: + case NS_STYLE_HINT_UNKNOWN: + case NS_STYLE_HINT_FRAMECHANGE: + reframe = PR_TRUE; + case NS_STYLE_HINT_REFLOW: + reflow = PR_TRUE; + case NS_STYLE_HINT_VISUAL: + render = PR_TRUE; + case NS_STYLE_HINT_CONTENT: + restyle = PR_TRUE; + break; + case NS_STYLE_HINT_AURAL: + break; } // apply changes