Skip to content

Commit

Permalink
Merge branch 'master' of github.com:google/pageloader
Browse files Browse the repository at this point in the history
* 'master' of github.com:google/pageloader:
  Fix strong mode warnings (#78)
  • Loading branch information
srawlins committed Aug 15, 2016
2 parents a45fb43 + a1d8114 commit 55de266
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
15 changes: 9 additions & 6 deletions dart/async/lib/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,25 @@ class _HtmlMouse implements PageLoaderMouse {

@override
Future down(MouseButton button,
{_ElementPageLoaderElement eventTarget, bool sync: true}) =>
{PageLoaderElement eventTarget, bool sync: true}) =>
loader.executeSynced(
() => dispatchEvent('mousedown', eventTarget, button), sync);

@override
Future moveTo(_ElementPageLoaderElement element, int xOffset, int yOffset,
{_ElementPageLoaderElement eventTarget, bool sync: true}) =>
Future moveTo(PageLoaderElement element, int xOffset, int yOffset,
{PageLoaderElement eventTarget, bool sync: true}) =>
loader.executeSynced(() {
clientX = (element.node.getBoundingClientRect().left + xOffset).ceil();
clientY = (element.node.getBoundingClientRect().top + yOffset).ceil();
if (element is _ElementPageLoaderElement) {
clientX =
(element.node.getBoundingClientRect().left + xOffset).ceil();
clientY = (element.node.getBoundingClientRect().top + yOffset).ceil();
}
return dispatchEvent('mousemove', eventTarget);
}, sync);

@override
Future up(MouseButton button,
{_ElementPageLoaderElement eventTarget, bool sync: true}) =>
{PageLoaderElement eventTarget, bool sync: true}) =>
loader.executeSynced(() => dispatchEvent('mouseup', eventTarget), sync);

int get pageX => window.pageXOffset + clientX;
Expand Down
13 changes: 6 additions & 7 deletions dart/async/lib/src/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class _ListFieldInfo extends _FieldInfo {
: super._(fieldName);

@override
Future<List> calculateFieldValue(PageLoaderElement context,
Future calculateFieldValue(PageLoaderElement context,
BasePageLoader loader, bool displayCheck) async {
if (!_displayCheck) {
displayCheck = false;
Expand Down Expand Up @@ -405,20 +405,19 @@ class _LazyFieldInfo extends _FieldInfo {
super._(impl._fieldName);

@override
calculateFieldValue(
Future calculateFieldValue(
PageLoaderElement context, BasePageLoader loader, bool displayCheck) {
return new _Lazy(
() => _impl.calculateFieldValue(context, loader, displayCheck));
return new Future.value(new _Lazy(
() => _impl.calculateFieldValue(context, loader, displayCheck)));
}
}

class _InjectedPageLoaderFieldInfo extends _FieldInfo {
_InjectedPageLoaderFieldInfo(Symbol fieldName) : super._(fieldName);

@override
calculateFieldValue(PageLoaderElement context, BasePageLoader loader,
bool displayCheck) =>
loader;
Future calculateFieldValue(PageLoaderElement context, BasePageLoader loader,
bool displayCheck) => new Future.value(loader);
}

Stream _getElements(PageLoaderElement context, Finder finder,
Expand Down
18 changes: 11 additions & 7 deletions dart/async/lib/webdriver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class _WebDriverMouse implements PageLoaderMouse {

@override
Future down(MouseButton button,
{_WebElementPageLoaderElement eventTarget, bool sync: true}) =>
{PageLoaderElement eventTarget, bool sync: true}) =>
loader.executeSynced(() {
if (eventTarget == null) {
return driver.mouse.down(button);
Expand All @@ -74,10 +74,10 @@ class _WebDriverMouse implements PageLoaderMouse {
}, sync);

@override
Future moveTo(_WebElementPageLoaderElement element, int xOffset, int yOffset,
{_WebElementPageLoaderElement eventTarget, bool sync: true}) =>
Future moveTo(PageLoaderElement element, int xOffset, int yOffset,
{PageLoaderElement eventTarget, bool sync: true}) =>
loader.executeSynced(() {
if (eventTarget == null) {
if (eventTarget == null && element is _WebElementPageLoaderElement) {
return driver.mouse.moveTo(
element: element.context, xOffset: xOffset, yOffset: yOffset);
}
Expand All @@ -86,20 +86,24 @@ class _WebDriverMouse implements PageLoaderMouse {

@override
Future up(MouseButton button,
{_WebElementPageLoaderElement eventTarget, bool sync: true}) =>
{PageLoaderElement eventTarget, bool sync: true}) =>
loader.executeSynced(() {
if (eventTarget == null) {
return driver.mouse.up(button);
}
return _fireEvent(eventTarget, 'mouseup', button);
}, sync);

Future _fireEvent(_WebElementPageLoaderElement eventTarget, String type,
Future _fireEvent(PageLoaderElement eventTarget, String type,
[MouseButton button]) =>
driver.execute(
"arguments[0].dispatchEvent(new MouseEvent(arguments[1], "
"{'button' : arguments[2]}));",
[eventTarget.context, type, button?.value]);
[
(eventTarget as _WebElementPageLoaderElement).context,
type,
button?.value
]);
}

abstract class WebDriverPageLoaderElement implements PageLoaderElement {
Expand Down

0 comments on commit 55de266

Please sign in to comment.