зеркало из https://github.com/mozilla/pjs.git
Camino only - Bug 348695: Use editor context menu in Midas frames. r=kreeger sr=pink
This commit is contained in:
Родитель
5dc8c539a5
Коммит
01cc661489
|
@ -3988,7 +3988,7 @@
|
|||
GCC_OPTIMIZATION_LEVEL = 2;
|
||||
GCC_PREFIX_HEADER = src/includes/ChimeraPrefix.h;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "OSTYPE=Darwin1.4 OSARCH=Darwin MOZILLA_INTERNAL_API=1";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/txtsvc ../dist/include/editor ../dist/include/spellchecker ../dist/include/exthandler ../dist/include/helperAppDlg ../dist/include/intl ../dist/include/pipboot ../dist/include/pipnss ../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/uconv ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/commandhandler ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/nkcache ../dist/include/docshell ../dist/include/profdirserviceprovider ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/history ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/chardet ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/chrome ../dist/include/xpcom ../dist/include/xpcom_obsolete ../dist/include/cookie ../dist/include/mork ../dist/include/js ../dist/include/xpconnect ../dist/include/ ../dist/public/nss ../ $(SYSTEM_DEVELOPER_DIR)/Headers/FlatCarbon $(LOCAL_LIBRARY_DIR)/Frameworks/SharedMenusCocoa.framework/Headers";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/txtsvc ../dist/include/editor ../dist/include/spellchecker ../dist/include/composer ../dist/include/exthandler ../dist/include/helperAppDlg ../dist/include/intl ../dist/include/pipboot ../dist/include/pipnss ../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/uconv ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/commandhandler ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/nkcache ../dist/include/docshell ../dist/include/profdirserviceprovider ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/history ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/chardet ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/chrome ../dist/include/xpcom ../dist/include/xpcom_obsolete ../dist/include/cookie ../dist/include/mork ../dist/include/js ../dist/include/xpconnect ../dist/include/ ../dist/public/nss ../ $(SYSTEM_DEVELOPER_DIR)/Headers/FlatCarbon $(LOCAL_LIBRARY_DIR)/Frameworks/SharedMenusCocoa.framework/Headers";
|
||||
INFOPLIST_FILE = "Info-Camino.plist";
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LIBRARY_SEARCH_PATHS = "../dist/bin ../dist/lib ../dist/Embed/components";
|
||||
|
@ -7881,7 +7881,7 @@
|
|||
GCC_OPTIMIZATION_LEVEL = 2;
|
||||
GCC_PREFIX_HEADER = src/includes/ChimeraPrefix.h;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "OSTYPE=Darwin1.4 OSARCH=Darwin _BUILD_STATIC_BIN MOZILLA_INTERNAL_API=1";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/txtsvc ../dist/include/editor ../dist/include/spellchecker ../dist/include/helperAppDlg ../dist/include/exthandler ../dist/include/intl ../dist/include/pipboot ../dist/include/pipnss ../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/uconv ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/commandhandler ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/nkcache ../dist/include/docshell ../dist/include/profdirserviceprovider ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/history ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/chardet ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/chrome ../dist/include/xpcom ../dist/include/xpcom_obsolete ../dist/include/cookie ../dist/include/mork ../dist/include/js ../dist/include/xpconnect ../dist/include/ ../dist/public/nss $(SYSTEM_DEVELOPER_DIR)/Headers/FlatCarbon $(LOCAL_LIBRARY_DIR)/Frameworks/SharedMenusCocoa.framework/Headers";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/txtsvc ../dist/include/editor ../dist/include/spellchecker ../dist/include/composer ../dist/include/helperAppDlg ../dist/include/exthandler ../dist/include/intl ../dist/include/pipboot ../dist/include/pipnss ../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/uconv ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/commandhandler ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/nkcache ../dist/include/docshell ../dist/include/profdirserviceprovider ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/history ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/chardet ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/chrome ../dist/include/xpcom ../dist/include/xpcom_obsolete ../dist/include/cookie ../dist/include/mork ../dist/include/js ../dist/include/xpconnect ../dist/include/ ../dist/public/nss $(SYSTEM_DEVELOPER_DIR)/Headers/FlatCarbon $(LOCAL_LIBRARY_DIR)/Frameworks/SharedMenusCocoa.framework/Headers";
|
||||
INFOPLIST_FILE = "Info-CaminoStatic.plist";
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LIBRARY_SEARCH_PATHS = "../dist/bin ../dist/lib ../dist/lib/components ../js/src/liveconnect ../js/src/xpconnect/loader";
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
#include "nsIHistoryItems.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMNSHTMLDocument.h"
|
||||
#include "nsIDOMLocation.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
|
@ -125,6 +126,7 @@
|
|||
|
||||
// for spellchecking
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIEditingSession.h"
|
||||
#include "nsIInlineSpellChecker.h"
|
||||
#include "nsIEditorSpellCheck.h"
|
||||
#include "nsISelection.h"
|
||||
|
@ -3068,17 +3070,12 @@ enum BWCOpenDest {
|
|||
[self forward:sender];
|
||||
}
|
||||
|
||||
//
|
||||
// -focusedElement
|
||||
//
|
||||
// Returns the currently focused DOM element in the currently visible tab
|
||||
//
|
||||
- (void)focusedElement:(nsIDOMElement**)outElement
|
||||
- (void)focusController:(nsIFocusController**)outController
|
||||
{
|
||||
#define ENSURE_TRUE(x) if (!x) return;
|
||||
if (!outElement)
|
||||
if (!outController)
|
||||
return;
|
||||
*outElement = nsnull;
|
||||
*outController = nsnull;
|
||||
|
||||
nsCOMPtr<nsIWebBrowser> webBrizzle = dont_AddRef([[[self getBrowserWrapper] getBrowserView] getWebBrowser]);
|
||||
ENSURE_TRUE(webBrizzle);
|
||||
|
@ -3086,20 +3083,36 @@ enum BWCOpenDest {
|
|||
webBrizzle->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
nsCOMPtr<nsPIDOMWindow> privateWindow = do_QueryInterface(domWindow);
|
||||
ENSURE_TRUE(privateWindow);
|
||||
nsIFocusController *controller = privateWindow->GetRootFocusController();
|
||||
ENSURE_TRUE(controller);
|
||||
*outController = privateWindow->GetRootFocusController();
|
||||
NS_IF_ADDREF(*outController);
|
||||
#undef ENSURE_TRUE
|
||||
}
|
||||
|
||||
//
|
||||
// -focusedElement
|
||||
//
|
||||
// Returns the currently focused DOM element in the currently visible tab
|
||||
//
|
||||
- (void)focusedElement:(nsIDOMElement**)outElement
|
||||
{
|
||||
if (!outElement)
|
||||
return;
|
||||
*outElement = nsnull;
|
||||
|
||||
nsCOMPtr<nsIFocusController> controller;
|
||||
[self focusController:getter_AddRefs(controller)];
|
||||
if (!controller)
|
||||
return;
|
||||
nsCOMPtr<nsIDOMElement> focusedItem;
|
||||
controller->GetFocusedElement(getter_AddRefs(focusedItem));
|
||||
*outElement = focusedItem.get();
|
||||
NS_IF_ADDREF(*outElement);
|
||||
|
||||
#undef ENSURE_TRUE
|
||||
}
|
||||
|
||||
//
|
||||
// -currentEditor:
|
||||
//
|
||||
// Returns the nsIEditor of the currently focused text area or input
|
||||
// Returns the nsIEditor of the currently focused text area, input, or midas editor
|
||||
//
|
||||
- (void)currentEditor:(nsIEditor**)outEditor
|
||||
{
|
||||
|
@ -3110,8 +3123,36 @@ enum BWCOpenDest {
|
|||
nsCOMPtr<nsIDOMElement> focusedElement;
|
||||
[self focusedElement:getter_AddRefs(focusedElement)];
|
||||
nsCOMPtr<nsIDOMNSEditableElement> editElement = do_QueryInterface(focusedElement);
|
||||
if (editElement)
|
||||
if (editElement) {
|
||||
editElement->GetEditor(outEditor);
|
||||
}
|
||||
// if there's no element focused, we're probably in a Midas editor
|
||||
else {
|
||||
#define ENSURE_TRUE(x) if (!x) return;
|
||||
nsCOMPtr<nsIFocusController> controller;
|
||||
[self focusController:getter_AddRefs(controller)];
|
||||
ENSURE_TRUE(controller);
|
||||
nsCOMPtr<nsIDOMWindowInternal> winInternal;
|
||||
controller->GetFocusedWindow(getter_AddRefs(winInternal));
|
||||
nsCOMPtr<nsIDOMWindow> focusedWindow(do_QueryInterface(winInternal));
|
||||
ENSURE_TRUE(focusedWindow);
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
focusedWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc(do_QueryInterface(domDoc));
|
||||
ENSURE_TRUE(htmlDoc);
|
||||
nsAutoString designMode;
|
||||
htmlDoc->GetDesignMode(designMode);
|
||||
if (designMode.EqualsLiteral("on")) {
|
||||
// we are in a Midas editor, so find its editor
|
||||
nsCOMPtr<nsPIDOMWindow> privateWindow = do_QueryInterface(focusedWindow);
|
||||
ENSURE_TRUE(privateWindow);
|
||||
nsIDocShell *docshell = privateWindow->GetDocShell();
|
||||
nsCOMPtr<nsIEditingSession> editSession = do_GetInterface(docshell);
|
||||
ENSURE_TRUE(editSession)
|
||||
editSession->GetEditorForWindow(focusedWindow, outEditor);
|
||||
}
|
||||
#undef ENSURE_TRUE
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -3898,16 +3939,40 @@ enum BWCOpenDest {
|
|||
BOOL showSpellingItems = NO;
|
||||
BOOL needsAlternates = NO;
|
||||
|
||||
NSMenu* menuPrototype = nil;
|
||||
int contextMenuFlags = mDataOwner->mContextMenuFlags;
|
||||
|
||||
NSArray* emailAddresses = nil;
|
||||
unsigned numEmailAddresses = 0;
|
||||
|
||||
BOOL hasSelection = [[mBrowserView getBrowserView] canCopy];
|
||||
BOOL isMidas = NO;
|
||||
|
||||
if ((contextMenuFlags & nsIContextMenuListener::CONTEXT_LINK) != 0)
|
||||
{
|
||||
if (mDataOwner->mContextMenuNode) {
|
||||
nsCOMPtr<nsIDOMDocument> ownerDoc;
|
||||
mDataOwner->mContextMenuNode->GetOwnerDocument(getter_AddRefs(ownerDoc));
|
||||
|
||||
// Check to see if it's a Midas frame
|
||||
nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc(do_QueryInterface(ownerDoc));
|
||||
if (htmlDoc) {
|
||||
nsAutoString designMode;
|
||||
htmlDoc->GetDesignMode(designMode);
|
||||
isMidas = designMode.EqualsLiteral("on");
|
||||
}
|
||||
|
||||
// If it's not a Midas frame, check to see if it's a subframe
|
||||
if (!isMidas) {
|
||||
nsCOMPtr<nsIDOMWindow> contentWindow = [[mBrowserView getBrowserView] getContentWindow];
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> contentDoc;
|
||||
if (contentWindow)
|
||||
contentWindow->GetDocument(getter_AddRefs(contentDoc));
|
||||
|
||||
showFrameItems = (contentDoc != ownerDoc);
|
||||
}
|
||||
}
|
||||
|
||||
NSMenu* menuPrototype = nil;
|
||||
int contextMenuFlags = mDataOwner->mContextMenuFlags;
|
||||
|
||||
if ((contextMenuFlags & nsIContextMenuListener::CONTEXT_LINK) != 0) {
|
||||
emailAddresses = [self mailAddressesInContextMenuLinkNode];
|
||||
if (emailAddresses != nil)
|
||||
numEmailAddresses = [emailAddresses count];
|
||||
|
@ -3928,7 +3993,9 @@ enum BWCOpenDest {
|
|||
}
|
||||
}
|
||||
else if ((contextMenuFlags & nsIContextMenuListener::CONTEXT_INPUT) != 0 ||
|
||||
(contextMenuFlags & nsIContextMenuListener::CONTEXT_TEXT) != 0) {
|
||||
(contextMenuFlags & nsIContextMenuListener::CONTEXT_TEXT) != 0 ||
|
||||
isMidas)
|
||||
{
|
||||
menuPrototype = mInputMenu;
|
||||
showSpellingItems = YES;
|
||||
}
|
||||
|
@ -3946,19 +4013,6 @@ enum BWCOpenDest {
|
|||
[mCopyItem setEnabled:hasSelection];
|
||||
}
|
||||
|
||||
if (mDataOwner->mContextMenuNode) {
|
||||
nsCOMPtr<nsIDOMDocument> ownerDoc;
|
||||
mDataOwner->mContextMenuNode->GetOwnerDocument(getter_AddRefs(ownerDoc));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> contentWindow = [[mBrowserView getBrowserView] getContentWindow];
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> contentDoc;
|
||||
if (contentWindow)
|
||||
contentWindow->GetDocument(getter_AddRefs(contentDoc));
|
||||
|
||||
showFrameItems = (contentDoc != ownerDoc);
|
||||
}
|
||||
|
||||
// we have to clone the menu and return that, so that we don't change
|
||||
// our only copy of the menu
|
||||
NSMenu* result = [[menuPrototype copy] autorelease];
|
||||
|
|
Загрузка…
Ссылка в новой задаче