Skip to content

Commit

Permalink
Merge branch 'main' into font_weight
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli authored Nov 16, 2023
2 parents d083f20 + 63c75d7 commit ee3ffc7
Show file tree
Hide file tree
Showing 146 changed files with 2,213 additions and 1,894 deletions.
9 changes: 5 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CMakeLists.txt @ilikethese @etkmao
/framework/ios/ @wwwcg @ruifanyuan

# framework: voltron
/framework/voltron/ @lvfen @skindhu
/framework/voltron/ @lvfen @henryjin0511

# dom: others
/dom/ @etkmao @ilikethese
Expand All @@ -57,17 +57,17 @@ CMakeLists.txt @ilikethese @etkmao
/renderer/tdf/ios/ @wwwcg @ruifanyuan

# renderer: voltron
/renderer/voltron/ @lvfen @skindhu
/renderer/voltron/ @lvfen @henryjin0511

# module: vfs
/modules/vfs/ @etkmao @ilikethese
/modules/vfs/android/ @siguangli @iPel
/modules/vfs/android/**/src/main/cpp/ @etkmao @ilikethese
/modules/vfs/ios/ @wwwcg @ruifanyuan
/modules/vfs/voltron/ @lvfen @skindhu
/modules/vfs/voltron/ @lvfen @henryjin0511

# module: voltron
/modules/voltron/ @lvfen @skindhu
/modules/voltron/ @lvfen @henryjin0511

# module: android
/modules/android/ @siguangli @iPel
Expand All @@ -90,6 +90,7 @@ CMakeLists.txt @ilikethese @etkmao
/framework/examples/android-demo/res/ @zealotchen0
/framework/examples/ios-demo/ @wwwcg @ruifanyuan
/framework/examples/ios-demo/res/ @zealotchen0
/framework/examples/voltron-demo/ @henryjin0511

# doc: pages
/*.md @zealotchen0
Expand Down
2 changes: 0 additions & 2 deletions docs/api/hippy-react/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ import icon from './qb_icon_new.png';
| 参数 | 描述 | 类型 | 支持平台 |
| --------------------- | ------------------------------------------------------------ | ----------------------------------------------------------- | -------- |
| bounces | 是否开启回弹效果,默认 `true`, Android `2.14.1` 版本后支持该属性,老版本使用 `overScrollEnabled` | `boolean` | `Android``iOS``Voltron` |
| overScrollEnabled | 是否开启回弹效果,默认 `true`,3.0 版本后即将废弃 | `boolean` | `Android、Voltron` |
| getRowKey | 指定一个函数,在其中返回对应条目的 Key 值,详见 [React 官文](//reactjs.org/docs/lists-and-keys.html) | `(index: number) => any` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| getRowStyle | 设置 `ListViewItem` 容器的样式。当设置了 `horizontal=true` 启用横向 `ListView` 时,需显式设置 `ListViewItem` 宽度 | `(index: number) => styleObject` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| getHeaderStyle | 设置 `PullHeader` 容器的样式。当设置了 `horizontal=true` 启用横向 `ListView` 时,需显式设置 `PullHeader` 宽度。`最低支持版本2.14.1` | `() => styleObject` | `Android、iOS、Voltron` |
Expand Down Expand Up @@ -176,7 +175,6 @@ import icon from './qb_icon_new.png';

| 参数 | 描述 | 类型 | 支持平台 |
| --------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- |
| animated | 弹出时是否需要带动画 | `boolean` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| animationType | 动画效果 | `enum (none, slide, fade, slide_fade)` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| supportedOrientations | 支持屏幕翻转方向 | `enum (portrait, portrait-upside-down, landscape, landscape-left, landscape-right)[]` | `iOS` |
| immersionStatusBar | 是否是沉浸式状态栏。`default: false` | `boolean` | `Android、Voltron` |
Expand Down
8 changes: 4 additions & 4 deletions docs/api/hippy-react/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ AsyncStorage 是一个简单的、异步的、持久化的 Key-Value 存储系
### AsyncStorage.multiGet

`(key: string[]) => Promise<[key: string, value: value][]>` 一次性用多个 key 值的数组去批量请求缓存数据,返回值将在回调函数以键值对的二维数组形式返回。
`(key: string[]) => Promise<[key: string, value: string][]>` 一次性用多个 key 值的数组去批量请求缓存数据,返回值将在回调函数以键值对的二维数组形式返回。

> - key: string[] - 需要获取值的目标 key 数组
Expand All @@ -171,9 +171,9 @@ AsyncStorage 是一个简单的、异步的、持久化的 Key-Value 存储系
### AsyncStorage.multiSet

`(keyValuePairs: [key: string, value: value][]) => void` 调用这个函数可以批量存储键值对对象。
`(keyValuePairs: [key: string, value: string][]) => void` 调用这个函数可以批量存储键值对对象。

> - keyValuePairs: [key: string, value: value][] - 需要设置的储键值二维数组
> - keyValuePairs: [key: string, value: string][] - 需要设置的储键值二维数组
### AsyncStorage.removeItem

Expand Down Expand Up @@ -256,7 +256,7 @@ AsyncStorage 是一个简单的、异步的、持久化的 Key-Value 存储系
`(target: 'window' | 'screen') => { height: number, width: number, scale: number, statusBarHeight, navigatorBarHeight }` Hippy Root View 尺寸或者屏幕尺寸。

> - target: 'window' | 'screen' - 指定丈量 Hippy Root View 或者屏幕尺寸。
> - Android 特别说明:因为历史遗留问题,screen 下的 statusBarHeight 是按实际像素算的,window 下经过修正已经是 dp 单位。
> - Android 特别说明:因为历史遗留问题,2.x 及以下版本的 screen 下的 statusBarHeight 是按物理像素算的,window 下经过修正已经是 dp 单位;3.0 及以上版本 screen 和 window 均为 dp 单位。
> - navigatorBarHeight: Android 底部 navigatorBar 高度;最低支持版本 2.3.4
---
Expand Down
7 changes: 3 additions & 4 deletions docs/api/hippy-vue/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,13 @@ Hippy 的重点功能,高性能的可复用列表组件,在终端侧会被
| --------------------- | ------------------------------------------------------------ | ----------------------------------------------------------- | -------- |
| horizontal | 指定 `ul` 是否采用横向布局。`default: undefined` 纵向布局,Android `2.14.1` 版本后可设置 `false` 显式固定纵向布局;iOS 暂不支持横向 `ul` | `boolean \| undefined` | `Android、Voltron` |
| initialContentOffset | 初始位移值。在列表初始化时即可指定滚动距离,避免初始化后再通过 scrollTo 系列方法产生的闪动。Android 在 `2.8.0` 版本后支持 | `number` | `Android、iOS、Web-Renderer、Voltron` |
| bounces | 是否开启回弹效果,默认 `true` | `boolean` | `iOS、Voltron` |
| overScrollEnabled | 是否开启回弹效果,默认 `true` | `boolean` | `Android、Voltron` |
| rowShouldSticky | 设置 `ul` 是否需要开启悬停效果能力,与 `li``sticky` 配合使用。 `default: false` | `boolean` | `Android、iOS、Web-Renderer、Voltron`
| bounces | 是否开启回弹效果,默认 `true`, Android `2.14.1` 版本后支持该属性,老版本使用 `overScrollEnabled` | `boolean` | `Android、iOS、Voltron` |
| rowShouldSticky | 设置 `ul` 是否需要开启悬停效果能力,与 `li``sticky` 配合使用。 `default: false` | `boolean` | `Android、iOS、Web-Renderer、Voltron`|
| scrollEnabled | 滑动是否开启。`default: true` | `boolean` | `Android、iOS、Web-Renderer、Voltron` |
| scrollEventThrottle | 指定滑动事件的回调频率,传入数值指定了多少毫秒(ms)组件会调用一次 `onScroll` 回调事件,默认 200ms | `number` | `Android、iOS、Web-Renderer、Voltron` |
| showScrollIndicator | 是否显示滚动条。`default: true` | `boolean` | `iOS、Voltron` |
| preloadItemNumber | 指定当列表滚动至倒数第几行时触发 `endReached` 回调。 | `number` | `Android、iOS、Web-Renderer、Voltron` |
| exposureEventEnabled | Android 曝光能力启用开关,如果要使用 `appear``disappear` 相关事件,Android 需要设置该开关(iOS无需设置), `default: true` | `boolean` | `Android、Voltron`
| exposureEventEnabled | Android 曝光能力启用开关,如果要使用 `appear``disappear` 相关事件,Android 需要设置该开关(iOS无需设置), `default: true` | `boolean` | `Android、Voltron`|
| endReached | 当所有的数据都已经渲染过,并且列表被滚动到最后一条时,将触发 `endReached` 回调。 | `Function` | `Android、iOS、Web-Renderer、Voltron` |
| editable | 是否可编辑,开启侧滑删除时需要设置为 `true``最低支持版本2.9.0` | `boolean` | `iOS` |
| delText | 侧滑删除文本。`最低支持版本2.9.0` | `string` | `iOS` |
Expand Down
6 changes: 3 additions & 3 deletions docs/api/hippy-vue/vue-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Vue.Native.AsyncStorage.getItem('itemKey');
### AsyncStorage.multiGet

`(key: string[]) => Promise<[key: string, value: value][]>` 一次性用多个 key 值的数组去批量请求缓存数据,返回值将在回调函数以键值对的二维数组形式返回。
`(key: string[]) => Promise<[key: string, value: string][]>` 一次性用多个 key 值的数组去批量请求缓存数据,返回值将在回调函数以键值对的二维数组形式返回。

> * key: string[] - 需要获取值的目标 key 数组
Expand All @@ -132,9 +132,9 @@ Vue.Native.AsyncStorage.getItem('itemKey');
### AsyncStorage.multiSet

`(keyValuePairs: [key: string, value: value][]) => void` 调用这个函数可以批量存储键值对对象。
`(keyValuePairs: [key: string, value: string][]) => void` 调用这个函数可以批量存储键值对对象。

> * keyValuePairs: [key: string, value: value][] - 需要设置的储键值二维数组
> * keyValuePairs: [key: string, value: string][] - 需要设置的储键值二维数组
### AsyncStorage.removeItem

Expand Down
15 changes: 11 additions & 4 deletions dom/src/dom/dom_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,9 @@ LayoutResult DomNode::GetLayoutInfoFromRoot() {
void DomNode::TransferLayoutOutputsRecursive(std::vector<std::shared_ptr<DomNode>>& changed_nodes) {
auto not_equal = std::not_equal_to<>();
bool changed = layout_node_->IsDirty() || layout_node_->HasNewLayout();
#ifdef __ANDROID__
bool trigger_layout_event = true;
#else
bool trigger_layout_event =
not_equal(layout_.left, layout_node_->GetLeft()) || not_equal(layout_.top, layout_node_->GetTop()) ||
not_equal(layout_.width, layout_node_->GetWidth()) || not_equal(layout_.height, layout_node_->GetHeight());
#endif

layout_.left = layout_node_->GetLeft();
layout_.top = layout_node_->GetTop();
Expand Down Expand Up @@ -611,6 +607,13 @@ std::ostream& operator<<(std::ostream& os, const RefInfo& ref_info) {
return os;
}

std::ostream& operator<<(std::ostream& os, const DiffInfo& diff_info) {
os << "{";
os << "\"skip_style_diff\": " << diff_info.skip_style_diff << ", ";
os << "}";
return os;
}

std::ostream& operator<<(std::ostream& os, const DomNode& dom_node) {
os << "{";
os << "\"id\": " << dom_node.id_ << ", ";
Expand All @@ -637,10 +640,14 @@ std::ostream& operator<<(std::ostream& os, const DomNode& dom_node) {
std::ostream& operator<<(std::ostream& os, const DomInfo& dom_info) {
auto dom_node = dom_info.dom_node;
auto ref_info = dom_info.ref_info;
auto diff_info = dom_info.diff_info;
os << "{";
if (ref_info != nullptr) {
os << "\"ref info\": " << *ref_info << ", ";
}
if (diff_info != nullptr) {
os << "\"diff info\": " << *diff_info << ", ";
}
if (dom_node != nullptr) {
os << "\"dom node\": " << *dom_node << ", ";
}
Expand Down
16 changes: 8 additions & 8 deletions dom/src/dom/root_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ void RootNode::UpdateDomNodes(std::vector<std::shared_ptr<DomInfo>>&& nodes) {
if (!ext_update->empty()) {
diff_value->insert(ext_update->begin(), ext_update->end());
}
dom_node->SetStyleMap(node_info->dom_node->GetStyleMap());
if (!skip_style_diff) {
dom_node->SetStyleMap(node_info->dom_node->GetStyleMap());
}
dom_node->SetExtStyleMap(node_info->dom_node->GetExtStyle());
dom_node->SetDiffStyle(diff_value);

Expand Down Expand Up @@ -276,21 +278,19 @@ void RootNode::CallFunction(uint32_t id, const std::string& name, const DomArgum
}

void RootNode::SyncWithRenderManager(const std::shared_ptr<RenderManager>& render_manager) {
HP_PERF_LOG("RootNode::SyncWithRenderManager");
unsigned long cnt = dom_operations_.size();
TDF_PERF_DO_STMT_AND_LOG(unsigned long domCnt = dom_operations_.size(); , "RootNode::SyncWithRenderManager");
FlushDomOperations(render_manager);
HP_PERF_LOG("RootNode::FlushDomOperations Done, dom op count:%lld", cnt);
cnt = event_operations_.size();
TDF_PERF_DO_STMT_AND_LOG(unsigned long evCnt = event_operations_.size(); , "RootNode::FlushDomOperations Done, dom op count:%lld", domCnt);
FlushEventOperations(render_manager);
HP_PERF_LOG("RootNode::FlushEventOperations Done, event op count:%d",cnt);
TDF_PERF_LOG("RootNode::FlushEventOperations Done, event op count:%d", evCnt);
DoAndFlushLayout(render_manager);
HP_PERF_LOG("RootNode::DoAndFlushLayout Done");
TDF_PERF_LOG("RootNode::DoAndFlushLayout Done");
auto dom_manager = dom_manager_.lock();
if (dom_manager) {
dom_manager->RecordDomEndTimePoint();
}
render_manager->EndBatch(GetWeakSelf());
HP_PERF_LOG("RootNode::SyncWithRenderManager End");
TDF_PERF_LOG("RootNode::SyncWithRenderManager End");
}

void RootNode::AddEvent(uint32_t id, const std::string& event_name) {
Expand Down
6 changes: 6 additions & 0 deletions driver/js/src/modules/animation_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ std::shared_ptr<ParseAnimationResult> ParseAnimation(const std::shared_ptr<Ctx>&
const std::shared_ptr<CtxValue> arguments[],
std::shared_ptr<CtxValue>& exception) {
if (argument_count != kAnimationUpdateArgc) {
exception = context->CreateException("animation argument count error");
return nullptr;
}

Expand Down Expand Up @@ -306,11 +307,13 @@ RegisterAnimation(const std::weak_ptr<Scope>& weak_scope) {
auto weak_dom_manager = scope->GetDomManager();
auto dom_manager = weak_dom_manager.lock();
if (!dom_manager) {
exception = scope->GetContext()->CreateException("dom_manager null error");
return nullptr;
}
auto weak_root_node = scope->GetRootNode();
auto root_node = weak_root_node.lock();
if (!root_node) {
exception = scope->GetContext()->CreateException("root_node null error");
return nullptr;
}
auto result = ParseAnimation(scope->GetContext(), argument_count, arguments, exception);
Expand Down Expand Up @@ -619,15 +622,18 @@ RegisterAnimationSet(const std::weak_ptr<Scope>& weak_scope) {
auto weak_dom_manager = scope->GetDomManager();
auto dom_manager = weak_dom_manager.lock();
if (!dom_manager) {
exception = scope->GetContext()->CreateException("dom_manager null error");
return nullptr;
}
auto weak_root_node = scope->GetRootNode();
auto root_node = weak_root_node.lock();
if (!root_node) {
exception = scope->GetContext()->CreateException("root_node null error");
return nullptr;
}
auto animation_manager = root_node->GetAnimationManager();
if (!animation_manager) {
exception = scope->GetContext()->CreateException("animation_manager null error");
return nullptr;
}
auto set = ParseAnimationSet(scope->GetContext(), argument_count, arguments, exception);
Expand Down
6 changes: 3 additions & 3 deletions driver/js/src/modules/scene_builder_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,14 @@ std::shared_ptr<ClassTemplate<SceneBuilder>> RegisterSceneBuilder(const std::wea
size_t argument_count,
const std::shared_ptr<CtxValue> arguments[],
std::shared_ptr<CtxValue>&) -> std::shared_ptr<CtxValue> {
HP_PERF_LOG("SceneBuilder.build()");
TDF_PERF_LOG("SceneBuilder.build()");
auto scope = weak_scope.lock();
if (!scope) {
HP_PERF_LOG("SceneBuilder.build() exit with error");
TDF_PERF_LOG("SceneBuilder.build() exit with error");
return nullptr;
}
SceneBuilder::Build(scope->GetDomManager(), scope->GetRootNode());
HP_PERF_LOG("SceneBuilder.build() End");
TDF_PERF_LOG("SceneBuilder.build() End");
return nullptr;
};
class_template.functions.emplace_back(std::move(build_func_def));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.tencent.mtt.hippy.modules.nativemodules.HippyNativeModuleBase;
import com.tencent.mtt.hippy.runtime.builtins.JSObject;
import com.tencent.vfs.ResourceDataHolder;
import com.tencent.vfs.ResourceDataHolder.TransferType;
import com.tencent.vfs.VfsManager;
import com.tencent.vfs.VfsManager.FetchResourceCallback;
import java.nio.charset.StandardCharsets;
Expand All @@ -54,7 +53,7 @@ public NetworkModule(HippyEngineContext context) {
}

@SuppressWarnings("deprecation")
private void normalizeRequestHeaders(@NonNull HippyMap headers,
protected void normalizeRequestHeaders(@NonNull HippyMap headers,
@NonNull HashMap<String, String> requestHeaders) {
Set<Entry<String, Object>> entrySet = headers.entrySet();
for (Entry<String, Object> entry : entrySet) {
Expand Down Expand Up @@ -82,7 +81,7 @@ private void normalizeRequestHeaders(@NonNull HippyMap headers,
}

@SuppressWarnings("deprecation")
private void normalizeRequest(@NonNull HippyMap request,
protected void normalizeRequest(@NonNull HippyMap request,
@NonNull HashMap<String, String> requestHeaders,
@NonNull HashMap<String, String> requestParams) throws IllegalStateException {
Set<Entry<String, Object>> entrySet = request.entrySet();
Expand All @@ -103,7 +102,7 @@ private void normalizeRequest(@NonNull HippyMap request,
}
}

private void handleFetchResponse(@NonNull ResourceDataHolder dataHolder, Promise promise)
protected void handleFetchResponse(@NonNull ResourceDataHolder dataHolder, Promise promise)
throws IllegalStateException {
JSObject responseObject = new JSObject();
int statusCode = 0;
Expand Down Expand Up @@ -151,12 +150,12 @@ public void fetch(final HippyMap request, final Promise promise) {
try {
normalizeRequest(request, requestHeaders, requestParams);
} catch (Exception e) {
promise.resolve(e.getMessage());
promise.reject(e.getMessage());
return;
}
final String uri = requestParams.get(HTTP_URL);
if (TextUtils.isEmpty(uri)) {
promise.resolve("Get url parameter failed!");
promise.reject("Get url parameter failed!");
return;
}
vfsManager.fetchResourceAsync(uri, requestHeaders, requestParams,
Expand All @@ -168,12 +167,13 @@ public void onFetchCompleted(@NonNull ResourceDataHolder dataHolder) {
try {
handleFetchResponse(dataHolder, promise);
} catch (IllegalStateException e) {
promise.resolve(
"Handle response failed: " + dataHolder.errorMessage);
promise.reject(
"Handle response failed: " + e.getMessage());
}
} else {
promise.resolve(
"Load remote resource failed: " + dataHolder.errorMessage);
String error = TextUtils.isEmpty(dataHolder.errorMessage)
? "Load remote resource failed!" : dataHolder.errorMessage;
promise.resolve(error);
}
dataHolder.recycle();
}
Expand Down
Loading

0 comments on commit ee3ffc7

Please sign in to comment.