Bug 314095 - Eliminate nsIContent::GetDocument, r=jst

--HG--
extra : rebase_source : dd8f690940825b298a478b65b68a57418a9962ff
This commit is contained in:
Olli Pettay 2014-08-22 23:11:27 +03:00
parent 83699c0bf8
commit ceb34d2d4a
43 changed files with 98 additions and 102 deletions

View File

@ -1287,7 +1287,7 @@ Accessible::NativeAttributes()
// override properties on a widget they used in an iframe.
nsIContent* startContent = mContent;
while (startContent) {
nsIDocument* doc = startContent->GetDocument();
nsIDocument* doc = startContent->GetComposedDoc();
if (!doc)
break;

View File

@ -24,7 +24,7 @@
if (navigator.platform.startsWith("Mac")) {
SimpleTest.expectAssertions(0, 1);
} else {
SimpleTest.expectAssertions(1);
SimpleTest.expectAssertions(0, 1);
}
function doTest()

View File

@ -39,8 +39,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0x329f4c0f, 0x369d, 0x4f35, \
{ 0x9a, 0x49, 0xd6, 0xa3, 0xaf, 0xb4, 0x34, 0x9f } }
{ 0x697a2fe1, 0x5549, 0x48e7, \
{ 0x9a, 0x1a, 0xc2, 0x9d, 0xab, 0x14, 0xe2, 0x39 } }
/**
* A node of content in a document's content model. This interface
@ -112,16 +112,6 @@ public:
*/
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true) = 0;
/**
* DEPRECATED - Use GetCurrentDoc or GetOwnerDoc.
* Get the document for this content.
* @return the document
*/
nsIDocument *GetDocument() const
{
return GetCurrentDoc();
}
enum {
/**

View File

@ -1650,7 +1650,7 @@ Element::ShouldBlur(nsIContent *aContent)
{
// Determine if the current element is focused, if it is not focused
// then we should not try to blur
nsIDocument *document = aContent->GetDocument();
nsIDocument* document = aContent->GetComposedDoc();
if (!document)
return false;

View File

@ -1891,7 +1891,7 @@ nsresult
nsFrameLoader::GetWindowDimensions(nsIntRect& aRect)
{
// Need to get outer window position here
nsIDocument* doc = mOwnerContent->GetDocument();
nsIDocument* doc = mOwnerContent->GetComposedDoc();
if (!doc) {
return NS_ERROR_FAILURE;
}
@ -2065,7 +2065,10 @@ nsFrameLoader::TryRemoteBrowser()
{
NS_ASSERTION(!mRemoteBrowser, "TryRemoteBrowser called with a remote browser already?");
nsIDocument* doc = mOwnerContent->GetDocument();
//XXXsmaug Per spec (2014/08/21) frameloader should not work in case the
// element isn't in document, only in shadow dom, but that will change
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=26365#c0
nsIDocument* doc = mOwnerContent->GetComposedDoc();
if (!doc) {
return false;
}

View File

@ -322,7 +322,7 @@ nsPluginCrashedEvent::Run()
LOG(("OBJLC [%p]: Firing plugin crashed event\n",
mContent.get()));
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsCOMPtr<nsIDocument> doc = mContent->GetComposedDoc();
if (!doc) {
NS_WARNING("Couldn't get document for PluginCrashed event!");
return NS_OK;

View File

@ -199,7 +199,7 @@ HTMLAnchorElement::IsHTMLFocusable(bool aWithMouse,
}
// cannot focus links if there is no link handler
nsIDocument* doc = GetCurrentDoc();
nsIDocument* doc = GetComposedDoc();
if (doc) {
nsIPresShell* presShell = doc->GetShell();
if (presShell) {

View File

@ -453,7 +453,7 @@ HTMLBodyElement::GetAssociatedEditor()
}
// For designmode, try to get document's editor
nsPresContext* presContext = GetPresContext();
nsPresContext* presContext = GetPresContext(eForComposedDoc);
if (!presContext) {
return nullptr;
}

View File

@ -247,7 +247,6 @@ void
HTMLFormElement::Submit(ErrorResult& aRv)
{
// Send the submit event
nsRefPtr<nsPresContext> presContext = GetPresContext();
if (mPendingSubmission) {
// aha, we have a pending submission that was not flushed
// (this happens when form.submit() is called twice)

View File

@ -3188,7 +3188,7 @@ HTMLInputElement::Select()
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
nsRefPtr<nsPresContext> presContext = GetPresContext();
nsRefPtr<nsPresContext> presContext = GetPresContext(eForComposedDoc);
if (state == eInactiveWindow) {
if (fm)
fm->SetFocus(this, nsIFocusManager::FLAG_NOSCROLL);
@ -3961,7 +3961,8 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
fm->GetLastFocusMethod(document->GetWindow(), &lastFocusMethod);
if (lastFocusMethod &
(nsIFocusManager::FLAG_BYKEY | nsIFocusManager::FLAG_BYMOVEFOCUS)) {
nsRefPtr<nsPresContext> presContext = GetPresContext();
nsRefPtr<nsPresContext> presContext =
GetPresContext(eForComposedDoc);
if (DispatchSelectEvent(presContext)) {
SelectAll(presContext);
}

View File

@ -216,7 +216,7 @@ HTMLLabelElement::PerformAccesskey(bool aKeyCausesActivation,
if (element)
element->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
} else {
nsPresContext *presContext = GetPresContext();
nsPresContext *presContext = GetPresContext(eForUncomposedDoc);
if (!presContext)
return;

View File

@ -127,7 +127,7 @@ HTMLTextAreaElement::Select()
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
nsRefPtr<nsPresContext> presContext = GetPresContext();
nsRefPtr<nsPresContext> presContext = GetPresContext(eForComposedDoc);
if (state == eInactiveWindow) {
if (fm)
fm->SetFocus(this, nsIFocusManager::FLAG_NOSCROLL);

View File

@ -798,7 +798,7 @@ GetSubmitCharset(nsGenericHTMLElement* aForm,
}
// if there are no accept-charset or all the charset are not supported
// Get the charset from document
nsIDocument* doc = aForm->GetDocument();
nsIDocument* doc = aForm->GetComposedDoc();
if (doc) {
oCharset = doc->GetDocumentCharacterSet();
}

View File

@ -291,7 +291,8 @@ static const nsAttrValue::EnumTable kDirTable[] = {
void
nsGenericHTMLElement::GetAccessKeyLabel(nsString& aLabel)
{
nsPresContext *presContext = GetPresContext();
//XXXsmaug We shouldn't need PresContext for this.
nsPresContext *presContext = GetPresContext(eForComposedDoc);
if (presContext) {
nsAutoString suffix;
@ -1111,12 +1112,12 @@ nsGenericHTMLElement::GetFormControlFrame(bool aFlushFrames)
return nullptr;
}
// XXX This creates a dependency between content and frames
nsPresContext*
nsGenericHTMLElement::GetPresContext()
nsGenericHTMLElement::GetPresContext(PresContextFor aFor)
{
// Get the document
nsIDocument* doc = GetDocument();
nsIDocument* doc = (aFor == eForComposedDoc) ?
GetComposedDoc() : GetUncomposedDoc();
if (doc) {
// Get presentation shell.
nsIPresShell *presShell = doc->GetShell();
@ -2709,7 +2710,7 @@ nsGenericHTMLElement::RegUnRegAccessKey(bool aDoReg)
}
// We have an access key, so get the ESM from the pres context.
nsPresContext *presContext = GetPresContext();
nsPresContext* presContext = GetPresContext(eForUncomposedDoc);
if (presContext) {
EventStateManager* esm = presContext->EventStateManager();
@ -2727,7 +2728,7 @@ void
nsGenericHTMLElement::PerformAccesskey(bool aKeyCausesActivation,
bool aIsTrustedEvent)
{
nsPresContext *presContext = GetPresContext();
nsPresContext* presContext = GetPresContext(eForUncomposedDoc);
if (!presContext)
return;
@ -2941,7 +2942,7 @@ nsGenericHTMLFormElementWithState::GenerateStateKey()
return NS_OK;
}
nsIDocument* doc = GetDocument();
nsIDocument* doc = GetUncomposedDoc();
if (!doc) {
return NS_OK;
}
@ -2989,7 +2990,7 @@ nsGenericHTMLFormElementWithState::GetPrimaryPresState()
already_AddRefed<nsILayoutHistoryState>
nsGenericHTMLFormElementWithState::GetLayoutHistory(bool aRead)
{
nsCOMPtr<nsIDocument> doc = GetDocument();
nsCOMPtr<nsIDocument> doc = GetUncomposedDoc();
if (!doc) {
return nullptr;
}

View File

@ -829,7 +829,12 @@ public:
* Get the presentation context for this content node.
* @return the presentation context
*/
nsPresContext* GetPresContext();
enum PresContextFor
{
eForComposedDoc,
eForUncomposedDoc
};
nsPresContext* GetPresContext(PresContextFor aFor);
// Form Helper Routines
/**

View File

@ -355,7 +355,7 @@ nsXULPopupListener::LaunchPopup(nsIDOMEvent* aEvent, nsIContent* aTargetContent)
return rv;
// Try to find the popup content and the document.
nsCOMPtr<nsIDocument> document = mElement->GetDocument();
nsCOMPtr<nsIDocument> document = mElement->GetComposedDoc();
if (!document) {
NS_WARNING("No document!");
return NS_ERROR_FAILURE;
@ -386,10 +386,14 @@ nsXULPopupListener::LaunchPopup(nsIDOMEvent* aEvent, nsIContent* aTargetContent)
}
}
}
} else if (!(popup = document->GetElementById(identifier))) {
} else if (!mElement->IsInUncomposedDoc() ||
!(popup = document->GetElementById(identifier))) {
// XXXsmaug Should we try to use ShadowRoot::GetElementById in case
// mElement is in shadow DOM?
//
// Use getElementById to obtain the popup content and gracefully fail if
// we didn't find any popup content in the document.
NS_ERROR("GetElementById had some kind of spasm.");
NS_WARNING("GetElementById had some kind of spasm.");
return rv;
}

View File

@ -4003,7 +4003,9 @@ XULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
nsDependentAtomString id(idAtom);
if (!id.IsEmpty()) {
nsIDocument *doc = aTargetNode->GetDocument();
nsIDocument *doc = aTargetNode->GetUncomposedDoc();
//XXXsmaug should we use ShadowRoot::GetElementById()
// if doc is null?
if (!doc) return NS_ERROR_FAILURE;
elementInDocument = doc->GetElementById(id);

View File

@ -396,12 +396,6 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
for (int32_t u = 0; u < updaters.Count(); u++) {
nsIContent* content = updaters[u];
nsCOMPtr<nsIDocument> document = content->GetDocument();
NS_ASSERTION(document != nullptr, "element has no document");
if (! document)
continue;
#ifdef DEBUG
if (PR_LOG_TEST(gCommandLog, PR_LOG_NOTICE)) {
nsAutoCString aeventnameC;
@ -413,18 +407,8 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
}
#endif
nsCOMPtr<nsIPresShell> shell = document->GetShell();
if (shell) {
// Retrieve the context in which our DOM event will fire.
nsRefPtr<nsPresContext> context = shell->GetPresContext();
// Handle the DOM event
nsEventStatus status = nsEventStatus_eIgnore;
WidgetEvent event(true, NS_XUL_COMMAND_UPDATE);
EventDispatcher::Dispatch(content, context, &event, nullptr, &status);
}
WidgetEvent event(true, NS_XUL_COMMAND_UPDATE);
EventDispatcher::Dispatch(content, nullptr, &event);
}
return NS_OK;
}

View File

@ -1342,7 +1342,7 @@ nsXULContentBuilder::GetElementsForResult(nsIXULTemplateResult* aResult,
{
// if the root has been removed from the document, just return
// since there won't be any generated content any more
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetDocument());
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetComposedDoc());
if (! xuldoc)
return NS_OK;
@ -1359,7 +1359,7 @@ nsXULContentBuilder::CreateElement(int32_t aNameSpaceID,
nsIAtom* aTag,
Element** aResult)
{
nsCOMPtr<nsIDocument> doc = mRoot->GetDocument();
nsCOMPtr<nsIDocument> doc = mRoot->GetComposedDoc();
NS_ASSERTION(doc != nullptr, "not initialized");
if (! doc)
return NS_ERROR_NOT_INITIALIZED;
@ -1457,7 +1457,7 @@ nsXULContentBuilder::HasGeneratedContent(nsIRDFResource* aResource,
NS_ConvertUTF8toUTF16 refID(uri);
// just return if the node is no longer in a document
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetDocument());
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetComposedDoc());
if (! xuldoc)
return NS_OK;
@ -1576,7 +1576,7 @@ nsXULContentBuilder::GetInsertionLocations(nsIXULTemplateResult* aResult,
if (NS_FAILED(rv))
return false;
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetDocument());
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetComposedDoc());
if (! xuldoc)
return false;
@ -1717,7 +1717,7 @@ nsXULContentBuilder::OpenContainer(nsIContent* aElement)
bool rightBuilder = false;
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(aElement->GetDocument());
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(aElement->GetComposedDoc());
if (! xuldoc)
return NS_OK;
@ -1756,7 +1756,7 @@ nsXULContentBuilder::RebuildAll()
NS_ENSURE_TRUE(mRoot, NS_ERROR_NOT_INITIALIZED);
// Bail out early if we are being torn down.
nsCOMPtr<nsIDocument> doc = mRoot->GetDocument();
nsCOMPtr<nsIDocument> doc = mRoot->GetComposedDoc();
if (!doc)
return NS_OK;

View File

@ -437,7 +437,7 @@ nsXULTemplateBuilder::Init(nsIContent* aElement)
NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
mRoot = aElement;
nsCOMPtr<nsIDocument> doc = mRoot->GetDocument();
nsCOMPtr<nsIDocument> doc = mRoot->GetComposedDoc();
NS_ASSERTION(doc, "element has no document");
if (! doc)
return NS_ERROR_UNEXPECTED;
@ -1371,7 +1371,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
// 'database' and 'builder' properties onto aElement.
nsresult rv;
nsCOMPtr<nsIDocument> doc = mRoot->GetDocument();
nsCOMPtr<nsIDocument> doc = mRoot->GetComposedDoc();
NS_ASSERTION(doc, "no document");
if (! doc)
return NS_ERROR_UNEXPECTED;
@ -1635,7 +1635,7 @@ nsXULTemplateBuilder::GetTemplateRoot(nsIContent** aResult)
mRoot->GetAttr(kNameSpaceID_None, nsGkAtoms::_template, templateID);
if (! templateID.IsEmpty()) {
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(mRoot->GetDocument());
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(mRoot->GetComposedDoc());
if (! domDoc)
return NS_OK;

View File

@ -118,7 +118,7 @@ public:
void RunnableLoadAndRebuild() {
Uninit(false); // Reset results
nsCOMPtr<nsIDocument> doc = mRoot ? mRoot->GetDocument() : nullptr;
nsCOMPtr<nsIDocument> doc = mRoot ? mRoot->GetComposedDoc() : nullptr;
if (doc) {
bool shouldDelay;
LoadDataSources(doc, &shouldDelay);

View File

@ -1236,7 +1236,7 @@ nsXULTemplateQueryProcessorRDF::CompileExtendedQuery(nsRDFQuery* aQuery,
tag = do_GetAtom(tagstr);
}
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(condition->GetDocument());
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(condition->GetComposedDoc());
if (! doc)
return NS_ERROR_FAILURE;

View File

@ -810,7 +810,7 @@ nsXULTreeBuilder::ToggleOpenState(int32_t aIndex)
bool isOpen;
IsContainerOpen(aIndex, &isOpen);
nsIDocument* doc = mRoot->GetDocument();
nsIDocument* doc = mRoot->GetComposedDoc();
if (!doc) {
return NS_ERROR_FAILURE;
}
@ -1288,7 +1288,7 @@ nsXULTreeBuilder::RebuildAll()
{
NS_ENSURE_TRUE(mRoot, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIDocument> doc = mRoot->GetDocument();
nsCOMPtr<nsIDocument> doc = mRoot->GetComposedDoc();
// Bail out early if we are being torn down.
if (!doc)
@ -1710,7 +1710,7 @@ nsXULTreeBuilder::IsContainerOpen(nsIXULTemplateResult *aResult)
return false;
}
nsIDocument* doc = mRoot->GetDocument();
nsIDocument* doc = mRoot->GetComposedDoc();
if (!doc) {
return false;
}

View File

@ -9647,7 +9647,7 @@ nsGlobalWindow::GetPrivateParent()
if (!chromeElement)
return nullptr; // This is ok, just means a null parent.
nsIDocument* doc = chromeElement->GetDocument();
nsIDocument* doc = chromeElement->GetComposedDoc();
if (!doc)
return nullptr; // This is ok, just means a null parent.
@ -9679,7 +9679,7 @@ nsGlobalWindow::GetPrivateRoot()
nsCOMPtr<nsIContent> chromeElement(do_QueryInterface(mChromeEventHandler));
if (chromeElement) {
nsIDocument* doc = chromeElement->GetDocument();
nsIDocument* doc = chromeElement->GetComposedDoc();
if (doc) {
nsIDOMWindow *parent = doc->GetWindow();
if (parent) {

View File

@ -4763,7 +4763,8 @@ EventStateManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
(aContent->AsElement()->State().HasAtLeastOneOfStates(NS_EVENT_STATE_FOCUS |
NS_EVENT_STATE_HOVER))) {
nsGenericHTMLElement* element = static_cast<nsGenericHTMLElement*>(aContent);
element->LeaveLink(element->GetPresContext());
element->LeaveLink(
element->GetPresContext(nsGenericHTMLElement::eForComposedDoc));
}
IMEStateManager::OnRemoveContent(mPresContext, aContent);

View File

@ -1682,7 +1682,7 @@ NS_IMETHODIMP
CarbonEventModelFailureEvent::Run()
{
nsString type = NS_LITERAL_STRING("npapi-carbon-event-model-failure");
nsContentUtils::DispatchTrustedEvent(mContent->GetDocument(), mContent,
nsContentUtils::DispatchTrustedEvent(mContent->GetComposedDoc(), mContent,
type, true, true);
return NS_OK;
}

View File

@ -6687,7 +6687,7 @@ nsCSSFrameConstructor::GetRangeInsertionPoint(nsIContent* aContainer,
bool hasInsertion = false;
if (!multiple) {
// XXXbz XBL2/sXBL issue
nsIDocument* document = aStartChild->GetDocument();
nsIDocument* document = aStartChild->GetComposedDoc();
// XXXbz how would |document| be null here?
if (document && aStartChild->GetXBLInsertionParent()) {
hasInsertion = true;

View File

@ -75,7 +75,7 @@ nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
nsresult
nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
nsCOMPtr<nsIDocument> doc = mContent->GetComposedDoc();
// Create and setup the file picking button.
mBrowse = doc->CreateHTMLElement(nsGkAtoms::button);

View File

@ -6300,6 +6300,7 @@ nsBlockFrame::AccessibleType()
}
if (!HasBullet() || !PresContext()) {
//XXXsmaug What if we're in the shadow dom?
if (!mContent->GetParent()) {
// Don't create accessible objects for the root content node, they are redundant with
// the nsDocAccessible object created with the document node
@ -6307,7 +6308,7 @@ nsBlockFrame::AccessibleType()
}
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc =
do_QueryInterface(mContent->GetDocument());
do_QueryInterface(mContent->GetComposedDoc());
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLElement> body;
htmlDoc->GetBody(getter_AddRefs(body));

View File

@ -943,7 +943,7 @@ inDOMUtils::GetRuleNodeForElement(dom::Element* aElement,
*aRuleNode = nullptr;
*aStyleContext = nullptr;
nsIDocument* doc = aElement->GetDocument();
nsIDocument* doc = aElement->GetComposedDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
nsIPresShell *presShell = doc->GetShell();

View File

@ -78,7 +78,7 @@ inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content) {
nsCOMPtr<nsIDocument> doc = content->GetDocument();
nsCOMPtr<nsIDocument> doc = content->GetComposedDoc();
if (doc) {
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc->GetSubDocumentFor(content)));

View File

@ -1326,7 +1326,7 @@ nsPrintEngine::MapContentForPO(nsPrintObject* aPO,
{
NS_PRECONDITION(aPO && aContent, "Null argument");
nsIDocument* doc = aContent->GetDocument();
nsIDocument* doc = aContent->GetComposedDoc();
NS_ASSERTION(doc, "Content without a document from a document tree?");

View File

@ -83,7 +83,7 @@ nsDocElementBoxFrame::DestroyFrom(nsIFrame* aDestructRoot)
nsresult
nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
nsIDocument* doc = mContent->GetDocument();
nsIDocument* doc = mContent->GetComposedDoc();
if (!doc) {
// The page is currently being torn down. Why bother.
return NS_ERROR_FAILURE;

View File

@ -801,7 +801,7 @@ nsListBoxBodyFrame::ScrollToIndex(int32_t aRowIndex)
// This change has to happen immediately.
// Flush any pending reflow commands.
// XXXbz why, exactly?
mContent->GetDocument()->FlushPendingNotifications(Flush_Layout);
mContent->GetComposedDoc()->FlushPendingNotifications(Flush_Layout);
return NS_OK;
}
@ -874,7 +874,7 @@ nsListBoxBodyFrame::DoInternalPositionChanged(bool aUp, int32_t aDelta)
PRTime start = PR_Now();
nsWeakFrame weakThis(this);
mContent->GetDocument()->FlushPendingNotifications(Flush_Layout);
mContent->GetComposedDoc()->FlushPendingNotifications(Flush_Layout);
if (!weakThis.IsAlive()) {
return NS_OK;
}

View File

@ -72,7 +72,7 @@ nsMenuBarFrame::Init(nsIContent* aContent,
// 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.
mTarget = aContent->GetDocument();
mTarget = aContent->GetComposedDoc();
// Also hook up the listener to the window listening for focus events. This is so we can keep proper
// state as the user alt-tabs through processes.

View File

@ -1034,10 +1034,12 @@ nsMenuFrame::BuildAcceleratorText(bool aNotify)
return;
// Turn the document into a DOM document so we can use getElementById
nsIDocument *document = mContent->GetDocument();
nsIDocument *document = mContent->GetUncomposedDoc();
if (!document)
return;
//XXXsmaug If mContent is in shadow dom, should we use
// ShadowRoot::GetElementById()?
nsIContent *keyElement = document->GetElementById(keyValue);
if (!keyElement) {
#ifdef DEBUG

View File

@ -1752,11 +1752,11 @@ nsXULPopupManager::UpdateKeyboardListeners()
nsMenuChainItem* item = GetTopVisibleMenu();
if (item) {
if (!item->IgnoreKeys())
newTarget = item->Content()->GetDocument();
newTarget = item->Content()->GetComposedDoc();
isForMenu = item->PopupType() == ePopupTypeMenu;
}
else if (mActiveMenuBar) {
newTarget = mActiveMenuBar->GetContent()->GetDocument();
newTarget = mActiveMenuBar->GetContent()->GetComposedDoc();
isForMenu = true;
}

View File

@ -331,7 +331,7 @@ nsXULTooltipListener::CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent)
// get the boxObject of the documentElement of the document the tree is in
nsCOMPtr<nsIBoxObject> bx;
nsIDocument* doc = sourceNode->GetDocument();
nsIDocument* doc = sourceNode->GetComposedDoc();
if (doc) {
ErrorResult ignored;
bx = doc->GetBoxObjectFor(doc->GetRootElement(), ignored);
@ -387,11 +387,12 @@ 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<nsIDOMXULDocument> xulDoc(do_QueryInterface(tooltipNode->GetDocument()));
nsCOMPtr<nsIDOMXULDocument> xulDoc =
do_QueryInterface(tooltipNode->GetComposedDoc());
if (xulDoc) {
// Make sure the target node is still attached to some document.
// It might have been deleted.
if (sourceNode->GetDocument()) {
if (sourceNode->IsInComposedDoc()) {
#ifdef MOZ_XUL
if (!mIsSourceTree) {
mLastTreeRow = -1;
@ -413,7 +414,7 @@ nsXULTooltipListener::ShowTooltip()
this, false, false);
// listen for mousedown, mouseup, keydown, and DOMMouseScroll events at document level
nsIDocument* doc = sourceNode->GetDocument();
nsIDocument* doc = sourceNode->GetComposedDoc();
if (doc) {
// Probably, we should listen to untrusted events for hiding tooltips
// on content since tooltips might disturb something of web
@ -555,7 +556,7 @@ nsXULTooltipListener::FindTooltip(nsIContent* aTarget, nsIContent** aTooltip)
return NS_ERROR_NULL_POINTER;
// before we go on, make sure that target node still has a window
nsIDocument *document = aTarget->GetDocument();
nsIDocument *document = aTarget->GetComposedDoc();
if (!document) {
NS_WARNING("Unable to retrieve the tooltip node document.");
return NS_ERROR_FAILURE;
@ -595,8 +596,10 @@ nsXULTooltipListener::FindTooltip(nsIContent* aTarget, nsIContent** aTooltip)
return NS_OK;
}
if (!tooltipId.IsEmpty()) {
if (!tooltipId.IsEmpty() && aTarget->IsInUncomposedDoc()) {
// tooltip must be an id, use getElementById to find it
//XXXsmaug If aTarget is in shadow dom, should we use
// ShadowRoot::GetElementById()?
nsCOMPtr<nsIContent> tooltipEl = document->GetElementById(tooltipId);
if (tooltipEl) {
@ -658,7 +661,7 @@ nsXULTooltipListener::DestroyTooltip()
mCurrentTooltip = nullptr;
// clear out the tooltip node on the document
nsCOMPtr<nsIDocument> doc = currentTooltip->GetDocument();
nsCOMPtr<nsIDocument> doc = currentTooltip->GetComposedDoc();
if (doc) {
// remove the mousedown and keydown listener from document
doc->RemoveSystemEventListener(NS_LITERAL_STRING("DOMMouseScroll"), this,

View File

@ -319,7 +319,7 @@ nsTreeBodyFrame::EnsureBoxObject()
if (!mTreeBoxObject) {
nsIContent* parent = GetBaseElement();
if (parent) {
nsIDocument* nsDoc = parent->GetDocument();
nsIDocument* nsDoc = parent->GetComposedDoc();
if (!nsDoc) // there may be no document, if we're called from Destroy()
return;
ErrorResult ignored;
@ -2171,7 +2171,7 @@ nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContex
if (styleRequest) {
styleRequest->Clone(imgNotificationObserver, getter_AddRefs(imageRequest));
} else {
nsIDocument* doc = mContent->GetDocument();
nsIDocument* doc = mContent->GetComposedDoc();
if (!doc)
// The page is currently being torn down. Why bother.
return NS_ERROR_FAILURE;

View File

@ -488,7 +488,7 @@ nsTreeContentView::SetTree(nsITreeBoxObject* aTree)
NS_ENSURE_STATE(mRoot);
// Add ourselves to document's observers.
nsIDocument* document = mRoot->GetDocument();
nsIDocument* document = mRoot->GetComposedDoc();
if (document) {
document->AddObserver(this);
mDocument = document;

View File

@ -404,7 +404,7 @@ nsSecureBrowserUIImpl::Notify(nsIDOMHTMLFormElement* aDOMForm,
nsCOMPtr<nsIContent> formNode = do_QueryInterface(aDOMForm);
nsCOMPtr<nsIDocument> document = formNode->GetDocument();
nsCOMPtr<nsIDocument> document = formNode->GetComposedDoc();
if (!document) return NS_OK;
nsIPrincipal *principal = formNode->NodePrincipal();

View File

@ -470,7 +470,7 @@ void nsMenuBarX::HideItem(nsIDOMDocument* inDoc, const nsAString & inID, nsICont
// Do what is necessary to conform to the Aqua guidelines for menus.
void nsMenuBarX::AquifyMenuBar()
{
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mContent->GetDocument()));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mContent->GetComposedDoc()));
if (domDoc) {
// remove the "About..." item and its separator
HideItem(domDoc, NS_LITERAL_STRING("aboutSeparator"), nullptr);
@ -512,7 +512,7 @@ NSMenuItem* nsMenuBarX::CreateNativeAppMenuItem(nsMenuX* inMenu, const nsAString
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
nsCOMPtr<nsIDocument> doc = inMenu->Content()->GetDocument();
nsCOMPtr<nsIDocument> doc = inMenu->Content()->GetUncomposedDoc();
if (!doc)
return nil;

View File

@ -179,7 +179,7 @@ nsMenuItemIconX::GetIconURI(nsIURI** aIconURI)
if (!hasImageAttr) {
// If the content node has no "image" attribute, get the
// "list-style-image" property from CSS.
nsCOMPtr<nsIDocument> document = mContent->GetDocument();
nsCOMPtr<nsIDocument> document = mContent->GetComposedDoc();
if (!document)
return NS_ERROR_FAILURE;