srctree

Robin Linden parent c08bd96b 389013cf
all: Fix identifier naming style violations

inlinesplit
browser/gui/app.cpp added: 52, removed: 48, total 4
@@ -156,15 +156,15 @@ void App::set_scale(unsigned scale) {
scale_ = scale;
ImGui::GetIO().FontGlobalScale = static_cast<float>(scale_);
canvas_->set_scale(scale_);
auto windowSize = window_.getSize();
auto window_size = window_.getSize();
 
// Only resize the window if the user hasn't resized it.
if (windowSize.x == kDefaultResolutionX && windowSize.y == kDefaultResolutionY) {
if (window_size.x == kDefaultResolutionX && window_size.y == kDefaultResolutionY) {
window_.setSize({kDefaultResolutionX * scale_, kDefaultResolutionY * scale_});
canvas_->set_viewport_size(window_.getSize().x, window_.getSize().y);
}
 
engine_.set_layout_width(windowSize.x / scale_);
engine_.set_layout_width(window_size.x / scale_);
}
 
int App::run() {
 
css/parser.h added: 52, removed: 48, total 4
@@ -144,46 +144,46 @@ private:
std::size_t pos = 0, loc = 0;
while ((loc = str.find(delimiter, pos)) != std::string_view::npos) {
if (auto substr = str.substr(pos, loc - pos); !substr.empty()) {
tokens.push_back(substr);
tokens_.push_back(substr);
}
pos = loc + 1;
}
if (pos < str.size()) {
tokens.push_back(str.substr(pos));
tokens_.push_back(str.substr(pos));
}
token_iter = cbegin(tokens);
token_iter_ = cbegin(tokens_);
}
 
std::optional<std::string_view> get() const {
if (empty()) {
return std::nullopt;
} else {
return *token_iter;
return *token_iter_;
}
}
 
std::optional<std::string_view> peek() const {
if (empty() || ((token_iter + 1) == cend(tokens))) {
if (empty() || ((token_iter_ + 1) == cend(tokens_))) {
return std::nullopt;
} else {
return *(token_iter + 1);
return *(token_iter_ + 1);
}
}
 
Tokenizer &next() {
if (!empty()) {
++token_iter;
++token_iter_;
}
return *this;
}
 
bool empty() const { return token_iter == cend(tokens); }
bool empty() const { return token_iter_ == cend(tokens_); }
 
std::size_t size() const { return tokens.size(); }
std::size_t size() const { return tokens_.size(); }
 
private:
std::vector<std::string_view> tokens;
std::vector<std::string_view>::const_iterator token_iter;
std::vector<std::string_view> tokens_;
std::vector<std::string_view>::const_iterator token_iter_;
};
 
constexpr void skip_if_neq(char c) {
 
etest/cxx_compat.h added: 52, removed: 48, total 4
@@ -17,6 +17,8 @@ using source_location = std::source_location;
 
#include <cstdint>
namespace etest {
// https://en.cppreference.com/w/cpp/utility/source_location
// NOLINTNEXTLINE(readability-identifier-naming)
struct source_location {
static constexpr source_location current() noexcept { return source_location{}; }
constexpr std::uint_least32_t line() const noexcept { return 0; }
 
etest/etest.cpp added: 52, removed: 48, total 4
@@ -34,7 +34,7 @@ Registry &registry() {
return test_registry;
}
 
struct test_failure : public std::exception {};
struct TestFailure : public std::exception {};
 
std::stringstream test_log{};
 
@@ -70,7 +70,7 @@ int run_all_tests(RunOptions const &opts) noexcept {
 
try {
test.body();
} catch (test_failure const &) {
} catch (TestFailure const &) {
++assertion_failures;
} catch (std::exception const &e) {
++assertion_failures;
@@ -131,7 +131,7 @@ void require(bool b, std::optional<std::string_view> log_message, etest::source_
test_log << *log_message << "\n\n";
}
 
throw test_failure{};
throw TestFailure{};
}
 
} // namespace etest
 
gfx/opengl_canvas.cpp added: 52, removed: 48, total 4
@@ -23,7 +23,7 @@ void OpenGLCanvas::set_viewport_size(int width, int height) {
}
 
void OpenGLCanvas::fill_rect(geom::Rect const &rect, Color color) {
auto translated{rect.translated(translation_x, translation_y)};
auto translated{rect.translated(translation_x_, translation_y_)};
auto scaled{translated.scaled(scale_)};
glColor4ub(color.r, color.g, color.b, color.a);
glRecti(scaled.x, scaled.y, scaled.x + scaled.width, scaled.y + scaled.height);
 
gfx/opengl_canvas.h added: 52, removed: 48, total 4
@@ -17,8 +17,8 @@ public:
constexpr void set_scale(int scale) override { scale_ = scale; }
 
constexpr void add_translation(int dx, int dy) override {
translation_x += dx;
translation_y += dy;
translation_x_ += dx;
translation_y_ += dy;
}
 
void fill_rect(geom::Rect const &, Color) override;
@@ -27,8 +27,8 @@ public:
void draw_text(geom::Position, std::string_view, Font, FontSize, FontStyle, Color) override {}
 
private:
int translation_x{};
int translation_y{};
int translation_x_{};
int translation_y_{};
int scale_{1};
};
 
 
style/style.cpp added: 52, removed: 48, total 4
@@ -23,9 +23,9 @@ bool has_class(dom::Element const &element, std::string_view needle_class) {
} // namespace
 
// TODO(robinlinden): This needs to match more things.
bool is_match(dom::Element const &element, std::string_view selector_) {
bool is_match(dom::Element const &element, std::string_view selector) {
// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
auto [selector, psuedo_class] = util::split_once(selector_, ":");
auto [selector_, psuedo_class] = util::split_once(selector, ":");
 
if (!psuedo_class.empty()) {
// https://developer.mozilla.org/en-US/docs/Web/CSS/:any-link
@@ -41,7 +41,7 @@ bool is_match(dom::Element const &element, std::string_view selector_) {
return false;
}
 
if (selector.empty()) {
if (selector_.empty()) {
return true;
}
} else {
@@ -51,22 +51,22 @@ bool is_match(dom::Element const &element, std::string_view selector_) {
}
 
// https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors
if (selector == "*") {
if (selector_ == "*") {
return true;
}
 
if (element.name == selector) {
if (element.name == selector_) {
return true;
}
 
if (selector.starts_with('.')) {
selector.remove_prefix(1);
return has_class(element, selector);
if (selector_.starts_with('.')) {
selector_.remove_prefix(1);
return has_class(element, selector_);
}
 
if (selector.starts_with('#') && element.attributes.contains("id")) {
selector.remove_prefix(1);
return element.attributes.at("id") == selector;
if (selector_.starts_with('#') && element.attributes.contains("id")) {
selector_.remove_prefix(1);
return element.attributes.at("id") == selector_;
}
 
return false;
 
uri/uri_fuzz_test.cpp added: 52, removed: 48, total 4
@@ -9,7 +9,7 @@
#include <string>
#include <tuple>
 
extern "C" int LLVMFuzzerTestOneInput(uint8_t const *data, size_t size);
extern "C" int LLVMFuzzerTestOneInput(uint8_t const *data, size_t size); // NOLINT
 
extern "C" int LLVMFuzzerTestOneInput(uint8_t const *data, size_t size) {
std::ignore = uri::Uri::parse(std::string{reinterpret_cast<char const *>(data), size});
 
url/url_test.cpp added: 52, removed: 48, total 4
@@ -13,7 +13,7 @@
 
int main() {
etest::test("blob URL generation", [] {
std::string REGEX_UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
std::string regex_uuid = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
 
url::Host h = {url::HostType::DnsDomain, "example.com"};
url::Origin o = {"https", h, std::uint16_t{8080}, std::nullopt, false};
@@ -21,7 +21,7 @@ int main() {
std::string blob = url::blob_url_create(o);
std::cout << "Generated Blob URL: " << blob << std::endl;
 
etest::expect(std::regex_match(blob, std::regex("blob:https://example.com:8080/" + REGEX_UUID)));
etest::expect(std::regex_match(blob, std::regex("blob:https://example.com:8080/" + regex_uuid)));
 
h = url::Host{url::HostType::Ip4Addr, std::uint32_t{134744072}};
o = {"https", h, std::uint16_t{8080}, std::nullopt, false};
@@ -29,7 +29,7 @@ int main() {
blob = url::blob_url_create(o);
std::cout << "Generated Blob URL: " << blob << std::endl;
 
etest::expect(std::regex_match(blob, std::regex("blob:https://8.8.8.8:8080/" + REGEX_UUID)));
etest::expect(std::regex_match(blob, std::regex("blob:https://8.8.8.8:8080/" + regex_uuid)));
 
std::array<uint16_t, 8> v6 = {0x2001, 0xdb8, 0x85a3, 0, 0, 0x8a2e, 0x370, 0x7334};
h = url::Host{url::HostType::Ip6Addr, v6};
@@ -39,7 +39,7 @@ int main() {
std::cout << "Generated Blob URL: " << blob;
 
etest::expect(std::regex_match(
blob, std::regex("blob:https://\\[2001:db8:85a3::8a2e:370:7334\\]:8080/" + REGEX_UUID)));
blob, std::regex("blob:https://\\[2001:db8:85a3::8a2e:370:7334\\]:8080/" + regex_uuid)));
});
 
return etest::run_all_tests();
 
util/generator.h added: 52, removed: 48, total 4
@@ -17,6 +17,8 @@ namespace util {
template<std::movable T>
class Generator {
public:
// https://en.cppreference.com/w/cpp/coroutine/coroutine_traits
// NOLINTNEXTLINE(readability-identifier-naming)
struct promise_type {
std::optional<T> maybe_value;