Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c2a26696cc420b4c9c925cdf6b1a2afa122dc9a8
      
https://github.com/WebKit/WebKit/commit/c2a26696cc420b4c9c925cdf6b1a2afa122dc9a8
  Author: Kiet Ho <[email protected]>
  Date:   2026-08-07 (Fri, 07 Aug 2026)

  Changed paths:
    M Source/WebCore/style/AnchorPositionEvaluator.cpp
    M Source/WebCore/style/AnchorPositionEvaluator.h

  Log Message:
  -----------
  [css-anchor-position] Refactor how position-anchor: none and normal work
rdar://183590606
https://bugs.webkit.org/show_bug.cgi?id=320625

Reviewed by Antti Koivisto.

position-anchor: none makes an element not have a default anchor, while
position-anchor: normal gives it a default anchor (the implicit anchor)
if it uses position-area.

A natural place to implement this is AnchorPositionEvaluator::defaultAnchorName,
which determines the name of the default anchor name. Instead, the current code
doesn't touch defaultAnchorName at all - elements that should not have a default
anchor are still given the implicit anchor as the default anchor. Then, in
findAnchorForAnchorFunctionAndAttemptResolution, we reject resolving the 
implicit
anchor if the element shouldn't have a default anchor.

This patch moves the implementation to defaultAnchorName - it now returns 
std::nullopt
if the element doesn't have a default anchor. Its callers got fixed up to deal 
with
it returning std::nullopt.

Refactoring, tested by existing test suite.

* Source/WebCore/style/AnchorPositionEvaluator.cpp:
(WebCore::Style::AnchorPositionEvaluator::findAnchorForAnchorFunctionAndAttemptResolution):
(WebCore::Style::findAnchorsForAnchorPositionedElement):
(WebCore::Style::AnchorPositionEvaluator::updateAnchorPositioningStatesAfterInterleavedLayout):
(WebCore::Style::AnchorPositionEvaluator::updateAnchorPositionedStateForDefaultAnchorAndPositionVisibility):
(WebCore::Style::AnchorPositionEvaluator::defaultAnchorName):
(WebCore::Style::AnchorPositionEvaluator::defaultAnchorForBox):
* Source/WebCore/style/AnchorPositionEvaluator.h:

Canonical link: https://commits.webkit.org/318823@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to