mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-06 08:40:56 +00:00
Bug 1320484 part 1: Improve documentation for debug-only function FrameWantsToBeInAnonymousItem(), & change its arg from nsIAtom* to nsIFrame*. r=mats
This patch doesn't affect behavior at all -- it just refactors the sanity-checking function "FrameWantsToBeInAnonymousItem()", so that the next patch in this series can give it a new special case that checks a state bit on the container frame. This patch renames "parent" to "container" in this function's variable-names, for clarity, because when this function returns true, the flex/grid container is actually NOT expected to be the parent of aFrame. Rather, it's expected to be the grandparent, and the anonymous flex/grid item would be the parent. So, "aContainerFrame"/"containerType" is a bit more accurate (representing the flex/grid container for aFrame). Also worth mentioning: this patch makes FrameWantsToBeInAnonymousItem() perform its own local GetType() call, instead of accepting an already-queried GetType() result from the caller (as it previously did). Technically this could cause a slight perf hit, but it doesn't really matter since this is in "#ifdef DEBUG" sanity-checking code anyway. We could keep the nsIAtom* as an additional arg to avoid this new call, but it seems better to fall on the side of simplicity & just look up GetType() independently, rather than complicating the function signature with an extra arg. MozReview-Commit-ID: 4oJFkQMuH9c --HG-- extra : rebase_source : 3b5d60d8c15e69470f450168698b855e353486d3
This commit is contained in:
parent
67f3a5ff19
commit
3ee9d5690d
@ -10603,13 +10603,30 @@ void nsCSSFrameConstructor::CreateNeededPseudoSiblings(
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* Returns true iff aFrame should be wrapped in an anonymous flex/grid item,
|
||||
* rather than being a direct child of aContainerFrame.
|
||||
*
|
||||
* NOTE: aContainerFrame must be a flex or grid container - this function is
|
||||
* purely for sanity-checking the children of these container types.
|
||||
* NOTE: See also NeedsAnonFlexOrGridItem(), for the non-debug version of this
|
||||
* logic (which operates a bit earlier, on FCData instead of frames).
|
||||
*/
|
||||
static bool
|
||||
FrameWantsToBeInAnonymousItem(const nsIAtom* aParentType, const nsIFrame* aFrame)
|
||||
FrameWantsToBeInAnonymousItem(const nsIFrame* aContainerFrame,
|
||||
const nsIFrame* aFrame)
|
||||
{
|
||||
MOZ_ASSERT(aParentType == nsGkAtoms::flexContainerFrame ||
|
||||
aParentType == nsGkAtoms::gridContainerFrame);
|
||||
nsIAtom* containerType = aContainerFrame->GetType();
|
||||
MOZ_ASSERT(containerType == nsGkAtoms::flexContainerFrame ||
|
||||
containerType == nsGkAtoms::gridContainerFrame);
|
||||
|
||||
return aFrame->IsFrameOfType(nsIFrame::eLineParticipant);
|
||||
// Any line-participant frames (e.g. text) definitely want to be wrapped in
|
||||
// an anonymous flex/grid item.
|
||||
if (aFrame->IsFrameOfType(nsIFrame::eLineParticipant)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -10626,7 +10643,7 @@ VerifyGridFlexContainerChildren(nsIFrame* aParentFrame,
|
||||
|
||||
bool prevChildWasAnonItem = false;
|
||||
for (const nsIFrame* child : aChildren) {
|
||||
MOZ_ASSERT(!FrameWantsToBeInAnonymousItem(parentType, child),
|
||||
MOZ_ASSERT(!FrameWantsToBeInAnonymousItem(aParentFrame, child),
|
||||
"frame wants to be inside an anonymous item, but it isn't");
|
||||
if (IsAnonymousFlexOrGridItem(child)) {
|
||||
AssertAnonymousFlexOrGridItemParent(child, aParentFrame);
|
||||
|
Loading…
x
Reference in New Issue
Block a user