mirror of
https://github.com/openharmony/ace_engine_lite.git
synced 2026-07-20 05:43:59 -04:00
!190 【轻量级 PR】:修改deveco模拟器中,运行js应用,某些场景下动态改变组件的属性,导致组件有残影存在的问题
Merge pull request !190 from dml-hw/N/A
This commit is contained in:
@@ -240,7 +240,7 @@ bool Component::UpdateView(uint16_t attrKeyId, jerry_value_t attrValue)
|
||||
parent_->GetConstrainedParam(parentParam);
|
||||
AlignDimensions(parentParam);
|
||||
}
|
||||
AdaptBoxSizing();
|
||||
AdaptBoxSizing(attrKeyId);
|
||||
// force parent to relayout the children in case component's area is changed
|
||||
InvalidateIfNeeded(attrKeyId, false);
|
||||
if (updateResult) {
|
||||
@@ -423,6 +423,16 @@ void Component::ApplyAlignedMargin(UIView &uiView) const
|
||||
}
|
||||
}
|
||||
|
||||
bool Component::IsLayoutRelatedAttrs(uint16_t attrKeyId) const
|
||||
{
|
||||
return (attrKeyId == K_HEIGHT || attrKeyId == K_WIDTH || attrKeyId == K_MARGIN || attrKeyId == K_MARGIN_BOTTOM ||
|
||||
attrKeyId == K_MARGIN_LEFT || attrKeyId == K_MARGIN_RIGHT || attrKeyId == K_MARGIN_TOP ||
|
||||
attrKeyId == K_PADDING || attrKeyId == K_PADDING_BOTTOM || attrKeyId == K_PADDING_LEFT ||
|
||||
attrKeyId == K_PADDING_RIGHT || attrKeyId == K_PADDING_TOP || attrKeyId == K_BORDER_BOTTOM_WIDTH ||
|
||||
attrKeyId == K_BORDER_LEFT_WIDTH || attrKeyId == K_BORDER_RIGHT_WIDTH || attrKeyId == K_BORDER_TOP_WIDTH ||
|
||||
attrKeyId == K_BORDER_WIDTH || attrKeyId == K_BORDER_RADIUS || attrKeyId == K_LEFT || attrKeyId == K_TOP);
|
||||
}
|
||||
|
||||
void Component::ApplyAlignedPosition(UIView &uiView) const
|
||||
{
|
||||
if (top_.type == DimensionType::TYPE_PIXEL) {
|
||||
@@ -477,14 +487,17 @@ void Component::AdapteBoxRectArea(UIView &uiView) const
|
||||
}
|
||||
}
|
||||
|
||||
bool Component::AdaptBoxSizing() const
|
||||
bool Component::AdaptBoxSizing(uint16_t attrKeyId) const
|
||||
{
|
||||
UIView *uiView = GetComponentRootView();
|
||||
if (uiView == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// apply aligned top and left
|
||||
ApplyAlignedPosition(*uiView);
|
||||
bool isNeedAlignedPosition = ((attrKeyId == K_UNKNOWN) ? true : IsLayoutRelatedAttrs(attrKeyId));
|
||||
if (isNeedAlignedPosition) {
|
||||
// apply aligned top and left
|
||||
ApplyAlignedPosition(*uiView);
|
||||
}
|
||||
// apply aligned magin
|
||||
ApplyAlignedMargin(*uiView);
|
||||
// adjust the box sizing
|
||||
@@ -1289,12 +1302,7 @@ void Component::InvalidateIfNeeded(uint16_t attrKeyId, bool invalidateSelf) cons
|
||||
return;
|
||||
}
|
||||
|
||||
if (attrKeyId == K_HEIGHT || attrKeyId == K_WIDTH || attrKeyId == K_MARGIN || attrKeyId == K_MARGIN_BOTTOM ||
|
||||
attrKeyId == K_MARGIN_LEFT || attrKeyId == K_MARGIN_RIGHT || attrKeyId == K_MARGIN_TOP ||
|
||||
attrKeyId == K_PADDING || attrKeyId == K_PADDING_BOTTOM || attrKeyId == K_PADDING_LEFT ||
|
||||
attrKeyId == K_PADDING_RIGHT || attrKeyId == K_PADDING_TOP || attrKeyId == K_BORDER_BOTTOM_WIDTH ||
|
||||
attrKeyId == K_BORDER_LEFT_WIDTH || attrKeyId == K_BORDER_RIGHT_WIDTH || attrKeyId == K_BORDER_TOP_WIDTH ||
|
||||
attrKeyId == K_BORDER_WIDTH || attrKeyId == K_BORDER_RADIUS || attrKeyId == K_LEFT || attrKeyId == K_TOP) {
|
||||
if (IsLayoutRelatedAttrs(attrKeyId)) {
|
||||
if (invalidateSelf) {
|
||||
uiView->Invalidate();
|
||||
return;
|
||||
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
/**
|
||||
* @brief This function will be called after the ApplyCommonStyle, make padding style work.
|
||||
*/
|
||||
bool AdaptBoxSizing() const;
|
||||
bool AdaptBoxSizing(uint16_t attrKeyId = K_UNKNOWN) const;
|
||||
void AlignDimensions(const ConstrainedParameter ¶m);
|
||||
|
||||
protected:
|
||||
@@ -513,6 +513,7 @@ private:
|
||||
* @brief Apply combined styles into native view.
|
||||
*/
|
||||
void ApplyStyles(const jerry_value_t options, Component& currentComponent) const;
|
||||
bool IsLayoutRelatedAttrs(uint16_t attrKeyId) const;
|
||||
void ApplyAlignedPosition(UIView &uiView) const;
|
||||
void AdapteBoxRectArea(UIView &uiView) const;
|
||||
void SetVisible(UIView& view, const AppStyleItem *styleItem) const;
|
||||
|
||||
Reference in New Issue
Block a user