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

This commit is contained in:
cmanske%netscape.com 2002-03-17 20:39:16 +00:00
parent 94f37d49ae
commit d5612a514e
14 changed files with 385 additions and 194 deletions

View File

@ -64,7 +64,6 @@ REQUIRES = xpcom \
CPPSRCS = \
nsEditorShell.cpp \
nsEditorShellMouseListener.cpp \
nsEditorParserObserver.cpp \
nsInterfaceState.cpp \
nsComposerController.cpp \

View File

@ -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 \

View File

@ -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<nsIDOMEventReceiver> 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<nsIDOMEventReceiver> 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<nsIDOMEventReceiver> 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<nsIDOMDocument> domDoc;
if(!mContentWindow)
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMWindowInternal> 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<nsIDOMElement> rootElement;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
nsresult rv = editor->GetRootElement(getter_AddRefs(rootElement));
nsCOMPtr<nsIDOMEventReceiver> 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)
{

View File

@ -206,12 +206,6 @@ class nsEditorShell : public nsIEditorShell,
nsCOMPtr<nsISupports> mSearchContext; // context used for search and replace. Owned by the appshell.
nsCOMPtr<nsISpellChecker> mSpellChecker;
// Let UI detect and process double click on elements for AdvancedProperties
// (see nsEditorShellMouseEventListener)
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
// We need this to add mMouseListenerP to document
nsresult GetDocumentEventReceiver(nsIDOMEventReceiver **aEventReceiver);
nsresult GetDocShellFromContentWindow(nsIDocShell **aDocShell);
PRBool mMailCompose;

View File

@ -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:

View File

@ -55,6 +55,7 @@ CPPSRCS = \
nsHTMLEditorStyle.cpp \
nsHTMLEditRules.cpp \
nsHTMLEditUtils.cpp \
nsHTMLEditorMouseListener.cpp \
nsHTMLURIRefObject.cpp \
nsTableEditor.cpp \
nsWSRunObject.cpp \

View File

@ -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 \

View File

@ -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;

View File

@ -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<nsIDOMMouseEvent> 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<nsIHTMLEditor> 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<nsIDOMEventTarget> target;
res = aMouseEvent->GetTarget(getter_AddRefs(target));
if (NS_FAILED(res)) return res;
if (!target) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
PRInt32 clickCount;
res = mouseEvent->GetDetail(&clickCount);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsISelection> selection;
mEditor->GetSelection(getter_AddRefs(selection));
if (!selection) return NS_OK;
nsCOMPtr<nsIDOMNode> parent;
PRInt32 offset = 0;
// Get location of mouse within target node
nsCOMPtr<nsIDOMNSUIEvent> 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<nsIDOMRange> range;
res = selection->GetRangeAt(i, getter_AddRefs(range));
if (NS_FAILED(res) || !range)
continue;//dont bail yet, iterate through them all
nsCOMPtr<nsIDOMNSRange> 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<nsIDOMNode> 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<nsIDOMElement> 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);
}

View File

@ -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__

View File

@ -1007,13 +1007,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsEditorShellMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsComposerController.cpp</PATH>
@ -1111,11 +1104,6 @@
<PATH>JavaScriptDebug.shlb</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsEditorShellMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsComposerController.cpp</PATH>
@ -2092,13 +2080,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsEditorShellMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsComposerController.cpp</PATH>
@ -2196,11 +2177,6 @@
<PATH>JavaScript.shlb</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsEditorShellMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsComposerController.cpp</PATH>
@ -2256,12 +2232,6 @@
<PATH>nsEditorShell.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>ComposerDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsEditorShellMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>ComposerDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

View File

@ -1067,6 +1067,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsHTMLEditorMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsTextEditRules.cpp</PATH>
@ -1417,6 +1424,11 @@
<PATH>nsHTMLEditor.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsHTMLEditorMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsTextEditRules.cpp</PATH>
@ -2598,6 +2610,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsHTMLEditorMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsTextEditRules.cpp</PATH>
@ -2941,6 +2960,11 @@
<PATH>nsHTMLEditor.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsHTMLEditorMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsTextEditRules.cpp</PATH>
@ -6042,6 +6066,12 @@
<PATH>nsHTMLEditor.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>HTMLEditorDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsHTMLEditorMouseListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>HTMLEditorDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

View File

@ -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;
}

View File

@ -236,7 +236,8 @@
which breaks deck frame-hiding mechanism
-->
<stack>
<editor type="content-primary" id="content-frame" src="about:blank" context="editorContentContext" flex="1"/>
<editor type="content-primary" id="content-frame" src="about:blank" context="editorContentContext" flex="1"
onclick="EditorClick(event);" ondblclick="EditorDblClick(event);"/>
</stack>
<vbox>
<label id="doctype-text" crop="right"/>