Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Unified Diff: Source/core/html/HTMLImportStateResolver.cpp

Issue 141143006: [import] Cleanup: get rid of ad-hoc state machine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated to ToT Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLImportStateResolver.h ('k') | Source/core/html/HTMLImportsController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLImportStateResolver.cpp
diff --git a/Source/core/svg/SVGRectTearOff.cpp b/Source/core/html/HTMLImportStateResolver.cpp
similarity index 53%
copy from Source/core/svg/SVGRectTearOff.cpp
copy to Source/core/html/HTMLImportStateResolver.cpp
index 64a2538c50c2656117137d6d704a5122264ff0b2..9bc6fd351b160ef2da65dd7976531ff5b04f189d 100644
--- a/Source/core/svg/SVGRectTearOff.cpp
+++ b/Source/core/html/HTMLImportStateResolver.cpp
@@ -29,62 +29,57 @@
*/
#include "config.h"
-
-#include "core/svg/SVGRectTearOff.h"
-
-#include "bindings/v8/ExceptionState.h"
-#include "core/dom/ExceptionCode.h"
+#include "core/html/HTMLImportStateResolver.h"
namespace WebCore {
-SVGRectTearOff::SVGRectTearOff(PassRefPtr<SVGRect> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName)
- : NewSVGPropertyTearOff<SVGRect>(target, contextElement, propertyIsAnimVal, attributeName)
+inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import)
{
- ScriptWrappable::init(this);
+ if (!import->hasLoader())
+ return true;
+ if (!import->ownsLoader())
+ return false;
+ return !import->isStateReady();
}
-void SVGRectTearOff::setX(float f, ExceptionState& exceptionState)
+inline bool HTMLImportStateResolver::isBlockedFromCreatingDocument() const
{
- if (isImmutable()) {
- exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
- return;
+ // If any of its preceeding imports isn't ready, this import
+ // cannot start loading because such preceeding onces can include
+ // duplicating import that should wins over this.
+ for (const HTMLImport* ancestor = m_import; ancestor; ancestor = ancestor->parent()) {
+ if (ancestor->previous() && isBlockingFollowers(ancestor->previous()))
+ return true;
}
- target()->setX(f);
- commitChange();
+ return false;
}
-void SVGRectTearOff::setY(float f, ExceptionState& exceptionState)
+inline bool HTMLImportStateResolver::isBlockedFromRunningScript() const
{
- if (isImmutable()) {
- exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
- return;
+ for (HTMLImport* child = m_import->firstChild(); child; child = child->next()) {
+ if (child->isCreatedByParser() && isBlockingFollowers(child))
+ return true;
}
- target()->setY(f);
- commitChange();
+ return false;
}
-void SVGRectTearOff::setWidth(float f, ExceptionState& exceptionState)
+inline bool HTMLImportStateResolver::isActive() const
{
- if (isImmutable()) {
- exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
- return;
- }
-
- target()->setWidth(f);
- commitChange();
+ return !m_import->isDone();
}
-void SVGRectTearOff::setHeight(float f, ExceptionState& exceptionState)
+HTMLImport::State HTMLImportStateResolver::resolve() const
{
- if (isImmutable()) {
- exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
- return;
- }
-
- target()->setHeight(f);
- commitChange();
+ if (isBlockedFromCreatingDocument())
+ return HTMLImport::BlockedFromCreatingDocument;
+ if (isBlockedFromRunningScript())
+ return HTMLImport::BlockedFromRunningScript;
+ if (isActive())
+ return HTMLImport::Active;
+ return HTMLImport::Ready;
}
}
+
« no previous file with comments | « Source/core/html/HTMLImportStateResolver.h ('k') | Source/core/html/HTMLImportsController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698