mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
Everywhere: Remove LibCore/System.h includes from header files
This reduces the number of compilation jobs when System.h changes from about 750 to 60. (There are still a large number of linker jobs.)
This commit is contained in:
parent
58b32814e0
commit
674075f79e
Notes:
github-actions[bot]
2025-12-04 15:42:18 +00:00
Author: https://github.com/trflynn89
Commit: 674075f79e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7019
Reviewed-by: https://github.com/AtkinsSJ ✅
19 changed files with 155 additions and 97 deletions
|
|
@ -592,6 +592,8 @@ set(SOURCES
|
|||
HTML/NavigationTransition.cpp
|
||||
HTML/Navigator.cpp
|
||||
HTML/NavigatorBeacon.cpp
|
||||
HTML/NavigatorConcurrentHardware.cpp
|
||||
HTML/NavigatorDeviceMemory.cpp
|
||||
HTML/NavigatorID.cpp
|
||||
HTML/Numbers.cpp
|
||||
HTML/OffscreenCanvas.cpp
|
||||
|
|
|
|||
19
Libraries/LibWeb/HTML/NavigatorConcurrentHardware.cpp
Normal file
19
Libraries/LibWeb/HTML/NavigatorConcurrentHardware.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/System.h>
|
||||
#include <LibWeb/HTML/NavigatorConcurrentHardware.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#dom-navigator-hardwareconcurrency
|
||||
WebIDL::UnsignedLongLong NavigatorConcurrentHardwareMixin::hardware_concurrency()
|
||||
{
|
||||
return Core::System::hardware_concurrency();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,15 +7,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/System.h>
|
||||
#include <LibWeb/WebIDL/Types.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class NavigatorConcurrentHardwareMixin {
|
||||
public:
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#dom-navigator-hardwareconcurrency
|
||||
static WebIDL::UnsignedLongLong hardware_concurrency() { return Core::System::hardware_concurrency(); }
|
||||
static WebIDL::UnsignedLongLong hardware_concurrency();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
34
Libraries/LibWeb/HTML/NavigatorDeviceMemory.cpp
Normal file
34
Libraries/LibWeb/HTML/NavigatorDeviceMemory.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibWeb/HTML/NavigatorDeviceMemory.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://www.w3.org/TR/device-memory/#computing-device-memory-value
|
||||
WebIDL::Double NavigatorDeviceMemoryMixin::device_memory() const
|
||||
{
|
||||
// The value is calculated by using the actual device memory in MiB then rounding it to the nearest number where
|
||||
// only the most significant bit can be set and the rest are zeros (nearest power of two).
|
||||
auto memory_in_bytes = Core::System::physical_memory_bytes();
|
||||
auto memory_in_mib = memory_in_bytes / MiB;
|
||||
auto required_bits = AK::count_required_bits(memory_in_mib);
|
||||
auto lower_memory_in_mib = static_cast<u64>(1) << (required_bits - 1);
|
||||
auto upper_memory_in_mib = static_cast<u64>(1) << required_bits;
|
||||
auto rounded_memory_in_mib = upper_memory_in_mib - memory_in_mib <= memory_in_mib - lower_memory_in_mib
|
||||
? upper_memory_in_mib
|
||||
: lower_memory_in_mib;
|
||||
|
||||
// Then dividing that number by 1024.0 to get the value in GiB.
|
||||
auto memory_in_gib = static_cast<WebIDL::Double>(rounded_memory_in_mib) / 1024.0;
|
||||
|
||||
// An upper bound and a lower bound should be set on the list of values.
|
||||
return AK::clamp(memory_in_gib, 1.0, 4.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,35 +6,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibWeb/WebIDL/Types.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class NavigatorDeviceMemoryMixin {
|
||||
public:
|
||||
// https://www.w3.org/TR/device-memory/#computing-device-memory-value
|
||||
WebIDL::Double device_memory() const
|
||||
{
|
||||
// The value is calculated by using the actual device memory in MiB then rounding it to the
|
||||
// nearest number where only the most significant bit can be set and the rest are zeros
|
||||
// (nearest power of two).
|
||||
auto memory_in_bytes = Core::System::physical_memory_bytes();
|
||||
auto memory_in_mib = memory_in_bytes / MiB;
|
||||
auto required_bits = AK::count_required_bits(memory_in_mib);
|
||||
auto lower_memory_in_mib = static_cast<u64>(1) << (required_bits - 1);
|
||||
auto upper_memory_in_mib = static_cast<u64>(1) << required_bits;
|
||||
auto rounded_memory_in_mib = upper_memory_in_mib - memory_in_mib <= memory_in_mib - lower_memory_in_mib
|
||||
? upper_memory_in_mib
|
||||
: lower_memory_in_mib;
|
||||
|
||||
// Then dividing that number by 1024.0 to get the value in GiB.
|
||||
auto memory_in_gib = static_cast<WebIDL::Double>(rounded_memory_in_mib) / 1024.0;
|
||||
|
||||
// An upper bound and a lower bound should be set on the list of values.
|
||||
return AK::clamp(memory_in_gib, 1.0, 4.0);
|
||||
}
|
||||
WebIDL::Double device_memory() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/MimeData.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGC/Function.h>
|
||||
#include <LibRequests/Request.h>
|
||||
#include <LibRequests/RequestClient.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue