mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
We shouldn't need pendingScripts in ScriptRunner since we should never be trying to run scripts when we're not ready to run them. However this wasn't completely true in the case of imports there was code to have us break before any start tag after an <import> was seen, but it was subtly wrong in that it it would include the start-tag it was trying to break before in the chunk it sent to the main thread. This didn't run out to be the problem I was facing, but I fixed it anyway. The problem which was actually preventing me from removing pendingScripts was adding a check inside didRecieveParsedChunk... to check if imports were pending and add the chunk to the list of pending chunks. I also renamed m_speculations to m_pendingChunks since these chunks are never speculative anymore. We can't test the off-by-one import-breaking code with our current system, but it would be trivial to test with a self-closing custom element if/when we ever add custom elements back to the system. R=abarth@chromium.org BUG= Review URL: https://codereview.chromium.org/934083002
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/config.h"
|
|
#include "sky/engine/core/html/parser/HTMLScriptRunner.h"
|
|
|
|
#include "sky/engine/core/app/AbstractModule.h"
|
|
#include "sky/engine/core/dom/Document.h"
|
|
#include "sky/engine/core/dom/Microtask.h"
|
|
#include "sky/engine/core/frame/LocalFrame.h"
|
|
#include "sky/engine/core/html/HTMLScriptElement.h"
|
|
#include "sky/engine/core/script/dart_controller.h"
|
|
|
|
namespace blink {
|
|
|
|
HTMLScriptRunner::HTMLScriptRunner()
|
|
: m_isExecutingScript(false)
|
|
{
|
|
}
|
|
|
|
HTMLScriptRunner::~HTMLScriptRunner()
|
|
{
|
|
}
|
|
|
|
void HTMLScriptRunner::runScript(PassRefPtr<HTMLScriptElement> element, TextPosition textPosition)
|
|
{
|
|
ASSERT(element->document().haveImportsLoaded());
|
|
Microtask::performCheckpoint();
|
|
|
|
Document& sourceDocument = element->document();
|
|
String source = element->textContent();
|
|
|
|
RefPtr<Document> contextDocument = sourceDocument.contextDocument().get();
|
|
if (!contextDocument)
|
|
return;
|
|
|
|
LocalFrame* frame = contextDocument->frame();
|
|
if (!frame)
|
|
return;
|
|
|
|
ASSERT(!m_isExecutingScript);
|
|
TemporaryChange<bool> executingScript(m_isExecutingScript, true);
|
|
|
|
ASSERT(sourceDocument.module());
|
|
frame->dart().LoadModule(sourceDocument.module(), source, textPosition);
|
|
}
|
|
|
|
}
|