[webkit-changes] [WebKit/WebKit] 778c00: Use `LayoutUnit::fromRawValue` more in `LayoutUnit...

Ahmad Saleem noreply at github.com
Fri Jan 17 00:39:20 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 778c00cc651d4811b2137f2bade7849ca04017e1
      https://github.com/WebKit/WebKit/commit/778c00cc651d4811b2137f2bade7849ca04017e1
  Author: Ahmad Saleem <ahmad.saleem792+github at gmail.com>
  Date:   2025-01-17 (Fri, 17 Jan 2025)

  Changed paths:
    M Source/WebCore/platform/LayoutUnit.h

  Log Message:
  -----------
  Use `LayoutUnit::fromRawValue` more in `LayoutUnit.h` and other fixes

https://bugs.webkit.org/show_bug.cgi?id=285362
rdar://142330759

Reviewed by Antti Koivisto.

Inspired by: https://source.chromium.org/chromium/chromium/src/+/6477aa568ab9445ef2c5cb1314e237c8c8faeb4c,
https://source.chromium.org/chromium/chromium/src/+/54c3bf5d8173d5e11a32cfcb088cf85c818e992a and
https://source.chromium.org/chromium/chromium/src/+/e22d0d6c01c78bfa7362f9bc57eb4a46256c69ff

This patch leverages `fromRawValue` throughout code to reduce duplicate pattern
and it also brings consistency of `static constexpr` throughout code.

Only two function which are made `constexpr` are `epsilon` and `fromRawValue`.

Additionally, it makes four global variables `inline constexpr` as well to take single
copy by using C++17 inline variables.

* Source/WebCore/platform/LayoutUnit.h:
(WebCore::LayoutUnit::fromFloatCeil):
(WebCore::LayoutUnit::fromFloatFloor):
(WebCore::LayoutUnit::fromRawValue):
(WebCore::LayoutUnit::abs const):
(WebCore::LayoutUnit::fraction const):
(WebCore::LayoutUnit::epsilon):
(WebCore::LayoutUnit::max):
(WebCore::LayoutUnit::min):
(WebCore::LayoutUnit::nearlyMax):
(WebCore::LayoutUnit::nearlyMin):
(WebCore::boundedMultiply):
(WebCore::operator/):
(WebCore::operator+):
(WebCore::operator-):
(WebCore::intMod):
(WebCore::operator%):
(WTF::HashTraits<WebCore::LayoutUnit>::emptyValue):

Canonical link: https://commits.webkit.org/289048@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