[webkit-changes] [WebKit/WebKit] fab917: Reduce the amount of SVGElement::updateRelativeLen...

Chris Dumez noreply at github.com
Thu Aug 31 13:59:45 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fab91723ea6b142820bc5c7186672e122391f272
      https://github.com/WebKit/WebKit/commit/fab91723ea6b142820bc5c7186672e122391f272
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2023-08-31 (Thu, 31 Aug 2023)

  Changed paths:
    M Source/WebCore/svg/SVGElement.cpp

  Log Message:
  -----------
  Reduce the amount of SVGElement::updateRelativeLengthsInformation() calls
https://bugs.webkit.org/show_bug.cgi?id=260971

Reviewed by Ryosuke Niwa.

Reduce the amount of SVGElement::updateRelativeLengthsInformation() calls.

In SVGElement::removedFromAncestor(), if `removalType.disconnectedFromDocument`
was true, we would call `updateRelativeLengthsInformation(false, *this)` to remove
the element from m_elementsWithRelativeLengths and from our ancestor's map.

However, when SVGElement::removedFromAncestor() gets called, we know that
the element either doesn't have a parent or that it's parent is not connected
(I added an assertion to this effect). As a result, recursively calling
`updateRelativeLengthsInformation(false, element)` on the ancestors had no
effect, since the function would early return at the `!isConnected()` check.

As a result, it is sufficient to clear m_elementsWithRelativeLengths in
SVGElement::removedFromAncestor(), without calling
`updateRelativeLengthsInformation(false, *this)` or worrying about the
ancestors.

* Source/WebCore/svg/SVGElement.cpp:
(WebCore::SVGElement::removedFromAncestor):

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




More information about the webkit-changes mailing list