fixing regressions from 34986 ender-lite. adding new selection controller sensitivity. r=saari

This commit is contained in:
mjudge%netscape.com 2000-06-14 02:57:26 +00:00
Родитель 1d6c6fadc5
Коммит a3b3e1e94d
2 изменённых файлов: 72 добавлений и 12 удалений

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

@ -83,6 +83,7 @@
#include "nsHTMLToTXTSinkStream.h"
#include "nsXIFDTD.h"
#include "nsIFrameSelection.h"
#include "nsIDOMNSHTMLInputElement.h" //optimization for ::DoXXX commands
#include "nsViewsCID.h"
#include "nsIFrameManager.h"
#include "nsISupportsPrimitives.h"
@ -2687,16 +2688,45 @@ PresShell::DoCopy()
nsString buffer;
nsresult rv;
nsIDOMSelection* sel;
GetSelection(nsISelectionController::SELECTION_NORMAL, &sel);
nsCOMPtr<nsIDOMSelection> sel;
nsCOMPtr<nsIEventStateManager> manager;
nsCOMPtr<nsIContent> content;
rv = mPresContext->GetEventStateManager(getter_AddRefs(manager));
if (NS_FAILED(rv) || !manager)
return rv?rv:NS_ERROR_FAILURE;
rv = manager->GetFocusedContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv) && 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"
nsCOMPtr<nsIDOMNSHTMLInputElement> htmlElement(do_QueryInterface(content));
if (htmlElement)
{
nsIFrame *htmlInputFrame;
rv = GetPrimaryFrameFor(content, &htmlInputFrame);
if (NS_FAILED(rv) || !htmlInputFrame)
return rv?rv:NS_ERROR_FAILURE;
nsCOMPtr<nsISelectionController> selCon;
rv = htmlInputFrame->GetSelectionController(mPresContext,getter_AddRefs(selCon));
if (NS_FAILED(rv) || !selCon)
return rv?rv:NS_ERROR_FAILURE;
rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
}
}
if (!sel) //get selection from this PresShell
rv = GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
if (sel != nsnull)
doc->CreateXIF(buffer,sel);
NS_IF_RELEASE(sel);
if (NS_FAILED(rv) || !sel)
return rv?rv:NS_ERROR_FAILURE;
doc->CreateXIF(buffer,sel);
// Get the Clipboard
NS_WITH_SERVICE(nsIClipboard, clipboard, kCClipboardCID, &rv);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if ( clipboard ) {
// Create a transferable for putting data on the Clipboard

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

@ -83,6 +83,7 @@
#include "nsHTMLToTXTSinkStream.h"
#include "nsXIFDTD.h"
#include "nsIFrameSelection.h"
#include "nsIDOMNSHTMLInputElement.h" //optimization for ::DoXXX commands
#include "nsViewsCID.h"
#include "nsIFrameManager.h"
#include "nsISupportsPrimitives.h"
@ -2687,16 +2688,45 @@ PresShell::DoCopy()
nsString buffer;
nsresult rv;
nsIDOMSelection* sel;
GetSelection(nsISelectionController::SELECTION_NORMAL, &sel);
nsCOMPtr<nsIDOMSelection> sel;
nsCOMPtr<nsIEventStateManager> manager;
nsCOMPtr<nsIContent> content;
rv = mPresContext->GetEventStateManager(getter_AddRefs(manager));
if (NS_FAILED(rv) || !manager)
return rv?rv:NS_ERROR_FAILURE;
rv = manager->GetFocusedContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv) && 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"
nsCOMPtr<nsIDOMNSHTMLInputElement> htmlElement(do_QueryInterface(content));
if (htmlElement)
{
nsIFrame *htmlInputFrame;
rv = GetPrimaryFrameFor(content, &htmlInputFrame);
if (NS_FAILED(rv) || !htmlInputFrame)
return rv?rv:NS_ERROR_FAILURE;
nsCOMPtr<nsISelectionController> selCon;
rv = htmlInputFrame->GetSelectionController(mPresContext,getter_AddRefs(selCon));
if (NS_FAILED(rv) || !selCon)
return rv?rv:NS_ERROR_FAILURE;
rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
}
}
if (!sel) //get selection from this PresShell
rv = GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
if (sel != nsnull)
doc->CreateXIF(buffer,sel);
NS_IF_RELEASE(sel);
if (NS_FAILED(rv) || !sel)
return rv?rv:NS_ERROR_FAILURE;
doc->CreateXIF(buffer,sel);
// Get the Clipboard
NS_WITH_SERVICE(nsIClipboard, clipboard, kCClipboardCID, &rv);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if ( clipboard ) {
// Create a transferable for putting data on the Clipboard