Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
f37aafd4
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f37aafd4
编写于
6月 06, 2017
作者:
S
Sarah Zakarias
提交者:
GitHub
6月 06, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add setInitialRoute on FlutterView. (#3727)
上级
62c6f657
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
32 addition
and
27 deletion
+32
-27
lib/ui/hooks.dart
lib/ui/hooks.dart
+0
-18
lib/ui/window.dart
lib/ui/window.dart
+2
-2
lib/ui/window/window.cc
lib/ui/window/window.cc
+6
-0
lib/ui/window/window.h
lib/ui/window/window.h
+1
-0
runtime/runtime_controller.cc
runtime/runtime_controller.cc
+4
-0
runtime/runtime_controller.h
runtime/runtime_controller.h
+1
-0
runtime/runtime_delegate.h
runtime/runtime_delegate.h
+1
-0
shell/common/engine.cc
shell/common/engine.cc
+11
-6
shell/common/engine.h
shell/common/engine.h
+2
-1
shell/platform/android/io/flutter/view/FlutterView.java
shell/platform/android/io/flutter/view/FlutterView.java
+4
-0
未找到文件。
lib/ui/hooks.dart
浏览文件 @
f37aafd4
...
...
@@ -40,25 +40,7 @@ void _updateSemanticsEnabled(bool enabled) {
window
.
onSemanticsEnabledChanged
();
}
void
_handleNavigationMessage
(
ByteData
data
)
{
if
(
window
.
_defaultRouteName
!=
null
)
return
;
try
{
final
dynamic
message
=
_decodeJSON
(
_decodeUTF8
(
data
));
final
dynamic
method
=
message
[
'method'
];
if
(
method
!=
'pushRoute'
)
return
;
final
dynamic
args
=
message
[
'args'
];
window
.
_defaultRouteName
=
args
[
0
];
}
catch
(
e
)
{
// We ignore any exception and just let the message be dispatched as usual.
}
}
void
_dispatchPlatformMessage
(
String
name
,
ByteData
data
,
int
responseId
)
{
if
(
name
==
'flutter/navigation'
)
_handleNavigationMessage
(
data
);
if
(
window
.
onPlatformMessage
!=
null
)
{
window
.
onPlatformMessage
(
name
,
data
,
(
ByteData
responseData
)
{
window
.
_respondToPlatformMessage
(
responseId
,
responseData
);
...
...
lib/ui/window.dart
浏览文件 @
f37aafd4
...
...
@@ -275,8 +275,8 @@ class Window {
/// The route or path that the operating system requested when the application
/// was launched.
String
get
defaultRouteName
=>
_defaultRouteName
;
String
_defaultRouteName
;
String
get
defaultRouteName
=>
_defaultRouteName
()
;
String
_defaultRouteName
()
native
"Window_defaultRouteName"
;
/// Requests that, at the next appropriate opportunity, the [onBeginFrame]
/// and [onDrawFrame] callbacks be invoked.
...
...
lib/ui/window/window.cc
浏览文件 @
f37aafd4
...
...
@@ -39,6 +39,11 @@ Dart_Handle ToByteData(const std::vector<uint8_t>& buffer) {
return
data_handle
;
}
void
DefaultRouteName
(
Dart_NativeArguments
args
)
{
std
::
string
routeName
=
UIDartState
::
Current
()
->
window
()
->
client
()
->
DefaultRouteName
();
Dart_SetReturnValue
(
args
,
StdStringToDart
(
routeName
));
}
void
ScheduleFrame
(
Dart_NativeArguments
args
)
{
UIDartState
::
Current
()
->
window
()
->
client
()
->
ScheduleFrame
();
}
...
...
@@ -253,6 +258,7 @@ void Window::CompletePlatformMessageResponse(int response_id,
void
Window
::
RegisterNatives
(
tonic
::
DartLibraryNatives
*
natives
)
{
natives
->
Register
({
{
"Window_defaultRouteName"
,
DefaultRouteName
,
1
,
true
},
{
"Window_scheduleFrame"
,
ScheduleFrame
,
1
,
true
},
{
"Window_sendPlatformMessage"
,
_SendPlatformMessage
,
4
,
true
},
{
"Window_respondToPlatformMessage"
,
_RespondToPlatformMessage
,
3
,
true
},
...
...
lib/ui/window/window.h
浏览文件 @
f37aafd4
...
...
@@ -23,6 +23,7 @@ class Scene;
class
WindowClient
{
public:
virtual
std
::
string
DefaultRouteName
()
=
0
;
virtual
void
ScheduleFrame
()
=
0
;
virtual
void
Render
(
Scene
*
scene
)
=
0
;
virtual
void
UpdateSemantics
(
SemanticsUpdate
*
update
)
=
0
;
...
...
runtime/runtime_controller.cc
浏览文件 @
f37aafd4
...
...
@@ -98,6 +98,10 @@ Window* RuntimeController::GetWindow() {
return
dart_controller_
->
dart_state
()
->
window
();
}
std
::
string
RuntimeController
::
DefaultRouteName
()
{
return
client_
->
DefaultRouteName
();
}
void
RuntimeController
::
ScheduleFrame
()
{
client_
->
ScheduleFrame
();
}
...
...
runtime/runtime_controller.h
浏览文件 @
f37aafd4
...
...
@@ -52,6 +52,7 @@ class RuntimeController : public WindowClient, public IsolateClient {
Window
*
GetWindow
();
std
::
string
DefaultRouteName
()
override
;
void
ScheduleFrame
()
override
;
void
Render
(
Scene
*
scene
)
override
;
void
UpdateSemantics
(
SemanticsUpdate
*
update
)
override
;
...
...
runtime/runtime_delegate.h
浏览文件 @
f37aafd4
...
...
@@ -17,6 +17,7 @@ namespace blink {
class
RuntimeDelegate
{
public:
virtual
std
::
string
DefaultRouteName
()
=
0
;
virtual
void
ScheduleFrame
()
=
0
;
virtual
void
Render
(
std
::
unique_ptr
<
flow
::
LayerTree
>
layer_tree
)
=
0
;
virtual
void
UpdateSemantics
(
std
::
vector
<
SemanticsNode
>
update
)
=
0
;
...
...
shell/common/engine.cc
浏览文件 @
f37aafd4
...
...
@@ -310,7 +310,7 @@ void Engine::DispatchPlatformMessage(
return
;
}
// If there's no runtime_, we
need to buffer some navigation messages
.
// If there's no runtime_, we
may still need to set the initial route
.
if
(
message
->
channel
()
==
kNavigationChannel
)
HandleNavigationPlatformMessage
(
std
::
move
(
message
));
}
...
...
@@ -341,10 +341,10 @@ bool Engine::HandleNavigationPlatformMessage(
return
false
;
auto
root
=
document
.
GetObject
();
auto
method
=
root
.
FindMember
(
"method"
);
if
(
method
==
root
.
MemberEnd
()
||
method
->
value
!=
"push
Route"
)
if
(
method
->
value
!=
"setInitial
Route"
)
return
false
;
pending_push_route_message_
=
std
::
move
(
message
);
auto
route
=
root
.
FindMember
(
"args"
);
initial_route_
=
std
::
move
(
route
->
value
.
GetString
()
);
return
true
;
}
...
...
@@ -427,8 +427,6 @@ void Engine::ConfigureRuntime(const std::string& script_uri) {
runtime_
->
SetViewportMetrics
(
viewport_metrics_
);
runtime_
->
SetLocale
(
language_code_
,
country_code_
);
runtime_
->
SetSemanticsEnabled
(
semantics_enabled_
);
if
(
pending_push_route_message_
)
runtime_
->
DispatchPlatformMessage
(
std
::
move
(
pending_push_route_message_
));
}
void
Engine
::
DidCreateMainIsolate
(
Dart_Isolate
isolate
)
{
...
...
@@ -450,6 +448,13 @@ void Engine::StartAnimatorIfPossible() {
animator_
->
Start
();
}
std
::
string
Engine
::
DefaultRouteName
()
{
if
(
!
initial_route_
.
empty
())
{
return
initial_route_
;
}
return
"/"
;
}
void
Engine
::
ScheduleFrame
()
{
animator_
->
RequestFrame
();
}
...
...
shell/common/engine.h
浏览文件 @
f37aafd4
...
...
@@ -71,6 +71,7 @@ class Engine : public blink::RuntimeDelegate {
private:
// RuntimeDelegate methods:
std
::
string
DefaultRouteName
()
override
;
void
ScheduleFrame
()
override
;
void
Render
(
std
::
unique_ptr
<
flow
::
LayerTree
>
layer_tree
)
override
;
void
UpdateSemantics
(
std
::
vector
<
blink
::
SemanticsNode
>
update
)
override
;
...
...
@@ -98,7 +99,7 @@ class Engine : public blink::RuntimeDelegate {
std
::
unique_ptr
<
Animator
>
animator_
;
std
::
unique_ptr
<
blink
::
RuntimeController
>
runtime_
;
tonic
::
DartErrorHandleType
load_script_error_
;
ftl
::
RefPtr
<
blink
::
PlatformMessage
>
pending_push_route_messag
e_
;
std
::
string
initial_rout
e_
;
blink
::
ViewportMetrics
viewport_metrics_
;
std
::
string
language_code_
;
std
::
string
country_code_
;
...
...
shell/platform/android/io/flutter/view/FlutterView.java
浏览文件 @
f37aafd4
...
...
@@ -241,6 +241,10 @@ public class FlutterView extends SurfaceView
mFlutterSystemChannel
.
send
(
message
);
}
public
void
setInitialRoute
(
String
route
)
{
mFlutterNavigationChannel
.
invokeMethod
(
"setInitialRoute"
,
route
);
}
public
void
pushRoute
(
String
route
)
{
mFlutterNavigationChannel
.
invokeMethod
(
"pushRoute"
,
route
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录