summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-11-18 19:26:40 +0000
committerAndreas Kling <kling@serenityos.org>2021-11-18 21:11:19 +0100
commitd106f20a7325860d5fa95f607aae1f28ed8fa588 (patch)
tree8d0f52ea1ecc9126a748904a7adc4d7d321b0070 /Userland
parent60867703c0a450787c486353f4b819e0dc5b3a68 (diff)
downloadserenity-d106f20a7325860d5fa95f607aae1f28ed8fa588.zip
LibWeb: Delete CSSLoader
All CSS loading is now done by the relevant classes: - CSSImportRule, which loads its linked stylesheet - HTMLStyleElement, which "loads" its contents - HTMLLinkElement, which loads its linked stylesheet
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibWeb/Loader/CSSLoader.cpp75
-rw-r--r--Userland/Libraries/LibWeb/Loader/CSSLoader.h41
3 files changed, 0 insertions, 117 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index e48b7a7ed9..a81b293ce5 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -232,7 +232,6 @@ set(SOURCES
Layout/TableRowGroupBox.cpp
Layout/TextNode.cpp
Layout/TreeBuilder.cpp
- Loader/CSSLoader.cpp
Loader/ContentFilter.cpp
Loader/FrameLoader.cpp
Loader/ImageLoader.cpp
diff --git a/Userland/Libraries/LibWeb/Loader/CSSLoader.cpp b/Userland/Libraries/LibWeb/Loader/CSSLoader.cpp
deleted file mode 100644
index 3638a5129d..0000000000
--- a/Userland/Libraries/LibWeb/Loader/CSSLoader.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2021, the SerenityOS developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <AK/Debug.h>
-#include <AK/URL.h>
-#include <LibWeb/CSS/CSSImportRule.h>
-#include <LibWeb/CSS/Parser/Parser.h>
-#include <LibWeb/DOM/Document.h>
-#include <LibWeb/DOM/Element.h>
-#include <LibWeb/Loader/CSSLoader.h>
-#include <LibWeb/Loader/ResourceLoader.h>
-
-namespace Web {
-
-CSSLoader::CSSLoader(DOM::Element& owner_element)
- : m_owner_element(owner_element)
-{
-}
-
-void CSSLoader::load_from_text(const String& text)
-{
- m_style_sheet = parse_css(CSS::ParsingContext(m_owner_element.document()), text);
- if (!m_style_sheet) {
- m_style_sheet = CSS::CSSStyleSheet::create({});
- m_style_sheet->set_owner_node(&m_owner_element);
- }
-}
-
-void CSSLoader::load_from_url(const AK::URL& url)
-{
- m_style_sheet = CSS::CSSStyleSheet::create({});
- m_style_sheet->set_owner_node(&m_owner_element);
-
- auto request = LoadRequest::create_for_url_on_page(url, m_owner_element.document().page());
- set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
-
- m_document_load_event_delayer.emplace(m_owner_element.document());
-}
-
-void CSSLoader::resource_did_load()
-{
- VERIFY(resource());
-
- m_document_load_event_delayer.clear();
-
- if (!resource()->has_encoded_data()) {
- dbgln_if(CSS_LOADER_DEBUG, "CSSLoader: Resource did load, no encoded data. URL: {}", resource()->url());
- } else {
- dbgln_if(CSS_LOADER_DEBUG, "CSSLoader: Resource did load, has encoded data. URL: {}", resource()->url());
- }
-
- auto sheet = parse_css(CSS::ParsingContext(m_owner_element.document()), resource()->encoded_data());
- if (!sheet) {
- dbgln_if(CSS_LOADER_DEBUG, "CSSLoader: Failed to parse stylesheet: {}", resource()->url());
- return;
- }
-
- // Transfer the rules from the successfully parsed sheet into the sheet we've already inserted.
- m_style_sheet->set_rules(sheet->rules());
-
- if (on_load)
- on_load();
-}
-
-void CSSLoader::resource_did_fail()
-{
- dbgln_if(CSS_LOADER_DEBUG, "CSSLoader: Resource did fail. URL: {}", resource()->url());
-
- m_document_load_event_delayer.clear();
-}
-
-}
diff --git a/Userland/Libraries/LibWeb/Loader/CSSLoader.h b/Userland/Libraries/LibWeb/Loader/CSSLoader.h
deleted file mode 100644
index 9556571702..0000000000
--- a/Userland/Libraries/LibWeb/Loader/CSSLoader.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Function.h>
-#include <LibWeb/CSS/CSSStyleSheet.h>
-#include <LibWeb/DOM/Document.h>
-#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
-#include <LibWeb/Loader/Resource.h>
-
-namespace Web {
-
-class CSSLoader : public ResourceClient {
-public:
- explicit CSSLoader(DOM::Element& owner_element);
-
- void load_from_text(const String&);
- void load_from_url(const AK::URL&);
-
- RefPtr<CSS::CSSStyleSheet> style_sheet() const { return m_style_sheet; };
-
- Function<void()> on_load;
- Function<void()> on_fail;
-
-private:
- // ^ResourceClient
- virtual void resource_did_load() override;
- virtual void resource_did_fail() override;
-
- DOM::Element& m_owner_element;
-
- RefPtr<CSS::CSSStyleSheet> m_style_sheet;
-
- Optional<DOM::DocumentLoadEventDelayer> m_document_load_event_delayer;
-};
-
-}