[webkit-changes] [WebKit/WebKit] 5eaa13: [css-anchor-position-1] Allow access to more ancho...

David Choi noreply at github.com
Fri Aug 16 17:43:44 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5eaa137f32aed6b384292f1a40318d3037b6b12a
      https://github.com/WebKit/WebKit/commit/5eaa137f32aed6b384292f1a40318d3037b6b12a
  Author: David Choi <davidchoi1027 at gmail.com>
  Date:   2024-08-16 (Fri, 16 Aug 2024)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-name-in-shadow-002-expected.txt
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/dom/Element.h
    M Source/WebCore/style/AnchorPositionEvaluator.cpp
    M Source/WebCore/style/StyleTreeResolver.cpp

  Log Message:
  -----------
  [css-anchor-position-1] Allow access to more anchor targets
https://bugs.webkit.org/show_bug.cgi?id=278237
rdar://134067014

Reviewed by Alan Baradlay.

The way we mark an anchor element as an eligible target for anchor-positioned
elements is by maintaining an `anchorsForAnchorName` map. (It maps anchor-names
to an array of anchor elements with that name.) In each style resolution round,
this map is cleared and rebuilt while traversing the flat tree. As a result,
this does not allow anchor-positioned elements to "see" anchor elements that
come after it in tree order.

This patch does not clear that `anchorsForAnchorName` map during each style
round. This allows anchor-positioned elements to essentially "see" all
anchors in the flat tree. To ensure that non-relevant anchors for an
anchor-positioned element are excluded from consideration, more logic was
added to the `isAcceptableAnchorElement` function.

Note that this patch does not completely ensure that all valid anchor targets
are considered for a particular anchor-positioned element. This is because
anchor-positioned elements are resolved in tree order, when they should be
resolved in a different order to ensure we don't miss anchor targets that
are descendants of query containers or other anchor-positioned elements.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-name-in-shadow-002-expected.txt:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::invalidateAncestorsForAnchor): Deleted.
* Source/WebCore/dom/Element.h:
* Source/WebCore/style/AnchorPositionEvaluator.cpp:
(WebCore::Style::penultimateContainingBlockChainElement):
(WebCore::Style::firstChildPrecedesSecondChild):
(WebCore::Style::isAcceptableAnchorElement):
(WebCore::Style::findLastAcceptableAnchorWithName):
(WebCore::Style::elementIsInContainingBlockChain): Deleted.
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolve):
(WebCore::Style::TreeResolver::updateAnchorPositioningState):

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



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


More information about the webkit-changes mailing list