DeCOMify GetParent/GetBindingParent/GetDocument on nsIContent. Bug 213823,

r+sr=jst


git-svn-id: svn://10.0.0.236/trunk@145289 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu 2003-07-28 21:25:13 +00:00
parent 5966afb32f
commit 82c14d79dd
63 changed files with 395 additions and 717 deletions

View File

@ -352,21 +352,22 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
return NS_ERROR_NULL_POINTER;
range->GetCommonAncestorContainer(getter_AddRefs(commonParent));
nsCOMPtr<nsIContent> tmp, selContent( do_QueryInterface(commonParent) );
while (selContent)
for (nsCOMPtr<nsIContent> selContent(do_QueryInterface(commonParent));
selContent;
selContent = selContent->GetParent())
{
// checking for selection inside a plaintext form widget
nsCOMPtr<nsIAtom> atom;
selContent->GetTag(getter_AddRefs(atom));
if (atom.get() == nsHTMLAtoms::input ||
atom.get() == nsHTMLAtoms::textarea)
if (atom == nsHTMLAtoms::input ||
atom == nsHTMLAtoms::textarea)
{
*aIsPlainTextContext = PR_TRUE;
break;
}
if (atom.get() == nsHTMLAtoms::body)
if (atom == nsHTMLAtoms::body)
{
// check for moz prewrap style on body. If it's there we are
// in a plaintext editor. This is pretty cheezy but I haven't
@ -380,8 +381,6 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
break;
}
}
selContent->GetParent(getter_AddRefs(tmp));
selContent = tmp;
}
// also consider ourselves in a text widget if we can't find an html document

View File

@ -7985,17 +7985,14 @@ ShouldIgnoreSelectChild(nsIContent* aContainer)
if (containerTag == nsHTMLAtoms::optgroup ||
containerTag == nsHTMLAtoms::select) {
nsCOMPtr<nsIContent> selectContent = aContainer;
nsCOMPtr<nsIContent> tmpContent;
nsIContent* selectContent = aContainer;
while (selectContent) {
if (containerTag == nsHTMLAtoms::select)
while (containerTag != nsHTMLAtoms::select) {
selectContent = selectContent->GetParent();
if (!selectContent) {
break;
tmpContent = selectContent;
tmpContent->GetParent(getter_AddRefs(selectContent));
if (selectContent)
selectContent->GetTag(getter_AddRefs(containerTag));
}
selectContent->GetTag(getter_AddRefs(containerTag));
}
nsCOMPtr<nsISelectElement> selectElement = do_QueryInterface(selectContent);
@ -8097,11 +8094,11 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext,
PRBool hasInsertion = PR_FALSE;
if (!multiple) {
nsCOMPtr<nsIBindingManager> bindingManager;
nsCOMPtr<nsIDocument> document;
nsIDocument* document = nsnull;
nsCOMPtr<nsIContent> firstAppendedChild;
aContainer->ChildAt(aNewIndexInContainer, getter_AddRefs(firstAppendedChild));
if (firstAppendedChild) {
firstAppendedChild->GetDocument(getter_AddRefs(document));
document = firstAppendedChild->GetDocument();
}
if (document)
document->GetBindingManager(getter_AddRefs(bindingManager));
@ -8969,8 +8966,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext,
// Check again to see if the frame we are manipulating is part
// of a block-in-inline hierarchy.
if (IsFrameSpecial(parentFrame)) {
nsCOMPtr<nsIContent> parentContainer;
blockContent->GetParent(getter_AddRefs(parentContainer));
nsCOMPtr<nsIContent> parentContainer = blockContent->GetParent();
#ifdef DEBUG
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ContentInserted: parentFrame=");
@ -9944,8 +9940,7 @@ nsCSSFrameConstructor::ContentChanged(nsIPresContext* aPresContext,
if (haveFirstLetterStyle) {
// The block has first-letter style. Use content-replaced to
// repair the blocks frame structure properly.
nsCOMPtr<nsIContent> container;
aContent->GetParent(getter_AddRefs(container));
nsCOMPtr<nsIContent> container = aContent->GetParent();
if (container) {
PRInt32 ix;
container->IndexOf(aContent, ix);
@ -10055,18 +10050,10 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
return NS_OK;
}
inline already_AddRefed<nsIContent>
parent_of(nsIContent *aContent)
{
nsIContent *parent = nsnull;
aContent->GetParent(&parent);
return parent;
}
static PRBool
IsAncestorOf(nsIContent *aAncestor, nsIContent *aDescendant)
{
for (nsCOMPtr<nsIContent> n = aDescendant; n; n = parent_of(n))
for (nsIContent* n = aDescendant; n; n = n->GetParent())
if (n == aAncestor)
return PR_TRUE;
return PR_FALSE;
@ -11272,10 +11259,8 @@ nsCSSFrameConstructor::FindFrameWithContent(nsIPresContext* aPresContext,
// child frames, too.
// We also need to search if the child content is anonymous and scoped
// to the parent content.
nsCOMPtr<nsIContent> parentScope;
kidContent->GetBindingParent(getter_AddRefs(parentScope));
if (aParentContent == kidContent ||
(aParentContent && (aParentContent == parentScope)))
(aParentContent && (aParentContent == kidContent->GetBindingParent())))
{
#ifdef NOISY_FINDFRAME
FFWC_recursions++;
@ -11358,14 +11343,13 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext,
// - internal table frames (row-group, row, cell, col-group, col)
//
// That means we need to need to search for the frame
nsCOMPtr<nsIContent> parentContent; // we get this one time
nsIFrame* parentFrame; // this pointer is used to iterate across all frames that map to parentContent
// Get the frame that corresponds to the parent content object.
// Note that this may recurse indirectly, because the pres shell will
// call us back if there is no mapping in the hash table
aContent->GetParent(getter_AddRefs(parentContent));
if (parentContent.get()) {
nsCOMPtr<nsIContent> parentContent = aContent->GetParent(); // Get this once
if (parentContent) {
aFrameManager->GetPrimaryFrameFor(parentContent, &parentFrame);
while (parentFrame) {
// Search the child frames for a match
@ -11455,8 +11439,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIPresShell* aPresShell,
if (!container)
return NS_OK;
nsCOMPtr<nsIDocument> document;
container->GetDocument(getter_AddRefs(document));
nsIDocument* document = container->GetDocument();
if (!document)
return NS_OK;
@ -11469,9 +11452,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIPresShell* aPresShell,
if (aChildContent) {
// We've got an explicit insertion child. Check to see if it's
// anonymous.
nsCOMPtr<nsIContent> bindingParent;
aChildContent->GetBindingParent(getter_AddRefs(bindingParent));
if (bindingParent == container) {
if (aChildContent->GetBindingParent() == container) {
// This child content is anonymous. Don't use the insertion
// point, since that's only for the explicit kids.
return NS_OK;
@ -11585,8 +11566,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext,
// If there is no document, we don't want to recreate frames for it. (You
// shouldn't generally be giving this method content without a document
// anyway).
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = aContent->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
// Is the frame `special'? If so, we need to reframe the containing
@ -11630,8 +11610,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext,
}
nsresult rv = NS_OK;
nsCOMPtr<nsIContent> container;
aContent->GetParent(getter_AddRefs(container));
nsCOMPtr<nsIContent> container = aContent->GetParent();
if (container) {
PRInt32 indexInContainer;
rv = container->IndexOf(aContent, indexInContainer);
@ -11667,8 +11646,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext,
// However, double check that it's really part of the document,
// since rebuilding the frame tree can have bad effects, especially
// if it's the frame tree for chrome (see bug 157322).
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = aContent->GetDocument();
NS_ASSERTION(doc, "received style change for content not in document");
if (doc)
ReconstructDocElementHierarchy(aPresContext);
@ -13336,8 +13314,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext,
// Tell parent of the containing block to reformulate the
// entire block. This is painful and definitely not optimal
// but it will *always* get the right answer.
nsCOMPtr<nsIContent> parentContainer;
aBlockContent->GetParent(getter_AddRefs(parentContainer));
nsCOMPtr<nsIContent> parentContainer = aBlockContent->GetParent();
#ifdef DEBUG
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::WipeContainingBlock: aBlockContent=%p parentContainer=%p\n",
@ -13662,11 +13639,10 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIPresContext* aPresContext, nsIF
// so GetFloaterContainingBlock(aPresContext, aFrame) has been removed
// And get the containingBlock's content
nsIContent* blockContent = containingBlock->GetContent();
nsCOMPtr<nsIContent> blockContent = containingBlock->GetContent();
if (blockContent) {
// Now find the containingBlock's content's parent
nsCOMPtr<nsIContent> parentContainer;
blockContent->GetParent(getter_AddRefs(parentContainer));
nsCOMPtr<nsIContent> parentContainer = blockContent->GetParent();
if (parentContainer) {
#ifdef DEBUG
if (gNoisyContentUpdates) {

View File

@ -2797,22 +2797,16 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
// a root, other wise keep going in order to let the theme stuff
// draw the background. The canvas really should be drawing the
// bg, but there's no way to hook that up via css.
const nsStyleDisplay* displayData = aForFrame->GetStyleDisplay();
if (displayData->mAppearance) {
nsIContent* content = aForFrame->GetContent();
if (content) {
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
if (parent)
return;
else
color = aForFrame->GetStyleBackground();
}
else
return;
}
else
if (!aForFrame->GetStyleDisplay()->mAppearance) {
return;
}
nsIContent* content = aForFrame->GetContent();
if (!content || content->GetParent()) {
return;
}
color = aForFrame->GetStyleBackground();
}
if (!isCanvas) {
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,

View File

@ -53,9 +53,8 @@ ChildIterator::Init(nsIContent* aContent,
if (! aContent)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(getter_AddRefs(doc));
NS_ASSERTION(doc != nsnull, "element not in the document");
nsCOMPtr<nsIDocument> doc = aContent->GetDocument();
NS_ASSERTION(doc, "element not in the document");
if (! doc)
return NS_ERROR_FAILURE;

View File

@ -617,14 +617,14 @@ FrameManager::GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aResult)
// if any methods in here fail, don't report that failure
// we're just trying to enhance performance here, not test for correctness
nsFindFrameHint hint;
nsCOMPtr<nsIContent> prevSibling, parent;
rv = aContent->GetParent(getter_AddRefs(parent));
if (NS_SUCCEEDED(rv) && parent)
nsIContent* parent = aContent->GetParent();
if (parent)
{
PRInt32 index;
rv = parent->IndexOf(aContent, index);
if (NS_SUCCEEDED(rv) && index>0) // no use looking if it's the first child
if (NS_SUCCEEDED(rv) && index > 0) // no use looking if it's the first child
{
nsCOMPtr<nsIContent> prevSibling;
nsCOMPtr<nsIAtom> tag;
do {
parent->ChildAt(--index, getter_AddRefs(prevSibling));
@ -809,8 +809,7 @@ FrameManager::GetUndisplayedContent(nsIContent* aContent)
if (!aContent || !mUndisplayedMap)
return nsnull;
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = aContent->GetParent();
if (!parent)
return nsnull;
@ -839,8 +838,7 @@ FrameManager::SetUndisplayedContent(nsIContent* aContent,
mUndisplayedMap = new UndisplayedMap;
}
if (mUndisplayedMap) {
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = aContent->GetParent();
NS_ASSERTION(parent, "undisplayed content must have a parent");
if (parent) {
mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext);
@ -861,9 +859,7 @@ FrameManager::ChangeUndisplayedContent(nsIContent* aContent,
printf("ChangeUndisplayedContent(%d): p=%p \n", i++, (void *)aContent);
#endif
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(parent);
for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(aContent->GetParent());
node; node = node->mNext) {
if (node->mContent == aContent) {
node->mStyle = aStyleContext;

View File

@ -1393,8 +1393,7 @@ nsPresContext::LoadImage(const nsString& aURL,
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(content));
if (content && element) {
nsCOMPtr<nsIDocument> document;
rv = content->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = content->GetDocument();
// If there is no document, skip the policy check
// XXXldb This really means the document is being destroyed, so

View File

@ -4343,9 +4343,8 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
// XXX: The dependency on the command dispatcher needs to be fixed.
nsIContent* content = aFrame->GetContent();
if (content) {
nsCOMPtr<nsIDocument> document;
content->GetDocument(getter_AddRefs(document));
if(document){
nsIDocument* document = content->GetDocument();
if (document){
nsCOMPtr<nsIFocusController> focusController;
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
@ -5769,9 +5768,7 @@ PresShell::GetCurrentEventFrame()
// then we assume it is no longer in the content tree and the
// frame shouldn't get an event, nor should we even assume its
// safe to try and find the frame.
nsCOMPtr<nsIDocument> doc;
nsresult result = mCurrentEventContent->GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(result) && doc) {
if (mCurrentEventContent->GetDocument()) {
GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame);
}
}
@ -5836,9 +5833,9 @@ PRBool PresShell::InZombieDocument(nsIContent *aContent)
// Such documents cannot handle DOM events.
// It might actually be in a node not attached to any document,
// in which case there is not parent presshell to retarget it to.
nsCOMPtr<nsIDocument> doc;
mCurrentEventContent->GetDocument(getter_AddRefs(doc));
return !doc;
// XXXbz shouldn't this use aContent->GetDocument? Good thing we
// only call it on mCurrentEventContent....
return !mCurrentEventContent->GetDocument();
}
nsresult PresShell::RetargetEventToParent(nsIView *aView,
@ -6088,8 +6085,7 @@ PresShell::HandleEvent(nsIView *aView,
// will *not* go away. And this happens on every mousemove.
while (targetElement &&
!targetElement->IsContentOfType(nsIContent::eELEMENT)) {
nsIContent* temp = targetElement;
temp->GetParent(getter_AddRefs(targetElement));
targetElement = targetElement->GetParent();
}
// If we found an element, target it. Otherwise, target *nothing*.

View File

@ -352,21 +352,22 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
return NS_ERROR_NULL_POINTER;
range->GetCommonAncestorContainer(getter_AddRefs(commonParent));
nsCOMPtr<nsIContent> tmp, selContent( do_QueryInterface(commonParent) );
while (selContent)
for (nsCOMPtr<nsIContent> selContent(do_QueryInterface(commonParent));
selContent;
selContent = selContent->GetParent())
{
// checking for selection inside a plaintext form widget
nsCOMPtr<nsIAtom> atom;
selContent->GetTag(getter_AddRefs(atom));
if (atom.get() == nsHTMLAtoms::input ||
atom.get() == nsHTMLAtoms::textarea)
if (atom == nsHTMLAtoms::input ||
atom == nsHTMLAtoms::textarea)
{
*aIsPlainTextContext = PR_TRUE;
break;
}
if (atom.get() == nsHTMLAtoms::body)
if (atom == nsHTMLAtoms::body)
{
// check for moz prewrap style on body. If it's there we are
// in a plaintext editor. This is pretty cheezy but I haven't
@ -380,8 +381,6 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
break;
}
}
selContent->GetParent(getter_AddRefs(tmp));
selContent = tmp;
}
// also consider ourselves in a text widget if we can't find an html document

View File

@ -1393,8 +1393,7 @@ nsPresContext::LoadImage(const nsString& aURL,
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(content));
if (content && element) {
nsCOMPtr<nsIDocument> document;
rv = content->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = content->GetDocument();
// If there is no document, skip the policy check
// XXXldb This really means the document is being destroyed, so

View File

@ -388,9 +388,8 @@ nsComboboxControlFrame::Init(nsIPresContext* aPresContext,
// Start - Temporary fix for Bug 36558
//-------------------------------
mGoodToGo = PR_FALSE;
nsCOMPtr<nsIDocument> document;
nsresult rv = aContent->GetDocument(getter_AddRefs(document));
if (NS_SUCCEEDED(rv) && document) {
nsIDocument* document = aContent->GetDocument();
if (document) {
#ifdef MOZ_XUL
nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(document));
mGoodToGo = xulDoc?PR_FALSE:PR_TRUE;
@ -2124,8 +2123,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
mDisplayContent = do_QueryInterface(labelContent);
mDisplayContent->SetText(NS_LITERAL_STRING("X"), PR_TRUE);
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
// mContent->AppendChildTo(labelContent, PR_FALSE, PR_FALSE);
nsCOMPtr<nsINodeInfoManager> nimgr;

View File

@ -139,8 +139,7 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
nsISupportsArray& aChildList)
{
// Get the NodeInfoManager and tag necessary to create input elements
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsCOMPtr<nsINodeInfoManager> nimgr;
nsresult rv = doc->GetNodeInfoManager(getter_AddRefs(nimgr));
NS_ENSURE_SUCCESS(rv, rv);
@ -269,10 +268,9 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
if (!content)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
result = content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (!doc)
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
result = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));

View File

@ -110,13 +110,12 @@ nsGfxButtonControlFrame::IsFileBrowseButton(PRInt32 type)
// Check to see if parent is a file input
nsresult result;
nsCOMPtr<nsIContent> parentContent;
result = mContent->GetParent(getter_AddRefs(parentContent));
if (NS_SUCCEEDED(result) && parentContent) {
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent) {
nsCOMPtr<nsIAtom> atom;
result = parentContent->GetTag(getter_AddRefs(atom));
if (NS_SUCCEEDED(result) && atom) {
if (atom.get() == nsHTMLAtoms::input) {
if (atom == nsHTMLAtoms::input) {
// It's an input, is it a file input?
nsAutoString value;

View File

@ -227,8 +227,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
nsresult result;
// Get the node info manager (used to create hr's and input's)
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsCOMPtr<nsINodeInfoManager> nimgr;
result = doc->GetNodeInfoManager(getter_AddRefs(nimgr));
NS_ENSURE_SUCCESS(result, result);
@ -417,8 +416,7 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
// Get the document.
// We'll need it now to form the URL we're submitting to.
// We'll also need it later to get the DOM window when notifying form submit observers (bug 33203)
nsCOMPtr<nsIDocument> document;
mContent->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = mContent->GetDocument();
if (!document) return NS_OK; // No doc means don't submit, see Bug 28988
// Resolve url to an absolute url
@ -506,8 +504,7 @@ void nsIsIndexFrame::GetSubmitCharset(nsCString& oCharset)
// see 17.3 The FORM element in HTML 4 for details
// Get the charset from document
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = mContent->GetDocument();
if (doc) {
doc->GetDocumentCharacterSet(oCharset);
}

View File

@ -1455,17 +1455,10 @@ nsListControlFrame::IsOptionElement(nsIContent* aContent)
nsIContent *
nsListControlFrame::GetOptionFromContent(nsIContent *aContent)
{
nsCOMPtr<nsIContent> content = aContent;
while (content) {
for (nsIContent* content = aContent; content; content = content->GetParent()) {
if (IsOptionElement(content)) {
nsIContent *out = content;
NS_ADDREF(out);
return out;
return content;
}
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
parent.swap(content);
}
return nsnull;
@ -2899,7 +2892,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
nsCOMPtr<nsIContent> content;
stateManager->GetEventTargetContent(nsnull, getter_AddRefs(content));
nsCOMPtr<nsIContent> optionContent = getter_AddRefs(GetOptionFromContent(content));
nsCOMPtr<nsIContent> optionContent = GetOptionFromContent(content);
if (optionContent) {
aCurIndex = GetIndexFromContent(optionContent);
rv = NS_OK;
@ -3109,8 +3102,7 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement)
// and then adds in the parent's y coord
// XXX this assume only one level of nesting of optgroups
// which is all the spec specifies at the moment.
nsCOMPtr<nsIContent> parentContent;
aOptElement->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIContent> parentContent = aOptElement->GetParent();
nsCOMPtr<nsIDOMHTMLOptGroupElement> optGroup(do_QueryInterface(parentContent));
nsRect optRect(0,0,0,0);
if (optGroup) {

View File

@ -262,22 +262,19 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection*
mFrame->GetFormContent(*getter_AddRefs(content));
if (content)
{
nsCOMPtr<nsIDocument> doc;
if (NS_SUCCEEDED(content->GetDocument(getter_AddRefs(doc))))
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (doc)
{
if (doc)
nsCOMPtr<nsIPresShell> presShell;
doc->GetShellAt(0, getter_AddRefs(presShell));
if (presShell)
{
nsCOMPtr<nsIPresShell> presShell;
doc->GetShellAt(0, getter_AddRefs(presShell));
if (presShell)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_FORM_SELECTED;
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_FORM_SELECTED;
presShell->HandleEventWithTarget(&event,mFrame,content,NS_EVENT_FLAG_INIT,&status);
}
presShell->HandleEventWithTarget(&event,mFrame,content,NS_EVENT_FLAG_INIT,&status);
}
}
}
@ -384,12 +381,11 @@ nsTextInputListener::UpdateTextInputCommands(const nsAString& commandsToUpdate)
nsIContent* content = mFrame->GetContent();
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> doc;
nsresult rv = content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
rv = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
nsresult rv = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(scriptGlobalObject);

View File

@ -228,8 +228,10 @@ NS_IMETHODIMP BRFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
{
if (!mContent)
return NS_ERROR_NULL_POINTER;
nsresult result = mContent->GetParent(aContent);
if (NS_SUCCEEDED(result) && *aContent)
NS_IF_ADDREF(*aContent = mContent->GetParent());
nsresult result = NS_OK;
if (*aContent)
result = (*aContent)->IndexOf(mContent, aOffsetBegin);
aOffsetEnd = aOffsetBegin;
aBeginFrameContent = PR_TRUE;
@ -241,14 +243,11 @@ NS_IMETHODIMP BRFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStru
if (!aPos)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIContent> parentContent;
PRInt32 offsetBegin; //offset of this content in its parents child list. base 0
nsresult result = mContent->GetParent(getter_AddRefs(parentContent));
if (NS_SUCCEEDED(result) && parentContent)
result = parentContent->IndexOf(mContent, offsetBegin);
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent)
parentContent->IndexOf(mContent, offsetBegin);
if (aPos->mAmount != eSelectLine && aPos->mAmount != eSelectBeginLine
&& aPos->mAmount != eSelectEndLine) //then we must do the adjustment to make sure we leave this frame

View File

@ -144,7 +144,7 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
nsCOMPtr<nsIURI> documentURI;
nsCOMPtr<nsIDocument> doc;
if (mContent) {
(void) mContent->GetDocument(getter_AddRefs(doc));
doc = mContent->GetDocument();
if (doc) {
doc->GetDocumentURL(getter_AddRefs(documentURI));
}
@ -1648,7 +1648,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
nsCOMPtr<nsIURI> documentURI;
nsCOMPtr<nsIDocument> doc;
if (mContent) {
(void) mContent->GetDocument(getter_AddRefs(doc));
doc = mContent->GetDocument();
if (doc) {
doc->GetDocumentURL(getter_AddRefs(documentURI));
}

View File

@ -857,12 +857,12 @@ nsFrame::Paint(nsIPresContext* aPresContext,
return NS_OK; //if frame does not allow selection. do nothing
nsCOMPtr<nsIContent> newContent;
result = mContent->GetParent(getter_AddRefs(newContent));
nsCOMPtr<nsIContent> newContent = mContent->GetParent();
//check to see if we are anonymouse content
//check to see if we are anonymous content
PRInt32 offset;
if (NS_SUCCEEDED(result) && newContent){
if (newContent) {
// XXXbz there has GOT to be a better way of determining this!
result = newContent->IndexOf(mContent, offset);
if (NS_FAILED(result))
return result;
@ -1098,9 +1098,7 @@ nsFrame::GetDataForTableSelection(nsIFrameSelection *aFrameSelection,
nsIContent* tableOrCellContent = frame->GetContent();
if (!tableOrCellContent) return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> parentContent;
result = tableOrCellContent->GetParent(getter_AddRefs(parentContent));
if (NS_FAILED(result)) return result;
nsCOMPtr<nsIContent> parentContent = tableOrCellContent->GetParent();
if (!parentContent) return NS_ERROR_FAILURE;
PRInt32 offset;
@ -1331,11 +1329,10 @@ nsFrame::HandlePress(nsIPresContext* aPresContext,
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
if (!isEditor && !keyEvent->isAlt) {
nsCOMPtr<nsIContent> content;
GetContent (getter_AddRefs(content));
static NS_NAMED_LITERAL_STRING(simple, "simple");
while (content) {
for (nsIContent* content = mContent; content;
content = content->GetParent()) {
// are we a link with an href? If so, bail out now!
nsAutoString href;
// a?
@ -1379,12 +1376,6 @@ nsFrame::HandlePress(nsIPresContext* aPresContext,
frameRect.y <= aEvent->point.y && (frameRect.y + frameRect.height >= aEvent->point.y))
return NS_OK;
}
// now try the parent
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
content.swap(parent);
} // if browser, not editor
}
@ -2007,11 +1998,9 @@ nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
nsIContent* kidContent = GetContent();
if (kidContent) {
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIContent> content = kidContent->GetParent();
result = kidContent->GetParent(getter_AddRefs(content));
if (NS_SUCCEEDED(result) && content) {
if (content) {
PRInt32 kidCount = 0;
result = content->ChildCount(kidCount);
@ -2120,7 +2109,7 @@ nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
thisRect.x = offsetPoint.x;
thisRect.y = offsetPoint.y;
result = mContent->GetParent(aNewContent);
NS_IF_ADDREF(*aNewContent = mContent->GetParent());
if (*aNewContent){
PRInt32 contentOffset(aContentOffset); //temp to hold old value in case of failure
@ -2660,9 +2649,7 @@ PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
nsIContent* content = aFrame->GetContent();
if (content) {
nsCOMPtr<nsIContent> parentContent;
content->GetParent(getter_AddRefs(parentContent));
nsIContent* parentContent = content->GetParent();
if (parentContent) {
parentContent->IndexOf(content, result);
}
@ -3109,11 +3096,10 @@ nsFrame::GetPointFromOffset(nsIPresContext* inPresContext, nsIRenderingContext*
nsPoint bottomLeft(0, 0);
if (mContent)
{
nsCOMPtr<nsIContent> newContent;
PRInt32 newOffset;
nsresult result = mContent->GetParent(getter_AddRefs(newContent));
nsIContent* newContent = mContent->GetParent();
if (newContent){
result = newContent->IndexOf(mContent, newOffset);
PRInt32 newOffset;
nsresult result = newContent->IndexOf(mContent, newOffset);
if (NS_FAILED(result))
{
return result;
@ -3305,8 +3291,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsIPresContext* aPresContext,
nsIContent* content = resultFrame->GetContent();
if (content)
{
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
nsIContent* parent = content->GetParent();
if (parent)
{
aPos->mResultContent = parent;
@ -3665,10 +3650,9 @@ nsFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
{
if (mContent)
{
nsCOMPtr<nsIContent> newContent;
PRInt32 newOffset;
result = mContent->GetParent(getter_AddRefs(newContent));
nsIContent* newContent = mContent->GetParent();
if (newContent){
PRInt32 newOffset;
aPos->mResultContent = newContent;
result = newContent->IndexOf(mContent, newOffset);
if (aPos->mStartOffset < 0)//start at "end"

View File

@ -623,11 +623,8 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext,
}
// If the noResize attribute changes, dis/allow frame to be resized
else if (aAttribute == nsHTMLAtoms::noresize) {
nsCOMPtr<nsIContent> parentContent;
mContent->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIAtom> parentTag;
parentContent->GetTag(getter_AddRefs(parentTag));
mContent->GetParent()->GetTag(getter_AddRefs(parentTag));
if (parentTag == nsHTMLAtoms::frameset) {
nsIFrame* parentFrame = GetParent();

View File

@ -283,8 +283,7 @@ nsHTMLFramesetFrame::Observe(nsISupports* aObject, const char* aAction,
{
nsAutoString prefName(aPrefName);
if (prefName.Equals(NS_LITERAL_STRING(kFrameResizePref))) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
if (doc) {
doc->BeginUpdate();
doc->AttributeWillChange(mContent,
@ -707,15 +706,11 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild)
nsIContent* content = aChild->GetContent();
if (content) {
nsCOMPtr<nsIContent> contentParent;
content->GetParent(getter_AddRefs(contentParent));
nsCOMPtr<nsIContent> contentParent = content->GetParent();
nsCOMPtr<nsIHTMLContent> contentParent2 =
do_QueryInterface(contentParent);
if (contentParent2) {
if (contentParent && contentParent->IsContentOfType(nsIContent::eHTML)) {
nsCOMPtr<nsIAtom> tag;
contentParent2->GetTag(getter_AddRefs(tag));
contentParent->GetTag(getter_AddRefs(tag));
if (tag == nsHTMLAtoms::frameset) {
nsIFrame* fptr = aChild->GetParent();

View File

@ -1325,15 +1325,10 @@ IsInitialContainingBlock(nsIFrame* aFrame)
{
nsIContent* content = aFrame->GetContent();
if (content) {
nsCOMPtr<nsIContent> parentContent;
content->GetParent(getter_AddRefs(parentContent));
if (!parentContent) {
// The containing block corresponds to the document element so it's
// the initial containing block
return PR_TRUE;
}
if (content && !content->GetParent()) {
// The containing block corresponds to the document element so it's
// the initial containing block
return PR_TRUE;
}
return PR_FALSE;
}
@ -2780,13 +2775,10 @@ nsHTMLReflowState::IsBidiFormControl(nsIPresContext* aPresContext)
// find out if the reflow root is a descendant of a form control.
// Otherwise, just test this content node
if (mReflowDepth == 0) {
while (content) {
for ( ; content; content = content->GetParent()) {
if (content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {
return PR_TRUE;
}
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
content = parent;
}
} else {
return (content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL));

View File

@ -1428,8 +1428,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
selection->GetRangeCount(&rangeCount);
if (rangeCount == 1) //if not one then let code drop to nsFrame::Paint
{
nsCOMPtr<nsIContent> parentContent;
mContent->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent)
{
PRInt32 thisOffset;
@ -1473,8 +1472,7 @@ nsImageMap*
nsImageFrame::GetImageMap(nsIPresContext* aPresContext)
{
if (!mImageMap) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
return nsnull;
}
@ -1598,9 +1596,8 @@ nsImageFrame::GetAnchorHREFAndTarget(nsString& aHref, nsString& aTarget)
aTarget.Truncate();
// Walk up the content tree, looking for an nsIDOMAnchorElement
nsCOMPtr<nsIContent> content;
mContent->GetParent(getter_AddRefs(content));
while (content) {
for (nsIContent* content = mContent->GetParent();
content; content = content->GetParent()) {
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(content));
if (anchor) {
anchor->GetHref(aHref);
@ -1610,9 +1607,6 @@ nsImageFrame::GetAnchorHREFAndTarget(nsString& aHref, nsString& aTarget)
anchor->GetTarget(aTarget);
break;
}
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
content = parent;
}
return status;
}
@ -1891,13 +1885,10 @@ nsImageFrame::LoadIcon(const nsAString& aSpec,
void
nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const
{
nsresult rv;
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(mContent, &rv));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDocument> doc;
rv = htmlContent->GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(rv))
(void) doc->GetDocumentCharacterSet(aCharset);
if (mContent) {
NS_ASSERTION(mContent->GetDocument(),
"Frame still alive after content removed from document!");
mContent->GetDocument()->GetDocumentCharacterSet(aCharset);
}
}

View File

@ -448,6 +448,7 @@ void RectArea::ParseCoords(const nsAString& aSpec)
if (NS_FAILED(rv))
return;
// XXX GetOwnerDocument
nsCOMPtr<nsINodeInfo> nodeInfo;
mArea->GetNodeInfo(getter_AddRefs(nodeInfo));
NS_ASSERTION(nodeInfo, "Element with no nodeinfo");
@ -736,10 +737,12 @@ void CircleArea::GetRect(nsIPresContext* aCX, nsRect& aRect)
//----------------------------------------------------------------------
nsImageMap::nsImageMap()
nsImageMap::nsImageMap() :
mPresShell(nsnull),
mImageFrame(nsnull),
mDocument(nsnull),
mContainsBlockContents(PR_FALSE)
{
mDocument = nsnull;
mContainsBlockContents = PR_FALSE;
}
nsImageMap::~nsImageMap()
@ -759,8 +762,8 @@ nsImageMap::~nsImageMap()
}
FreeAreas();
if (nsnull != mDocument) {
mDocument->RemoveObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
if (mDocument) {
mDocument->RemoveObserver(this);
}
}
@ -815,12 +818,9 @@ nsImageMap::Init(nsIPresShell* aPresShell, nsIFrame* aImageFrame, nsIDOMHTMLMapE
nsresult rv;
mMap = do_QueryInterface(aMap, &rv);
NS_ASSERTION(mMap, "aMap is not an nsIHTMLContent!");
rv = mMap->GetDocument(&mDocument);
if (NS_SUCCEEDED(rv) && mDocument) {
mDocument->AddObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
// mDocument is a weak reference, so release the reference we got
nsIDocument *temp = mDocument;
NS_RELEASE(temp);
mDocument = mMap->GetDocument();
if (mDocument) {
mDocument->AddObserver(this);
}
// "Compile" the areas in the map into faster access versions
@ -1026,8 +1026,7 @@ PRBool
nsImageMap::IsAncestorOf(nsIContent* aContent,
nsIContent* aAncestorContent)
{
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContent->GetParent();
if (parent) {
return parent == aAncestorContent ||
IsAncestorOf(parent, aAncestorContent);
@ -1043,9 +1042,8 @@ nsImageMap::ContentChanged(nsIDocument *aDocument,
{
// If the parent of the changing content node is our map then update
// the map.
nsCOMPtr<nsIContent> parent;
nsresult rv = aContent->GetParent(getter_AddRefs(parent));
if (NS_SUCCEEDED(rv) && (nsnull != parent)) {
nsIContent* parent = aContent->GetParent();
if (parent) {
if ((parent == mMap) ||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
UpdateAreas();
@ -1063,8 +1061,7 @@ nsImageMap::AttributeChanged(nsIDocument *aDocument,
{
// If the parent of the changing content node is our map then update
// the map.
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = aContent->GetParent();
if ((parent == mMap) ||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
UpdateAreas();
@ -1153,9 +1150,9 @@ nsImageMap::ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus) {
//Set or Remove internal focus
area->HasFocus(aFocus);
//Now invalidate the rect
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIDocument> doc = targetContent->GetDocument();
//This check is necessary to see if we're still attached to the doc
if (NS_SUCCEEDED(targetContent->GetDocument(getter_AddRefs(doc))) && doc) {
if (doc) {
nsCOMPtr<nsIPresShell> presShell;
doc->GetShellAt(0, getter_AddRefs(presShell));
if (presShell) {

View File

@ -1591,8 +1591,7 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
// for THIS content node in order to call ->Print() on the right plugin
// first, we need to get the document
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER);
// now we need to get the shell for the screen
@ -1964,9 +1963,7 @@ nsresult nsObjectFrame::GetPluginInstance(nsIPluginInstance*& aPluginInstance)
nsresult
nsObjectFrame::NotifyContentObjectWrapper()
{
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIScriptGlobalObject> sgo;

View File

@ -658,7 +658,7 @@ public:
{}
};
nsIDocument* GetDocument(nsIPresContext* aPresContext);
already_AddRefed<nsIDocument> GetDocument(nsIPresContext* aPresContext);
PRIntn PrepareUnicodeText(nsTextTransformer& aTransformer,
nsAutoIndexBuffer* aIndexBuffer,
@ -1024,10 +1024,8 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent,
mSelectionPseudoBGIsTransparent = PR_FALSE;
if (aContent) {
nsCOMPtr<nsIContent> parentContent;
aContent->GetParent(getter_AddRefs(parentContent));
nsRefPtr<nsStyleContext> sc;
sc = aPresContext->ProbePseudoStyleContextFor(parentContent,
sc = aPresContext->ProbePseudoStyleContextFor(aContent->GetParent(),
nsCSSPseudoElements::mozSelection,
aStyleContext);
if (sc) {
@ -1347,20 +1345,15 @@ nsTextFrame::~nsTextFrame()
}
}
nsIDocument*
already_AddRefed<nsIDocument>
nsTextFrame::GetDocument(nsIPresContext* aPresContext)
{
nsIDocument* result = nsnull;
if (mContent) {
mContent->GetDocument(&result);
NS_IF_ADDREF(result = mContent->GetDocument());
}
if (!result && aPresContext) {
nsIPresShell* shell;
aPresContext->GetShell(&shell);
if (shell) {
shell->GetDocument(&result);
NS_RELEASE(shell);
}
aPresContext->GetPresShell()->GetDocument(&result);
}
return result;
}
@ -2519,7 +2512,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext,
*aNewContent = mContent;
aOffset =0;
}
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(aPresContext)));
nsCOMPtr<nsIDocument> doc(GetDocument(aPresContext));
// Make enough space to transform
nsAutoTextBuffer paintBuffer;
@ -3429,7 +3422,7 @@ nsTextFrame::GetPosition(nsIPresContext* aCX,
SetFontFromStyle(acx, mStyleContext);
// Get the renderable form of the text
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(aCX)));
nsCOMPtr<nsIDocument> doc(GetDocument(aCX));
nsCOMPtr<nsILineBreaker> lb;
doc->GetLineBreaker(getter_AddRefs(lb));
nsTextTransformer tx(lb, nsnull, aCX);
@ -3767,7 +3760,7 @@ nsTextFrame::GetPointFromOffset(nsIPresContext* aPresContext,
}
// Transform text from content into renderable form
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(aPresContext)));
nsCOMPtr<nsIDocument> doc(GetDocument(aPresContext));
nsCOMPtr<nsILineBreaker> lb;
doc->GetLineBreaker(getter_AddRefs(lb));
nsTextTransformer tx(lb, nsnull, aPresContext);
@ -3975,14 +3968,12 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
case eSelectNoAmount:
{
// Transform text from content into renderable form
nsIDocument* doc;
result = mContent->GetDocument(&doc);
if (NS_FAILED(result) || !doc) {
return result;
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
return NS_OK;
}
nsCOMPtr<nsILineBreaker> lb;
doc->GetLineBreaker(getter_AddRefs(lb));
NS_RELEASE(doc);
nsTextTransformer tx(lb, nsnull, aPresContext);
PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength);
@ -4007,14 +3998,12 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
case eSelectCharacter:
{
// Transform text from content into renderable form
nsIDocument* doc;
result = mContent->GetDocument(&doc);
if (NS_FAILED(result) || !doc) {
return result;
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
return NS_OK;
}
nsCOMPtr<nsILineBreaker> lb;
doc->GetLineBreaker(getter_AddRefs(lb));
NS_RELEASE(doc);
nsTextTransformer tx(lb, nsnull, aPresContext);
PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength);
@ -4153,9 +4142,8 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
case eSelectWord:
{
// Transform text from content into renderable form
nsIDocument* doc;
result = mContent->GetDocument(&doc);
if (NS_FAILED(result) || !doc) {
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
return result;
}
@ -4163,7 +4151,6 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
doc->GetLineBreaker(getter_AddRefs(lb));
nsCOMPtr<nsIWordBreaker> wb;
doc->GetWordBreaker(getter_AddRefs(wb));
NS_RELEASE(doc);
nsTextTransformer tx(lb, wb, aPresContext);
@ -5345,8 +5332,7 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext,
nscoord maxWidth = aReflowState.availableWidth;
// Setup text transformer to transform this frames text content
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
NS_WARNING("Content has no document.");
return NS_ERROR_FAILURE;

View File

@ -228,8 +228,10 @@ NS_IMETHODIMP BRFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
{
if (!mContent)
return NS_ERROR_NULL_POINTER;
nsresult result = mContent->GetParent(aContent);
if (NS_SUCCEEDED(result) && *aContent)
NS_IF_ADDREF(*aContent = mContent->GetParent());
nsresult result = NS_OK;
if (*aContent)
result = (*aContent)->IndexOf(mContent, aOffsetBegin);
aOffsetEnd = aOffsetBegin;
aBeginFrameContent = PR_TRUE;
@ -241,14 +243,11 @@ NS_IMETHODIMP BRFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStru
if (!aPos)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIContent> parentContent;
PRInt32 offsetBegin; //offset of this content in its parents child list. base 0
nsresult result = mContent->GetParent(getter_AddRefs(parentContent));
if (NS_SUCCEEDED(result) && parentContent)
result = parentContent->IndexOf(mContent, offsetBegin);
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent)
parentContent->IndexOf(mContent, offsetBegin);
if (aPos->mAmount != eSelectLine && aPos->mAmount != eSelectBeginLine
&& aPos->mAmount != eSelectEndLine) //then we must do the adjustment to make sure we leave this frame

View File

@ -144,7 +144,7 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
nsCOMPtr<nsIURI> documentURI;
nsCOMPtr<nsIDocument> doc;
if (mContent) {
(void) mContent->GetDocument(getter_AddRefs(doc));
doc = mContent->GetDocument();
if (doc) {
doc->GetDocumentURL(getter_AddRefs(documentURI));
}
@ -1648,7 +1648,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
nsCOMPtr<nsIURI> documentURI;
nsCOMPtr<nsIDocument> doc;
if (mContent) {
(void) mContent->GetDocument(getter_AddRefs(doc));
doc = mContent->GetDocument();
if (doc) {
doc->GetDocumentURL(getter_AddRefs(documentURI));
}

View File

@ -857,12 +857,12 @@ nsFrame::Paint(nsIPresContext* aPresContext,
return NS_OK; //if frame does not allow selection. do nothing
nsCOMPtr<nsIContent> newContent;
result = mContent->GetParent(getter_AddRefs(newContent));
nsCOMPtr<nsIContent> newContent = mContent->GetParent();
//check to see if we are anonymouse content
//check to see if we are anonymous content
PRInt32 offset;
if (NS_SUCCEEDED(result) && newContent){
if (newContent) {
// XXXbz there has GOT to be a better way of determining this!
result = newContent->IndexOf(mContent, offset);
if (NS_FAILED(result))
return result;
@ -1098,9 +1098,7 @@ nsFrame::GetDataForTableSelection(nsIFrameSelection *aFrameSelection,
nsIContent* tableOrCellContent = frame->GetContent();
if (!tableOrCellContent) return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> parentContent;
result = tableOrCellContent->GetParent(getter_AddRefs(parentContent));
if (NS_FAILED(result)) return result;
nsCOMPtr<nsIContent> parentContent = tableOrCellContent->GetParent();
if (!parentContent) return NS_ERROR_FAILURE;
PRInt32 offset;
@ -1331,11 +1329,10 @@ nsFrame::HandlePress(nsIPresContext* aPresContext,
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
if (!isEditor && !keyEvent->isAlt) {
nsCOMPtr<nsIContent> content;
GetContent (getter_AddRefs(content));
static NS_NAMED_LITERAL_STRING(simple, "simple");
while (content) {
for (nsIContent* content = mContent; content;
content = content->GetParent()) {
// are we a link with an href? If so, bail out now!
nsAutoString href;
// a?
@ -1379,12 +1376,6 @@ nsFrame::HandlePress(nsIPresContext* aPresContext,
frameRect.y <= aEvent->point.y && (frameRect.y + frameRect.height >= aEvent->point.y))
return NS_OK;
}
// now try the parent
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
content.swap(parent);
} // if browser, not editor
}
@ -2007,11 +1998,9 @@ nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
nsIContent* kidContent = GetContent();
if (kidContent) {
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIContent> content = kidContent->GetParent();
result = kidContent->GetParent(getter_AddRefs(content));
if (NS_SUCCEEDED(result) && content) {
if (content) {
PRInt32 kidCount = 0;
result = content->ChildCount(kidCount);
@ -2120,7 +2109,7 @@ nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
thisRect.x = offsetPoint.x;
thisRect.y = offsetPoint.y;
result = mContent->GetParent(aNewContent);
NS_IF_ADDREF(*aNewContent = mContent->GetParent());
if (*aNewContent){
PRInt32 contentOffset(aContentOffset); //temp to hold old value in case of failure
@ -2660,9 +2649,7 @@ PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
nsIContent* content = aFrame->GetContent();
if (content) {
nsCOMPtr<nsIContent> parentContent;
content->GetParent(getter_AddRefs(parentContent));
nsIContent* parentContent = content->GetParent();
if (parentContent) {
parentContent->IndexOf(content, result);
}
@ -3109,11 +3096,10 @@ nsFrame::GetPointFromOffset(nsIPresContext* inPresContext, nsIRenderingContext*
nsPoint bottomLeft(0, 0);
if (mContent)
{
nsCOMPtr<nsIContent> newContent;
PRInt32 newOffset;
nsresult result = mContent->GetParent(getter_AddRefs(newContent));
nsIContent* newContent = mContent->GetParent();
if (newContent){
result = newContent->IndexOf(mContent, newOffset);
PRInt32 newOffset;
nsresult result = newContent->IndexOf(mContent, newOffset);
if (NS_FAILED(result))
{
return result;
@ -3305,8 +3291,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsIPresContext* aPresContext,
nsIContent* content = resultFrame->GetContent();
if (content)
{
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
nsIContent* parent = content->GetParent();
if (parent)
{
aPos->mResultContent = parent;
@ -3665,10 +3650,9 @@ nsFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
{
if (mContent)
{
nsCOMPtr<nsIContent> newContent;
PRInt32 newOffset;
result = mContent->GetParent(getter_AddRefs(newContent));
nsIContent* newContent = mContent->GetParent();
if (newContent){
PRInt32 newOffset;
aPos->mResultContent = newContent;
result = newContent->IndexOf(mContent, newOffset);
if (aPos->mStartOffset < 0)//start at "end"

View File

@ -617,14 +617,14 @@ FrameManager::GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aResult)
// if any methods in here fail, don't report that failure
// we're just trying to enhance performance here, not test for correctness
nsFindFrameHint hint;
nsCOMPtr<nsIContent> prevSibling, parent;
rv = aContent->GetParent(getter_AddRefs(parent));
if (NS_SUCCEEDED(rv) && parent)
nsIContent* parent = aContent->GetParent();
if (parent)
{
PRInt32 index;
rv = parent->IndexOf(aContent, index);
if (NS_SUCCEEDED(rv) && index>0) // no use looking if it's the first child
if (NS_SUCCEEDED(rv) && index > 0) // no use looking if it's the first child
{
nsCOMPtr<nsIContent> prevSibling;
nsCOMPtr<nsIAtom> tag;
do {
parent->ChildAt(--index, getter_AddRefs(prevSibling));
@ -809,8 +809,7 @@ FrameManager::GetUndisplayedContent(nsIContent* aContent)
if (!aContent || !mUndisplayedMap)
return nsnull;
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = aContent->GetParent();
if (!parent)
return nsnull;
@ -839,8 +838,7 @@ FrameManager::SetUndisplayedContent(nsIContent* aContent,
mUndisplayedMap = new UndisplayedMap;
}
if (mUndisplayedMap) {
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = aContent->GetParent();
NS_ASSERTION(parent, "undisplayed content must have a parent");
if (parent) {
mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext);
@ -861,9 +859,7 @@ FrameManager::ChangeUndisplayedContent(nsIContent* aContent,
printf("ChangeUndisplayedContent(%d): p=%p \n", i++, (void *)aContent);
#endif
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(parent);
for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(aContent->GetParent());
node; node = node->mNext) {
if (node->mContent == aContent) {
node->mStyle = aStyleContext;

View File

@ -380,8 +380,8 @@ HRuleFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aPresContext,
thisRect.x = offsetPoint.x;
thisRect.y = offsetPoint.y;
rv = mContent->GetParent(aNewContent);
if (!*aNewContent) return rv;
NS_IF_ADDREF(*aNewContent = mContent->GetParent());
if (!*aNewContent) return NS_OK;
rv = (*aNewContent)->IndexOf(mContent, aContentOffset);
if (NS_FAILED(rv)) return rv;

View File

@ -1325,15 +1325,10 @@ IsInitialContainingBlock(nsIFrame* aFrame)
{
nsIContent* content = aFrame->GetContent();
if (content) {
nsCOMPtr<nsIContent> parentContent;
content->GetParent(getter_AddRefs(parentContent));
if (!parentContent) {
// The containing block corresponds to the document element so it's
// the initial containing block
return PR_TRUE;
}
if (content && !content->GetParent()) {
// The containing block corresponds to the document element so it's
// the initial containing block
return PR_TRUE;
}
return PR_FALSE;
}
@ -2780,13 +2775,10 @@ nsHTMLReflowState::IsBidiFormControl(nsIPresContext* aPresContext)
// find out if the reflow root is a descendant of a form control.
// Otherwise, just test this content node
if (mReflowDepth == 0) {
while (content) {
for ( ; content; content = content->GetParent()) {
if (content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {
return PR_TRUE;
}
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
content = parent;
}
} else {
return (content->IsContentOfType(nsIContent::eHTML_FORM_CONTROL));

View File

@ -1428,8 +1428,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
selection->GetRangeCount(&rangeCount);
if (rangeCount == 1) //if not one then let code drop to nsFrame::Paint
{
nsCOMPtr<nsIContent> parentContent;
mContent->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent)
{
PRInt32 thisOffset;
@ -1473,8 +1472,7 @@ nsImageMap*
nsImageFrame::GetImageMap(nsIPresContext* aPresContext)
{
if (!mImageMap) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
return nsnull;
}
@ -1598,9 +1596,8 @@ nsImageFrame::GetAnchorHREFAndTarget(nsString& aHref, nsString& aTarget)
aTarget.Truncate();
// Walk up the content tree, looking for an nsIDOMAnchorElement
nsCOMPtr<nsIContent> content;
mContent->GetParent(getter_AddRefs(content));
while (content) {
for (nsIContent* content = mContent->GetParent();
content; content = content->GetParent()) {
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(content));
if (anchor) {
anchor->GetHref(aHref);
@ -1610,9 +1607,6 @@ nsImageFrame::GetAnchorHREFAndTarget(nsString& aHref, nsString& aTarget)
anchor->GetTarget(aTarget);
break;
}
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
content = parent;
}
return status;
}
@ -1891,13 +1885,10 @@ nsImageFrame::LoadIcon(const nsAString& aSpec,
void
nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const
{
nsresult rv;
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(mContent, &rv));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDocument> doc;
rv = htmlContent->GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(rv))
(void) doc->GetDocumentCharacterSet(aCharset);
if (mContent) {
NS_ASSERTION(mContent->GetDocument(),
"Frame still alive after content removed from document!");
mContent->GetDocument()->GetDocumentCharacterSet(aCharset);
}
}

View File

@ -448,6 +448,7 @@ void RectArea::ParseCoords(const nsAString& aSpec)
if (NS_FAILED(rv))
return;
// XXX GetOwnerDocument
nsCOMPtr<nsINodeInfo> nodeInfo;
mArea->GetNodeInfo(getter_AddRefs(nodeInfo));
NS_ASSERTION(nodeInfo, "Element with no nodeinfo");
@ -736,10 +737,12 @@ void CircleArea::GetRect(nsIPresContext* aCX, nsRect& aRect)
//----------------------------------------------------------------------
nsImageMap::nsImageMap()
nsImageMap::nsImageMap() :
mPresShell(nsnull),
mImageFrame(nsnull),
mDocument(nsnull),
mContainsBlockContents(PR_FALSE)
{
mDocument = nsnull;
mContainsBlockContents = PR_FALSE;
}
nsImageMap::~nsImageMap()
@ -759,8 +762,8 @@ nsImageMap::~nsImageMap()
}
FreeAreas();
if (nsnull != mDocument) {
mDocument->RemoveObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
if (mDocument) {
mDocument->RemoveObserver(this);
}
}
@ -815,12 +818,9 @@ nsImageMap::Init(nsIPresShell* aPresShell, nsIFrame* aImageFrame, nsIDOMHTMLMapE
nsresult rv;
mMap = do_QueryInterface(aMap, &rv);
NS_ASSERTION(mMap, "aMap is not an nsIHTMLContent!");
rv = mMap->GetDocument(&mDocument);
if (NS_SUCCEEDED(rv) && mDocument) {
mDocument->AddObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
// mDocument is a weak reference, so release the reference we got
nsIDocument *temp = mDocument;
NS_RELEASE(temp);
mDocument = mMap->GetDocument();
if (mDocument) {
mDocument->AddObserver(this);
}
// "Compile" the areas in the map into faster access versions
@ -1026,8 +1026,7 @@ PRBool
nsImageMap::IsAncestorOf(nsIContent* aContent,
nsIContent* aAncestorContent)
{
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContent->GetParent();
if (parent) {
return parent == aAncestorContent ||
IsAncestorOf(parent, aAncestorContent);
@ -1043,9 +1042,8 @@ nsImageMap::ContentChanged(nsIDocument *aDocument,
{
// If the parent of the changing content node is our map then update
// the map.
nsCOMPtr<nsIContent> parent;
nsresult rv = aContent->GetParent(getter_AddRefs(parent));
if (NS_SUCCEEDED(rv) && (nsnull != parent)) {
nsIContent* parent = aContent->GetParent();
if (parent) {
if ((parent == mMap) ||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
UpdateAreas();
@ -1063,8 +1061,7 @@ nsImageMap::AttributeChanged(nsIDocument *aDocument,
{
// If the parent of the changing content node is our map then update
// the map.
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = aContent->GetParent();
if ((parent == mMap) ||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
UpdateAreas();
@ -1153,9 +1150,9 @@ nsImageMap::ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus) {
//Set or Remove internal focus
area->HasFocus(aFocus);
//Now invalidate the rect
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIDocument> doc = targetContent->GetDocument();
//This check is necessary to see if we're still attached to the doc
if (NS_SUCCEEDED(targetContent->GetDocument(getter_AddRefs(doc))) && doc) {
if (doc) {
nsCOMPtr<nsIPresShell> presShell;
doc->GetShellAt(0, getter_AddRefs(presShell));
if (presShell) {

View File

@ -1591,8 +1591,7 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
// for THIS content node in order to call ->Print() on the right plugin
// first, we need to get the document
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER);
// now we need to get the shell for the screen
@ -1964,9 +1963,7 @@ nsresult nsObjectFrame::GetPluginInstance(nsIPluginInstance*& aPluginInstance)
nsresult
nsObjectFrame::NotifyContentObjectWrapper()
{
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIScriptGlobalObject> sgo;

View File

@ -4343,9 +4343,8 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
// XXX: The dependency on the command dispatcher needs to be fixed.
nsIContent* content = aFrame->GetContent();
if (content) {
nsCOMPtr<nsIDocument> document;
content->GetDocument(getter_AddRefs(document));
if(document){
nsIDocument* document = content->GetDocument();
if (document){
nsCOMPtr<nsIFocusController> focusController;
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
@ -5769,9 +5768,7 @@ PresShell::GetCurrentEventFrame()
// then we assume it is no longer in the content tree and the
// frame shouldn't get an event, nor should we even assume its
// safe to try and find the frame.
nsCOMPtr<nsIDocument> doc;
nsresult result = mCurrentEventContent->GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(result) && doc) {
if (mCurrentEventContent->GetDocument()) {
GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame);
}
}
@ -5836,9 +5833,9 @@ PRBool PresShell::InZombieDocument(nsIContent *aContent)
// Such documents cannot handle DOM events.
// It might actually be in a node not attached to any document,
// in which case there is not parent presshell to retarget it to.
nsCOMPtr<nsIDocument> doc;
mCurrentEventContent->GetDocument(getter_AddRefs(doc));
return !doc;
// XXXbz shouldn't this use aContent->GetDocument? Good thing we
// only call it on mCurrentEventContent....
return !mCurrentEventContent->GetDocument();
}
nsresult PresShell::RetargetEventToParent(nsIView *aView,
@ -6088,8 +6085,7 @@ PresShell::HandleEvent(nsIView *aView,
// will *not* go away. And this happens on every mousemove.
while (targetElement &&
!targetElement->IsContentOfType(nsIContent::eELEMENT)) {
nsIContent* temp = targetElement;
temp->GetParent(getter_AddRefs(targetElement));
targetElement = targetElement->GetParent();
}
// If we found an element, target it. Otherwise, target *nothing*.

View File

@ -658,7 +658,7 @@ public:
{}
};
nsIDocument* GetDocument(nsIPresContext* aPresContext);
already_AddRefed<nsIDocument> GetDocument(nsIPresContext* aPresContext);
PRIntn PrepareUnicodeText(nsTextTransformer& aTransformer,
nsAutoIndexBuffer* aIndexBuffer,
@ -1024,10 +1024,8 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent,
mSelectionPseudoBGIsTransparent = PR_FALSE;
if (aContent) {
nsCOMPtr<nsIContent> parentContent;
aContent->GetParent(getter_AddRefs(parentContent));
nsRefPtr<nsStyleContext> sc;
sc = aPresContext->ProbePseudoStyleContextFor(parentContent,
sc = aPresContext->ProbePseudoStyleContextFor(aContent->GetParent(),
nsCSSPseudoElements::mozSelection,
aStyleContext);
if (sc) {
@ -1347,20 +1345,15 @@ nsTextFrame::~nsTextFrame()
}
}
nsIDocument*
already_AddRefed<nsIDocument>
nsTextFrame::GetDocument(nsIPresContext* aPresContext)
{
nsIDocument* result = nsnull;
if (mContent) {
mContent->GetDocument(&result);
NS_IF_ADDREF(result = mContent->GetDocument());
}
if (!result && aPresContext) {
nsIPresShell* shell;
aPresContext->GetShell(&shell);
if (shell) {
shell->GetDocument(&result);
NS_RELEASE(shell);
}
aPresContext->GetPresShell()->GetDocument(&result);
}
return result;
}
@ -2519,7 +2512,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext,
*aNewContent = mContent;
aOffset =0;
}
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(aPresContext)));
nsCOMPtr<nsIDocument> doc(GetDocument(aPresContext));
// Make enough space to transform
nsAutoTextBuffer paintBuffer;
@ -3429,7 +3422,7 @@ nsTextFrame::GetPosition(nsIPresContext* aCX,
SetFontFromStyle(acx, mStyleContext);
// Get the renderable form of the text
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(aCX)));
nsCOMPtr<nsIDocument> doc(GetDocument(aCX));
nsCOMPtr<nsILineBreaker> lb;
doc->GetLineBreaker(getter_AddRefs(lb));
nsTextTransformer tx(lb, nsnull, aCX);
@ -3767,7 +3760,7 @@ nsTextFrame::GetPointFromOffset(nsIPresContext* aPresContext,
}
// Transform text from content into renderable form
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(aPresContext)));
nsCOMPtr<nsIDocument> doc(GetDocument(aPresContext));
nsCOMPtr<nsILineBreaker> lb;
doc->GetLineBreaker(getter_AddRefs(lb));
nsTextTransformer tx(lb, nsnull, aPresContext);
@ -3975,14 +3968,12 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
case eSelectNoAmount:
{
// Transform text from content into renderable form
nsIDocument* doc;
result = mContent->GetDocument(&doc);
if (NS_FAILED(result) || !doc) {
return result;
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
return NS_OK;
}
nsCOMPtr<nsILineBreaker> lb;
doc->GetLineBreaker(getter_AddRefs(lb));
NS_RELEASE(doc);
nsTextTransformer tx(lb, nsnull, aPresContext);
PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength);
@ -4007,14 +3998,12 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
case eSelectCharacter:
{
// Transform text from content into renderable form
nsIDocument* doc;
result = mContent->GetDocument(&doc);
if (NS_FAILED(result) || !doc) {
return result;
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
return NS_OK;
}
nsCOMPtr<nsILineBreaker> lb;
doc->GetLineBreaker(getter_AddRefs(lb));
NS_RELEASE(doc);
nsTextTransformer tx(lb, nsnull, aPresContext);
PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength);
@ -4153,9 +4142,8 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
case eSelectWord:
{
// Transform text from content into renderable form
nsIDocument* doc;
result = mContent->GetDocument(&doc);
if (NS_FAILED(result) || !doc) {
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
return result;
}
@ -4163,7 +4151,6 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
doc->GetLineBreaker(getter_AddRefs(lb));
nsCOMPtr<nsIWordBreaker> wb;
doc->GetWordBreaker(getter_AddRefs(wb));
NS_RELEASE(doc);
nsTextTransformer tx(lb, wb, aPresContext);
@ -5345,8 +5332,7 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext,
nscoord maxWidth = aReflowState.availableWidth;
// Setup text transformer to transform this frames text content
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = mContent->GetDocument();
if (!doc) {
NS_WARNING("Content has no document.");
return NS_ERROR_FAILURE;

View File

@ -623,11 +623,8 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext,
}
// If the noResize attribute changes, dis/allow frame to be resized
else if (aAttribute == nsHTMLAtoms::noresize) {
nsCOMPtr<nsIContent> parentContent;
mContent->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIAtom> parentTag;
parentContent->GetTag(getter_AddRefs(parentTag));
mContent->GetParent()->GetTag(getter_AddRefs(parentTag));
if (parentTag == nsHTMLAtoms::frameset) {
nsIFrame* parentFrame = GetParent();

View File

@ -283,8 +283,7 @@ nsHTMLFramesetFrame::Observe(nsISupports* aObject, const char* aAction,
{
nsAutoString prefName(aPrefName);
if (prefName.Equals(NS_LITERAL_STRING(kFrameResizePref))) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
if (doc) {
doc->BeginUpdate();
doc->AttributeWillChange(mContent,
@ -707,15 +706,11 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild)
nsIContent* content = aChild->GetContent();
if (content) {
nsCOMPtr<nsIContent> contentParent;
content->GetParent(getter_AddRefs(contentParent));
nsCOMPtr<nsIContent> contentParent = content->GetParent();
nsCOMPtr<nsIHTMLContent> contentParent2 =
do_QueryInterface(contentParent);
if (contentParent2) {
if (contentParent && contentParent->IsContentOfType(nsIContent::eHTML)) {
nsCOMPtr<nsIAtom> tag;
contentParent2->GetTag(getter_AddRefs(tag));
contentParent->GetTag(getter_AddRefs(tag));
if (tag == nsHTMLAtoms::frameset) {
nsIFrame* fptr = aChild->GetParent();

View File

@ -388,9 +388,8 @@ nsComboboxControlFrame::Init(nsIPresContext* aPresContext,
// Start - Temporary fix for Bug 36558
//-------------------------------
mGoodToGo = PR_FALSE;
nsCOMPtr<nsIDocument> document;
nsresult rv = aContent->GetDocument(getter_AddRefs(document));
if (NS_SUCCEEDED(rv) && document) {
nsIDocument* document = aContent->GetDocument();
if (document) {
#ifdef MOZ_XUL
nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(document));
mGoodToGo = xulDoc?PR_FALSE:PR_TRUE;
@ -2124,8 +2123,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
mDisplayContent = do_QueryInterface(labelContent);
mDisplayContent->SetText(NS_LITERAL_STRING("X"), PR_TRUE);
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
// mContent->AppendChildTo(labelContent, PR_FALSE, PR_FALSE);
nsCOMPtr<nsINodeInfoManager> nimgr;

View File

@ -139,8 +139,7 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
nsISupportsArray& aChildList)
{
// Get the NodeInfoManager and tag necessary to create input elements
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsCOMPtr<nsINodeInfoManager> nimgr;
nsresult rv = doc->GetNodeInfoManager(getter_AddRefs(nimgr));
NS_ENSURE_SUCCESS(rv, rv);
@ -269,10 +268,9 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
if (!content)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
result = content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (!doc)
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
result = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));

View File

@ -110,13 +110,12 @@ nsGfxButtonControlFrame::IsFileBrowseButton(PRInt32 type)
// Check to see if parent is a file input
nsresult result;
nsCOMPtr<nsIContent> parentContent;
result = mContent->GetParent(getter_AddRefs(parentContent));
if (NS_SUCCEEDED(result) && parentContent) {
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent) {
nsCOMPtr<nsIAtom> atom;
result = parentContent->GetTag(getter_AddRefs(atom));
if (NS_SUCCEEDED(result) && atom) {
if (atom.get() == nsHTMLAtoms::input) {
if (atom == nsHTMLAtoms::input) {
// It's an input, is it a file input?
nsAutoString value;

View File

@ -227,8 +227,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
nsresult result;
// Get the node info manager (used to create hr's and input's)
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsCOMPtr<nsINodeInfoManager> nimgr;
result = doc->GetNodeInfoManager(getter_AddRefs(nimgr));
NS_ENSURE_SUCCESS(result, result);
@ -417,8 +416,7 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
// Get the document.
// We'll need it now to form the URL we're submitting to.
// We'll also need it later to get the DOM window when notifying form submit observers (bug 33203)
nsCOMPtr<nsIDocument> document;
mContent->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = mContent->GetDocument();
if (!document) return NS_OK; // No doc means don't submit, see Bug 28988
// Resolve url to an absolute url
@ -506,8 +504,7 @@ void nsIsIndexFrame::GetSubmitCharset(nsCString& oCharset)
// see 17.3 The FORM element in HTML 4 for details
// Get the charset from document
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = mContent->GetDocument();
if (doc) {
doc->GetDocumentCharacterSet(oCharset);
}

View File

@ -1455,17 +1455,10 @@ nsListControlFrame::IsOptionElement(nsIContent* aContent)
nsIContent *
nsListControlFrame::GetOptionFromContent(nsIContent *aContent)
{
nsCOMPtr<nsIContent> content = aContent;
while (content) {
for (nsIContent* content = aContent; content; content = content->GetParent()) {
if (IsOptionElement(content)) {
nsIContent *out = content;
NS_ADDREF(out);
return out;
return content;
}
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
parent.swap(content);
}
return nsnull;
@ -2899,7 +2892,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
nsCOMPtr<nsIContent> content;
stateManager->GetEventTargetContent(nsnull, getter_AddRefs(content));
nsCOMPtr<nsIContent> optionContent = getter_AddRefs(GetOptionFromContent(content));
nsCOMPtr<nsIContent> optionContent = GetOptionFromContent(content);
if (optionContent) {
aCurIndex = GetIndexFromContent(optionContent);
rv = NS_OK;
@ -3109,8 +3102,7 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement)
// and then adds in the parent's y coord
// XXX this assume only one level of nesting of optgroups
// which is all the spec specifies at the moment.
nsCOMPtr<nsIContent> parentContent;
aOptElement->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIContent> parentContent = aOptElement->GetParent();
nsCOMPtr<nsIDOMHTMLOptGroupElement> optGroup(do_QueryInterface(parentContent));
nsRect optRect(0,0,0,0);
if (optGroup) {

View File

@ -262,22 +262,19 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection*
mFrame->GetFormContent(*getter_AddRefs(content));
if (content)
{
nsCOMPtr<nsIDocument> doc;
if (NS_SUCCEEDED(content->GetDocument(getter_AddRefs(doc))))
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (doc)
{
if (doc)
nsCOMPtr<nsIPresShell> presShell;
doc->GetShellAt(0, getter_AddRefs(presShell));
if (presShell)
{
nsCOMPtr<nsIPresShell> presShell;
doc->GetShellAt(0, getter_AddRefs(presShell));
if (presShell)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_FORM_SELECTED;
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_FORM_SELECTED;
presShell->HandleEventWithTarget(&event,mFrame,content,NS_EVENT_FLAG_INIT,&status);
}
presShell->HandleEventWithTarget(&event,mFrame,content,NS_EVENT_FLAG_INIT,&status);
}
}
}
@ -384,12 +381,11 @@ nsTextInputListener::UpdateTextInputCommands(const nsAString& commandsToUpdate)
nsIContent* content = mFrame->GetContent();
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> doc;
nsresult rv = content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
rv = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
nsresult rv = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(scriptGlobalObject);

View File

@ -7985,17 +7985,14 @@ ShouldIgnoreSelectChild(nsIContent* aContainer)
if (containerTag == nsHTMLAtoms::optgroup ||
containerTag == nsHTMLAtoms::select) {
nsCOMPtr<nsIContent> selectContent = aContainer;
nsCOMPtr<nsIContent> tmpContent;
nsIContent* selectContent = aContainer;
while (selectContent) {
if (containerTag == nsHTMLAtoms::select)
while (containerTag != nsHTMLAtoms::select) {
selectContent = selectContent->GetParent();
if (!selectContent) {
break;
tmpContent = selectContent;
tmpContent->GetParent(getter_AddRefs(selectContent));
if (selectContent)
selectContent->GetTag(getter_AddRefs(containerTag));
}
selectContent->GetTag(getter_AddRefs(containerTag));
}
nsCOMPtr<nsISelectElement> selectElement = do_QueryInterface(selectContent);
@ -8097,11 +8094,11 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext,
PRBool hasInsertion = PR_FALSE;
if (!multiple) {
nsCOMPtr<nsIBindingManager> bindingManager;
nsCOMPtr<nsIDocument> document;
nsIDocument* document = nsnull;
nsCOMPtr<nsIContent> firstAppendedChild;
aContainer->ChildAt(aNewIndexInContainer, getter_AddRefs(firstAppendedChild));
if (firstAppendedChild) {
firstAppendedChild->GetDocument(getter_AddRefs(document));
document = firstAppendedChild->GetDocument();
}
if (document)
document->GetBindingManager(getter_AddRefs(bindingManager));
@ -8969,8 +8966,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext,
// Check again to see if the frame we are manipulating is part
// of a block-in-inline hierarchy.
if (IsFrameSpecial(parentFrame)) {
nsCOMPtr<nsIContent> parentContainer;
blockContent->GetParent(getter_AddRefs(parentContainer));
nsCOMPtr<nsIContent> parentContainer = blockContent->GetParent();
#ifdef DEBUG
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ContentInserted: parentFrame=");
@ -9944,8 +9940,7 @@ nsCSSFrameConstructor::ContentChanged(nsIPresContext* aPresContext,
if (haveFirstLetterStyle) {
// The block has first-letter style. Use content-replaced to
// repair the blocks frame structure properly.
nsCOMPtr<nsIContent> container;
aContent->GetParent(getter_AddRefs(container));
nsCOMPtr<nsIContent> container = aContent->GetParent();
if (container) {
PRInt32 ix;
container->IndexOf(aContent, ix);
@ -10055,18 +10050,10 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
return NS_OK;
}
inline already_AddRefed<nsIContent>
parent_of(nsIContent *aContent)
{
nsIContent *parent = nsnull;
aContent->GetParent(&parent);
return parent;
}
static PRBool
IsAncestorOf(nsIContent *aAncestor, nsIContent *aDescendant)
{
for (nsCOMPtr<nsIContent> n = aDescendant; n; n = parent_of(n))
for (nsIContent* n = aDescendant; n; n = n->GetParent())
if (n == aAncestor)
return PR_TRUE;
return PR_FALSE;
@ -11272,10 +11259,8 @@ nsCSSFrameConstructor::FindFrameWithContent(nsIPresContext* aPresContext,
// child frames, too.
// We also need to search if the child content is anonymous and scoped
// to the parent content.
nsCOMPtr<nsIContent> parentScope;
kidContent->GetBindingParent(getter_AddRefs(parentScope));
if (aParentContent == kidContent ||
(aParentContent && (aParentContent == parentScope)))
(aParentContent && (aParentContent == kidContent->GetBindingParent())))
{
#ifdef NOISY_FINDFRAME
FFWC_recursions++;
@ -11358,14 +11343,13 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext,
// - internal table frames (row-group, row, cell, col-group, col)
//
// That means we need to need to search for the frame
nsCOMPtr<nsIContent> parentContent; // we get this one time
nsIFrame* parentFrame; // this pointer is used to iterate across all frames that map to parentContent
// Get the frame that corresponds to the parent content object.
// Note that this may recurse indirectly, because the pres shell will
// call us back if there is no mapping in the hash table
aContent->GetParent(getter_AddRefs(parentContent));
if (parentContent.get()) {
nsCOMPtr<nsIContent> parentContent = aContent->GetParent(); // Get this once
if (parentContent) {
aFrameManager->GetPrimaryFrameFor(parentContent, &parentFrame);
while (parentFrame) {
// Search the child frames for a match
@ -11455,8 +11439,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIPresShell* aPresShell,
if (!container)
return NS_OK;
nsCOMPtr<nsIDocument> document;
container->GetDocument(getter_AddRefs(document));
nsIDocument* document = container->GetDocument();
if (!document)
return NS_OK;
@ -11469,9 +11452,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIPresShell* aPresShell,
if (aChildContent) {
// We've got an explicit insertion child. Check to see if it's
// anonymous.
nsCOMPtr<nsIContent> bindingParent;
aChildContent->GetBindingParent(getter_AddRefs(bindingParent));
if (bindingParent == container) {
if (aChildContent->GetBindingParent() == container) {
// This child content is anonymous. Don't use the insertion
// point, since that's only for the explicit kids.
return NS_OK;
@ -11585,8 +11566,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext,
// If there is no document, we don't want to recreate frames for it. (You
// shouldn't generally be giving this method content without a document
// anyway).
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = aContent->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
// Is the frame `special'? If so, we need to reframe the containing
@ -11630,8 +11610,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext,
}
nsresult rv = NS_OK;
nsCOMPtr<nsIContent> container;
aContent->GetParent(getter_AddRefs(container));
nsCOMPtr<nsIContent> container = aContent->GetParent();
if (container) {
PRInt32 indexInContainer;
rv = container->IndexOf(aContent, indexInContainer);
@ -11667,8 +11646,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext,
// However, double check that it's really part of the document,
// since rebuilding the frame tree can have bad effects, especially
// if it's the frame tree for chrome (see bug 157322).
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = aContent->GetDocument();
NS_ASSERTION(doc, "received style change for content not in document");
if (doc)
ReconstructDocElementHierarchy(aPresContext);
@ -13336,8 +13314,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext,
// Tell parent of the containing block to reformulate the
// entire block. This is painful and definitely not optimal
// but it will *always* get the right answer.
nsCOMPtr<nsIContent> parentContainer;
aBlockContent->GetParent(getter_AddRefs(parentContainer));
nsCOMPtr<nsIContent> parentContainer = aBlockContent->GetParent();
#ifdef DEBUG
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::WipeContainingBlock: aBlockContent=%p parentContainer=%p\n",
@ -13662,11 +13639,10 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIPresContext* aPresContext, nsIF
// so GetFloaterContainingBlock(aPresContext, aFrame) has been removed
// And get the containingBlock's content
nsIContent* blockContent = containingBlock->GetContent();
nsCOMPtr<nsIContent> blockContent = containingBlock->GetContent();
if (blockContent) {
// Now find the containingBlock's content's parent
nsCOMPtr<nsIContent> parentContainer;
blockContent->GetParent(getter_AddRefs(parentContainer));
nsCOMPtr<nsIContent> parentContainer = blockContent->GetParent();
if (parentContainer) {
#ifdef DEBUG
if (gNoisyContentUpdates) {

View File

@ -2797,22 +2797,16 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
// a root, other wise keep going in order to let the theme stuff
// draw the background. The canvas really should be drawing the
// bg, but there's no way to hook that up via css.
const nsStyleDisplay* displayData = aForFrame->GetStyleDisplay();
if (displayData->mAppearance) {
nsIContent* content = aForFrame->GetContent();
if (content) {
nsCOMPtr<nsIContent> parent;
content->GetParent(getter_AddRefs(parent));
if (parent)
return;
else
color = aForFrame->GetStyleBackground();
}
else
return;
}
else
if (!aForFrame->GetStyleDisplay()->mAppearance) {
return;
}
nsIContent* content = aForFrame->GetContent();
if (!content || content->GetParent()) {
return;
}
color = aForFrame->GetStyleBackground();
}
if (!isCanvas) {
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,

View File

@ -53,9 +53,8 @@ ChildIterator::Init(nsIContent* aContent,
if (! aContent)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(getter_AddRefs(doc));
NS_ASSERTION(doc != nsnull, "element not in the document");
nsCOMPtr<nsIDocument> doc = aContent->GetDocument();
NS_ASSERTION(doc, "element not in the document");
if (! doc)
return NS_ERROR_FAILURE;

View File

@ -630,7 +630,7 @@ nsMathMLFrame::MapAttributesIntoCSS(nsIPresContext* aPresContext,
if (!sheet) {
// first time... we do this to defer the lookup up to the
// point where we encounter attributes that actually matter
aContent->GetDocument(getter_AddRefs(doc));
doc = aContent->GetDocument();
if (!doc)
return 0;
GetMathMLAttributeStyleSheet(aPresContext, getter_AddRefs(sheet));

View File

@ -672,8 +672,7 @@ nsBox::GetBorder(nsMargin& aMargin)
nsCOMPtr<nsIContent> content;
frame->GetContent(getter_AddRefs(content));
if (content) {
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (doc) {
nsCOMPtr<nsIPresShell> shell;
doc->GetShellAt(0, getter_AddRefs(shell));

View File

@ -179,8 +179,7 @@ nsBoxObject::GetOffsetRect(nsRect& aRect)
aRect.x = aRect.y = 0;
aRect.Empty();
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
if (doc) {
// Get Presentation shell 0
@ -284,8 +283,7 @@ nsBoxObject::GetScreenRect(nsRect& aRect)
aRect.x = aRect.y = 0;
aRect.Empty();
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
if (doc) {
// Get Presentation shell 0

View File

@ -124,8 +124,7 @@ nsDocElementBoxFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
return NS_ERROR_FAILURE;
nsCOMPtr<nsINodeInfoManager> nodeInfoManager;
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = mContent->GetDocument();
if (!doc)
// The page is currently being torn down. Why bother.
return NS_ERROR_FAILURE;

View File

@ -476,7 +476,7 @@ nsImageBoxFrame::UpdateImage(nsIPresContext* aPresContext, PRBool& aResize)
nsCOMPtr<nsIURI> documentURI;
nsCOMPtr<nsIDocument> doc;
if (mContent) {
(void) mContent->GetDocument(getter_AddRefs(doc));
doc = mContent->GetDocument();
if (doc) {
doc->GetDocumentURL(getter_AddRefs(documentURI));
}

View File

@ -579,8 +579,7 @@ nsListBoxBodyFrame::GetIndexOfItem(nsIDOMElement* aItem, PRInt32* _retval)
*_retval = 0;
nsCOMPtr<nsIContent> itemContent(do_QueryInterface(aItem));
nsCOMPtr<nsIContent> listbox;
mContent->GetBindingParent(getter_AddRefs(listbox));
nsIContent* listbox = mContent->GetBindingParent();
PRInt32 childCount = 0;
listbox->ChildCount(childCount);
@ -612,8 +611,7 @@ nsListBoxBodyFrame::GetItemAtIndex(PRInt32 aIndex, nsIDOMElement** _retval)
if (aIndex < 0)
return NS_ERROR_ILLEGAL_VALUE;
nsCOMPtr<nsIContent> listbox;
mContent->GetBindingParent(getter_AddRefs(listbox));
nsIContent* listbox = mContent->GetBindingParent();
PRInt32 childCount = 0;
listbox->ChildCount(childCount);
@ -750,8 +748,7 @@ nsListBoxBodyFrame::ComputeIntrinsicWidth(nsBoxLayoutState& aBoxLayoutState)
styleContext->GetStyleMargin()->GetMargin(margin);
width += (margin.left + margin.right);
nsCOMPtr<nsIContent> listbox;
mContent->GetBindingParent(getter_AddRefs(listbox));
nsIContent* listbox = mContent->GetBindingParent();
PRInt32 childCount;
listbox->ChildCount(childCount);
@ -803,8 +800,7 @@ nsListBoxBodyFrame::ComputeIntrinsicWidth(nsBoxLayoutState& aBoxLayoutState)
void
nsListBoxBodyFrame::ComputeTotalRowCount()
{
nsCOMPtr<nsIContent> listbox;
mContent->GetBindingParent(getter_AddRefs(listbox));
nsIContent* listbox = mContent->GetBindingParent();
PRInt32 childCount;
listbox->ChildCount(childCount);
@ -856,9 +852,7 @@ nsListBoxBodyFrame::DoScrollToIndex(PRInt32 aRowIndex, PRBool aForceDestruct)
// This change has to happen immediately.
// Flush any pending reflow commands.
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
doc->FlushPendingNotifications();
mContent->GetDocument()->FlushPendingNotifications();
return NS_OK;
}
@ -1147,8 +1141,7 @@ nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated)
// We need to insert rows before the top frame
nsCOMPtr<nsIContent> topContent;
mTopFrame->GetContent(getter_AddRefs(topContent));
nsCOMPtr<nsIContent> topParent;
topContent->GetParent(getter_AddRefs(topParent));
nsIContent* topParent = topContent->GetParent();
PRInt32 contentIndex;
topParent->IndexOf(topContent, contentIndex);
contentIndex -= aOffset;
@ -1206,8 +1199,7 @@ nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset, PRBool* aCreat
PRInt32 i, childCount;
nsCOMPtr<nsIContent> prevContent;
frame->GetContent(getter_AddRefs(prevContent));
nsCOMPtr<nsIContent> parentContent;
prevContent->GetParent(getter_AddRefs(parentContent));
nsIContent* parentContent = prevContent->GetParent();
parentContent->IndexOf(prevContent, i);
parentContent->ChildCount(childCount);
if (i+aOffset+1 < childCount) {
@ -1356,10 +1348,9 @@ nsListBoxBodyFrame::OnContentRemoved(nsIPresContext* aPresContext, nsIFrame* aCh
if (!aChildFrame) {
// The row we are removing is out of view, so we need to try to
// determine the index of its next sibling.
nsCOMPtr<nsIContent> listboxContent;
mContent->GetBindingParent(getter_AddRefs(listboxContent));
nsCOMPtr<nsIContent> oldNextSiblingContent;
listboxContent->ChildAt(aIndex, getter_AddRefs(oldNextSiblingContent));
mContent->GetBindingParent()->ChildAt(aIndex,
getter_AddRefs(oldNextSiblingContent));
PRInt32 siblingIndex = -1;
if (oldNextSiblingContent) {
nsCOMPtr<nsIContent> nextSiblingContent;
@ -1382,8 +1373,7 @@ nsListBoxBodyFrame::OnContentRemoved(nsIPresContext* aPresContext, nsIFrame* aCh
// down by one, and we will have to insert a new frame at the top.
// if the last content node has a frame, we are scrolled to the bottom
nsCOMPtr<nsIContent> listBoxContent;
mContent->GetBindingParent(getter_AddRefs(listBoxContent));
nsIContent* listBoxContent = mContent->GetBindingParent();
PRInt32 childCount;
listBoxContent->ChildCount(childCount);
if (childCount > 0) {
@ -1426,8 +1416,7 @@ nsListBoxBodyFrame::OnContentRemoved(nsIPresContext* aPresContext, nsIFrame* aCh
void
nsListBoxBodyFrame::GetListItemContentAt(PRInt32 aIndex, nsIContent** aContent)
{
nsCOMPtr<nsIContent> listboxContent;
mContent->GetBindingParent(getter_AddRefs(listboxContent));
nsIContent* listboxContent = mContent->GetBindingParent();
PRInt32 childCount;
listboxContent->ChildCount(childCount);
@ -1452,8 +1441,7 @@ nsListBoxBodyFrame::GetListItemContentAt(PRInt32 aIndex, nsIContent** aContent)
void
nsListBoxBodyFrame::GetListItemNextSibling(nsIContent* aListItem, nsIContent** aContent, PRInt32& aSiblingIndex)
{
nsCOMPtr<nsIContent> listboxContent;
mContent->GetBindingParent(getter_AddRefs(listboxContent));
nsIContent* listboxContent = mContent->GetBindingParent();
aSiblingIndex = -1;

View File

@ -186,8 +186,7 @@ FindBodyContent(nsIContent* aParent, nsIContent** aResult)
NS_IF_ADDREF(*aResult);
}
else {
nsCOMPtr<nsIDocument> doc;
aParent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = aParent->GetDocument();
nsCOMPtr<nsIBindingManager> bindingManager;
doc->GetBindingManager(getter_AddRefs(bindingManager));
nsCOMPtr<nsIDOMNodeList> kids;

View File

@ -153,9 +153,7 @@ nsMenuBarFrame::Init(nsIPresContext* aPresContext,
// Hook up the menu bar as a key listener on the whole document. It will see every
// key press that occurs, but after everyone else does.
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(doc);
nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(aContent->GetDocument());
mTarget = target;

View File

@ -1512,11 +1512,8 @@ nsMenuFrame::BuildAcceleratorText()
if (keyValue.IsEmpty())
return;
nsCOMPtr<nsIDocument> document;
mContent->GetDocument(getter_AddRefs(document));
// Turn the document into a DOM document so we can use getElementById
nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(document));
nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(mContent->GetDocument()));
if (!domDocument)
return;
@ -1710,14 +1707,12 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent)
// XXX HACK. Just gracefully exit if the node has been removed, e.g., window.close()
// was executed.
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsIFrame* primary = nsnull;
if (shell) shell->GetPrimaryFrameFor(content, &primary);
// Now properly close them all up.
if (doc && (primary == me) && mMenuParent) // <-- HACK IS HERE. ICK.
if (content->GetDocument() && // <-- HACK IS HERE. ICK.
(primary == me) && mMenuParent)
mMenuParent->DismissChain();
// END HACK
@ -1764,9 +1759,7 @@ nsMenuFrame::OnCreate()
// of them has a command attribute. If so, then several attributes must
// potentially be updated.
if (child) {
nsCOMPtr<nsIDocument> doc;
child->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(child->GetDocument()));
PRInt32 count;
child->ChildCount(count);

View File

@ -223,8 +223,7 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext,
widgetData.mBorderStyle = eBorderStyle_default;
widgetData.clipSiblings = PR_TRUE;
nsCOMPtr<nsIContent> parentContent;
aContent->GetParent(getter_AddRefs(parentContent));
nsIContent* parentContent = aContent->GetParent();
nsCOMPtr<nsIAtom> tag;
if (parentContent)
parentContent->GetTag(getter_AddRefs(tag));
@ -632,8 +631,7 @@ nsMenuPopupFrame::AdjustClientXYForNestedDocuments ( nsIDOMXULDocument* inPopupD
nsCOMPtr<nsIContent> targetAsContent ( do_QueryInterface(targetNode) );
nsCOMPtr<nsIWidget> targetDocumentWidget;
if ( targetAsContent ) {
nsCOMPtr<nsIDocument> targetDocument;
targetAsContent->GetDocument(getter_AddRefs(targetDocument));
nsCOMPtr<nsIDocument> targetDocument = targetAsContent->GetDocument();
if (targetDocument) {
nsCOMPtr<nsIPresShell> shell;
targetDocument->GetShellAt(0, getter_AddRefs(shell));
@ -1456,8 +1454,7 @@ NS_IMETHODIMP nsMenuPopupFrame::ConsumeOutsideClicks(PRBool& aConsumeOutsideClic
aConsumeOutsideClicks = PR_TRUE;
nsCOMPtr<nsIContent> parentContent;
mContent->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
if (parentContent) {
nsCOMPtr<nsIAtom> parentTag;
@ -1702,8 +1699,7 @@ nsMenuPopupFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, PRBool& doActi
nsIMenuFrame* frameAfter = nsnull;
nsIMenuFrame* frameShortcut = nsnull;
nsCOMPtr<nsIContent> parentContent;
mContent->GetParent(getter_AddRefs(parentContent));
nsIContent* parentContent = mContent->GetParent();
if (parentContent) {
nsCOMPtr<nsIAtom> tag;
parentContent->GetTag(getter_AddRefs(tag));
@ -2090,9 +2086,7 @@ nsMenuPopupFrame::InstallKeyboardNavigator()
if (mKeyboardNavigator)
return NS_OK;
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(doc);
nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(mContent->GetDocument());
mTarget = target;
mKeyboardNavigator = new nsMenuListener(this);

View File

@ -558,8 +558,7 @@ nsPopupSetFrame::ActivatePopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
// can get into trouble if a dialog with a modal event loop comes along and
// processes the reflows before we get to call DestroyChain(). Processing the
// reflow will cause the popup to show itself again. (bug 71219)
nsCOMPtr<nsIDocument> doc;
aEntry->mPopupContent->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = aEntry->mPopupContent->GetDocument();
if (doc)
doc->FlushPendingNotifications();
@ -613,9 +612,7 @@ nsPopupSetFrame::OnCreate(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent)
// of them has a command attribute. If so, then several attributes must
// potentially be updated.
nsCOMPtr<nsIDocument> doc;
aPopupContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aPopupContent->GetDocument()));
PRInt32 count;
aPopupContent->ChildCount(count);

View File

@ -139,10 +139,8 @@ nsXULTooltipListener::MouseOut(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsIDOMNode> targetNode(do_QueryInterface(eventTarget));
// which node is our tooltip on?
nsCOMPtr<nsIDocument> doc;
mCurrentTooltip->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(doc));
if (!doc) // remotely possible someone could have
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(mCurrentTooltip->GetDocument()));
if (!xulDoc) // remotely possible someone could have
return NS_OK; // removed tooltip from dom while it was open
nsCOMPtr<nsIDOMNode> tooltipNode;
xulDoc->GetTooltipNode (getter_AddRefs(tooltipNode));
@ -387,15 +385,11 @@ nsXULTooltipListener::ShowTooltip()
return NS_ERROR_FAILURE; // the target node doesn't need a tooltip
// set the node in the document that triggered the tooltip and show it
nsCOMPtr<nsIDocument> doc;
mCurrentTooltip->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(mCurrentTooltip->GetDocument()));
if (xulDoc) {
// Make sure the target node is still attached to some document.
// It might have been deleted.
nsCOMPtr<nsIDocument> targetDoc;
mSourceNode->GetDocument(getter_AddRefs(targetDoc));
if (targetDoc) {
if (mSourceNode->GetDocument()) {
#ifdef MOZ_XUL
if (!mIsSourceTree) {
mLastTreeRow = -1;
@ -426,8 +420,7 @@ nsXULTooltipListener::ShowTooltip()
(nsIDOMMouseListener*)this, PR_FALSE);
// listen for mousedown,keydown, and DOMMouseScroll events at document level
nsCOMPtr<nsIDocument> doc;
mSourceNode->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = mSourceNode->GetDocument();
if (doc) {
evtTarget = do_QueryInterface(doc);
evtTarget->AddEventListener(NS_LITERAL_STRING("DOMMouseScroll"),
@ -567,8 +560,8 @@ nsXULTooltipListener::GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip)
return NS_ERROR_FAILURE; // could be a text node or something
// before we go on, make sure that target node still has a window
nsCOMPtr<nsIDocument> document;
if (NS_FAILED(aTarget->GetDocument(getter_AddRefs(document))) || !document) {
nsCOMPtr<nsIDocument> document = aTarget->GetDocument();
if (!document) {
NS_ERROR("Unable to retrieve the tooltip node document.");
return NS_ERROR_FAILURE;
}
@ -645,8 +638,7 @@ nsXULTooltipListener::DestroyTooltip()
{
if (mCurrentTooltip) {
// clear out the tooltip node on the document
nsCOMPtr<nsIDocument> doc;
mCurrentTooltip->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mCurrentTooltip->GetDocument();
if (doc) {
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(doc));
if (xulDoc)
@ -726,9 +718,7 @@ nsXULTooltipListener::GetSourceTreeBoxObject(nsITreeBoxObject** aBoxObject)
*aBoxObject = nsnull;
if (mIsSourceTree && mSourceNode) {
nsCOMPtr<nsIContent> treeParent;
mSourceNode->GetParent(getter_AddRefs(treeParent));
nsCOMPtr<nsIDOMXULElement> xulEl(do_QueryInterface(treeParent));
nsCOMPtr<nsIDOMXULElement> xulEl(do_QueryInterface(mSourceNode->GetParent()));
if (xulEl) {
nsCOMPtr<nsIBoxObject> bx;
xulEl->GetBoxObject(getter_AddRefs(bx));

View File

@ -265,8 +265,7 @@ nsTreeColumn::nsTreeColumn(nsIContent* aColElement, nsIFrame* aFrame)
// Cache our index.
mColIndex = -1;
nsCOMPtr<nsIContent> parent;
mColElement->GetParent(getter_AddRefs(parent));
nsIContent* parent = mColElement->GetParent();
PRInt32 count;
parent->ChildCount(count);
PRInt32 j = 0;
@ -559,12 +558,9 @@ nsTreeBodyFrame::EnsureBoxObject()
GetBaseElement(getter_AddRefs(parent));
if (parent) {
nsCOMPtr<nsIDocument> parentDoc;
parent->GetDocument(getter_AddRefs(parentDoc));
if (!parentDoc) // there may be no document, if we're called from Destroy()
nsCOMPtr<nsIDOMNSDocument> nsDoc = do_QueryInterface(parent->GetDocument());
if (!nsDoc) // there may be no document, if we're called from Destroy()
return;
nsCOMPtr<nsIDOMNSDocument> nsDoc = do_QueryInterface(parentDoc);
nsCOMPtr<nsIBoxObject> box;
nsCOMPtr<nsIDOMElement> domElem = do_QueryInterface(parent);
nsDoc->GetBoxObjectFor(domElem, getter_AddRefs(box));
@ -612,9 +608,7 @@ nsTreeBodyFrame::EnsureView()
// If we don't have a box object yet, or no view was set on it,
// look for a XULTreeBuilder or create a content view.
nsCOMPtr<nsIContent> parent;
mContent->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIDOMXULElement> xulele = do_QueryInterface(parent);
nsCOMPtr<nsIDOMXULElement> xulele = do_QueryInterface(mContent->GetParent());
if (xulele) {
nsCOMPtr<nsITreeView> view;
@ -1117,9 +1111,7 @@ nsTreeBodyFrame::AdjustEventCoordsToBoxCoordSpace (PRInt32 aX, PRInt32 aY, PRInt
aY = NSToIntRound(aY * pixelsToTwips);
// Get our box object.
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(mContent->GetDocument()));
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mContent));
nsCOMPtr<nsIBoxObject> boxObject;
@ -1952,8 +1944,7 @@ nsTreeBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUs
nsCOMPtr<imgIDecoderObserver> imgDecoderObserver = listener;
nsCOMPtr<nsIURI> baseURI;
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
if (!doc)
// The page is currently being torn down. Why bother.
return NS_ERROR_FAILURE;
@ -3522,18 +3513,16 @@ nsTreeBodyFrame::EnsureColumns()
nsresult
nsTreeBodyFrame::GetBaseElement(nsIContent** aContent)
{
nsCOMPtr<nsIContent> parent = mContent;
nsCOMPtr<nsIAtom> tag;
nsCOMPtr<nsIContent> temp;
while (parent && NS_SUCCEEDED(parent->GetTag(getter_AddRefs(tag)))
&& tag != nsXULAtoms::tree && tag != nsHTMLAtoms::select) {
temp = parent;
temp->GetParent(getter_AddRefs(parent));
nsIContent* parent;
for (parent = mContent;
parent && NS_SUCCEEDED(parent->GetTag(getter_AddRefs(tag)))
&& tag != nsXULAtoms::tree && tag != nsHTMLAtoms::select;
parent = parent->GetParent()) {
// Do nothing; we just go up till we hit the right tag or run off the tree
}
*aContent = parent;
NS_IF_ADDREF(*aContent);
NS_IF_ADDREF(*aContent = parent);
return NS_OK;
}

View File

@ -201,14 +201,10 @@ nsTreeColFrame::EnsureTree()
{
if (!mTree && mContent) {
// Get our parent node.
nsCOMPtr<nsIContent> parent;
mContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = mContent->GetParent();
if (parent) {
nsCOMPtr<nsIContent> grandParent;
parent->GetParent(getter_AddRefs(grandParent));
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(doc));
nsIContent* grandParent = parent->GetParent();
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(mContent->GetDocument()));
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(grandParent));
nsCOMPtr<nsIBoxObject> boxObject;

View File

@ -551,8 +551,7 @@ nsTreeContentView::SetTree(nsITreeBoxObject* aTree)
mRoot = do_QueryInterface(element);
// Add ourselves to document's observers.
nsCOMPtr<nsIDocument> document;
mRoot->GetDocument(getter_AddRefs(document));
nsIDocument* document = mRoot->GetDocument();
if (document) {
document->AddObserver(this);
mDocument = document;
@ -757,8 +756,7 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
nsCOMPtr<nsIContent> parent = aContent;
nsCOMPtr<nsIAtom> parentTag;
do {
nsCOMPtr<nsIContent> temp = parent;
temp->GetParent(getter_AddRefs(parent));
parent = parent->GetParent();
if (parent)
parent->GetTag(getter_AddRefs(parentTag));
} while (parent && parentTag != nsXULAtoms::tree);
@ -783,11 +781,9 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
}
else if (!hidden && index < 0) {
// Show this row along with its children.
nsCOMPtr<nsIContent> container;
aContent->GetParent(getter_AddRefs(container));
nsCOMPtr<nsIContent> container = aContent->GetParent();
if (container) {
nsCOMPtr<nsIContent> parent;
container->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = container->GetParent();
if (parent)
InsertRowFor(parent, container, aContent);
}
@ -843,8 +839,7 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
}
else if (tag == nsXULAtoms::treerow) {
if (aAttribute == nsXULAtoms::properties) {
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContent->GetParent();
if (parent) {
PRInt32 index = FindContent(parent);
if (index >= 0) {
@ -859,11 +854,9 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
aAttribute == nsXULAtoms::mode ||
aAttribute == nsHTMLAtoms::value ||
aAttribute == nsHTMLAtoms::label) {
nsCOMPtr<nsIContent> parent;
aContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = aContent->GetParent();
if (parent) {
nsCOMPtr<nsIContent> grandParent;
parent->GetParent(getter_AddRefs(grandParent));
nsCOMPtr<nsIContent> grandParent = parent->GetParent();
if (grandParent) {
PRInt32 index = FindContent(grandParent);
if (index >= 0) {
@ -922,7 +915,7 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument,
nsCOMPtr<nsIContent> element = aContainer;
nsCOMPtr<nsIAtom> parentTag;
while (element) {
for (nsIContent* element = aContainer; element; element = element->GetParent()) {
element->GetTag(getter_AddRefs(parentTag));
if ((element->IsContentOfType(nsIContent::eXUL) && parentTag == nsXULAtoms::tree) ||
(element->IsContentOfType(nsIContent::eHTML) && parentTag == nsHTMLAtoms::select))
@ -930,14 +923,11 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument,
break;
else // this is not for us, we can bail out
return NS_OK;
nsCOMPtr<nsIContent> temp = element;
temp->GetParent(getter_AddRefs(element));
}
if (childTag == nsXULAtoms::treeitem ||
childTag == nsXULAtoms::treeseparator) {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if (parent)
InsertRowFor(parent, aContainer, aChild);
}
@ -969,8 +959,7 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument,
mBoxObject->InvalidateRow(index);
}
else if (childTag == nsXULAtoms::treecell) {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if (parent) {
PRInt32 index = FindContent(parent);
if (index >= 0)
@ -1023,10 +1012,9 @@ nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
// If we have a legal tag, go up to the tree/select and make sure
// that it's ours.
nsCOMPtr<nsIContent> element = aContainer;
nsCOMPtr<nsIAtom> parentTag;
while (element) {
for (nsIContent* element = aContainer; element; element = element->GetParent()) {
element->GetTag(getter_AddRefs(parentTag));
if ((element->IsContentOfType(nsIContent::eXUL) && parentTag == nsXULAtoms::tree) ||
(element->IsContentOfType(nsIContent::eHTML) && parentTag == nsHTMLAtoms::select))
@ -1034,8 +1022,6 @@ nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
break;
else // this is not for us, we can bail out
return NS_OK;
nsCOMPtr<nsIContent> temp = element;
temp->GetParent(getter_AddRefs(element));
}
if (tag == nsXULAtoms::treeitem ||
@ -1074,8 +1060,7 @@ nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
mBoxObject->InvalidateRow(index);
}
else if (tag == nsXULAtoms::treecell) {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if (parent) {
PRInt32 index = FindContent(parent);
if (index >= 0)

View File

@ -736,8 +736,7 @@ nsTreeSelection::FireOnSelectHandler()
boxObject->GetElement(getter_AddRefs(elt));
nsCOMPtr<nsIContent> content(do_QueryInterface(elt));
nsCOMPtr<nsIDocument> document;
content->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = content->GetDocument();
// we might be firing on a delay, so it's possible in rare cases that
// the document may have been destroyed by the time it fires