Skip to content

Conversation

EndlessJour9527
Copy link
Collaborator

@EndlessJour9527 EndlessJour9527 commented Sep 6, 2025

Added hasHitTestableOverflow(): Detects overflow:visible cases where any child box’s physical border box extends beyond the parent’s border box.
Updated mayIntersect(): When overflow is visible and children overflow, builds a union AABB of the parent and child boxes (applies accumulatedOffset) and ray-tests that instead of clipping to the parent.

The element is positioned according to the Normal Flow of the document. The top, right, bottom, left, and z-index properties have no effect. This is the default value.

Copilot

This comment was marked as outdated.

@yorkie
Copy link
Collaborator

yorkie commented Sep 9, 2025

@EndlessJour9527 Please describe what issues to be fixed in this pull request.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances hit testing for layout boxes by implementing proper overflow handling for elements with overflow: visible. The implementation detects when child elements extend beyond their parent's border box and adjusts hit testing to include these overflowing children.

Key changes:

  • Added hit-testable overflow detection logic to identify when children extend beyond parent boundaries
  • Modified hit testing to use union bounding boxes for overflow cases instead of clipping to parent bounds
  • Fixed static positioning to properly handle auto inset values in CSS computed styles

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/client/layout/layout_box.cpp Implements hasHitTestableOverflow() and updates mayIntersect() with overflow-aware hit testing logic
src/client/cssom/computed_style.cpp Fixes static positioning by setting auto inset values when position is static
fixtures/html/dom/document_hittest_overflow.html Adds comprehensive test fixture for overflow hit testing scenarios

if (!child->isBox())
continue; // Only element (box) children can produce overflow boxes here.

auto childBox = std::dynamic_pointer_cast<LayoutBox>(child);
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The code performs a std::dynamic_pointer_cast after already checking child->isBox(). Since isBox() should guarantee the child can be cast to LayoutBox, consider using std::static_pointer_cast for better performance, or restructure to avoid the redundant cast.

Suggested change
auto childBox = std::dynamic_pointer_cast<LayoutBox>(child);
auto childBox = std::static_pointer_cast<LayoutBox>(child);

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Other locations apply "dynamic_pointer_cast" why.

layoutStyle.setRight(inset_.right().toLayoutValue());
layoutStyle.setBottom(inset_.bottom().toLayoutValue());
layoutStyle.setLeft(inset_.left().toLayoutValue());
if (position_type_.isStatic())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does taffy not handle this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please provide some information indicating that taffy does not handle this?
Then, if taffy indeed confirms it doesn’t handle it, I think we should add this logic here
, rather than inside the ComputedStyle class.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

display: block;
}

/* FIX hover selector (removed space) */
Copy link
Preview

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

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

Remove the TODO-style comment /* FIX hover selector (removed space) */ as it appears to describe a completed fix rather than documenting the current code.

Suggested change
/* FIX hover selector (removed space) */

Copilot uses AI. Check for mistakes.

layoutStyle.setRight(inset_.right().toLayoutValue());
layoutStyle.setBottom(inset_.bottom().toLayoutValue());
layoutStyle.setLeft(inset_.left().toLayoutValue());
if (position_type_.isStatic())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please provide some information indicating that taffy does not handle this?
Then, if taffy indeed confirms it doesn’t handle it, I think we should add this logic here
, rather than inside the ComputedStyle class.

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.

3 participants