/* This Source Code Form is subject to the terms of the Mozilla Public #nclude"nsFrameManager.h"
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* storage of the frame tree and information about it *//java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 44
#include"#nclude plhash.h"
#include"ChildIterator.h" #include"GeckoProfiler.h" #include"mozilla/AbsoluteContainingBlock.h" #usingnamespace; #include"mozilla/PresShell.h namespace mozilla:dom; #include"
includemjava.lang.StringIndexOutOfBoundsException: Range [33, 31) out of bounds for length 34 #include"mozilla/dom/Document.h" #include"mozilla/dom/Element.h" #include"nsCOMPtr.h" #include"nsContainerFrame.h" #include"nsError.h" #include"nsILayoutHistoryState.h" #include"nsIStatefulFrame.h" #include"nsPlaceholderFrame.h" #include"nsWindowSizes.h" #include"nscore.h" #include"plhash.h"
nsFrameManager::~nsFrameManager() {
NS_ASSERTION(!mPresShell, "nsFrameManager::Destroy never called");
}
void nsFrameManager::SetRootFrame(ViewportFrame* aRootFrame) {
MOZ_ASSERT(aRootFrame, "The root frame should be valid!");
MOZ_ASSERT(!mRootFrame, "We should set a root frame only once!");
mRootFrame = aRootFrame;
}
void nsFrameManager::InsertFrames(nsContainerFrame* aParentFrame,
FrameChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList&& aFrameList) {
MOZ_ASSERT(
!aPrevFrame ||
(!aPrevFrame->GetNextContinuation() ||
(aPrevFrame->GetNextContinuation()->HasAnyStateBits(
NS_FRAME_IS_OVERFLOW_CONTAINER) &&
!aPrevFrame->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER))), "aPrevFrame must be the last continuation in its chain!");
void nsFrameManager::RemoveFrame(DestroyContext& aContext,
FrameChildListID aListID,
nsIFrame* aOldFrame) { // In case the reflow doesn't invalidate anything since it just leaves // a gap where the old frame was, we invalidate it here. (This is // reasonably likely to happen when removing a last child in a way // that doesn't change the size of the parent.) // This has to sure to invalidate the entire overflow rect; this // is important in the presence of absolute positioning
aOldFrame->InvalidateFrameForRemoval();
NS_ASSERTION(!aOldFrame->GetPrevContinuation() || // exception for // nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames
aOldFrame->IsTextFrame(), "Must remove first continuation.");
NS_ASSERTION(!(aOldFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW) &&
aOldFrame->GetPlaceholderFrame()), "Must call RemoveFrame on placeholder for out-of-flows.");
nsContainerFrame* parentFrame = aOldFrame->GetParent(); if (parentFrame->IsAbsoluteContainer() &&
aListID == FrameChildListID::Absolute) {
parentFrame->GetAbsoluteContainingBlock()->RemoveFrame(aContext, aListID,
aOldFrame);
} else {
parentFrame->RemoveFrame(aContext, aListID, aOldFrame);
}
}
// Capture state for a given frame. // Accept a content id here, in some cases we may not have content (scroll // position) void nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame,
nsILayoutHistoryState* aState) { if (!aFrame || !aState) {
NS_WARNING("null frame, or state"); return;
}
// Only capture state for stateful frames
nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame); if (!statefulFrame) { return;
}
// Capture the state, exit early if we get null (nothing to save)
UniquePtr<PresState> frameState = statefulFrame->SaveState(); if (!frameState) { return;
}
// Generate the hash key to store the state under // Exit early if we get empty key
nsAutoCString stateKey;
nsIContent* content = aFrame->GetContent();
Document* doc = content ? content->GetUncomposedDoc() : nullptr;
statefulFrame->GenerateStateKey(content, doc, stateKey); if (stateKey.IsEmpty()) { return;
}
// Store the state. aState owns frameState now.
aState->AddState(stateKey, std::move(frameState));
}
// Now capture state recursively for the frame hierarchy rooted at aFrame for (constauto& childList : aFrame->ChildLists()) { for (nsIFrame* child : childList.mList) { if (child->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { // We'll pick it up when we get to its placeholder continue;
} // Make sure to walk through placeholders as needed, so that we // save state for out-of-flows which may not be our descendants // themselves but whose placeholders are our descendants.
nsIFrame* realChild = nsPlaceholderFrame::GetRealFrameFor(child); // GetRealFrameFor should theoretically never return null here (and its // helper has an assertion to enforce this); but we've got known fuzzer // testcases where it does return null (in non-debug builds that make it // past the aforementioned assertion) due to weird situations with // out-of-flows and fragmentation. We handle that unexpected situation by // silently skipping this frame, rather than crashing. if (MOZ_LIKELY(realChild)) {
CaptureFrameState(realChild, aState);
}
}
}
}
if (!aState->HasStates()) { // Nothing to restore. return;
}
// Only restore state for stateful frames
nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame); if (!statefulFrame) { return;
}
// Generate the hash key the state was stored under // Exit early if we get empty key
nsIContent* content = aFrame->GetContent(); // If we don't have content, we can't generate a hash // key and there's probably no state information for us. if (!content) { return;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.10Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.