Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/renderer/dom/element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ void Element::UpdateLayout(float left, float top, float width, float height,
const std::array<float, 4>& margins,
const std::array<float, 4>& borders,
const std::array<float, 4>* sticky_positions,
float max_height) {
float max_height, bool display_none) {
TRACE_EVENT(LYNX_TRACE_CATEGORY, ELEMENT_UPDATE_LAYOUT);
// TODO: only leaf node need to update border padding
frame_changed_ = true;
Expand All @@ -411,6 +411,7 @@ void Element::UpdateLayout(float left, float top, float width, float height,
paddings_ = paddings;
margins_ = margins;
borders_ = borders;
display_none_ = display_none;
UpdateStickyPosition(sticky_positions);
MarkSubtreeNeedUpdate();
NotifyElementSizeUpdated();
Expand Down
4 changes: 3 additions & 1 deletion core/renderer/dom/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class Element : public lepus::RefCounted,
const std::array<float, 4>& margins,
const std::array<float, 4>& borders,
const std::array<float, 4>* sticky_positions,
float max_height);
float max_height, bool display_none = false);
// Used to update child element's left and top value from list element. The
// another overloaded function is used to update layout info from starlight,
// but if the element is list's child, the left and top's value are always 0.
Expand Down Expand Up @@ -878,6 +878,7 @@ class Element : public lepus::RefCounted,
float height() { return height_; }
float top() { return top_; }
float left() { return left_; }
bool display_none() { return display_none_; }

bool enable_new_animator() { return enable_new_animator_; }

Expand Down Expand Up @@ -1543,6 +1544,7 @@ class Element : public lepus::RefCounted,

bool subtree_need_update_{false};
bool frame_changed_{false};
bool display_none_{false};
// Determine by Catalyzer
bool is_layout_only_{false};

Expand Down
1 change: 1 addition & 0 deletions core/renderer/dom/fiber/fiber_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5601,6 +5601,7 @@ void FiberElement::UpdateLayoutInfo() {
borders_[1] = layout_result.border_[starlight::kTop];
borders_[2] = layout_result.border_[starlight::kRight];
borders_[3] = layout_result.border_[starlight::kBottom];
display_none_ = sl_node_->GetShouldDisplayNone();

if (IsShadowNodeCustom()) {
element_manager_->layout_context()->OnLayout(id_, left_, top_, width_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DelegateEmptyImpl : public LayoutContext::Delegate {
const std::array<float, 4>& margins,
const std::array<float, 4>& borders,
const std::array<float, 4>* sticky_positions,
float max_height) override {}
float max_height, bool display_none) override {}
virtual void OnLayoutAfter(const std::shared_ptr<PipelineOptions>& options,
std::unique_ptr<PlatformExtraBundleHolder> holder,
bool has_layout) override {}
Expand Down
4 changes: 3 additions & 1 deletion core/renderer/ui_wrapper/layout/layout_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,11 @@ void LayoutContext::UpdateLayoutInfo(LayoutNode* node) {
}
}

bool display_none = sl_node->GetShouldDisplayNone();
delegate_->OnLayoutUpdate(
node->id(), left, top, width, height, paddings, margins, borders,
sticky_positions, sl_node->GetCSSStyle()->GetMaxHeight().GetRawValue());
sticky_positions, sl_node->GetCSSStyle()->GetMaxHeight().GetRawValue(),
display_none);

if (node->slnode()->GetSLMeasureFunc()) {
// Dispatch OnLayoutAfter to those nodes that have custom measure
Expand Down
2 changes: 1 addition & 1 deletion core/renderer/ui_wrapper/layout/layout_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class LayoutContext : public std::enable_shared_from_this<LayoutContext>,
const std::array<float, 4>& margins,
const std::array<float, 4>& borders,
const std::array<float, 4>* sticky_positions,
float max_height) = 0;
float max_height, bool display_none) = 0;
void OnLayoutAfter(const std::shared_ptr<PipelineOptions>& options) {
OnLayoutAfter(options, nullptr, false);
};
Expand Down
11 changes: 7 additions & 4 deletions core/shell/layout_mediator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ void LayoutMediator::OnLayoutUpdate(
int tag, float x, float y, float width, float height,
const std::array<float, 4> &paddings, const std::array<float, 4> &margins,
const std::array<float, 4> &borders,
const std::array<float, 4> *sticky_positions, float max_height) {
const std::array<float, 4> *sticky_positions, float max_height,
bool display_none) {
std::array<float, 4> sticky_positions_clone;
bool has_sticky = false;
if (sticky_positions) {
Expand All @@ -43,15 +44,17 @@ void LayoutMediator::OnLayoutUpdate(
if (node_manager_ != nullptr) {
operation_queue_->EnqueueOperation(
[node_manager = node_manager_, tag, x, y, width, height, paddings,
margins, borders, sticky_positions_clone, has_sticky, max_height]() {
margins, borders, sticky_positions_clone, has_sticky, max_height,
display_none]() {
auto *node = node_manager->Get(tag);
if (node != nullptr) {
if (has_sticky) {
node->UpdateLayout(x, y, width, height, paddings, margins,
borders, &sticky_positions_clone, max_height);
borders, &sticky_positions_clone, max_height,
display_none);
} else {
node->UpdateLayout(x, y, width, height, paddings, margins,
borders, nullptr, max_height);
borders, nullptr, max_height, display_none);
}
} else {
LOGE(
Expand Down
2 changes: 1 addition & 1 deletion core/shell/layout_mediator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LayoutMediator : public tasm::LayoutContext::Delegate,
const std::array<float, 4> &margins,
const std::array<float, 4> &borders,
const std::array<float, 4> *sticky_positions,
float max_height) override;
float max_height, bool display_none) override;
void OnLayoutAfter(const std::shared_ptr<tasm::PipelineOptions> &option,
std::unique_ptr<tasm::PlatformExtraBundleHolder> holder,
bool has_layout) override;
Expand Down
2 changes: 1 addition & 1 deletion core/shell/testing/mock_layout_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MockLayoutDelegate : public LayoutContext::Delegate {
const std::array<float, 4>& margins,
const std::array<float, 4>& borders,
const std::array<float, 4>* sticky_positions,
float max_height) override {}
float max_height, bool /*display_none*/) override {}
void PostPlatformExtraBundle(
int32_t id, std::unique_ptr<tasm::PlatformExtraBundle> bundle) override {}
void OnCalculatedViewportChanged(const CalculatedViewport& viewport,
Expand Down
Loading