Skip to content

Commit

Permalink
Bug 1360241: Devirtualize nsIFrame::GetType. r=heycam
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 5Nzhyta5Hle

--HG--
extra : rebase_source : c2e9d4bfb9239f5e851d110cd7dff98c1e1a8d8b
  • Loading branch information
emilio committed Apr 30, 2017
1 parent 71f396b commit e44543a
Show file tree
Hide file tree
Showing 243 changed files with 1,742 additions and 2,624 deletions.
9 changes: 4 additions & 5 deletions accessible/base/nsAccessibilityService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,8 @@ nsAccessibilityService::CreateAccessible(nsINode* aNode,
// accessible for it.
if (!newAcc && aContext->IsXULTabpanels() &&
content->GetParent() == aContext->GetContent()) {
nsIAtom* frameType = frame->GetType();
if (frameType == nsGkAtoms::boxFrame ||
frameType == nsGkAtoms::scrollFrame) {
FrameType frameType = frame->Type();
if (frameType == FrameType::Box || frameType == FrameType::Scroll) {
newAcc = new XULTabpanelAccessible(content, document);
}
}
Expand Down Expand Up @@ -1615,12 +1614,12 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
if (table) {
nsIContent* parentContent = aContent->GetParent();
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
if (parentFrame->GetType() != nsGkAtoms::tableWrapperFrame) {
if (!parentFrame->IsTableWrapperFrame()) {
parentContent = parentContent->GetParent();
parentFrame = parentContent->GetPrimaryFrame();
}

if (parentFrame->GetType() == nsGkAtoms::tableWrapperFrame &&
if (parentFrame->IsTableWrapperFrame() &&
table->GetContent() == parentContent) {
newAcc = new HTMLTableRowAccessible(aContent, document);
}
Expand Down
7 changes: 4 additions & 3 deletions accessible/generic/Accessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Accessible::VisibilityState()
// marked invisible.
// XXX Can we just remove this check? Why do we need to mark empty
// text invisible?
if (frame->GetType() == nsGkAtoms::textFrame &&
if (frame->IsTextFrame() &&
!(frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
frame->GetRect().IsEmpty()) {
nsIFrame::RenderedText text = frame->GetRenderedText(0,
Expand Down Expand Up @@ -636,7 +636,8 @@ Accessible::RelativeBounds(nsIFrame** aBoundingFrame) const
// Find a canvas frame the found hit region is relative to.
nsIFrame* canvasFrame = frame->GetParent();
if (canvasFrame) {
canvasFrame = nsLayoutUtils::GetClosestFrameOfType(canvasFrame, nsGkAtoms::HTMLCanvasFrame);
canvasFrame = nsLayoutUtils::GetClosestFrameOfType(
canvasFrame, FrameType::HTMLCanvas);
}

// make the canvas the bounding frame
Expand Down Expand Up @@ -1888,7 +1889,7 @@ Accessible::AppendTextTo(nsAString& aText, uint32_t aStartOffset,
NS_ASSERTION(mParent,
"Called on accessible unbound from tree. Result can be wrong.");

if (frame->GetType() == nsGkAtoms::brFrame) {
if (frame->IsBrFrame()) {
aText += kForcedNewLineChar;
} else if (mParent && nsAccUtils::MustPrune(mParent)) {
// Expose the embedded object accessible as imaginary embedded object
Expand Down
20 changes: 9 additions & 11 deletions accessible/generic/HyperTextAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ HyperTextAccessible::NativeRole()
return r;

nsIFrame* frame = GetFrame();
if (frame && frame->GetType() == nsGkAtoms::inlineFrame)
if (frame && frame->IsInlineFrame())
return roles::TEXT;

return roles::TEXT_CONTAINER;
Expand Down Expand Up @@ -96,7 +96,7 @@ HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame,
uint32_t aEndRenderedOffset)
{
nsPresContext* presContext = mDoc->PresContext();
if (aFrame->GetType() != nsGkAtoms::textFrame) {
if (!aFrame->IsTextFrame()) {
return aFrame->GetScreenRectInAppUnits().
ToNearestPixels(presContext->AppUnitsPerDevPixel());
}
Expand Down Expand Up @@ -539,7 +539,7 @@ HyperTextAccessible::FindOffset(uint32_t aOffset, nsDirection aDirection,

int32_t innerContentOffset = innerOffset;
if (child->IsTextLeaf()) {
NS_ASSERTION(childFrame->GetType() == nsGkAtoms::textFrame, "Wrong frame!");
NS_ASSERTION(childFrame->IsTextFrame(), "Wrong frame!");
RenderedToContentOffset(childFrame, innerOffset, &innerContentOffset);
}

Expand Down Expand Up @@ -917,7 +917,7 @@ HyperTextAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset,

// Compute spelling attributes on text accessible only.
nsIFrame *offsetFrame = accAtOffset->GetFrame();
if (offsetFrame && offsetFrame->GetType() == nsGkAtoms::textFrame) {
if (offsetFrame && offsetFrame->IsTextFrame()) {
int32_t nodeOffset = 0;
RenderedToContentOffset(offsetFrame, offsetInAcc, &nodeOffset);

Expand Down Expand Up @@ -1109,7 +1109,7 @@ HyperTextAccessible::NativeAttributes()
// 'formatting' attribute is deprecated, 'display' attribute should be
// instead.
nsIFrame *frame = GetFrame();
if (frame && frame->GetType() == nsGkAtoms::blockFrame) {
if (frame && frame->IsBlockFrame()) {
nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("formatting"),
NS_LITERAL_STRING("block"), unused);
Expand Down Expand Up @@ -1223,7 +1223,7 @@ HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType)
nsSize frameSize = frame->GetSize();
if (pointInFrame.x < frameSize.width && pointInFrame.y < frameSize.height) {
// Finished
if (frame->GetType() == nsGkAtoms::textFrame) {
if (frame->IsTextFrame()) {
nsIFrame::ContentOffsets contentOffsets =
frame->GetContentOffsetsFromPointExternal(pointInFrame, nsIFrame::IGNORE_SELECTION_STYLE);
if (contentOffsets.IsNull() || contentOffsets.content != content) {
Expand Down Expand Up @@ -1971,8 +1971,7 @@ HyperTextAccessible::ContentToRenderedOffset(nsIFrame* aFrame, int32_t aContentO
return NS_OK;
}

NS_ASSERTION(aFrame->GetType() == nsGkAtoms::textFrame,
"Need text frame for offset conversion");
NS_ASSERTION(aFrame->IsTextFrame(), "Need text frame for offset conversion");
NS_ASSERTION(aFrame->GetPrevContinuation() == nullptr,
"Call on primary frame only");

Expand All @@ -1996,8 +1995,7 @@ HyperTextAccessible::RenderedToContentOffset(nsIFrame* aFrame, uint32_t aRendere
*aContentOffset = 0;
NS_ENSURE_TRUE(aFrame, NS_ERROR_FAILURE);

NS_ASSERTION(aFrame->GetType() == nsGkAtoms::textFrame,
"Need text frame for offset conversion");
NS_ASSERTION(aFrame->IsTextFrame(), "Need text frame for offset conversion");
NS_ASSERTION(aFrame->GetPrevContinuation() == nullptr,
"Call on primary frame only");

Expand Down Expand Up @@ -2100,7 +2098,7 @@ HyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame* aFrame, int32_t aOffset,
aPoint->idx = parent->IndexOf(content) + 1;
aPoint->node = parent;

} else if (aFrame->GetType() == nsGkAtoms::textFrame) {
} else if (aFrame->IsTextFrame()) {
nsIContent* content = aFrame->GetContent();
NS_ENSURE_STATE(content);

Expand Down
4 changes: 2 additions & 2 deletions dom/base/DOMIntersectionObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
root = mRoot;
rootFrame = root->GetPrimaryFrame();
if (rootFrame) {
if (rootFrame->GetType() == nsGkAtoms::scrollFrame) {
if (rootFrame->IsScrollFrame()) {
nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame);
rootRect = nsLayoutUtils::TransformFrameRectToAncestor(
rootFrame,
Expand Down Expand Up @@ -353,7 +353,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time

nsIFrame* containerFrame = nsLayoutUtils::GetCrossDocParentFrame(targetFrame);
while (containerFrame && containerFrame != rootFrame) {
if (containerFrame->GetType() == nsGkAtoms::scrollFrame) {
if (containerFrame->IsScrollFrame()) {
nsIScrollableFrame* scrollFrame = do_QueryFrame(containerFrame);
nsRect subFrameRect = scrollFrame->GetScrollPortRect();
nsRect intersectionRectRelativeToContainer =
Expand Down
4 changes: 2 additions & 2 deletions dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ Element::GetScrollFrame(nsIFrame **aStyledFrame, bool aFlushLayout)

// menu frames implement GetScrollTargetFrame but we don't want
// to use it here. Similar for comboboxes.
nsIAtom* type = frame->GetType();
if (type != nsGkAtoms::menuFrame && type != nsGkAtoms::comboboxControlFrame) {
FrameType type = frame->Type();
if (type != FrameType::Menu && type != FrameType::ComboboxControl) {
nsIScrollableFrame *scrollFrame = frame->GetScrollTargetFrame();
if (scrollFrame)
return scrollFrame;
Expand Down
8 changes: 4 additions & 4 deletions dom/base/nsFocusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2690,8 +2690,8 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow,
// autocomplete widget use the noautofocus attribute to allow the focus to
// remain outside the popup when it is opened.
if (frame) {
popupFrame = nsLayoutUtils::GetClosestFrameOfType(frame,
nsGkAtoms::menuPopupFrame);
popupFrame =
nsLayoutUtils::GetClosestFrameOfType(frame, FrameType::MenuPopup);
}

if (popupFrame && !forDocumentNavigation) {
Expand Down Expand Up @@ -2917,8 +2917,8 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow,
// navigation would move outside the popup when tabbing outside the
// iframe.
if (!forDocumentNavigation) {
popupFrame = nsLayoutUtils::GetClosestFrameOfType(frame,
nsGkAtoms::menuPopupFrame);
popupFrame =
nsLayoutUtils::GetClosestFrameOfType(frame, FrameType::MenuPopup);
if (popupFrame) {
rootContent = popupFrame->GetContent();
NS_ASSERTION(rootContent, "Popup frame doesn't have a content node");
Expand Down
101 changes: 4 additions & 97 deletions dom/base/nsGkAtomList.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ GK_ATOM(autoplay, "autoplay")
GK_ATOM(autorepeatbutton, "autorepeatbutton")
GK_ATOM(axis, "axis")
GK_ATOM(b, "b")
GK_ATOM(backdropFrame, "BackdropFrame")
GK_ATOM(background, "background")
GK_ATOM(base, "base")
GK_ATOM(basefont, "basefont")
Expand Down Expand Up @@ -1978,101 +1977,11 @@ GK_ATOM(processingInstructionTagName, "#processing-instruction")
GK_ATOM(textTagName, "#text")

// Frame types
GK_ATOM(bcTableCellFrame, "BCTableCellFrame") // table cell in border collapsing model
GK_ATOM(blockFrame, "BlockFrame")
GK_ATOM(boxFrame, "BoxFrame")
GK_ATOM(brFrame, "BRFrame")
GK_ATOM(bulletFrame, "BulletFrame")
GK_ATOM(colorControlFrame, "colorControlFrame")
GK_ATOM(columnSetFrame, "ColumnSetFrame")
GK_ATOM(comboboxControlFrame, "ComboboxControlFrame")
GK_ATOM(comboboxDisplayFrame, "ComboboxDisplayFrame")
GK_ATOM(dateTimeControlFrame, "DateTimeControlFrame")
GK_ATOM(deckFrame, "DeckFrame")
GK_ATOM(detailsFrame, "DetailsFrame")
GK_ATOM(fieldSetFrame, "FieldSetFrame")
GK_ATOM(flexContainerFrame, "FlexContainerFrame")
GK_ATOM(formControlFrame, "FormControlFrame") // radio or checkbox
GK_ATOM(frameSetFrame, "FrameSetFrame")
GK_ATOM(gfxButtonControlFrame, "gfxButtonControlFrame")
GK_ATOM(gridContainerFrame, "GridContainerFrame")
GK_ATOM(HTMLButtonControlFrame, "HTMLButtonControlFrame")
GK_ATOM(HTMLCanvasFrame, "HTMLCanvasFrame")
GK_ATOM(subDocumentFrame, "subDocumentFrame")
GK_ATOM(imageBoxFrame, "ImageBoxFrame")
GK_ATOM(imageFrame, "ImageFrame")
GK_ATOM(imageControlFrame, "ImageControlFrame")
GK_ATOM(inlineFrame, "InlineFrame")
GK_ATOM(leafBoxFrame, "LeafBoxFrame")
GK_ATOM(legendFrame, "LegendFrame")
GK_ATOM(letterFrame, "LetterFrame")
GK_ATOM(lineFrame, "LineFrame")
GK_ATOM(listControlFrame,"ListControlFrame")
GK_ATOM(menuFrame,"MenuFrame")
GK_ATOM(meterFrame, "MeterFrame")
GK_ATOM(menuPopupFrame,"MenuPopupFrame")
GK_ATOM(numberControlFrame, "NumberControlFrame")
GK_ATOM(objectFrame, "ObjectFrame")
GK_ATOM(pageFrame, "PageFrame")
GK_ATOM(pageBreakFrame, "PageBreakFrame")
GK_ATOM(pageContentFrame, "PageContentFrame")
//
// TODO(emilio): Rename this? This is only used now to mark the style context of
// the placeholder with a dummy pseudo.
GK_ATOM(placeholderFrame, "PlaceholderFrame")
GK_ATOM(popupSetFrame, "PopupSetFrame")
GK_ATOM(progressFrame, "ProgressFrame")
GK_ATOM(canvasFrame, "CanvasFrame")
GK_ATOM(rangeFrame, "RangeFrame")
GK_ATOM(rootFrame, "RootFrame")
GK_ATOM(rubyBaseContainerFrame, "RubyBaseContainerFrame")
GK_ATOM(rubyBaseFrame, "RubyBaseFrame")
GK_ATOM(rubyFrame, "RubyFrame")
GK_ATOM(rubyTextContainerFrame, "RubyTextContainerFrame")
GK_ATOM(rubyTextFrame, "RubyTextFrame")
GK_ATOM(scrollFrame, "ScrollFrame")
GK_ATOM(scrollbarFrame, "ScrollbarFrame")
GK_ATOM(sequenceFrame, "SequenceFrame")
GK_ATOM(sliderFrame, "sliderFrame")
GK_ATOM(tableCellFrame, "TableCellFrame")
GK_ATOM(tableColFrame, "TableColFrame")
GK_ATOM(tableColGroupFrame, "TableColGroupFrame")
GK_ATOM(tableFrame, "TableFrame")
GK_ATOM(tableWrapperFrame, "TableWrapperFrame")
GK_ATOM(tableRowGroupFrame, "TableRowGroupFrame")
GK_ATOM(tableRowFrame, "TableRowFrame")
GK_ATOM(textInputFrame,"TextInputFrame")
GK_ATOM(textFrame, "TextFrame")
GK_ATOM(viewportFrame, "ViewportFrame")
#ifdef MOZ_XUL
GK_ATOM(XULLabelFrame, "XULLabelFrame")
#endif
GK_ATOM(svgAFrame, "SVGAFrame")
GK_ATOM(svgClipPathFrame, "SVGClipPathFrame")
GK_ATOM(svgDefsFrame, "SVGDefsFrame")
GK_ATOM(svgFEContainerFrame, "SVGFEContainerFrame")
GK_ATOM(svgFEImageFrame, "SVGFEImageFrame")
GK_ATOM(svgFELeafFrame, "SVGFELeafFrame")
GK_ATOM(svgFEUnstyledLeafFrame, "SVGFEUnstyledLeafFrame")
GK_ATOM(svgFilterFrame, "SVGFilterFrame")
GK_ATOM(svgForeignObjectFrame, "SVGForeignObjectFrame")
GK_ATOM(svgGenericContainerFrame, "SVGGenericContainerFrame")
GK_ATOM(svgGeometryFrame, "SVGGeometryFrame")
GK_ATOM(svgGFrame, "SVGGFrame")
GK_ATOM(svgGradientFrame, "SVGGradientFrame")
GK_ATOM(svgImageFrame, "SVGImageFrame")
GK_ATOM(svgInnerSVGFrame, "SVGInnerSVGFrame")
GK_ATOM(svgLinearGradientFrame, "SVGLinearGradientFrame")
GK_ATOM(svgMarkerFrame, "SVGMarkerFrame")
GK_ATOM(svgMarkerAnonChildFrame, "SVGMarkerAnonChildFrame")
GK_ATOM(svgMaskFrame, "SVGMaskFrame")
GK_ATOM(svgOuterSVGFrame, "SVGOuterSVGFrame")
GK_ATOM(svgOuterSVGAnonChildFrame, "SVGOuterSVGAnonChildFrame")
GK_ATOM(svgPatternFrame, "SVGPatternFrame")
GK_ATOM(svgRadialGradientFrame, "SVGRadialGradientFrame")
GK_ATOM(svgStopFrame, "SVGStopFrame")
GK_ATOM(svgSwitchFrame, "SVGSwitchFrame")
GK_ATOM(svgTextFrame, "SVGTextFrame")
GK_ATOM(svgUseFrame, "SVGUseFrame")
GK_ATOM(svgViewFrame, "SVGViewFrame")
GK_ATOM(HTMLVideoFrame, "VideoFrame")

GK_ATOM(onloadend, "onloadend")
GK_ATOM(onloadstart, "onloadstart")
GK_ATOM(onprogress, "onprogress")
Expand Down Expand Up @@ -2367,7 +2276,6 @@ GK_ATOM(aria_valuenow, "aria-valuenow")
GK_ATOM(aria_valuemin, "aria-valuemin")
GK_ATOM(aria_valuemax, "aria-valuemax")
GK_ATOM(aria_valuetext, "aria-valuetext")
GK_ATOM(AreaFrame, "AreaFrame")
GK_ATOM(auto_generated, "auto-generated")
GK_ATOM(banner, "banner")
GK_ATOM(checkable, "checkable")
Expand All @@ -2388,7 +2296,6 @@ GK_ATOM(grammar, "grammar")
GK_ATOM(gridcell, "gridcell")
GK_ATOM(heading, "heading")
GK_ATOM(hitregion, "hitregion")
GK_ATOM(InlineBlockFrame, "InlineBlockFrame")
GK_ATOM(inlinevalue, "inline")
GK_ATOM(invalid, "invalid")
GK_ATOM(item, "item")
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsGlobalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14028,7 +14028,7 @@ nsGlobalWindow::BeginWindowMove(Event& aMouseDownEvent, Element* aPanel,
#ifdef MOZ_XUL
if (aPanel) {
nsIFrame* frame = aPanel->GetPrimaryFrame();
if (!frame || frame->GetType() != nsGkAtoms::menuPopupFrame) {
if (!frame || !frame->IsMenuPopupFrame()) {
return;
}

Expand Down
11 changes: 5 additions & 6 deletions dom/base/nsRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2973,7 +2973,7 @@ GetTextFrameForContent(nsIContent* aContent, bool aFlushLayout)
}

nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame && frame->GetType() == nsGkAtoms::textFrame) {
if (frame && frame->IsTextFrame()) {
return static_cast<nsTextFrame*>(frame);
}
}
Expand Down Expand Up @@ -3513,9 +3513,8 @@ GetRequiredInnerTextLineBreakCount(nsIFrame* aFrame)
static bool
IsLastCellOfRow(nsIFrame* aFrame)
{
nsIAtom* type = aFrame->GetType();
if (type != nsGkAtoms::tableCellFrame &&
type != nsGkAtoms::bcTableCellFrame) {
FrameType type = aFrame->Type();
if (type != FrameType::TableCell && type != FrameType::BCTableCell) {
return true;
}
for (nsIFrame* c = aFrame; c; c = c->GetNextContinuation()) {
Expand All @@ -3529,7 +3528,7 @@ IsLastCellOfRow(nsIFrame* aFrame)
static bool
IsLastRowOfRowGroup(nsIFrame* aFrame)
{
if (aFrame->GetType() != nsGkAtoms::tableRowFrame) {
if (!aFrame->IsTableRowFrame()) {
return true;
}
for (nsIFrame* c = aFrame; c; c = c->GetNextContinuation()) {
Expand All @@ -3543,7 +3542,7 @@ IsLastRowOfRowGroup(nsIFrame* aFrame)
static bool
IsLastNonemptyRowGroupOfTable(nsIFrame* aFrame)
{
if (aFrame->GetType() != nsGkAtoms::tableRowGroupFrame) {
if (!aFrame->IsTableRowGroupFrame()) {
return true;
}
for (nsIFrame* c = aFrame; c; c = c->GetNextContinuation()) {
Expand Down
Loading

0 comments on commit e44543a

Please sign in to comment.