diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 3d47e927d..e684b0b00 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -905,8 +905,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. this._value = this.inputField.value; gBrowser.userTypedValue = this.value; this.valueIsTyped = true; - this.gotResultForCurrentQuery = false; - this.mController.handleText(); + // Only wait for a result when we are sure to get one. In some + // cases, like when pasting the same exact text, we may not fire + // a new search and we won't get a result. + if (this.mController.handleText()) { + this.gotResultForCurrentQuery = false; + } } this.resetActionType(); ]]> @@ -955,7 +959,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. // a backspace on the text value instead of removing the result. if (this.popup.selectedIndex == 0 && this.popup._isFirstResultHeuristic) { - return this.mController.handleText(); + this.mController.handleText(); + return false; } return this.mController.handleDelete(); ]]> diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 0fbc68c7c..ae3bda203 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -680,7 +680,7 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal, nsAutoCString targetScheme; nsresult rv = targetBaseURI->GetScheme(targetScheme); if (NS_FAILED(rv)) return rv; - + //-- Some callers do not allow loading javascript: if ((aFlags & nsIScriptSecurityManager::DISALLOW_SCRIPT) && targetScheme.EqualsLiteral("javascript")) @@ -688,6 +688,235 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal, return NS_ERROR_DOM_BAD_URI; } + // TenFourFox issue 469 + // determine if this is a script we want to block + if (mIsTenFourFoxAdBlockEnabled && + (targetScheme.EqualsLiteral("http") || targetScheme.EqualsLiteral("https"))) { + nsAutoCString hostname; + if (NS_SUCCEEDED(targetBaseURI->GetHost(hostname))) { + ToLowerCase(hostname); +#define BLOK(q) hostname.EqualsLiteral(q) + if (0 || + // This is used as a data source by a lot of UIs, + // so we shouldn't block it (e.g., nytimes). + // Probably also shouldn't block googletagmanager.com + // for the same reasons. + //BLOK("www.googletagservices.com") || + + // blocking zdbb.net seems to be problematic + // https://github.com/AdguardTeam/AdguardFilters/issues/1278 + + BLOK("c.amazon-adsystem.com") || + + BLOK("google-analytics.com") || + BLOK("www.google-analytics.com") || + BLOK("ssl.google-analytics.com") || + + BLOK("tpc.googlesyndication.com") || + BLOK("pagead.googlesyndication.com") || + BLOK("pagead2.googlesyndication.com") || + + BLOK("adservice.google.com") || + + BLOK("www.googleadservices.com") || + + BLOK("adrta.com") || + BLOK("p.adrta.com") || + BLOK("q.adrta.com") || + BLOK("cdn.adrta.com") || + BLOK("ipv6.adrta.com") || + + BLOK("ib.adnxs.com") || + BLOK("acdn.adnxs.com") || + BLOK("secure.adnxs.com") || + BLOK("yj-a.p.adnxs.com") || + BLOK("sharethrough.adnxs.com") || + + BLOK("c2.taboola.com") || + BLOK("nr.taboola.com") || + BLOK("cdn.taboola.com") || + BLOK("trc.taboola.com") || + + BLOK("b.scorecardresearch.com") || + BLOK("sb.scorecardresearch.com") || + + BLOK("ad.doubleclick.net") || + BLOK("static.doubleclick.net") || + BLOK("stats.g.doubleclick.net") || + BLOK("googleads.g.doubleclick.net") || + BLOK("securepubads.g.doubleclick.net") || + + BLOK("at.atwola.com") || + + BLOK("pixel.advertising.com") || + BLOK("dtm.advertising.com") || + + BLOK("sp.analytics.yahoo.com") || + BLOK("ads.yap.yahoo.com") || + + BLOK("cdn.gotraffic.net") || + + BLOK("cdn.rta247.com") || + + BLOK("widget.perfectmarket.com") || + + BLOK("cdn.doubleverify.com") || + BLOK("rtb0.doubleverify.com") || + BLOK("rtbcdn.doubleverify.com") || + + BLOK("cdn.flashtalking.com") || + BLOK("servedby.flashtalking.com") || + + BLOK("a.postrelease.com") || + BLOK("jadserve.postrelease.com") || + + BLOK("native.sharethrough.com") || + + BLOK("static.chartbeat.com") || + + BLOK("edge.quantserve.com") || + BLOK("secure.quantserve.com") || + + BLOK("rules.quantcount.com") || + + BLOK("api.viglink.com") || + BLOK("cdn.viglink.com") || + + BLOK("xcp.go.sonobi.com") || + + BLOK("s.ntv.io") || + + BLOK("cdn.segment.com") || + + BLOK("cdn-gl.imrworldwide.com") || + BLOK("secure-dcr.imrworldwide.com") || + + BLOK("labs-cdn.revcontent.com") || + BLOK("trends.revcontent.com") || + BLOK("cdn.revcontent.com") || + + BLOK("cas.criteo.com") || + BLOK("static.criteo.net") || + + BLOK("jsc.idealmedia.com") || + BLOK("servicer.idealmedia.com") || + + BLOK("js-agent.newrelic.com") || + BLOK("bam.nr-data.net") || + + BLOK("widgets.outbrain.com") || + BLOK("amplify.outbrain.com") || + + BLOK("cdn.krxd.net") || + BLOK("beacon.krxd.net") || + + BLOK("scdn.cxense.com") || + BLOK("rscdn.cxense.com") || + + BLOK("z.moatads.com") || + BLOK("s-jsonp.moatads.com") || + + BLOK("static.yieldmo.com") || + + BLOK("ads.rubiconproject.com") || + + BLOK("cdn.engine.4dsply.com") || + + BLOK("as-sec.casalemedia.com") || + + BLOK("loadm.exelator.com") || + + BLOK("sdk.streamrail.com") || + + BLOK("cdn.lockerdome.com") || + BLOK("cdn2.lockerdome.com") || + + BLOK("pi.pardot.com") || + + BLOK("js-sec.indexww.com") || + + BLOK("tags.tiqcdn.com") || + + BLOK("tag.bounceexchange.com") || + BLOK("api.bounceexchange.com") || + + BLOK("www.npttech.com") || + + BLOK("cdn.adsafeprotected.com") || + + BLOK("aka-cdn.adtechus.com") || + BLOK("adserver.adtechus.com") || + + BLOK("r.skimresources.com") || + BLOK("s.skimresources.com") || + BLOK("t.skimresources.com") || + + BLOK("contextual.media.net") || + + BLOK("edge.simplereach.com") || + + BLOK("js.adsrvr.org") || + + BLOK("script.crazyegg.com") || + + BLOK("launch.newsinc.com") || + + BLOK("c.go-mpulse.net") || + + BLOK("cdn5.userzoom.com") || + + BLOK("dx.steelhousemedia.com") || + BLOK("px.steelhousemedia.com") || + BLOK("ww.steelhousemedia.com") || + + BLOK("nexus.ensighten.com") || + + BLOK("cdn.mediavoice.com") || + BLOK("plugin.mediavoice.com") || + + BLOK("segment-data.zqtk.net") || + + BLOK("d.turn.com") || + + BLOK("i.yldbt.com") || + BLOK("cdn.yldbt.com") || + + BLOK("pippio.com") || + + BLOK("cdn.quantummetric.com") || + + BLOK("cdn.blueconic.net") || + + BLOK("www.zergnet.com") || + + BLOK("f.monetate.net") || + BLOK("sb.monetate.net") || + BLOK("se.monetate.net") || + + BLOK("tags.crwdcntrl.net") || + + BLOK("cdn.nsstatic.net") || + + BLOK("tags.bkrtx.com") || + + BLOK("yads.c.yimg.jp") || + BLOK("yjtag.yahoo.co.jp") || + BLOK("yads.yjtag.yahoo.co.jp") || + + BLOK("px-ya.ladsp.com") || + 0) { +#undef BLOK + // Yup. +#ifndef DEBUG + if (mIsTenFourFoxAdBlockLoggingEnabled) +#endif + fprintf(stderr, "Warning: TenFourFox basic adblock intercepted script from %s.\n", + hostname.get()); + return NS_ERROR_DOM_BAD_URI; + } + } + } + NS_NAMED_LITERAL_STRING(errorTag, "CheckLoadURIError"); bool reportErrors = !(aFlags & nsIScriptSecurityManager::DONT_REPORT_ERRORS); @@ -728,6 +957,7 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal, NS_ENSURE_SUCCESS(rv, rv); if (hasFlags) { +#if(0) // no B2G // Let apps load the whitelisted theme resources even if they don't // have the webapps-manage permission but have the themeable one. // Resources from the theme origin are also allowed to load from @@ -744,6 +974,7 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal, ? NS_OK : NS_ERROR_DOM_BAD_URI; } } +#endif // In this case, we allow opening only if the source and target URIS // are on the same domain, or the opening URI has the webapps // permision granted @@ -1246,6 +1477,7 @@ static const char* kObservedPrefs[] = { sJSEnabledPrefName, sFileOriginPolicyPrefName, "capability.policy.", + "tenfourfox.adblock.", nullptr }; @@ -1264,6 +1496,8 @@ nsScriptSecurityManager::Observe(nsISupports* aObject, const char* aTopic, nsScriptSecurityManager::nsScriptSecurityManager(void) : mPrefInitialized(false) , mIsJavaScriptEnabled(false) + , mIsTenFourFoxAdBlockEnabled(false) + , mIsTenFourFoxAdBlockLoggingEnabled(false) { static_assert(sizeof(intptr_t) == sizeof(void*), "intptr_t and void* have different lengths on this platform. " @@ -1400,6 +1634,10 @@ nsScriptSecurityManager::ScriptSecurityPrefChanged() Preferences::GetBool(sJSEnabledPrefName, mIsJavaScriptEnabled); sStrictFileOriginPolicy = Preferences::GetBool(sFileOriginPolicyPrefName, false); + mIsTenFourFoxAdBlockEnabled = + Preferences::GetBool("tenfourfox.adblock.enabled", mIsTenFourFoxAdBlockEnabled); + mIsTenFourFoxAdBlockLoggingEnabled = + Preferences::GetBool("tenfourfox.adblock.logging.enabled", mIsTenFourFoxAdBlockLoggingEnabled); // // Rebuild the set of principals for which we allow file:// URI loads. This diff --git a/caps/nsScriptSecurityManager.h b/caps/nsScriptSecurityManager.h index 361879dc5..41b68e137 100644 --- a/caps/nsScriptSecurityManager.h +++ b/caps/nsScriptSecurityManager.h @@ -123,6 +123,8 @@ private: nsCOMPtr mSystemPrincipal; bool mPrefInitialized; bool mIsJavaScriptEnabled; + bool mIsTenFourFoxAdBlockEnabled; + bool mIsTenFourFoxAdBlockLoggingEnabled; nsTArray> mFileURIWhitelist; // This machinery controls new-style domain policies. The old-style diff --git a/dom/base/IdleDeadline.cpp b/dom/base/IdleDeadline.cpp new file mode 100644 index 000000000..6e71b4930 --- /dev/null +++ b/dom/base/IdleDeadline.cpp @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include + +#include "mozilla/dom/IdleDeadline.h" +#include "mozilla/dom/IdleDeadlineBinding.h" +#include "nsPerformance.h" +#include "nsCOMPtr.h" +#include "nsCycleCollectionParticipant.h" +#include "nsDOMNavigationTiming.h" +#include "nsPIDOMWindow.h" + +namespace mozilla { +namespace dom { + +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IdleDeadline, mWindow) +NS_IMPL_CYCLE_COLLECTING_ADDREF(IdleDeadline) +NS_IMPL_CYCLE_COLLECTING_RELEASE(IdleDeadline) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IdleDeadline) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +IdleDeadline::IdleDeadline(nsPIDOMWindow* aWindow, bool aDidTimeout, + DOMHighResTimeStamp aDeadline) + : mWindow(aWindow) + , mDidTimeout(aDidTimeout) + , mDeadline(aDeadline) +{ +} + +IdleDeadline::~IdleDeadline() +{ +} + +JSObject* +IdleDeadline::WrapObject(JSContext* aCx, JS::Handle aGivenProto) +{ + return IdleDeadlineBinding::Wrap(aCx, this, aGivenProto); +} + +DOMHighResTimeStamp +IdleDeadline::TimeRemaining() +{ + if (mDidTimeout) { + return 0.0; + } + + RefPtr performance = mWindow->GetPerformance(); + if (!performance) { + // If there is no performance object the window is partially torn + // down, so we can safely say that there is no time remaining. + return 0.0; + } + + return std::max(mDeadline - performance->Now(), 0.0); +} + +bool +IdleDeadline::DidTimeout() const +{ + return mDidTimeout; +} + +} // namespace dom +} // namespace mozilla diff --git a/dom/base/IdleDeadline.h b/dom/base/IdleDeadline.h new file mode 100644 index 000000000..f8cc46c47 --- /dev/null +++ b/dom/base/IdleDeadline.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_IdleDeadline_h +#define mozilla_dom_IdleDeadline_h + +#include "js/TypeDecls.h" +#include "mozilla/Attributes.h" +#include "mozilla/ErrorResult.h" +#include "mozilla/Maybe.h" +#include "mozilla/dom/BindingDeclarations.h" +#include "nsCOMPtr.h" +#include "nsCycleCollectionParticipant.h" +#include "nsDOMNavigationTiming.h" +#include "nsWrapperCache.h" + +class nsPIDOMWindow; + +namespace mozilla { +namespace dom { + +class IdleDeadline final + : public nsISupports + , public nsWrapperCache +{ +public: + IdleDeadline(nsPIDOMWindow* aWindow, bool aDidTimeout, + DOMHighResTimeStamp aDeadline); + + nsPIDOMWindow* GetParentObject() const { return mWindow; } + + virtual JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + + DOMHighResTimeStamp TimeRemaining(); + bool DidTimeout() const; + + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IdleDeadline) + +private: + ~IdleDeadline(); + + nsCOMPtr mWindow; + const bool mDidTimeout; + const DOMHighResTimeStamp mDeadline; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_IdleDeadline_h diff --git a/dom/base/moz.build b/dom/base/moz.build index 3c5ba1d8d..afb21618d 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -182,6 +182,7 @@ EXPORTS.mozilla.dom += [ 'FileReader.h', 'FragmentOrElement.h', 'FromParser.h', + 'IdleDeadline.h', 'ImageEncoder.h', 'ImportManager.h', 'Link.h', @@ -247,6 +248,7 @@ UNIFIED_SOURCES += [ 'FileList.cpp', 'FileReader.cpp', 'FragmentOrElement.cpp', + 'IdleDeadline.cpp', 'ImageEncoder.cpp', 'ImportManager.cpp', 'Link.cpp', diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 179aeadf9..f8bf14a4f 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1143,6 +1143,7 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) mTimeoutsSuspendDepth(0), mFocusMethod(0), mSerial(0), + mIdleRequestCallbackCounter(1), #ifdef DEBUG mSetOpenerWindowCalled(false), #endif @@ -13858,3 +13859,35 @@ nsGlobalWindow::CreateImageBitmap(const ImageBitmapSource& aImage, { return ImageBitmap::Create(this, aImage, Some(gfx::IntRect(aSx, aSy, aSw, aSh)), aRv); } + +/* Support for requestIdleCallback() from TenFourFox issue 463 */ + +uint32_t +nsGlobalWindow::RequestIdleCallback(JSContext* aCx, + IdleRequestCallback& aCallback, + const IdleRequestOptions& aOptions, + ErrorResult& aError) +{ + MOZ_RELEASE_ASSERT(IsInnerWindow()); + AssertIsOnMainThread(); + + // uint32_t handle = ++mIdleRequestCallbackCounter; + + fprintf(stderr, "::RequestIdleCallback() is not yet implemented\n"); +#if DEBUG + MOZ_ASSERT(0); +#endif + return 0; // handle; +} + +void +nsGlobalWindow::CancelIdleCallback(uint32_t aHandle) +{ + MOZ_RELEASE_ASSERT(IsInnerWindow()); + + fprintf(stderr, "::CancelIdleCallback() is not yet implemented\n"); +#if DEBUG + MOZ_ASSERT(0); +#endif +} + diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 9b73d8fcb..41d1b65e4 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -118,6 +118,7 @@ class RequestOrUSVString; class Selection; class SpeechSynthesis; class WakeLock; +class IdleRequestCallback; #if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK) class WindowOrientationObserver; #endif @@ -1042,6 +1043,13 @@ public: int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback, mozilla::ErrorResult& aError); void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError); + + uint32_t RequestIdleCallback(JSContext* aCx, + mozilla::dom::IdleRequestCallback& aCallback, + const mozilla::dom::IdleRequestOptions& aOptions, + mozilla::ErrorResult& aError); + void CancelIdleCallback(uint32_t aHandle); + #ifdef MOZ_WEBSPEECH mozilla::dom::SpeechSynthesis* GetSpeechSynthesis(mozilla::ErrorResult& aError); @@ -1791,6 +1799,9 @@ protected: uint32_t mSerial; + // requestIdleCallback() support + uint32_t mIdleRequestCallbackCounter; + #ifdef DEBUG bool mSetOpenerWindowCalled; nsCOMPtr mLastOpenedURI; diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index e6323eada..c00f9c594 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1610,6 +1610,9 @@ DOMInterfaces = { 'binaryNames': { 'postMessage': 'postMessageMoz', }, + 'implicitJSContext': [ + 'requestIdleCallback' + ], }, 'WindowProxy': { diff --git a/dom/webidl/IdleDeadline.webidl b/dom/webidl/IdleDeadline.webidl new file mode 100644 index 000000000..afc834aea --- /dev/null +++ b/dom/webidl/IdleDeadline.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is: + * https://w3c.github.io/requestidlecallback/ + */ + +[Pref="dom.requestIdleCallback.enabled"] +interface IdleDeadline { + DOMHighResTimeStamp timeRemaining(); + readonly attribute boolean didTimeout; +}; + diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl index 704c65636..0446f25d8 100644 --- a/dom/webidl/Window.webidl +++ b/dom/webidl/Window.webidl @@ -494,3 +494,17 @@ interface ChromeWindow { Window implements ChromeWindow; Window implements GlobalFetch; Window implements ImageBitmapFactories; + +partial interface Window { + [Throws, Pref="dom.requestIdleCallback.enabled"] + unsigned long requestIdleCallback(IdleRequestCallback callback, + optional IdleRequestOptions options); + [Pref="dom.requestIdleCallback.enabled"] + void cancelIdleCallback(unsigned long handle); +}; + +dictionary IdleRequestOptions { + unsigned long timeout; +}; + +callback IdleRequestCallback = void (IdleDeadline deadline); diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index beae51d9c..cffef9c89 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -264,6 +264,7 @@ WEBIDL_FILES = [ 'IDBRequest.webidl', 'IDBTransaction.webidl', 'IDBVersionChangeEvent.webidl', + 'IdleDeadline.webidl', 'ImageBitmap.webidl', 'ImageCapture.webidl', 'ImageData.webidl', diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 5d04d9934..fd43ece78 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1050,6 +1050,9 @@ pref("dom.disable_window_open_feature.status", true); pref("dom.allow_scripts_to_close_windows", false); +// TenFourFox issue 463 +pref("dom.requestIdleCallback.enabled", false); + pref("dom.require_user_interaction_for_beforeunload", true); pref("dom.disable_open_during_load", false); @@ -5140,3 +5143,6 @@ pref("dom.mozKillSwitch.enabled", false); pref("toolkit.pageThumbs.screenSizeDivisor", 7); pref("toolkit.pageThumbs.minWidth", 0); pref("toolkit.pageThumbs.minHeight", 0); + +pref("tenfourfox.adblock.enabled", false); +pref("tenfourfox.adblock.logging.enabled", true); diff --git a/toolkit/components/autocomplete/nsAutoCompleteController.cpp b/toolkit/components/autocomplete/nsAutoCompleteController.cpp index a8c7ab474..51c356d9a 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteController.cpp +++ b/toolkit/components/autocomplete/nsAutoCompleteController.cpp @@ -180,8 +180,9 @@ nsAutoCompleteController::StartSearch(const nsAString &aSearchString) } NS_IMETHODIMP -nsAutoCompleteController::HandleText() +nsAutoCompleteController::HandleText(bool *_retval) { + *_retval = false; // Note: the events occur in the following order when IME is used. // 1. a compositionstart event(HandleStartComposition) // 2. some input events (HandleText), eCompositionState_Composing @@ -284,6 +285,7 @@ nsAutoCompleteController::HandleText() return NS_OK; } + *_retval = true; StartSearches(); return NS_OK; @@ -610,7 +612,8 @@ nsAutoCompleteController::HandleDelete(bool *_retval) input->GetPopupOpen(&isOpen); if (!isOpen || mRowCount <= 0) { // Nothing left to delete, proceed as normal - HandleText(); + bool unused = false; + HandleText(&unused); return NS_OK; } @@ -621,7 +624,8 @@ nsAutoCompleteController::HandleDelete(bool *_retval) popup->GetSelectedIndex(&index); if (index == -1) { // No row is selected in the list - HandleText(); + bool unused = false; + HandleText(&unused); return NS_OK; } @@ -1185,7 +1189,7 @@ nsAutoCompleteController::StartSearch(uint16_t aSearchType) nsAutoString searchParam; nsresult rv = input->GetSearchParam(searchParam); if (NS_FAILED(rv)) - return rv; + return rv; // FormFill expects the searchParam to only contain the input element id, // other consumers may have other expectations, so this modifies it only diff --git a/toolkit/components/autocomplete/nsIAutoCompleteController.idl b/toolkit/components/autocomplete/nsIAutoCompleteController.idl index 2e2405dcb..16b3950ef 100644 --- a/toolkit/components/autocomplete/nsIAutoCompleteController.idl +++ b/toolkit/components/autocomplete/nsIAutoCompleteController.idl @@ -37,7 +37,7 @@ interface nsIAutoCompleteController : nsISupports */ void startSearch(in AString searchString); - /* + /* * Stop all asynchronous searches */ void stopSearch(); @@ -54,8 +54,10 @@ interface nsIAutoCompleteController : nsISupports * it's not in composing mode. DOM compositionend event is not good * timing for calling handleText(). DOM input event immediately after * DOM compositionend event is the best timing to call this. + * + * @return whether this handler started a new search. */ - void handleText(); + boolean handleText(); /* * Notify the controller that the user wishes to enter the current text. If @@ -63,14 +65,16 @@ interface nsIAutoCompleteController : nsISupports * fill this value into the input field before continuing. If false, just * use the current value of the input field. * - * @return True if the controller wishes to prevent event propagation and default event + * @return Whether the controller wishes to prevent event propagation and + * default event. */ boolean handleEnter(in boolean aIsPopupSelection); /* * Notify the controller that the user wishes to revert autocomplete * - * @return True if the controller wishes to prevent event propagation and default event + * @return Whether the controller wishes to prevent event propagation and + * default event. */ boolean handleEscape(); @@ -90,7 +94,7 @@ interface nsIAutoCompleteController : nsISupports */ void handleEndComposition(); - /* + /* * Handle tab. Just closes up. */ void handleTab(); @@ -99,16 +103,19 @@ interface nsIAutoCompleteController : nsISupports * Notify the controller of the following key navigation events: * up, down, left, right, page up, page down * - * @return True if the controller wishes to prevent event propagation and default event + * @return Whether the controller wishes to prevent event propagation and + * default event */ boolean handleKeyNavigation(in unsigned long key); /* * Notify the controller that the user chose to delete the current * auto-complete result. + * + * @return Whether the controller removed a result item. */ boolean handleDelete(); - + /* * Get the value of the result at a given index in the last completed search */ diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index da126bf86..4a2ac698c 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -821,8 +821,9 @@ nsFormFillController::HandleEvent(nsIDOMEvent* aEvent) return KeyPress(aEvent); } if (type.EqualsLiteral("input")) { + bool unused = false; return (!mSuppressOnInput && mController && mFocusedInput) ? - mController->HandleText() : NS_OK; + mController->HandleText(&unused) : NS_OK; } if (type.EqualsLiteral("blur")) { if (mFocusedInput) @@ -932,6 +933,7 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent) return NS_ERROR_FAILURE; bool cancel = false; + bool unused = false; uint32_t k; keyEvent->GetKeyCode(&k); @@ -941,7 +943,7 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent) mController->HandleDelete(&cancel); break; case nsIDOMKeyEvent::DOM_VK_BACK_SPACE: - mController->HandleText(); + mController->HandleText(&unused); break; #else case nsIDOMKeyEvent::DOM_VK_BACK_SPACE: @@ -949,10 +951,11 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent) bool isShift = false; keyEvent->GetShiftKey(&isShift); - if (isShift) + if (isShift) { mController->HandleDelete(&cancel); - else - mController->HandleText(); + } else { + mController->HandleText(&unused); + } break; } @@ -1062,7 +1065,8 @@ nsFormFillController::MouseDown(nsIDOMEvent* aEvent) if (value.Length() > 0) { // Show the popup with a filtered result set mController->SetSearchString(EmptyString()); - mController->HandleText(); + bool unused = false; + mController->HandleText(&unused); } else { // Show the popup with the complete result set. Can't use HandleText() // because it doesn't display the popup if the input is blank. diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 97008e93e..16c4b2935 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -2978,6 +2978,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, // draw a focus ring if (eventState.HasState(NS_EVENT_STATE_FOCUS)) { NSGraphicsContext* savedContext = [NSGraphicsContext currentContext]; + if (MOZ_UNLIKELY(!savedContext)) break; // speculative fix issue 471 [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES]]; CGContextSaveGState(cgContext); NSSetFocusRingStyle(NSFocusRingOnly);