This commit is contained in:
Doug Turner 2008-09-30 16:18:13 -07:00
commit 9d5f8695fc
11 changed files with 488 additions and 72 deletions

View File

@ -71,10 +71,10 @@
</xul:hbox>
<xul:hbox class="tabbrowser-strip" collapsed="true" tooltip="_child" context="_child"
anonid="strip"
ondraggesture="nsDragAndDrop.startDrag(event, this.parentNode.parentNode); event.stopPropagation();"
ondragover="nsDragAndDrop.dragOver(event, this.parentNode.parentNode); event.stopPropagation();"
ondragdrop="nsDragAndDrop.drop(event, this.parentNode.parentNode); event.stopPropagation();"
ondragexit="nsDragAndDrop.dragExit(event, this.parentNode.parentNode); event.stopPropagation();">
ondragstart="this.parentNode.parentNode._onDragStart(event); event.stopPropagation();"
ondragover="this.parentNode.parentNode._onDragOver(event); event.stopPropagation();"
ondrop="this.parentNode.parentNode._onDrop(event); event.stopPropagation();"
ondragleave="this.parentNode.parentNode._onDragLeave(event); event.stopPropagation();">
<xul:tooltip onpopupshowing="return this.parentNode.parentNode.parentNode.createTooltip(event);"/>
<xul:menupopup anonid="tabContextMenu" onpopupshowing="this.parentNode.parentNode.parentNode.updatePopupMenu(this);">
<xul:menuitem id="context_newTab" label="&newTab.label;" accesskey="&newTab.accesskey;"
@ -1778,55 +1778,91 @@
</getter>
</property>
<!-- Drag and drop observer API -->
<method name="onDragStart">
<method name="_onDragStart">
<parameter name="aEvent"/>
<parameter name="aXferData"/>
<parameter name="aDragAction"/>
<body>
<![CDATA[
if (aEvent.target.localName == "tab" &&
var target = aEvent.target;
if (target.localName == "tab" &&
aEvent.originalTarget.localName != "toolbarbutton") {
aXferData.data = new TransferData();
var dt = aEvent.dataTransfer;
dt.mozSetDataAt("application/x-moz-node", target, 0);
var URI = this.getBrowserForTab(aEvent.target).currentURI;
if (URI) {
aXferData.data.addDataForFlavour("text/x-moz-url", URI.spec + "\n" + aEvent.target.label);
aXferData.data.addDataForFlavour("text/unicode", URI.spec);
aXferData.data.addDataForFlavour("text/html", '<a href="' + URI.spec + '">' + aEvent.target.label + '</a>');
var spec = URI.spec;
dt.mozSetDataAt("text/x-moz-url", spec + "\n" + aEvent.target.label, 0);
dt.mozSetDataAt("text/uri-list", spec + "\n" + aEvent.target.label, 0);
dt.mozSetDataAt("text/plain", spec, 0);
dt.mozSetDataAt("text/html", '<a href="' + spec + '">' + aEvent.target.label + '</a>', 0);
} else {
aXferData.data.addDataForFlavour("text/unicode", "about:blank");
dt.mozSetDataAt("text/plain", "about:blank", 0);
}
}
]]>
</body>
</method>
<method name="canDrop">
<field name="mDragTime">0</field>
<field name="mDragOverDelay">350</field>
<field name="_supportedLinkDropTypes"><![CDATA[
["text/x-moz-url", "text/uri-list", "text/plain", "application/x-moz-file"]
]]></field>
<method name="_setEffectAllowedForDataTransfer">
<parameter name="aEvent"/>
<parameter name="aDragSession"/>
<body>
<![CDATA[
if (aDragSession.sourceNode &&
aDragSession.sourceNode.parentNode == this.mTabContainer &&
(aEvent.screenX >= aDragSession.sourceNode.boxObject.screenX &&
aEvent.screenX <= (aDragSession.sourceNode.boxObject.screenX +
aDragSession.sourceNode.boxObject.width)))
return false;
return true;
var dt = aEvent.dataTransfer;
// Disallow dropping multiple items
if (dt.mozItemCount > 1)
return dt.effectAllowed = "none";
var types = dt.mozTypesAt(0);
var sourceNode = null;
// tabs are always added as the first type
if (types[0] == "application/x-moz-node") {
var sourceNode = dt.mozGetDataAt("application/x-moz-node", 0);
if (sourceNode instanceof XULElement &&
sourceNode.localName == "tab" &&
(sourceNode.parentNode == this.mTabContainer ||
(sourceNode.ownerDocument.defaultView instanceof ChromeWindow &&
sourceNode.ownerDocument.documentElement.getAttribute("windowtype") == "navigator:browser"))) {
if (sourceNode.parentNode == this.mTabContainer &&
(aEvent.screenX >= sourceNode.boxObject.screenX &&
aEvent.screenX <= (sourceNode.boxObject.screenX +
sourceNode.boxObject.width))) {
return dt.effectAllowed = "none";
}
return dt.effectAllowed = "copyMove";
}
}
for (var i=0; i < this._supportedLinkDropTypes.length; i++) {
if (types.contains(this._supportedLinkDropTypes[i])) {
// Here we need to to do this manually
return dt.effectAllowed = dt.dropEffect = "link";
}
}
return dt.effectAllowed = "none";
]]>
</body>
</method>
<field name="mDragTime">0</field>
<field name="mDragOverDelay">350</field>
<method name="onDragOver">
<method name="_onDragOver">
<parameter name="aEvent"/>
<parameter name="aFlavour"/>
<parameter name="aDragSession"/>
<body>
<![CDATA[
var effects = this._setEffectAllowedForDataTransfer(aEvent);
var ib = this.mTabDropIndicatorBar;
if (effects == "none") {
ib.collapsed = "true";
return;
}
aEvent.preventDefault();
var tabStrip = this.mTabContainer.mTabstrip;
var ltr = (window.getComputedStyle(this.parentNode, null).direction
== "ltr");
@ -1851,9 +1887,7 @@
tabStrip.scrollByPixels((ltr ? 1 : -1) * pixelsToScroll);
}
var isTabDrag = (aDragSession.sourceNode &&
aDragSession.sourceNode.parentNode == this.mTabContainer);
if (!isTabDrag && aEvent.target.localName == "tab") {
if (effects == "link" && aEvent.target.localName == "tab") {
if (!this.mDragTime)
this.mDragTime = Date.now();
if (Date.now() >= this.mDragTime + this.mDragOverDelay)
@ -1912,27 +1946,27 @@
ind.style.MozMarginStart = newMargin + 'px';
ib.collapsed = !aDragSession.canDrop;
ib.collapsed = false;
]]>
</body>
</method>
<method name="onDrop">
<method name="_onDrop">
<parameter name="aEvent"/>
<parameter name="aXferData"/>
<parameter name="aDragSession"/>
<body>
<![CDATA[
var isCopy = aEvent.dataTransfer.dropEffect == "copy";
var dt = aEvent.dataTransfer;
var dropEffect = dt.dropEffect;
var draggedTab;
if (aDragSession.sourceNode && aDragSession.sourceNode.localName == "tab" &&
(aDragSession.sourceNode.parentNode == this.mTabContainer ||
aDragSession.sourceNode.ownerDocument.defaultView instanceof ChromeWindow &&
aDragSession.sourceNode.ownerDocument.documentElement.getAttribute("windowtype") == "navigator:browser"))
draggedTab = aDragSession.sourceNode;
if (draggedTab && (isCopy || draggedTab.parentNode == this.mTabContainer)) {
if (dropEffect != "link") { // copy or move
draggedTab = dt.mozGetDataAt("application/x-moz-node", 0);
NS_ASSERT(draggedTab && draggedTab.localName == "tab",
"copy or move action without a tab");
}
if (draggedTab && (dropEffect == "copy" || draggedTab.parentNode == this.mTabContainer)) {
var newIndex = this.getNewIndex(aEvent);
if (isCopy) {
if (dropEffect == "copy") {
// copy the dropped tab (wherever it's from)
var newTab = this.duplicateTab(draggedTab);
this.moveTabTo(newTab, newIndex);
@ -1970,7 +2004,20 @@
this.setTabTitle(newTab);
}
else {
var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);
var url;
for (var i=0; i < this._supportedLinkDropTypes.length; i++) {
let dataType = this._supportedLinkDropTypes[i];
// uri-list: for now, support dropping of the first URL
// only
var isURLList = dataType == "text/uri-list";
let urlData = isURLList ?
dt.mozGetDataAt("URL", 0) : dt.mozGetDataAt(dataType, 0);
if (urlData) {
url = transferUtils.retrieveURLFromData(urlData, isURLList ? "text/plain" : dataType);
break;
}
}
NS_ASSERT(url, "In the drop event, at least one mime-type should match our supported types");
// valid urls don't contain spaces ' '; if we have a space it isn't a valid url.
// Also disallow dropping javascript: or data: urls--bail out
@ -1978,7 +2025,12 @@
/^\s*(javascript|data):/.test(url))
return;
nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url);
// XXXmano: temporary fix until dragDropSecurityCheck make the
// drag-session an optional paramter
var dragService = Cc["@mozilla.org/widget/dragservice;1"].
getService(Ci.nsIDragService);
var dragSession = dragService.getCurrentSession();
nsDragAndDrop.dragDropSecurityCheck(aEvent, dragSession, url);
var bgLoad = true;
try {
@ -1989,7 +2041,7 @@
if (aEvent.shiftKey)
bgLoad = !bgLoad;
if (document.getBindingParent(aEvent.originalTarget).localName != "tab" || isCopy) {
if (document.getBindingParent(aEvent.originalTarget).localName != "tab" || dropEffect == "copy") {
// We're adding a new tab.
newIndex = this.getNewIndex(aEvent);
newTab = this.loadOneTab(getShortcutOrURI(url), null, null, null, bgLoad, false);
@ -2011,16 +2063,14 @@
</body>
</method>
<method name="onDragExit">
<method name="_onDragLeave">
<parameter name="aEvent"/>
<parameter name="aDragSession"/>
<body>
<![CDATA[
this.mDragTime = 0;
if (aDragSession.sourceNode &&
aDragSession.sourceNode.parentNode == this.mTabContainer &&
aDragSession.canDrop) {
var dropEffect = aEvent.dataTransfer.dropEffect;
if (dropEffect == "move" || dropEffect == "copy") {
var target = aEvent.relatedTarget;
while (target && target != this.mStrip)
target = target.parentNode;
@ -2032,18 +2082,6 @@
</body>
</method>
<method name="getSupportedFlavours">
<body>
<![CDATA[
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("text/unicode");
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
return flavourSet;
]]>
</body>
</method>
<method name="moveTabTo">
<parameter name="aTab"/>
<parameter name="aIndex"/>

View File

@ -144,7 +144,6 @@ struct CSSPropertyAlias {
};
static const CSSPropertyAlias gAliases[] = {
{ "-moz-opacity", eCSSProperty_opacity },
{ "-moz-outline", eCSSProperty_outline },
{ "-moz-outline-color", eCSSProperty_outline_color },
{ "-moz-outline-style", eCSSProperty_outline_style },

View File

@ -643,15 +643,17 @@ PRBool imgLoader::PutIntoCache(nsIURI *key, imgCacheEntry *entry)
if (!tmpRequest->IsReusable(cacheId))
return PR_FALSE;
if (gCacheTracker)
gCacheTracker->MarkUsed(tmpCacheEntry);
// If it already exists, and we're putting the same key into the cache, we
// should remove the old version.
PR_LOG(gImgLog, PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Replacing cached element", nsnull));
return PR_TRUE;
RemoveFromCache(key);
} else {
PR_LOG(gImgLog, PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Element NOT already in the cache", nsnull));
}
PR_LOG(gImgLog, PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Element NOT already in the cache", nsnull));
if (!cache.Put(spec, entry))
return PR_FALSE;

View File

@ -89,6 +89,11 @@ ifeq ($(OS_ARCH),WINNT)
../system/win32/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
endif
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
SHARED_LIBRARY_LIBS += \
../system/mac/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
endif
LOCAL_INCLUDES = \
-I$(srcdir)/../base/src \
-I$(srcdir)/../dns/src \
@ -106,6 +111,10 @@ ifeq ($(OS_ARCH),WINNT)
LOCAL_INCLUDES += -I$(srcdir)/../system/win32
endif
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
LOCAL_INCLUDES += -I$(srcdir)/../system/mac
endif
ifdef NECKO_COOKIES
SHARED_LIBRARY_LIBS += \
../cookie/src/$(LIB_PREFIX)neckocookie_s.$(LIB_SUFFIX) \
@ -128,6 +137,7 @@ EXTRA_DSO_LDOPTS = \
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
EXTRA_DSO_LDOPTS += \
-framework SystemConfiguration \
$(TK_LIBS) \
$(NULL)
endif

View File

@ -272,6 +272,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsIDNService, Init)
#if defined(XP_WIN) && !defined(WINCE)
#include "nsNotifyAddrListener.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init)
#elif defined(MOZ_WIDGET_COCOA)
#include "nsNetworkLinkService.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetworkLinkService, Init)
#endif
///////////////////////////////////////////////////////////////////////////////
@ -1110,6 +1113,12 @@ static const nsModuleComponentInfo gNetModuleInfo[] = {
NS_NETWORK_LINK_SERVICE_CONTRACTID,
nsNotifyAddrListenerConstructor
},
#elif defined(MOZ_WIDGET_COCOA)
{ NS_NETWORK_LINK_SERVICE_CLASSNAME,
NS_NETWORK_LINK_SERVICE_CID,
NS_NETWORK_LINK_SERVICE_CONTRACTID,
nsNetworkLinkServiceConstructor
},
#endif
};

View File

@ -48,4 +48,8 @@ ifeq ($(OS_ARCH),WINNT)
DIRS += win32
endif
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
DIRS += mac
endif
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,57 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla 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/MPL/
#
# 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
# Mozilla Corporation
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# 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 MPL, 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 MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = necko
LIBRARY_NAME = neckosystem_s
LIBXUL_LIBRARY = 1
REQUIRES = xpcom \
string \
$(NULL)
FORCE_STATIC_LIB = 1
CMMSRCS += nsNetworkLinkService.mm
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,74 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dave Camp <dcamp@mozilla.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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSNETWORKLINKSERVICEMAC_H_
#define NSNETWORKLINKSERVICEMAC_H_
#include "nsINetworkLinkService.h"
#include "nsIObserver.h"
#include <SystemConfiguration/SCNetworkReachability.h>
class nsNetworkLinkService : public nsINetworkLinkService,
public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSINETWORKLINKSERVICE
NS_DECL_NSIOBSERVER
nsNetworkLinkService();
virtual ~nsNetworkLinkService();
nsresult Init();
nsresult Shutdown();
private:
PRPackedBool mLinkUp;
PRPackedBool mStatusKnown;
SCNetworkReachabilityRef mReachability;
CFRunLoopRef mCFRunLoop;
void UpdateReachability();
void SendEvent();
static void ReachabilityChanged(SCNetworkReachabilityRef target,
SCNetworkConnectionFlags flags,
void *info);
};
#endif /* NSNETWORKLINKSERVICEMAC_H_ */

View File

@ -0,0 +1,221 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dave Camp <dcamp@mozilla.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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsNetworkLinkService.h"
#include "nsCOMPtr.h"
#include "nsIObserverService.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#import <Cocoa/Cocoa.h>
#import <netinet/in.h>
NS_IMPL_ISUPPORTS2(nsNetworkLinkService,
nsINetworkLinkService,
nsIObserver)
nsNetworkLinkService::nsNetworkLinkService()
: mLinkUp(PR_TRUE)
, mStatusKnown(PR_FALSE)
, mReachability(NULL)
, mCFRunLoop(NULL)
{
}
nsNetworkLinkService::~nsNetworkLinkService()
{
}
NS_IMETHODIMP
nsNetworkLinkService::GetIsLinkUp(PRBool *aIsUp)
{
*aIsUp = mLinkUp;
return NS_OK;
}
NS_IMETHODIMP
nsNetworkLinkService::GetLinkStatusKnown(PRBool *aIsUp)
{
*aIsUp = mStatusKnown;
return NS_OK;
}
NS_IMETHODIMP
nsNetworkLinkService::Observe(nsISupports *subject,
const char *topic,
const PRUnichar *data)
{
if (!strcmp(topic, "xpcom-shutdown")) {
Shutdown();
}
return NS_OK;
}
nsresult
nsNetworkLinkService::Init(void)
{
nsresult rv;
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = observerService->AddObserver(this, "xpcom-shutdown", PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
// If the network reachability API can reach 0.0.0.0 without
// requiring a connection, there is a network interface available.
struct sockaddr_in addr;
bzero(&addr, sizeof(addr));
addr.sin_len = sizeof(addr);
addr.sin_family = AF_INET;
mReachability =
::SCNetworkReachabilityCreateWithAddress(NULL,
(struct sockaddr *)&addr);
if (!mReachability) {
return NS_ERROR_NOT_AVAILABLE;
}
SCNetworkReachabilityContext context = {0, this, NULL, NULL, NULL};
if (!::SCNetworkReachabilitySetCallback(mReachability,
ReachabilityChanged,
&context)) {
NS_WARNING("SCNetworkReachabilitySetCallback failed.");
::CFRelease(mReachability);
mReachability = NULL;
return NS_ERROR_NOT_AVAILABLE;
}
// Get the current run loop. This service is initialized at startup,
// so we shouldn't run in to any problems with modal dialog run loops.
mCFRunLoop = [[NSRunLoop currentRunLoop] getCFRunLoop];
if (!mCFRunLoop) {
NS_WARNING("Could not get current run loop.");
::CFRelease(mReachability);
mReachability = NULL;
return NS_ERROR_NOT_AVAILABLE;
}
::CFRetain(mCFRunLoop);
if (!::SCNetworkReachabilityScheduleWithRunLoop(mReachability, mCFRunLoop,
kCFRunLoopDefaultMode)) {
NS_WARNING("SCNetworkReachabilityScheduleWIthRunLoop failed.");
::CFRelease(mReachability);
mReachability = NULL;
::CFRelease(mCFRunLoop);
mCFRunLoop = NULL;
return NS_ERROR_NOT_AVAILABLE;
}
UpdateReachability();
return NS_OK;
}
nsresult
nsNetworkLinkService::Shutdown()
{
if (!::SCNetworkReachabilityUnscheduleFromRunLoop(mReachability,
mCFRunLoop,
kCFRunLoopDefaultMode)) {
NS_WARNING("SCNetworkReachabilityUnscheduleFromRunLoop failed.");
}
::CFRelease(mReachability);
mReachability = NULL;
::CFRelease(mCFRunLoop);
mCFRunLoop = NULL;
return NS_OK;
}
void
nsNetworkLinkService::UpdateReachability()
{
if (!mReachability) {
return;
}
SCNetworkConnectionFlags flags;
if (!::SCNetworkReachabilityGetFlags(mReachability, &flags) ||
flags == 0) {
mStatusKnown = PR_FALSE;
return;
}
PRBool reachable = (flags & kSCNetworkFlagsReachable) != 0;
PRBool needsConnection = (flags & kSCNetworkFlagsConnectionRequired) != 0;
mLinkUp = (reachable && !needsConnection);
mStatusKnown = PR_TRUE;
}
void
nsNetworkLinkService::SendEvent()
{
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
if (!observerService)
return;
const char *event;
if (!mStatusKnown)
event = NS_NETWORK_LINK_DATA_UNKNOWN;
else
event = mLinkUp ? NS_NETWORK_LINK_DATA_UP
: NS_NETWORK_LINK_DATA_DOWN;
observerService->NotifyObservers(static_cast<nsINetworkLinkService*>(this),
NS_NETWORK_LINK_TOPIC,
NS_ConvertASCIItoUTF16(event).get());
}
/* static */
void
nsNetworkLinkService::ReachabilityChanged(SCNetworkReachabilityRef target,
SCNetworkConnectionFlags flags,
void *info)
{
nsNetworkLinkService *service =
static_cast<nsNetworkLinkService*>(info);
service->UpdateReachability();
service->SendEvent();
}

View File

@ -294,6 +294,7 @@ var transferUtils = {
{
switch (flavour) {
case "text/unicode":
case "text/plain":
return aData.replace(/^\s+|\s+$/g, "");
case "text/x-moz-url":
return ((aData instanceof Components.interfaces.nsISupportsString) ? aData.toString() : aData).split("\n")[0];

View File

@ -2278,6 +2278,7 @@ NSEvent* gLastDragEvent = nil;
{
nsTSMManager::OnDestroyView(self);
mGeckoChild = nsnull;
mWindow = nil;
// Just in case we're destroyed abruptly and missed the draggingExited
// or performDragOperation message.
NS_IF_RELEASE(mDragService);