1 | /* |
2 | * Copyright (C) 2010 Alex Milowski (alex@milowski.com). All rights reserved. |
3 | * Copyright (C) 2013 The MathJax Consortium. |
4 | * Copyright (C) 2016 Igalia S.L. |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions |
8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
14 | * |
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
19 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #pragma once |
29 | |
30 | #if ENABLE(MATHML) |
31 | |
32 | #include "MathMLScriptsElement.h" |
33 | #include "RenderMathMLBlock.h" |
34 | |
35 | namespace WebCore { |
36 | |
37 | // Render a base with scripts. |
38 | class RenderMathMLScripts : public RenderMathMLBlock { |
39 | WTF_MAKE_ISO_ALLOCATED(RenderMathMLScripts); |
40 | public: |
41 | RenderMathMLScripts(MathMLScriptsElement&, RenderStyle&&); |
42 | RenderMathMLOperator* unembellishedOperator() const final; |
43 | |
44 | protected: |
45 | bool isRenderMathMLScripts() const override { return true; } |
46 | const char* renderName() const override { return "RenderMathMLScripts" ; } |
47 | MathMLScriptsElement::ScriptType scriptType() const; |
48 | void computePreferredLogicalWidths() override; |
49 | void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0_lu) override; |
50 | |
51 | private: |
52 | MathMLScriptsElement& element() const; |
53 | Optional<int> firstLineBaseline() const final; |
54 | struct ReferenceChildren { |
55 | RenderBox* base; |
56 | RenderBox* prescriptDelimiter; |
57 | RenderBox* firstPostScript; |
58 | RenderBox* firstPreScript; |
59 | }; |
60 | Optional<ReferenceChildren> validateAndGetReferenceChildren(); |
61 | LayoutUnit spaceAfterScript(); |
62 | LayoutUnit italicCorrection(const ReferenceChildren&); |
63 | struct VerticalParameters { |
64 | LayoutUnit subscriptShiftDown; |
65 | LayoutUnit superscriptShiftUp; |
66 | LayoutUnit subscriptBaselineDropMin; |
67 | LayoutUnit superScriptBaselineDropMax; |
68 | LayoutUnit subSuperscriptGapMin; |
69 | LayoutUnit superscriptBottomMin; |
70 | LayoutUnit subscriptTopMax; |
71 | LayoutUnit superscriptBottomMaxWithSubscript; |
72 | }; |
73 | VerticalParameters verticalParameters() const; |
74 | struct VerticalMetrics { |
75 | LayoutUnit subShift; |
76 | LayoutUnit supShift; |
77 | LayoutUnit ascent; |
78 | LayoutUnit descent; |
79 | }; |
80 | VerticalMetrics verticalMetrics(const ReferenceChildren&); |
81 | }; |
82 | |
83 | } // namespace WebCore |
84 | |
85 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLScripts, isRenderMathMLScripts()) |
86 | |
87 | #endif // ENABLE(MATHML) |
88 | |