Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new children/descendants api as well as deeper element queries to ElementHandle #5433

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tronical
Copy link
Member

No description provided.

@tronical tronical requested a review from ogoffart June 19, 2024 12:51
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should visit_element be removed. It is a bit redundent since you can do HasElementHandle::root_element(component).visit_descendants

(the only difference is that it visits the root)

@@ -312,21 +313,30 @@ impl ItemRc {
r.upgrade()?.parent_item()
}

// FIXME: This should be nicer/done elsewhere?
/// Returns true if this item is visible from the root of the item tree. Note that this will return
/// false for `Clip` elements, even if they are "visible".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it? All Clip elements? Why is that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something (I tried to cover that also in the test I added in search_api.rs), but the old code did this:

    pub fn is_visible(&self) -> bool {
        let item = self.borrow();
        let is_clipping = crate::item_rendering::is_clipping_item(item);
        let geometry = self.geometry();
        if is_clipping && (geometry.width() <= 0.01 as _ || geometry.height() <= 0.01 as _) {
            return false;
        }
        if let Some(parent) = self.parent_item() {
            parent.is_visible()
        } else {
            true
        }
    }

That suggests to me that is_clipping_item() returns true for Clip elements that are enabled for clipping (clip true) and the visible pass gives them the null width/height. So I think that'll return false.

The new code should return an empty clip rectangle from the call to absolute_clip_rect_and_geometry because of this:

      if crate::item_rendering::is_clipping_item(item) {
            clip = geometry.intersection(&clip).unwrap_or_default();
        }

And then the intersection of itself should be empty.

Should I add a direct unit test in here perhaps?

internal/backends/testing/search_api.rs Outdated Show resolved Hide resolved
@tronical
Copy link
Member Author

Should visit_element be removed. It is a bit redundent since you can do HasElementHandle::root_element(component).visit_descendants

(the only difference is that it visits the root)

Yes, I'm in favor of that - if you're okay with the rest of this API. I'd make that a separate change though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants