diff options
author | win7-7 <win7-7@users.noreply.github.com> | 2020-02-03 20:47:41 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:36:12 +0200 |
commit | be372691233b6e8d359cb31df337f3ee3f6cb68d (patch) | |
tree | 36ae65e74c2fbaf762533383b155554158130b08 /layout/tables | |
parent | 8acff5cdbeb2f92be5e9e926b72ba4a1f19d425d (diff) | |
download | UXP-be372691233b6e8d359cb31df337f3ee3f6cb68d.tar UXP-be372691233b6e8d359cb31df337f3ee3f6cb68d.tar.gz UXP-be372691233b6e8d359cb31df337f3ee3f6cb68d.tar.lz UXP-be372691233b6e8d359cb31df337f3ee3f6cb68d.tar.xz UXP-be372691233b6e8d359cb31df337f3ee3f6cb68d.zip |
Issue #1386 - Devirtualize GetRowSpan/GetColSpan
It's at ~1.5% on the perf log for the Netflix use case, which seems a bit too much.
Diffstat (limited to 'layout/tables')
-rw-r--r-- | layout/tables/celldata.h | 6 | ||||
-rw-r--r-- | layout/tables/nsITableCellLayout.h | 4 | ||||
-rw-r--r-- | layout/tables/nsTableCellFrame.cpp | 26 | ||||
-rw-r--r-- | layout/tables/nsTableCellFrame.h | 6 |
4 files changed, 24 insertions, 18 deletions
diff --git a/layout/tables/celldata.h b/layout/tables/celldata.h index b744b5175..ac7be58d7 100644 --- a/layout/tables/celldata.h +++ b/layout/tables/celldata.h @@ -6,6 +6,7 @@ #define CellData_h__ #include "nsISupports.h" +#include "nsITableCellLayout.h" // for MAX_COLSPAN / MAX_ROWSPAN #include "nsCoord.h" #include "mozilla/gfx/Types.h" #include "mozilla/WritingModes.h" @@ -15,11 +16,6 @@ class nsTableCellFrame; class nsCellMap; class BCCellData; - -#define MAX_ROWSPAN 65534 // the cellmap can not handle more. -#define MAX_COLSPAN 1000 // limit as IE and opera do. If this ever changes, - // change COL_SPAN_OFFSET/COL_SPAN_SHIFT accordingly. - /** * Data stored by nsCellMap to rationalize rowspan and colspan cells. */ diff --git a/layout/tables/nsITableCellLayout.h b/layout/tables/nsITableCellLayout.h index e761d76be..a366b150e 100644 --- a/layout/tables/nsITableCellLayout.h +++ b/layout/tables/nsITableCellLayout.h @@ -7,6 +7,10 @@ #include "nsQueryFrame.h" +#define MAX_ROWSPAN 65534 // the cellmap can not handle more. +#define MAX_COLSPAN 1000 // limit as IE and opera do. If this ever changes, +// change COL_SPAN_OFFSET/COL_SPAN_SHIFT accordingly. + /** * nsITableCellLayout * interface for layout objects that act like table cells. diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 2862bb201..d1736995e 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -711,16 +711,18 @@ nsTableCellFrame::GetCellBaseline() const borderPadding; } -int32_t nsTableCellFrame::GetRowSpan() +int32_t +nsTableCellFrame::GetRowSpan() { int32_t rowSpan=1; - nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent); // Don't look at the content's rowspan if we're a pseudo cell - if (hc && !StyleContext()->GetPseudo()) { - const nsAttrValue* attr = hc->GetParsedAttr(nsGkAtoms::rowspan); + if (!StyleContext()->GetPseudo()) { + dom::Element* elem = mContent->AsElement(); + const nsAttrValue* attr = elem->GetParsedAttr(nsGkAtoms::rowspan); // Note that we don't need to check the tag name, because only table cells - // and table headers parse the "rowspan" attribute into an integer. + // (including MathML <mtd>) and table headers parse the "rowspan" attribute + // into an integer. if (attr && attr->Type() == nsAttrValue::eInteger) { rowSpan = attr->GetIntegerValue(); } @@ -728,16 +730,20 @@ int32_t nsTableCellFrame::GetRowSpan() return rowSpan; } -int32_t nsTableCellFrame::GetColSpan() +int32_t +nsTableCellFrame::GetColSpan() { int32_t colSpan=1; - nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent); // Don't look at the content's colspan if we're a pseudo cell - if (hc && !StyleContext()->GetPseudo()) { - const nsAttrValue* attr = hc->GetParsedAttr(nsGkAtoms::colspan); + if (!StyleContext()->GetPseudo()) { + dom::Element* elem = mContent->AsElement(); + const nsAttrValue* attr = elem->GetParsedAttr( + MOZ_UNLIKELY(elem->IsMathMLElement()) ? nsGkAtoms::columnspan_ + : nsGkAtoms::colspan); // Note that we don't need to check the tag name, because only table cells - // and table headers parse the "colspan" attribute into an integer. + // (including MathML <mtd>) and table headers parse the "colspan" attribute + // into an integer. if (attr && attr->Type() == nsAttrValue::eInteger) { colSpan = attr->GetIntegerValue(); } diff --git a/layout/tables/nsTableCellFrame.h b/layout/tables/nsTableCellFrame.h index e8dad5c20..ea527b3c5 100644 --- a/layout/tables/nsTableCellFrame.h +++ b/layout/tables/nsTableCellFrame.h @@ -165,11 +165,11 @@ public: /** * return the cell's specified row span. this is what was specified in the - * content model or in the style info, and is always >= 1. + * content model or in the style info, and is always >= 0. * to get the effective row span (the actual value that applies), use GetEffectiveRowSpan() * @see nsTableFrame::GetEffectiveRowSpan() */ - virtual int32_t GetRowSpan(); + int32_t GetRowSpan(); // there is no set row index because row index depends on the cell's parent row only @@ -191,7 +191,7 @@ public: * to get the effective col span (the actual value that applies), use GetEffectiveColSpan() * @see nsTableFrame::GetEffectiveColSpan() */ - virtual int32_t GetColSpan(); + int32_t GetColSpan(); /** return the cell's column index (starting at 0 for the first column) */ virtual nsresult GetColIndex(int32_t &aColIndex) const override; |