[webkit-changes] [WebKit/WebKit] 0c3876: Remove redundant code from RenderBox::hasTrimmedMa...

Sammy Gill noreply at github.com
Thu Apr 6 13:55:24 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0c3876d9cb24a6f50f694d4e7ba5f8f4512ca0b7
      https://github.com/WebKit/WebKit/commit/0c3876d9cb24a6f50f694d4e7ba5f8f4512ca0b7
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2023-04-06 (Thu, 06 Apr 2023)

  Changed paths:
    M Source/WebCore/rendering/RenderBox.cpp

  Log Message:
  -----------
  Remove redundant code from RenderBox::hasTrimmedMargin(PhysicalDirection)
https://bugs.webkit.org/show_bug.cgi?id=255098
rdar://problem/107713529

Reviewed by Brent Fulgham.

RenderBox::hasTrimmedMargin is a overloaded function with two versions
that take in either a PhysicalDirection or std::optional<MarginTrimType>.
The version that takes in a PhysicalDirection simply maps the argument
to a MarginTrimType and then calls the other to perform the actual logic.

They both have the same pieces of debug code as well as an !isInFlow()
check. It is unnecessary to have this code in the PhysicalDirection one
since all it does it map the argument to a different type and then
call the other. The only benefit to this is that it would either trigger
a debug assert or return false earlier, but it also becomes tedious to
keep both versions in sync as more margin-trim patches are landed. It
increases the likelihood that one version would get some logic added in
a patch but would get missed in the other.

To address this we can just remove this shared code from the version
that takes in a PhysicalDirection and just keep it in the other. Now
the only time this function will change is when we add logic for it
to take in another value of PhysicalDirection.

* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::hasTrimmedMargin const):

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




More information about the webkit-changes mailing list