Changed nsHTMLStyleSheetImpl::AttributeChanged() so that it asks the

content objects for style change hint.  Removed tag specific code in this function.
This commit is contained in:
nisheeth%netscape.com 1998-12-10 23:49:13 +00:00
parent 412a9ae66b
commit 02450534e5
3 changed files with 69 additions and 306 deletions

View File

@ -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

View File

@ -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

View File

@ -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