Bug 1296516 - Cleanup a bit of code in layout/base

* Tidy RestyleManager::ContentStateChanged
* Convert UndisplayedMap to a typed hashtable
* Cleanup infallible or unchecked nsCSSFrameConstructor methods

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 05:04:10 -04:00 committed by Roy Tam
commit e1195a86e0
13 changed files with 358 additions and 459 deletions

View file

@ -48,7 +48,7 @@ class FlattenedChildIterator;
} // namespace dom
} // namespace mozilla
class nsCSSFrameConstructor : public nsFrameManager
class nsCSSFrameConstructor final : public nsFrameManager
{
public:
typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
@ -60,7 +60,7 @@ public:
nsCSSFrameConstructor(nsIDocument* aDocument, nsIPresShell* aPresShell);
~nsCSSFrameConstructor(void) {
NS_ASSERTION(mUpdateCount == 0, "Dying in the middle of our own update?");
MOZ_ASSERT(mUpdateCount == 0, "Dying in the middle of our own update?");
}
// get the alternate text for a content node
@ -78,7 +78,7 @@ public:
nsIFrame* ConstructRootFrame();
nsresult ReconstructDocElementHierarchy();
void ReconstructDocElementHierarchy();
// Create frames for content nodes that are marked as needing frames. This
// should be called before ProcessPendingRestyles.
@ -202,16 +202,16 @@ public:
// If aAllowLazyConstruction is true then frame construction of the new
// children can be done lazily.
nsresult ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent,
bool aAllowLazyConstruction);
void ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent,
bool aAllowLazyConstruction);
// If aAllowLazyConstruction is true then frame construction of the new child
// can be done lazily.
nsresult ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
nsILayoutHistoryState* aFrameState,
bool aAllowLazyConstruction);
void ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
nsILayoutHistoryState* aFrameState,
bool aAllowLazyConstruction);
// Like ContentInserted but handles inserting the children of aContainer in
// the range [aStartChild, aEndChild). aStartChild must be non-null.
@ -219,11 +219,11 @@ public:
// aStartChild. If aAllowLazyConstruction is true then frame construction of
// the new children can be done lazily. It is only allowed to be true when
// inserting a single node.
nsresult ContentRangeInserted(nsIContent* aContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
nsILayoutHistoryState* aFrameState,
bool aAllowLazyConstruction);
void ContentRangeInserted(nsIContent* aContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
nsILayoutHistoryState* aFrameState,
bool aAllowLazyConstruction);
enum RemoveFlags {
REMOVE_CONTENT, REMOVE_FOR_RECONSTRUCTION, REMOVE_DESTROY_FRAMES };
@ -243,15 +243,15 @@ public:
* only when aFlags == REMOVE_DESTROY_FRAMES, otherwise it will only be
* captured if we reconstructed frames for an ancestor.
*/
nsresult ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
nsIContent* aOldNextSibling,
RemoveFlags aFlags,
bool* aDidReconstruct,
nsIContent** aDestroyedFramesFor = nullptr);
void ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
nsIContent* aOldNextSibling,
RemoveFlags aFlags,
bool* aDidReconstruct,
nsIContent** aDestroyedFramesFor = nullptr);
nsresult CharacterDataChanged(nsIContent* aContent,
CharacterDataChangeInfo* aInfo);
void CharacterDataChanged(nsIContent* aContent,
CharacterDataChangeInfo* aInfo);
// If aContent is a text node that has been optimized away due to being
// whitespace next to a block boundary (or for some other reason), stop
@ -260,8 +260,8 @@ public:
// Returns the frame for aContent if there is one.
nsIFrame* EnsureFrameForTextNode(nsGenericDOMDataNode* aContent);
// generate the child frames and process bindings
nsresult GenerateChildFrames(nsContainerFrame* aFrame);
// Generate the child frames and process bindings
void GenerateChildFrames(nsContainerFrame* aFrame);
// Should be called when a frame is going to be destroyed and
// WillDestroyFrameTree hasn't been called yet.
@ -303,11 +303,11 @@ public:
*/
InsertionPoint GetInsertionPoint(nsIContent* aContainer, nsIContent* aChild);
nsresult CreateListBoxContent(nsContainerFrame* aParentFrame,
nsIFrame* aPrevFrame,
nsIContent* aChild,
nsIFrame** aResult,
bool aIsAppend);
void CreateListBoxContent(nsContainerFrame* aParentFrame,
nsIFrame* aPrevFrame,
nsIContent* aChild,
nsIFrame** aResult,
bool aIsAppend);
// GetInitialContainingBlock() is deprecated in favor of GetRootElementFrame();
// nsIFrame* GetInitialContainingBlock() { return mRootElementFrame; }
@ -419,14 +419,14 @@ private:
* @param [out] aNewContent the content node we create
* @param [out] aNewFrame the new frame we create
*/
nsresult CreateAttributeContent(nsIContent* aParentContent,
nsIFrame* aParentFrame,
int32_t aAttrNamespace,
nsIAtom* aAttrName,
nsStyleContext* aStyleContext,
nsCOMArray<nsIContent>& aGeneratedContent,
nsIContent** aNewContent,
nsIFrame** aNewFrame);
void CreateAttributeContent(nsIContent* aParentContent,
nsIFrame* aParentFrame,
int32_t aAttrNamespace,
nsIAtom* aAttrName,
nsStyleContext* aStyleContext,
nsCOMArray<nsIContent>& aGeneratedContent,
nsIContent** aNewContent,
nsIFrame** aNewFrame);
/**
* Create a text node containing the given string. If aText is non-null
@ -464,11 +464,11 @@ private:
// aParentFrame. aPrevSibling must be the frame after which aFrameList is to
// be placed on aParentFrame's principal child list. It may be null if
// aFrameList is being added at the beginning of the child list.
nsresult AppendFramesToParent(nsFrameConstructorState& aState,
nsContainerFrame* aParentFrame,
nsFrameItems& aFrameList,
nsIFrame* aPrevSibling,
bool aIsRecursiveCall = false);
void AppendFramesToParent(nsFrameConstructorState& aState,
nsContainerFrame* aParentFrame,
nsFrameItems& aFrameList,
nsIFrame* aPrevSibling,
bool aIsRecursiveCall = false);
// BEGIN TABLE SECTION
/**
@ -1692,7 +1692,7 @@ private:
// InitializeSelectFrame puts scrollFrame in aFrameItems if aBuildCombobox is false
// aBuildCombobox indicates if we are building a combobox that has a dropdown
// popup widget or not.
nsresult
void
InitializeSelectFrame(nsFrameConstructorState& aState,
nsContainerFrame* aScrollFrame,
nsContainerFrame* aScrolledFrame,
@ -1721,7 +1721,7 @@ private:
* @param aDestroyedFramesFor if non-null, it will contain the content that
* was actually reframed - it may be different than aContent.
*/
nsresult
void
RecreateFramesForContent(nsIContent* aContent,
bool aAsyncInsert,
RemoveFlags aFlags,
@ -1739,7 +1739,6 @@ private:
// content that was reframed.
bool MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
RemoveFlags aFlags,
nsresult* aResult,
nsIContent** aDestroyedFramesFor);
nsIFrame* CreateContinuingOuterTableFrame(nsIPresShell* aPresShell,
@ -1864,9 +1863,9 @@ private:
bool aIsAppend,
nsIFrame* aPrevSibling);
nsresult ReframeContainingBlock(nsIFrame* aFrame,
RemoveFlags aFlags,
nsIContent** aReframeContent);
void ReframeContainingBlock(nsIFrame* aFrame,
RemoveFlags aFlags,
nsIContent** aReframeContent);
//----------------------------------------
@ -1920,18 +1919,18 @@ private:
void RecoverLetterFrames(nsContainerFrame* aBlockFrame);
//
nsresult RemoveLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* aBlockFrame);
void RemoveLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* aBlockFrame);
// Recursive helper for RemoveLetterFrames
nsresult RemoveFirstLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* aFrame,
nsContainerFrame* aBlockFrame,
bool* aStopLooking);
void RemoveFirstLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* aFrame,
nsContainerFrame* aBlockFrame,
bool* aStopLooking);
// Special remove method for those pesky floating first-letter frames
nsresult RemoveFloatingFirstLetterFrames(nsIPresShell* aPresShell,
nsIFrame* aBlockFrame);
void RemoveFloatingFirstLetterFrames(nsIPresShell* aPresShell,
nsIFrame* aBlockFrame);
// Capture state for the frame tree rooted at the frame associated with the
// content object, aContent
@ -1962,12 +1961,12 @@ private:
nsContainerFrame* aBlockFrame,
nsFrameItems& aFrameItems);
nsresult InsertFirstLineFrames(nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aBlockFrame,
nsContainerFrame** aParentFrame,
nsIFrame* aPrevSibling,
nsFrameItems& aFrameItems);
void InsertFirstLineFrames(nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aBlockFrame,
nsContainerFrame** aParentFrame,
nsIFrame* aPrevSibling,
nsFrameItems& aFrameItems);
/**
* Find the right frame to use for aContent when looking for sibling