Bug 1243610 - Refactor UpdateOverflow to separate out local overflow from that contributed by descendants. r=dbaron

This commit is contained in:
Matt Woodrow 2016-05-04 12:27:43 +12:00
Родитель 7980b88d54
Коммит 47cde44daf
32 изменённых файлов: 133 добавлений и 134 удалений

Просмотреть файл

@ -1722,12 +1722,9 @@ nsBlockFrame::ComputeOverflowAreas(const nsRect& aBounds,
aOverflowAreas = areas;
}
bool
nsBlockFrame::UpdateOverflow()
void
nsBlockFrame::UnionChildOverflow(nsOverflowAreas& aOverflowAreas)
{
nsRect rect(nsPoint(0, 0), GetSize());
nsOverflowAreas overflowAreas(rect, rect);
// We need to update the overflow areas of lines manually, as they
// get cached and re-used otherwise. Lines aren't exposed as normal
// frame children, so calling UnionChildOverflow alone will end up
@ -1752,27 +1749,30 @@ nsBlockFrame::UpdateOverflow()
}
line->SetOverflowAreas(lineAreas);
overflowAreas.UnionWith(lineAreas);
aOverflowAreas.UnionWith(lineAreas);
}
// Line cursor invariants depend on the overflow areas of the lines, so
// we must clear the line cursor since those areas may have changed.
ClearLineCursor();
// Union with child frames, skipping the principal and float lists
// since we already handled those using the line boxes.
nsLayoutUtils::UnionChildOverflow(this, overflowAreas,
nsLayoutUtils::UnionChildOverflow(this, aOverflowAreas,
kPrincipalList | kFloatList);
}
bool
nsBlockFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
bool found;
nscoord blockEndEdgeOfChildren =
Properties().Get(BlockEndEdgeOfChildrenProperty(), &found);
if (found) {
ConsiderBlockEndEdgeOfChildren(GetWritingMode(),
blockEndEdgeOfChildren, overflowAreas);
blockEndEdgeOfChildren, aOverflowAreas);
}
return FinishAndStoreOverflow(overflowAreas, GetSize());
// Line cursor invariants depend on the overflow areas of the lines, so
// we must clear the line cursor since those areas may have changed.
ClearLineCursor();
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
}
void

Просмотреть файл

@ -475,7 +475,9 @@ public:
void ReparentFloats(nsIFrame* aFirstFrame, nsBlockFrame* aOldParent,
bool aReparentSiblings);
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
virtual void UnionChildOverflow(nsOverflowAreas& aOverflowAreas) override;
/** Load all of aFrame's floats into the float manager iff aFrame is not a
* block formatting context. Handles all necessary float manager translations;

Просмотреть файл

@ -5913,8 +5913,8 @@ nsIFrame::GetPreEffectsVisualOverflowRect() const
return r ? *r : GetVisualOverflowRectRelativeToSelf();
}
/* virtual */ bool
nsFrame::UpdateOverflow()
bool
nsIFrame::UpdateOverflow()
{
MOZ_ASSERT(FrameMaintainsOverflow(),
"Non-display SVG do not maintain visual overflow rects");
@ -5922,16 +5922,16 @@ nsFrame::UpdateOverflow()
nsRect rect(nsPoint(0, 0), GetSize());
nsOverflowAreas overflowAreas(rect, rect);
if (!DoesClipChildren() &&
!(IsXULCollapsed() && (IsXULBoxFrame() || ::IsXULBoxWrapped(this)))) {
nsLayoutUtils::UnionChildOverflow(this, overflowAreas);
if (!ComputeCustomOverflow(overflowAreas)) {
return false;
}
UnionChildOverflow(overflowAreas);
if (FinishAndStoreOverflow(overflowAreas, GetSize())) {
nsView* view = GetView();
if (view) {
uint32_t flags = 0;
GetLayoutFlags(flags);
uint32_t flags = GetXULLayoutFlags();
if ((flags & NS_FRAME_NO_SIZE_VIEW) == 0) {
// Make sure the frame's view is properly sized.
@ -5946,6 +5946,22 @@ nsFrame::UpdateOverflow()
return false;
}
/* virtual */ bool
nsFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
return true;
}
/* virtual */ void
nsFrame::UnionChildOverflow(nsOverflowAreas& aOverflowAreas)
{
if (!DoesClipChildren() &&
!(IsXULCollapsed() && (IsXULBoxFrame() || ::IsXULBoxWrapped(this)))) {
nsLayoutUtils::UnionChildOverflow(this, aOverflowAreas);
}
}
// Define the MAX_FRAME_DEPTH to be the ContentSink's MAX_REFLOW_DEPTH plus
// 4 for the frames above the document's frames:
// the Viewport, GFXScroll, ScrollPort, and Canvas

Просмотреть файл

@ -368,7 +368,9 @@ public:
virtual bool CanContinueTextRun() const override;
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
virtual void UnionChildOverflow(nsOverflowAreas& aOverflowAreas) override;
// Selection Methods

Просмотреть файл

@ -5174,7 +5174,7 @@ ScrollFrameHelper::ReflowCallbackCanceled()
}
bool
ScrollFrameHelper::UpdateOverflow()
ScrollFrameHelper::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
nsIScrollableFrame* sf = do_QueryFrame(mOuter);
ScrollbarStyles ss = sf->GetScrollbarStyles();
@ -5214,7 +5214,7 @@ ScrollFrameHelper::UpdateOverflow()
return false; // reflowing will update overflow
}
PostOverflowEvent();
return mOuter->nsContainerFrame::UpdateOverflow();
return mOuter->nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
}
void

Просмотреть файл

@ -341,7 +341,7 @@ public:
mScrollPosForLayerPixelAlignment = GetScrollPosition();
}
bool UpdateOverflow();
bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas);
void UpdateSticky();
@ -707,8 +707,8 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) override;
virtual bool UpdateOverflow() override {
return mHelper.UpdateOverflow();
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
return mHelper.ComputeCustomOverflow(aOverflowAreas);
}
// Called to set the child frames. We typically have three: the scroll area,
@ -1082,8 +1082,8 @@ public:
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) override;
#endif
virtual bool UpdateOverflow() override {
return mHelper.UpdateOverflow();
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
return mHelper.ComputeCustomOverflow(aOverflowAreas);
}
// Called to set the child frames. We typically have three: the scroll area,

Просмотреть файл

@ -2050,14 +2050,28 @@ public:
const nsHTMLReflowState* aReflowState,
nsDidReflowStatus aStatus) = 0;
// XXX Maybe these three should be a separate interface?
/**
* Updates the overflow areas of the frame. This can be called if an
* overflow area of the frame's children has changed without reflowing.
* @return true if either of the overflow areas for this frame have changed.
*/
virtual bool UpdateOverflow() = 0;
bool UpdateOverflow();
/**
* Computes any overflow area created by the frame itself (outside of the
* frame bounds) and includes it into aOverflowAreas.
*
* Returns false if updating overflow isn't supported for this frame.
* If the frame requires a reflow instead, then it is responsible
* for scheduling one.
*/
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) = 0;
/**
* Computes any overflow area created by children of this frame and
* includes it into aOverflowAreas.
*/
virtual void UnionChildOverflow(nsOverflowAreas& aOverflowAreas) = 0;
/**
* Helper method used by block reflow to identify runs of text so
@ -2948,6 +2962,9 @@ public:
virtual nsBoxLayout* GetXULLayoutManager() { return nullptr; }
nsresult GetXULClientRect(nsRect& aContentRect);
virtual uint32_t GetXULLayoutFlags()
{ return 0; }
// For nsSprocketLayout
virtual Valignment GetXULVAlign() const = 0;
virtual Halignment GetXULHAlign() const = 0;

Просмотреть файл

@ -9636,10 +9636,10 @@ nsTextFrame::HasAnyNoncollapsedCharacters()
}
bool
nsTextFrame::UpdateOverflow()
nsTextFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
return false;
return true;
}
nsIFrame* decorationsBlock;
@ -9657,14 +9657,13 @@ nsTextFrame::UpdateOverflow()
f = f->GetParent();
if (!f) {
NS_ERROR("Couldn't find any block ancestor (for text decorations)");
return false;
return nsFrame::ComputeCustomOverflow(aOverflowAreas);
}
}
}
nsOverflowAreas overflowAreas = RecomputeOverflow(decorationsBlock);
return FinishAndStoreOverflow(overflowAreas, GetSize());
aOverflowAreas = RecomputeOverflow(decorationsBlock);
return nsFrame::ComputeCustomOverflow(aOverflowAreas);
}
NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(JustificationAssignmentProperty, int32_t)

Просмотреть файл

@ -565,7 +565,7 @@ public:
bool IsFloatingFirstLetterChild() const;
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
void AssignJustificationGaps(const mozilla::JustificationAssignment& aAssign);
mozilla::JustificationAssignment GetJustificationAssignment() const;

Просмотреть файл

@ -389,7 +389,7 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
}
bool
ViewportFrame::UpdateOverflow()
ViewportFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
nsIScrollableFrame* rootScrollFrame =
PresContext()->PresShell()->GetRootScrollFrameAsScrollable();
@ -397,7 +397,7 @@ ViewportFrame::UpdateOverflow()
return false;
}
return nsFrame::UpdateOverflow();
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
}
nsIAtom*

Просмотреть файл

@ -76,7 +76,7 @@ public:
*/
virtual nsIAtom* GetType() const override;
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
/**
* Adjust aReflowState to account for scrollbars and pres shell

Просмотреть файл

@ -782,7 +782,27 @@ nsMathMLContainerFrame::AttributeChanged(int32_t aNameSpaceID,
}
void
nsMathMLContainerFrame::ComputeOverflow(nsOverflowAreas& aOverflowAreas)
nsMathMLContainerFrame::GatherAndStoreOverflow(nsHTMLReflowMetrics* aMetrics)
{
mBlockStartAscent = aMetrics->BlockStartAscent();
// nsIFrame::FinishAndStoreOverflow likes the overflow area to include the
// frame rectangle.
aMetrics->SetOverflowAreasToDesiredBounds();
ComputeCustomOverflow(aMetrics->mOverflowAreas);
// mBoundingMetrics does not necessarily include content of <mpadded>
// elements whose mBoundingMetrics may not be representative of the true
// bounds, and doesn't include the CSS2 outline rectangles of children, so
// make such to include child overflow areas.
UnionChildOverflow(aMetrics->mOverflowAreas);
FinishAndStoreOverflow(aMetrics);
}
bool
nsMathMLContainerFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
// All non-child-frame content such as nsMathMLChars (and most child-frame
// content) is included in mBoundingMetrics.
@ -794,41 +814,7 @@ nsMathMLContainerFrame::ComputeOverflow(nsOverflowAreas& aOverflowAreas)
// REVIEW: Maybe this should contribute only to visual overflow
// and not scrollable?
aOverflowAreas.UnionAllWith(boundingBox);
// mBoundingMetrics does not necessarily include content of <mpadded>
// elements whose mBoundingMetrics may not be representative of the true
// bounds, and doesn't include the CSS2 outline rectangles of children, so
// make such to include child overflow areas.
nsIFrame* childFrame = mFrames.FirstChild();
while (childFrame) {
ConsiderChildOverflow(aOverflowAreas, childFrame);
childFrame = childFrame->GetNextSibling();
}
}
void
nsMathMLContainerFrame::GatherAndStoreOverflow(nsHTMLReflowMetrics* aMetrics)
{
mBlockStartAscent = aMetrics->BlockStartAscent();
// nsIFrame::FinishAndStoreOverflow likes the overflow area to include the
// frame rectangle.
aMetrics->SetOverflowAreasToDesiredBounds();
ComputeOverflow(aMetrics->mOverflowAreas);
FinishAndStoreOverflow(aMetrics);
}
bool
nsMathMLContainerFrame::UpdateOverflow()
{
nsRect bounds(nsPoint(0, 0), GetSize());
nsOverflowAreas overflowAreas(bounds, bounds);
ComputeOverflow(overflowAreas);
return FinishAndStoreOverflow(overflowAreas, GetSize());
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
}
void

Просмотреть файл

@ -129,7 +129,7 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) override;
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
virtual void MarkIntrinsicISizesDirty() override;
@ -380,8 +380,6 @@ protected:
// overflow.
void GatherAndStoreOverflow(nsHTMLReflowMetrics* aMetrics);
void ComputeOverflow(nsOverflowAreas& aOverflowAreas);
/**
* Call DidReflow() if the NS_FRAME_IN_REFLOW frame bit is set on aFirst and
* all its next siblings up to, but not including, aStop.

Просмотреть файл

@ -58,7 +58,7 @@ public:
nsIAtom* aAttribute,
int32_t aModType) override;
virtual bool UpdateOverflow() override {
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
// We don't maintain a visual overflow rect
return false;
}

Просмотреть файл

@ -67,7 +67,7 @@ public:
void OnVisibilityChange(Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction = Nothing()) override;
virtual bool UpdateOverflow() override {
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
// We don't maintain a visual overflow rect
return false;
}

Просмотреть файл

@ -57,7 +57,7 @@ public:
nsIAtom* aAttribute,
int32_t aModType) override;
virtual bool UpdateOverflow() override {
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
// We don't maintain a visual overflow rect
return false;
}

Просмотреть файл

@ -51,7 +51,7 @@ public:
nsIAtom* aAttribute,
int32_t aModType) override;
virtual bool UpdateOverflow() override {
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
// We don't maintain a visual overflow rect
return false;
}

Просмотреть файл

@ -61,7 +61,7 @@ public:
nsIAtom* aAttribute,
int32_t aModType) override;
virtual bool UpdateOverflow() override {
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
// We don't maintain a visual overflow rect
return false;
}

Просмотреть файл

@ -71,14 +71,14 @@ nsSVGContainerFrame::RemoveFrame(ChildListID aListID,
}
bool
nsSVGContainerFrame::UpdateOverflow()
nsSVGContainerFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
if (mState & NS_FRAME_IS_NONDISPLAY) {
// We don't maintain overflow rects.
// XXX It would have be better if the restyle request hadn't even happened.
return false;
}
return nsContainerFrame::UpdateOverflow();
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
}
/**

Просмотреть файл

@ -86,7 +86,7 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) override {}
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
protected:
/**

Просмотреть файл

@ -514,24 +514,19 @@ nsSVGOuterSVGFrame::DidReflow(nsPresContext* aPresContext,
PresContext()->PresShell()->SynthesizeMouseMove(false);
}
/* virtual */ bool
nsSVGOuterSVGFrame::UpdateOverflow()
/* virtual */ void
nsSVGOuterSVGFrame::UnionChildOverflow(nsOverflowAreas& aOverflowAreas)
{
// See the comments in Reflow above.
// WARNING!! Keep this in sync with Reflow above!
nsRect rect(nsPoint(0, 0), GetSize());
nsOverflowAreas overflowAreas(rect, rect);
if (!mIsRootContent) {
nsIFrame *anonKid = PrincipalChildList().FirstChild();
overflowAreas.VisualOverflow().UnionRect(
overflowAreas.VisualOverflow(),
aOverflowAreas.VisualOverflow().UnionRect(
aOverflowAreas.VisualOverflow(),
anonKid->GetVisualOverflowRect() + anonKid->GetPosition());
}
return FinishAndStoreOverflow(overflowAreas, GetSize());
}

Просмотреть файл

@ -62,7 +62,7 @@ public:
const nsHTMLReflowState* aReflowState,
nsDidReflowStatus aStatus) override;
virtual bool UpdateOverflow() override;
virtual void UnionChildOverflow(nsOverflowAreas& aOverflowAreas) override;
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,

Просмотреть файл

@ -660,15 +660,13 @@ void nsTableCellFrame::BlockDirAlignChild(WritingMode aWM, nscoord aMaxAscent)
}
bool
nsTableCellFrame::UpdateOverflow()
nsTableCellFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
nsRect bounds(nsPoint(0,0), GetSize());
bounds.Inflate(GetBorderOverflow());
nsOverflowAreas overflowAreas(bounds, bounds);
nsLayoutUtils::UnionChildOverflow(this, overflowAreas);
return FinishAndStoreOverflow(overflowAreas, GetSize());
aOverflowAreas.UnionAllWith(bounds);
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
}
// Per CSS 2.1, we map 'sub', 'super', 'text-top', 'text-bottom',

Просмотреть файл

@ -230,7 +230,7 @@ public:
void DecorateForSelection(DrawTarget* aDrawTarget, nsPoint aPt);
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
virtual bool IsFrameOfType(uint32_t aFlags) const override
{

Просмотреть файл

@ -2054,22 +2054,19 @@ nsTableFrame::FixupPositionedTableParts(nsPresContext* aPresContext,
}
bool
nsTableFrame::UpdateOverflow()
nsTableFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
nsRect bounds(nsPoint(0, 0), GetSize());
// As above in Reflow, make sure the table overflow area includes the table
// rect, and check for collapsed borders leaking out.
if (!ShouldApplyOverflowClipping(this, StyleDisplay())) {
nsRect bounds(nsPoint(0, 0), GetSize());
WritingMode wm = GetWritingMode();
LogicalMargin bcMargin = GetExcludedOuterBCBorder(wm);
bounds.Inflate(bcMargin.GetPhysicalMargin(wm));
aOverflowAreas.UnionAllWith(bounds);
}
nsOverflowAreas overflowAreas(bounds, bounds);
nsLayoutUtils::UnionChildOverflow(this, overflowAreas);
return FinishAndStoreOverflow(overflowAreas, GetSize());
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
}
void

Просмотреть файл

@ -598,7 +598,7 @@ public:
const nsRect& aOrigVisualOverflow,
bool aIsFirstReflow);
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
protected:

Просмотреть файл

@ -1397,12 +1397,12 @@ nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext,
}
bool
nsTableRowGroupFrame::UpdateOverflow()
nsTableRowGroupFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
// Row cursor invariants depend on the visual overflow area of the rows,
// which may have changed, so we need to clear the cursor now.
ClearRowCursor();
return nsContainerFrame::UpdateOverflow();
return nsContainerFrame::ComputeCustomOverflow(aOverflowAreas);
}
/* virtual */ void

Просмотреть файл

@ -113,7 +113,7 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) override;
virtual bool UpdateOverflow() override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
/**
* Get the "type" of the frame

Просмотреть файл

@ -236,8 +236,7 @@ nsBox::SetXULBounds(nsBoxLayoutState& aState, const nsRect& aRect, bool aRemoveO
nsRect rect(mRect);
uint32_t flags = 0;
GetLayoutFlags(flags);
uint32_t flags = GetXULLayoutFlags();
uint32_t stateFlags = aState.LayoutFlags();
@ -276,13 +275,6 @@ nsBox::SetXULBounds(nsBoxLayoutState& aState, const nsRect& aRect, bool aRemoveO
*/
}
void
nsBox::GetLayoutFlags(uint32_t& aFlags)
{
aFlags = 0;
}
nsresult
nsIFrame::GetXULBorderAndPadding(nsMargin& aBorderAndPadding)
{
@ -542,8 +534,7 @@ nsBox::SyncLayout(nsBoxLayoutState& aState)
nsPresContext* presContext = aState.PresContext();
uint32_t flags = 0;
GetLayoutFlags(flags);
uint32_t flags = GetXULLayoutFlags();
uint32_t stateFlags = aState.LayoutFlags();

Просмотреть файл

@ -88,8 +88,6 @@ protected:
virtual void ListBox(nsAutoString& aResult);
#endif
virtual void GetLayoutFlags(uint32_t& aFlags);
nsresult BeginXULLayout(nsBoxLayoutState& aState);
NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState);

Просмотреть файл

@ -947,10 +947,10 @@ nsMenuPopupFrame::HidePopup(bool aDeselectMenu, nsPopupState aNewState)
}
}
void
nsMenuPopupFrame::GetLayoutFlags(uint32_t& aFlags)
uint32_t
nsMenuPopupFrame::GetXULLayoutFlags()
{
aFlags = NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_MOVE_VIEW | NS_FRAME_NO_VISIBILITY;
return NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_MOVE_VIEW | NS_FRAME_NO_VISIBILITY;
}
///////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -427,7 +427,7 @@ protected:
nsPopupLevel PopupLevel(bool aIsNoAutoHide) const;
// redefine to tell the box system not to move the views.
virtual void GetLayoutFlags(uint32_t& aFlags) override;
virtual uint32_t GetXULLayoutFlags() override;
void InitPositionFromAnchorAlign(const nsAString& aAnchor,
const nsAString& aAlign);