Skip to content

Commit

Permalink
Merge branch 'main' into fix/group_id
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli authored Sep 29, 2024
2 parents 5290219 + 8474160 commit 54be809
Show file tree
Hide file tree
Showing 224 changed files with 32,769 additions and 1,575 deletions.
10 changes: 10 additions & 0 deletions docs/development/android-3.0-upgrade-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
@Nullable Object params);
```

6. 自定义事件controller属性注册方式变更 <br>
由于3.0事件名称从2.0的驼峰写法统一转换为全小写命名,会导致之前开发者自定义事件无法接收到属性设置,需要在事件属性注解中将defaultType值改为HippyControllerProps.EVENT:

```java
@HippyControllerProps(name = "onMyEvent", defaultType = HippyControllerProps.EVENT, defaultBoolean = false)
public void setMyEvent(HippyScrollView scrollView, boolean isEnable) {

}
```

</br>

# 组件变更
Expand Down
8 changes: 7 additions & 1 deletion dom/include/dom/dom_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include "footstone/base_timer.h"
#include "footstone/worker.h"

#define HIPPY_EXPERIMENT_LAYER_OPTIMIZATION

namespace hippy {
inline namespace dom {

Expand Down Expand Up @@ -140,8 +142,12 @@ class DomManager : public std::enable_shared_from_this<DomManager> {
friend class DomNode;

uint32_t id_;
#ifdef HIPPY_EXPERIMENT_LAYER_OPTIMIZATION
std::shared_ptr<LayerOptimizedRenderManager> optimized_render_manager_;
std::weak_ptr<RenderManager> render_manager_;
std::shared_ptr<RenderManager> render_manager_;
#else
std::shared_ptr<RenderManager> render_manager_;
#endif
std::unordered_map<uint32_t, std::shared_ptr<BaseTimer>> timer_map_;
std::shared_ptr<TaskRunner> task_runner_;
std::shared_ptr<Worker> worker_;
Expand Down
1 change: 1 addition & 0 deletions dom/include/dom/layer_optimized_render_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ inline namespace dom {
class LayerOptimizedRenderManager : public RenderManager {
public:
LayerOptimizedRenderManager(std::shared_ptr<RenderManager> render_manager);
inline std::shared_ptr<RenderManager> GetInternalNativeRenderManager() { return render_manager_; }

void CreateRenderNode(std::weak_ptr<RootNode> root_node, std::vector<std::shared_ptr<DomNode>>&& nodes) override;
void UpdateRenderNode(std::weak_ptr<RootNode> root_node, std::vector<std::shared_ptr<DomNode>>&& nodes) override;
Expand Down
1 change: 1 addition & 0 deletions dom/include/dom/layout_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class LayoutNode {
const std::vector<std::string>& style_delete) = 0;
};

void InitLayoutConsts();
std::shared_ptr<LayoutNode> CreateLayoutNode();

} // namespace dom
Expand Down
10 changes: 4 additions & 6 deletions dom/src/dom/dom_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
* limitations under the License.
*/

#define EXPERIMENT_LAYER_OPTIMIZATION

#include "dom/dom_manager.h"

#include <mutex>
Expand Down Expand Up @@ -54,11 +52,11 @@ using Deserializer = footstone::value::Deserializer;
using HippyValueArrayType = footstone::value::HippyValue::HippyValueArrayType;

void DomManager::SetRenderManager(const std::weak_ptr<RenderManager>& render_manager) {
#ifdef EXPERIMENT_LAYER_OPTIMIZATION
#ifdef HIPPY_EXPERIMENT_LAYER_OPTIMIZATION
optimized_render_manager_ = std::make_shared<LayerOptimizedRenderManager>(render_manager.lock());
render_manager_ = optimized_render_manager_;
#else
render_manager_ = render_manager;
render_manager_ = render_manager.lock();
#endif
}

Expand Down Expand Up @@ -125,7 +123,7 @@ void DomManager::DeleteDomNodes(const std::weak_ptr<RootNode>& weak_root_node,
}

void DomManager::EndBatch(const std::weak_ptr<RootNode>& weak_root_node) {
auto render_manager = render_manager_.lock();
auto render_manager = render_manager_;
FOOTSTONE_DCHECK(render_manager);
if (!render_manager) {
return;
Expand Down Expand Up @@ -187,7 +185,7 @@ void DomManager::DoLayout(const std::weak_ptr<RootNode>& weak_root_node) {
if (!root_node) {
return;
}
auto render_manager = render_manager_.lock();
auto render_manager = render_manager_;
// check render_manager, measure text dependent render_manager
FOOTSTONE_DCHECK(render_manager);
if (!render_manager) {
Expand Down
1 change: 1 addition & 0 deletions dom/src/dom/root_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ bool DomNodeStyleDiffer::Calculate(const std::shared_ptr<hippy::dom::RootNode>&
}

RootNode::RootNode(uint32_t id) : DomNode(id, 0, 0, "", "", nullptr, nullptr, {}) {
InitLayoutConsts();
SetRenderInfo({id, 0, 0});
animation_manager_ = std::make_shared<AnimationManager>();
interceptors_.push_back(animation_manager_);
Expand Down
145 changes: 79 additions & 66 deletions dom/src/dom/taitank_layout_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,75 +30,82 @@
namespace hippy {
inline namespace dom {

const std::map<std::string, OverflowType> kOverflowMap = {{"visible", OverflowType::OVERFLOW_VISIBLE},
{"hidden", OverflowType::OVERFLOW_HIDDEN},
{"scroll", OverflowType::OVERFLOW_SCROLL}};

const std::map<std::string, FlexDirection> kFlexDirectionMap = {
{"row", FlexDirection::FLEX_DIRECTION_ROW},
{"row-reverse", FlexDirection::FLEX_DIRECTION_ROW_REVERSE},
{"column", FlexDirection::FLEX_DIRECTION_COLUMN},
{"column-reverse", FlexDirection::FLEX_DIRECTION_COLUNM_REVERSE}};

const std::map<std::string, FlexWrapMode> kWrapModeMap = {{"nowrap", FlexWrapMode::FLEX_NO_WRAP},
{"wrap", FlexWrapMode::FLEX_WRAP},
{"wrap-reverse", FlexWrapMode::FLEX_WRAP_REVERSE}};

const std::map<std::string, FlexAlign> kJustifyMap = {{"flex-start", FlexAlign::FLEX_ALIGN_START},
{"center", FlexAlign::FLEX_ALIGN_CENTER},
{"flex-end", FlexAlign::FLEX_ALIGN_END},
{"space-between", FlexAlign::FLEX_ALIGN_SPACE_BETWEEN},
{"space-around", FlexAlign::FLEX_ALIGN_SPACE_AROUND},
{"space-evenly", FlexAlign::FLEX_ALIGN_SPACE_EVENLY}};

const std::map<std::string, FlexAlign> kAlignMap = {{"auto", FlexAlign::FLEX_ALIGN_AUTO},
{"flex-start", FlexAlign::FLEX_ALIGN_START},
{"center", FlexAlign::FLEX_ALIGN_CENTER},
{"flex-end", FlexAlign::FLEX_ALIGN_END},
{"stretch", FlexAlign::FLEX_ALIGN_STRETCH},
{"baseline", FlexAlign::FLEX_ALIGN_BASE_LINE},
{"space-between", FlexAlign::FLEX_ALIGN_SPACE_BETWEEN},
{"space-around", FlexAlign::FLEX_ALIGN_SPACE_AROUND}};

const std::map<std::string, CSSDirection> kMarginMap = {{kMargin, CSSDirection::CSS_ALL},
{kMarginVertical, CSSDirection::CSS_VERTICAL},
{kMarginHorizontal, CSSDirection::CSS_HORIZONTAL},
{kMarginLeft, CSSDirection::CSS_LEFT},
{kMarginRight, CSSDirection::CSS_RIGHT},
{kMarginTop, CSSDirection::CSS_TOP},
{kMarginBottom, CSSDirection::CSS_BOTTOM}};

const std::map<std::string, CSSDirection> kPaddingMap = {{kPadding, CSSDirection::CSS_ALL},
{kPaddingVertical, CSSDirection::CSS_VERTICAL},
{kPaddingHorizontal, CSSDirection::CSS_HORIZONTAL},
{kPaddingLeft, CSSDirection::CSS_LEFT},
{kPaddingRight, CSSDirection::CSS_RIGHT},
{kPaddingTop, CSSDirection::CSS_TOP},
{kPaddingBottom, CSSDirection::CSS_BOTTOM}};

const std::map<std::string, CSSDirection> kPositionMap = {{kLeft, CSSDirection::CSS_LEFT},
{kRight, CSSDirection::CSS_RIGHT},
{kTop, CSSDirection::CSS_TOP},
{kBottom, CSSDirection::CSS_BOTTOM}};

const std::map<std::string, CSSDirection> kBorderMap = {{kBorderWidth, CSSDirection::CSS_ALL},
{kBorderLeftWidth, CSSDirection::CSS_LEFT},
{kBorderTopWidth, CSSDirection::CSS_TOP},
{kBorderRightWidth, CSSDirection::CSS_RIGHT},
{kBorderBottomWidth, CSSDirection::CSS_BOTTOM}};

const std::map<std::string, PositionType> kPositionTypeMap = {{"relative", PositionType::POSITION_TYPE_RELATIVE},
{"absolute", PositionType::POSITION_TYPE_ABSOLUTE}};

const std::map<std::string, DisplayType> kDisplayTypeMap = {{"none", DisplayType::DISPLAY_TYPE_NONE}};

const std::map<std::string, TaitankDirection> kDirectionMap = {
{"inherit", DIRECTION_INHERIT}, {"ltr", DIRECTION_LTR}, {"rtl", DIRECTION_RTL}};
class TaitankLayoutConsts {
public:
const std::map<std::string, OverflowType> kOverflowMap = {{"visible", OverflowType::OVERFLOW_VISIBLE},
{"hidden", OverflowType::OVERFLOW_HIDDEN},
{"scroll", OverflowType::OVERFLOW_SCROLL}};

const std::map<std::string, FlexDirection> kFlexDirectionMap = {
{"row", FlexDirection::FLEX_DIRECTION_ROW},
{"row-reverse", FlexDirection::FLEX_DIRECTION_ROW_REVERSE},
{"column", FlexDirection::FLEX_DIRECTION_COLUMN},
{"column-reverse", FlexDirection::FLEX_DIRECTION_COLUNM_REVERSE}};

const std::map<std::string, FlexWrapMode> kWrapModeMap = {{"nowrap", FlexWrapMode::FLEX_NO_WRAP},
{"wrap", FlexWrapMode::FLEX_WRAP},
{"wrap-reverse", FlexWrapMode::FLEX_WRAP_REVERSE}};

const std::map<std::string, FlexAlign> kJustifyMap = {{"flex-start", FlexAlign::FLEX_ALIGN_START},
{"center", FlexAlign::FLEX_ALIGN_CENTER},
{"flex-end", FlexAlign::FLEX_ALIGN_END},
{"space-between", FlexAlign::FLEX_ALIGN_SPACE_BETWEEN},
{"space-around", FlexAlign::FLEX_ALIGN_SPACE_AROUND},
{"space-evenly", FlexAlign::FLEX_ALIGN_SPACE_EVENLY}};

const std::map<std::string, FlexAlign> kAlignMap = {{"auto", FlexAlign::FLEX_ALIGN_AUTO},
{"flex-start", FlexAlign::FLEX_ALIGN_START},
{"center", FlexAlign::FLEX_ALIGN_CENTER},
{"flex-end", FlexAlign::FLEX_ALIGN_END},
{"stretch", FlexAlign::FLEX_ALIGN_STRETCH},
{"baseline", FlexAlign::FLEX_ALIGN_BASE_LINE},
{"space-between", FlexAlign::FLEX_ALIGN_SPACE_BETWEEN},
{"space-around", FlexAlign::FLEX_ALIGN_SPACE_AROUND}};

const std::map<std::string, CSSDirection> kMarginMap = {{kMargin, CSSDirection::CSS_ALL},
{kMarginVertical, CSSDirection::CSS_VERTICAL},
{kMarginHorizontal, CSSDirection::CSS_HORIZONTAL},
{kMarginLeft, CSSDirection::CSS_LEFT},
{kMarginRight, CSSDirection::CSS_RIGHT},
{kMarginTop, CSSDirection::CSS_TOP},
{kMarginBottom, CSSDirection::CSS_BOTTOM}};

const std::map<std::string, CSSDirection> kPaddingMap = {{kPadding, CSSDirection::CSS_ALL},
{kPaddingVertical, CSSDirection::CSS_VERTICAL},
{kPaddingHorizontal, CSSDirection::CSS_HORIZONTAL},
{kPaddingLeft, CSSDirection::CSS_LEFT},
{kPaddingRight, CSSDirection::CSS_RIGHT},
{kPaddingTop, CSSDirection::CSS_TOP},
{kPaddingBottom, CSSDirection::CSS_BOTTOM}};

const std::map<std::string, CSSDirection> kPositionMap = {{kLeft, CSSDirection::CSS_LEFT},
{kRight, CSSDirection::CSS_RIGHT},
{kTop, CSSDirection::CSS_TOP},
{kBottom, CSSDirection::CSS_BOTTOM}};

const std::map<std::string, CSSDirection> kBorderMap = {{kBorderWidth, CSSDirection::CSS_ALL},
{kBorderLeftWidth, CSSDirection::CSS_LEFT},
{kBorderTopWidth, CSSDirection::CSS_TOP},
{kBorderRightWidth, CSSDirection::CSS_RIGHT},
{kBorderBottomWidth, CSSDirection::CSS_BOTTOM}};

const std::map<std::string, PositionType> kPositionTypeMap = {{"relative", PositionType::POSITION_TYPE_RELATIVE},
{"absolute", PositionType::POSITION_TYPE_ABSOLUTE}};

const std::map<std::string, DisplayType> kDisplayTypeMap = {{"none", DisplayType::DISPLAY_TYPE_NONE}};

const std::map<std::string, TaitankDirection> kDirectionMap = {
{"inherit", DIRECTION_INHERIT}, {"ltr", DIRECTION_LTR}, {"rtl", DIRECTION_RTL}};
};

static std::shared_ptr<TaitankLayoutConsts> global_layout_consts = nullptr;

#define TAITANK_GET_STYLE_DECL(NAME, TYPE, DEFAULT) \
static TYPE GetStyle##NAME(const std::string& key) { \
auto iter = k##NAME##Map.find(key); \
if (iter != k##NAME##Map.end()) return iter->second; \
if (global_layout_consts == nullptr) return DEFAULT; \
auto &map = global_layout_consts->k##NAME##Map; \
auto iter = map.find(key); \
if (iter != map.end()) return iter->second; \
return DEFAULT; \
}

Expand Down Expand Up @@ -814,6 +821,12 @@ void TaitankLayoutNode::Deallocate() {
engine_node_ = nullptr;
}

void InitLayoutConsts() {
if (global_layout_consts == nullptr) {
global_layout_consts = std::make_shared<TaitankLayoutConsts>();
}
}

std::shared_ptr<LayoutNode> CreateLayoutNode() { return std::make_shared<TaitankLayoutNode>(); }

} // namespace dom
Expand Down
1 change: 1 addition & 0 deletions dom/src/dom/yoga_layout_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ void YogaLayoutNode::Deallocate() {
YGConfigFree(yoga_config_);
}

void InitLayoutConsts() {}
std::shared_ptr<LayoutNode> CreateLayoutNode() { return std::make_shared<YogaLayoutNode>(); }

} // namespace dom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ module.exports = {
console.warn('* Using the @hippy/react defined in package.json');
}

// If @hippy/web-renderer was built exist in packages directory then make an alias
// Remove the section if you don't use it
const webRendererPath = path.resolve(__dirname, '../../../packages/hippy-web-renderer/dist');
if (fs.existsSync(path.resolve(webRendererPath, 'index.js'))) {
console.warn(`* Using the @hippy/web-renderer in ${webRendererPath} as @hippy/web-renderer alias`);
aliases['@hippy/web-renderer'] = webRendererPath;
} else {
console.warn('* Using the @hippy/web-renderer defined in package.json');
}

return aliases;
})(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const styles = StyleSheet.create({
flex: 1,
textAlign: 'center',
color: '#4c9afa',
backgroundColor: '#fff',
},
itemEven: {
height: 40,
Expand Down
2 changes: 1 addition & 1 deletion driver/js/examples/hippy-react-demo/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Type = {
export default [
{
path: '/Components',
name: 'Componemts',
name: 'Components',
meta: {
type: Type.TITLE,
mapType: Type.COMPONENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ module.exports = {
console.warn('* Using the @hippy/vue-native-components defined in package.json');
}

// If @hippy/web-renderer was built exist in packages directory then make an alias
// Remove the section if you don't use it
const webRendererPath = path.resolve(__dirname, '../../../packages/hippy-web-renderer/dist');
if (fs.existsSync(path.resolve(webRendererPath, 'index.js'))) {
console.warn(`* Using the @hippy/web-renderer in ${webRendererPath} as @hippy/web-renderer alias`);
aliases['@hippy/web-renderer'] = webRendererPath;
} else {
console.warn('* Using the @hippy/web-renderer defined in package.json');
}

return aliases;
})(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ module.exports = {
console.warn('* Using the @hippy/vue-native-components defined in package.json');
}

// If @hippy/web-renderer was built exist in packages directory then make an alias
// Remove the section if you don't use it
const webRendererPath = path.resolve(__dirname, '../../../packages/hippy-web-renderer/dist');
if (fs.existsSync(path.resolve(webRendererPath, 'index.js'))) {
console.warn(`* Using the @hippy/web-renderer in ${webRendererPath} as @hippy/web-renderer alias`);
aliases['@hippy/web-renderer'] = webRendererPath;
} else {
console.warn('* Using the @hippy/web-renderer defined in package.json');
}

return aliases;
})(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default {
onDropped(evt) {
// 更细当前页码
this.currentSlideNum = evt.currentSlide;
this.currentSlide = evt.currentSlide;
},
onStateChanged(evt) {
// 更新当前滚屏状态
Expand Down
8 changes: 4 additions & 4 deletions driver/js/examples/hippy-vue-next-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"@hippy/vue-next": "v3.3-latest",
"@hippy/vue-router-next-history": "0.0.1",
"@hippy/web-renderer": "latest",
"@vue/runtime-core": "^3.2.46",
"@vue/shared": "^3.2.46",
"vue": "^3.2.46",
"@vue/runtime-core": "3.4.32",
"@vue/shared": "3.4.32",
"vue": "3.4.32",
"vue-router": "^4.0.12"
},
"devDependencies": {
Expand All @@ -43,7 +43,7 @@
"@hippy/vue-css-loader": "v3.3-latest",
"@vitejs/plugin-vue": "^1.9.4",
"@vue/cli-service": "^4.5.19",
"@vue/compiler-sfc": "^3.2.46",
"@vue/compiler-sfc": "3.4.32",
"babel-loader": "^8.1.0",
"case-sensitive-paths-webpack-plugin": "^2.2.0",
"clean-webpack-plugin": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ module.exports = {
console.warn('* Using the @hippy/vue-next defined in package.json');
}

// If @hippy/web-renderer was built exist in packages directory then make an alias
// Remove the section if you don't use it
const webRendererPath = path.resolve(__dirname, '../../../packages/hippy-web-renderer/dist');
if (fs.existsSync(path.resolve(webRendererPath, 'index.js'))) {
console.warn(`* Using the @hippy/web-renderer in ${webRendererPath} as @hippy/web-renderer alias`);
aliases['@hippy/web-renderer'] = webRendererPath;
} else {
console.warn('* Using the @hippy/web-renderer defined in package.json');
}

return aliases;
})(),
},
Expand Down
Loading

0 comments on commit 54be809

Please sign in to comment.