Skip to content

Commit

Permalink
Bug 1015781 - part 3, Fix whitespace and comments, and move some SetI…
Browse files Browse the repository at this point in the history
…nitialChildList/AppendFrames/InsertFrames/RemoveFrame methods so that they are together in the file. r=roc
  • Loading branch information
MatsPalmgren committed May 28, 2014
1 parent f08f841 commit 6ae2bb8
Show file tree
Hide file tree
Showing 29 changed files with 260 additions and 324 deletions.
2 changes: 1 addition & 1 deletion layout/forms/nsComboboxControlFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class nsComboboxControlFrame : public nsBlockFrame,
#endif
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
virtual void SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) MOZ_OVERRIDE;
nsFrameList& aChildList) MOZ_OVERRIDE;
virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE;
virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE;

Expand Down
10 changes: 5 additions & 5 deletions layout/forms/nsFieldSetFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class nsFieldSetFrame MOZ_FINAL : public nsContainerFrame
nsPoint aPt, const nsRect& aDirtyRect, uint32_t aBGFlags);

virtual void AppendFrames(ChildListID aListID,
nsFrameList& aFrameList) MOZ_OVERRIDE;
nsFrameList& aFrameList) MOZ_OVERRIDE;
virtual void InsertFrames(ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList) MOZ_OVERRIDE;
nsIFrame* aPrevFrame,
nsFrameList& aFrameList) MOZ_OVERRIDE;
virtual void RemoveFrame(ChildListID aListID,
nsIFrame* aOldFrame) MOZ_OVERRIDE;
nsIFrame* aOldFrame) MOZ_OVERRIDE;

virtual nsIAtom* GetType() const MOZ_OVERRIDE;
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
Expand All @@ -70,7 +70,7 @@ class nsFieldSetFrame MOZ_FINAL : public nsContainerFrame

#ifdef DEBUG
virtual void SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) MOZ_OVERRIDE;
nsFrameList& aChildList) MOZ_OVERRIDE;
#endif

#ifdef DEBUG_FRAME_DUMP
Expand Down
8 changes: 4 additions & 4 deletions layout/forms/nsHTMLButtonControlFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class nsHTMLButtonControlFrame : public nsContainerFrame,
nsStyleContext* aStyleContext) MOZ_OVERRIDE;

virtual void AppendFrames(ChildListID aListID,
nsFrameList& aFrameList) MOZ_OVERRIDE;
nsFrameList& aFrameList) MOZ_OVERRIDE;

virtual void InsertFrames(ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList) MOZ_OVERRIDE;
nsIFrame* aPrevFrame,
nsFrameList& aFrameList) MOZ_OVERRIDE;

virtual void RemoveFrame(ChildListID aListID,
nsIFrame* aOldFrame) MOZ_OVERRIDE;
nsIFrame* aOldFrame) MOZ_OVERRIDE;

#ifdef ACCESSIBILITY
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
Expand Down
2 changes: 1 addition & 1 deletion layout/forms/nsListControlFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class nsListControlFrame : public nsHTMLScrollFrame,
nsEventStatus* aEventStatus) MOZ_OVERRIDE;

virtual void SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) MOZ_OVERRIDE;
nsFrameList& aChildList) MOZ_OVERRIDE;

virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
Expand Down
4 changes: 1 addition & 3 deletions layout/forms/nsTextControlFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ class nsTextControlFrame : public nsContainerFrame,
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
uint32_t aFilter) MOZ_OVERRIDE;

// Utility methods to set current widget state

virtual void SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) MOZ_OVERRIDE;
nsFrameList& aChildList) MOZ_OVERRIDE;

virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
Expand Down
14 changes: 7 additions & 7 deletions layout/generic/nsAbsoluteContainingBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ class nsAbsoluteContainingBlock
}

void SetInitialChildList(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsFrameList& aChildList);
ChildListID aListID,
nsFrameList& aChildList);
void AppendFrames(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsFrameList& aFrameList);
ChildListID aListID,
nsFrameList& aFrameList);
void InsertFrames(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList);
ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList);
void RemoveFrame(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsIFrame* aOldFrame);
Expand Down
210 changes: 105 additions & 105 deletions layout/generic/nsBlockFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,62 @@ using namespace mozilla;
using namespace mozilla::css;
using namespace mozilla::layout;

static void MarkAllDescendantLinesDirty(nsBlockFrame* aBlock)
{
nsLineList::iterator line = aBlock->begin_lines();
nsLineList::iterator endLine = aBlock->end_lines();
while (line != endLine) {
if (line->IsBlock()) {
nsIFrame* f = line->mFirstChild;
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(f);
if (bf) {
MarkAllDescendantLinesDirty(bf);
}
}
line->MarkDirty();
++line;
}
}

static void MarkSameFloatManagerLinesDirty(nsBlockFrame* aBlock)
{
nsBlockFrame* blockWithFloatMgr = aBlock;
while (!(blockWithFloatMgr->GetStateBits() & NS_BLOCK_FLOAT_MGR)) {
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(blockWithFloatMgr->GetParent());
if (!bf) {
break;
}
blockWithFloatMgr = bf;
}

// Mark every line at and below the line where the float was
// dirty, and mark their lines dirty too. We could probably do
// something more efficient --- e.g., just dirty the lines that intersect
// the float vertically.
MarkAllDescendantLinesDirty(blockWithFloatMgr);
}

/**
* Returns true if aFrame is a block that has one or more float children.
*/
static bool BlockHasAnyFloats(nsIFrame* aFrame)
{
nsBlockFrame* block = nsLayoutUtils::GetAsBlock(aFrame);
if (!block)
return false;
if (block->GetFirstChild(nsIFrame::kFloatList))
return true;

nsLineList::iterator line = block->begin_lines();
nsLineList::iterator endLine = block->end_lines();
while (line != endLine) {
if (line->IsBlock() && BlockHasAnyFloats(line->mFirstChild))
return true;
++line;
}
return false;
}

#ifdef DEBUG
#include "nsBlockDebugFlags.h"

Expand Down Expand Up @@ -2446,23 +2502,6 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
#endif
}

static void MarkAllDescendantLinesDirty(nsBlockFrame* aBlock)
{
nsLineList::iterator line = aBlock->begin_lines();
nsLineList::iterator endLine = aBlock->end_lines();
while (line != endLine) {
if (line->IsBlock()) {
nsIFrame* f = line->mFirstChild;
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(f);
if (bf) {
MarkAllDescendantLinesDirty(bf);
}
}
line->MarkDirty();
++line;
}
}

void
nsBlockFrame::MarkLineDirtyForInterrupt(nsLineBox* aLine)
{
Expand Down Expand Up @@ -4742,6 +4781,55 @@ nsBlockFrame::InsertFrames(ChildListID aListID,
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
}

void
nsBlockFrame::RemoveFrame(ChildListID aListID,
nsIFrame* aOldFrame)
{
#ifdef NOISY_REFLOW_REASON
ListTag(stdout);
printf(": remove ");
nsFrame::ListTag(stdout, aOldFrame);
printf("\n");
#endif

if (aListID == kPrincipalList) {
bool hasFloats = BlockHasAnyFloats(aOldFrame);
DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS);
if (hasFloats) {
MarkSameFloatManagerLinesDirty(this);
}
}
else if (kAbsoluteList == aListID) {
nsContainerFrame::RemoveFrame(aListID, aOldFrame);
return;
}
else if (kFloatList == aListID) {
// Make sure to mark affected lines dirty for the float frame
// we are removing; this way is a bit messy, but so is the rest of the code.
// See bug 390762.
NS_ASSERTION(!aOldFrame->GetPrevContinuation(),
"RemoveFrame should not be called on pushed floats.");
for (nsIFrame* f = aOldFrame;
f && !(f->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER);
f = f->GetNextContinuation()) {
MarkSameFloatManagerLinesDirty(static_cast<nsBlockFrame*>(f->GetParent()));
}
DoRemoveOutOfFlowFrame(aOldFrame);
}
else if (kNoReflowPrincipalList == aListID) {
// Skip the call to |FrameNeedsReflow| below by returning now.
DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS);
return;
}
else {
MOZ_CRASH("unexpected child list");
}

PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
}

static bool
ShouldPutNextSiblingOnNewLine(nsIFrame* aLastFrame)
{
Expand Down Expand Up @@ -4942,94 +5030,6 @@ nsBlockFrame::RemoveFloat(nsIFrame* aFloat)
}
}

static void MarkSameFloatManagerLinesDirty(nsBlockFrame* aBlock)
{
nsBlockFrame* blockWithFloatMgr = aBlock;
while (!(blockWithFloatMgr->GetStateBits() & NS_BLOCK_FLOAT_MGR)) {
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(blockWithFloatMgr->GetParent());
if (!bf) {
break;
}
blockWithFloatMgr = bf;
}

// Mark every line at and below the line where the float was
// dirty, and mark their lines dirty too. We could probably do
// something more efficient --- e.g., just dirty the lines that intersect
// the float vertically.
MarkAllDescendantLinesDirty(blockWithFloatMgr);
}

/**
* Returns true if aFrame is a block that has one or more float children.
*/
static bool BlockHasAnyFloats(nsIFrame* aFrame)
{
nsBlockFrame* block = nsLayoutUtils::GetAsBlock(aFrame);
if (!block)
return false;
if (block->GetFirstChild(nsIFrame::kFloatList))
return true;

nsLineList::iterator line = block->begin_lines();
nsLineList::iterator endLine = block->end_lines();
while (line != endLine) {
if (line->IsBlock() && BlockHasAnyFloats(line->mFirstChild))
return true;
++line;
}
return false;
}

void
nsBlockFrame::RemoveFrame(ChildListID aListID,
nsIFrame* aOldFrame)
{
#ifdef NOISY_REFLOW_REASON
ListTag(stdout);
printf(": remove ");
nsFrame::ListTag(stdout, aOldFrame);
printf("\n");
#endif

if (aListID == kPrincipalList) {
bool hasFloats = BlockHasAnyFloats(aOldFrame);
DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS);
if (hasFloats) {
MarkSameFloatManagerLinesDirty(this);
}
}
else if (kAbsoluteList == aListID) {
nsContainerFrame::RemoveFrame(aListID, aOldFrame);
return;
}
else if (kFloatList == aListID) {
// Make sure to mark affected lines dirty for the float frame
// we are removing; this way is a bit messy, but so is the rest of the code.
// See bug 390762.
NS_ASSERTION(!aOldFrame->GetPrevContinuation(),
"RemoveFrame should not be called on pushed floats.");
for (nsIFrame* f = aOldFrame;
f && !(f->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER);
f = f->GetNextContinuation()) {
MarkSameFloatManagerLinesDirty(static_cast<nsBlockFrame*>(f->GetParent()));
}
DoRemoveOutOfFlowFrame(aOldFrame);
}
else if (kNoReflowPrincipalList == aListID) {
// Skip the call to |FrameNeedsReflow| below by returning now.
DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS);
return;
}
else {
MOZ_CRASH("unexpected child list");
}

PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
}

void
nsBlockFrame::DoRemoveOutOfFlowFrame(nsIFrame* aFrame)
{
Expand Down
16 changes: 8 additions & 8 deletions layout/generic/nsBlockFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ class nsBlockFrame : public nsBlockFrameSuper
nsContainerFrame* aParent,
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
virtual void SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) MOZ_OVERRIDE;
virtual void AppendFrames(ChildListID aListID,
nsFrameList& aFrameList) MOZ_OVERRIDE;
virtual void InsertFrames(ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList) MOZ_OVERRIDE;
virtual void RemoveFrame(ChildListID aListID,
nsIFrame* aOldFrame) MOZ_OVERRIDE;
nsFrameList& aChildList) MOZ_OVERRIDE;
virtual void AppendFrames(ChildListID aListID,
nsFrameList& aFrameList) MOZ_OVERRIDE;
virtual void InsertFrames(ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList) MOZ_OVERRIDE;
virtual void RemoveFrame(ChildListID aListID,
nsIFrame* aOldFrame) MOZ_OVERRIDE;
virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE;
virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE;
virtual nscoord GetBaseline() const MOZ_OVERRIDE;
Expand Down
10 changes: 5 additions & 5 deletions layout/generic/nsCanvasFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class nsCanvasFrame : public nsContainerFrame,
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;

virtual void SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) MOZ_OVERRIDE;
nsFrameList& aChildList) MOZ_OVERRIDE;
virtual void AppendFrames(ChildListID aListID,
nsFrameList& aFrameList) MOZ_OVERRIDE;
nsFrameList& aFrameList) MOZ_OVERRIDE;
virtual void InsertFrames(ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList) MOZ_OVERRIDE;
nsIFrame* aPrevFrame,
nsFrameList& aFrameList) MOZ_OVERRIDE;
virtual void RemoveFrame(ChildListID aListID,
nsIFrame* aOldFrame) MOZ_OVERRIDE;
nsIFrame* aOldFrame) MOZ_OVERRIDE;

virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
Expand Down
Loading

0 comments on commit 6ae2bb8

Please sign in to comment.