Bug 1512251 - Remove unused render only selection code r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D13829
This commit is contained in:
Miko Mynttinen
2018-12-06 19:40:50 +00:00
parent 65a65e231b
commit d362fc5ee4
34 changed files with 35 additions and 147 deletions

View File

@@ -4960,7 +4960,7 @@ void PresShell::AddCanvasBackgroundColorItem(
aFrame->PresShell()->GetRootScrollFrameAsScrollable();
if (sf) {
nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame());
if (canvasFrame && canvasFrame->IsVisibleForPainting(&aBuilder)) {
if (canvasFrame && canvasFrame->IsVisibleForPainting()) {
addedScrollingBackgroundColor = AddCanvasBackgroundColor(
aList, canvasFrame, bgcolor, mHasCSSBackgroundColor);
}

View File

@@ -217,7 +217,6 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
mDrawImageBackground(true), // always draw the background
mDrawColorBackground(true),
// mNeverAnimate is initialised below, in constructor body
mIsRenderingOnlySelection(false),
mPaginated(aType != eContext_Galley),
mCanPaginatedScroll(false),
mDoScaledTwips(true),

View File

@@ -861,15 +861,6 @@ class nsPresContext : public nsISupports,
*/
uint32_t GetBidi() const;
/**
* Render only Selection
*/
void SetIsRenderingOnlySelection(bool aResult) {
mIsRenderingOnlySelection = aResult;
}
bool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; }
bool IsTopLevelWindowInactive();
/*
@@ -1401,7 +1392,6 @@ class nsPresContext : public nsISupports,
unsigned mDrawImageBackground : 1;
unsigned mDrawColorBackground : 1;
unsigned mNeverAnimate : 1;
unsigned mIsRenderingOnlySelection : 1;
unsigned mPaginated : 1;
unsigned mCanPaginatedScroll : 1;
unsigned mDoScaledTwips : 1;

View File

@@ -1471,7 +1471,7 @@ void nsComboboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
if ((!IsThemed(disp) ||
!presContext->GetTheme()->ThemeDrawsFocusForWidget(
disp->mAppearance)) &&
mDisplayFrame && IsVisibleForPainting(aBuilder)) {
mDisplayFrame && IsVisibleForPainting()) {
aLists.Content()->AppendToTop(
MakeDisplayItem<nsDisplayComboboxFocus>(aBuilder, this));
}

View File

@@ -196,7 +196,7 @@ void nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// the background/border display item won't do anything, and if it isn't
// empty, we need to paint the outline
if (!(GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) &&
IsVisibleForPainting(aBuilder)) {
IsVisibleForPainting()) {
if (StyleEffects()->mBoxShadow) {
aLists.BorderBackground()->AppendToTop(
MakeDisplayItem<nsDisplayBoxShadowOuter>(aBuilder, this));

View File

@@ -90,7 +90,7 @@ void nsHTMLButtonControlFrame::BuildDisplayList(
}
nsDisplayList onTop;
if (IsVisibleForPainting(aBuilder)) {
if (IsVisibleForPainting()) {
mRenderer.DisplayButton(aBuilder, aLists.BorderBackground(), &onTop);
}

View File

@@ -246,7 +246,7 @@ void nsRangeFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// Draw a focus outline if appropriate:
if (!aBuilder->IsForPainting() || !IsVisibleForPainting(aBuilder)) {
if (!aBuilder->IsForPainting() || !IsVisibleForPainting()) {
// we don't want the focus ring item for hit-testing or if the item isn't
// in the area being [re]painted
return;

View File

@@ -6348,15 +6348,6 @@ static void ComputeVisualOverflowArea(nsLineList& aLines, nscoord aWidth,
}
#endif
bool nsBlockFrame::IsVisibleInSelection(Selection* aSelection) {
if (mContent->IsAnyOfHTMLElements(nsGkAtoms::html, nsGkAtoms::body))
return true;
IgnoredErrorResult rv;
bool visible = aSelection->ContainsNode(*mContent, true, rv);
return !rv.Failed() && visible;
}
#ifdef DEBUG
static void DebugOutputDrawLine(int32_t aDepth, nsLineBox* aLine, bool aDrawn) {
if (nsBlockFrame::gNoisyDamageRepair) {

View File

@@ -223,7 +223,6 @@ class nsBlockFrame : public nsContainerFrame {
};
void ChildIsDirty(nsIFrame* aChild) override;
bool IsVisibleInSelection(mozilla::dom::Selection* aSelection) override;
bool IsEmpty() override;
bool CachedIsEmpty() override;

View File

@@ -641,7 +641,7 @@ void nsDisplayBullet::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
void nsBulletFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
DO_GLOBAL_REFLOW_COUNT_DSP("nsBulletFrame");

View File

@@ -478,7 +478,7 @@ void nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// We don't have any border or outline, and our background draws over
// the overflow area, so just add nsDisplayCanvasBackground instead of
// calling DisplayBorderBackgroundOutline.
if (IsVisibleForPainting(aBuilder)) {
if (IsVisibleForPainting()) {
ComputedStyle* bg = nullptr;
nsIFrame* dependentFrame = nullptr;
bool isThemed = IsThemed();

View File

@@ -1223,7 +1223,7 @@ void nsColumnSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
DisplayBorderBackgroundOutline(aBuilder, aLists);
if (IsVisibleForPainting(aBuilder)) {
if (IsVisibleForPainting()) {
aLists.BorderBackground()->AppendToTop(
MakeDisplayItem<nsDisplayColumnRule>(aBuilder, this));
}

View File

@@ -2131,7 +2131,7 @@ already_AddRefed<ComputedStyle> nsIFrame::ComputeSelectionStyle() const {
void nsFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
nsDisplayList* aList,
uint16_t aContentType) {
if (!IsSelected() || !IsVisibleForPainting(aBuilder)) {
if (!IsSelected() || !IsVisibleForPainting()) {
return;
}
@@ -2189,14 +2189,14 @@ void nsFrame::DisplayOutlineUnconditional(nsDisplayListBuilder* aBuilder,
void nsFrame::DisplayOutline(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
DisplayOutlineUnconditional(aBuilder, aLists);
}
void nsIFrame::DisplayCaret(nsDisplayListBuilder* aBuilder,
nsDisplayList* aList) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
aList->AppendToTop(MakeDisplayItem<nsDisplayCaret>(aBuilder, this));
}
@@ -2226,7 +2226,7 @@ void nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder,
// The visibility check belongs here since child elements have the
// opportunity to override the visibility property and display even if
// their parent is hidden.
if (!IsVisibleForPainting(aBuilder)) {
if (!IsVisibleForPainting()) {
return;
}
@@ -2665,7 +2665,7 @@ void nsIFrame::BuildDisplayListForStackingContext(
// Replaced elements have their visibility handled here, because
// they're visually atomic
if (IsFrameOfType(eReplaced) && !IsVisibleForPainting(aBuilder)) return;
if (IsFrameOfType(eReplaced) && !IsVisibleForPainting()) return;
const nsStyleDisplay* disp = StyleDisplay();
const nsStyleEffects* effects = StyleEffects();
@@ -7342,48 +7342,12 @@ void nsIFrame::RootFrameList(nsPresContext* aPresContext, FILE* out,
}
#endif
bool nsIFrame::IsVisibleForPainting(nsDisplayListBuilder* aBuilder) {
if (!StyleVisibility()->IsVisible()) return false;
Selection* sel = aBuilder->GetBoundingSelection();
return !sel || IsVisibleInSelection(sel);
}
bool nsIFrame::IsVisibleForPainting() {
if (!StyleVisibility()->IsVisible()) return false;
nsPresContext* pc = PresContext();
if (!pc->IsRenderingOnlySelection()) return true;
nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(pc->PresShell()));
if (selcon) {
RefPtr<Selection> sel =
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL);
if (sel) {
return IsVisibleInSelection(sel);
}
}
return true;
return StyleVisibility()->IsVisible();
}
bool nsIFrame::IsVisibleInSelection(nsDisplayListBuilder* aBuilder) {
Selection* sel = aBuilder->GetBoundingSelection();
return !sel || IsVisibleInSelection(sel);
}
bool nsIFrame::IsVisibleOrCollapsedForPainting(nsDisplayListBuilder* aBuilder) {
if (!StyleVisibility()->IsVisibleOrCollapsed()) return false;
Selection* sel = aBuilder->GetBoundingSelection();
return !sel || IsVisibleInSelection(sel);
}
bool nsIFrame::IsVisibleInSelection(Selection* aSelection) {
if (!GetContent() || !GetContent()->IsSelectionDescendant()) {
return false;
}
ErrorResult rv;
bool vis = aSelection->ContainsNode(*mContent, true, rv);
return rv.Failed() || vis;
bool nsIFrame::IsVisibleOrCollapsedForPainting() {
return StyleVisibility()->IsVisibleOrCollapsed();
}
/* virtual */ bool nsFrame::IsEmpty() { return false; }

View File

@@ -440,7 +440,7 @@ bool nsHTMLCanvasFrame::UpdateWebRenderCanvasData(
void nsHTMLCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
DisplayBorderBackgroundOutline(aBuilder, aLists);

View File

@@ -3414,28 +3414,12 @@ class nsIFrame : public nsQueryFrame {
* Determines whether a frame is visible for painting;
* taking into account whether it is painting a selection or printing.
*/
bool IsVisibleForPainting(nsDisplayListBuilder* aBuilder);
bool IsVisibleForPainting();
/**
* Determines whether a frame is visible for painting or collapsed;
* taking into account whether it is painting a selection or printing,
*/
bool IsVisibleOrCollapsedForPainting(nsDisplayListBuilder* aBuilder);
/**
* As above, but slower because we have to recompute some stuff that
* aBuilder already has.
*/
bool IsVisibleForPainting();
/**
* Check whether this frame is visible in the current selection. Returns
* true if there is no current selection.
*/
bool IsVisibleInSelection(nsDisplayListBuilder* aBuilder);
/**
* Overridable function to determine whether this frame should be considered
* "in" the given non-null aSelection for visibility purposes.
*/
virtual bool IsVisibleInSelection(mozilla::dom::Selection* aSelection);
bool IsVisibleOrCollapsedForPainting();
/**
* Determines if this frame is a stacking context.

View File

@@ -1805,7 +1805,7 @@ already_AddRefed<imgIRequest> nsImageFrame::GetCurrentRequest() const {
void nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
DisplayBorderBackgroundOutline(aBuilder, aLists);

View File

@@ -1057,7 +1057,7 @@ bool nsPluginFrame::IsTransparentMode() const {
void nsPluginFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
// XXX why are we painting collapsed object frames?
if (!IsVisibleOrCollapsedForPainting(aBuilder)) return;
if (!IsVisibleOrCollapsedForPainting()) return;
DisplayBorderBackgroundOutline(aBuilder, aLists);

View File

@@ -296,7 +296,7 @@ static void WrapBackgroundColorInOwnLayer(nsDisplayListBuilder* aBuilder,
void nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
nsFrameLoader* frameLoader = FrameLoader();
RenderFrame* rf = nullptr;

View File

@@ -5032,7 +5032,7 @@ void nsDisplayText::RenderToContext(gfxContext* aCtx,
void nsTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame");
@@ -7158,26 +7158,6 @@ int16_t nsTextFrame::GetSelectionStatus(int16_t* aSelectionFlags) {
return selectionValue;
}
bool nsTextFrame::IsVisibleInSelection(Selection* aSelection) {
// Check the quick way first
if (!GetContent()->IsSelectionDescendant()) return false;
UniquePtr<SelectionDetails> details = GetSelectionDetails();
bool found = false;
// where are the selection points "really"
for (SelectionDetails* sdptr = details.get(); sdptr;
sdptr = sdptr->mNext.get()) {
if (sdptr->mEnd > GetContentOffset() && sdptr->mStart < GetContentEnd() &&
sdptr->mSelectionType == SelectionType::eNormal) {
found = true;
break;
}
}
return found;
}
/**
* Compute the longest prefix of text whose width is <= aWidth. Return
* the length of the prefix. Also returns the width of the prefix in aFitWidth.

View File

@@ -207,8 +207,6 @@ class nsTextFrame : public nsFrame {
int32_t* outFrameContentOffset,
nsIFrame** outChildFrame) final;
bool IsVisibleInSelection(mozilla::dom::Selection* aSelection) final;
bool IsEmpty() final;
bool IsSelfEmpty() final { return IsEmpty(); }
nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const final;

View File

@@ -545,7 +545,7 @@ class nsDisplayVideo : public nsDisplayItem {
void nsVideoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
DO_GLOBAL_REFLOW_COUNT_DSP("nsVideoFrame");

View File

@@ -594,7 +594,7 @@ void nsMathMLContainerFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
// report an error if something wrong was found in this frame
if (NS_MATHML_HAS_ERROR(mPresentationData.flags)) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
aLists.Content()->AppendToTop(
MakeDisplayItem<nsDisplayMathMLError>(aBuilder, this));

View File

@@ -1069,16 +1069,6 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mBuildCompositorHitTestInfo = mAsyncPanZoomEnabled && IsForPainting();
nsPresContext* pc = aReferenceFrame->PresContext();
nsIPresShell* shell = pc->PresShell();
if (pc->IsRenderingOnlySelection()) {
nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(shell));
if (selcon) {
mBoundingSelection =
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL);
}
}
static_assert(
static_cast<uint32_t>(DisplayItemType::TYPE_MAX) < (1 << TYPE_BITS),
"Check TYPE_MAX should not overflow");

View File

@@ -555,12 +555,6 @@ class nsDisplayListBuilder {
return mIsAtRootOfPseudoStackingContext;
}
/**
* @return the selection that painting should be restricted to (or nullptr
* in the normal unrestricted case)
*/
mozilla::dom::Selection* GetBoundingSelection() { return mBoundingSelection; }
/**
* @return the root of given frame's (sub)tree, whose origin
* establishes the coordinate system for the child display items.
@@ -1867,7 +1861,6 @@ class nsDisplayListBuilder {
nsIFrame* mIgnoreScrollFrame;
nsPresArena mPool;
RefPtr<mozilla::dom::Selection> mBoundingSelection;
AutoTArray<PresShellState, 8> mPresShellStates;
AutoTArray<nsIFrame*, 400> mFramesMarkedForDisplay;
AutoTArray<nsIFrame*, 40> mFramesMarkedForDisplayIfVisible;

View File

@@ -231,7 +231,7 @@ bool SVGGeometryFrame::IsSVGTransformed(
void SVGGeometryFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!static_cast<const nsSVGElement*>(GetContent())->HasValidDimensions() ||
(!IsVisibleForPainting(aBuilder) && aBuilder->IsForPainting())) {
(!IsVisibleForPainting() && aBuilder->IsForPainting())) {
return;
}
DisplayOutline(aBuilder, aLists);

View File

@@ -2939,7 +2939,7 @@ void SVGTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// painting.
return;
}
if (!IsVisibleForPainting(aBuilder) && aBuilder->IsForPainting()) {
if (!IsVisibleForPainting() && aBuilder->IsForPainting()) {
return;
}
DisplayOutline(aBuilder, aLists);

View File

@@ -753,7 +753,7 @@ void nsSVGOuterSVGFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsDisplayListSet set(contentList, contentList, contentList, contentList,
contentList, contentList);
BuildDisplayListForNonBlockChildren(aBuilder, set);
} else if (IsVisibleForPainting(aBuilder) || !aBuilder->IsForPainting()) {
} else if (IsVisibleForPainting() || !aBuilder->IsForPainting()) {
aLists.Content()->AppendToTop(
MakeDisplayItem<nsDisplayOuterSVG>(aBuilder, this));
}

View File

@@ -436,7 +436,7 @@ bool nsTableCellFrame::ShouldPaintBordersAndBackgrounds() const {
}
bool nsTableCellFrame::ShouldPaintBackground(nsDisplayListBuilder* aBuilder) {
return ShouldPaintBordersAndBackgrounds() && IsVisibleInSelection(aBuilder);
return ShouldPaintBordersAndBackgrounds();
}
void nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,

View File

@@ -1376,7 +1376,7 @@ void nsTableFrame::CalcHasBCBorders() {
nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
const nsDisplayListSet& aLists,
DisplayGenericTablePartTraversal aTraversal) {
bool isVisible = aFrame->IsVisibleForPainting(aBuilder);
bool isVisible = aFrame->IsVisibleForPainting();
bool isTable = aFrame->IsTableFrame();
// Note that we UpdateForFrameBackground() even if we're not visible, unless

View File

@@ -150,7 +150,7 @@ void nsDisplayXULGroupBorder::Paint(nsDisplayListBuilder* aBuilder,
void nsGroupBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
// Paint our background and border
if (IsVisibleForPainting(aBuilder)) {
if (IsVisibleForPainting()) {
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, this, GetBackgroundRectRelativeToSelf(),
aLists.BorderBackground());

View File

@@ -294,7 +294,7 @@ void nsImageBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
return;
}
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
uint32_t clipFlags =
nsStyleUtil::ObjectPropsMightCauseOverflow(StylePosition())

View File

@@ -92,7 +92,7 @@ void nsLeafBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// leaf boxes continue to receive events in the foreground layer.
DisplayBorderBackgroundOutline(aBuilder, aLists);
if (!aBuilder->IsForEventDelivery() || !IsVisibleForPainting(aBuilder))
if (!aBuilder->IsForEventDelivery() || !IsVisibleForPainting())
return;
aLists.Content()->AppendToTop(

View File

@@ -338,7 +338,7 @@ nsRect nsDisplayXULTextBox::GetComponentAlphaBounds(
void nsTextBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
if (!IsVisibleForPainting(aBuilder)) return;
if (!IsVisibleForPainting()) return;
nsLeafBoxFrame::BuildDisplayList(aBuilder, aLists);

View File

@@ -2564,7 +2564,7 @@ class nsDisplayTreeBody final : public nsDisplayItem {
void nsTreeBodyFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
// REVIEW: why did we paint if we were collapsed? that makes no sense!
if (!IsVisibleForPainting(aBuilder))
if (!IsVisibleForPainting())
return; // We're invisible. Don't paint.
// Handles painting our background, border, and outline.