| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Alex Milowski (alex@milowski.com). All rights reserved. | 2 * Copyright (C) 2010 Alex Milowski (alex@milowski.com). All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 { | 54 { |
| 55 RenderObject* baseWrapper = firstChild(); | 55 RenderObject* baseWrapper = firstChild(); |
| 56 if (!baseWrapper) | 56 if (!baseWrapper) |
| 57 return 0; | 57 return 0; |
| 58 RenderObject* base = baseWrapper->firstChild(); | 58 RenderObject* base = baseWrapper->firstChild(); |
| 59 if (!base || !base->isBoxModelObject()) | 59 if (!base || !base->isBoxModelObject()) |
| 60 return 0; | 60 return 0; |
| 61 return toRenderBoxModelObject(base); | 61 return toRenderBoxModelObject(base); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void RenderMathMLSubSup::fixScriptsStyle() | 64 void RenderMathMLSubSup::fixAnonymousStyles() |
| 65 { | 65 { |
| 66 // Set the base wrapper's style so that baseHeight in layout() will be an un
stretched height. |
| 67 ASSERT(firstChild() && firstChild()->style()->refCount() == 1); |
| 68 firstChild()->style()->setAlignSelf(AlignFlexStart); |
| 69 |
| 66 ASSERT(m_scripts && m_scripts->style()->refCount() == 1); | 70 ASSERT(m_scripts && m_scripts->style()->refCount() == 1); |
| 67 RenderStyle* scriptsStyle = m_scripts->style(); | 71 RenderStyle* scriptsStyle = m_scripts->style(); |
| 68 scriptsStyle->setFlexDirection(FlowColumn); | 72 scriptsStyle->setFlexDirection(FlowColumn); |
| 69 scriptsStyle->setJustifyContent(m_kind == Sub ? JustifyFlexEnd : m_kind == S
uper ? JustifyFlexStart : JustifySpaceBetween); | 73 scriptsStyle->setJustifyContent(m_kind == Sub ? JustifyFlexEnd : m_kind == S
uper ? JustifyFlexStart : JustifySpaceBetween); |
| 70 // Set this wrapper's font-size for its line-height & baseline position, for
its children. | 74 // Set this wrapper's font-size for its line-height & baseline position, for
its children. |
| 71 scriptsStyle->setFontSize(static_cast<int>(0.75 * style()->fontSize())); | 75 scriptsStyle->setFontSize(static_cast<int>(0.75 * style()->fontSize())); |
| 72 } | 76 } |
| 73 | 77 |
| 74 // FIXME: Handle arbitrary addChild/removeChild correctly throughout MathML. | 78 // FIXME: Handle arbitrary addChild/removeChild correctly throughout MathML. |
| 75 void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild
) | 79 void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild
) |
| 76 { | 80 { |
| 77 if (isEmpty()) { | 81 if (isEmpty()) { |
| 78 RenderMathMLBlock* baseWrapper = createAnonymousMathMLBlock(); | 82 RenderMathMLBlock* baseWrapper = createAnonymousMathMLBlock(); |
| 79 RenderMathMLBlock::addChild(baseWrapper); | 83 RenderMathMLBlock::addChild(baseWrapper); |
| 80 | 84 |
| 81 m_scripts = createAnonymousMathMLBlock(); | 85 m_scripts = createAnonymousMathMLBlock(); |
| 82 RenderMathMLBlock::addChild(m_scripts); | 86 RenderMathMLBlock::addChild(m_scripts); |
| 83 fixScriptsStyle(); | 87 |
| 88 fixAnonymousStyles(); |
| 84 } | 89 } |
| 85 | 90 |
| 86 if (firstChild()->isEmpty()) | 91 if (firstChild()->isEmpty()) |
| 87 firstChild()->addChild(child); | 92 firstChild()->addChild(child); |
| 88 else | 93 else |
| 89 m_scripts->addChild(child, beforeChild && beforeChild->parent() == m_scr
ipts ? beforeChild : 0); | 94 m_scripts->addChild(child, beforeChild && beforeChild->parent() == m_scr
ipts ? beforeChild : 0); |
| 90 } | 95 } |
| 91 | 96 |
| 92 void RenderMathMLSubSup::styleDidChange(StyleDifference diff, const RenderStyle*
oldStyle) | 97 void RenderMathMLSubSup::styleDidChange(StyleDifference diff, const RenderStyle*
oldStyle) |
| 93 { | 98 { |
| 94 RenderMathMLBlock::styleDidChange(diff, oldStyle); | 99 RenderMathMLBlock::styleDidChange(diff, oldStyle); |
| 95 | 100 |
| 96 if (m_scripts) | 101 if (!isEmpty()) |
| 97 fixScriptsStyle(); | 102 fixAnonymousStyles(); |
| 98 } | 103 } |
| 99 | 104 |
| 100 RenderMathMLOperator* RenderMathMLSubSup::unembellishedOperator() | 105 RenderMathMLOperator* RenderMathMLSubSup::unembellishedOperator() |
| 101 { | 106 { |
| 102 RenderBoxModelObject* base = this->base(); | 107 RenderBoxModelObject* base = this->base(); |
| 103 if (!base || !base->isRenderMathMLBlock()) | 108 if (!base || !base->isRenderMathMLBlock()) |
| 104 return 0; | 109 return 0; |
| 105 return toRenderMathMLBlock(base)->unembellishedOperator(); | 110 return toRenderMathMLBlock(base)->unembellishedOperator(); |
| 106 } | 111 } |
| 107 | 112 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 157 |
| 153 setChildNeedsLayout(true, MarkOnlyThis); | 158 setChildNeedsLayout(true, MarkOnlyThis); |
| 154 baseWrapper->setNeedsLayout(true, MarkOnlyThis); | 159 baseWrapper->setNeedsLayout(true, MarkOnlyThis); |
| 155 | 160 |
| 156 RenderMathMLBlock::layout(); | 161 RenderMathMLBlock::layout(); |
| 157 } | 162 } |
| 158 | 163 |
| 159 } | 164 } |
| 160 | 165 |
| 161 #endif // ENABLE(MATHML) | 166 #endif // ENABLE(MATHML) |
| OLD | NEW |