mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
clean up interface, per directions. adding copyLinkLocation(), and specifying semantics of selectNone() wrt insertion point location. Implemented selectNone(). r=saari/a=hyatt. bug#s 46867, 63001
This commit is contained in:
parent
c2d296983d
commit
f53d582d4a
@ -1264,7 +1264,7 @@ nsWebShell::CanCopySelection(PRBool* aResult)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CanPasteSelection(PRBool* aResult)
|
||||
nsWebShell::CanPaste(PRBool* aResult)
|
||||
{
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
@ -1287,7 +1287,13 @@ nsWebShell::CopySelection(void)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::PasteSelection(void)
|
||||
nsWebShell::CopyLinkLocation(void)
|
||||
{
|
||||
return DoCommand ( NS_LITERAL_STRING("cmd_copy_link") );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::Paste(void)
|
||||
{
|
||||
return DoCommand ( NS_LITERAL_STRING("cmd_paste") );
|
||||
}
|
||||
@ -1297,16 +1303,14 @@ nsWebShell::SelectAll(void)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer;
|
||||
rv = mContentViewer->QueryInterface(NS_GET_IID(nsIDocumentViewer),
|
||||
getter_AddRefs(docViewer));
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer ( do_QueryInterface(mContentViewer, &rv) );
|
||||
if (NS_FAILED(rv) || !docViewer) return rv;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = docViewer->GetPresShell(*getter_AddRefs(presShell));
|
||||
if (NS_FAILED(rv) || !presShell) return rv;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell);
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell, &rv);
|
||||
if (NS_FAILED(rv) || !selCon) return rv;
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
@ -1353,10 +1357,33 @@ nsWebShell::SelectAll(void)
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// SelectNone
|
||||
//
|
||||
// Collapses the current selection, insertion point ends up at beginning
|
||||
// of previous selection.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::SelectNone(void)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer ( do_QueryInterface(mContentViewer, &rv) );
|
||||
if (NS_FAILED(rv) || !docViewer) return rv;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = docViewer->GetPresShell(*getter_AddRefs(presShell));
|
||||
if (NS_FAILED(rv) || !presShell) return rv;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell, &rv);
|
||||
if (NS_FAILED(rv) || !selCon) return rv;
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv) || !selection) return rv;
|
||||
|
||||
return selection->CollapseToStart();
|
||||
}
|
||||
|
||||
|
||||
|
@ -287,7 +287,7 @@ Boolean CBrowserShell::ObeyCommand(PP_PowerPlant::CommandT inCommand, void* ioPa
|
||||
case cmd_Paste:
|
||||
rv = GetClipboardHandler(getter_AddRefs(clipCmd));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
clipCmd->PasteSelection();
|
||||
clipCmd->Paste();
|
||||
break;
|
||||
|
||||
case cmd_SelectAll:
|
||||
@ -374,7 +374,7 @@ void CBrowserShell::FindCommandStatus(PP_PowerPlant::CommandT inCommand,
|
||||
case cmd_Paste:
|
||||
rv = GetClipboardHandler(getter_AddRefs(clipCmd));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = clipCmd->CanPasteSelection(&canDo);
|
||||
rv = clipCmd->CanPaste(&canDo);
|
||||
outEnabled = NS_SUCCEEDED(rv) && canDo;
|
||||
}
|
||||
break;
|
||||
|
@ -342,14 +342,14 @@ void UpdateUI(nsIWebBrowserChrome *aChrome)
|
||||
|
||||
PRBool canCutSelection = PR_FALSE;
|
||||
PRBool canCopySelection = PR_FALSE;
|
||||
PRBool canPasteSelection = PR_FALSE;
|
||||
PRBool canPaste = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser);
|
||||
if (nsIClipboardCommands)
|
||||
{
|
||||
clipCmds->CanCutSelection(&canCutSelection);
|
||||
clipCmds->CanCopySelection(&canCopySelection);
|
||||
clipCmds->CanPasteSelection(&canPasteSelection);
|
||||
clipCmds->CanPaste(&canPaste);
|
||||
}
|
||||
|
||||
HMENU hmenu = GetMenu(hwndDlg);
|
||||
@ -365,7 +365,7 @@ void UpdateUI(nsIWebBrowserChrome *aChrome)
|
||||
EnableMenuItem(hmenu, MOZ_Copy, MF_BYCOMMAND |
|
||||
((canCopySelection) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED)));
|
||||
EnableMenuItem(hmenu, MOZ_Paste, MF_BYCOMMAND |
|
||||
((canPasteSelection) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED)));
|
||||
((canPaste) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED)));
|
||||
}
|
||||
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BACK), canGoBack);
|
||||
@ -499,7 +499,7 @@ BOOL CALLBACK BrowserDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||
case MOZ_Paste:
|
||||
{
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser);
|
||||
clipCmds->PasteSelection();
|
||||
clipCmds->Paste();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -37,7 +37,7 @@ interface nsIClipboardCommands : nsISupports {
|
||||
* Returns whether the current contents of the clipboard can be
|
||||
* pasted and if the current selection is not read-only.
|
||||
*/
|
||||
boolean canPasteSelection();
|
||||
boolean canPaste();
|
||||
|
||||
/**
|
||||
* Cut the current selection onto the clipboard.
|
||||
@ -48,11 +48,16 @@ interface nsIClipboardCommands : nsISupports {
|
||||
* Copy the current selection onto the clipboard.
|
||||
*/
|
||||
void copySelection();
|
||||
|
||||
/**
|
||||
* Copy the URL of the current selection, say for an <IMG> inside an <A>
|
||||
*/
|
||||
void copyLinkLocation();
|
||||
|
||||
/**
|
||||
* Paste the contents of the clipboard into the current selection.
|
||||
*/
|
||||
void pasteSelection();
|
||||
void paste();
|
||||
|
||||
/**
|
||||
* Select the entire contents.
|
||||
@ -60,7 +65,8 @@ interface nsIClipboardCommands : nsISupports {
|
||||
void selectAll();
|
||||
|
||||
/**
|
||||
* Clear the current selection (if any).
|
||||
* Clear the current selection (if any). Insertion point ends up
|
||||
* at beginning of current selection.
|
||||
*/
|
||||
void selectNone();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user