From 1a56f2a7d1648c0eba3d23fd9e579d166ceb67f6 Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Wed, 26 Nov 2003 10:23:03 +0000 Subject: [PATCH] Bug 225885 nsPresShell::DoCopy does not work for embedding p=marco@gnome.org r=bz sr=bryner a=dbaron --- layout/base/nsPresShell.cpp | 21 ++++++++++++++------- layout/html/base/src/nsPresShell.cpp | 21 ++++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 33e2785a7a28..bd46d2724bb0 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4549,21 +4549,28 @@ NS_IMETHODIMP PresShell::DoCopyImageContents(nsIDOMNode* aNode) nsresult PresShell::GetSelectionForCopy(nsISelection** outSelection) { + nsresult rv = NS_OK; + *outSelection = nsnull; nsCOMPtr doc; GetDocument(getter_AddRefs(doc)); if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr manager; - nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(manager)); - if (NS_FAILED(rv)) return rv; - if (!manager) return NS_ERROR_FAILURE; + nsCOMPtr content; + nsCOMPtr ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); + if (ourWindow) { + nsCOMPtr focusController; + ourWindow->GetRootFocusController(getter_AddRefs(focusController)); + if (focusController) { + nsCOMPtr focusedElement; + focusController->GetFocusedElement(getter_AddRefs(focusedElement)); + content = do_QueryInterface(focusedElement); + } + } nsCOMPtr sel; - nsCOMPtr content; - rv = manager->GetFocusedContent(getter_AddRefs(content)); - if (NS_SUCCEEDED(rv) && content) + if (content) { //check to see if we need to get selection from frame //optimization that MAY need to be expanded as more things implement their own "selection" diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index 33e2785a7a28..bd46d2724bb0 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -4549,21 +4549,28 @@ NS_IMETHODIMP PresShell::DoCopyImageContents(nsIDOMNode* aNode) nsresult PresShell::GetSelectionForCopy(nsISelection** outSelection) { + nsresult rv = NS_OK; + *outSelection = nsnull; nsCOMPtr doc; GetDocument(getter_AddRefs(doc)); if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr manager; - nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(manager)); - if (NS_FAILED(rv)) return rv; - if (!manager) return NS_ERROR_FAILURE; + nsCOMPtr content; + nsCOMPtr ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); + if (ourWindow) { + nsCOMPtr focusController; + ourWindow->GetRootFocusController(getter_AddRefs(focusController)); + if (focusController) { + nsCOMPtr focusedElement; + focusController->GetFocusedElement(getter_AddRefs(focusedElement)); + content = do_QueryInterface(focusedElement); + } + } nsCOMPtr sel; - nsCOMPtr content; - rv = manager->GetFocusedContent(getter_AddRefs(content)); - if (NS_SUCCEEDED(rv) && content) + if (content) { //check to see if we need to get selection from frame //optimization that MAY need to be expanded as more things implement their own "selection"