diff --git a/engine/core/dom/Document.idl b/engine/core/dom/Document.idl index 86274037cf7..a111f003b44 100644 --- a/engine/core/dom/Document.idl +++ b/engine/core/dom/Document.idl @@ -29,7 +29,7 @@ typedef (CanvasRenderingContext2D or WebGLRenderingContext) RenderingContext; [CustomElementCallbacks, RaisesException] Element createElement(DOMString tagName); DocumentFragment createDocumentFragment(); - [CustomElementCallbacks, RaisesException, TypeChecking=Interface] Node importNode(Node node, optional boolean deep = false); + [CustomElementCallbacks, RaisesException, TypeChecking=Interface] Node importNode(Node node, [Named] optional boolean deep = false); Element getElementById(DOMString elementId); diff --git a/engine/core/html/parser/HTMLDocumentParser.cpp b/engine/core/html/parser/HTMLDocumentParser.cpp index 08087fcb885..9f2ab19ed6d 100644 --- a/engine/core/html/parser/HTMLDocumentParser.cpp +++ b/engine/core/html/parser/HTMLDocumentParser.cpp @@ -394,11 +394,12 @@ bool HTMLDocumentParser::isWaitingForScripts() const void HTMLDocumentParser::resumeAfterWaitingForImports() { - RefPtr protect(this); - ASSERT(!isWaitingForScripts()); + if (isWaitingForScripts()) + return; if (m_pendingChunks.isEmpty()) return; ASSERT(m_haveBackgroundParser); + RefPtr protect(this); pumpPendingChunks(); } diff --git a/examples/data/cities.sky b/examples/data/cities.sky index 32b8bfedcf6..f1bf499c180 100644 --- a/examples/data/cities.sky +++ b/examples/data/cities.sky @@ -4,7 +4,7 @@ // found in the LICENSE file. --> - - - - diff --git a/examples/example-scrollable/example-scrollable.sky b/examples/example-scrollable/example-scrollable.sky new file mode 100644 index 00000000000..c6f27b88215 --- /dev/null +++ b/examples/example-scrollable/example-scrollable.sky @@ -0,0 +1,38 @@ + + + + + + + + + diff --git a/examples/example-scrollable/index.sky b/examples/example-scrollable/index.sky new file mode 100644 index 00000000000..f71a788e97e --- /dev/null +++ b/examples/example-scrollable/index.sky @@ -0,0 +1,10 @@ +#!mojo mojo:sky_viewer + + + + + diff --git a/framework/fling-curve.dart b/framework/fling-curve.dart new file mode 100644 index 00000000000..6dce624dda8 --- /dev/null +++ b/framework/fling-curve.dart @@ -0,0 +1,51 @@ +// Copyright 2015 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. + +import "dart:math" as math; + +const double _kDefaultAlpha = -5707.62; +const double _kDefaultBeta = 172.0; +const double _kDefaultGamma = 3.7; + +double _positionAtTime(double t) { + return kDefaultAlpha * math.exp(-kDefaultGamma * t) - kDefaultBeta * t - kDefaultAlpha; +} + +double _velocityAtTime(double t) { + return -kDefaultAlpha * kDefaultGamma * math.exp(-kDefaultGamma * t) - kDefaultBeta; +} + +double _timeAtVelocity(double v) { + return -math.log((v + kDefaultBeta) / (-kDefaultAlpha * kDefaultGamma)) / kDefaultGamma; +} + +final double _kMaxVelocity = _velocityAtTime(0.0); +final double _kCurveDuration = _timeAtVelocity(0.0); + +class FlingCurve { + double _timeOffset; + double _positionOffset; + double _startTime; + double _previousPosition; + double _direction; + + FlingCurve(double velocity, double startTime) { + double startingVelocity = math.min(_kMaxVelocity, velocity.abs()); + _timeOffset = _velocityAtTime(startingVelocity); + _positionOffset = _positionAtTime(_timeOffset); + _startTime = startTime / 1000.0; + _previousPosition = 0.0; + _direction = velocity.sign; + } + + double update(double timeStamp) { + double t = timeStamp / 1000.0 - _startTime + _timeOffset; + if (t >= _kCurveDuration) + return 0.0; + double position = _positionAtTime(t) - _positionOffset; + double positionDelta = position - _previousPosition; + _previousPosition = position; + return _direction * math.max(0.0, positionDelta); + } +} diff --git a/framework/fling-curve.sky b/framework/fling-curve.sky deleted file mode 100644 index 1c13908b4f9..00000000000 --- a/framework/fling-curve.sky +++ /dev/null @@ -1,47 +0,0 @@ - - diff --git a/framework/sky-element.sky b/framework/sky-element.sky index 8b04f79a504..2fdc62ad65d 100644 --- a/framework/sky-element.sky +++ b/framework/sky-element.sky @@ -47,8 +47,8 @@ abstract class SkyElement extends Element { var registration = _registery[tagName]; if (registration.template != null) { ShadowRoot shadow = ensureShadowRoot(); - var tree = registration.template.content.cloneNode(deep:true); - shadow.appendChild(tree); + Node content = registration.template.content; + shadow.appendChild(document.importNode(content, deep: true)); shadowRootReady(); } } diff --git a/framework/sky-scrollable.sky b/framework/sky-scrollable.sky index 9e369196a98..e0292d1d1ca 100644 --- a/framework/sky-scrollable.sky +++ b/framework/sky-scrollable.sky @@ -3,17 +3,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. --> - - + - +