From 4c87049c943aff61f73b406e328bc05dda6bbbe8 Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Sun, 17 Mar 2002 20:39:16 +0000 Subject: [PATCH] Moved mouse listener from EditorShell to HTMLEditor but keep previous context click and doubleclick element selection behavior. b=112181 & 128836, r=akkana, sr=sfraser, a=asa git-svn-id: svn://10.0.0.236/trunk@116754 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/composer/src/Makefile.in | 1 - mozilla/editor/composer/src/makefile.win | 1 - mozilla/editor/composer/src/nsEditorShell.cpp | 133 +--------- mozilla/editor/composer/src/nsEditorShell.h | 6 - mozilla/editor/idl/nsIEditorShell.idl | 6 - mozilla/editor/libeditor/html/Makefile.in | 1 + mozilla/editor/libeditor/html/makefile.win | 1 + .../editor/libeditor/html/nsHTMLEditor.cpp | 3 +- .../html/nsHTMLEditorMouseListener.cpp | 229 ++++++++++++++++++ .../html/nsHTMLEditorMouseListener.h | 79 ++++++ mozilla/editor/macbuild/composer.xml | 30 --- mozilla/editor/macbuild/editor.xml | 30 +++ mozilla/editor/ui/composer/content/editor.js | 56 +++-- mozilla/editor/ui/composer/content/editor.xul | 3 +- 14 files changed, 385 insertions(+), 194 deletions(-) create mode 100644 mozilla/editor/libeditor/html/nsHTMLEditorMouseListener.cpp create mode 100644 mozilla/editor/libeditor/html/nsHTMLEditorMouseListener.h diff --git a/mozilla/editor/composer/src/Makefile.in b/mozilla/editor/composer/src/Makefile.in index d0c8071b741..80c87326f50 100644 --- a/mozilla/editor/composer/src/Makefile.in +++ b/mozilla/editor/composer/src/Makefile.in @@ -64,7 +64,6 @@ REQUIRES = xpcom \ CPPSRCS = \ nsEditorShell.cpp \ - nsEditorShellMouseListener.cpp \ nsEditorParserObserver.cpp \ nsInterfaceState.cpp \ nsComposerController.cpp \ diff --git a/mozilla/editor/composer/src/makefile.win b/mozilla/editor/composer/src/makefile.win index eecc3e35fe7..2cf50ee7436 100644 --- a/mozilla/editor/composer/src/makefile.win +++ b/mozilla/editor/composer/src/makefile.win @@ -28,7 +28,6 @@ MODULE_NAME=nsComposerModule CPP_OBJS = \ .\$(OBJDIR)\nsEditorShell.obj \ .\$(OBJDIR)\nsEditingSession.obj \ - .\$(OBJDIR)\nsEditorShellMouseListener.obj \ .\$(OBJDIR)\nsInterfaceState.obj \ .\$(OBJDIR)\nsComposerController.obj \ .\$(OBJDIR)\nsComposerCommands.obj \ diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index 8ea7dc7d3f7..5a20b6a28bc 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -113,7 +113,6 @@ #include "nsISpellChecker.h" #include "nsInterfaceState.h" -#include "nsEditorShellMouseListener.h" #include "nsIStringBundle.h" #include "nsHTMLTags.h" @@ -304,23 +303,6 @@ nsEditorShell::Shutdown() (void) webProgress->RemoveProgressListener(this); } } - - // Remove our document mouse event listener - if (mMouseListenerP) - { - nsCOMPtr erP; - rv = GetDocumentEventReceiver(getter_AddRefs(erP)); - if (NS_SUCCEEDED(rv)) - { - if (erP) - { - erP->RemoveEventListenerByIID(mMouseListenerP, NS_GET_IID(nsIDOMMouseListener)); - mMouseListenerP = nsnull; - } - else rv = NS_ERROR_NULL_POINTER; - } - } - return rv; } @@ -380,18 +362,6 @@ nsEditorShell::ResetEditingState() } } - // Remove our document mouse event listener - if (mMouseListenerP) - { - nsCOMPtr erP; - rv = GetDocumentEventReceiver(getter_AddRefs(erP)); - if (NS_SUCCEEDED(rv) && erP) - { - erP->RemoveEventListenerByIID(mMouseListenerP, NS_GET_IID(nsIDOMMouseListener)); - mMouseListenerP = nsnull; - } - } - // clear this editor out of the controller if (mEditorController) { @@ -536,34 +506,9 @@ nsEditorShell::PrepareDocumentForEditing(nsIDOMWindow* aDOMWindow, nsIURI *aUrl) mEditorController->SetCommandRefCon(editorAsISupports); } - if (mEditorType == eHTMLTextEditorType) - { - // get a mouse listener for double click on tags - // We can't use nsEditor listener because core editor shouldn't call UI commands - rv = NS_NewEditorShellMouseListener(getter_AddRefs(mMouseListenerP), this); - if (NS_FAILED(rv)) - { - mMouseListenerP = nsnull; - return rv; - } - - // Add mouse listener to document - nsCOMPtr erP; - rv = GetDocumentEventReceiver(getter_AddRefs(erP)); - if (NS_FAILED(rv)) - { - mMouseListenerP = nsnull; - return rv; - } - - rv = erP->AddEventListenerByIID(mMouseListenerP, NS_GET_IID(nsIDOMMouseListener)); - if (NS_FAILED(rv)) return rv; - } - - // now all the listeners are set up, we can call PostCreate rv = editor->PostCreate(); if (NS_FAILED(rv)) return rv; - + if (!mMailCompose) { // Set the editor-specific Window caption UpdateWindowTitleAndRecentMenu(PR_TRUE); @@ -649,37 +594,6 @@ nsEditorShell::PrepareDocumentForEditing(nsIDOMWindow* aDOMWindow, nsIURI *aUrl) return NS_OK; } -nsresult nsEditorShell::GetDocumentEventReceiver(nsIDOMEventReceiver **aEventReceiver) -{ - if (!aEventReceiver) return NS_ERROR_NULL_POINTER; - if (!mContentWindow || !mEditor) return NS_ERROR_NOT_INITIALIZED; - - nsCOMPtr domDoc; - - if(!mContentWindow) - return NS_ERROR_NOT_INITIALIZED; - nsCOMPtr cwP = do_QueryReferent(mContentWindow); - if (!cwP) return NS_ERROR_NOT_INITIALIZED; - cwP->GetDocument(getter_AddRefs(domDoc)); - //mContentWindow->GetDocument(getter_AddRefs(domDoc)); - - if (!domDoc) return NS_ERROR_NOT_INITIALIZED; - - nsCOMPtr rootElement; - nsCOMPtr editor = do_QueryInterface(mEditor); - nsresult rv = editor->GetRootElement(getter_AddRefs(rootElement)); - - nsCOMPtr erP; - rv = rootElement->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(erP)); - - if (erP) - { - *aEventReceiver = erP; - NS_ADDREF(*aEventReceiver); - } - return rv; -} - nsresult nsEditorShell::GetDocShellFromContentWindow(nsIDocShell **aDocShell) { @@ -1930,11 +1844,11 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) return res; // This should only be allowed for HTML documents - if (mEditorType != eHTMLTextEditorType) - return NS_ERROR_NOT_IMPLEMENTED; - - res = mEditor->SetDocumentTitle(nsDependentString(title)); - if (NS_FAILED(res)) return res; + if (mEditorType == eHTMLTextEditorType) + { + res = mEditor->SetDocumentTitle(nsDependentString(title)); + if (NS_FAILED(res)) return res; + } // PR_FALSE means don't save menu to prefs return UpdateWindowTitleAndRecentMenu(PR_FALSE); @@ -4903,41 +4817,6 @@ nsEditorShell::CheckPrefAndNormalizeTable() } -NS_IMETHODIMP -nsEditorShell::HandleMouseClickOnElement(nsIDOMElement *aElement, PRInt32 aClickCount, - PRInt32 x, PRInt32 y, PRBool *_retval) -{ - // Guess it's ok if we don't have an element - if (!aElement) return NS_OK; - if (!_retval) return NS_ERROR_NULL_POINTER; - - *_retval = PR_FALSE; - - nsresult rv = NS_OK; - - // For double-click, edit element properties - if (aClickCount == 2) - { - // In "All Tags" mode, use AdvancedProperties, - // in others use appriate object property dialog - if (mDisplayMode == eDisplayModeAllTags) - { - // We must select element here because we don't do that for - // body, table, td, tr, caption elements in nsEditorShellMouseListener - rv = SelectElement(aElement); - if (NS_FAILED(rv)) return rv; - rv = DoControllerCommand(NS_LITERAL_STRING("cmd_advancedProperties")); - } - else - rv = DoControllerCommand(NS_LITERAL_STRING("cmd_objectProperties")); - - if (NS_SUCCEEDED(rv)) - *_retval = PR_TRUE; - } - - return rv; -} - nsresult nsEditorShell::DoControllerCommand(const nsAReadableString& aCommand) { diff --git a/mozilla/editor/composer/src/nsEditorShell.h b/mozilla/editor/composer/src/nsEditorShell.h index d333e508761..ed6d5ce603a 100644 --- a/mozilla/editor/composer/src/nsEditorShell.h +++ b/mozilla/editor/composer/src/nsEditorShell.h @@ -206,12 +206,6 @@ class nsEditorShell : public nsIEditorShell, nsCOMPtr mSearchContext; // context used for search and replace. Owned by the appshell. nsCOMPtr mSpellChecker; - // Let UI detect and process double click on elements for AdvancedProperties - // (see nsEditorShellMouseEventListener) - nsCOMPtr mMouseListenerP; - // We need this to add mMouseListenerP to document - nsresult GetDocumentEventReceiver(nsIDOMEventReceiver **aEventReceiver); - nsresult GetDocShellFromContentWindow(nsIDocShell **aDocShell); PRBool mMailCompose; diff --git a/mozilla/editor/idl/nsIEditorShell.idl b/mozilla/editor/idl/nsIEditorShell.idl index e94915eafa1..9d94fef1ea8 100644 --- a/mozilla/editor/idl/nsIEditorShell.idl +++ b/mozilla/editor/idl/nsIEditorShell.idl @@ -193,12 +193,6 @@ interface nsIEditorShell : nsISupports /** Element insert and property editing */ - /** Let editor handle clicking on a non-text element - * to do selection, property editing, etc. - * @return true if we "consumed" the event - */ - boolean HandleMouseClickOnElement(in nsIDOMElement element, in PRInt32 clickCount, in PRInt32 x, in PRInt32 y); - /** Return an element only if it is the only node selected, * such as an image, horizontal rule, etc. * The exception is a link, which is more like a text attribute: diff --git a/mozilla/editor/libeditor/html/Makefile.in b/mozilla/editor/libeditor/html/Makefile.in index 14089f6b6e9..f1cd019a481 100644 --- a/mozilla/editor/libeditor/html/Makefile.in +++ b/mozilla/editor/libeditor/html/Makefile.in @@ -55,6 +55,7 @@ CPPSRCS = \ nsHTMLEditorStyle.cpp \ nsHTMLEditRules.cpp \ nsHTMLEditUtils.cpp \ + nsHTMLEditorMouseListener.cpp \ nsHTMLURIRefObject.cpp \ nsTableEditor.cpp \ nsWSRunObject.cpp \ diff --git a/mozilla/editor/libeditor/html/makefile.win b/mozilla/editor/libeditor/html/makefile.win index a52f964c529..f77103ccb86 100644 --- a/mozilla/editor/libeditor/html/makefile.win +++ b/mozilla/editor/libeditor/html/makefile.win @@ -46,6 +46,7 @@ CPP_OBJS = \ .\$(OBJDIR)\nsHTMLDataTransfer.obj \ .\$(OBJDIR)\nsHTMLEditRules.obj \ .\$(OBJDIR)\nsHTMLEditUtils.obj \ + .\$(OBJDIR)\nsHTMLEditorMouseListener.obj \ .\$(OBJDIR)\nsHTMLEditor.obj \ .\$(OBJDIR)\nsHTMLEditorStyle.obj \ .\$(OBJDIR)\nsHTMLURIRefObject.obj \ diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index eadde95ba25..5877f593009 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -48,6 +48,7 @@ #include "nsHTMLEditUtils.h" #include "nsEditorEventListeners.h" +#include "nsHTMLEditorMouseListener.h" #include "TypeInState.h" #include "nsHTMLURIRefObject.h" @@ -346,7 +347,7 @@ nsHTMLEditor::InstallEventListeners() } // get a mouse listener - result = NS_NewEditorMouseListener(getter_AddRefs(mMouseListenerP), this); + result = NS_NewHTMLEditorMouseListener(getter_AddRefs(mMouseListenerP), this); if (NS_FAILED(result)) { HandleEventListenerError(); return result; diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorMouseListener.cpp b/mozilla/editor/libeditor/html/nsHTMLEditorMouseListener.cpp new file mode 100644 index 00000000000..ab886c27b43 --- /dev/null +++ b/mozilla/editor/libeditor/html/nsHTMLEditorMouseListener.cpp @@ -0,0 +1,229 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Charles Manske (cmanske@netscape.com) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#include "nsHTMLEditorMouseListener.h" +#include "nsString.h" + +#include "nsIDOMEvent.h" +#include "nsIDOMElement.h" +#include "nsIDOMMouseEvent.h" +#include "nsISelection.h" +#include "nsIDOMRange.h" +#include "nsIDOMNSRange.h" +#include "nsIDOMEventTarget.h" +#include "nsIDOMNSUIEvent.h" +#include "nsIDOMHTMLTableElement.h" +#include "nsIDOMHTMLTableCellElement.h" +#include "nsIContent.h" + +#include "nsIEditor.h" +#include "nsIHTMLEditor.h" +#include "nsIEditProperty.h" +#include "nsTextEditUtils.h" + +/* + * nsHTMLEditorMouseListener implementation + * + * The only reason we need this is so a context mouse-click + * moves the caret or selects an element as it does for normal click + */ + +nsHTMLEditorMouseListener::nsHTMLEditorMouseListener() +{ + NS_INIT_REFCNT(); +} + +nsHTMLEditorMouseListener::~nsHTMLEditorMouseListener() +{ +} + +NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLEditorMouseListener, nsTextEditorMouseListener, nsIDOMMouseListener) + +nsresult +nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) +{ + NS_ENSURE_TRUE(aMouseEvent, NS_ERROR_NULL_POINTER); + nsCOMPtr mouseEvent ( do_QueryInterface(aMouseEvent) ); + if (!mouseEvent) { + //non-ui event passed in. bad things. + return NS_OK; + } + nsresult res; + + // Don't do anything special if not an HTML editor + nsCOMPtr htmlEditor = do_QueryInterface(mEditor); + if (htmlEditor) + { + // Detect only "context menu" click + //XXX This should be easier to do! + // But eDOMEvents_contextmenu and NS_CONTEXTMENU is not exposed in any event interface :-( + PRUint16 buttonNumber; + res = mouseEvent->GetButton(&buttonNumber); + if (NS_FAILED(res)) return res; + + PRBool isContextClick; + +#if defined(XP_MAC) || defined(XP_MACOSX) + // Ctrl+Click for context menu + res = mouseEvent->GetCtrlKey(&isContextClick); + if (NS_FAILED(res)) return res; +#else + // Right mouse button for Windows, UNIX + isContextClick = buttonNumber == 2; +#endif + + PRInt32 clickCount; + res = mouseEvent->GetDetail(&clickCount); + if (NS_FAILED(res)) return res; + + if (isContextClick || (buttonNumber == 0 && clickCount == 2)) + { + nsCOMPtr target; + res = aMouseEvent->GetTarget(getter_AddRefs(target)); + if (NS_FAILED(res)) return res; + if (!target) return NS_ERROR_NULL_POINTER; + nsCOMPtr element = do_QueryInterface(target); + + PRInt32 clickCount; + res = mouseEvent->GetDetail(&clickCount); + if (NS_FAILED(res)) return res; + + nsCOMPtr selection; + mEditor->GetSelection(getter_AddRefs(selection)); + if (!selection) return NS_OK; + + nsCOMPtr parent; + PRInt32 offset = 0; + + // Get location of mouse within target node + nsCOMPtr uiEvent = do_QueryInterface(aMouseEvent); + if (!uiEvent) return NS_ERROR_FAILURE; + + res = uiEvent->GetRangeParent(getter_AddRefs(parent)); + if (NS_FAILED(res)) return res; + if (!parent) return NS_ERROR_FAILURE; + + res = uiEvent->GetRangeOffset(&offset); + if (NS_FAILED(res)) return res; + + // Detect if mouse point is within current selection for context click + PRBool nodeIsInSelection = PR_FALSE; + if ( !(buttonNumber == 0 && clickCount == 2) ) + { + PRBool isCollapsed; + selection->GetIsCollapsed(&isCollapsed); + if (!isCollapsed) + { + PRInt32 rangeCount; + res = selection->GetRangeCount(&rangeCount); + if (NS_FAILED(res)) return res; + + for (PRInt32 i = 0; i < rangeCount; i++) + { + nsCOMPtr range; + + res = selection->GetRangeAt(i, getter_AddRefs(range)); + if (NS_FAILED(res) || !range) + continue;//dont bail yet, iterate through them all + + nsCOMPtr nsrange(do_QueryInterface(range)); + if (NS_FAILED(res) || !nsrange) + continue;//dont bail yet, iterate through them all + + res = nsrange->IsPointInRange(parent, offset, &nodeIsInSelection); + + // Done when we find a range that we are in + if (nodeIsInSelection) + break; + } + } + } + nsCOMPtr node = do_QueryInterface(target); + if (node && !nodeIsInSelection) + { + PRBool elementIsLink = PR_FALSE; + if (element) + { + // Set caret just before an element + selection->Collapse(parent, offset); + } + else + { + // Get enclosing link if in text so we can select the link + //XXX Although I'd prefer to not select a link on context click, + // logic to place caret within a textnode is complicated and hidden + // in nsFrame code which is never reached during context-click processing + nsCOMPtr linkElement; + res = htmlEditor->GetElementOrParentByTagName(NS_LITERAL_STRING("href"), node, getter_AddRefs(linkElement)); + if (NS_FAILED(res)) return res; + if (linkElement) + element = linkElement; + } + // Select entire element clicked on if NOT within an existing selection + // and not the entire body, or table-related elements + if (element && !nodeIsInSelection && + !nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("body")) && + !nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("td")) && + !nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("th")) && + !nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("caption")) && + !nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("tr")) && + !nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("table"))) + { + htmlEditor->SelectElement(element); + } + } + mouseEvent->PreventDefault(); + return NS_OK; + } + } + + return nsTextEditorMouseListener::MouseDown(aMouseEvent); +} + +nsresult +NS_NewHTMLEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, + nsIEditor *aEditor) +{ + nsHTMLEditorMouseListener* listener = new nsHTMLEditorMouseListener(); + if (!listener) + return NS_ERROR_OUT_OF_MEMORY; + + listener->SetEditor(aEditor); + + return listener->QueryInterface(NS_GET_IID(nsIDOMEventListener), (void **) aInstancePtrResult); +} diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorMouseListener.h b/mozilla/editor/libeditor/html/nsHTMLEditorMouseListener.h new file mode 100644 index 00000000000..880be4726ea --- /dev/null +++ b/mozilla/editor/libeditor/html/nsHTMLEditorMouseListener.h @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Charles Manske (cmanske@netscape.com) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef htmlEditorMouseListener_h__ +#define htmlEditorMouseListener_h__ + +#include "nsCOMPtr.h" +#include "nsIDOMEvent.h" +#include "nsIDOMMouseListener.h" +#include "nsIEditor.h" +#include "nsIPlaintextEditor.h" +#include "nsIHTMLEditor.h" +#include "nsEditorEventListeners.h" + +class nsString; + +class nsHTMLEditorMouseListener : public nsTextEditorMouseListener +{ +public: + /** default constructor + */ + nsHTMLEditorMouseListener(); + /** default destructor + */ + virtual ~nsHTMLEditorMouseListener(); + +// void SetEditor(nsIEditor *aEditor){mEditor = aEditor;} + +/*interfaces for addref and release and queryinterface*/ + NS_DECL_ISUPPORTS_INHERITED + +/*BEGIN implementations of mouseevent handler interface*/ + NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent); +/*END implementations of mouseevent handler interface*/ + +}; + +/** factory for the mouse listener + */ +extern nsresult NS_NewHTMLEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor); + +#endif //htmlEditorMouseListener_h__ + diff --git a/mozilla/editor/macbuild/composer.xml b/mozilla/editor/macbuild/composer.xml index 7aecd3f3b3e..44c0b8f33f9 100644 --- a/mozilla/editor/macbuild/composer.xml +++ b/mozilla/editor/macbuild/composer.xml @@ -1007,13 +1007,6 @@ Text Debug - - Name - nsEditorShellMouseListener.cpp - MacOS - Text - Debug - Name nsComposerController.cpp @@ -1111,11 +1104,6 @@ JavaScriptDebug.shlb MacOS - - Name - nsEditorShellMouseListener.cpp - MacOS - Name nsComposerController.cpp @@ -2092,13 +2080,6 @@ Text Debug - - Name - nsEditorShellMouseListener.cpp - MacOS - Text - Debug - Name nsComposerController.cpp @@ -2196,11 +2177,6 @@ JavaScript.shlb MacOS - - Name - nsEditorShellMouseListener.cpp - MacOS - Name nsComposerController.cpp @@ -2256,12 +2232,6 @@ nsEditorShell.cpp MacOS - - ComposerDebug.shlb - Name - nsEditorShellMouseListener.cpp - MacOS - ComposerDebug.shlb Name diff --git a/mozilla/editor/macbuild/editor.xml b/mozilla/editor/macbuild/editor.xml index c2f61d40788..0953db084b3 100644 --- a/mozilla/editor/macbuild/editor.xml +++ b/mozilla/editor/macbuild/editor.xml @@ -1067,6 +1067,13 @@ Text Debug + + Name + nsHTMLEditorMouseListener.cpp + MacOS + Text + Debug + Name nsTextEditRules.cpp @@ -1417,6 +1424,11 @@ nsHTMLEditor.cpp MacOS + + Name + nsHTMLEditorMouseListener.cpp + MacOS + Name nsTextEditRules.cpp @@ -2598,6 +2610,13 @@ Text Debug + + Name + nsHTMLEditorMouseListener.cpp + MacOS + Text + Debug + Name nsTextEditRules.cpp @@ -2941,6 +2960,11 @@ nsHTMLEditor.cpp MacOS + + Name + nsHTMLEditorMouseListener.cpp + MacOS + Name nsTextEditRules.cpp @@ -6042,6 +6066,12 @@ nsHTMLEditor.cpp MacOS + + HTMLEditorDebug.shlb + Name + nsHTMLEditorMouseListener.cpp + MacOS + HTMLEditorDebug.shlb Name diff --git a/mozilla/editor/ui/composer/content/editor.js b/mozilla/editor/ui/composer/content/editor.js index a72f0428c4e..2705217a51f 100644 --- a/mozilla/editor/ui/composer/content/editor.js +++ b/mozilla/editor/ui/composer/content/editor.js @@ -1246,6 +1246,38 @@ function GetParentTableCell(element) return node; } +function EditorDblClick(event) +{ + goDoCommand("cmd_objectProperties"); +} + +function EditorClick(event) +{ + // In Show All Tags Mode, + // single click selects entire element, + // except for body and table elements + if (event && event.target && gEditorDisplayMode == DisplayModeAllTags) + { + try { + var element = event.target.QueryInterface( Components.interfaces.nsIDOMElement); + if (element) + { + var name = element.localName.toLowerCase(); + if (name != "body" && name != "table" && + name != "td" && name != "th" && name != "caption" && name != "tr") + { + var htmlEditor = editorShell.editor.QueryInterface(Components.interfaces.nsIHTMLEditor); + if (htmlEditor && event.target) + { + htmlEditor.selectElement(event.target); + event.preventDefault(); + } + } + } + } catch (e) {} + } +} + /*TODO: We need an oncreate hook to do enabling/disabling for the Format menu. There should be code like this for the object-specific "Properties" item @@ -1641,8 +1673,9 @@ function BuildRecentMenu(savePrefs) if (!url) continue; - // Skip over current URL - if (url != curUrl) + var scheme = GetScheme(url); + // Skip over current and "data:" URL + if (url != curUrl && scheme && scheme != "data") { // Build the menu AppendRecentMenuitem(popup, title, url, menuIndex); @@ -2631,22 +2664,3 @@ function SwitchInsertCharToAnotherEditorOrClose() window.InsertCharWindow.close(); } } - -function GetHTMLOrCSSStyleValue(element, attrName, cssPropertyName) -{ - var prefs = GetPrefs(); - var IsCSSPrefChecked = prefs.getBoolPref("editor.use_css"); - var value; - if (IsCSSPrefChecked && editorShell.editorType == "html") - { - value = element.style.getPropertyValue(cssPropertyName); - if (value == "") { - value = element.getAttribute(attrName); - } - } - else - { - value = element.getAttribute(attrName); - } - return value; -} diff --git a/mozilla/editor/ui/composer/content/editor.xul b/mozilla/editor/ui/composer/content/editor.xul index 9234d11164e..268b4916d9b 100644 --- a/mozilla/editor/ui/composer/content/editor.xul +++ b/mozilla/editor/ui/composer/content/editor.xul @@ -236,7 +236,8 @@ which breaks deck frame-hiding mechanism --> - +