From f2462158fb5e0709b80e900b39e01d44d6ea0e5c Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Mon, 12 Jun 2017 16:48:27 +0300 Subject: [PATCH] Chrome devtools elements tab support for Android (#4351) * Enable chrome-devtools elemets tab * Trigger updates when property is chaned form native * Tslint fixes * Don't run dom-elemet tests in IOS * fix tests * Create package.json * Update package.json * domNode changed to field for performance --- apps/app/devtools-app/app.css | 13 + apps/app/devtools-app/app.ts | 6 + apps/app/devtools-app/main-page.ts | 36 ++ apps/app/devtools-app/main-page.xml | 29 ++ tests/app/debugger/dom-node-tests.ts | 334 ++++++++++++++++++ tests/app/testRunner.ts | 3 + tns-core-modules/debugger/css-agent.ts | 81 +++++ .../debugger/devtools-elements.ts | 97 +++++ tns-core-modules/debugger/dom-node.ts | 197 +++++++++++ .../ui/core/properties/properties.d.ts | 7 +- .../ui/core/properties/properties.ts | 55 +++ .../ui/core/view-base/view-base.d.ts | 10 +- .../ui/core/view-base/view-base.ts | 26 +- tns-core-modules/ui/frame/frame-common.ts | 4 + tns-core-modules/ui/slider/slider.d.ts | 4 +- .../ui/text-base/text-base.android.ts | 2 +- 16 files changed, 896 insertions(+), 8 deletions(-) create mode 100644 apps/app/devtools-app/app.css create mode 100644 apps/app/devtools-app/app.ts create mode 100644 apps/app/devtools-app/main-page.ts create mode 100644 apps/app/devtools-app/main-page.xml create mode 100644 tests/app/debugger/dom-node-tests.ts create mode 100644 tns-core-modules/debugger/css-agent.ts create mode 100644 tns-core-modules/debugger/devtools-elements.ts create mode 100644 tns-core-modules/debugger/dom-node.ts diff --git a/apps/app/devtools-app/app.css b/apps/app/devtools-app/app.css new file mode 100644 index 000000000..6836901c4 --- /dev/null +++ b/apps/app/devtools-app/app.css @@ -0,0 +1,13 @@ +.btn1 { + background-color: lightgreen; + color: coral; + font-size: 20; + font-family: monospace; +} + +.btn2 { + background-color: coral; + color: lightgreen; + font-size: 24; + font-family: serif; +} \ No newline at end of file diff --git a/apps/app/devtools-app/app.ts b/apps/app/devtools-app/app.ts new file mode 100644 index 000000000..d55ff757d --- /dev/null +++ b/apps/app/devtools-app/app.ts @@ -0,0 +1,6 @@ +import * as application from "tns-core-modules/application"; + +// Needed only for build infrastructure +application.setCssFileName("devtools-app/app.css"); + +application.start({ moduleName: "devtools-app/main-page" }); diff --git a/apps/app/devtools-app/main-page.ts b/apps/app/devtools-app/main-page.ts new file mode 100644 index 000000000..451163c42 --- /dev/null +++ b/apps/app/devtools-app/main-page.ts @@ -0,0 +1,36 @@ +import * as frame from "tns-core-modules/ui/frame"; +import { Label } from "tns-core-modules/ui/label"; +import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout"; +// import { DOMNode } from "tns-core-modules/debugger/dom-node"; + +export function print(args) { + // const node = new DOMNode(frame.topmost()); + // console.dir(node.toJSON()); + + // const btn = args.object.page.getViewById("btn"); + // btn.ensureDomNode(); + // console.dir(btn.domNode.getComputedProperties()); +} + +let i = 0; +export function add(args) { + const container = args.object.page.getViewById("container"); + const lbl = new Label(); + lbl.text = "label " + i++; + container.addChild(lbl); +} + +export function remove(args) { + const container = args.object.page.getViewById("container"); + const lbl = container.getChildAt(container.getChildrenCount() - 1); + container.removeChild(lbl); +} + +export function navigate() { + frame.topmost().navigate("gallery-app/main-page"); +} + +export function change(args){ + args.object.text = "hi " + Math.random(); + +} \ No newline at end of file diff --git a/apps/app/devtools-app/main-page.xml b/apps/app/devtools-app/main-page.xml new file mode 100644 index 000000000..ff0ad44f4 --- /dev/null +++ b/apps/app/devtools-app/main-page.xml @@ -0,0 +1,29 @@ + + + + +