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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLImportStateResolver.h ('k') | Source/core/html/HTMLImportsController.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32 #include "core/html/HTMLImportStateResolver.h"
33 #include "core/svg/SVGRectTearOff.h"
34
35 #include "bindings/v8/ExceptionState.h"
36 #include "core/dom/ExceptionCode.h"
37 33
38 namespace WebCore { 34 namespace WebCore {
39 35
40 SVGRectTearOff::SVGRectTearOff(PassRefPtr<SVGRect> target, SVGElement* contextEl ement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeNa me) 36 inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import)
41 : NewSVGPropertyTearOff<SVGRect>(target, contextElement, propertyIsAnimVal, attributeName)
42 { 37 {
43 ScriptWrappable::init(this); 38 if (!import->hasLoader())
39 return true;
40 if (!import->ownsLoader())
41 return false;
42 return !import->isStateReady();
44 } 43 }
45 44
46 void SVGRectTearOff::setX(float f, ExceptionState& exceptionState) 45 inline bool HTMLImportStateResolver::isBlockedFromCreatingDocument() const
47 { 46 {
48 if (isImmutable()) { 47 // If any of its preceeding imports isn't ready, this import
49 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 48 // cannot start loading because such preceeding onces can include
50 return; 49 // duplicating import that should wins over this.
50 for (const HTMLImport* ancestor = m_import; ancestor; ancestor = ancestor->p arent()) {
51 if (ancestor->previous() && isBlockingFollowers(ancestor->previous()))
52 return true;
51 } 53 }
52 54
53 target()->setX(f); 55 return false;
54 commitChange();
55 } 56 }
56 57
57 void SVGRectTearOff::setY(float f, ExceptionState& exceptionState) 58 inline bool HTMLImportStateResolver::isBlockedFromRunningScript() const
58 { 59 {
59 if (isImmutable()) { 60 for (HTMLImport* child = m_import->firstChild(); child; child = child->next( )) {
60 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 61 if (child->isCreatedByParser() && isBlockingFollowers(child))
61 return; 62 return true;
62 } 63 }
63 64
64 target()->setY(f); 65 return false;
65 commitChange();
66 } 66 }
67 67
68 void SVGRectTearOff::setWidth(float f, ExceptionState& exceptionState) 68 inline bool HTMLImportStateResolver::isActive() const
69 { 69 {
70 if (isImmutable()) { 70 return !m_import->isDone();
71 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only.");
72 return;
73 }
74
75 target()->setWidth(f);
76 commitChange();
77 } 71 }
78 72
79 void SVGRectTearOff::setHeight(float f, ExceptionState& exceptionState) 73 HTMLImport::State HTMLImportStateResolver::resolve() const
80 { 74 {
81 if (isImmutable()) { 75 if (isBlockedFromCreatingDocument())
82 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 76 return HTMLImport::BlockedFromCreatingDocument;
83 return; 77 if (isBlockedFromRunningScript())
84 } 78 return HTMLImport::BlockedFromRunningScript;
85 79 if (isActive())
86 target()->setHeight(f); 80 return HTMLImport::Active;
87 commitChange(); 81 return HTMLImport::Ready;
88 } 82 }
89 83
90 } 84 }
85
OLDNEW
« 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