mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
119
Libraries/LibWeb/MathML/Default.css
Normal file
119
Libraries/LibWeb/MathML/Default.css
Normal file
|
@ -0,0 +1,119 @@
|
|||
/* https://w3c.github.io/mathml-core/#user-agent-stylesheet */
|
||||
@namespace url(http://www.w3.org/1998/Math/MathML);
|
||||
|
||||
/* Universal rules */
|
||||
* {
|
||||
font-size: math;
|
||||
display: block math;
|
||||
writing-mode: horizontal-tb !important;
|
||||
}
|
||||
|
||||
/* The <math> element */
|
||||
math {
|
||||
direction: ltr;
|
||||
text-indent: 0;
|
||||
letter-spacing: normal;
|
||||
line-height: normal;
|
||||
word-spacing: normal;
|
||||
font-family: math;
|
||||
font-size: inherit;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
display: inline math;
|
||||
math-shift: normal;
|
||||
math-style: compact;
|
||||
math-depth: 0;
|
||||
}
|
||||
math[display="block" i] {
|
||||
display: block math;
|
||||
math-style: normal;
|
||||
}
|
||||
math[display="inline" i] {
|
||||
display: inline math;
|
||||
math-style: compact;
|
||||
}
|
||||
|
||||
/* <mrow>-like elements */
|
||||
semantics > :not(:first-child) {
|
||||
display: none;
|
||||
}
|
||||
maction > :not(:first-child) {
|
||||
display: none;
|
||||
}
|
||||
merror {
|
||||
border: 1px solid red;
|
||||
background-color: lightYellow;
|
||||
}
|
||||
mphantom {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* Token elements */
|
||||
mi {
|
||||
text-transform: math-auto;
|
||||
}
|
||||
|
||||
/* Tables */
|
||||
mtable {
|
||||
display: inline-table;
|
||||
math-style: compact;
|
||||
}
|
||||
mtr {
|
||||
display: table-row;
|
||||
}
|
||||
mtd {
|
||||
display: table-cell;
|
||||
/* Centering inside table cells should rely on box alignment properties.
|
||||
See https://github.com/w3c/mathml-core/issues/156 */
|
||||
text-align: center;
|
||||
padding: 0.5ex 0.4em;
|
||||
}
|
||||
|
||||
/* Fractions */
|
||||
mfrac {
|
||||
padding-inline-start: 1px;
|
||||
padding-inline-end: 1px;
|
||||
}
|
||||
mfrac > * {
|
||||
math-depth: auto-add;
|
||||
math-style: compact;
|
||||
}
|
||||
mfrac > :nth-child(2) {
|
||||
math-shift: compact;
|
||||
}
|
||||
|
||||
/* Other rules for scriptlevel, displaystyle and math-shift */
|
||||
mroot > :not(:first-child) {
|
||||
math-depth: add(2);
|
||||
math-style: compact;
|
||||
}
|
||||
mroot, msqrt {
|
||||
math-shift: compact;
|
||||
}
|
||||
msub > :not(:first-child),
|
||||
msup > :not(:first-child),
|
||||
msubsup > :not(:first-child),
|
||||
mmultiscripts > :not(:first-child),
|
||||
munder > :not(:first-child),
|
||||
mover > :not(:first-child),
|
||||
munderover > :not(:first-child) {
|
||||
math-depth: add(1);
|
||||
math-style: compact;
|
||||
}
|
||||
munder[accentunder="true" i] > :nth-child(2),
|
||||
mover[accent="true" i] > :nth-child(2),
|
||||
munderover[accentunder="true" i] > :nth-child(2),
|
||||
munderover[accent="true" i] > :nth-child(3) {
|
||||
font-size: inherit;
|
||||
}
|
||||
msub > :nth-child(2),
|
||||
msubsup > :nth-child(2),
|
||||
mmultiscripts > :nth-child(even),
|
||||
mmultiscripts > mprescripts ~ :nth-child(odd),
|
||||
mover[accent="true" i] > :first-child,
|
||||
munderover[accent="true" i] > :first-child {
|
||||
math-shift: compact;
|
||||
}
|
||||
mmultiscripts > mprescripts ~ :nth-child(even) {
|
||||
math-shift: inherit;
|
||||
}
|
62
Libraries/LibWeb/MathML/MathMLElement.cpp
Normal file
62
Libraries/LibWeb/MathML/MathMLElement.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/MathMLElementPrototype.h>
|
||||
#include <LibWeb/MathML/MathMLElement.h>
|
||||
#include <LibWeb/MathML/TagNames.h>
|
||||
|
||||
namespace Web::MathML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(MathMLElement);
|
||||
|
||||
MathMLElement::~MathMLElement() = default;
|
||||
|
||||
MathMLElement::MathMLElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: DOM::Element(document, move(qualified_name))
|
||||
{
|
||||
}
|
||||
|
||||
void MathMLElement::attribute_change_steps(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
||||
{
|
||||
Base::attribute_change_steps(local_name, old_value, value, namespace_);
|
||||
HTMLOrSVGElement::attribute_change_steps(local_name, old_value, value, namespace_);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> MathMLElement::cloned(DOM::Node& node, bool clone_children)
|
||||
{
|
||||
TRY(Base::cloned(node, clone_children));
|
||||
TRY(HTMLOrSVGElement::cloned(node, clone_children));
|
||||
return {};
|
||||
}
|
||||
|
||||
void MathMLElement::inserted()
|
||||
{
|
||||
Base::inserted();
|
||||
HTMLOrSVGElement::inserted();
|
||||
}
|
||||
|
||||
void MathMLElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(MathMLElement);
|
||||
}
|
||||
|
||||
Optional<ARIA::Role> MathMLElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-math
|
||||
if (local_name() == TagNames::math)
|
||||
return ARIA::Role::math;
|
||||
return {};
|
||||
}
|
||||
|
||||
void MathMLElement::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
HTMLOrSVGElement::visit_edges(visitor);
|
||||
}
|
||||
|
||||
}
|
40
Libraries/LibWeb/MathML/MathMLElement.h
Normal file
40
Libraries/LibWeb/MathML/MathMLElement.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/HTML/GlobalEventHandlers.h>
|
||||
#include <LibWeb/HTML/HTMLOrSVGElement.h>
|
||||
|
||||
namespace Web::MathML {
|
||||
|
||||
class MathMLElement : public DOM::Element
|
||||
, public HTML::GlobalEventHandlers
|
||||
, public HTML::HTMLOrSVGElement<MathMLElement> {
|
||||
WEB_PLATFORM_OBJECT(MathMLElement, DOM::Element);
|
||||
JS_DECLARE_ALLOCATOR(MathMLElement);
|
||||
|
||||
public:
|
||||
virtual ~MathMLElement() override;
|
||||
|
||||
virtual Optional<ARIA::Role> default_role() const override;
|
||||
|
||||
protected:
|
||||
virtual void attribute_change_steps(FlyString const&, Optional<String> const&, Optional<String> const&, Optional<FlyString> const&) override;
|
||||
virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) override;
|
||||
virtual void inserted() override;
|
||||
virtual JS::GCPtr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; }
|
||||
|
||||
private:
|
||||
MathMLElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
13
Libraries/LibWeb/MathML/MathMLElement.idl
Normal file
13
Libraries/LibWeb/MathML/MathMLElement.idl
Normal file
|
@ -0,0 +1,13 @@
|
|||
#import <CSS/ElementCSSInlineStyle.idl>
|
||||
#import <DOM/Element.idl>
|
||||
#import <DOM/EventHandler.idl>
|
||||
#import <HTML/HTMLElement.idl>
|
||||
|
||||
// https://w3c.github.io/mathml-core/#dom-and-javascript
|
||||
[Exposed=Window]
|
||||
interface MathMLElement : Element { };
|
||||
MathMLElement includes GlobalEventHandlers;
|
||||
MathMLElement includes HTMLOrSVGElement; // FIXME: The spec calls for HTMLOrForeignElement which is a rename of HTMLOrSVGElement, when that change is upstreamed we should update here
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-elementcssinlinestyle-style
|
||||
MathMLElement includes ElementCSSInlineStyle;
|
30
Libraries/LibWeb/MathML/TagNames.cpp
Normal file
30
Libraries/LibWeb/MathML/TagNames.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/MathML/TagNames.h>
|
||||
|
||||
namespace Web::MathML::TagNames {
|
||||
|
||||
#define __ENUMERATE_MATHML_TAG(name) FlyString name;
|
||||
ENUMERATE_MATHML_TAGS
|
||||
#undef __ENUMERATE_MATHML_TAG
|
||||
FlyString annotation_xml;
|
||||
|
||||
void initialize_strings()
|
||||
{
|
||||
static bool s_initialized = false;
|
||||
VERIFY(!s_initialized);
|
||||
|
||||
#define __ENUMERATE_MATHML_TAG(name) name = #name##_fly_string;
|
||||
ENUMERATE_MATHML_TAGS
|
||||
#undef __ENUMERATE_MATHML_TAG
|
||||
annotation_xml = "annotation-xml"_fly_string;
|
||||
|
||||
s_initialized = true;
|
||||
}
|
||||
|
||||
}
|
54
Libraries/LibWeb/MathML/TagNames.h
Normal file
54
Libraries/LibWeb/MathML/TagNames.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
|
||||
namespace Web::MathML::TagNames {
|
||||
|
||||
#define ENUMERATE_MATHML_TAGS \
|
||||
__ENUMERATE_MATHML_TAG(annotation) \
|
||||
__ENUMERATE_MATHML_TAG(maction) \
|
||||
__ENUMERATE_MATHML_TAG(malignmark) \
|
||||
__ENUMERATE_MATHML_TAG(math) \
|
||||
__ENUMERATE_MATHML_TAG(merror) \
|
||||
__ENUMERATE_MATHML_TAG(mglyph) \
|
||||
__ENUMERATE_MATHML_TAG(mfrac) \
|
||||
__ENUMERATE_MATHML_TAG(mi) \
|
||||
__ENUMERATE_MATHML_TAG(mmultiscripts) \
|
||||
__ENUMERATE_MATHML_TAG(mn) \
|
||||
__ENUMERATE_MATHML_TAG(mo) \
|
||||
__ENUMERATE_MATHML_TAG(mover) \
|
||||
__ENUMERATE_MATHML_TAG(mpadded) \
|
||||
__ENUMERATE_MATHML_TAG(mphantom) \
|
||||
__ENUMERATE_MATHML_TAG(mprescripts) \
|
||||
__ENUMERATE_MATHML_TAG(mroot) \
|
||||
__ENUMERATE_MATHML_TAG(mrow) \
|
||||
__ENUMERATE_MATHML_TAG(ms) \
|
||||
__ENUMERATE_MATHML_TAG(mspace) \
|
||||
__ENUMERATE_MATHML_TAG(msqrt) \
|
||||
__ENUMERATE_MATHML_TAG(mstyle) \
|
||||
__ENUMERATE_MATHML_TAG(msub) \
|
||||
__ENUMERATE_MATHML_TAG(msubsup) \
|
||||
__ENUMERATE_MATHML_TAG(msup) \
|
||||
__ENUMERATE_MATHML_TAG(mtable) \
|
||||
__ENUMERATE_MATHML_TAG(mtd) \
|
||||
__ENUMERATE_MATHML_TAG(mtext) \
|
||||
__ENUMERATE_MATHML_TAG(mtr) \
|
||||
__ENUMERATE_MATHML_TAG(munder) \
|
||||
__ENUMERATE_MATHML_TAG(munderover) \
|
||||
__ENUMERATE_MATHML_TAG(semantics)
|
||||
|
||||
#define __ENUMERATE_MATHML_TAG(name) extern FlyString name;
|
||||
ENUMERATE_MATHML_TAGS
|
||||
#undef __ENUMERATE_MATHML_TAG
|
||||
|
||||
extern FlyString annotation_xml;
|
||||
|
||||
void initialize_strings();
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue