Bug 1176829 - Remove custom elements base element queue. r=smaug

This commit is contained in:
William Chen 2015-09-17 14:49:00 -07:00
parent 42d370d9a9
commit c346835aca
3 changed files with 6 additions and 57 deletions

View File

@ -5230,7 +5230,6 @@ nsContentUtils::LeaveMicroTask()
MOZ_ASSERT(NS_IsMainThread());
if (--sMicroTaskLevel == 0) {
PerformMainThreadMicroTaskCheckpoint();
nsDocument::ProcessBaseElementQueue();
}
}

View File

@ -5895,29 +5895,6 @@ nsDocument::RegisterUnresolvedElement(Element* aElement, nsIAtom* aTypeName)
return NS_OK;
}
namespace {
class ProcessStackRunner final : public nsIRunnable
{
~ProcessStackRunner() {}
public:
explicit ProcessStackRunner(bool aIsBaseQueue = false)
: mIsBaseQueue(aIsBaseQueue)
{
}
NS_DECL_ISUPPORTS
NS_IMETHOD Run() override
{
nsDocument::ProcessTopElementQueue(mIsBaseQueue);
return NS_OK;
}
bool mIsBaseQueue;
};
NS_IMPL_ISUPPORTS(ProcessStackRunner, nsIRunnable);
} // namespace
void
nsDocument::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType,
Element* aCustomElement,
@ -6019,10 +5996,7 @@ nsDocument::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType,
// A new element queue needs to be pushed if the queue at the
// top of the stack is associated with another microtask level.
// Don't push a queue for the level 0 microtask (base element queue)
// because we don't want to process the queue until the
// microtask checkpoint.
bool shouldPushElementQueue = nsContentUtils::MicroTaskLevel() > 0 &&
bool shouldPushElementQueue =
(!lastData || lastData->mAssociatedMicroTask <
static_cast<int32_t>(nsContentUtils::MicroTaskLevel()));
@ -6045,39 +6019,22 @@ nsDocument::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType,
// should be invoked prior to returning control back to script.
// Create a script runner to process the top of the processing
// stack as soon as it is safe to run script.
nsContentUtils::AddScriptRunner(new ProcessStackRunner());
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableFunction(&nsDocument::ProcessTopElementQueue);
nsContentUtils::AddScriptRunner(runnable);
}
}
}
// static
void
nsDocument::ProcessBaseElementQueue()
{
// Prevent re-entrance. Also, if a microtask checkpoint is reached
// and there is no processing stack to process, then we are done.
if (sProcessingBaseElementQueue || !sProcessingStack) {
return;
}
MOZ_ASSERT(nsContentUtils::MicroTaskLevel() == 0);
sProcessingBaseElementQueue = true;
nsContentUtils::AddScriptRunner(new ProcessStackRunner(true));
}
// static
void
nsDocument::ProcessTopElementQueue(bool aIsBaseQueue)
nsDocument::ProcessTopElementQueue()
{
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
nsTArray<nsRefPtr<CustomElementData>>& stack = *sProcessingStack;
uint32_t firstQueue = stack.LastIndexOf((CustomElementData*) nullptr);
if (aIsBaseQueue && firstQueue != 0) {
return;
}
for (uint32_t i = firstQueue + 1; i < stack.Length(); ++i) {
// Callback queue may have already been processed in an earlier
// element queue or in an element queue that was popped
@ -6095,7 +6052,6 @@ nsDocument::ProcessTopElementQueue(bool aIsBaseQueue)
} else {
// Don't pop sentinel for base element queue.
stack.SetLength(1);
sProcessingBaseElementQueue = false;
}
}

View File

@ -1303,7 +1303,7 @@ public:
mozilla::dom::LifecycleCallbackArgs* aArgs = nullptr,
mozilla::dom::CustomElementDefinition* aDefinition = nullptr) override;
static void ProcessTopElementQueue(bool aIsBaseQueue = false);
static void ProcessTopElementQueue();
void GetCustomPrototype(int32_t aNamespaceID,
nsIAtom* aAtom,
@ -1600,15 +1600,9 @@ private:
// queue in the stack is the base element queue.
static mozilla::Maybe<nsTArray<nsRefPtr<mozilla::dom::CustomElementData>>> sProcessingStack;
// Flag to prevent re-entrance into base element queue as described in the
// custom elements speicification.
static bool sProcessingBaseElementQueue;
static bool CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp);
public:
static void ProcessBaseElementQueue();
// Enqueue created callback or register upgrade candidate for
// newly created custom elements, possibly extending an existing type.
// ex. <x-button>, <button is="x-button> (type extension)