Browse Source

Fix: CanCopy() always returns true, use !IsSelectionCollapsed() instead.

master
roytam1 5 years ago
parent
commit
d772af1006
  1. 5
      k-meleon/app/BrowserGlue.cpp
  2. 17
      k-meleon/app/BrowserWindow.h

5
k-meleon/app/BrowserGlue.cpp

@ -428,10 +428,11 @@ BOOL CBrowserGlue::FocusPrevElement()
void CBrowserGlue::ShowContextMenu(UINT aContextFlags)
{
CString menu;
if ( !(aContextFlags & CONTEXT_LINK) &&
if (!(aContextFlags & CONTEXT_LINK) &&
!(aContextFlags & CONTEXT_IMAGE) &&
mpBrowserView->GetBrowserWrapper()->CanCopy())
!mpBrowserView->GetBrowserWrapper()->IsSelectionCollapsed())
{
// printf("CBrowserGlue::ShowContextMenu(%08x) = SelectedText\n", aContextFlags);
menu = _T("SelectedText");
}
else {

17
k-meleon/app/BrowserWindow.h

@ -24,7 +24,10 @@ class nsIX509Cert;
#include "nsICommandManager.h"
#include "nsIClipboardCommands.h"
#include "nsPIDOMWindow.h"
#include "nsIDocShell.h"
#include "nsIDocument.h"
#include "nsISelection.h"
#include "nsIWebNavigation.h"
#include "nsIWebBrowser.h"
#include "nsIWebBrowserFocus.h"
@ -119,7 +122,7 @@ public:
return NS_SUCCEEDED(ds->SetAllowJavascript(allow));
}
BOOL IsJSAllowed()
BOOL IsJSAllowed()
{
nsCOMPtr<nsIDocShell> ds = GetDocShell();
bool res = false;
@ -127,6 +130,18 @@ public:
return res;
}
BOOL IsSelectionCollapsed()
{
nsCOMPtr<nsIDOMWindow> dom;
if (mWebBrowser) mWebBrowser->GetContentDOMWindow(getter_AddRefs(dom));
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(dom);
nsCOMPtr<nsISelection> domSelection;
domWindow->GetSelection(getter_AddRefs(domSelection));
bool selectionCollapsed = false;
domSelection->GetIsCollapsed(&selectionCollapsed);
return selectionCollapsed;
}
BOOL Reload(bool force)
{
PRUint32 loadFlags = nsIWebNavigation::LOAD_FLAGS_NONE;

Loading…
Cancel
Save