Changeset 108136 in webkit
- Timestamp:
- Feb 17, 2012 3:33:05 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r108135 r108136 1 2012-02-17 David Barton <dbarton@mathscribe.com> 2 3 MathML internals - embellished operators, getBase() accessor functions 4 https://bugs.webkit.org/show_bug.cgi?id=78617 5 6 Reviewed by Eric Seidel. 7 8 Define functions that return an unembellished "base", by omitting 9 subscripts/superscripts, underscripts/overscripts, or denominators. This is needed in 10 subsequent patches both for correct operator stretching and simple code factoring. 11 12 No new tests. 13 14 * rendering/mathml/RenderMathMLBlock.h: 15 (WebCore): 16 (RenderMathMLBlock): 17 (WebCore::RenderMathMLBlock::unembellishedOperator): 18 * rendering/mathml/RenderMathMLFraction.cpp: 19 (WebCore::RenderMathMLFraction::unembellishedOperator): 20 (WebCore): 21 * rendering/mathml/RenderMathMLFraction.h: 22 (RenderMathMLFraction): 23 * rendering/mathml/RenderMathMLOperator.h: 24 (WebCore::RenderMathMLOperator::unembellishedOperator): 25 * rendering/mathml/RenderMathMLSubSup.cpp: 26 (WebCore::RenderMathMLSubSup::base): 27 (WebCore): 28 (WebCore::RenderMathMLSubSup::unembellishedOperator): 29 (WebCore::RenderMathMLSubSup::stretchToHeight): 30 - renamed a variable for clarity, especially in later patches 31 (WebCore::RenderMathMLSubSup::layout): 32 - renamed a variable for clarity, especially in later patches 33 * rendering/mathml/RenderMathMLSubSup.h: 34 (RenderMathMLSubSup): 35 * rendering/mathml/RenderMathMLUnderOver.cpp: 36 (WebCore::RenderMathMLUnderOver::base): 37 (WebCore): 38 (WebCore::RenderMathMLUnderOver::unembellishedOperator): 39 (WebCore::RenderMathMLUnderOver::stretchToHeight): 40 * rendering/mathml/RenderMathMLUnderOver.h: 41 (RenderMathMLUnderOver): 42 1 43 2012-02-17 No'am Rosenthal <noam.rosenthal@nokia.com> 2 44 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h
r107473 r108136 35 35 namespace WebCore { 36 36 37 class RenderMathMLOperator; 38 37 39 class RenderMathMLBlock : public RenderBlock { 38 40 public: … … 44 46 virtual bool isRenderMathMLRow() const { return false; } 45 47 virtual bool isRenderMathMLMath() const { return false; } 48 49 // MathML defines an "embellished operator" as roughly an <mo> that may have subscripts, 50 // superscripts, underscripts, overscripts, or a denominator (as in d/dx, where "d" is some 51 // differential operator). The padding, precedence, and stretchiness of the base <mo> should 52 // apply to the embellished operator as a whole. unembellishedOperator() checks for being an 53 // embellished operator, and omits any embellishments. 54 // FIXME: We don't yet handle all the cases in the MathML spec. See 55 // https://bugs.webkit.org/show_bug.cgi?id=78617. 56 virtual RenderMathMLOperator* unembellishedOperator() { return 0; } 46 57 virtual bool hasBase() const { return false; } 47 58 virtual int nonOperatorHeight() const; -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp
r107473 r108136 120 120 } 121 121 122 RenderMathMLOperator* RenderMathMLFraction::unembellishedOperator() 123 { 124 RenderObject* numeratorWrapper = firstChild(); 125 if (!numeratorWrapper) 126 return 0; 127 RenderObject* numerator = numeratorWrapper->firstChild(); 128 if (!numerator || !numerator->isRenderMathMLBlock()) 129 return 0; 130 return toRenderMathMLBlock(numerator)->unembellishedOperator(); 131 } 132 122 133 void RenderMathMLFraction::layout() 123 134 { -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h
r107263 r108136 39 39 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); 40 40 virtual void updateFromElement(); 41 42 virtual RenderMathMLOperator* unembellishedOperator(); 43 41 44 virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 42 45 virtual void paint(PaintInfo&, const LayoutPoint&); 43 46 protected: 44 47 virtual void layout(); 48 45 49 private: 46 50 virtual const char* renderName() const { return "RenderMathMLFraction"; } -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h
r107263 r108136 39 39 RenderMathMLOperator(Node*, UChar operatorChar); 40 40 virtual bool isRenderMathMLOperator() const { return true; } 41 virtual RenderMathMLOperator* unembellishedOperator() { return this; } 41 42 virtual void stretchToHeight(int pixelHeight); 42 43 virtual void updateFromElement(); -
trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp
r107880 r108136 55 55 } 56 56 57 RenderBoxModelObject* RenderMathMLSubSup::base() const 58 { 59 RenderObject* baseWrapper = firstChild(); 60 if (!baseWrapper) 61 return 0; 62 RenderObject* base = baseWrapper->firstChild(); 63 if (!base || !base->isBoxModelObject()) 64 return 0; 65 return toRenderBoxModelObject(base); 66 } 67 57 68 void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild) 58 69 { … … 105 116 } 106 117 118 RenderMathMLOperator* RenderMathMLSubSup::unembellishedOperator() 119 { 120 RenderBoxModelObject* base = this->base(); 121 if (!base || !base->isRenderMathMLBlock()) 122 return 0; 123 return toRenderMathMLBlock(base)->unembellishedOperator(); 124 } 125 107 126 void RenderMathMLSubSup::stretchToHeight(int height) 108 127 { 109 RenderObject* base = firstChild();110 if (!base || !base->firstChild())128 RenderObject* baseWrapper = firstChild(); 129 if (!baseWrapper || !baseWrapper->firstChild()) 111 130 return; 112 131 113 if (base ->firstChild() && base->firstChild()->isRenderMathMLBlock()) {114 RenderMathMLBlock* block = toRenderMathMLBlock(base ->firstChild());132 if (baseWrapper->firstChild() && baseWrapper->firstChild()->isRenderMathMLBlock()) { 133 RenderMathMLBlock* block = toRenderMathMLBlock(baseWrapper->firstChild()); 115 134 block->stretchToHeight(static_cast<int>(gSubSupStretch * height)); 116 135 … … 154 173 155 174 if (m_kind == SubSup) { 156 if (RenderObject* base = firstChild()) {175 if (RenderObject* baseWrapper = firstChild()) { 157 176 LayoutUnit maxHeight = 0; 158 RenderObject* current = base ->firstChild();177 RenderObject* current = baseWrapper->firstChild(); 159 178 while (current) { 160 179 LayoutUnit height = getBoxModelObjectHeight(current); … … 166 185 if (heightDiff < 0) 167 186 heightDiff = 0; 168 base ->style()->setPaddingTop(Length(heightDiff, Fixed));169 base ->setNeedsLayout(true);187 baseWrapper->style()->setPaddingTop(Length(heightDiff, Fixed)); 188 baseWrapper->setNeedsLayout(true); 170 189 } 171 190 setNeedsLayout(true); -
trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h
r107263 r108136 37 37 RenderMathMLSubSup(Element*); 38 38 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); 39 40 virtual RenderMathMLOperator* unembellishedOperator(); 39 41 virtual bool hasBase() const { return true; } 40 42 virtual int nonOperatorHeight() const; … … 48 50 virtual const char* renderName() const { return "RenderMathMLSubSup"; } 49 51 52 // Omit our subscript and/or superscript. This may return 0 for a non-MathML base (which 53 // won't occur in valid MathML). 54 RenderBoxModelObject* base() const; 55 50 56 enum SubSupType { Sub, Sup, SubSup }; 51 57 SubSupType m_kind; -
trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp
r107473 r108136 53 53 } 54 54 55 RenderBoxModelObject* RenderMathMLUnderOver::base() const 56 { 57 RenderObject* baseWrapper = firstChild(); 58 if ((m_kind == Over || m_kind == UnderOver) && baseWrapper) 59 baseWrapper = baseWrapper->nextSibling(); 60 if (!baseWrapper) 61 return 0; 62 RenderObject* base = baseWrapper->firstChild(); 63 if (!base || !base->isBoxModelObject()) 64 return 0; 65 return toRenderBoxModelObject(base); 66 } 67 55 68 void RenderMathMLUnderOver::addChild(RenderObject* child, RenderObject* beforeChild) 56 69 { … … 107 120 } 108 121 122 RenderMathMLOperator* RenderMathMLUnderOver::unembellishedOperator() 123 { 124 RenderBoxModelObject* base = this->base(); 125 if (!base || !base->isRenderMathMLBlock()) 126 return 0; 127 return toRenderMathMLBlock(base)->unembellishedOperator(); 128 } 129 109 130 inline int getOffsetHeight(RenderObject* obj) 110 131 { … … 119 140 void RenderMathMLUnderOver::stretchToHeight(int height) 120 141 { 121 122 RenderObject* base = firstChild(); 123 if (!base) 124 return; 125 126 // For over or underover, the base is the sibling of the first child 127 if (m_kind != Under) 128 base = base->nextSibling(); 129 130 if (!base) 131 return; 132 133 // use the child of the row which is the actual base 134 base = base->firstChild(); 135 142 RenderBoxModelObject* base = this->base(); 136 143 if (base && base->isRenderMathMLBlock()) { 137 144 RenderMathMLBlock* block = toRenderMathMLBlock(base); -
trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h
r107263 r108136 37 37 RenderMathMLUnderOver(Element*); 38 38 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); 39 40 virtual RenderMathMLOperator* unembellishedOperator(); 39 41 virtual void layout(); 40 42 virtual bool hasBase() const { return true; } … … 42 44 virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 43 45 virtual void stretchToHeight(int pixelHeight); 46 44 47 private: 45 48 virtual const char* renderName() const { return "RenderMathMLUnderOver"; } 46 49 50 // Omit our underscript and/or overscript. This may return 0 for a non-MathML base (which 51 // won't occur in valid MathML). 52 RenderBoxModelObject* base() const; 53 47 54 enum UnderOverType { Under, Over, UnderOver }; 48 55 UnderOverType m_kind;
Note: See TracChangeset
for help on using the changeset viewer.