pulling content-area drag&drop out of JS and into C++ so it is available to embedding. Now built-in to <browser> tag. r=brade/sr=ben. bug#45605

This commit is contained in:
pinkerton%netscape.com 2002-02-17 19:32:08 +00:00
Родитель 4ae0d1e48d
Коммит 6f1ac94599
20 изменённых файлов: 243 добавлений и 412 удалений

Просмотреть файл

@ -13,3 +13,4 @@ nsIScriptLoaderObserver.idl
nsIPrintProgress.idl
nsIPrintStatusFeedback.idl
nsIPrintProgressParams.idl
nsIDragDropHandler.idl

Просмотреть файл

@ -71,6 +71,7 @@ XPIDLSRCS = \
nsIPrintProgress.idl \
nsIPrintProgressParams.idl \
nsIPrintStatusFeedback.idl \
nsIDragDropHandler.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -66,6 +66,7 @@ XPIDLSRCS= \
.\nsIPrintProgress.idl \
.\nsIPrintStatusFeedback.idl \
.\nsIPrintProgressParams.idl \
.\nsIDragDropHandler.idl \
$(NULL)

Просмотреть файл

@ -95,6 +95,7 @@ CPPSRCS = \
nsPlainTextSerializer.cpp \
nsScriptLoader.cpp \
nsStyleLinkElement.cpp \
nsContentAreaDragDrop.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

Просмотреть файл

@ -95,6 +95,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsContentUtils.obj \
.\$(OBJDIR)\nsScriptLoader.obj \
.\$(OBJDIR)\nsStyleLinkElement.obj \
.\$(OBJDIR)\nsContentAreaDragDrop.cpp \
$(NULL)
LINCS=-I..\..\html\base\src -I..\..\html\style\src \

Просмотреть файл

@ -102,6 +102,8 @@
#include "nsXMLContentSerializer.h"
#include "nsRuleNode.h"
#include "nsWyciwygProtocolHandler.h"
#include "nsContentAreaDragDrop.h"
class nsIDocumentLoaderFactory;
@ -359,6 +361,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentHTTPStartup)
MAKE_CTOR(CreateContentDLF, nsIDocumentLoaderFactory, NS_NewContentDocumentLoaderFactory)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCSSOMFactory)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWyciwygProtocolHandler)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentAreaDragDrop)
static NS_IMETHODIMP
CreateHTMLImgElement(nsISupports* aOuter, REFNSIID aIID, void** aResult)
@ -809,7 +812,12 @@ static const nsModuleComponentInfo gComponents[] = {
{ "Wyciwyg Handler",
NS_WYCIWYGPROTOCOLHANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "wyciwyg",
nsWyciwygProtocolHandlerConstructor }
nsWyciwygProtocolHandlerConstructor },
{ "Content Area DragDrop",
NS_CONTENTAREADRAGDROP_CID,
NS_CONTENTAREADRAGDROP_CONTRACTID,
nsContentAreaDragDropConstructor }
};

Просмотреть файл

@ -2289,6 +2289,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsContentAreaDragDrop.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStatic.o</PATH>
@ -3402,6 +3409,11 @@
<PATH>nsRuleNode.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsContentAreaDragDrop.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStatic.o</PATH>
@ -5730,6 +5742,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsContentAreaDragDrop.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStaticDebug.o</PATH>
@ -6843,6 +6862,11 @@
<PATH>nsRuleNode.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsContentAreaDragDrop.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStaticDebug.o</PATH>
@ -7154,6 +7178,12 @@
<PATH>nsRuleNode.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>content.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsContentAreaDragDrop.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUP>
<GROUP><NAME>build</NAME>
<FILEREF>

Просмотреть файл

@ -883,6 +883,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDragDropHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -980,6 +987,11 @@
<PATH>nsIWyciwygChannel.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDragDropHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
<TARGET>
@ -1812,6 +1824,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDragDropHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -1909,6 +1928,11 @@
<PATH>nsIWyciwygChannel.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDragDropHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
</TARGETLIST>
@ -2033,6 +2057,12 @@
<PATH>nsIWyciwygChannel.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDragDropHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUPLIST>
</PROJECT>

Просмотреть файл

@ -80,6 +80,8 @@
static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);
nsCOMPtr<nsIDragHelperService> CBrowserShell::sDragHelper;
//*****************************************************************************
//*** CBrowserShellProgressListener
//*****************************************************************************
@ -237,7 +239,8 @@ NS_IMETHODIMP CBrowserShellProgressListener::OnSecurityChange(nsIWebProgress *aW
CBrowserShell::CBrowserShell() :
mChromeFlags(nsIWebBrowserChrome::CHROME_DEFAULT), mIsMainContent(true),
mContextMenuContext(nsIContextMenuListener::CONTEXT_NONE), mContextMenuDOMNode(nsnull)
mContextMenuContext(nsIContextMenuListener::CONTEXT_NONE), mContextMenuDOMNode(nsnull),
LDropArea(GetMacWindow())
{
nsresult rv = CommonConstruct();
if (rv != NS_OK)
@ -249,9 +252,10 @@ CBrowserShell::CBrowserShell(const SPaneInfo &inPaneInfo,
const SViewInfo &inViewInfo,
const UInt32 inChromeFlags,
const Boolean inIsMainContent) :
LView(inPaneInfo, inViewInfo),
LView(inPaneInfo, inViewInfo), LDropArea(GetMacWindow()),
mChromeFlags(inChromeFlags), mIsMainContent(inIsMainContent),
mContextMenuContext(nsIContextMenuListener::CONTEXT_NONE), mContextMenuDOMNode(nsnull)
{
nsresult rv = CommonConstruct();
if (rv != NS_OK)
@ -260,7 +264,7 @@ CBrowserShell::CBrowserShell(const SPaneInfo &inPaneInfo,
CBrowserShell::CBrowserShell(LStream* inStream) :
LView(inStream),
LView(inStream), LDropArea(GetMacWindow()),
mContextMenuContext(nsIContextMenuListener::CONTEXT_NONE), mContextMenuDOMNode(nsnull)
{
*inStream >> mChromeFlags;
@ -1411,3 +1415,55 @@ void CBrowserShell::PostOpenURLEvent(const nsACString& url)
}
UAppleEventsMgr::SendAppleEvent(getURLEvent);
}
void
CBrowserShell::InsideDropArea(DragReference inDragRef)
{
if ( sDragHelper ) {
PRBool dropAllowed = PR_FALSE;
sDragHelper->Tracking ( inDragRef, mEventSink, &dropAllowed );
}
}
void
CBrowserShell::EnterDropArea( DragReference inDragRef, Boolean inDragHasLeftSender)
{
sDragHelper = do_GetService ( "@mozilla.org/widget/draghelperservice;1" );
NS_ASSERTION ( sDragHelper, "Couldn't get a drag service, we're in biiig trouble" );
if ( sDragHelper )
sDragHelper->Enter ( inDragRef, mEventSink );
}
void
CBrowserShell::LeaveDropArea( DragReference inDragRef )
{
if ( sDragHelper ) {
sDragHelper->Leave ( inDragRef, mEventSink );
sDragHelper = nsnull;
}
}
Boolean
CBrowserShell::PointInDropArea(Point inGlobalPt)
{
return true;
}
Boolean
CBrowserShell::DragIsAcceptable( DragReference inDragRef )
{
return true;
}
void
CBrowserShell::DoDragReceive( DragReference inDragRef )
{
if ( sDragHelper ) {
PRBool dragAccepted = PR_FALSE;
sDragHelper->Drop ( inDragRef, mEventSink, &dragAccepted );
}
}

Просмотреть файл

@ -28,6 +28,7 @@
#include <LPeriodical.h>
#include <LListener.h>
#include <LString.h>
#include <LDragAndDrop.h>
#include "nsCOMPtr.h"
#include "nsAString.h"
@ -36,6 +37,7 @@
#include "nsIWebNavigation.h"
#include "nsIEventSink.h"
#include "nsIWebProgress.h"
#include "nsIDragHelperService.h"
class CBrowserChrome;
class CBrowserShellProgressListener;
@ -52,7 +54,8 @@ class nsIDOMNode;
class CBrowserShell : public LView,
public LCommander,
public LBroadcaster,
public LPeriodical
public LPeriodical,
public LDropArea
{
friend class CBrowserChrome;
@ -151,6 +154,15 @@ public:
Boolean FindNext();
protected:
// LDropArea
virtual void InsideDropArea( DragReference inDragRef );
virtual Boolean PointInDropArea( Point inGlobalPt) ;
virtual Boolean DragIsAcceptable( DragReference inDragRef );
virtual void EnterDropArea( DragReference inDragRef, Boolean inDragHasLeftSender);
virtual void LeaveDropArea( DragReference inDragRef );
virtual void DoDragReceive( DragReference inDragRef );
NS_METHOD OnShowContextMenu(PRUint32 aContextFlags,
nsIDOMEvent *aEvent,
nsIDOMNode *aNode);
@ -188,6 +200,8 @@ protected:
nsCOMPtr<nsIBaseWindow> mWebBrowserAsBaseWin; // Convenience interface to above
nsCOMPtr<nsIWebNavigation> mWebBrowserAsWebNav; // Ditto
static nsCOMPtr<nsIDragHelperService> sDragHelper;
CBrowserChrome *mChrome;
CBrowserShellProgressListener *mProgressListener;

Просмотреть файл

@ -33,6 +33,7 @@
#include "nsSize.h"
#include "nsHTMLReflowState.h"
#include "nsIServiceManager.h"
#include "nsComponentManagerUtils.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
@ -51,6 +52,7 @@
#include "nsIDOMMouseEvent.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIWebNavigation.h"
#include "nsIDOMHTMLElement.h"
#include "nsIPresShell.h"
#include "nsPIDOMWindow.h"
@ -67,6 +69,37 @@
static const char sWindowWatcherContractID[] = "@mozilla.org/embedcomp/window-watcher;1";
//
// GetEventReceiver
//
// A helper routine that navigates the tricky path from a |nsWebBrowser| to
// a |nsIDOMEventReceiver| via the window root and chrome event handler.
//
static nsresult
GetEventReceiver ( nsWebBrowser* inBrowser, nsIDOMEventReceiver** outEventRcvr )
{
nsCOMPtr<nsIDOMWindow> domWindow;
inBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> domWindowPrivate = do_QueryInterface(domWindow);
NS_ENSURE_TRUE(domWindowPrivate, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindowInternal> rootWindow;
domWindowPrivate->GetPrivateRoot(getter_AddRefs(rootWindow));
NS_ENSURE_TRUE(rootWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsIChromeEventHandler> chromeHandler;
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(rootWindow));
NS_ENSURE_TRUE(piWin, NS_ERROR_FAILURE);
piWin->GetChromeEventHandler(getter_AddRefs(chromeHandler));
NS_ENSURE_TRUE(chromeHandler, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMEventReceiver> rcvr = do_QueryInterface(chromeHandler);
*outEventRcvr = rcvr.get();
NS_IF_ADDREF(*outEventRcvr);
return NS_OK;
}
//*****************************************************************************
//*** nsDocShellTreeOwner: Object Management
@ -772,7 +805,20 @@ nsDocShellTreeOwner :: AddChromeListeners ( )
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
// install the external dragDrop handler
if ( !mChromeDragHandler ) {
mChromeDragHandler = do_CreateInstance("@mozilla.org:/content/content-area-dragdrop;1", &rv);
NS_ASSERTION(mChromeDragHandler, "Couldn't create the chrome drag handler");
if ( mChromeDragHandler ) {
nsCOMPtr<nsIDOMEventReceiver> rcvr;
GetEventReceiver(mWebBrowser, getter_AddRefs(rcvr));
//nsCOMPtr<nsIDOMWebNavigation> webNav (do_QueryInterface(mWebBrowser));
nsCOMPtr<nsIDOMEventTarget> rcvrTarget(do_QueryInterface(rcvr));
mChromeDragHandler->HookupTo(rcvrTarget, NS_STATIC_CAST(nsIWebNavigation*, mWebBrowser));
}
}
return rv;
} // AddChromeListeners
@ -789,7 +835,9 @@ nsDocShellTreeOwner :: RemoveChromeListeners ( )
mChromeContextMenuListener->RemoveChromeListeners();
NS_RELEASE(mChromeContextMenuListener);
}
if ( mChromeDragHandler )
mChromeDragHandler->Detach();
return NS_OK;
}
@ -907,23 +955,8 @@ ChromeTooltipListener :: ~ChromeTooltipListener ( )
NS_IMETHODIMP
ChromeTooltipListener :: AddChromeListeners ( )
{
if ( !mEventReceiver ) {
nsCOMPtr<nsIDOMWindow> domWindow;
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> domWindowPrivate = do_QueryInterface(domWindow);
NS_ENSURE_TRUE(domWindowPrivate, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindowInternal> rootWindow;
domWindowPrivate->GetPrivateRoot(getter_AddRefs(rootWindow));
NS_ENSURE_TRUE(rootWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsIChromeEventHandler> chromeHandler;
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(rootWindow));
piWin->GetChromeEventHandler(getter_AddRefs(chromeHandler));
NS_ENSURE_TRUE(chromeHandler, NS_ERROR_FAILURE);
mEventReceiver = do_QueryInterface(chromeHandler);
}
if ( !mEventReceiver )
GetEventReceiver(mWebBrowser, getter_AddRefs(mEventReceiver));
// Register the appropriate events for tooltips, but only if
// the embedding chrome cares.
@ -1374,23 +1407,8 @@ ChromeContextMenuListener :: RemoveContextMenuListener()
NS_IMETHODIMP
ChromeContextMenuListener :: AddChromeListeners ( )
{
if ( !mEventReceiver ) {
nsCOMPtr<nsIDOMWindow> domWindow;
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> domWindowPrivate = do_QueryInterface(domWindow);
NS_ENSURE_TRUE(domWindowPrivate, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindowInternal> rootWindow;
domWindowPrivate->GetPrivateRoot(getter_AddRefs(rootWindow));
NS_ENSURE_TRUE(rootWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsIChromeEventHandler> chromeHandler;
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(rootWindow));
piWin->GetChromeEventHandler(getter_AddRefs(chromeHandler));
NS_ENSURE_TRUE(chromeHandler, NS_ERROR_FAILURE);
mEventReceiver = do_QueryInterface(chromeHandler);
}
if ( !mEventReceiver )
GetEventReceiver(mWebBrowser, getter_AddRefs(mEventReceiver));
// Register the appropriate events for context menus, but only if
// the embedding chrome cares.

Просмотреть файл

@ -49,6 +49,7 @@
#include "nsITooltipListener.h"
#include "nsITooltipTextProvider.h"
#include "nsCTooltipTextProvider.h"
#include "nsIDragDropHandler.h"
#include "nsCommandHandler.h"
@ -132,6 +133,7 @@ protected:
// and the DOM. These are strong, owning refs.
ChromeTooltipListener* mChromeTooltipListener;
ChromeContextMenuListener* mChromeContextMenuListener;
nsCOMPtr<nsIDragDropHandler> mChromeDragHandler;
nsCOMPtr<nsIPrompt> mPrompter;
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;

Просмотреть файл

@ -72,7 +72,6 @@ Rights Reserved.
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/mail-offline.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/searchBar.js"/>
@ -184,7 +183,7 @@ Rights Reserved.
<!-- message view -->
<browser id="messagepane" context="messagePaneContext" style="height: 0px" flex="1" name="messagepane"
disableHistory="true" type="content-primary" src="about:blank" onclick="contentAreaClick(event);" ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);"/>
disableHistory="true" type="content-primary" src="about:blank" onclick="contentAreaClick(event);"/>
</vbox>
</vbox>

Просмотреть файл

@ -64,7 +64,6 @@ Rights Reserved.
<script type="application/x-javascript" src="chrome://communicator/content/nsContextMenu.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/mailContextMenus.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaUtils.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
@ -132,7 +131,7 @@ Rights Reserved.
<!-- message view -->
<browser id="messagepane" context="messagePaneContext" style="height: 0px" flex="1" name="messagepane"
disableHistory="true" type="content-primary" src="about:blank" onclick="contentAreaClick(event);" ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);"/>
disableHistory="true" type="content-primary" src="about:blank" onclick="contentAreaClick(event);"/>
</vbox>

Просмотреть файл

@ -74,7 +74,6 @@ Rights Reserved.
<script type="application/x-javascript" src="chrome://messenger/content/mail-offline.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/searchBar.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
@ -170,7 +169,7 @@ Rights Reserved.
<grippy onclick="OnClickThreadAndMessagePaneSplitterGrippy()"/>
</splitter>
<vbox id="messagepanebox" flex="3" persist="collapsed height" onclick="contentAreaClick(event);" ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);">
<vbox id="messagepanebox" flex="3" persist="collapsed height" onclick="contentAreaClick(event);">
<hbox id="msgHeaderView"/>
<browser id="messagepane" context="messagePaneContext" style="height: 0px" flex="1" name="messagepane"

Просмотреть файл

@ -1,135 +0,0 @@
<?xml version="1.0"?> <!-- -*- Mode: HTML -*- -->
<!-- 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 Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-2000 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s): ______________________________________. -->
<?xml-stylesheet href="chrome://navigator/skin/" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
<!ENTITY % buildDTD SYSTEM "chrome://global/content/build.dtd" >
%buildDTD;
<!ENTITY % navigatorDTD SYSTEM "chrome://navigator/locale/navigator.dtd" >
%navigatorDTD;
]>
<window id="main-window"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Startup()" onunload="Shutdown()"
contenttitlesettting="true"
title="&mainWindow.title;"
titlemodifier="&mainWindow.titlemodifier;"
titlemenuseparator="&mainWindow.titlemodifiermenuseparator;"
windowtype="navigator:browser" orient="vertical"
width="640" height="480"
screenX="10" screenY="10"
persist="screenX screenY width height sizemode">
<!-- Fast-Nav -->
<script type="application/x-javascript" src="chrome://navigator/content/fastnav.js"/>
<toolbox id="navigator-toolbox" class="toolbox-top" deferattached="true">
<toolbar class="toolbar-primary chromeclass-toolbar" id="nav-bar" persist="collapsed"
tbalign="stretch">
<hbox id="nav-bar-buttons">
<menubutton id="back-button" label="&backButton.label;" tooltiptext="&backButton.tooltip;"
oncommand="gotoHistoryIndex(event);" buttonaction="BrowserBack();" context="backMenu"
class="menubutton-dual top" crop="right" observes="canGoBack">
<menupopup context="" onpopupshowing="BrowserBackMenu(event);"/>
</menubutton>
<menubutton id="forward-button" label="&forwardButton.label;" tooltiptext="&forwardButton.tooltip;"
oncommand="gotoHistoryIndex(event);" buttonaction="BrowserForward();" context="forwardMenu"
class="menubutton-dual top" crop="right" observes="canGoForward">
<menupopup context="" onpopupshowing="BrowserForwardMenu(event);"/>
</menubutton>
<button class="button-toolbar-1 top" id="reload-button" crop="right" oncommand="if (event.shiftKey) BrowserReloadSkipCache(); else BrowserReload();" label="&reloadButton.label;"
tooltiptext="&reloadButton.tooltip;"/>
<button class="button-toolbar-1 top" id="stop-button" crop="right" observes="canStop" oncommand="BrowserStop();" label="&stopButton.label;"
tooltiptext="&stopButton.tooltip;"/>
</hbox>
<hbox id="nav-bar-inner" flex="1">
<hbox id="urlbar-group" class="box-toolbar-group chromeclass-location" flex="1">
<hbox flex="1" id="urlbar-container">
<textbox id="urlbar" class="plain" flex="1"
type="autocomplete" searchSessions="history"
timeout="50" maxrows="6" alwaysOpenPopup="true"
defaultSearchEngine="true"
tooltiptext="&locationBar.tooltip;"
ontextcommand="return handleURLBarCommand(userAction);"
ontextrevert="return handleURLBarRevert();"
onmouseup="URLBarMouseupHandler(event);"
onblur="URLBarBlurHandler(event);">
<image id="page-proxy-button" allowevents="true"
ondraggesture="PageProxyDragGesture(event);"/>
<menupopup id="ubhist-popup" class="autocomplete-history-popup"
popupalign="topleft" popupanchor="bottomleft"
onpopupshowing="createUBHistoryMenu(event.target);"
oncommand="executeUrlBarHistoryCommand(event.target);"/>
</textbox>
</hbox>
</hbox>
<button class="button-toolbar-3 chromeclass-location" id="go-button" persist="hidden" hidden="true" label="&goButton.label;" oncommand="addToUrlbarHistory(); BrowserLoadURL();"
tooltiptext="&goButton.tooltip;"/>
<button class="button-toolbar-3 chromeclass-location" persist="hidden"
id="search-button" label="&searchButton.label;"
oncommand="OpenSearch('internet',false, document.getElementById('urlbar').value);"
tooltiptext="&searchButton.tooltip;"/>
</hbox>
<menubutton class="menubutton-dual top" id="print-button" persist="hidden" label="&printButton.label;"
crop="right" buttonaction="BrowserPrint()" tooltiptext="&printButton.tooltip;">
<menupopup id="printMenu" popupalign="topright" popupanchor="bottomright">
<menuitem label="&printCmd.label;" accesskey="&printCmd.accesskey;" oncommand="BrowserPrint()" default="true"/>
</menupopup>
</menubutton>
<hbox id="throbber-box" align="center">
<button id="navigator-throbber" oncommand="goClickThrobber('browser.throbber.url')" tooltiptext="&throbber.tooltip;"/>
</hbox>
</toolbar>
</toolbox>
<hbox flex="1" >
<vbox id="appcontent" flex="1"
ondragover="nsDragAndDrop.dragOver(event, contentAreaDNDObserver);"
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
<!-- this box is temporary, pending XBLified <browser> -->
<hbox id="browser" flex="1">
<browser id="content" type="content-primary" src="about:blank"
flex="1" tooltip="aHTMLTooltip"
context="contentAreaContextMenu"
onclick="return contentAreaClick(event);"
ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);"/>
</hbox>
</vbox>
</hbox>
</window>

Просмотреть файл

@ -373,8 +373,9 @@ Contributor(s): ______________________________________. -->
<vbox id="sidebar-box" class="chromeclass-extrachrome"/>
<splitter id="sidebar-splitter" class="chromeclass-extrachrome" />
<!-- we only need to handle |ondragdrop| because everything else is
taken care of by the builtin behavior inside the tabbrowser -->
<vbox id="appcontent" flex="1"
ondragover="nsDragAndDrop.dragOver(event, contentAreaDNDObserver);"
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
<!-- this box is temporary, pending XBLified <browser> -->
@ -382,14 +383,12 @@ Contributor(s): ______________________________________. -->
<tabbrowser id="content"
flex="1" contenttooltip="aHTMLTooltip"
contentcontextmenu="contentAreaContextMenu"
onclick="return contentAreaClick(event);"
ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);"/>
onclick="return contentAreaClick(event);"/>
</hbox>
</vbox>
</hbox>
<statusbar id="status-bar" class="chromeclass-status"
ondragover="nsDragAndDrop.dragOver(event, contentAreaDNDObserver);"
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
<statusbarpanel id="component-bar"/>
<statusbarpanel id="statusbar-display" label="&statusText.label;" flex="1"/>

Просмотреть файл

@ -168,8 +168,6 @@
</toolbox>
<vbox id="appcontent" flex="1"
ondragover="nsDragAndDrop.dragOver(event, contentAreaDNDObserver);"
ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);"
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
<browser id="content" type="content-primary" name="content" src="about:blank" flex="1"

Просмотреть файл

@ -39,171 +39,16 @@
*
* ***** END LICENSE BLOCK ***** */
/*
* Note that most of this routine has been moved into C++ in order to
* be available for all <browser> tags as well as gecko embedding. See
* mozilla/content/base/src/nsContentAreaDragDrop.cpp.
*
* Do not add any new fuctionality here other than what is needed for
* a standalone product.
*/
var contentAreaDNDObserver = {
onDragStart: function (aEvent, aXferData, aDragAction)
{
if (aEvent.getPreventDefault())
throw Components.results.NS_ERROR_FAILURE;
// only drag form elements by using the alt key,
// otherwise buttons and select widgets are hard to use
if ('form' in aEvent.target && !aEvent.altKey)
throw Components.results.NS_ERROR_FAILURE;
var draggedNode = aEvent.target;
// the resulting strings from the beginning of the drag
var titlestring = null;
var urlstring = null;
// htmlstring will be filled automatically if you fill urlstring
var htmlstring = null;
var isAnchor = false;
var domselection = aEvent.view.getSelection();
if (domselection && !domselection.isCollapsed &&
domselection.containsNode(draggedNode,false))
{
// track down the anchor node, if any
var firstAnchor = this.findFirstAnchor(domselection.anchorNode);
if (firstAnchor && domselection.containsNode(firstAnchor,false)) {
isAnchor = true;
urlstring = firstAnchor.href;
}
var privateSelection = domselection.QueryInterface(Components.interfaces.nsISelectionPrivate);
if (privateSelection)
{
// the window has a selection so we should grab that rather
// than looking for specific elements
htmlstring = privateSelection.toStringWithFormat("text/html", 128+256, 0);
titlestring = privateSelection.toStringWithFormat("text/plain", 0, 0);
} else {
titlestring = domselection.toString();
}
}
else
{
if (aEvent.altKey && findParentNode(draggedNode, 'a'))
return false;
var local_name = draggedNode.localName;
if (local_name) {
local_name.toUpperCase();
}
switch (local_name)
{
case 'AREA':
var areasrc = draggedNode.getAttribute("href");
// use alt text as the title of the area, if it's there
titlestring = draggedNode.getAttribute("alt");
urlstring = areasrc;
if (!titlestring)
titlestring = urlstring;
htmlstring = "<img src=\"" + urlstring + "\">";
break;
case 'IMG':
var imgsrc = draggedNode.getAttribute("src");
// var baseurl = window._content.location.href;
// need to do some stuff with the window._content.location
// (path?) to get base URL for image.
// use alt text as the title of the image, if it's there
titlestring = draggedNode.getAttribute("alt");
urlstring = imgsrc;
if (!titlestring)
titlestring = urlstring;
htmlstring = "<img src=\"" + urlstring + "\">";
// if the image is also a link, then re-wrap htmlstring in
// an anchor tag
linkNode = findParentNode(draggedNode, 'a');
if (linkNode) {
isAnchor = true;
urlstring = this.getAnchorUrl(linkNode);
htmlstring = this.createLinkText(urlstring, htmlstring);
}
break;
case 'A':
urlstring = this.getAnchorUrl(draggedNode);
titlestring = this.getNodeString(draggedNode);
// this causes d&d problems on windows -- see bug 68058
//aDragAction.action = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
isAnchor = true;
break;
default:
var linkNode = findParentNode(draggedNode, 'a');
if (linkNode) {
urlstring = this.getAnchorUrl(linkNode);
titlestring = this.getNodeString(linkNode);
// select node now!
// this shouldn't be fatal, and
// we should still do the drag if this fails
try {
this.normalizeSelection(linkNode, domselection);
} catch (ex) {
// non-fatal, so catch & ignore
}
isAnchor = true;
// this causes d&d problems on windows -- see bug 68058
//aDragAction.action = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
}
else {
// Need to throw to indicate that the drag target should not
// allow drags.
throw Components.results.NS_OK;
}
break;
}
}
// default text value is the URL
if (!titlestring) titlestring = urlstring;
// if we haven't constructed a html version, make one now
if (!htmlstring && urlstring)
htmlstring = this.createLinkText(urlstring, titlestring);
// now create the flavour lists
aXferData.data = new TransferData();
if (urlstring && isAnchor) {
aXferData.data.addDataForFlavour("text/x-moz-url", urlstring + "\n" + titlestring);
}
aXferData.data.addDataForFlavour("text/unicode", isAnchor ? urlstring : titlestring);
aXferData.data.addDataForFlavour("text/html", htmlstring);
// we use the url for text/unicode data if an anchor is being dragged, rather than
// the title text of the link or the alt text for an anchor image.
return true;
},
onDragOver: function (aEvent, aFlavour, aDragSession)
{
if (aEvent.getPreventDefault())
return;
// if the drag originated w/in this content area, bail
// early. This avoids loading a URL dragged from the content
// area into the very same content area (which is almost never
// the desired action). This code is a bit too simplistic and
// may have problems with nested frames, but that's not my
// problem ;)
if (aDragSession.sourceDocument == aEvent.view.document) {
aDragSession.canDrop = false;
return;
}
// this causes d&d problems on windows -- see bug 68058
//aDragSession.dragAction = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
},
onDrop: function (aEvent, aXferData, aDragSession)
{
var url = retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);
@ -220,6 +65,10 @@ var contentAreaDNDObserver = {
viewSource(url);
break;
}
// keep the event from being handled by the dragDrop listeners
// built-in to gecko if they happen to be above us.
aEvent.preventDefault();
},
getSupportedFlavours: function ()
@ -230,66 +79,6 @@ var contentAreaDNDObserver = {
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
return flavourSet;
},
createLinkText: function(url, text)
{
return "<a href=\"" + url + "\">" + text + "</a>";
},
findFirstAnchor: function(node)
{
if (!node) return null;
while (node) {
if (node.nodeType == Node.ELEMENT_NODE &&
node.localName.toLowerCase() == "a")
return node;
var childResult = this.findFirstAnchor(node.firstChild);
if (childResult)
return childResult;
node = node.nextSibling;
}
return null;
},
normalizeSelection: function(baseNode, domselection)
{
var parent = baseNode.parentNode;
if (!parent) return;
if (!domselection) return;
var nodelist = parent.childNodes;
var index;
for (index = 0; index<nodelist.length; index++)
{
if (nodelist.item(index) == baseNode)
break;
}
if (index >= nodelist.length) {
throw Components.results.NS_ERROR_FAILURE;
}
// now make the selection contain all of the parent's children up to
// the selected one
domselection.collapse(parent,index);
domselection.extend(parent,index+1);
},
getAnchorUrl: function(linkNode)
{
return linkNode.href || linkNode.name || null;
},
getNodeString: function(node)
{
// use a range to get the text-equivalent of the node
var range = document.createRange();
range.selectNode(node);
return range.toString();
}
};

Просмотреть файл

@ -246,7 +246,12 @@
</body>
</method>
<field name="mDragDropHandler">
null
</field>
<constructor>
<![CDATA[
if (!this.hasAttribute("disableHistory")) {
// wire up session history
// XXXdwh On a dynamic skin switch, we should be checking our box object to obtain
@ -258,7 +263,22 @@
this.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).globalHistory = globalHistory;
}
try {
this.mDragDropHandler = Components.classes["@mozilla.org:/content/content-area-dragdrop;1"]
.createInstance(Components.interfaces.nsIDragDropHandler);
if ( this.mDragDropHandler )
mDragDropHandler.hookupTo(this,null);
}
catch (x) { }
]]>
</constructor>
<destructor>
<![CDATA[
if ( this.mDragDropHandler )
mDragDropHandler.detach();
]]>
</destructor>
</implementation>
</binding>