diff options
author | John Reck <jreck@google.com> | 2010-11-04 12:00:17 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2010-11-09 11:35:04 -0800 |
commit | e14391e94c850b8bd03680c23b38978db68687a8 (patch) | |
tree | 3fed87e6620fecaf3edc7259ae58a11662bedcb2 /WebCore/mathml | |
parent | 1bd705833a68f07850cf7e204b26f8d328d16951 (diff) | |
download | external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.zip external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.gz external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.bz2 |
Merge Webkit at r70949: Initial merge by git.
Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e
Diffstat (limited to 'WebCore/mathml')
-rw-r--r-- | WebCore/mathml/RenderMathMLFenced.cpp | 20 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLFenced.h | 3 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLFraction.cpp | 7 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLOperator.cpp | 3 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLRoot.cpp | 6 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLRow.cpp | 76 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLRow.h | 1 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLSubSup.cpp | 62 | ||||
-rw-r--r-- | WebCore/mathml/RenderMathMLUnderOver.cpp | 20 | ||||
-rw-r--r-- | WebCore/mathml/mathtags.in | 4 |
10 files changed, 71 insertions, 131 deletions
diff --git a/WebCore/mathml/RenderMathMLFenced.cpp b/WebCore/mathml/RenderMathMLFenced.cpp index a304fa4..f7bbf71 100644 --- a/WebCore/mathml/RenderMathMLFenced.cpp +++ b/WebCore/mathml/RenderMathMLFenced.cpp @@ -142,26 +142,6 @@ void RenderMathMLFenced::addChild(RenderObject* child, RenderObject*) RenderBlock::addChild(child, lastChild()); } -void RenderMathMLFenced::layout() -{ - RenderMathMLRow::layout(); - - int width = 0; - for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { - if (current->isBoxModelObject()) { - RenderBoxModelObject* box = toRenderBoxModelObject(current); - width += box->offsetWidth(); - } - } - width++; - style()->setWidth(Length(width, Fixed)); - - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); - RenderBlock::layout(); - - setNeedsLayout(false); -} } #endif diff --git a/WebCore/mathml/RenderMathMLFenced.h b/WebCore/mathml/RenderMathMLFenced.h index 63cdaa8..64e4d90 100644 --- a/WebCore/mathml/RenderMathMLFenced.h +++ b/WebCore/mathml/RenderMathMLFenced.h @@ -38,9 +38,6 @@ public: virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); virtual void updateFromElement(); -protected: - virtual void layout(); - private: void makeFences(); RefPtr<RenderStyle> makeOperatorStyle(); diff --git a/WebCore/mathml/RenderMathMLFraction.cpp b/WebCore/mathml/RenderMathMLFraction.cpp index 92c8101..1000604 100644 --- a/WebCore/mathml/RenderMathMLFraction.cpp +++ b/WebCore/mathml/RenderMathMLFraction.cpp @@ -129,13 +129,6 @@ void RenderMathMLFraction::layout() RenderBlock::layout(); - // The row layout can affect the numerator/denominator width. - // FIXME: This is probably only needed if one of the children - // contains an mrow. - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); - - RenderBlock::layout(); } void RenderMathMLFraction::paint(PaintInfo& info, int tx, int ty) diff --git a/WebCore/mathml/RenderMathMLOperator.cpp b/WebCore/mathml/RenderMathMLOperator.cpp index 1e3b429..9f35480 100644 --- a/WebCore/mathml/RenderMathMLOperator.cpp +++ b/WebCore/mathml/RenderMathMLOperator.cpp @@ -67,8 +67,7 @@ void RenderMathMLOperator::stretchToHeight(int height) m_stretchHeight = static_cast<int>(height * gOperatorExpansion); updateBoxModelInfoFromStyle(); - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); + setNeedsLayout(true); } void RenderMathMLOperator::layout() diff --git a/WebCore/mathml/RenderMathMLRoot.cpp b/WebCore/mathml/RenderMathMLRoot.cpp index ab15c80..ba60c9f 100644 --- a/WebCore/mathml/RenderMathMLRoot.cpp +++ b/WebCore/mathml/RenderMathMLRoot.cpp @@ -246,14 +246,14 @@ void RenderMathMLRoot::layout() if (rootMarginTop > 0) style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed)); - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); + setNeedsLayout(true); + setPreferredLogicalWidthsDirty(true, false); RenderBlock::layout(); indexBox->style()->setBottom(Length(radicalHeight + style()->paddingBottom().value(), Fixed)); // Now that we've potentially changed its position, we need layout the index again. - indexBox->setNeedsLayoutAndPrefWidthsRecalc(); + indexBox->setNeedsLayout(true); indexBox->layout(); } diff --git a/WebCore/mathml/RenderMathMLRow.cpp b/WebCore/mathml/RenderMathMLRow.cpp index 632b794..ae911fc 100644 --- a/WebCore/mathml/RenderMathMLRow.cpp +++ b/WebCore/mathml/RenderMathMLRow.cpp @@ -66,42 +66,27 @@ void RenderMathMLRow::layout() { RenderBlock::layout(); - // Calculate the maximum height of the row without the operators. - int maxHeight = nonOperatorHeight(); - - // Notify contained operators they may need to re-layout their stretched operators. - // We need to keep track of the number of children and operators because a row of - // operators needs some special handling. + int maxHeight = 0; int childCount = 0; int operatorCount = 0; - for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { - childCount++; - if (current->isRenderMathMLBlock()) { - RenderMathMLBlock* block = toRenderMathMLBlock(current); - block->stretchToHeight(maxHeight); - if (block->isRenderMathMLOperator()) - operatorCount++; - } - } - - // Layout the non-operators which have just been stretched. - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); - RenderBlock::layout(); - // Make a second pass with the real height of the operators. + // Calculate the non-operator max height of the row. int operatorHeight = 0; for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { + childCount++; if (current->isRenderMathMLBlock()) { RenderMathMLBlock* block = toRenderMathMLBlock(current); - if (!block->hasBase() && !block->isRenderMathMLOperator()) { - // Check to see if this box has a larger height. - if (block->offsetHeight() > maxHeight) - maxHeight = block->offsetHeight(); - } - if (block->isRenderMathMLOperator()) + // Check to see if the non-operator block has a greater height. + if (!block->hasBase() && !block->isRenderMathMLOperator() && block->offsetHeight() > maxHeight) + maxHeight = block->offsetHeight(); + if (block->hasBase() && block->nonOperatorHeight() > maxHeight) + maxHeight = block->nonOperatorHeight(); + // If the block is an operator, capture the maximum height and increment the count. + if (block->isRenderMathMLOperator()) { if (block->offsetHeight() > operatorHeight) operatorHeight = block->offsetHeight(); + operatorCount++; + } } else if (current->isBoxModelObject()) { RenderBoxModelObject* box = toRenderBoxModelObject(current); // Check to see if this box has a larger height. @@ -115,34 +100,23 @@ void RenderMathMLRow::layout() maxHeight = operatorHeight; } - int stretchHeight = maxHeight; - - // Stretch the operators again and re-calculate the row height. - for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { - if (current->isRenderMathMLBlock()) { - RenderMathMLBlock* block = toRenderMathMLBlock(current); - if (block->isRenderMathMLOperator()) { - RenderMathMLOperator* mathop = toRenderMathMLOperator(block); - mathop->stretchToHeight(stretchHeight); - } else { - block->stretchToHeight(stretchHeight); - RenderBoxModelObject* box = toRenderBoxModelObject(current); - // Check to see if this box has a larger height - if (box->offsetHeight() > maxHeight) - maxHeight = box->offsetHeight(); + // Stretch everything to the same height (blocks can ignore the request). + if (maxHeight > 0) { + bool didStretch = false; + for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { + if (current->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(current); + block->stretchToHeight(maxHeight); + didStretch = true; } - } else if (current->isBoxModelObject()) { - RenderBoxModelObject* box = toRenderBoxModelObject(current); - // Check to see if this box has a larger height - if (box->offsetHeight() > maxHeight) - maxHeight = box->offsetHeight(); + } + if (didStretch) { + setNeedsLayout(true); + setPreferredLogicalWidthsDirty(true, false); + RenderBlock::layout(); } } - // Mark outself as needing layout and do the final layout of the row. - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); - RenderBlock::layout(); } int RenderMathMLRow::baselinePosition(bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const diff --git a/WebCore/mathml/RenderMathMLRow.h b/WebCore/mathml/RenderMathMLRow.h index b363b1b..c877561 100644 --- a/WebCore/mathml/RenderMathMLRow.h +++ b/WebCore/mathml/RenderMathMLRow.h @@ -38,6 +38,7 @@ public: virtual bool isRenderMathMLRow() const { return true; } virtual int nonOperatorHeight() const; virtual int baselinePosition(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual void stretchToHeight(int) {} protected: virtual void layout(); }; diff --git a/WebCore/mathml/RenderMathMLSubSup.cpp b/WebCore/mathml/RenderMathMLSubSup.cpp index 8add254..6c9c6b9 100644 --- a/WebCore/mathml/RenderMathMLSubSup.cpp +++ b/WebCore/mathml/RenderMathMLSubSup.cpp @@ -95,10 +95,11 @@ void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild RefPtr<RenderStyle> wrapperStyle = RenderStyle::create(); wrapperStyle->inheritFrom(style()); wrapperStyle->setDisplay(INLINE_BLOCK); - wrapperStyle->setVerticalAlign(TOP); + wrapperStyle->setVerticalAlign(BASELINE); wrapper->setStyle(wrapperStyle.release()); RenderMathMLBlock::addChild(wrapper, beforeChild); wrapper->addChild(child); + } } @@ -111,6 +112,8 @@ void RenderMathMLSubSup::stretchToHeight(int height) if (base->firstChild()->isRenderMathMLBlock()) { RenderMathMLBlock* block = toRenderMathMLBlock(base->firstChild()); block->stretchToHeight(static_cast<int>(gSubSupStretch * height)); + + // Adjust the script placement after we stretch if (height > 0 && m_kind == SubSup && m_scripts) { RenderObject* script = m_scripts->firstChild(); if (script) { @@ -124,31 +127,28 @@ void RenderMathMLSubSup::stretchToHeight(int height) RenderBoxModelObject* topBox = toRenderBoxModelObject(top); topBox->updateBoxModelInfoFromStyle(); } - m_scripts->setNeedsLayoutAndPrefWidthsRecalc(); - m_scripts->markContainingBlocksForLayout(); + m_scripts->setNeedsLayout(true); + setNeedsLayout(true); } } + } - updateBoxModelInfoFromStyle(); - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); } int RenderMathMLSubSup::nonOperatorHeight() const { - return 0; + if (m_kind == SubSup) + return static_cast<int>(style()->fontSize()*gSubSupStretch); + return static_cast<int>(style()->fontSize()); } void RenderMathMLSubSup::layout() { - if (firstChild()) { - firstChild()->setNeedsLayoutAndPrefWidthsRecalc(); - firstChild()->markContainingBlocksForLayout(); - } - if (m_scripts) { - m_scripts->setNeedsLayoutAndPrefWidthsRecalc(); - m_scripts->markContainingBlocksForLayout(); - } + if (firstChild()) + firstChild()->setNeedsLayout(true); + if (m_scripts) + m_scripts->setNeedsLayout(true); + RenderBlock::layout(); if (m_kind == SubSup) { @@ -165,10 +165,10 @@ void RenderMathMLSubSup::layout() int heightDiff = m_scripts ? (m_scripts->offsetHeight() - maxHeight) / 2 : 0; if (heightDiff < 0) heightDiff = 0; - base->style()->setMarginTop(Length(heightDiff, Fixed)); + base->style()->setPaddingTop(Length(heightDiff, Fixed)); } - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); + setNeedsLayout(true); + base->setNeedsLayout(true); RenderBlock::layout(); } } @@ -178,17 +178,17 @@ int RenderMathMLSubSup::baselinePosition(bool firstLine, LineDirectionMode direc RenderObject* base = firstChild(); if (!base) return offsetHeight(); - base = base->firstChild(); int baseline = offsetHeight(); if (!base || !base->isBoxModelObject()) return baseline; - RenderBoxModelObject* box = toRenderBoxModelObject(base); - switch (m_kind) { case SubSup: - if (m_scripts) { + base = base->firstChild(); + if (m_scripts && base->isBoxModelObject()) { + RenderBoxModelObject* box = toRenderBoxModelObject(base); + int topAdjust = (m_scripts->offsetHeight() - box->offsetHeight()) / 2; // FIXME: The last bit of this calculation should be more exact. Why is the 2-3px scaled for zoom necessary? @@ -197,22 +197,10 @@ int RenderMathMLSubSup::baselinePosition(bool firstLine, LineDirectionMode direc return topAdjust + box->baselinePosition(firstLine, direction, linePositionMode) + static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); } break; - case Sup: { - baseline = box->baselinePosition(firstLine, direction, linePositionMode) + 4; - // FIXME: The extra amount of the superscript ascending above the base's box - // isn't taken into account. This should be calculated in a more reliable - // way. - RenderObject* sup = base->nextSibling(); - if (sup && sup->isBoxModelObject()) { - RenderBoxModelObject* box = toRenderBoxModelObject(sup); - // we'll take half of the sup's box height into account in the baseline - baseline += static_cast<int>(box->offsetHeight() * 0.5); - } - baseline++; - break; - } + case Sup: case Sub: - baseline = box->baselinePosition(true, direction) + 4; + RenderBoxModelObject* box = toRenderBoxModelObject(base); + baseline = box->baselinePosition(firstLine, direction, linePositionMode); break; } diff --git a/WebCore/mathml/RenderMathMLUnderOver.cpp b/WebCore/mathml/RenderMathMLUnderOver.cpp index 69f2c57..a76f6b1 100644 --- a/WebCore/mathml/RenderMathMLUnderOver.cpp +++ b/WebCore/mathml/RenderMathMLUnderOver.cpp @@ -118,7 +118,7 @@ inline int getOffsetHeight(RenderObject* obj) return 0; } -void RenderMathMLUnderOver::stretchToHeight(int height) +void RenderMathMLUnderOver::stretchToHeight(int height) { RenderObject* base = firstChild(); @@ -138,9 +138,7 @@ void RenderMathMLUnderOver::stretchToHeight(int height) if (base && base->isRenderMathMLBlock()) { RenderMathMLBlock* block = toRenderMathMLBlock(base); block->stretchToHeight(height); - updateBoxModelInfoFromStyle(); - setNeedsLayoutAndPrefWidthsRecalc(); - markContainingBlocksForLayout(); + setNeedsLayout(true); } } @@ -241,7 +239,7 @@ void RenderMathMLUnderOver::layout() } break; } - setNeedsLayoutAndPrefWidthsRecalc(); + setNeedsLayout(true); RenderBlock::layout(); } @@ -282,7 +280,17 @@ int RenderMathMLUnderOver::baselinePosition(bool firstLine, LineDirectionMode di int RenderMathMLUnderOver::nonOperatorHeight() const { - return 0; + int nonOperators = 0; + for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { + if (current->firstChild()->isRenderMathMLBlock()) { + RenderMathMLBlock* block = toRenderMathMLBlock(current->firstChild()); + if (!block->isRenderMathMLOperator()) + nonOperators += getOffsetHeight(current); + } else { + nonOperators += getOffsetHeight(current); + } + } + return nonOperators; } } diff --git a/WebCore/mathml/mathtags.in b/WebCore/mathml/mathtags.in index 5bb369a..b2dcb93 100644 --- a/WebCore/mathml/mathtags.in +++ b/WebCore/mathml/mathtags.in @@ -16,8 +16,8 @@ mi interfaceName=MathMLTextElement mn interfaceName=MathMLTextElement mo interfaceName=MathMLTextElement mtext interfaceName=MathMLTextElement -msub interfaceName=MathMLElement -msup interfaceName=MathMLElement +msub interfaceName=MathMLInlineContainerElement +msup interfaceName=MathMLInlineContainerElement #if 0 // Curently only for MathMLNames used by HTMLTreeBuilder. ms |