diff options
| author | Ben Murdoch <benm@google.com> | 2010-10-22 13:02:20 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2010-10-26 15:21:41 +0100 |
| commit | a94275402997c11dd2e778633dacf4b7e630a35d (patch) | |
| tree | e66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebCore/mathml | |
| parent | 09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff) | |
| download | external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2 | |
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebCore/mathml')
| -rw-r--r-- | WebCore/mathml/RenderMathMLBlock.cpp | 6 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLFenced.cpp | 9 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLFraction.cpp | 6 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLFraction.h | 2 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLOperator.cpp | 22 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLOperator.h | 5 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLRoot.cpp | 8 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLRow.cpp | 6 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLRow.h | 2 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLSquareRoot.cpp | 6 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLSubSup.cpp | 48 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLSubSup.h | 2 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLUnderOver.cpp | 31 | ||||
| -rw-r--r-- | WebCore/mathml/RenderMathMLUnderOver.h | 2 |
14 files changed, 76 insertions, 79 deletions
diff --git a/WebCore/mathml/RenderMathMLBlock.cpp b/WebCore/mathml/RenderMathMLBlock.cpp index ef94893..c625b1d 100644 --- a/WebCore/mathml/RenderMathMLBlock.cpp +++ b/WebCore/mathml/RenderMathMLBlock.cpp @@ -89,7 +89,7 @@ void RenderMathMLBlock::paint(PaintInfo& info, int tx, int ty) info.context->setStrokeThickness(1.0f); info.context->setStrokeStyle(SolidStroke); - info.context->setStrokeColor(Color(0, 0, 255), sRGBColorSpace); + info.context->setStrokeColor(Color(0, 0, 255), ColorSpaceSRGB); info.context->drawLine(IntPoint(tx, ty), IntPoint(tx + offsetWidth(), ty)); info.context->drawLine(IntPoint(tx + offsetWidth(), ty), IntPoint(tx + offsetWidth(), ty + offsetHeight())); @@ -98,13 +98,13 @@ void RenderMathMLBlock::paint(PaintInfo& info, int tx, int ty) int topStart = paddingTop(); - info.context->setStrokeColor(Color(0, 255, 0), sRGBColorSpace); + info.context->setStrokeColor(Color(0, 255, 0), ColorSpaceSRGB); info.context->drawLine(IntPoint(tx, ty + topStart), IntPoint(tx + offsetWidth(), ty + topStart)); int baseline = baselinePosition(true); - info.context->setStrokeColor(Color(255, 0, 0), sRGBColorSpace); + info.context->setStrokeColor(Color(255, 0, 0), ColorSpaceSRGB); info.context->drawLine(IntPoint(tx, ty + baseline), IntPoint(tx + offsetWidth(), ty + baseline)); diff --git a/WebCore/mathml/RenderMathMLFenced.cpp b/WebCore/mathml/RenderMathMLFenced.cpp index 6c0bb0b..a304fa4 100644 --- a/WebCore/mathml/RenderMathMLFenced.cpp +++ b/WebCore/mathml/RenderMathMLFenced.cpp @@ -40,6 +40,8 @@ namespace WebCore { using namespace MathMLNames; enum Braces { OpeningBraceChar = 0x28, ClosingBraceChar = 0x29 }; + +static const float gOperatorPadding = 0.1f; RenderMathMLFenced::RenderMathMLFenced(Node* fenced) : RenderMathMLRow(fenced) @@ -67,7 +69,7 @@ void RenderMathMLFenced::updateFromElement() if (!isSpaceOrNewline(separators[i])) characters.append(separators[i]); } - m_separators = !separators.length() ? 0 : StringImpl::create(characters.data() , characters.size()); + m_separators = !characters.size() ? 0 : StringImpl::create(characters.data() , characters.size()); } else { // The separator defaults to a single comma. m_separators = StringImpl::create(","); @@ -82,8 +84,7 @@ RefPtr<RenderStyle> RenderMathMLFenced::makeOperatorStyle() RefPtr<RenderStyle> newStyle = RenderStyle::create(); newStyle->inheritFrom(style()); newStyle->setDisplay(INLINE_BLOCK); - newStyle->setHeight(Length(100.0, Percent)); - newStyle->setVerticalAlign(MIDDLE); + newStyle->setPaddingRight(Length(static_cast<int>(gOperatorPadding * style()->fontSize()), Fixed)); return newStyle; } @@ -158,6 +159,8 @@ void RenderMathMLFenced::layout() setNeedsLayoutAndPrefWidthsRecalc(); markContainingBlocksForLayout(); RenderBlock::layout(); + + setNeedsLayout(false); } } diff --git a/WebCore/mathml/RenderMathMLFraction.cpp b/WebCore/mathml/RenderMathMLFraction.cpp index 914f6fe..92c8101 100644 --- a/WebCore/mathml/RenderMathMLFraction.cpp +++ b/WebCore/mathml/RenderMathMLFraction.cpp @@ -167,14 +167,14 @@ void RenderMathMLFraction::paint(PaintInfo& info, int tx, int ty) info.context->setStrokeThickness(static_cast<float>(m_lineThickness)); info.context->setStrokeStyle(SolidStroke); - info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), sRGBColorSpace); + info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceSRGB); info.context->drawLine(IntPoint(tx, ty), IntPoint(tx + offsetWidth(), ty)); info.context->restore(); } -int RenderMathMLFraction::baselinePosition(bool firstLine, bool isRootLineBox) const +int RenderMathMLFraction::baselinePosition(bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const { if (firstChild() && firstChild()->isRenderMathMLBlock()) { RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild()); @@ -184,7 +184,7 @@ int RenderMathMLFraction::baselinePosition(bool firstLine, bool isRootLineBox) c // a good guess. return numerator->offsetHeight() + style()->fontSize() / 3; } - return RenderBlock::baselinePosition(firstLine, isRootLineBox); + return RenderBlock::baselinePosition(firstLine, lineDirection, linePositionMode); } } diff --git a/WebCore/mathml/RenderMathMLFraction.h b/WebCore/mathml/RenderMathMLFraction.h index c8c1cb8..d0f3fe0 100644 --- a/WebCore/mathml/RenderMathMLFraction.h +++ b/WebCore/mathml/RenderMathMLFraction.h @@ -38,7 +38,7 @@ public: RenderMathMLFraction(Element* fraction); virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); virtual void updateFromElement(); - virtual int baselinePosition(bool , bool) const; + virtual int baselinePosition(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void paint(PaintInfo&, int tx, int ty); protected: virtual void layout(); diff --git a/WebCore/mathml/RenderMathMLOperator.cpp b/WebCore/mathml/RenderMathMLOperator.cpp index a6778a9..1e3b429 100644 --- a/WebCore/mathml/RenderMathMLOperator.cpp +++ b/WebCore/mathml/RenderMathMLOperator.cpp @@ -174,7 +174,6 @@ void RenderMathMLOperator::updateFromElement() // We only stretch character if the stretch height is larger than a minimum size (e.g. 24px). bool shouldStretch = isStretchy && m_stretchHeight>gMinimumStretchHeight; - m_isCentered = true; // Either stretch is disabled or we don't have a stretchable character over the minimum height if (stretchDisabled || !shouldStretch) { @@ -184,6 +183,7 @@ void RenderMathMLOperator::updateFromElement() RefPtr<RenderStyle> newStyle = RenderStyle::create(); newStyle->inheritFrom(style()); newStyle->setDisplay(INLINE_BLOCK); + newStyle->setVerticalAlign(BASELINE); // Check for a stretchable character that is under the minimum height and use the // font size to adjust the glyph size. @@ -195,18 +195,6 @@ void RenderMathMLOperator::updateFromElement() desc.setComputedSize(m_stretchHeight); newStyle->setFontDescription(desc); newStyle->font().update(newStyle->font().fontSelector()); - newStyle->setVerticalAlign(BASELINE); - m_isCentered = false; - } else { - int topPad = (m_stretchHeight - currentFontSize) / 2; - - if (topPad / static_cast<float>(m_stretchHeight) > gMinimumRatioForStretch) { - newStyle->setVerticalAlign(TOP); - newStyle->setPaddingTop(Length(topPad, Fixed)); - } else { - m_isCentered = false; - newStyle->setVerticalAlign(BASELINE); - } } container->setStyle(newStyle.release()); @@ -345,13 +333,11 @@ RenderBlock* RenderMathMLOperator::createGlyph(UChar glyph, int size, int charRe return container; } -int RenderMathMLOperator::baselinePosition(bool firstLine, bool isRootLineBox) const +int RenderMathMLOperator::baselinePosition(bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const { if (m_isStacked) - return m_stretchHeight * 2 / 3 - (m_stretchHeight - static_cast<int>(m_stretchHeight / gOperatorExpansion)) / 2; - if (m_isCentered && firstChild()) - return firstChild()->baselinePosition(firstLine, isRootLineBox); - return RenderBlock::baselinePosition(firstLine, isRootLineBox); + return m_stretchHeight * 2 / 3 - (m_stretchHeight - static_cast<int>(m_stretchHeight / gOperatorExpansion)) / 2; + return RenderBlock::baselinePosition(firstLine, lineDirection, linePositionMode); } } diff --git a/WebCore/mathml/RenderMathMLOperator.h b/WebCore/mathml/RenderMathMLOperator.h index 99c5246..7091b34 100644 --- a/WebCore/mathml/RenderMathMLOperator.h +++ b/WebCore/mathml/RenderMathMLOperator.h @@ -41,8 +41,8 @@ public: virtual void stretchToHeight(int pixelHeight); virtual void updateFromElement(); virtual bool isChildAllowed(RenderObject*, RenderStyle*) const; - virtual int baselinePosition(bool , bool) const; - + virtual int baselinePosition(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + protected: virtual void layout(); virtual RefPtr<RenderStyle> createStackableStyle(int size, int topRelative); @@ -51,7 +51,6 @@ protected: private: int m_stretchHeight; bool m_isStacked; - bool m_isCentered; UChar m_operator; }; diff --git a/WebCore/mathml/RenderMathMLRoot.cpp b/WebCore/mathml/RenderMathMLRoot.cpp index da303c9..ab15c80 100644 --- a/WebCore/mathml/RenderMathMLRoot.cpp +++ b/WebCore/mathml/RenderMathMLRoot.cpp @@ -151,7 +151,7 @@ void RenderMathMLRoot::paint(PaintInfo& info, int tx, int ty) info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize()); info.context->setStrokeStyle(SolidStroke); - info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), DeviceColorSpace); + info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB); info.context->setLineJoin(MiterJoin); info.context->setMiterLimit(style()->fontSize()); @@ -190,9 +190,9 @@ void RenderMathMLRoot::paint(PaintInfo& info, int tx, int ty) info.context->setLineCap(SquareCap); Path line; - - line = line.createLine(bottomLeft, topLeft); - + line.moveTo(bottomLeft); + line.addLineTo(topLeft); + info.context->beginPath(); info.context->addPath(line); info.context->strokePath(); diff --git a/WebCore/mathml/RenderMathMLRow.cpp b/WebCore/mathml/RenderMathMLRow.cpp index acbfb9d..632b794 100644 --- a/WebCore/mathml/RenderMathMLRow.cpp +++ b/WebCore/mathml/RenderMathMLRow.cpp @@ -145,15 +145,15 @@ void RenderMathMLRow::layout() RenderBlock::layout(); } -int RenderMathMLRow::baselinePosition(bool firstLine, bool isRootLineBox) const +int RenderMathMLRow::baselinePosition(bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { if (firstChild() && firstChild()->isRenderMathMLBlock()) { RenderMathMLBlock* block = toRenderMathMLBlock(firstChild()); if (block->isRenderMathMLOperator()) - return block->baselinePosition(firstLine, isRootLineBox); + return block->y() + block->baselinePosition(firstLine, direction, linePositionMode); } - return RenderBlock::baselinePosition(firstLine, isRootLineBox); + return RenderBlock::baselinePosition(firstLine, direction, linePositionMode); } } diff --git a/WebCore/mathml/RenderMathMLRow.h b/WebCore/mathml/RenderMathMLRow.h index 83c6832..b363b1b 100644 --- a/WebCore/mathml/RenderMathMLRow.h +++ b/WebCore/mathml/RenderMathMLRow.h @@ -37,7 +37,7 @@ public: RenderMathMLRow(Node* container); virtual bool isRenderMathMLRow() const { return true; } virtual int nonOperatorHeight() const; - virtual int baselinePosition(bool , bool) const; + virtual int baselinePosition(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; protected: virtual void layout(); }; diff --git a/WebCore/mathml/RenderMathMLSquareRoot.cpp b/WebCore/mathml/RenderMathMLSquareRoot.cpp index 86add7a..862d8a4 100644 --- a/WebCore/mathml/RenderMathMLSquareRoot.cpp +++ b/WebCore/mathml/RenderMathMLSquareRoot.cpp @@ -117,7 +117,7 @@ void RenderMathMLSquareRoot::paint(PaintInfo& info, int tx, int ty) info.context->setStrokeThickness(gRadicalLineThickness * style()->fontSize()); info.context->setStrokeStyle(SolidStroke); - info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), DeviceColorSpace); + info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB); info.context->setLineJoin(MiterJoin); info.context->setMiterLimit(style()->fontSize()); @@ -156,8 +156,8 @@ void RenderMathMLSquareRoot::paint(PaintInfo& info, int tx, int ty) info.context->setLineCap(SquareCap); Path line; - - line = line.createLine(bottomLeft, topLeft); + line.moveTo(bottomLeft); + line.addLineTo(topLeft); info.context->beginPath(); info.context->addPath(line); diff --git a/WebCore/mathml/RenderMathMLSubSup.cpp b/WebCore/mathml/RenderMathMLSubSup.cpp index 4cda36f..8add254 100644 --- a/WebCore/mathml/RenderMathMLSubSup.cpp +++ b/WebCore/mathml/RenderMathMLSubSup.cpp @@ -173,49 +173,47 @@ void RenderMathMLSubSup::layout() } } -int RenderMathMLSubSup::baselinePosition(bool firstLine, bool isRootLineBox) const +int RenderMathMLSubSup::baselinePosition(bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { RenderObject* base = firstChild(); if (!base) return offsetHeight(); base = base->firstChild(); - if (!base) - return offsetHeight(); int baseline = offsetHeight(); - + if (!base || !base->isBoxModelObject()) + return baseline; + + RenderBoxModelObject* box = toRenderBoxModelObject(base); + switch (m_kind) { case SubSup: if (m_scripts) { - int topAdjust = 0; - if (base->isBoxModelObject()) { - RenderBoxModelObject* box = toRenderBoxModelObject(base); - topAdjust = (m_scripts->offsetHeight() - box->offsetHeight()) / 2; - } + 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? // The baseline is top spacing of the base + the baseline of the base + adjusted space for zoom float zoomFactor = style()->effectiveZoom(); - return topAdjust + base->baselinePosition(firstLine, isRootLineBox) + static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); + return topAdjust + box->baselinePosition(firstLine, direction, linePositionMode) + static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); } break; - case Sup: - if (base) { - baseline = base->baselinePosition(firstLine, isRootLineBox) + 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++; + 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 Sub: - if (base) - baseline = base->baselinePosition(true) + 4; + baseline = box->baselinePosition(true, direction) + 4; + break; } return baseline; diff --git a/WebCore/mathml/RenderMathMLSubSup.h b/WebCore/mathml/RenderMathMLSubSup.h index 037ef89..3e62eb0 100644 --- a/WebCore/mathml/RenderMathMLSubSup.h +++ b/WebCore/mathml/RenderMathMLSubSup.h @@ -41,7 +41,7 @@ public: virtual bool hasBase() const { return true; } virtual int nonOperatorHeight() const; virtual void stretchToHeight(int pixelHeight); - virtual int baselinePosition(bool, bool) const; + virtual int baselinePosition(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; protected: virtual void layout(); diff --git a/WebCore/mathml/RenderMathMLUnderOver.cpp b/WebCore/mathml/RenderMathMLUnderOver.cpp index f015054..69f2c57 100644 --- a/WebCore/mathml/RenderMathMLUnderOver.cpp +++ b/WebCore/mathml/RenderMathMLUnderOver.cpp @@ -157,7 +157,10 @@ void RenderMathMLUnderOver::layout() if (over) { // FIXME: descending glyphs intrude into base (e.g. lowercase y over base) // FIXME: bases that ascend higher than the line box intrude into the over - int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - over->firstChild()->baselinePosition(true))); + if (!over->firstChild()->isBoxModelObject()) + break; + + int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - toRenderBoxModelObject(over->firstChild())->baselinePosition(true, HorizontalLine))); // base row wrapper base = over->nextSibling(); @@ -182,9 +185,12 @@ void RenderMathMLUnderOver::layout() int baseHeight = getOffsetHeight(base); // actual base base = base->firstChild(); + if (!base->isBoxModelObject()) + break; + // FIXME: We need to look at the space between a single maximum height of // the line boxes and the baseline and squeeze them together - int underSpacing = baseHeight - base->baselinePosition(true); + int underSpacing = baseHeight - toRenderBoxModelObject(base)->baselinePosition(true, HorizontalLine); // adjust the base's intrusion into the under RenderObject* under = lastChild(); @@ -203,7 +209,9 @@ void RenderMathMLUnderOver::layout() if (over) { // FIXME: descending glyphs intrude into base (e.g. lowercase y over base) // FIXME: bases that ascend higher than the line box intrude into the over - int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - over->firstChild()->baselinePosition(true))); + if (!over->firstChild()->isBoxModelObject()) + break; + int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - toRenderBoxModelObject(over->firstChild())->baselinePosition(true, HorizontalLine))); // base row wrapper base = over->nextSibling(); @@ -218,9 +226,12 @@ void RenderMathMLUnderOver::layout() int baseHeight = getOffsetHeight(base); // actual base base = base->firstChild(); + if (!base->isBoxModelObject()) + break; + // FIXME: We need to look at the space between a single maximum height of // the line boxes and the baseline and squeeze them together - int underSpacing = baseHeight - base->baselinePosition(true); + int underSpacing = baseHeight - toRenderBoxModelObject(base)->baselinePosition(true, HorizontalLine); RenderObject* under = lastChild(); if (under && under->firstChild()->isRenderInline() && underSpacing > 0) @@ -234,11 +245,11 @@ void RenderMathMLUnderOver::layout() RenderBlock::layout(); } -int RenderMathMLUnderOver::baselinePosition(bool firstLine, bool isRootLineBox) const +int RenderMathMLUnderOver::baselinePosition(bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { RenderObject* current = firstChild(); if (!current) - return RenderBlock::baselinePosition(firstLine, isRootLineBox); + return RenderBlock::baselinePosition(firstLine, direction, linePositionMode); int baseline = 0; switch (m_kind) { @@ -249,17 +260,17 @@ int RenderMathMLUnderOver::baselinePosition(bool firstLine, bool isRootLineBox) if (current) { // actual base RenderObject* base = current->firstChild(); - if (!base) + if (!base || !base->isBoxModelObject()) break; - baseline += base->baselinePosition(firstLine, isRootLineBox); + baseline += toRenderBoxModelObject(base)->baselinePosition(firstLine, HorizontalLine, linePositionMode); // added the negative top margin baseline += current->style()->marginTop().value(); } break; case Under: RenderObject* base = current->firstChild(); - if (base) - baseline += base->baselinePosition(true); + if (base && base->isBoxModelObject()) + baseline += toRenderBoxModelObject(base)->baselinePosition(true, HorizontalLine); } // FIXME: Where is the extra 2-3px adjusted for zoom coming from? diff --git a/WebCore/mathml/RenderMathMLUnderOver.h b/WebCore/mathml/RenderMathMLUnderOver.h index 5917126..88edea8 100644 --- a/WebCore/mathml/RenderMathMLUnderOver.h +++ b/WebCore/mathml/RenderMathMLUnderOver.h @@ -40,7 +40,7 @@ public: virtual void layout(); virtual bool hasBase() const { return true; } virtual int nonOperatorHeight() const; - virtual int baselinePosition(bool , bool) const; + virtual int baselinePosition(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void stretchToHeight(int pixelHeight); private: enum UnderOverType { Under, Over, UnderOver }; |
