From 78faf6f7fa139c1967c956a72e9660ae70ec0095 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Wed, 16 Apr 2003 18:11:45 +0000 Subject: [PATCH] fix for bug 174802 - simplify GetMappedAttributeImpact, buy making a simple attribute->reflow style map and providing a single helper which walks the map r=dbaron,sr=jst git-svn-id: svn://10.0.0.236/trunk@141248 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsGenericHTMLElement.cpp | 130 +++++++++--------- .../html/content/src/nsGenericHTMLElement.h | 71 +++------- .../html/content/src/nsHTMLAppletElement.cpp | 18 +-- .../html/content/src/nsHTMLBRElement.cpp | 19 +-- .../content/src/nsHTMLBaseFontElement.cpp | 23 ++-- .../html/content/src/nsHTMLBodyElement.cpp | 32 +++-- .../html/content/src/nsHTMLDListElement.cpp | 17 ++- .../content/src/nsHTMLDirectoryElement.cpp | 22 +-- .../html/content/src/nsHTMLDivElement.cpp | 18 ++- .../html/content/src/nsHTMLFontElement.cpp | 26 ++-- .../content/src/nsHTMLFrameSetElement.cpp | 20 ++- .../html/content/src/nsHTMLHRElement.cpp | 25 ++-- .../html/content/src/nsHTMLHeadingElement.cpp | 20 ++- .../html/content/src/nsHTMLIFrameElement.cpp | 27 ++-- .../html/content/src/nsHTMLImageElement.cpp | 27 ++-- .../html/content/src/nsHTMLInputElement.cpp | 43 +++--- .../html/content/src/nsHTMLLIElement.cpp | 17 ++- .../html/content/src/nsHTMLMapElement.cpp | 17 ++- .../html/content/src/nsHTMLMenuElement.cpp | 17 ++- .../html/content/src/nsHTMLOListElement.cpp | 17 ++- .../html/content/src/nsHTMLObjectElement.cpp | 17 ++- .../html/content/src/nsHTMLOptionElement.cpp | 21 ++- .../content/src/nsHTMLParagraphElement.cpp | 17 ++- .../html/content/src/nsHTMLPreElement.cpp | 25 ++-- .../html/content/src/nsHTMLSelectElement.cpp | 23 ++-- .../html/content/src/nsHTMLSharedElement.cpp | 47 ++++--- .../content/src/nsHTMLSharedLeafElement.cpp | 47 ++++--- .../content/src/nsHTMLSharedObjectElement.cpp | 17 ++- .../content/src/nsHTMLTableCaptionElement.cpp | 17 ++- .../content/src/nsHTMLTableCellElement.cpp | 36 ++--- .../content/src/nsHTMLTableColElement.cpp | 28 ++-- .../html/content/src/nsHTMLTableElement.cpp | 55 ++++---- .../content/src/nsHTMLTableRowElement.cpp | 24 ++-- .../content/src/nsHTMLTableSectionElement.cpp | 23 ++-- .../content/src/nsHTMLTextAreaElement.cpp | 20 +-- .../html/content/src/nsHTMLUListElement.cpp | 17 ++- 36 files changed, 567 insertions(+), 473 deletions(-) diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index f93abafaa6c..d6d7cde6445 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -2565,10 +2565,12 @@ nsGenericHTMLElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - + static const AttributeImpactEntry* const map[] = { + sCommonAttributeMap + }; + + FindAttributeImpact(aAttribute, aHint, + map, NS_ARRAY_LENGTH(map)); return NS_OK; } @@ -3165,38 +3167,67 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsIHTMLMappedAttributes* aAt } } -PRBool -nsGenericHTMLElement::GetCommonMappedAttributesImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint) + + +const nsGenericHTMLElement::AttributeImpactEntry +nsGenericHTMLElement::sCommonAttributeMap[] = { + { &nsHTMLAtoms::dir, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::lang, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::_baseHref, NS_STYLE_HINT_VISUAL }, + { nsnull, NS_STYLE_HINT_NONE } +}; + +const +nsGenericHTMLElement::AttributeImpactEntry +nsGenericHTMLElement::sImageAttributeMap[] = { + { &nsHTMLAtoms::width, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::height, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::hspace, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::vspace, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } +}; + +const nsGenericHTMLElement::AttributeImpactEntry +nsGenericHTMLElement::sImageAlignAttributeMap[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_FRAMECHANGE }, + { nsnull, NS_STYLE_HINT_NONE } +}; + +const nsGenericHTMLElement::AttributeImpactEntry +nsGenericHTMLElement::sImageBorderAttributeMap[] = { + { &nsHTMLAtoms::border, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } +}; + + +const nsGenericHTMLElement::AttributeImpactEntry +nsGenericHTMLElement::sBackgroundAttributeMap[] = { + { &nsHTMLAtoms::background, NS_STYLE_HINT_VISUAL }, + { &nsHTMLAtoms::bgcolor, NS_STYLE_HINT_VISUAL }, + { nsnull, NS_STYLE_HINT_NONE } +}; + +void +nsGenericHTMLElement::FindAttributeImpact(const nsIAtom* aAttribute, + nsChangeHint& aHint, + const AttributeImpactEntry* const aMaps[], + PRUint32 aMapCount) { - if (nsHTMLAtoms::dir == aAttribute) { - aHint = NS_STYLE_HINT_REFLOW; // XXX really? possibly FRAMECHANGE? - return PR_TRUE; + for (PRUint32 mapindex = 0; mapindex < aMapCount; ++mapindex) { + const AttributeImpactEntry* map = aMaps[mapindex]; + while (map->attribute) { + if (aAttribute == *map->attribute) { + aHint = map->hint; + return; + } + map++; + } } - else if (nsHTMLAtoms::lang == aAttribute) { - aHint = NS_STYLE_HINT_REFLOW; // LANG attribute affects font selection - return PR_TRUE; - } - else if (nsHTMLAtoms::_baseHref == aAttribute) { - aHint = NS_STYLE_HINT_VISUAL; // at a minimum, elements may need to override - return PR_TRUE; - } - return PR_FALSE; + + // fall-through + aHint = NS_STYLE_HINT_CONTENT; } -PRBool -nsGenericHTMLElement::GetImageMappedAttributesImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint) -{ - if ((nsHTMLAtoms::width == aAttribute) || - (nsHTMLAtoms::height == aAttribute) || - (nsHTMLAtoms::hspace == aAttribute) || - (nsHTMLAtoms::vspace == aAttribute)) { - aHint = NS_STYLE_HINT_REFLOW; - return PR_TRUE; - } - return PR_FALSE; -} void nsGenericHTMLElement::MapAlignAttributeInto(const nsIHTMLMappedAttributes* aAttributes, @@ -3242,16 +3273,6 @@ nsGenericHTMLElement::MapDivAlignAttributeInto(const nsIHTMLMappedAttributes* aA } } -PRBool -nsGenericHTMLElement::GetImageAlignAttributeImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint) -{ - if ((nsHTMLAtoms::align == aAttribute)) { - aHint = NS_STYLE_HINT_FRAMECHANGE; - return PR_TRUE; - } - return PR_FALSE; -} void nsGenericHTMLElement::MapImageMarginAttributeInto(const nsIHTMLMappedAttributes* aAttributes, @@ -3373,18 +3394,6 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsIHTMLMappedAttributes* borderColor->mBottom.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated); } -PRBool -nsGenericHTMLElement::GetImageBorderAttributeImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint) -{ - if ((nsHTMLAtoms::border == aAttribute)) { - aHint = NS_STYLE_HINT_REFLOW; - return PR_TRUE; - } - return PR_FALSE; -} - - void nsGenericHTMLElement::MapBackgroundAttributesInto(const nsIHTMLMappedAttributes* aAttributes, nsRuleData* aData) @@ -3444,19 +3453,6 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsIHTMLMappedAttributes* } } -PRBool -nsGenericHTMLElement::GetBackgroundAttributesImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint) -{ - if ((nsHTMLAtoms::background == aAttribute) || - (nsHTMLAtoms::bgcolor == aAttribute)) { - aHint = NS_STYLE_HINT_VISUAL; - return PR_TRUE; - } - return PR_FALSE; -} - - //---------------------------------------------------------------------- nsGenericHTMLLeafElement::nsGenericHTMLLeafElement() diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index b65a09dc301..916629ba0c2 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -71,7 +71,6 @@ class nsILayoutHistoryState; struct nsRect; struct nsSize; - /** * A common superclass for HTML elements */ @@ -485,38 +484,32 @@ public: */ static void MapCommonAttributesInto(const nsIHTMLMappedAttributes* aAttributes, nsRuleData* aRuleData); - /** - * Get the style impact of common attributes (dir, lang and _baseHref - * currently). To be called from GetMappedAttributeImpact(). - * - * @param aAttribute the attribute to test for impact - * @param aHint the impact (NS_STYLE_HINT_*) - * @return whether the impact was set - */ - static PRBool GetCommonMappedAttributesImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint); + struct AttributeImpactEntry { + nsIAtom** attribute; + nsChangeHint hint; + }; + static const AttributeImpactEntry sCommonAttributeMap[]; + static const AttributeImpactEntry sImageAttributeMap[]; + static const AttributeImpactEntry sImageBorderAttributeMap[]; + static const AttributeImpactEntry sImageAlignAttributeMap[]; + static const AttributeImpactEntry sBackgroundAttributeMap[]; + /** - * Get the style impact of image attributes (width, height, hspace and vspace - * currently). To be called from GetMappedAttributeImpact(). + * A common method where you can just pass in a list of maps to + * check for impact. Most implementations of GetMappedAttributeImpact + * should use this function as a default handler. * - * @param aAttribute the attribute to test for impact - * @param aHint the impact (NS_STYLE_HINT_*) - * @return whether the impact was set + * @param aAttribute attribute that we care about + * @param aHint the resulting hint + * @param aImpactFlags the types of attributes that we care about - see the + * NS_*_ATTRIBUTE_IMPACT flags */ - static PRBool GetImageMappedAttributesImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint); - /** - * Get the style impact of image align attributes (align currently). To be - * called from GetMappedAttributeImpact(). - * - * @param aAttribute the attribute to test for impact - * @param aHint the impact (NS_STYLE_HINT_*) - * @return whether the impact was set - */ - static PRBool GetImageAlignAttributeImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint); + static void + FindAttributeImpact(const nsIAtom* aAttribute, nsChangeHint& aHint, + const AttributeImpactEntry* const aMaps[], + PRUint32 aMapCount); /** * Helper to map the align attribute into a style struct. * @@ -565,17 +558,6 @@ public: */ static void MapImagePositionAttributeInto(const nsIHTMLMappedAttributes* aAttributes, nsRuleData* aData); - /** - * Get the style impact of image border attributes (border currently). To be - * called from GetMappedAttributeImpact(). - * - * @param aAttribute the attribute to test for impact - * @param aHint the impact (NS_STYLE_HINT_*) - * @return whether the impact was set - */ - static PRBool GetImageBorderAttributeImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint); - /** * Helper to map the background attributes (currently background and bgcolor) * into a style struct. @@ -586,17 +568,6 @@ public: */ static void MapBackgroundAttributesInto(const nsIHTMLMappedAttributes* aAttributes, nsRuleData* aData); - /** - * Get the style impact of background attributes (background and bgcolor - * currently). To be called from GetMappedAttributeImpact(). - * - * @param aAttribute the attribute to test for impact - * @param aHint the impact (NS_STYLE_HINT_*) - * @return whether the impact was set - */ - static PRBool GetBackgroundAttributesImpact(const nsIAtom* aAttribute, - nsChangeHint& aHint); - /** * Get the primary frame for a piece of content. * diff --git a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp index 2c499abd4e5..63168d51c21 100644 --- a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp @@ -231,15 +231,15 @@ NS_IMETHODIMP nsHTMLAppletElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageAlignAttributeImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } - } + static const AttributeImpactEntry* const map[] = { + sCommonAttributeMap, + sImageAttributeMap, + sImageAlignAttributeMap, + sImageBorderAttributeMap + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLBRElement.cpp b/mozilla/content/html/content/src/nsHTMLBRElement.cpp index 8a3c890ae0f..6fff059acbe 100644 --- a/mozilla/content/html/content/src/nsHTMLBRElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBRElement.cpp @@ -215,14 +215,17 @@ NS_IMETHODIMP nsHTMLBRElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (nsHTMLAtoms::clear == aAttribute) { - aHint = NS_STYLE_HINT_REFLOW; - } - else { - aHint = NS_STYLE_HINT_CONTENT; - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::clear, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp b/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp index 104544a7b2d..b8e68aed8bc 100644 --- a/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp @@ -207,13 +207,20 @@ NS_IMETHODIMP nsHTMLBaseFontElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((nsHTMLAtoms::color == aAttribute) || - (nsHTMLAtoms::face == aAttribute) || - (nsHTMLAtoms::size == aAttribute)) { - aHint = NS_STYLE_HINT_RECONSTRUCT_ALL; // XXX this seems a bit harsh, perhaps we need a reflow_all? - } - else if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + // XXX this seems a bit harsh, perhaps we need a reflow_all? + { &nsHTMLAtoms::color, NS_STYLE_HINT_RECONSTRUCT_ALL }, + { &nsHTMLAtoms::face, NS_STYLE_HINT_RECONSTRUCT_ALL }, + { &nsHTMLAtoms::size, NS_STYLE_HINT_RECONSTRUCT_ALL }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 83cc45166ec..a71fc9b3cfd 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -608,21 +608,23 @@ NS_IMETHODIMP nsHTMLBodyElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::link) || - (aAttribute == nsHTMLAtoms::vlink) || - (aAttribute == nsHTMLAtoms::alink) || - (aAttribute == nsHTMLAtoms::text)) { - aHint = NS_STYLE_HINT_VISUAL; - } - else if ((aAttribute == nsHTMLAtoms::marginwidth) || - (aAttribute == nsHTMLAtoms::marginheight)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetBackgroundAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::link, NS_STYLE_HINT_VISUAL }, + { &nsHTMLAtoms::vlink, NS_STYLE_HINT_VISUAL }, + { &nsHTMLAtoms::alink, NS_STYLE_HINT_VISUAL }, + { &nsHTMLAtoms::text, NS_STYLE_HINT_VISUAL }, + { &nsHTMLAtoms::marginwidth, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::marginheight, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sBackgroundAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLDListElement.cpp b/mozilla/content/html/content/src/nsHTMLDListElement.cpp index 59eb07c1377..ac36829b7ed 100644 --- a/mozilla/content/html/content/src/nsHTMLDListElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLDListElement.cpp @@ -178,12 +178,17 @@ NS_IMETHODIMP nsHTMLDListElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::compact) { - aHint = NS_STYLE_HINT_CONTENT; // handled by ua.css? - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::compact, NS_STYLE_HINT_CONTENT }, // handled by ua.css? + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp b/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp index 89259332b2c..6de494a9662 100644 --- a/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp @@ -222,15 +222,19 @@ NS_IMETHODIMP nsHTMLDirectoryElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::type) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (aAttribute == nsHTMLAtoms::compact) { - aHint = NS_STYLE_HINT_CONTENT; // XXX - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::type, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::compact, NS_STYLE_HINT_CONTENT}, // XXX + { nsnull, NS_STYLE_HINT_NONE} + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLDivElement.cpp b/mozilla/content/html/content/src/nsHTMLDivElement.cpp index 88baa6d563c..64c76657306 100644 --- a/mozilla/content/html/content/src/nsHTMLDivElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLDivElement.cpp @@ -220,12 +220,18 @@ NS_IMETHODIMP nsHTMLDivElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::align) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLFontElement.cpp b/mozilla/content/html/content/src/nsHTMLFontElement.cpp index ca48af49d00..bfaa38a9a4f 100644 --- a/mozilla/content/html/content/src/nsHTMLFontElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFontElement.cpp @@ -307,19 +307,21 @@ NS_IMETHODIMP nsHTMLFontElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::color) { - aHint = NS_STYLE_HINT_VISUAL; - } - else if ((aAttribute == nsHTMLAtoms::face) || - (aAttribute == nsHTMLAtoms::pointSize) || - (aAttribute == nsHTMLAtoms::size) || - (aAttribute == nsHTMLAtoms::fontWeight)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::face, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::pointSize, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::size, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::fontWeight, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::color, NS_STYLE_HINT_VISUAL }, + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp index edb2dd7052f..75c30883e08 100644 --- a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp @@ -383,13 +383,19 @@ NS_IMETHODIMP nsHTMLFrameSetElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::rows) || - (aAttribute == nsHTMLAtoms::cols)) { - aHint = mCurrentRowColHint; - } - else if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + // can't be static const because it uses mCurrentRowColHint + AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::rows, mCurrentRowColHint }, + { &nsHTMLAtoms::cols, mCurrentRowColHint }, + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLHRElement.cpp b/mozilla/content/html/content/src/nsHTMLHRElement.cpp index 29e3f371da3..929e7b62bff 100644 --- a/mozilla/content/html/content/src/nsHTMLHRElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLHRElement.cpp @@ -273,18 +273,21 @@ NS_IMETHODIMP nsHTMLHRElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::noshade) { - aHint = NS_STYLE_HINT_VISUAL; - } - else if ((aAttribute == nsHTMLAtoms::align) || - (aAttribute == nsHTMLAtoms::width) || - (aAttribute == nsHTMLAtoms::size)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::noshade, NS_STYLE_HINT_VISUAL }, + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::width, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::size, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp index c3c462f5d99..fd1348a0a37 100644 --- a/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp @@ -199,16 +199,22 @@ MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes, nsRuleData* aD } NS_IMETHODIMP -nsHTMLHeadingElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, +nsHTMLHeadingElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, + PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::align) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE }, + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp index 4b170ea3753..036bf5598f4 100644 --- a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp @@ -494,19 +494,20 @@ nsHTMLIFrameElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::width) || - (aAttribute == nsHTMLAtoms::height)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (aAttribute == nsHTMLAtoms::align) { - aHint = NS_STYLE_HINT_FRAMECHANGE; - } - else if (aAttribute == nsHTMLAtoms::frameborder) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::width, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::height, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::align, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::frameborder, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index bb8834f0265..31ab5e79469 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -554,18 +554,21 @@ nsHTMLImageElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::usemap) || - (aAttribute == nsHTMLAtoms::ismap) || - (aAttribute == nsHTMLAtoms::align)) { - aHint = NS_STYLE_HINT_FRAMECHANGE; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::usemap, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::ismap, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::align, NS_STYLE_HINT_FRAMECHANGE }, + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sImageAttributeMap, + sImageBorderAttributeMap + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 7b26d5aa710..4de001a100a 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -1967,28 +1967,27 @@ NS_IMETHODIMP nsHTMLInputElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::value) { - if (mType == NS_FORM_INPUT_BUTTON || - mType == NS_FORM_INPUT_RESET || - mType == NS_FORM_INPUT_SUBMIT) { - aHint = NS_STYLE_HINT_CONTENT; - } - else { - aHint = NS_STYLE_HINT_ATTRCHANGE; - } - } - else if ((aAttribute == nsHTMLAtoms::align) || - (aAttribute == nsHTMLAtoms::type)) { - aHint = NS_STYLE_HINT_FRAMECHANGE; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } + nsChangeHint valueHint = (mType == NS_FORM_INPUT_BUTTON || + mType == NS_FORM_INPUT_RESET || + mType == NS_FORM_INPUT_SUBMIT) ? + NS_STYLE_HINT_CONTENT : NS_STYLE_HINT_ATTRCHANGE; + const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::value, valueHint }, + { &nsHTMLAtoms::align, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::type, NS_STYLE_HINT_FRAMECHANGE }, + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sImageAttributeMap, + sImageBorderAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } @@ -2157,7 +2156,7 @@ nsHTMLInputElement::FireEventForAccessibility(nsIPresContext* aPresContext, { nsCOMPtr event; nsCOMPtr manager; - nsresult rv = GetListenerManager(getter_AddRefs(manager)); + GetListenerManager(getter_AddRefs(manager)); if (manager && NS_SUCCEEDED(manager->CreateEvent(aPresContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) { event->InitEvent(aEventType, PR_TRUE, PR_TRUE); diff --git a/mozilla/content/html/content/src/nsHTMLLIElement.cpp b/mozilla/content/html/content/src/nsHTMLLIElement.cpp index b672799e9ad..0dda626f955 100644 --- a/mozilla/content/html/content/src/nsHTMLLIElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLIElement.cpp @@ -240,12 +240,17 @@ NS_IMETHODIMP nsHTMLLIElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::type) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::type, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLMapElement.cpp b/mozilla/content/html/content/src/nsHTMLMapElement.cpp index c8962e02d4b..d72acb3e0e3 100644 --- a/mozilla/content/html/content/src/nsHTMLMapElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLMapElement.cpp @@ -215,12 +215,17 @@ NS_IMETHODIMP nsHTMLMapElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::name) { - aHint = NS_STYLE_HINT_RECONSTRUCT_ALL; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::name, NS_STYLE_HINT_RECONSTRUCT_ALL }, + { nsnull, NS_STYLE_HINT_NONE } + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLMenuElement.cpp b/mozilla/content/html/content/src/nsHTMLMenuElement.cpp index 5559916397e..d4060363a67 100644 --- a/mozilla/content/html/content/src/nsHTMLMenuElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLMenuElement.cpp @@ -222,12 +222,17 @@ NS_IMETHODIMP nsHTMLMenuElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::type) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::type, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLOListElement.cpp b/mozilla/content/html/content/src/nsHTMLOListElement.cpp index e76aebb46b1..28b6d1957dd 100644 --- a/mozilla/content/html/content/src/nsHTMLOListElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOListElement.cpp @@ -258,12 +258,17 @@ NS_IMETHODIMP nsHTMLOListElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::type) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::type, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp index 978bdb768ae..a9f1cba9884 100644 --- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp @@ -299,16 +299,15 @@ NS_IMETHODIMP nsHTMLObjectElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageAlignAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } - } + static const AttributeImpactEntry* const map[] = { + sCommonAttributeMap, + sImageAttributeMap, + sImageBorderAttributeMap, + sImageAlignAttributeMap, + }; + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index 86913f6ccbf..8d9a28cfdb6 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -497,14 +497,21 @@ nsHTMLOptionElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 nsIFormControlFrame* fcFrame = GetSelectFrame(); if (fcFrame) { - if (aAttribute == nsHTMLAtoms::label) { - aHint = NS_STYLE_HINT_REFLOW; - } else if (aAttribute == nsHTMLAtoms::text) { - aHint = NS_STYLE_HINT_REFLOW; - } else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::label, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::text, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + } else { + // XXX don't we want to try common attributes here? if (aAttribute == nsXULAtoms::menuactive) { aHint = NS_STYLE_HINT_CONTENT; } else { diff --git a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp index 9ed2575478e..89aa8056e87 100644 --- a/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp @@ -204,13 +204,18 @@ NS_IMETHODIMP nsHTMLParagraphElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::align) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLPreElement.cpp b/mozilla/content/html/content/src/nsHTMLPreElement.cpp index d88f3fc6214..d34d82bfb3f 100644 --- a/mozilla/content/html/content/src/nsHTMLPreElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLPreElement.cpp @@ -255,16 +255,21 @@ NS_IMETHODIMP nsHTMLPreElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::variable) || - (aAttribute == nsHTMLAtoms::wrap) || - (aAttribute == nsHTMLAtoms::cols) || - (aAttribute == nsHTMLAtoms::width) || - (aAttribute == nsHTMLAtoms::tabstop)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::variable, NS_STYLE_HINT_REFLOW}, + { &nsHTMLAtoms::wrap, NS_STYLE_HINT_REFLOW}, + { &nsHTMLAtoms::cols, NS_STYLE_HINT_REFLOW}, + { &nsHTMLAtoms::width, NS_STYLE_HINT_REFLOW}, + { &nsHTMLAtoms::tabstop, NS_STYLE_HINT_REFLOW}, + { nsnull, NS_STYLE_HINT_NONE }, + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index f8221f2dddb..a97424dd417 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -1880,16 +1880,19 @@ nsHTMLSelectElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::multiple || - aAttribute == nsHTMLAtoms::size) { - aHint = NS_STYLE_HINT_FRAMECHANGE; - } - else if (aAttribute == nsHTMLAtoms::align) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::multiple, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::size, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp index 00ef18d36d2..b7e4d2ff3bd 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedElement.cpp @@ -411,32 +411,35 @@ nsHTMLSharedLeafElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, nsChangeHint& aHint) const { if (mNodeInfo->Equals(nsHTMLAtoms::embed)) { - if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageAlignAttributeImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } - } - + static const AttributeImpactEntry* const map[] = { + sCommonAttributeMap, + sImageAttributeMap, + sImageAlignAttributeMap, + sImageBorderAttributeMap + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) { - if ((aAttribute == nsHTMLAtoms::usemap) || - (aAttribute == nsHTMLAtoms::ismap)) { - aHint = NS_STYLE_HINT_FRAMECHANGE; - } else if (aAttribute == nsHTMLAtoms::align) { - aHint = NS_STYLE_HINT_REFLOW; - } else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::usemap, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::ismap, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sImageAttributeMap, + sImageBorderAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + + return NS_OK; } return nsGenericHTMLLeafElement::GetMappedAttributeImpact(aAttribute, diff --git a/mozilla/content/html/content/src/nsHTMLSharedLeafElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedLeafElement.cpp index 00ef18d36d2..b7e4d2ff3bd 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedLeafElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedLeafElement.cpp @@ -411,32 +411,35 @@ nsHTMLSharedLeafElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, nsChangeHint& aHint) const { if (mNodeInfo->Equals(nsHTMLAtoms::embed)) { - if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageAlignAttributeImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } - } - + static const AttributeImpactEntry* const map[] = { + sCommonAttributeMap, + sImageAttributeMap, + sImageAlignAttributeMap, + sImageBorderAttributeMap + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) { - if ((aAttribute == nsHTMLAtoms::usemap) || - (aAttribute == nsHTMLAtoms::ismap)) { - aHint = NS_STYLE_HINT_FRAMECHANGE; - } else if (aAttribute == nsHTMLAtoms::align) { - aHint = NS_STYLE_HINT_REFLOW; - } else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::usemap, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::ismap, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sImageAttributeMap, + sImageBorderAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + + return NS_OK; } return nsGenericHTMLLeafElement::GetMappedAttributeImpact(aAttribute, diff --git a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp index 978bdb768ae..a9f1cba9884 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -299,16 +299,15 @@ NS_IMETHODIMP nsHTMLObjectElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageBorderAttributeImpact(aAttribute, aHint)) { - if (!GetImageMappedAttributesImpact(aAttribute, aHint)) { - if (!GetImageAlignAttributeImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } - } - } + static const AttributeImpactEntry* const map[] = { + sCommonAttributeMap, + sImageAttributeMap, + sImageBorderAttributeMap, + sImageAlignAttributeMap, + }; + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp index 9aa21d1e9b8..e5a852eea9f 100644 --- a/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp @@ -217,12 +217,17 @@ NS_IMETHODIMP nsHTMLTableCaptionElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::align) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp index fff82a274c0..a1108019806 100644 --- a/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp @@ -509,22 +509,26 @@ NS_IMETHODIMP nsHTMLTableCellElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::align) || - (aAttribute == nsHTMLAtoms::valign) || - (aAttribute == nsHTMLAtoms::nowrap) || - (aAttribute == nsHTMLAtoms::abbr) || - (aAttribute == nsHTMLAtoms::axis) || - (aAttribute == nsHTMLAtoms::headers) || - (aAttribute == nsHTMLAtoms::scope) || - (aAttribute == nsHTMLAtoms::width) || - (aAttribute == nsHTMLAtoms::height)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetBackgroundAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::valign, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::nowrap, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::abbr, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::axis, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::headers, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::scope, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::width, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::height, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sBackgroundAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp index 8f817685edd..548131a66da 100644 --- a/mozilla/content/html/content/src/nsHTMLTableColElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp @@ -327,16 +327,24 @@ nsHTMLTableColElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::width) || - (aAttribute == nsHTMLAtoms::align) || - (aAttribute == nsHTMLAtoms::valign) || - ((aAttribute == nsHTMLAtoms::span) && - !mNodeInfo->Equals(nsHTMLAtoms::col))) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + // we don't match "span" if we're a + nsIAtom** matchSpan = mNodeInfo->Equals(nsHTMLAtoms::col) ? + nsnull : &nsHTMLAtoms::span; + + AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::width, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::valign, NS_STYLE_HINT_REFLOW }, + { matchSpan, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp index 99dd2117514..02d9bfdcdb8 100644 --- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -1505,33 +1505,36 @@ NS_IMETHODIMP nsHTMLTableElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::layout) || - (aAttribute == nsHTMLAtoms::cellpadding) || - (aAttribute == nsHTMLAtoms::cellspacing) || - (aAttribute == nsHTMLAtoms::cols) || - (aAttribute == nsHTMLAtoms::border) || - (aAttribute == nsHTMLAtoms::frame) || - (aAttribute == nsHTMLAtoms::width) || - (aAttribute == nsHTMLAtoms::height) || - (aAttribute == nsHTMLAtoms::hspace) || - (aAttribute == nsHTMLAtoms::vspace)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (aAttribute == nsHTMLAtoms::bordercolor) { - aHint = NS_STYLE_HINT_VISUAL; - } - else if ((aAttribute == nsHTMLAtoms::align) || - (aAttribute == nsHTMLAtoms::rules)) { - // Changing to rules will force border-collapse. Unfortunately, if border-collapse was - // already in effect, then a frame change is not necessary. - aHint = NS_STYLE_HINT_FRAMECHANGE; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetBackgroundAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::layout, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::cellpadding, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::cellspacing, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::cols, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::border, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::frame, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::width, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::height, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::hspace, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::vspace, NS_STYLE_HINT_REFLOW }, + + { &nsHTMLAtoms::bordercolor, NS_STYLE_HINT_VISUAL }, + + // Changing to rules will force border-collapse. Unfortunately, if + // border-collapse was already in effect, then a frame change is + // not necessary. + { &nsHTMLAtoms::align, NS_STYLE_HINT_FRAMECHANGE }, + { &nsHTMLAtoms::rules, NS_STYLE_HINT_FRAMECHANGE }, + { nsnull, NS_STYLE_HINT_NONE } + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sBackgroundAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp index 97b9372764b..69b24b4cb83 100644 --- a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp @@ -639,17 +639,21 @@ NS_IMETHODIMP nsHTMLTableRowElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::align) || - (aAttribute == nsHTMLAtoms::valign) || - (aAttribute == nsHTMLAtoms::height)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetBackgroundAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::valign, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::height, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sBackgroundAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp index 58571674794..3343aaaa6b9 100644 --- a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -394,17 +394,20 @@ NS_IMETHODIMP nsHTMLTableSectionElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if ((aAttribute == nsHTMLAtoms::align) || - (aAttribute == nsHTMLAtoms::valign) || - (aAttribute == nsHTMLAtoms::height)) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - if (!GetBackgroundAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::valign, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::height, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + sBackgroundAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index 5fcdf1b4206..34289ae1bd6 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -635,15 +635,19 @@ nsHTMLTextAreaElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt // rows and cols and why the AttributeChanged method in // nsTextControlFrame does take care of the entire problem, but // it doesn't and this makes things better - if (aAttribute == nsHTMLAtoms::align || - aAttribute == nsHTMLAtoms::rows || - aAttribute == nsHTMLAtoms::cols) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::align, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::rows, NS_STYLE_HINT_REFLOW }, + { &nsHTMLAtoms::cols, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLUListElement.cpp b/mozilla/content/html/content/src/nsHTMLUListElement.cpp index bc9699a8542..220b6df0286 100644 --- a/mozilla/content/html/content/src/nsHTMLUListElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLUListElement.cpp @@ -239,13 +239,18 @@ NS_IMETHODIMP nsHTMLUListElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType, nsChangeHint& aHint) const { - if (aAttribute == nsHTMLAtoms::type) { - aHint = NS_STYLE_HINT_REFLOW; - } - else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) { - aHint = NS_STYLE_HINT_CONTENT; - } + static const AttributeImpactEntry attributes[] = { + { &nsHTMLAtoms::type, NS_STYLE_HINT_REFLOW }, + { nsnull, NS_STYLE_HINT_NONE } + }; + static const AttributeImpactEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + FindAttributeImpact(aAttribute, aHint, map, NS_ARRAY_LENGTH(map)); + return NS_OK; }