Bug 500882 part 5. Switch layout module to using the new GetPrimaryFrame API. r=roc

This commit is contained in:
Boris Zbarsky 2009-12-24 16:20:06 -05:00
Родитель d39e948da2
Коммит 6e5cc7e838
34 изменённых файлов: 149 добавлений и 225 удалений

Просмотреть файл

@ -5450,7 +5450,7 @@ nsIFrame*
nsCSSFrameConstructor::GetFrameFor(nsIContent* aContent)
{
// Get the primary frame associated with the content
nsIFrame* frame = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* frame = aContent->GetPrimaryFrame();
if (!frame)
return nsnull;
@ -5827,14 +5827,14 @@ nsCSSFrameConstructor::FindFrameForContentSibling(nsIContent* aContent,
PRUint8& aTargetContentDisplay,
PRBool aPrevSibling)
{
nsIFrame* sibling = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* sibling = aContent->GetPrimaryFrame();
if (!sibling || sibling->GetContent() != aContent) {
// XXX the GetContent() != aContent check is needed due to bug 135040.
// Remove it once that's fixed.
return nsnull;
}
// If the frame is out-of-flow, GPFF() will have returned the
// If the frame is out-of-flow, GetPrimaryFrame() will have returned the
// out-of-flow frame; we want the placeholder.
if (sibling->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
nsIFrame* placeholderFrame;
@ -6075,7 +6075,7 @@ nsCSSFrameConstructor::AddTextItemIfNeeded(nsFrameConstructorState& aState,
// NS_CREATE_FRAME_IF_NON_WHITESPACE flag)
return;
}
NS_ASSERTION(!mPresShell->GetPrimaryFrameFor(content),
NS_ASSERTION(!content->GetPrimaryFrame(),
"Text node has a frame and NS_CREATE_FRAME_IF_NON_WHITESPACE");
AddFrameConstructionItems(aState, content, aContentIndex, aParentFrame, aItems);
}
@ -6095,7 +6095,7 @@ nsCSSFrameConstructor::ReframeTextIfNeeded(nsIContent* aParentContent,
// NS_CREATE_FRAME_IF_NON_WHITESPACE flag)
return;
}
NS_ASSERTION(!mPresShell->GetPrimaryFrameFor(content),
NS_ASSERTION(!content->GetPrimaryFrame(),
"Text node has a frame and NS_CREATE_FRAME_IF_NON_WHITESPACE");
ContentInserted(aParentContent, content, aContentIndex, nsnull);
}
@ -6190,7 +6190,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
PRUint32 containerCount = aContainer->GetChildCount();
for (PRUint32 i = aNewIndexInContainer; i < containerCount; i++) {
nsIContent* content = aContainer->GetChildAt(i);
if ((mPresShell->GetPrimaryFrameFor(content) ||
if ((content->GetPrimaryFrame() ||
mPresShell->FrameManager()->GetUndisplayedContent(content))
#ifdef MOZ_XUL
// Except listboxes suck, so do NOT skip anything here if
@ -6886,8 +6886,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
nsresult rv = NS_OK;
// Find the child frame that maps the content
nsIFrame* childFrame =
frameManager->GetPrimaryFrameFor(aChild, aIndexInContainer);
nsIFrame* childFrame = aChild->GetPrimaryFrame();
if (!childFrame || childFrame->GetContent() != aChild) {
// XXXbz the GetContent() != aChild check is needed due to bug 135040.
@ -7006,7 +7005,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
containingBlock);
// Recover childFrame and parentFrame
childFrame = mPresShell->GetPrimaryFrameFor(aChild);
childFrame = aChild->GetPrimaryFrame();
if (!childFrame || childFrame->GetContent() != aChild) {
// XXXbz the GetContent() != aChild check is needed due to bug 135040.
// Remove it once that's fixed.
@ -7360,7 +7359,7 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
(aContent->HasFlag(NS_REFRAME_IF_WHITESPACE) &&
aContent->TextIsOnlyWhitespace())) {
#ifdef DEBUG
nsIFrame* frame = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* frame = aContent->GetPrimaryFrame();
NS_ASSERTION(!frame || !frame->IsGeneratedContentFrame(),
"Bit should never be set on generated content");
#endif
@ -7371,7 +7370,7 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
}
// Find the child frame
nsIFrame* frame = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* frame = aContent->GetPrimaryFrame();
// Notify the first frame that maps the content. It will generate a reflow
// command
@ -7405,7 +7404,7 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
mPresShell->FrameManager(), block);
// Reget |frame|, since we might have killed it.
// Do we really need to call CharacterDataChanged in this case, though?
frame = mPresShell->GetPrimaryFrameFor(aContent);
frame = aContent->GetPrimaryFrame();
NS_ASSERTION(frame, "Should have frame here!");
}
}
@ -7537,7 +7536,7 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
#ifdef DEBUG
// reget frame from content since it may have been regenerated...
if (changeData->mContent) {
nsIFrame* frame = mPresShell->GetPrimaryFrameFor(changeData->mContent);
nsIFrame* frame = changeData->mContent->GetPrimaryFrame();
if (frame) {
mPresShell->FrameManager()->DebugVerifyStyleTree(frame);
}
@ -7556,7 +7555,7 @@ nsCSSFrameConstructor::RestyleElement(nsIContent *aContent,
nsIFrame *aPrimaryFrame,
nsChangeHint aMinHint)
{
NS_ASSERTION(aPrimaryFrame == mPresShell->GetPrimaryFrameFor(aContent),
NS_ASSERTION(aPrimaryFrame == aContent->GetPrimaryFrame(),
"frame/content mismatch");
if (aPrimaryFrame && aPrimaryFrame->GetContent() != aContent) {
// XXXbz this is due to image maps messing with the primary frame pointer
@ -7593,7 +7592,7 @@ nsCSSFrameConstructor::RestyleLaterSiblings(nsIContent *aContent)
if (!child->IsNodeOfType(nsINode::eELEMENT))
continue;
nsIFrame* primaryFrame = mPresShell->GetPrimaryFrameFor(child);
nsIFrame* primaryFrame = child->GetPrimaryFrame();
RestyleElement(child, primaryFrame, NS_STYLE_HINT_NONE);
}
}
@ -7624,7 +7623,7 @@ nsCSSFrameConstructor::DoContentStateChanged(nsIContent* aContent,
// based on content states, so if we already don't have a frame we don't
// need to force a reframe -- if it's needed, the HasStateDependentStyle
// call will handle things.
nsIFrame* primaryFrame = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* primaryFrame = aContent->GetPrimaryFrame();
if (primaryFrame) {
// If it's generated content, ignore LOADING/etc state changes on it.
if (!primaryFrame->IsGeneratedContentFrame() &&
@ -7684,7 +7683,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent,
nsCOMPtr<nsIPresShell> shell = mPresShell;
// Get the frame associated with the content which is the highest in the frame tree
nsIFrame* primaryFrame = shell->GetPrimaryFrameFor(aContent);
nsIFrame* primaryFrame = aContent->GetPrimaryFrame();
#if 0
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
@ -8315,7 +8314,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIFrame* aParentFrame,
}
if (insertionElement) {
nsIFrame* insertionPoint = mPresShell->GetPrimaryFrameFor(insertionElement);
nsIFrame* insertionPoint = insertionElement->GetPrimaryFrame();
if (insertionPoint) {
// Use the content insertion frame of the insertion point.
insertionPoint = insertionPoint->GetContentInsertionFrame();
@ -8347,7 +8346,7 @@ nsresult
nsCSSFrameConstructor::CaptureStateForFramesOf(nsIContent* aContent,
nsILayoutHistoryState* aHistoryState)
{
nsIFrame* frame = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame == mRootElementFrame) {
frame = mFixedContainingBlock;
}
@ -8418,7 +8417,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
NS_PRECONDITION(aFrame->GetParent(), "Frame shouldn't be root");
NS_PRECONDITION(aResult, "Null out param?");
NS_PRECONDITION(aFrame == aFrame->GetFirstContinuation(),
"aFrame not the result of GetPrimaryFrameFor()?");
"aFrame not the result of GetPrimaryFrame()?");
if (IsFrameSpecial(aFrame)) {
// The removal functions can't handle removal of an {ib} split directly; we
@ -8544,13 +8543,13 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
// below!). We'd really like to optimize away one of those
// containing block reframes, hence the code here.
nsIFrame* frame = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame && frame->IsFrameOfType(nsIFrame::eMathML)) {
// Reframe the topmost MathML element to prevent exponential blowup
// (see bug 397518)
while (PR_TRUE) {
nsIContent* parentContent = aContent->GetParent();
nsIFrame* parentContentFrame = mPresShell->GetPrimaryFrameFor(parentContent);
nsIFrame* parentContentFrame = parentContent->GetPrimaryFrame();
if (!parentContentFrame || !parentContentFrame->IsFrameOfType(nsIFrame::eMathML))
break;
aContent = parentContent;
@ -8608,7 +8607,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
if (mPresShell->IsAccessibilityActive()) {
PRUint32 changeType;
if (frame) {
nsIFrame *newFrame = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame *newFrame = aContent->GetPrimaryFrame();
changeType = newFrame ? nsIAccessibilityService::FRAME_SIGNIFICANT_CHANGE :
nsIAccessibilityService::FRAME_HIDE;
}
@ -11002,7 +11001,7 @@ nsCSSFrameConstructor::ProcessOneRestyle(nsIContent* aContent,
return;
}
nsIFrame* primaryFrame = mPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* primaryFrame = aContent->GetPrimaryFrame();
if (aRestyleHint & eReStyle_Self) {
RestyleElement(aContent, primaryFrame, aChangeHint);
} else if (aChangeHint &&
@ -11232,7 +11231,8 @@ nsCSSFrameConstructor::LazyGenerateChildrenEvent::Run()
mPresShell->GetDocument()->FlushPendingNotifications(Flush_Layout);
// this is hard-coded to handle only menu popup frames
nsIFrame* frame = mPresShell->GetPrimaryFrameFor(mContent);
nsIFrame* frame = mPresShell->GetPresContext() ?
mPresShell->GetPresContext()->GetPrimaryFrameFor(mContent) : nsnull;
if (frame && frame->GetType() == nsGkAtoms::menuPopupFrame) {
nsWeakFrame weakFrame(frame);
#ifdef MOZ_XUL

Просмотреть файл

@ -987,8 +987,7 @@ nsCSSRendering::FindBackgroundStyleFrame(nsIFrame* aForFrame)
// and thus |InitialReflow| on the pres shell. See bug 119351
// for the ugly details.
if (bodyContent) {
nsIFrame *bodyFrame = aForFrame->PresContext()->GetPresShell()->
GetPrimaryFrameFor(bodyContent);
nsIFrame *bodyFrame = bodyContent->GetPrimaryFrame();
if (bodyFrame) {
return nsLayoutUtils::GetStyleFrame(bodyFrame);
}

Просмотреть файл

@ -222,7 +222,7 @@ public:
virtual void PopStackMemory() = 0;
virtual void* AllocateStackMemory(size_t aSize) = 0;
nsIDocument* GetDocument() { return mDocument; }
nsIDocument* GetDocument() const { return mDocument; }
nsPresContext* GetPresContext() { return mPresContext; }

Просмотреть файл

@ -3078,7 +3078,7 @@ PresShell::CheckVisibility(nsIDOMNode *node, PRInt16 startOffset, PRInt16 EndOff
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
if (!content)
return NS_ERROR_FAILURE;
nsIFrame *frame = GetPrimaryFrameFor(content);
nsIFrame *frame = content->GetPrimaryFrame();
if (!frame) //no frame to look at so it must not be visible
return NS_OK;
//start process now to go through all frames to find startOffset. then check chars after that to see
@ -3446,7 +3446,7 @@ PresShell::GetViewToScroll(nsLayoutUtils::Direction aDirection)
}
}
if (focusedContent) {
nsIFrame* startFrame = GetPrimaryFrameFor(focusedContent);
nsIFrame* startFrame = focusedContent->GetPrimaryFrame();
if (startFrame) {
nsIScrollableViewProvider* svp = do_QueryFrame(startFrame);
// If this very frame provides a scroll view, start there instead of frame's
@ -4127,7 +4127,7 @@ PresShell::DoScrollContentIntoView(nsIContent* aContent,
PRIntn aVPercent,
PRIntn aHPercent)
{
nsIFrame* frame = GetPrimaryFrameFor(aContent);
nsIFrame* frame = aContent->GetPrimaryFrame();
if (!frame) {
mContentToScrollTo = nsnull;
return;
@ -4281,7 +4281,7 @@ PresShell::GetSelectionForCopy(nsISelection** outSelection)
nsCOMPtr<nsIDOMNSHTMLTextAreaElement> htmlTextAreaElement(do_QueryInterface(content));
if (htmlInputElement || htmlTextAreaElement)
{
nsIFrame *htmlInputFrame = GetPrimaryFrameFor(content);
nsIFrame *htmlInputFrame = content->GetPrimaryFrame();
if (!htmlInputFrame) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelectionController> selCon;
@ -4386,7 +4386,7 @@ PresShell::ClearMouseCapture(nsIView* aView)
if (shell->FrameManager()->IsDestroyingFrames())
return;
frame = shell->GetPrimaryFrameFor(gCaptureInfo.mContent);
frame = gCaptureInfo.mContent->GetPrimaryFrame();
}
}
@ -5152,7 +5152,10 @@ PresShell::GetPrimaryFrameFor(nsIContent* aContent) const
nsIFrame*
PresShell::GetRealPrimaryFrameFor(nsIContent* aContent) const
{
nsIFrame *primaryFrame = FrameManager()->GetPrimaryFrameFor(aContent, -1);
if (aContent->GetDocument() != GetDocument()) {
return nsnull;
}
nsIFrame *primaryFrame = aContent->GetPrimaryFrame();
if (!primaryFrame)
return nsnull;
return nsPlaceholderFrame::GetRealFrameFor(primaryFrame);
@ -5458,7 +5461,7 @@ PresShell::CreateRangePaintInfo(nsIDOMRange* aRange,
return nsnull;
nsIContent* ancestorContent = static_cast<nsIContent*>(ancestor);
ancestorFrame = GetPrimaryFrameFor(ancestorContent);
ancestorFrame = ancestorContent->GetPrimaryFrame();
// use the nearest ancestor frame that includes all continuations as the
// root for building the display list
@ -5833,7 +5836,7 @@ PresShell::GetCurrentEventFrame()
// frame shouldn't get an event, nor should we even assume its
// safe to try and find the frame.
if (mCurrentEventContent->GetDocument()) {
mCurrentEventFrame = GetPrimaryFrameFor(mCurrentEventContent);
mCurrentEventFrame = mCurrentEventContent->GetPrimaryFrame();
}
}
@ -6152,7 +6155,11 @@ PresShell::HandleEvent(nsIView *aView,
if (capturingContent) {
captureRetarget = gCaptureInfo.mRetargetToElement;
if (!captureRetarget) {
nsIFrame* captureFrame = GetPrimaryFrameFor(capturingContent);
// A check was already done above to ensure that capturingContent is
// in this presshell, so GetPrimaryFrame can just be called directly.
NS_ASSERTION(capturingContent->GetCurrentDoc() == GetDocument(),
"Unexpected document");
nsIFrame* captureFrame = capturingContent->GetPrimaryFrame();
if (captureFrame) {
if (capturingContent->Tag() == nsGkAtoms::select &&
capturingContent->IsHTML()) {
@ -6202,8 +6209,10 @@ PresShell::HandleEvent(nsIView *aView,
!nsContentUtils::ContentIsCrossDocDescendantOf(targetFrame->GetContent(),
capturingContent))) {
// A check was already done above to ensure that capturingContent is
// in this presshell, so GetPrimaryFrameFor can just be called directly.
nsIFrame* capturingFrame = GetPrimaryFrameFor(capturingContent);
// in this presshell, so GetPrimaryFrame can just be called directly.
NS_ASSERTION(capturingContent->GetCurrentDoc() == GetDocument(),
"Unexpected document");
nsIFrame* capturingFrame = capturingContent->GetPrimaryFrame();
if (capturingFrame) {
targetFrame = capturingFrame;
aView = targetFrame->GetClosestView();
@ -6733,7 +6742,7 @@ PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTarge
rv = ScrollContentIntoView(content, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE);
NS_ENSURE_SUCCESS(rv, PR_FALSE);
frame = GetPrimaryFrameFor(content);
frame = content->GetPrimaryFrame();
NS_WARN_IF_FALSE(frame, "No frame for focused content?");
}
@ -6836,7 +6845,7 @@ PresShell::GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
col->GetElement(getter_AddRefs(colElement));
nsCOMPtr<nsIContent> colContent(do_QueryInterface(colElement));
if (colContent) {
nsIFrame* frame = GetPrimaryFrameFor(colContent);
nsIFrame* frame = colContent->GetPrimaryFrame();
if (frame) {
extraTreeY = frame->GetSize().height;
}
@ -6866,7 +6875,7 @@ PresShell::GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
focusedContent = do_QueryInterface(item);
#endif
nsIFrame *frame = GetPrimaryFrameFor(focusedContent);
nsIFrame *frame = focusedContent->GetPrimaryFrame();
if (frame) {
nsPoint frameOrigin(0, 0);
@ -6978,10 +6987,9 @@ PresShell::RemoveOverrideStyleSheet(nsIStyleSheet *aSheet)
}
static void
FreezeElement(nsIContent *aContent, void *aShell)
FreezeElement(nsIContent *aContent, void * /* unused */)
{
nsIPresShell* shell = static_cast<nsIPresShell*>(aShell);
nsIFrame *frame = shell->FrameManager()->GetPrimaryFrameFor(aContent, -1);
nsIFrame *frame = aContent->GetPrimaryFrame();
nsIObjectFrame *objectFrame = do_QueryFrame(frame);
if (objectFrame) {
objectFrame->StopPlugin();
@ -7003,7 +7011,7 @@ PresShell::Freeze()
{
MaybeReleaseCapturingContent();
mDocument->EnumerateFreezableElements(FreezeElement, this);
mDocument->EnumerateFreezableElements(FreezeElement, nsnull);
if (mCaret)
mCaret->SetCaretVisible(PR_FALSE);

Просмотреть файл

@ -146,10 +146,9 @@ nsIsIndexFrame::UpdatePromptLabel(PRBool aNotify)
nsresult
nsIsIndexFrame::GetInputFrame(nsIFormControlFrame** oFrame)
{
nsIPresShell *presShell = PresContext()->GetPresShell();
if (!mInputContent) NS_WARNING("null content - cannot restore state");
if (presShell && mInputContent) {
nsIFrame *frame = presShell->GetPrimaryFrameFor(mInputContent);
if (mInputContent) {
nsIFrame *frame = mInputContent->GetPrimaryFrame();
if (frame) {
*oFrame = do_QueryFrame(frame);
return *oFrame ? NS_OK : NS_NOINTERFACE;

Просмотреть файл

@ -279,9 +279,6 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsPoint aPt)
nsPresContext* presContext = PresContext();
if (!GetScrollableView()) return;
nsIPresShell *presShell = presContext->GetPresShell();
if (!presShell) return;
nsIFrame* containerFrame = GetOptionsContainer();
if (!containerFrame) return;
@ -301,7 +298,7 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsPoint aPt)
focusedContent = GetOptionContent(focusedIndex);
// otherwise we find the focusedContent's frame and scroll to it
if (focusedContent) {
childframe = presShell->GetPrimaryFrameFor(focusedContent);
childframe = focusedContent->GetPrimaryFrame();
}
} else {
nsCOMPtr<nsIDOMHTMLSelectElement> selectHTMLElement(do_QueryInterface(mContent));
@ -337,7 +334,7 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsPoint aPt)
// if we found a node use it, if not get the first child (this is for empty selects)
if (node) {
focusedContent = do_QueryInterface(node);
childframe = presShell->GetPrimaryFrameFor(focusedContent);
childframe = focusedContent->GetPrimaryFrame();
}
if (!childframe) {
// Failing all else, try the first thing we have, but only if
@ -476,8 +473,7 @@ GetNumberOfOptionsRecursive(nsIContent* aContent)
}
static nscoord
GetOptGroupLabelsHeight(nsPresContext* aPresContext,
nsIContent* aContent,
GetOptGroupLabelsHeight(nsIContent* aContent,
nscoord aRowHeight)
{
nscoord height = 0;
@ -487,7 +483,7 @@ GetOptGroupLabelsHeight(nsPresContext* aPresContext,
if (::IsOptGroup(child)) {
PRUint32 numOptions = ::GetNumberOfOptionsRecursive(child);
nscoord optionsHeight = aRowHeight * numOptions;
nsIFrame* frame = aPresContext->GetPresShell()->GetPrimaryFrameFor(child);
nsIFrame* frame = child->GetPrimaryFrame();
nscoord totalHeight = frame ? frame->GetSize().height : 0;
height += NS_MAX(0, totalHeight - optionsHeight);
}
@ -1933,8 +1929,7 @@ nsListControlFrame::CalcIntrinsicHeight(nscoord aHeightOfARow,
// When SIZE=0 or unspecified we constrain the height to
// [2..kMaxDropDownRows] rows. We add in the height of optgroup labels
// (within the constraint above), bug 300474.
nscoord labelHeight =
::GetOptGroupLabelsHeight(PresContext(), mContent, aHeightOfARow);
nscoord labelHeight = ::GetOptGroupLabelsHeight(mContent, aHeightOfARow);
if (GetMultiple()) {
if (aNumberOfOptions < 2) {
@ -2136,7 +2131,6 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
return NS_OK;
}
nsIPresShell *presShell = PresContext()->PresShell();
PRInt32 numOptions = GetNumberOfOptions();
if (numOptions < 1)
return NS_ERROR_FAILURE;
@ -2147,7 +2141,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
// first option frame
nsCOMPtr<nsIContent> firstOption = GetOptionContent(0);
NS_ASSERTION(firstOption, "Can't find first option that's supposed to be there");
nsIFrame* optionFrame = presShell->GetPrimaryFrameFor(firstOption);
nsIFrame* optionFrame = firstOption->GetPrimaryFrame();
if (optionFrame) {
nsPoint ptInOptionFrame = pt - optionFrame->GetOffsetTo(this);
if (ptInOptionFrame.y < 0 && ptInOptionFrame.x >= 0 &&
@ -2161,7 +2155,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
// If the event coordinate is below the last option frame, then target the
// last option frame
NS_ASSERTION(lastOption, "Can't find last option that's supposed to be there");
optionFrame = presShell->GetPrimaryFrameFor(lastOption);
optionFrame = lastOption->GetPrimaryFrame();
if (optionFrame) {
nsPoint ptInOptionFrame = pt - optionFrame->GetOffsetTo(this);
if (ptInOptionFrame.y >= optionFrame->GetSize().height && ptInOptionFrame.x >= 0 &&
@ -2327,10 +2321,9 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement)
}
// otherwise we find the content's frame and scroll to it
nsIPresShell *presShell = PresContext()->PresShell();
nsIFrame * childframe;
if (aOptElement) {
childframe = presShell->GetPrimaryFrameFor(aOptElement);
childframe = aOptElement->GetPrimaryFrame();
} else {
return NS_ERROR_FAILURE;
}
@ -2363,7 +2356,7 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement)
nsCOMPtr<nsIDOMHTMLOptGroupElement> optGroup(do_QueryInterface(parentContent));
nsRect optRect(0,0,0,0);
if (optGroup) {
nsIFrame * optFrame = presShell->GetPrimaryFrameFor(parentContent);
nsIFrame * optFrame = parentContent->GetPrimaryFrame();
if (optFrame) {
optRect = optFrame->GetRect();
}

Просмотреть файл

@ -758,14 +758,11 @@ nsFrame::GetChildList(nsIAtom* aListName) const
static nsIFrame*
GetActiveSelectionFrame(nsPresContext* aPresContext, nsIFrame* aFrame)
{
nsIPresShell* shell = aPresContext->GetPresShell();
if (shell) {
nsIContent* capturingContent = nsIPresShell::GetCapturingContent();
if (capturingContent) {
nsIFrame* activeFrame = shell->GetPrimaryFrameFor(capturingContent);
nsIFrame* activeFrame = aPresContext->GetPrimaryFrameFor(capturingContent);
return activeFrame ? activeFrame : aFrame;
}
}
return aFrame;
}

Просмотреть файл

@ -566,7 +566,7 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext,
aStatus = NS_FRAME_COMPLETE;
NS_ASSERTION(aPresContext->GetPresShell()->GetPrimaryFrameFor(mContent) == this,
NS_ASSERTION(mContent->GetPrimaryFrame() == this,
"Shouldn't happen");
// "offset" is the offset of our content area from our frame's

Просмотреть файл

@ -2152,8 +2152,7 @@ nsGfxScrollFrameInner::IsLTR() const
}
if (root) {
nsIFrame *rootsFrame =
presContext->PresShell()->GetPrimaryFrameFor(root);
nsIFrame *rootsFrame = root->GetPrimaryFrame();
if (rootsFrame)
frame = rootsFrame;
}

Просмотреть файл

@ -4907,19 +4907,8 @@ DepthOfVisual(const Screen* screen, const Visual* visual)
static GdkWindow* GetClosestWindow(nsIDOMElement *element)
{
nsCOMPtr<nsIDOMDocument> domDocument;
element->GetOwnerDocument(getter_AddRefs(domDocument));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDocument);
if (!doc)
return nsnull;
nsIPresShell *presShell = doc->GetPrimaryShell();
if (!presShell)
return nsnull;
nsCOMPtr<nsIContent> content = do_QueryInterface(element);
nsIFrame* frame = presShell->GetPrimaryFrameFor(content);
nsIFrame* frame = content->GetPrimaryFrame();
if (!frame)
return nsnull;

Просмотреть файл

@ -467,7 +467,7 @@ public:
{
if (mSelection && mPresContext)
{
nsWeakFrame frame = mPresContext->PresShell()->GetPrimaryFrameFor(mContent);
nsWeakFrame frame = mPresContext->GetPrimaryFrameFor(mContent);
mContent = nsnull;
mFrameSelection->HandleDrag(frame, mPoint);
@ -968,7 +968,7 @@ nsFrameSelection::ConstrainFrameAndPointToAnchorSubtree(nsIFrame *aFrame,
// frame.
//
*aRetFrame = mShell->GetPrimaryFrameFor(anchorRoot);
*aRetFrame = anchorRoot->GetPrimaryFrame();
if (!*aRetFrame)
return NS_ERROR_FAILURE;
@ -2090,7 +2090,7 @@ nsFrameSelection::GetFrameForNodeOffset(nsIContent *aNode,
}
}
nsIFrame* returnFrame = mShell->GetPrimaryFrameFor(theNode);
nsIFrame* returnFrame = theNode->GetPrimaryFrame();
if (!returnFrame)
return nsnull;
@ -2303,12 +2303,8 @@ nsITableCellLayout*
nsFrameSelection::GetCellLayout(nsIContent *aCellContent) const
{
NS_ENSURE_TRUE(mShell, nsnull);
// Get frame for cell
nsIFrame *cellFrame = mShell->GetPrimaryFrameFor(aCellContent);
if (!cellFrame)
return nsnull;
nsITableCellLayout *cellLayoutObject = do_QueryFrame(cellFrame);
nsITableCellLayout *cellLayoutObject =
do_QueryFrame(aCellContent->GetPrimaryFrame());
return cellLayoutObject;
}
@ -2316,12 +2312,8 @@ nsITableLayout*
nsFrameSelection::GetTableLayout(nsIContent *aTableContent) const
{
NS_ENSURE_TRUE(mShell, nsnull);
// Get frame for table
nsIFrame *tableFrame = mShell->GetPrimaryFrameFor(aTableContent);
if (!tableFrame)
return nsnull;
nsITableLayout *tableLayoutObject = do_QueryFrame(tableFrame);
nsITableLayout *tableLayoutObject =
do_QueryFrame(aTableContent->GetPrimaryFrame());
return tableLayoutObject;
}
@ -2489,8 +2481,7 @@ printf("HandleTableSelection: Mouse down event\n");
// We have at least 1 other selected cell
// Check if new cell is already selected
NS_ENSURE_STATE(mShell);
nsIFrame *cellFrame = mShell->GetPrimaryFrameFor(childContent);
nsIFrame *cellFrame = childContent->GetPrimaryFrame();
if (!cellFrame) return NS_ERROR_NULL_POINTER;
result = cellFrame->GetSelected(&isSelected);
if (NS_FAILED(result)) return result;
@ -4200,7 +4191,7 @@ nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOf
content = child; // releases the focusnode
}
}
*aReturnFrame = mFrameSelection->GetShell()->GetPrimaryFrameFor(content);
*aReturnFrame = content->GetPrimaryFrame();
return NS_OK;
}
#endif
@ -4286,7 +4277,7 @@ nsTypedSelection::SelectAllFramesForContent(nsIContentIterator *aInnerIter,
if (NS_SUCCEEDED(result))
{
// First select frame of content passed in
frame = shell->GetPrimaryFrameFor(aContent);
frame = aContent->GetPrimaryFrame();
if (frame)
{
frame->SetSelected(aSelected, mType);
@ -4305,7 +4296,7 @@ nsTypedSelection::SelectAllFramesForContent(nsIContentIterator *aInnerIter,
nsCOMPtr<nsIContent> innercontent =
do_QueryInterface(aInnerIter->GetCurrentNode());
frame = shell->GetPrimaryFrameFor(innercontent);
frame = innercontent->GetPrimaryFrame();
if (frame)
{
frame->SetSelected(aSelected, mType);
@ -4364,10 +4355,9 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsIRange *aRange, PR
if (!content)
return NS_ERROR_UNEXPECTED;
nsIFrame *frame;
if (content->IsNodeOfType(nsINode::eTEXT))
{
frame = presShell->GetPrimaryFrameFor(content);
nsIFrame* frame = content->GetPrimaryFrame();
// The frame could be an SVG text frame, in which case we'll ignore
// it.
if (frame && frame->GetType() == nsGkAtoms::textFrame)
@ -4404,7 +4394,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsIRange *aRange, PR
if (content->IsNodeOfType(nsINode::eTEXT))
{
frame = presShell->GetPrimaryFrameFor(content);
nsIFrame* frame = content->GetPrimaryFrame();
// The frame could be an SVG text frame, in which case we'll
// ignore it.
if (frame && frame->GetType() == nsGkAtoms::textFrame)

Просмотреть файл

@ -100,13 +100,7 @@ inDOMUtils::IsIgnorableWhitespace(nsIDOMCharacterData *aDataNode,
return NS_OK;
}
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(win);
if (!presShell) {
// Display:none iframe or something... Bail out
return NS_OK;
}
nsIFrame* frame = presShell->GetPrimaryFrameFor(content);
nsIFrame* frame = content->GetPrimaryFrame();
if (frame) {
const nsStyleText* text = frame->GetStyleText();
*aReturn = !text->WhiteSpaceIsSignificant();

Просмотреть файл

@ -133,11 +133,7 @@ NS_IMETHODIMP
inFlasher::RepaintElement(nsIDOMElement* aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
nsCOMPtr<nsIDOMWindowInternal> window = inLayoutUtils::GetWindowFor(aElement);
if (!window) return NS_OK;
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(window);
if (!presShell) return NS_OK;
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell);
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement);
if (!frame) return NS_OK;
frame->Invalidate(frame->GetRect());
@ -154,7 +150,7 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement)
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(window);
if (!presShell) return NS_OK;
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell);
nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement);
PRBool isFirstFrame = PR_TRUE;

Просмотреть файл

@ -84,10 +84,10 @@ inLayoutUtils::GetPresShellFor(nsISupports* aThing)
/*static*/
nsIFrame*
inLayoutUtils::GetFrameFor(nsIDOMElement* aElement, nsIPresShell* aShell)
inLayoutUtils::GetFrameFor(nsIDOMElement* aElement)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
return aShell->GetPrimaryFrameFor(content);
return content->GetPrimaryFrame();
}
nsIEventStateManager*

Просмотреть файл

@ -54,7 +54,7 @@ public:
static nsIDOMWindowInternal* GetWindowFor(nsIDOMNode* aNode);
static nsIDOMWindowInternal* GetWindowFor(nsIDOMDocument* aDoc);
static nsIPresShell* GetPresShellFor(nsISupports* aThing);
static nsIFrame* GetFrameFor(nsIDOMElement* aElement, nsIPresShell* aShell);
static nsIFrame* GetFrameFor(nsIDOMElement* aElement);
static nsIEventStateManager* GetEventStateManagerFor(nsIDOMElement *aElement);
static nsBindingManager* GetBindingManagerFor(nsIDOMNode* aNode);
static nsIDOMDocument* GetSubDocumentFor(nsIDOMNode* aNode);

Просмотреть файл

@ -1817,8 +1817,7 @@ nsPrintEngine::ReflowDocList(nsPrintObject* aPO, PRBool aSetPixelScale)
// Check to see if the subdocument's element has been hidden by the parent document
if (aPO->mParent && aPO->mParent->mPresShell) {
nsIFrame * frame =
aPO->mParent->mPresShell->GetPrimaryFrameFor(aPO->mContent);
nsIFrame * frame = aPO->mContent->GetPrimaryFrame();
if (frame) {
if (!frame->GetStyleVisibility()->IsVisible()) {
aPO->mDontPrint = PR_TRUE;
@ -1872,10 +1871,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
return NS_OK;
if (aPO->mParent && aPO->mParent->IsPrintable()) {
if (aPO->mParent->mPresShell) {
frame = aPO->mParent->mPresShell->FrameManager()->
GetPrimaryFrameFor(aPO->mContent, -1);
}
frame = aPO->mContent->GetPrimaryFrame();
// Without a frame, this document can't be displayed; therefore, there is no
// point to reflowing it
if (!frame) {

Просмотреть файл

@ -354,7 +354,7 @@ nsComputedDOMStyle::GetStyleContextForContentNoFlush(nsIContent* aContent,
}
if (!aPseudo) {
nsIFrame* frame = aPresShell->GetPrimaryFrameFor(aContent);
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame) {
nsStyleContext* result =
nsLayoutUtils::GetStyleFrame(frame)->GetStyleContext();
@ -453,7 +453,7 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName,
NS_ENSURE_TRUE(mPresShell && mPresShell->GetPresContext(),
NS_ERROR_NOT_AVAILABLE);
mOuterFrame = mPresShell->GetPrimaryFrameFor(mContent);
mOuterFrame = mContent->GetPrimaryFrame();
mInnerFrame = mOuterFrame;
if (mOuterFrame && !mPseudo) {
nsIAtom* type = mOuterFrame->GetType();

Просмотреть файл

@ -410,7 +410,7 @@ static nsresult GetBodyColor(nsPresContext* aPresContext, nscolor* aColor)
nsCOMPtr<nsIDOMHTMLElement> body;
domdoc->GetBody(getter_AddRefs(body));
nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body);
nsIFrame *bodyFrame = shell->GetPrimaryFrameFor(bodyContent);
nsIFrame *bodyFrame = bodyContent->GetPrimaryFrame();
if (!bodyFrame)
return NS_ERROR_FAILURE;
*aColor = bodyFrame->GetStyleColor()->mColor;

Просмотреть файл

@ -90,7 +90,7 @@ nsSVGRenderingObserver::GetReferencedFrame()
nsIDocument* doc = mElement.get()->GetCurrentDoc();
nsIPresShell* shell = doc ? doc->GetPrimaryShell() : nsnull;
if (shell && !shell->FrameManager()->IsDestroyingFrames()) {
nsIFrame* frame = shell->GetPrimaryFrameFor(mElement.get());
nsIFrame* frame = mElement.get()->GetPrimaryFrame();
if (frame) {
mReferencedFrame = frame;
mReferencedFramePresShell = shell;

Просмотреть файл

@ -95,7 +95,7 @@ nsSVGMutationObserver::AttributeChanged(nsIDocument *aDocument,
nsPresShellIterator iter(aDocument);
nsCOMPtr<nsIPresShell> shell;
while ((shell = iter.GetNextShell())) {
nsIFrame *frame = shell->GetPrimaryFrameFor(aContent);
nsIFrame *frame = aContent->GetPrimaryFrame();
if (!frame) {
continue;
}

Просмотреть файл

@ -557,9 +557,7 @@ nsSVGUtils::GetCTM(nsSVGElement *aElement, PRBool aScreenCTM)
if (currentDoc && element->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG)) {
nsIPresShell *presShell = currentDoc->GetPrimaryShell();
if (presShell) {
nsPresContext *context = presShell->GetPresContext();
if (context) {
nsIFrame* frame = presShell->GetPrimaryFrameFor(element);
nsIFrame* frame = element->GetPrimaryFrame();
nsIFrame* ancestorFrame = presShell->GetRootFrame();
if (frame && ancestorFrame) {
nsPoint point = frame->GetOffsetTo(ancestorFrame);
@ -568,7 +566,6 @@ nsSVGUtils::GetCTM(nsSVGElement *aElement, PRBool aScreenCTM)
}
}
}
}
return matrix * gfxMatrix().Translate(gfxPoint(x, y));
}

Просмотреть файл

@ -153,7 +153,12 @@ nsBoxObject::GetFrame(PRBool aFlushLayout)
shell->FlushPendingNotifications(Flush_Frames);
}
return shell->GetPrimaryFrameFor(mContent);
// The flush might have killed mContent.
if (!mContent) {
return nsnull;
}
return mContent->GetPrimaryFrame();
}
nsIPresShell*

Просмотреть файл

@ -1224,8 +1224,7 @@ nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset,
return GetNextItemBox(aBox, ++aOffset, aCreated);
nsPresContext* presContext = PresContext();
nsIFrame* existingFrame =
presContext->GetPresShell()->GetPrimaryFrameFor(nextContent);
nsIFrame* existingFrame = nextContent->GetPrimaryFrame();
if (existingFrame && existingFrame->GetParent() != this)
return GetNextItemBox(aBox, ++aOffset, aCreated);
@ -1348,13 +1347,12 @@ nsListBoxBodyFrame::OnContentInserted(nsPresContext* aPresContext, nsIContent* a
if (mRowCount >= 0)
++mRowCount;
nsIPresShell *shell = aPresContext->PresShell();
// The RDF content builder will build content nodes such that they are all
// ready when OnContentInserted is first called, meaning the first call
// to CreateRows will create all the frames, but OnContentInserted will
// still be called again for each content node - so we need to make sure
// that the frame for each content node hasn't already been created.
nsIFrame* childFrame = shell->GetPrimaryFrameFor(aChildContent);
nsIFrame* childFrame = aChildContent->GetPrimaryFrame();
if (childFrame)
return;
@ -1369,7 +1367,7 @@ nsListBoxBodyFrame::OnContentInserted(nsPresContext* aPresContext, nsIContent* a
mRowsToPrepend = 1;
} else if (nextSiblingContent) {
// we may be inserting before a frame that is on screen
nsIFrame* nextSiblingFrame = shell->GetPrimaryFrameFor(nextSiblingContent);
nsIFrame* nextSiblingFrame = nextSiblingContent->GetPrimaryFrame();
mLinkupFrame = nextSiblingFrame;
}
@ -1427,8 +1425,7 @@ nsListBoxBodyFrame::OnContentRemoved(nsPresContext* aPresContext,
if (last.position() > 0) {
iter.seek(last.position() - 1);
nsIContent *lastChild = *iter;
nsIFrame* lastChildFrame =
aPresContext->PresShell()->GetPrimaryFrameFor(lastChild);
nsIFrame* lastChildFrame = lastChild->GetPrimaryFrame();
if (lastChildFrame) {
mTopFrame = nsnull;

Просмотреть файл

@ -194,7 +194,7 @@ nsListBoxObject::GetListBoxBody(PRBool aFlush)
nsIFrame* frame = aFlush ?
GetFrame(PR_FALSE) /* does Flush_Frames */ :
shell->GetPrimaryFrameFor(mContent);
mContent->GetPrimaryFrame();
if (!frame)
return nsnull;
@ -203,7 +203,7 @@ nsListBoxObject::GetListBoxBody(PRBool aFlush)
FindBodyContent(frame->GetContent(), getter_AddRefs(content));
// this frame will be a nsGFXScrollFrame
frame = shell->GetPrimaryFrameFor(content);
frame = content->GetPrimaryFrame();
if (!frame)
return nsnull;
nsIScrollableFrame* scrollFrame = do_QueryFrame(frame);

Просмотреть файл

@ -1328,7 +1328,7 @@ nsMenuFrame::SetActiveChild(nsIDOMElement* aChild)
nsCOMPtr<nsIContent> child(do_QueryInterface(aChild));
nsIFrame* kid = PresContext()->PresShell()->GetPrimaryFrameFor(child);
nsIFrame* kid = child->GetPrimaryFrame();
if (kid && kid->GetType() == nsGkAtoms::menuFrame)
mPopupFrame->ChangeMenuItem(static_cast<nsMenuFrame *>(kid), PR_FALSE);
return NS_OK;

Просмотреть файл

@ -911,7 +911,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)
if (!shell)
return NS_ERROR_FAILURE;
aAnchorFrame = shell->GetPrimaryFrameFor(mAnchorContent);
aAnchorFrame = mAnchorContent->GetPrimaryFrame();
}
}

Просмотреть файл

@ -102,7 +102,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
nsIContent* contentToResize =
GetContentToResize(presShell, getter_AddRefs(window));
if (contentToResize) {
nsIFrame* frameToResize = presShell->GetPrimaryFrameFor(contentToResize);
nsIFrame* frameToResize = contentToResize->GetPrimaryFrame();
if (!frameToResize)
break;
@ -165,7 +165,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
// check if the returned content really is a menupopup
nsMenuPopupFrame* menuPopupFrame = nsnull;
if (contentToResize) {
nsIFrame* frameToResize = presShell->GetPrimaryFrameFor(contentToResize);
nsIFrame* frameToResize = contentToResize->GetPrimaryFrame();
if (frameToResize && frameToResize->GetType() == nsGkAtoms::menuPopupFrame) {
menuPopupFrame = static_cast<nsMenuPopupFrame *>(frameToResize);
}

Просмотреть файл

@ -185,8 +185,7 @@ nsScrollbarFrame::GetScrollbarMediator()
{
if (!mScrollbarMediator)
return nsnull;
nsIFrame* f =
PresContext()->PresShell()->GetPrimaryFrameFor(mScrollbarMediator);
nsIFrame* f = mScrollbarMediator->GetPrimaryFrame();
if (!f)
return nsnull;

Просмотреть файл

@ -818,14 +818,11 @@ nsSliderFrame::SetCurrentPositionInternal(nsIContent* aScrollbar, PRInt32 aNewPo
mediator->PositionChanged(scrollbarFrame, GetCurrentPosition(scrollbar), aNewPos);
// 'mediator' might be dangling now...
UpdateAttribute(scrollbar, aNewPos, PR_FALSE, aIsSmooth);
nsIPresShell* shell = context->GetPresShell();
if (shell) {
nsIFrame* frame = shell->GetPrimaryFrameFor(content);
nsIFrame* frame = content->GetPrimaryFrame();
if (frame && frame->GetType() == nsGkAtoms::sliderFrame) {
static_cast<nsSliderFrame*>(frame)->
CurrentPositionChanged(frame->PresContext(), aImmediateRedraw);
}
}
mUserChanged = PR_FALSE;
return;
}

Просмотреть файл

@ -287,7 +287,7 @@ nsXULPopupManager::GetFrameOfTypeForContent(nsIContent* aContent,
if (aShouldFlush)
presShell->FlushPendingNotifications(Flush_Frames);
nsIFrame* frame = presShell->GetPrimaryFrameFor(aContent);
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame && frame->GetType() == aFrameType)
return frame;
}
@ -1064,7 +1064,7 @@ nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
document->FlushPendingNotifications(Flush_Layout);
// get the frame again in case it went away
nsIFrame* frame = presShell->GetPrimaryFrameFor(aPopup);
nsIFrame* frame = aPopup->GetPrimaryFrame();
if (frame && frame->GetType() == nsGkAtoms::menuPopupFrame) {
nsMenuPopupFrame* popupFrame = static_cast<nsMenuPopupFrame *>(frame);
@ -1113,7 +1113,7 @@ nsXULPopupManager::FirePopupHidingEvent(nsIContent* aPopup,
}
// get frame again in case it went away
nsIFrame* frame = presShell->GetPrimaryFrameFor(aPopup);
nsIFrame* frame = aPopup->GetPrimaryFrame();
if (frame && frame->GetType() == nsGkAtoms::menuPopupFrame) {
nsMenuPopupFrame* popupFrame = static_cast<nsMenuPopupFrame *>(frame);

Просмотреть файл

@ -696,9 +696,7 @@ nsXULTooltipListener::GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip)
// Submenus can't be used as tooltips, see bug 288763.
nsIContent* parent = tooltip->GetParent();
if (parent) {
nsIDocument* doc = parent->GetCurrentDoc();
nsIPresShell* presShell = doc ? doc->GetPrimaryShell() : nsnull;
nsIFrame* frame = presShell ? presShell->GetPrimaryFrameFor(parent) : nsnull;
nsIFrame* frame = parent->GetPrimaryFrame();
if (frame && frame->GetType() == nsGkAtoms::menuFrame) {
NS_WARNING("Menu cannot be used as a tooltip");
return NS_ERROR_FAILURE;

Просмотреть файл

@ -882,11 +882,10 @@ FindScrollParts(nsIFrame* aCurrFrame, nsTreeBodyFrame::ScrollParts* aResult)
nsTreeBodyFrame::ScrollParts nsTreeBodyFrame::GetScrollParts()
{
nsPresContext* presContext = PresContext();
ScrollParts result = { nsnull, nsnull, nsnull, nsnull, nsnull, nsnull };
nsIContent* baseElement = GetBaseElement();
nsIFrame* treeFrame =
baseElement ? presContext->PresShell()->GetPrimaryFrameFor(baseElement) : nsnull;
baseElement ? baseElement->GetPrimaryFrame() : nsnull;
if (treeFrame) {
// The way we do this, searching through the entire frame subtree, is pretty
// dumb! We should know where these frames are.
@ -1364,7 +1363,7 @@ nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
nsIRenderingContext& aRenderingContext,
nsRect& aTextRect)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
nscoord width =
nsLayoutUtils::GetStringWidth(this, &aRenderingContext, aText.get(), aText.Length());
@ -1522,7 +1521,7 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
PRInt32 aRowIndex,
nsTreeColumn* aColumn)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
// Obtain the properties for our cell.
PrefillPropertyArray(aRowIndex, aColumn);
@ -1966,7 +1965,7 @@ nsTreeBodyFrame::EndUpdateBatch()
void
nsTreeBodyFrame::PrefillPropertyArray(PRInt32 aRowIndex, nsTreeColumn* aCol)
{
NS_PRECONDITION(!aCol || aCol->GetFrame(this), "invalid column passed");
NS_PRECONDITION(!aCol || aCol->GetFrame(), "invalid column passed");
mScratchArray->Clear();
// focus
@ -2911,7 +2910,7 @@ nsTreeBodyFrame::PaintColumn(nsTreeColumn* aColumn,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
// Now obtain the properties for our cell.
PrefillPropertyArray(-1, aColumn);
@ -3146,7 +3145,7 @@ nsTreeBodyFrame::PaintCell(PRInt32 aRowIndex,
nscoord& aCurrX,
nsPoint aPt)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
// Now obtain the properties for our cell.
// XXX Automatically fill in the following props: open, closed, container, leaf, selected, focused, and the col ID.
@ -3325,7 +3324,7 @@ nsTreeBodyFrame::PaintTwisty(PRInt32 aRowIndex,
nscoord& aRemainingWidth,
nscoord& aCurrX)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
PRBool isRTL = GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
nscoord rightEdge = aCurrX + aRemainingWidth;
@ -3417,7 +3416,7 @@ nsTreeBodyFrame::PaintImage(PRInt32 aRowIndex,
nscoord& aRemainingWidth,
nscoord& aCurrX)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
PRBool isRTL = GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
nscoord rightEdge = aCurrX + aRemainingWidth;
@ -3553,7 +3552,7 @@ nsTreeBodyFrame::PaintText(PRInt32 aRowIndex,
nscoord& aCurrX,
PRBool aTextRTL)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
PRBool isRTL = GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
nscoord rightEdge = aTextRect.XMost();
@ -3659,7 +3658,7 @@ nsTreeBodyFrame::PaintCheckbox(PRInt32 aRowIndex,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
// Resolve style for the checkbox.
nsStyleContext* checkboxContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecheckbox);
@ -3721,7 +3720,7 @@ nsTreeBodyFrame::PaintProgressMeter(PRInt32 aRowIndex,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
NS_PRECONDITION(aColumn && aColumn->GetFrame(this), "invalid column passed");
NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
// Resolve style for the progress meter. It contains all the info we need
// to lay ourselves out and to paint.

Просмотреть файл

@ -127,13 +127,10 @@ nsTreeBoxObject::GetTreeBody()
// Iterate over our content model children looking for the body.
nsCOMPtr<nsIContent> content;
FindBodyElement(frame->GetContent(), getter_AddRefs(content));
nsIPresShell* shell = GetPresShell(PR_FALSE);
if (!shell) {
if (!content)
return nsnull;
}
frame = shell->GetPrimaryFrameFor(content);
frame = content->GetPrimaryFrame();
if (!frame)
return nsnull;

Просмотреть файл

@ -92,50 +92,30 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeColumn)
else
NS_INTERFACE_MAP_END
nsIFrame*
nsTreeColumn::GetFrame(nsTreeBodyFrame* aBodyFrame)
{
NS_PRECONDITION(aBodyFrame, "null frame?");
nsIPresShell *shell = aBodyFrame->PresContext()->PresShell();
if (!shell)
return nsnull;
return shell->GetPrimaryFrameFor(mContent);
}
nsIFrame*
nsTreeColumn::GetFrame()
{
NS_ENSURE_TRUE(mContent, nsnull);
nsCOMPtr<nsIDocument> document = mContent->GetDocument();
if (!document)
return nsnull;
nsIPresShell *shell = document->GetPrimaryShell();
if (!shell)
return nsnull;
return shell->GetPrimaryFrameFor(mContent);
return mContent->GetPrimaryFrame();
}
PRBool
nsTreeColumn::IsLastVisible(nsTreeBodyFrame* aBodyFrame)
{
NS_ASSERTION(GetFrame(aBodyFrame), "should have checked for this already");
NS_ASSERTION(GetFrame(), "should have checked for this already");
// cyclers are fixed width, don't adjust them
if (IsCycler())
return PR_FALSE;
// we're certainly not the last visible if we're not visible
if (GetFrame(aBodyFrame)->GetRect().width == 0)
if (GetFrame()->GetRect().width == 0)
return PR_FALSE;
// try to find a visible successor
for (nsTreeColumn *next = GetNext(); next; next = next->GetNext()) {
nsIFrame* frame = next->GetFrame(aBodyFrame);
nsIFrame* frame = next->GetFrame();
if (frame && frame->GetRect().width > 0)
return PR_FALSE;
}
@ -145,7 +125,7 @@ nsTreeColumn::IsLastVisible(nsTreeBodyFrame* aBodyFrame)
nsresult
nsTreeColumn::GetRect(nsTreeBodyFrame* aBodyFrame, nscoord aY, nscoord aHeight, nsRect* aResult)
{
nsIFrame* frame = GetFrame(aBodyFrame);
nsIFrame* frame = GetFrame();
if (!frame) {
*aResult = nsRect();
return NS_ERROR_FAILURE;
@ -165,7 +145,7 @@ nsTreeColumn::GetRect(nsTreeBodyFrame* aBodyFrame, nscoord aY, nscoord aHeight,
nsresult
nsTreeColumn::GetXInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult)
{
nsIFrame* frame = GetFrame(aBodyFrame);
nsIFrame* frame = GetFrame();
if (!frame) {
*aResult = 0;
return NS_ERROR_FAILURE;
@ -177,7 +157,7 @@ nsTreeColumn::GetXInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult)
nsresult
nsTreeColumn::GetWidthInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult)
{
nsIFrame* frame = GetFrame(aBodyFrame);
nsIFrame* frame = GetFrame();
if (!frame) {
*aResult = 0;
return NS_ERROR_FAILURE;
@ -648,17 +628,12 @@ nsTreeColumns::EnsureColumns()
if (!colsContent)
return;
nsCOMPtr<nsIDocument> document = treeContent->GetDocument();
nsIPresShell *shell = document->GetPrimaryShell();
if (!shell)
return;
nsIContent* colContent =
nsTreeUtils::GetDescendantChild(colsContent, nsGkAtoms::treecol);
if (!colContent)
return;
nsIFrame* colFrame = shell->GetPrimaryFrameFor(colContent);
nsIFrame* colFrame = colContent->GetPrimaryFrame();
if (!colFrame)
return;