Bug 508665 - part 1, Change the signature of SetParent/GetParent from nsIFrame* to nsContainerFrame*. r=roc

This commit is contained in:
Mats Palmgren 2014-05-24 22:20:39 +00:00
parent 7792c4a45f
commit a6feda0f22
35 changed files with 84 additions and 59 deletions

View File

@ -13,6 +13,7 @@
#include "gfxFont.h"
#include "nsFontMetrics.h"
#include "nsLayoutUtils.h"
#include "nsContainerFrame.h"
#include "HyperTextAccessible.h"
#include "mozilla/AppUnits.h"
#include "mozilla/gfx/2D.h"
@ -364,7 +365,7 @@ TextAttrsMgr::BGColorTextAttr::
return true;
}
nsIFrame *parentFrame = aFrame->GetParent();
nsContainerFrame *parentFrame = aFrame->GetParent();
if (!parentFrame) {
*aColor = aFrame->PresContext()->DefaultBackgroundColor();
return true;

View File

@ -22,7 +22,7 @@
#include "nsFocusManager.h"
#include "nsIDOMRange.h"
#include "nsIEditingSession.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsFrameSelection.h"
#include "nsILineIterator.h"
#include "nsIInterfaceRequestorUtils.h"
@ -1257,7 +1257,7 @@ HyperTextAccessible::CaretLineNumber()
if (hyperTextContent == caretFrame->GetContent()) {
return lineNumber; // Must be in a single line hyper text, there is no line iterator
}
nsIFrame *parentFrame = caretFrame->GetParent();
nsContainerFrame *parentFrame = caretFrame->GetParent();
if (!parentFrame)
break;

View File

@ -18,7 +18,7 @@
#include "nsCOMPtr.h"
#include "mozilla/dom/HTMLOptionElement.h"
#include "nsIComboboxControlFrame.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsIListControlFrame.h"
using namespace mozilla::a11y;

View File

@ -27,7 +27,7 @@
#include "nsIScriptGlobalObject.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
@ -218,7 +218,7 @@ nsIContent::UpdateEditableState(bool aNotify)
if (root) {
nsIFrame* rootFrame = root->GetPrimaryFrame();
if (rootFrame) {
nsIFrame* parentFrame = rootFrame->GetParent();
nsContainerFrame* parentFrame = rootFrame->GetParent();
nsITextControlFrame* textCtrl = do_QueryFrame(parentFrame);
isUnknownNativeAnon = !textCtrl;
}

View File

@ -113,7 +113,7 @@
#include "nsIFormControl.h"
#include "nsIForm.h"
#include "nsIFragmentContentSink.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsIHTMLDocument.h"
#include "nsIIdleService.h"
#include "nsIImageLoadingContent.h"

View File

@ -18,7 +18,7 @@
#include "nsIServiceManager.h"
#include "nsNetUtil.h"
#include "nsContentUtils.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsNodeInfoManager.h"
#include "mozilla/MouseEvents.h"
#include "nsContentPolicyUtils.h"

View File

@ -52,6 +52,7 @@
#include "nsScriptLoader.h"
#include "nsRuleData.h"
#include "nsIPrincipal.h"
#include "nsContainerFrame.h"
#include "nsPresState.h"
#include "nsILayoutHistoryState.h"

View File

@ -5,7 +5,7 @@
#include "ActiveLayerTracker.h"
#include "nsExpirationTracker.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsIContent.h"
#include "nsRefreshDriver.h"
#include "nsPIDOMWindow.h"

View File

@ -13,7 +13,7 @@
#include "mozilla/dom/Element.h"
#include "nsDataHashtable.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "mozilla/SplayTree.h"
namespace mozilla {

View File

@ -70,6 +70,7 @@
#include "RestyleManager.h"
#include "StickyScrollContainer.h"
#include "nsFieldSetFrame.h"
#include "nsInlineFrame.h"
#ifdef MOZ_XUL
#include "nsIRootBox.h"
@ -413,7 +414,7 @@ AnyKidsNeedBlockParent(nsIFrame *aFrameList)
// Reparent a frame into a wrapper frame that is a child of its old parent.
static void
ReparentFrame(RestyleManager* aRestyleManager,
nsIFrame* aNewParentFrame,
nsContainerFrame* aNewParentFrame,
nsIFrame* aFrame)
{
aFrame->SetParent(aNewParentFrame);
@ -422,7 +423,7 @@ ReparentFrame(RestyleManager* aRestyleManager,
static void
ReparentFrames(nsCSSFrameConstructor* aFrameConstructor,
nsIFrame* aNewParentFrame,
nsContainerFrame* aNewParentFrame,
const nsFrameList& aFrameList)
{
RestyleManager* restyleManager = aFrameConstructor->RestyleManager();
@ -1420,7 +1421,7 @@ MoveChildrenTo(nsPresContext* aPresContext,
}
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
e.get()->SetParent(aNewParent);
e.get()->SetParent(static_cast<nsContainerFrame*>(aNewParent)); // XXX static_cast will be removed in a later patch
}
if (aNewParent->PrincipalChildList().IsEmpty() &&
@ -4673,7 +4674,7 @@ nsCSSFrameConstructor::FlushAccumulatedBlock(nsFrameConstructorState& aState,
// then, create a block frame that will wrap the child frames. Make it a
// MathML frame so that Get(Absolute/Float)ContainingBlockFor know that this
// is not a suitable block.
nsIFrame* blockFrame =
nsContainerFrame* blockFrame =
NS_NewMathMLmathBlockFrame(mPresShell, blockContext,
NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
@ -9481,7 +9482,7 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState,
nsRefPtr<nsStyleContext> blockSC = mPresShell->StyleSet()->
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozXULAnonymousBlock,
frameStyleContext);
nsIFrame *blockFrame = NS_NewBlockFrame(mPresShell, blockSC);
nsBlockFrame* blockFrame = NS_NewBlockFrame(mPresShell, blockSC);
// We might, in theory, want to set NS_BLOCK_FLOAT_MGR and
// NS_BLOCK_MARGIN_ROOT, but I think it's a bad idea given that
// a real block placed here wouldn't get those set on it.
@ -9519,7 +9520,7 @@ nsCSSFrameConstructor::WrapFramesInFirstLineFrame(
nsFrameConstructorState& aState,
nsIContent* aBlockContent,
nsIFrame* aBlockFrame,
nsIFrame* aLineFrame,
nsFirstLineFrame* aLineFrame,
nsFrameItems& aFrameItems)
{
// Find the part of aFrameItems that we want to put in the first-line
@ -9598,8 +9599,9 @@ nsCSSFrameConstructor::AppendFirstLineFrames(
return;
}
nsFirstLineFrame* lineFrame = static_cast<nsFirstLineFrame*>(lastBlockKid);
WrapFramesInFirstLineFrame(aState, aBlockContent, aBlockFrame,
lastBlockKid, aFrameItems);
lineFrame, aFrameItems);
}
// Special routine to handle inserting a new frame into a block

View File

@ -29,6 +29,7 @@ struct nsStyleDisplay;
class nsIDOMHTMLSelectElement;
struct nsGenConInitializer;
class nsFirstLineFrame;
class nsICSSAnonBoxPseudo;
class nsPageContentFrame;
struct PendingBinding;
@ -1675,7 +1676,7 @@ private:
void WrapFramesInFirstLineFrame(nsFrameConstructorState& aState,
nsIContent* aBlockContent,
nsIFrame* aBlockFrame,
nsIFrame* aLineFrame,
nsFirstLineFrame* aLineFrame,
nsFrameItems& aFrameItems);
// Handle the case when a block with first-line style is appended to (by

View File

@ -15,7 +15,7 @@
#include "mozilla/Attributes.h"
#include "nsCOMPtr.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsPoint.h"
#include "nsRect.h"
#include "nsCaret.h"

View File

@ -36,6 +36,7 @@
#include "nsFrameManager.h"
#include "GeckoProfiler.h"
#include "nsIStatefulFrame.h"
#include "nsContainerFrame.h"
#ifdef DEBUG
//#define DEBUG_UNDISPLAYED_MAP

View File

@ -8,6 +8,7 @@
#include "nsFrameTraversal.h"
#include "nsFrameList.h"
#include "nsPlaceholderFrame.h"
#include "nsContainerFrame.h"
class nsFrameIterator : public nsIFrameEnumerator

View File

@ -1062,7 +1062,7 @@ nsLayoutUtils::GetChildListNameFor(nsIFrame* aChildFrame)
#ifdef DEBUG
// Verify that the frame is actually in that child list or in the
// corresponding overflow list.
nsIFrame* parent = aChildFrame->GetParent();
nsContainerFrame* parent = aChildFrame->GetParent();
bool found = parent->GetChildList(id).ContainsFrame(aChildFrame);
if (!found) {
if (!(aChildFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {

View File

@ -6,7 +6,9 @@
EXPORTS += [
'nsCanvasFrame.h',
'nsContainerFrame.h',
'nsDirection.h',
'nsFrame.h',
'nsFrameIdList.h',
'nsFrameList.h',
'nsFrameSelection.h',
@ -28,6 +30,7 @@ EXPORTS += [
'nsIStatefulFrame.h',
'nsObjectFrame.h',
'nsQueryFrame.h',
'nsSplittableFrame.h',
'nsSubDocumentFrame.h',
'ScrollbarActivity.h',
'Selection.h',

View File

@ -243,7 +243,7 @@ NS_DECLARE_FRAME_PROPERTY(BottomEdgeOfChildrenProperty, nullptr)
//----------------------------------------------------------------------
nsIFrame*
nsBlockFrame*
NS_NewBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags)
{
nsBlockFrame* it = new (aPresShell) nsBlockFrame(aContext);
@ -523,7 +523,8 @@ nsBlockFrame::IsFloatContainingBlock() const
}
static void
ReparentFrame(nsIFrame* aFrame, nsIFrame* aOldParent, nsIFrame* aNewParent)
ReparentFrame(nsIFrame* aFrame, nsContainerFrame* aOldParent,
nsContainerFrame* aNewParent)
{
NS_ASSERTION(aOldParent == aFrame->GetParent(),
"Parent not consistent with expectations");
@ -536,8 +537,8 @@ ReparentFrame(nsIFrame* aFrame, nsIFrame* aOldParent, nsIFrame* aNewParent)
}
static void
ReparentFrames(nsFrameList& aFrameList, nsIFrame* aOldParent,
nsIFrame* aNewParent)
ReparentFrames(nsFrameList& aFrameList, nsContainerFrame* aOldParent,
nsContainerFrame* aNewParent)
{
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
ReparentFrame(e.get(), aOldParent, aNewParent);

View File

@ -99,7 +99,9 @@ public:
line_iterator line(nsLineBox* aList) { return mLines.begin(aList); }
reverse_line_iterator rline(nsLineBox* aList) { return mLines.rbegin(aList); }
friend nsIFrame* NS_NewBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags);
friend nsBlockFrame* NS_NewBlockFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext,
nsFrameState aFlags);
// nsQueryFrame
NS_DECL_QUERYFRAME

View File

@ -8,7 +8,7 @@
#ifndef nsFontInflationData_h_
#define nsFontInflationData_h_
#include "nsIFrame.h"
#include "nsContainerFrame.h"
struct nsHTMLReflowState;

View File

@ -7486,6 +7486,17 @@ nsIFrame::ComputePreserve3DChildrenOverflow(nsOverflowAreas& aOverflowAreas, con
aOverflowAreas.Overflow(eScrollableOverflow) = aOverflowAreas.Overflow(eScrollableOverflow).Union(childScrollable);
}
uint32_t
nsIFrame::GetDepthInFrameTree() const
{
uint32_t result = 0;
for (nsContainerFrame* ancestor = GetParent(); ancestor;
ancestor = ancestor->GetParent()) {
result++;
}
return result;
}
void
nsFrame::ConsiderChildOverflow(nsOverflowAreas& aOverflowAreas,
nsIFrame* aChildFrame)
@ -8443,7 +8454,7 @@ nsIFrame::RemoveInPopupStateBitFromDescendants(nsIFrame* aFrame)
}
void
nsFrame::SetParent(nsIFrame* aParent)
nsFrame::SetParent(nsContainerFrame* aParent)
{
bool wasBoxWrapped = IsBoxWrapped();
mParent = aParent;

View File

@ -157,7 +157,7 @@ public:
virtual nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE;
virtual void SetAdditionalStyleContext(int32_t aIndex,
nsStyleContext* aStyleContext) MOZ_OVERRIDE;
virtual void SetParent(nsIFrame* aParent) MOZ_OVERRIDE;
virtual void SetParent(nsContainerFrame* aParent) MOZ_OVERRIDE;
virtual nscoord GetBaseline() const MOZ_OVERRIDE;
virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE;
virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE;
@ -603,6 +603,8 @@ public:
aFrame->GetType() == nsGkAtoms::blockFrame;
}
virtual nsILineIterator* GetLineIterator() MOZ_OVERRIDE;
protected:
// Test if we are selecting a table object:
@ -648,8 +650,6 @@ private:
NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState);
virtual nsILineIterator* GetLineIterator() MOZ_OVERRIDE;
#ifdef DEBUG_FRAME_DUMP
public:
/**

View File

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsFrameList.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
@ -314,7 +314,7 @@ nsFrameList::ApplySetParent(nsIFrame* aParent) const
NS_ASSERTION(aParent, "null ptr");
for (nsIFrame* f = FirstChild(); f; f = f->GetNextSibling()) {
f->SetParent(aParent);
f->SetParent(static_cast<nsContainerFrame*>(aParent)); // XXX static_cast will be removed in a later patch
}
}

View File

@ -48,7 +48,8 @@ class nsTableColFrame;
// Factory methods for creating html layout objects
// Create a frame that supports "display: block" layout behavior
nsIFrame*
class nsBlockFrame;
nsBlockFrame*
NS_NewBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags = nsFrameState(0));
// Special Generated Content Node. It contains text taken from an
@ -66,8 +67,8 @@ nsIFrame*
NS_NewSelectsAreaFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags);
// Create a block formatting context blockframe
inline nsIFrame* NS_NewBlockFormattingContext(nsIPresShell* aPresShell,
nsStyleContext* aStyleContext)
inline nsBlockFrame* NS_NewBlockFormattingContext(nsIPresShell* aPresShell,
nsStyleContext* aStyleContext)
{
return NS_NewBlockFrame(aPresShell, aStyleContext,
NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
@ -120,7 +121,8 @@ nsIFrame*
NS_NewPageBreakFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewFirstLetterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
class nsFirstLineFrame;
nsFirstLineFrame*
NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
// forms

View File

@ -82,6 +82,7 @@ class gfxContext;
class nsLineList_iterator;
class nsAbsoluteContainingBlock;
class nsIContent;
class nsContainerFrame;
struct nsPeekOffsetStruct;
struct nsPoint;
@ -672,14 +673,14 @@ public:
/**
* Accessor functions for geometric parent
*/
nsIFrame* GetParent() const { return mParent; }
nsContainerFrame* GetParent() const { return static_cast<nsContainerFrame*>(static_cast<void*>(mParent)); } // XXX static_cast will be removed in a later patch
/**
* Set this frame's parent to aParent.
* If the frame may have moved into or out of a scrollframe's
* frame subtree, StickyScrollContainer::NotifyReparentedFrameAcrossScrollFrameBoundary
* must also be called.
*/
virtual void SetParent(nsIFrame* aParent) = 0;
virtual void SetParent(nsContainerFrame* aParent) = 0;
/**
* The frame's writing-mode, used for logical layout computations.
@ -1296,14 +1297,7 @@ public:
/**
* Returns the number of ancestors between this and the root of our frame tree
*/
uint32_t GetDepthInFrameTree() {
uint32_t result = 0;
for (nsIFrame* ancestor = GetParent(); ancestor;
ancestor = ancestor->GetParent()) {
result++;
}
return result;
}
uint32_t GetDepthInFrameTree() const;
/**
* Event handling of GUI events.

View File

@ -955,7 +955,7 @@ nsInlineFrame::AccessibleType()
// nsLineFrame implementation
nsIFrame*
nsFirstLineFrame*
NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
return new (aPresShell) nsFirstLineFrame(aContext);

View File

@ -187,7 +187,8 @@ class nsFirstLineFrame MOZ_FINAL : public nsInlineFrame {
public:
NS_DECL_FRAMEARENA_HELPERS
friend nsIFrame* NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
friend nsFirstLineFrame* NS_NewFirstLineFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;

View File

@ -1578,7 +1578,7 @@ nsMathMLContainerFrame::ReportInvalidChildError(nsIAtom* aChildTag)
//==========================
nsIFrame*
nsContainerFrame*
NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext,
nsFrameState aFlags)
{
@ -1593,7 +1593,7 @@ NS_QUERYFRAME_HEAD(nsMathMLmathBlockFrame)
NS_QUERYFRAME_ENTRY(nsMathMLmathBlockFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
nsIFrame*
nsContainerFrame*
NS_NewMathMLmathInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
return new (aPresShell) nsMathMLmathInlineFrame(aContext);

View File

@ -411,7 +411,7 @@ public:
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
friend nsIFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell,
friend nsContainerFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext, nsFrameState aFlags);
// beware, mFrames is not set by nsBlockFrame
@ -493,7 +493,8 @@ public:
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
friend nsIFrame* NS_NewMathMLmathInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
friend nsContainerFrame* NS_NewMathMLmathInlineFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
virtual nsresult
SetInitialChildList(ChildListID aListID,

View File

@ -35,9 +35,9 @@ nsIFrame* NS_NewMathMLmactionFrame(nsIPresShell* aPresShell, nsStyleContext* aCo
nsIFrame* NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLsemanticsFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags);
nsIFrame* NS_NewMathMLmathInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
inline nsIFrame* NS_CreateNewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
nsContainerFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags);
nsContainerFrame* NS_NewMathMLmathInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
inline nsContainerFrame* NS_CreateNewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
return NS_NewMathMLmathBlockFrame(aPresShell, aContext, nsFrameState(0));
}

View File

@ -8,6 +8,7 @@
#include "gfxPlatform.h"
#include "mozilla/gfx/2D.h"
#include "imgIContainer.h"
#include "nsContainerFrame.h"
#include "nsIImageLoadingContent.h"
#include "nsLayoutUtils.h"
#include "nsRenderingContext.h"

View File

@ -20,6 +20,7 @@ XPIDL_SOURCES += [
XPIDL_MODULE = 'layout_xul'
EXPORTS += [
'nsBox.h',
'nsIScrollbarMediator.h',
'nsPIBoxObject.h',
'nsXULPopupManager.h',

View File

@ -9,7 +9,7 @@
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsContainerFrame.h"
#include "nsIDocShell.h"
#include "nsReadableUtils.h"
#include "nsDOMClassInfoID.h"

View File

@ -186,7 +186,7 @@ nsMenuFrame::nsMenuFrame(nsIPresShell* aShell, nsStyleContext* aContext):
}
void
nsMenuFrame::SetParent(nsIFrame* aParent)
nsMenuFrame::SetParent(nsContainerFrame* aParent)
{
nsBoxFrame::SetParent(aParent);
InitMenuParent(aParent);

View File

@ -152,7 +152,7 @@ public:
// otherwise null will be returned.
nsMenuFrame* Enter(mozilla::WidgetGUIEvent* aEvent);
virtual void SetParent(nsIFrame* aParent) MOZ_OVERRIDE;
virtual void SetParent(nsContainerFrame* aParent) MOZ_OVERRIDE;
virtual nsMenuParent *GetMenuParent() { return mMenuParent; }
const nsAString& GetRadioGroupName() { return mGroupName; }

View File

@ -4,7 +4,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ContentHelper.h"
#include "nsQueryFrame.h"
#include "nsContainerFrame.h"
#include "nsIContent.h"
#include "nsIScrollableFrame.h"
#include "nsLayoutUtils.h"