~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/rendering/mathml/RenderMathMLBlock.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Alex Milowski (alex@milowski.com). All rights reserved.
 
3
 * Copyright (C) 2012 David Barton (dbarton@mathscribe.com). All rights reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 * 1. Redistributions of source code must retain the above copyright
 
9
 *    notice, this list of conditions and the following disclaimer.
 
10
 * 2. Redistributions in binary form must reproduce the above copyright
 
11
 *    notice, this list of conditions and the following disclaimer in the
 
12
 *    documentation and/or other materials provided with the distribution.
 
13
 *
 
14
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
15
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
16
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
17
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
18
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
19
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
20
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
21
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
22
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
25
 */
 
26
 
 
27
#ifndef RenderMathMLBlock_h
 
28
#define RenderMathMLBlock_h
 
29
 
 
30
#if ENABLE(MATHML)
 
31
 
 
32
#include "RenderFlexibleBox.h"
 
33
#include "RenderTable.h"
 
34
#include "StyleInheritedData.h"
 
35
 
 
36
#define ENABLE_DEBUG_MATH_LAYOUT 0
 
37
 
 
38
namespace WebCore {
 
39
    
 
40
class RenderMathMLOperator;
 
41
 
 
42
class RenderMathMLBlock : public RenderFlexibleBox {
 
43
public:
 
44
    RenderMathMLBlock(Node* container);
 
45
    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;
 
46
    
 
47
    virtual bool isRenderMathMLBlock() const { return true; }
 
48
    virtual bool isRenderMathMLOperator() const { return false; }
 
49
    virtual bool isRenderMathMLRow() const { return false; }
 
50
    virtual bool isRenderMathMLMath() const { return false; }
 
51
    virtual bool isRenderMathMLFenced() const { return false; }
 
52
    virtual bool isRenderMathMLFraction() const { return false; }
 
53
    virtual bool isRenderMathMLRoot() const { return false; }
 
54
    virtual bool isRenderMathMLSquareRoot() const { return false; }
 
55
    virtual bool isRenderMathMLSubSup() const { return false; }
 
56
    virtual bool isRenderMathMLUnderOver() const { return false; }
 
57
    
 
58
    // MathML defines an "embellished operator" as roughly an <mo> that may have subscripts,
 
59
    // superscripts, underscripts, overscripts, or a denominator (as in d/dx, where "d" is some
 
60
    // differential operator). The padding, precedence, and stretchiness of the base <mo> should
 
61
    // apply to the embellished operator as a whole. unembellishedOperator() checks for being an
 
62
    // embellished operator, and omits any embellishments.
 
63
    // FIXME: We don't yet handle all the cases in the MathML spec. See
 
64
    // https://bugs.webkit.org/show_bug.cgi?id=78617.
 
65
    virtual RenderMathMLOperator* unembellishedOperator() { return 0; }
 
66
 
 
67
    virtual LayoutUnit paddingTop() const OVERRIDE;
 
68
    virtual LayoutUnit paddingBottom() const OVERRIDE;
 
69
    virtual LayoutUnit paddingLeft() const OVERRIDE;
 
70
    virtual LayoutUnit paddingRight() const OVERRIDE;
 
71
    virtual LayoutUnit paddingBefore() const OVERRIDE;
 
72
    virtual LayoutUnit paddingAfter() const OVERRIDE;
 
73
    virtual LayoutUnit paddingStart() const OVERRIDE;
 
74
    virtual LayoutUnit paddingEnd() const OVERRIDE;
 
75
    
 
76
    // A MathML element's preferred logical widths often depend on its children's preferred heights, not just their widths.
 
77
    // This is due to operator stretching and other layout fine tuning. We define an element's preferred height to be its
 
78
    // actual height after layout inside a very wide parent.
 
79
    bool isPreferredLogicalHeightDirty() const { return preferredLogicalWidthsDirty() || m_preferredLogicalHeight < 0; }
 
80
    // The caller must ensure !isPreferredLogicalHeightDirty().
 
81
    LayoutUnit preferredLogicalHeight() const { ASSERT(!isPreferredLogicalHeightDirty()); return m_preferredLogicalHeight; }
 
82
    static const int preferredLogicalHeightUnset = -1;
 
83
    void setPreferredLogicalHeight(LayoutUnit logicalHeight) { m_preferredLogicalHeight = logicalHeight; }
 
84
    // computePreferredLogicalWidths() in derived classes must ensure m_preferredLogicalHeight is set to < 0 or its correct value.
 
85
    virtual void computePreferredLogicalWidths() OVERRIDE;
 
86
    
 
87
    virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;
 
88
    
 
89
#if ENABLE(DEBUG_MATH_LAYOUT)
 
90
    virtual void paint(PaintInfo&, const LayoutPoint&);
 
91
#endif
 
92
    
 
93
    // Create a new RenderMathMLBlock, with a new style inheriting from this->style().
 
94
    RenderMathMLBlock* createAnonymousMathMLBlock(EDisplay = FLEX);
 
95
    
 
96
    void setIgnoreInAccessibilityTree(bool flag) { m_ignoreInAccessibilityTree = flag; }
 
97
    bool ignoreInAccessibilityTree() const { return m_ignoreInAccessibilityTree; }
 
98
    
 
99
private:
 
100
    virtual const char* renderName() const OVERRIDE;
 
101
    bool m_ignoreInAccessibilityTree;
 
102
    
 
103
protected:
 
104
    // Set our logical width to a large value, and compute our children's preferred logical heights.
 
105
    void computeChildrenPreferredLogicalHeights();
 
106
    // This can only be called after children have been sized by computeChildrenPreferredLogicalHeights().
 
107
    static LayoutUnit preferredLogicalHeightAfterSizing(RenderObject* child);
 
108
    
 
109
    int m_intrinsicPaddingBefore;
 
110
    int m_intrinsicPaddingAfter;
 
111
    int m_intrinsicPaddingStart;
 
112
    int m_intrinsicPaddingEnd;
 
113
    
 
114
    // m_preferredLogicalHeight is dirty if it's < 0 or preferredLogicalWidthsDirty().
 
115
    LayoutUnit m_preferredLogicalHeight;
 
116
};
 
117
 
 
118
inline RenderMathMLBlock* toRenderMathMLBlock(RenderObject* object)
 
119
 
120
    ASSERT(!object || object->isRenderMathMLBlock());
 
121
    return static_cast<RenderMathMLBlock*>(object);
 
122
}
 
123
 
 
124
inline const RenderMathMLBlock* toRenderMathMLBlock(const RenderObject* object)
 
125
 
126
    ASSERT(!object || object->isRenderMathMLBlock());
 
127
    return static_cast<const RenderMathMLBlock*>(object);
 
128
}
 
129
 
 
130
// This will catch anyone doing an unnecessary cast.
 
131
void toRenderMathMLBlock(const RenderMathMLBlock*);
 
132
 
 
133
class RenderMathMLTable : public RenderTable {
 
134
public:
 
135
    explicit RenderMathMLTable(Node* node) : RenderTable(node) { }
 
136
    
 
137
    virtual int firstLineBoxBaseline() const OVERRIDE;
 
138
    
 
139
private:
 
140
    virtual const char* renderName() const OVERRIDE { return "RenderMathMLTable"; }
 
141
};
 
142
 
 
143
}
 
144
 
 
145
#endif // ENABLE(MATHML)
 
146
#endif // RenderMathMLBlock_h