[webkit-changes] [WebKit/WebKit] df707c: Refactor Editing's areIdenticalElements() as eleme...

Anne van Kesteren noreply at github.com
Tue Feb 6 11:24:03 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: df707c11ddceb52503936158c809c278a977e700
      https://github.com/WebKit/WebKit/commit/df707c11ddceb52503936158c809c278a977e700
  Author: Anne van Kesteren <annevk at annevk.nl>
  Date:   2024-02-06 (Tue, 06 Feb 2024)

  Changed paths:
    M Source/WebCore/editing/ApplyStyleCommand.cpp
    M Source/WebCore/editing/Editing.cpp
    M Source/WebCore/editing/Editing.h
    M Source/WebCore/editing/ReplaceSelectionCommand.cpp

  Log Message:
  -----------
  Refactor Editing's areIdenticalElements() as elementIfEquivalent() to reduce downcasting
https://bugs.webkit.org/show_bug.cgi?id=268761

Reviewed by Chris Dumez.

This moves some logic out of the function which results in some
additional work for callers that is hopefully offset by no longer
having to downcast several times overall.

The second argument of elementIfEquivalent() is no longer const as that
would require the return value to be const which poses a problem for
algorithms that return value is passed on to, such as
mergeIdenticalElements().

* Source/WebCore/editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::mergeStartWithPreviousIfIdentical):
(WebCore::ApplyStyleCommand::mergeEndWithNextIfIdentical):
(WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
* Source/WebCore/editing/Editing.cpp:
(WebCore::elementIfEquivalent):
(WebCore::areIdenticalElements): Deleted.
* Source/WebCore/editing/Editing.h:
* Source/WebCore/editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):

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




More information about the webkit-changes mailing list