Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d2c22029e468944bffdf230921dab80d5c7bfb83
      
https://github.com/WebKit/WebKit/commit/d2c22029e468944bffdf230921dab80d5c7bfb83
  Author: Kiet Ho <[email protected]>
  Date:   2026-04-13 (Mon, 13 Apr 2026)

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

  Log Message:
  -----------
  [css-anchor-position-1] Replace AnchorPositionedKey with WeakStyleable
https://bugs.webkit.org/show_bug.cgi?id=311690

Reviewed by Antti Koivisto.

Many HashMaps use AnchorPositionedKey as the hash key of anchor-positioned
elements. The key includes an Element pointer and an optional pseudo-element
identifier - identical to a Styleable, but it can be used as a hash key
(Styleable is not hash-key-able).

Now that 307912@main added hashing support for WeakStyleable (a variation of
Styleable that holds a weak pointer to the Element), this patch replaces
AnchorPositionedKey with Styleable.

There're some remaining places where anchor-positioned elements are represented
by their Element pointer, which will get in the way of supporting more
anchor-positioned pseudo elements beside ::before/::after. This will be fixed in
later patches.

Tested by the existing anchor positioning test suite.

* Source/WebCore/style/AnchorPositionEvaluator.cpp:
(WebCore::Style::AnchorPositionEvaluator::findAnchorForAnchorFunctionAndAttemptResolution):
(WebCore::Style::AnchorPositionEvaluator::updateAnchorPositioningStatesAfterInterleavedLayout):
(WebCore::Style::AnchorPositionEvaluator::updateAnchorPositionedStateForDefaultAnchorAndPositionVisibility):
(WebCore::Style::AnchorPositionEvaluator::makeAnchorPositionedForAnchorMap):
(WebCore::Style::AnchorPositionEvaluator::defaultAnchorForBox):
(WebCore::Style::AnchorPositionEvaluator::recordLastSuccessfulPositionOptions):
(WebCore::Style::AnchorPositionEvaluator::keyForElementOrPseudoElement): 
Deleted.
* Source/WebCore/style/AnchorPositionEvaluator.h:
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::lastSuccessfulPositionOptionIndexFor):
(WebCore::Style::Scope::setLastSuccessfulPositionOptionIndexMap):
(WebCore::Style::Scope::forgetLastSuccessfulPositionOptionIndex):
* Source/WebCore/style/StyleScope.h:
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resetStyleForNonRenderedDescendants):
(WebCore::Style::TreeResolver::resolve):
(WebCore::Style::TreeResolver::generatePositionOptionsIfNeeded):
(WebCore::Style::TreeResolver::tryChoosePositionOption):
(WebCore::Style::TreeResolver::updateForPositionVisibility):
(WebCore::Style::TreeResolver::hasUnresolvedAnchorPosition const):
(WebCore::Style::TreeResolver::hasResolvedAnchorPosition const):
(WebCore::Style::TreeResolver::isTryingPositionOption const):
* Source/WebCore/style/StyleTreeResolver.h:

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



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

Reply via email to