From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/object/sp-style-elem.cpp | 579 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 579 insertions(+) create mode 100644 src/object/sp-style-elem.cpp (limited to 'src/object/sp-style-elem.cpp') diff --git a/src/object/sp-style-elem.cpp b/src/object/sp-style-elem.cpp new file mode 100644 index 0000000..412c0ef --- /dev/null +++ b/src/object/sp-style-elem.cpp @@ -0,0 +1,579 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * TODO: insert short description here + *//* + * Authors: see git history + * + * Copyright (C) 2018 Authors + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ +#include <3rdparty/libcroco/cr-parser.h> +#include "xml/node-event-vector.h" +#include "xml/repr.h" +#include "document.h" +#include "sp-style-elem.h" +#include "sp-root.h" +#include "attributes.h" +#include "style.h" + +// For external style sheets +#include "io/resource.h" +#include +#include + +// For font-rule +#include "libnrtype/FontFactory.h" + +SPStyleElem::SPStyleElem() : SPObject() { + media_set_all(this->media); + this->is_css = false; + this->style_sheet = nullptr; +} + +SPStyleElem::~SPStyleElem() = default; + +void SPStyleElem::set(SPAttr key, const gchar* value) { + switch (key) { + case SPAttr::TYPE: { + if (!value) { + /* TODO: `type' attribute is required. Give error message as per + http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. */ + is_css = false; + } else { + /* fixme: determine what whitespace is allowed. Will probably need to ask on SVG + list; though the relevant RFC may give info on its lexer. */ + is_css = ( g_ascii_strncasecmp(value, "text/css", 8) == 0 + && ( value[8] == '\0' || + value[8] == ';' ) ); + } + break; + } + +#if 0 /* unfinished */ + case SPAttr::MEDIA: { + parse_media(style_elem, value); + break; + } +#endif + + /* title is ignored. */ + default: { + SPObject::set(key, value); + break; + } + } +} + +/** + * Callback for changing the content of a