gecko-dev/dom/xbl
Mike Conley 359f06fb50 Bug 1166351 - Prioritize getting the nsXBLDocumentInfo out of the bound document's nsBindingManager instead of the nsXULPrototypeCache. r=bobbyholley+313730
This is kind of a long story, stay with me on this.

In bug 990290, a WeakMap was added to any JS scope that loaded an XBL
binding. That WeakMap stored the JS prototypes that are injected into
a bound node's prototype chain.

When a binding is removed, we search the prototype chain for the
JS prototype that we'd added, and remove it.

The XUL prototype cache caches numerous things, including nsXBLDocumentInfo,
which we use to get at the nsXBLPrototypeBinding for a particular binding,
which is then used to generate the class object that's put into the WeakMap.

When the XUL prototype cache is flushed, that means that when a binding
is bound, its definition needs to be reloaded off of the disk. If, however,
there was a pre-existing instance of the binding already being used in a
document, now we were in a funny case.

We were in a funny case, because when attempting to remove a binding, we
would look up the nsXBLPrototypeBinding via the nsXBLDocumentInfo that's
being held within the nsXULPrototypeCache, find (or load off the disk) a
_new_ nsXBLDocumentInfo and generate a _new_ nsXBLPrototypeBinding that
did not match to the one that we'd already stored in the WeakMap. This
would mean that removal would go wrong, and things would break horribly.

This patch makes it so that we prioritize checking the nsBindingManager
for a document for the nsXBLDocumentInfo before checking the
global nsXULPrototypeCache. That way, even if the cache gets cleared,
if the binding was ever used in this document, it'll be in the
nsBindingManager, and we'll get the same nsXULProtoypeBinding that
we'd been using before, and sanity will prevail.

MozReview-Commit-ID: G8iLDbCPRAC

--HG--
extra : rebase_source : 4322965c0b7150b22454651ad7a9461ee76d766b
2016-05-16 19:07:26 -04:00
..
builtin
crashtests Bug 1268050 - Skip dom/xbl/crashtests/336744-1.html on Android, for frequent failures 2016-04-28 10:49:40 -06:00
test Bug 932517 - Treat let as a contextual keyword in sloppy mode and make it versionless. (r=jorendorff) 2015-10-27 20:13:17 -07:00
moz.build Bug 1272513 - Part 1: Suppress -Wshadow warnings-as-errors in some directories. r=glandium 2016-05-11 00:00:01 -07:00
nsBindingManager.cpp Bug 1268313: Part 7 - Move NS_NewRunnableMethod and friends to mozilla::NewRunnableMethod. r=froydnj 2016-05-05 01:45:00 -07:00
nsBindingManager.h Bug 1244074 - Part 4: Use StyleSheetHandle instead of concrete style sheet class in most places. r=dholbert 2016-02-24 18:01:12 +11:00
nsXBLBinding.cpp Bug 1166351 - Add an assertion to make sure that we use the correct cached XBL binding prototypes. r=bobbyholley+313730 2016-04-29 14:54:12 -04:00
nsXBLBinding.h Bug 1242214 - Rename JSPropertyDescriptor JS::PropertyDescriptor everywhere else. r=smaug 2016-01-28 11:28:04 +01:00
nsXBLContentSink.cpp Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat 2015-10-18 01:24:48 -04:00
nsXBLContentSink.h
nsXBLDocumentInfo.cpp Bug 1251655 - Remove support for JavaScript-DOM-class and JavaScript-DOM-interface. r=bz. 2016-02-14 15:59:48 +01:00
nsXBLDocumentInfo.h
nsXBLEventHandler.cpp Bug 1154183 part.1 Move shortcut/access key candidate list creators from nsContentUtils to WidgetKeyboardEvent r=smaug 2016-03-18 11:22:37 +09:00
nsXBLEventHandler.h
nsXBLMaybeCompiled.h Bug 1267699 - Move some public types to the right namespace; r=sfink 2016-04-26 09:18:48 -07:00
nsXBLProtoImpl.cpp Bug 1255817 part 2. Get rid of AutoJSAPI::OwnsErrorReporting and AutoJSAPI::TakeOwnershipOfErrorReporting. r=bholley 2016-03-23 11:44:54 -04:00
nsXBLProtoImpl.h Bug 1242214 - Rename JSPropertyDescriptor JS::PropertyDescriptor everywhere else. r=smaug 2016-01-28 11:28:04 +01:00
nsXBLProtoImplField.cpp Bug 1254847 part 3. Make AutoEntryScript always take ownership of error reporting. r=bholley 2016-03-09 19:02:03 -05:00
nsXBLProtoImplField.h
nsXBLProtoImplMember.h
nsXBLProtoImplMethod.cpp Bug 1254847 part 3. Make AutoEntryScript always take ownership of error reporting. r=bholley 2016-03-09 19:02:03 -05:00
nsXBLProtoImplMethod.h Bug 1217307 - Remove some unnecessary null checks in rest of dom/. r=njn 2015-11-19 09:13:49 +02:00
nsXBLProtoImplProperty.cpp
nsXBLProtoImplProperty.h
nsXBLPrototypeBinding.cpp Bug 1260871 - Remove do_GetAtom() and rename NS_NewAtom() as NS_Atomize(). r=erahm. 2016-03-29 10:09:43 +11:00
nsXBLPrototypeBinding.h Bug 1244074 - Part 4: Use StyleSheetHandle instead of concrete style sheet class in most places. r=dholbert 2016-02-24 18:01:12 +11:00
nsXBLPrototypeHandler.cpp Bug 1260871 - Remove do_GetAtom() and rename NS_NewAtom() as NS_Atomize(). r=erahm. 2016-03-29 10:09:43 +11:00
nsXBLPrototypeHandler.h Bug 1154183 part.7 Don't dispatch preceding keydown events of reserved keypress events on content in the default event group r=smaug 2016-03-22 15:05:25 +09:00
nsXBLPrototypeResources.cpp Bug 1247182 - Add an nsCSSRuleProcessor constructor that takes ownership of the given sheet array. r=birtles 2016-04-14 16:02:44 +10:00
nsXBLPrototypeResources.h Bug 1244074 - Part 4: Use StyleSheetHandle instead of concrete style sheet class in most places. r=dholbert 2016-02-24 18:01:12 +11:00
nsXBLResourceLoader.cpp Bug 1206961 - Use channel->AsyncOpen2() for imageLoader; Remove security checks from callsites (r=bz) 2016-04-27 19:41:13 +02:00
nsXBLResourceLoader.h Bug 1244074 - Part 4: Use StyleSheetHandle instead of concrete style sheet class in most places. r=dholbert 2016-02-24 18:01:12 +11:00
nsXBLSerialize.cpp
nsXBLSerialize.h
nsXBLService.cpp Bug 1166351 - Prioritize getting the nsXBLDocumentInfo out of the bound document's nsBindingManager instead of the nsXULPrototypeCache. r=bobbyholley+313730 2016-05-16 19:07:26 -04:00
nsXBLService.h
nsXBLWindowKeyHandler.cpp Bug 1253284 - Allow reserved attribute without command attribute r=masayuki 2016-05-06 18:38:44 +09:00
nsXBLWindowKeyHandler.h Bug 1257759 part.8 nsXBLWindowKeyHandler should handle eKeyDownOnPlugin and eKeyUpOnPlugin events only with reserved shortcut key handlers r=smaug 2016-04-23 02:12:54 +09:00
XBLChildrenElement.cpp Bug 1260871 - Remove do_GetAtom() and rename NS_NewAtom() as NS_Atomize(). r=erahm. 2016-03-29 10:09:43 +11:00
XBLChildrenElement.h