diff options
Diffstat (limited to 'Source/WebCore/rendering')
61 files changed, 355 insertions, 231 deletions
diff --git a/Source/WebCore/rendering/AutoTableLayout.cpp b/Source/WebCore/rendering/AutoTableLayout.cpp index 08ecff90e..fb436ca55 100644 --- a/Source/WebCore/rendering/AutoTableLayout.cpp +++ b/Source/WebCore/rendering/AutoTableLayout.cpp @@ -49,81 +49,77 @@ void AutoTableLayout::recalcColumn(unsigned effCol) RenderTableCell* fixedContributor = 0; RenderTableCell* maxContributor = 0; - for (RenderObject* child = m_table->children()->firstChild(); child; child = child->nextSibling()) { - if (child->isRenderTableCol()) - toRenderTableCol(child)->computePreferredLogicalWidths(); - else if (child->isTableSection()) { - RenderTableSection* section = toRenderTableSection(child); - unsigned numRows = section->numRows(); - for (unsigned i = 0; i < numRows; i++) { - RenderTableSection::CellStruct current = section->cellAt(i, effCol); - RenderTableCell* cell = current.primaryCell(); - - if (current.inColSpan || !cell) - continue; - - bool cellHasContent = cell->children()->firstChild() || cell->style()->hasBorder() || cell->style()->hasPadding(); - if (cellHasContent) - columnLayout.emptyCellsOnly = false; - - // A cell originates in this column. Ensure we have - // a min/max width of at least 1px for this column now. - columnLayout.minLogicalWidth = max<int>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0); - columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1); - - if (cell->colSpan() == 1) { - if (cell->preferredLogicalWidthsDirty()) - cell->computePreferredLogicalWidths(); - columnLayout.minLogicalWidth = max<int>(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth); - if (cell->maxPreferredLogicalWidth() > columnLayout.maxLogicalWidth) { - columnLayout.maxLogicalWidth = cell->maxPreferredLogicalWidth(); - maxContributor = cell; - } + for (RenderTableSection* section = m_table->topNonEmptySection(); section; section = m_table->sectionBelow(section, SkipEmptySections)) { + unsigned numRows = section->numRows(); + ASSERT(numRows); + for (unsigned i = 0; i < numRows; i++) { + RenderTableSection::CellStruct current = section->cellAt(i, effCol); + RenderTableCell* cell = current.primaryCell(); + + if (current.inColSpan || !cell) + continue; - // All browsers implement a size limit on the cell's max width. - // Our limit is based on KHTML's representation that used 16 bits widths. - // FIXME: Other browsers have a lower limit for the cell's max width. - const int cCellMaxWidth = 32760; - Length cellLogicalWidth = cell->styleOrColLogicalWidth(); - if (cellLogicalWidth.value() > cCellMaxWidth) - cellLogicalWidth.setValue(cCellMaxWidth); - if (cellLogicalWidth.isNegative()) - cellLogicalWidth.setValue(0); - switch (cellLogicalWidth.type()) { - case Fixed: - // ignore width=0 - if (cellLogicalWidth.isPositive() && !columnLayout.logicalWidth.isPercent()) { - LayoutUnit logicalWidth = cell->adjustBorderBoxLogicalWidthForBoxSizing(cellLogicalWidth.value()); - if (columnLayout.logicalWidth.isFixed()) { - // Nav/IE weirdness - if ((logicalWidth > columnLayout.logicalWidth.value()) - || ((columnLayout.logicalWidth.value() == logicalWidth) && (maxContributor == cell))) { - columnLayout.logicalWidth.setValue(Fixed, logicalWidth); - fixedContributor = cell; - } - } else { + bool cellHasContent = cell->children()->firstChild() || cell->style()->hasBorder() || cell->style()->hasPadding(); + if (cellHasContent) + columnLayout.emptyCellsOnly = false; + + // A cell originates in this column. Ensure we have + // a min/max width of at least 1px for this column now. + columnLayout.minLogicalWidth = max<int>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0); + columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1); + + if (cell->colSpan() == 1) { + if (cell->preferredLogicalWidthsDirty()) + cell->computePreferredLogicalWidths(); + columnLayout.minLogicalWidth = max<int>(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth); + if (cell->maxPreferredLogicalWidth() > columnLayout.maxLogicalWidth) { + columnLayout.maxLogicalWidth = cell->maxPreferredLogicalWidth(); + maxContributor = cell; + } + + // All browsers implement a size limit on the cell's max width. + // Our limit is based on KHTML's representation that used 16 bits widths. + // FIXME: Other browsers have a lower limit for the cell's max width. + const int cCellMaxWidth = 32760; + Length cellLogicalWidth = cell->styleOrColLogicalWidth(); + if (cellLogicalWidth.value() > cCellMaxWidth) + cellLogicalWidth.setValue(cCellMaxWidth); + if (cellLogicalWidth.isNegative()) + cellLogicalWidth.setValue(0); + switch (cellLogicalWidth.type()) { + case Fixed: + // ignore width=0 + if (cellLogicalWidth.isPositive() && !columnLayout.logicalWidth.isPercent()) { + LayoutUnit logicalWidth = cell->adjustBorderBoxLogicalWidthForBoxSizing(cellLogicalWidth.value()); + if (columnLayout.logicalWidth.isFixed()) { + // Nav/IE weirdness + if ((logicalWidth > columnLayout.logicalWidth.value()) + || ((columnLayout.logicalWidth.value() == logicalWidth) && (maxContributor == cell))) { columnLayout.logicalWidth.setValue(Fixed, logicalWidth); fixedContributor = cell; } + } else { + columnLayout.logicalWidth.setValue(Fixed, logicalWidth); + fixedContributor = cell; } - break; - case Percent: - m_hasPercent = true; - if (cellLogicalWidth.isPositive() && (!columnLayout.logicalWidth.isPercent() || cellLogicalWidth.value() > columnLayout.logicalWidth.value())) - columnLayout.logicalWidth = cellLogicalWidth; - break; - case Relative: - // FIXME: Need to understand this case and whether it makes sense to compare values - // which are not necessarily of the same type. - if (cellLogicalWidth.value() > columnLayout.logicalWidth.value()) - columnLayout.logicalWidth = cellLogicalWidth; - default: - break; } - } else if (!effCol || section->primaryCellAt(i, effCol - 1) != cell) { - // This spanning cell originates in this column. Insert the cell into spanning cells list. - insertSpanCell(cell); + break; + case Percent: + m_hasPercent = true; + if (cellLogicalWidth.isPositive() && (!columnLayout.logicalWidth.isPercent() || cellLogicalWidth.value() > columnLayout.logicalWidth.value())) + columnLayout.logicalWidth = cellLogicalWidth; + break; + case Relative: + // FIXME: Need to understand this case and whether it makes sense to compare values + // which are not necessarily of the same type. + if (cellLogicalWidth.value() > columnLayout.logicalWidth.value()) + columnLayout.logicalWidth = cellLogicalWidth; + default: + break; } + } else if (!effCol || section->primaryCellAt(i, effCol - 1) != cell) { + // This spanning cell originates in this column. Insert the cell into spanning cells list. + insertSpanCell(cell); } } } diff --git a/Source/WebCore/rendering/ExclusionPolygon.cpp b/Source/WebCore/rendering/ExclusionPolygon.cpp index ba20dc2e6..eaeeba70d 100644 --- a/Source/WebCore/rendering/ExclusionPolygon.cpp +++ b/Source/WebCore/rendering/ExclusionPolygon.cpp @@ -241,13 +241,13 @@ void ExclusionPolygon::computeEdgeIntersections(float y1, float y2, Vector<Exclu sortExclusionIntervals(result); } -void ExclusionPolygon::getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const +void ExclusionPolygon::getExcludedIntervals(float logicalTop, float logicalHeight, SegmentList& result) const { if (isEmpty()) return; - float y1 = minYForLogicalLine(logicalTop, logicalBottom); - float y2 = maxYForLogicalLine(logicalTop, logicalBottom); + float y1 = minYForLogicalLine(logicalTop, logicalHeight); + float y2 = maxYForLogicalLine(logicalTop, logicalHeight); Vector<ExclusionInterval> y1XIntervals, y2XIntervals; computeXIntersections(y1, y1XIntervals); @@ -268,13 +268,13 @@ void ExclusionPolygon::getExcludedIntervals(float logicalTop, float logicalBotto } } -void ExclusionPolygon::getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const +void ExclusionPolygon::getIncludedIntervals(float logicalTop, float logicalHeight, SegmentList& result) const { if (isEmpty()) return; - float y1 = minYForLogicalLine(logicalTop, logicalBottom); - float y2 = maxYForLogicalLine(logicalTop, logicalBottom); + float y1 = minYForLogicalLine(logicalTop, logicalHeight); + float y2 = maxYForLogicalLine(logicalTop, logicalHeight); Vector<ExclusionInterval> y1XIntervals, y2XIntervals; computeXIntersections(y1, y1XIntervals); diff --git a/Source/WebCore/rendering/ExclusionPolygon.h b/Source/WebCore/rendering/ExclusionPolygon.h index 57e35520d..be28a7f45 100644 --- a/Source/WebCore/rendering/ExclusionPolygon.h +++ b/Source/WebCore/rendering/ExclusionPolygon.h @@ -60,9 +60,9 @@ public: WindRule fillRule() const { return m_fillRule; } virtual FloatRect shapeLogicalBoundingBox() const OVERRIDE { return internalToLogicalBoundingBox(m_boundingBox); } - virtual void getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const OVERRIDE; - virtual void getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const OVERRIDE; virtual bool isEmpty() const OVERRIDE { return m_empty; } + virtual void getExcludedIntervals(float logicalTop, float logicalHeight, SegmentList&) const OVERRIDE; + virtual void getIncludedIntervals(float logicalTop, float logicalHeight, SegmentList&) const OVERRIDE; private: float rightVertexY(unsigned) const; diff --git a/Source/WebCore/rendering/ExclusionRectangle.cpp b/Source/WebCore/rendering/ExclusionRectangle.cpp index 0ccf6224a..328cba2f3 100644 --- a/Source/WebCore/rendering/ExclusionRectangle.cpp +++ b/Source/WebCore/rendering/ExclusionRectangle.cpp @@ -40,13 +40,13 @@ static inline float ellipseXIntercept(float y, float rx, float ry) return rx * sqrt(1 - (y*y) / (ry*ry)); } -void ExclusionRectangle::getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const +void ExclusionRectangle::getExcludedIntervals(float logicalTop, float logicalHeight, SegmentList& result) const { if (isEmpty()) return; - float y1 = minYForLogicalLine(logicalTop, logicalBottom); - float y2 = maxYForLogicalLine(logicalTop, logicalBottom); + float y1 = minYForLogicalLine(logicalTop, logicalHeight); + float y2 = maxYForLogicalLine(logicalTop, logicalHeight); if (y2 < m_y || y1 >= m_y + m_height) return; @@ -71,13 +71,13 @@ void ExclusionRectangle::getExcludedIntervals(float logicalTop, float logicalBot result.append(LineSegment(x1, x2)); } -void ExclusionRectangle::getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList& result) const +void ExclusionRectangle::getIncludedIntervals(float logicalTop, float logicalHeight, SegmentList& result) const { if (isEmpty()) return; - float y1 = minYForLogicalLine(logicalTop, logicalBottom); - float y2 = maxYForLogicalLine(logicalTop, logicalBottom); + float y1 = minYForLogicalLine(logicalTop, logicalHeight); + float y2 = maxYForLogicalLine(logicalTop, logicalHeight); if (y1 < m_y || y2 > m_y + m_height) return; diff --git a/Source/WebCore/rendering/ExclusionRectangle.h b/Source/WebCore/rendering/ExclusionRectangle.h index 0078264dd..5839eec47 100644 --- a/Source/WebCore/rendering/ExclusionRectangle.h +++ b/Source/WebCore/rendering/ExclusionRectangle.h @@ -51,9 +51,9 @@ public: } virtual FloatRect shapeLogicalBoundingBox() const OVERRIDE { return internalToLogicalBoundingBox(FloatRect(m_x, m_y, m_width, m_height)); } - virtual void getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const OVERRIDE; - virtual void getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const OVERRIDE; virtual bool isEmpty() const OVERRIDE { return m_width <= 0 || m_height <= 0; } + virtual void getExcludedIntervals(float logicalTop, float logicalHeight, SegmentList&) const OVERRIDE; + virtual void getIncludedIntervals(float logicalTop, float logicalHeight, SegmentList&) const OVERRIDE; private: float m_x; diff --git a/Source/WebCore/rendering/ExclusionShape.h b/Source/WebCore/rendering/ExclusionShape.h index a75ab70e8..075c002c7 100644 --- a/Source/WebCore/rendering/ExclusionShape.h +++ b/Source/WebCore/rendering/ExclusionShape.h @@ -39,14 +39,14 @@ namespace WebCore { struct LineSegment { - float logicalLeft; - float logicalRight; - LineSegment(float logicalLeft, float logicalRight) : logicalLeft(logicalLeft) , logicalRight(logicalRight) { } + + float logicalLeft; + float logicalRight; }; typedef Vector<LineSegment> SegmentList; @@ -64,14 +64,13 @@ public: virtual ~ExclusionShape() { } virtual FloatRect shapeLogicalBoundingBox() const = 0; - virtual FloatRect shapeBoundingBox() const { return m_boundingBox; } - virtual void getIncludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const = 0; - virtual void getExcludedIntervals(float logicalTop, float logicalBottom, SegmentList&) const = 0; virtual bool isEmpty() const = 0; + virtual void getIncludedIntervals(float logicalTop, float logicalHeight, SegmentList&) const = 0; + virtual void getExcludedIntervals(float logicalTop, float logicalHeight, SegmentList&) const = 0; protected: - float minYForLogicalLine(float logicalTop, float logicalBottom) const { return (m_writingMode == RightToLeftWritingMode) ? m_logicalBoxHeight - logicalBottom : logicalTop; } - float maxYForLogicalLine(float logicalTop, float logicalBottom) const { return (m_writingMode == RightToLeftWritingMode) ? m_logicalBoxHeight - logicalTop : logicalBottom; } + float minYForLogicalLine(float logicalTop, float logicalHeight) const { return (m_writingMode == RightToLeftWritingMode) ? m_logicalBoxHeight - logicalTop - logicalHeight : logicalTop; } + float maxYForLogicalLine(float logicalTop, float logicalHeight) const { return (m_writingMode == RightToLeftWritingMode) ? m_logicalBoxHeight - logicalTop : logicalTop + logicalHeight; } FloatRect internalToLogicalBoundingBox(FloatRect r) const { return (m_writingMode == RightToLeftWritingMode) ? FloatRect(r.x(), m_logicalBoxHeight - r.maxY(), r.width(), r.height()) : r; } private: diff --git a/Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp b/Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp index bf7f30dfd..b7830f10e 100644 --- a/Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp +++ b/Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp @@ -100,16 +100,16 @@ void ExclusionShapeInsideInfo::computeShapeSize(LayoutUnit logicalWidth, LayoutU ASSERT(m_shape); } -bool ExclusionShapeInsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineBottom) +bool ExclusionShapeInsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) { - ASSERT(lineTop <= lineBottom); + ASSERT(lineHeight >= 0); m_lineTop = lineTop; - m_lineBottom = lineBottom; + m_lineHeight = lineHeight; m_segments.clear(); if (lineOverlapsShapeBounds()) { ASSERT(m_shape); - m_shape->getIncludedIntervals(lineTop, std::min(lineBottom, shapeLogicalBottom()), m_segments); + m_shape->getIncludedIntervals(lineTop, std::min(lineHeight, shapeLogicalBottom() - lineTop), m_segments); } return m_segments.size(); } diff --git a/Source/WebCore/rendering/ExclusionShapeInsideInfo.h b/Source/WebCore/rendering/ExclusionShapeInsideInfo.h index 9db1b101e..bea2b45a0 100644 --- a/Source/WebCore/rendering/ExclusionShapeInsideInfo.h +++ b/Source/WebCore/rendering/ExclusionShapeInsideInfo.h @@ -73,7 +73,7 @@ public: ASSERT(hasSegments()); return m_segments; } - bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineBottom); + bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight); bool lineOverlapsShapeBounds() const; void computeShapeSize(LayoutUnit logicalWidth, LayoutUnit logicalHeight); void dirtyShapeSize() { m_shapeSizeDirty = true; } @@ -85,7 +85,7 @@ private: OwnPtr<ExclusionShape> m_shape; LayoutUnit m_lineTop; - LayoutUnit m_lineBottom; + LayoutUnit m_lineHeight; LayoutUnit m_logicalWidth; LayoutUnit m_logicalHeight; @@ -97,7 +97,7 @@ inline bool ExclusionShapeInsideInfo::lineOverlapsShapeBounds() const { ASSERT(m_shape); FloatRect shapeBounds = m_shape->shapeLogicalBoundingBox(); - return m_lineTop <= shapeBounds.maxY() && m_lineBottom >= shapeBounds.y(); + return m_lineTop < shapeBounds.maxY() && m_lineTop + m_lineHeight >= shapeBounds.y(); } } diff --git a/Source/WebCore/rendering/FixedTableLayout.cpp b/Source/WebCore/rendering/FixedTableLayout.cpp index 2a08ad6b5..eed6e0b54 100644 --- a/Source/WebCore/rendering/FixedTableLayout.cpp +++ b/Source/WebCore/rendering/FixedTableLayout.cpp @@ -88,8 +88,6 @@ int FixedTableLayout::calcWidthArray(int) unsigned currentEffectiveColumn = 0; for (RenderTableCol* col = m_table->firstColumn(); col; col = col->nextColumn()) { - col->computePreferredLogicalWidths(); - // Width specified by column-groups that have column child does not affect column width in fixed layout tables if (col->isTableColumnGroupWithColumnChildren()) continue; diff --git a/Source/WebCore/rendering/InlineBox.cpp b/Source/WebCore/rendering/InlineBox.cpp index 01742e5bf..18079ff0b 100644 --- a/Source/WebCore/rendering/InlineBox.cpp +++ b/Source/WebCore/rendering/InlineBox.cpp @@ -159,7 +159,7 @@ float InlineBox::logicalHeight() const return result; } -LayoutUnit InlineBox::baselinePosition(FontBaseline baselineType) const +int InlineBox::baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); } diff --git a/Source/WebCore/rendering/InlineBox.h b/Source/WebCore/rendering/InlineBox.h index a6b94debb..e2cf85fdc 100644 --- a/Source/WebCore/rendering/InlineBox.h +++ b/Source/WebCore/rendering/InlineBox.h @@ -246,7 +246,7 @@ public: FloatRect logicalFrameRect() const { return isHorizontal() ? FloatRect(m_topLeft.x(), m_topLeft.y(), m_logicalWidth, logicalHeight()) : FloatRect(m_topLeft.y(), m_topLeft.x(), m_logicalWidth, logicalHeight()); } - virtual LayoutUnit baselinePosition(FontBaseline baselineType) const; + virtual int baselinePosition(FontBaseline baselineType) const; virtual LayoutUnit lineHeight() const; virtual int caretMinOffset() const; diff --git a/Source/WebCore/rendering/InlineFlowBox.cpp b/Source/WebCore/rendering/InlineFlowBox.cpp index 8e6714068..66bc11e09 100644 --- a/Source/WebCore/rendering/InlineFlowBox.cpp +++ b/Source/WebCore/rendering/InlineFlowBox.cpp @@ -475,7 +475,7 @@ bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo return false; } -void InlineFlowBox::adjustMaxAscentAndDescent(LayoutUnit& maxAscent, LayoutUnit& maxDescent, LayoutUnit maxPositionTop, LayoutUnit maxPositionBottom) +void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, int maxPositionTop, int maxPositionBottom) { for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { // The computed lineheight needs to be extended for the @@ -483,7 +483,7 @@ void InlineFlowBox::adjustMaxAscentAndDescent(LayoutUnit& maxAscent, LayoutUnit& if (curr->renderer()->isOutOfFlowPositioned()) continue; // Positioned placeholders don't affect calculations. if (curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) { - LayoutUnit lineHeight = curr->lineHeight(); + int lineHeight = curr->lineHeight(); if (curr->verticalAlign() == TOP) { if (maxAscent + maxDescent < lineHeight) maxDescent = lineHeight - maxAscent; @@ -503,7 +503,7 @@ void InlineFlowBox::adjustMaxAscentAndDescent(LayoutUnit& maxAscent, LayoutUnit& } void InlineFlowBox::computeLogicalBoxHeights(RootInlineBox* rootBox, LayoutUnit& maxPositionTop, LayoutUnit& maxPositionBottom, - LayoutUnit& maxAscent, LayoutUnit& maxDescent, bool& setMaxAscent, bool& setMaxDescent, + int& maxAscent, int& maxDescent, bool& setMaxAscent, bool& setMaxDescent, bool strictMode, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, FontBaseline baselineType, VerticalPositionCache& verticalPositionCache) { @@ -599,7 +599,7 @@ void InlineFlowBox::computeLogicalBoxHeights(RootInlineBox* rootBox, LayoutUnit& } } -void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHeight, LayoutUnit maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom, bool& setLineTop, +void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHeight, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom, bool& setLineTop, LayoutUnit& lineTopIncludingMargins, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotationsAfter, FontBaseline baselineType) { bool isRootBox = isRootInlineBox(); diff --git a/Source/WebCore/rendering/InlineFlowBox.h b/Source/WebCore/rendering/InlineFlowBox.h index 5a34f6c65..48b720c75 100644 --- a/Source/WebCore/rendering/InlineFlowBox.h +++ b/Source/WebCore/rendering/InlineFlowBox.h @@ -175,11 +175,11 @@ public: LayoutUnit getFlowSpacingLogicalWidth(); float placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap&); void computeLogicalBoxHeights(RootInlineBox*, LayoutUnit& maxPositionTop, LayoutUnit& maxPositionBottom, - LayoutUnit& maxAscent, LayoutUnit& maxDescent, bool& setMaxAscent, bool& setMaxDescent, + int& maxAscent, int& maxDescent, bool& setMaxAscent, bool& setMaxDescent, bool strictMode, GlyphOverflowAndFallbackFontsMap&, FontBaseline, VerticalPositionCache&); - void adjustMaxAscentAndDescent(LayoutUnit& maxAscent, LayoutUnit& maxDescent, - LayoutUnit maxPositionTop, LayoutUnit maxPositionBottom); - void placeBoxesInBlockDirection(LayoutUnit logicalTop, LayoutUnit maxHeight, LayoutUnit maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom, bool& setLineTop, + void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, + int maxPositionTop, int maxPositionBottom); + void placeBoxesInBlockDirection(LayoutUnit logicalTop, LayoutUnit maxHeight, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom, bool& setLineTop, LayoutUnit& lineTopIncludingMargins, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotationsAfter, FontBaseline); void flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lineBottom); bool requiresIdeographicBaseline(const GlyphOverflowAndFallbackFontsMap&) const; diff --git a/Source/WebCore/rendering/InlineTextBox.cpp b/Source/WebCore/rendering/InlineTextBox.cpp index ae316d498..ca1fef31b 100644 --- a/Source/WebCore/rendering/InlineTextBox.cpp +++ b/Source/WebCore/rendering/InlineTextBox.cpp @@ -88,7 +88,7 @@ void InlineTextBox::setLogicalOverflowRect(const LayoutRect& rect) gTextBoxesWithOverflow->add(this, rect); } -LayoutUnit InlineTextBox::baselinePosition(FontBaseline baselineType) const +int InlineTextBox::baselinePosition(FontBaseline baselineType) const { if (!isText() || !parent()) return 0; @@ -766,10 +766,10 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, } // Paint decorations - int textDecorations = styleToUse->textDecorationsInEffect(); + ETextDecoration textDecorations = styleToUse->textDecorationsInEffect(); if (textDecorations != TDNONE && paintInfo.phase != PaintPhaseSelection) { updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace()); - paintDecoration(context, boxOrigin, textDecorations, textShadow); + paintDecoration(context, boxOrigin, textDecorations, styleToUse->textDecorationStyle(), textShadow); } if (paintInfo.phase == PaintPhaseForeground) { @@ -925,8 +925,38 @@ void InlineTextBox::paintCustomHighlight(const LayoutPoint& paintOffset, const A #endif -void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& boxOrigin, int deco, const ShadowData* shadow) +static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle) { + StrokeStyle strokeStyle = SolidStroke; + switch (decorationStyle) { + case TextDecorationStyleSolid: + strokeStyle = SolidStroke; + break; +#if ENABLE(CSS3_TEXT) + case TextDecorationStyleDouble: + strokeStyle = DoubleStroke; + break; + case TextDecorationStyleDotted: + strokeStyle = DottedStroke; + break; + case TextDecorationStyleDashed: + strokeStyle = DashedStroke; + break; + case TextDecorationStyleWavy: + // FIXME: https://bugs.webkit.org/show_bug.cgi?id=92868 - Needs platform support. + strokeStyle = WavyStroke; + break; +#endif // CSS3_TEXT + } + + return strokeStyle; +} + +void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& boxOrigin, ETextDecoration deco, TextDecorationStyle decorationStyle, const ShadowData* shadow) +{ + // FIXME: We should improve this rule and not always just assume 1. + const float textDecorationThickness = 1.f; + if (m_truncation == cFullTruncation) return; @@ -947,7 +977,7 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& // Use a special function for underlines to get the positioning exactly right. bool isPrinting = textRenderer()->document()->printing(); - context->setStrokeThickness(1.0f); // FIXME: We should improve this rule and not always just assume 1. + context->setStrokeThickness(textDecorationThickness); bool linesAreOpaque = !isPrinting && (!(deco & UNDERLINE) || underline.alpha() == 255) && (!(deco & OVERLINE) || overline.alpha() == 255) && (!(deco & LINE_THROUGH) || linethrough.alpha() == 255); @@ -976,7 +1006,7 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& ColorSpace colorSpace = renderer()->style()->colorSpace(); bool setShadow = false; - + do { if (shadow) { if (!shadow->next()) { @@ -991,21 +1021,35 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& shadow = shadow->next(); } +#if ENABLE(CSS3_TEXT) + // Offset between lines - always non-zero, so lines never cross each other. + float doubleOffset = textDecorationThickness + 1.f; +#endif // CSS3_TEXT + context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle)); if (deco & UNDERLINE) { context->setStrokeColor(underline, colorSpace); - context->setStrokeStyle(SolidStroke); // Leave one pixel of white between the baseline and the underline. context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + baseline + 1), width, isPrinting); +#if ENABLE(CSS3_TEXT) + if (decorationStyle == TextDecorationStyleDouble) + context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + baseline + 1 + doubleOffset), width, isPrinting); +#endif // CSS3_TEXT } if (deco & OVERLINE) { context->setStrokeColor(overline, colorSpace); - context->setStrokeStyle(SolidStroke); context->drawLineForText(localOrigin, width, isPrinting); +#if ENABLE(CSS3_TEXT) + if (decorationStyle == TextDecorationStyleDouble) + context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() - doubleOffset), width, isPrinting); +#endif // CSS3_TEXT } if (deco & LINE_THROUGH) { context->setStrokeColor(linethrough, colorSpace); - context->setStrokeStyle(SolidStroke); context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + 2 * baseline / 3), width, isPrinting); +#if ENABLE(CSS3_TEXT) + if (decorationStyle == TextDecorationStyleDouble) + context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + doubleOffset + 2 * baseline / 3), width, isPrinting); +#endif // CSS3_TEXT } } while (shadow); diff --git a/Source/WebCore/rendering/InlineTextBox.h b/Source/WebCore/rendering/InlineTextBox.h index f0b081d73..1f2a63acf 100644 --- a/Source/WebCore/rendering/InlineTextBox.h +++ b/Source/WebCore/rendering/InlineTextBox.h @@ -85,7 +85,7 @@ public: static inline bool compareByStart(const InlineTextBox* first, const InlineTextBox* second) { return first->start() < second->start(); } - virtual LayoutUnit baselinePosition(FontBaseline) const; + virtual int baselinePosition(FontBaseline) const; virtual LayoutUnit lineHeight() const; bool getEmphasisMarkPosition(RenderStyle*, TextEmphasisPosition&) const; @@ -183,7 +183,7 @@ protected: #endif private: - void paintDecoration(GraphicsContext*, const FloatPoint& boxOrigin, int decoration, const ShadowData*); + void paintDecoration(GraphicsContext*, const FloatPoint& boxOrigin, ETextDecoration, TextDecorationStyle, const ShadowData*); void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, RenderStyle*, const Font&, Color textColor); void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&, bool grammar); void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&); diff --git a/Source/WebCore/rendering/LayoutState.cpp b/Source/WebCore/rendering/LayoutState.cpp index fac96e648..d389b93b3 100644 --- a/Source/WebCore/rendering/LayoutState.cpp +++ b/Source/WebCore/rendering/LayoutState.cpp @@ -36,7 +36,12 @@ namespace WebCore { LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo) - : m_columnInfo(columnInfo) + : m_clipped(false) +#if !ASSERT_DISABLED && ENABLE(SATURATED_LAYOUT_ARITHMETIC) + , m_layoutDeltaXSaturated(false) + , m_layoutDeltaYSaturated(false) +#endif + , m_columnInfo(columnInfo) , m_lineGrid(0) , m_next(prev) #ifndef NDEBUG @@ -119,6 +124,10 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSiz #endif m_layoutDelta = m_next->m_layoutDelta; +#if !ASSERT_DISABLED && ENABLE(SATURATED_LAYOUT_ARITHMETIC) + m_layoutDeltaXSaturated = m_next->m_layoutDeltaXSaturated; + m_layoutDeltaYSaturated = m_next->m_layoutDeltaYSaturated; +#endif m_isPaginated = m_pageLogicalHeight || m_columnInfo || renderer->isRenderFlowThread(); @@ -135,6 +144,10 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSiz LayoutState::LayoutState(RenderObject* root) : m_clipped(false) , m_isPaginated(false) +#if !ASSERT_DISABLED && ENABLE(SATURATED_LAYOUT_ARITHMETIC) + , m_layoutDeltaXSaturated(false) + , m_layoutDeltaYSaturated(false) +#endif , m_pageLogicalHeight(0) , m_pageLogicalHeightChanged(false) , m_columnInfo(0) diff --git a/Source/WebCore/rendering/LayoutState.h b/Source/WebCore/rendering/LayoutState.h index 5450df9cb..b0ac4943e 100644 --- a/Source/WebCore/rendering/LayoutState.h +++ b/Source/WebCore/rendering/LayoutState.h @@ -48,6 +48,10 @@ public: LayoutState() : m_clipped(false) , m_isPaginated(false) +#if !ASSERT_DISABLED && ENABLE(SATURATED_LAYOUT_ARITHMETIC) + , m_layoutDeltaXSaturated(false) + , m_layoutDeltaYSaturated(false) +#endif , m_pageLogicalHeight(0) , m_pageLogicalHeightChanged(false) , m_columnInfo(0) @@ -109,6 +113,10 @@ private: public: bool m_clipped; bool m_isPaginated; +#if !ASSERT_DISABLED && ENABLE(SATURATED_LAYOUT_ARITHMETIC) + bool m_layoutDeltaXSaturated; + bool m_layoutDeltaYSaturated; +#endif LayoutRect m_clipRect; // x/y offset from container. Includes relative positioning and scroll offsets. diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp index 6e1087d35..f20b0b22f 100644 --- a/Source/WebCore/rendering/RenderBlock.cpp +++ b/Source/WebCore/rendering/RenderBlock.cpp @@ -161,13 +161,11 @@ RenderBlock::MarginInfo::MarginInfo(RenderBlock* block, LayoutUnit beforeBorderP , m_marginAfterQuirk(false) , m_determinedMarginBeforeQuirk(false) { - // Whether or not we can collapse our own margins with our children. We don't do this - // if we had any border/padding (obviously), if we're the root or HTML elements, or if - // we're positioned, floating, a table cell. RenderStyle* blockStyle = block->style(); + ASSERT(block->isRenderView() || block->parent()); m_canCollapseWithChildren = !block->isRenderView() && !block->isRoot() && !block->isOutOfFlowPositioned() && !block->isFloating() && !block->isTableCell() && !block->hasOverflowClip() && !block->isInlineBlockOrInlineTable() - && !block->isWritingModeRoot() && blockStyle->hasAutoColumnCount() && blockStyle->hasAutoColumnWidth() + && !block->isWritingModeRoot() && !block->parent()->isFlexibleBox() && blockStyle->hasAutoColumnCount() && blockStyle->hasAutoColumnWidth() && !blockStyle->columnSpan(); m_canCollapseMarginBeforeWithChildren = m_canCollapseWithChildren && !beforeBorderPadding && blockStyle->marginBeforeCollapse() != MSEPARATE; @@ -2567,7 +2565,7 @@ void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, Lay setLogicalHeight(newHeight); } - ASSERT(oldLayoutDelta == view()->layoutDelta()); + ASSERT(view()->layoutDeltaMatches(oldLayoutDelta)); } void RenderBlock::simplifiedNormalFlowLayout() @@ -6182,7 +6180,7 @@ LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction, return m_lineHeight; } -LayoutUnit RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { // Inline blocks are replaced elements. Otherwise, just pass off to // the base class. If we're being queried as though we're the root line @@ -6205,7 +6203,7 @@ LayoutUnit RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLi bool ignoreBaseline = (layer() && (layer()->marquee() || (direction == HorizontalLine ? (layer()->verticalScrollbar() || layer()->scrollYOffset() != 0) : (layer()->horizontalScrollbar() || layer()->scrollXOffset() != 0)))) || (isWritingModeRoot() && !isRubyRun()); - LayoutUnit baselinePos = ignoreBaseline ? static_cast<LayoutUnit>(-1) : lastLineBoxBaseline(); + int baselinePos = ignoreBaseline ? -1 : inlineBlockBaseline(direction); LayoutUnit bottomOfContent = direction == HorizontalLine ? borderTop() + paddingTop() + contentHeight() : borderRight() + paddingRight() + contentWidth(); if (baselinePos != -1 && baselinePos <= bottomOfContent) @@ -6218,7 +6216,7 @@ LayoutUnit RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLi return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2; } -LayoutUnit RenderBlock::firstLineBoxBaseline() const +int RenderBlock::firstLineBoxBaseline() const { if (!isBlockFlow() || (isWritingModeRoot() && !isRubyRun())) return -1; @@ -6232,7 +6230,7 @@ LayoutUnit RenderBlock::firstLineBoxBaseline() const else { for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox()) { if (!curr->isFloatingOrOutOfFlowPositioned()) { - LayoutUnit result = curr->firstLineBoxBaseline(); + int result = curr->firstLineBoxBaseline(); if (result != -1) return curr->logicalTop() + result; // Translate to our coordinate space. } @@ -6242,13 +6240,16 @@ LayoutUnit RenderBlock::firstLineBoxBaseline() const return -1; } -LayoutUnit RenderBlock::lastLineBoxBaseline() const +int RenderBlock::inlineBlockBaseline(LineDirectionMode direction) const +{ + return lastLineBoxBaseline(direction); +} + +int RenderBlock::lastLineBoxBaseline(LineDirectionMode lineDirection) const { if (!isBlockFlow() || (isWritingModeRoot() && !isRubyRun())) return -1; - LineDirectionMode lineDirection = isHorizontalWritingMode() ? HorizontalLine : VerticalLine; - if (childrenInline()) { if (!firstLineBox() && hasLineIfEmpty()) { const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); @@ -6264,7 +6265,7 @@ LayoutUnit RenderBlock::lastLineBoxBaseline() const for (RenderBox* curr = lastChildBox(); curr; curr = curr->previousSiblingBox()) { if (!curr->isFloatingOrOutOfFlowPositioned()) { haveNormalFlowChild = true; - LayoutUnit result = curr->lastLineBoxBaseline(); + int result = curr->inlineBlockBaseline(lineDirection); if (result != -1) return curr->logicalTop() + result; // Translate to our coordinate space. } diff --git a/Source/WebCore/rendering/RenderBlock.h b/Source/WebCore/rendering/RenderBlock.h index 24cce99b4..567d7dcb4 100644 --- a/Source/WebCore/rendering/RenderBlock.h +++ b/Source/WebCore/rendering/RenderBlock.h @@ -93,7 +93,7 @@ public: // These two functions are overridden for inline-block. virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; RenderLineBoxList* lineBoxes() { return &m_lineBoxes; } const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; } @@ -463,8 +463,9 @@ protected: virtual void computePreferredLogicalWidths(); - virtual LayoutUnit firstLineBoxBaseline() const; - virtual LayoutUnit lastLineBoxBaseline() const; + virtual int firstLineBoxBaseline() const; + virtual int inlineBlockBaseline(LineDirectionMode) const OVERRIDE; + int lastLineBoxBaseline(LineDirectionMode) const; virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&); diff --git a/Source/WebCore/rendering/RenderBlockLineLayout.cpp b/Source/WebCore/rendering/RenderBlockLineLayout.cpp index 1cfd1e098..756a3c31e 100644 --- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp +++ b/Source/WebCore/rendering/RenderBlockLineLayout.cpp @@ -1436,8 +1436,7 @@ void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, Inlin // case these segments may be incorrect. if (exclusionShapeInsideInfo) { LayoutUnit lineTop = logicalHeight() + absoluteLogicalTop; - LayoutUnit lineBottom = lineTop + lineHeight(layoutState.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); - exclusionShapeInsideInfo->computeSegmentsForLine(lineTop, lineBottom); + exclusionShapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight(layoutState.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)); } #endif WordMeasurements wordMeasurements; diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp index 779277d14..683c23839 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -1786,7 +1786,7 @@ static bool isStretchingColumnFlexItem(const RenderObject* flexitem) return true; // We don't stretch multiline flexboxes because they need to apply line spacing (align-content) first. - if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexWrapNone && parent->style()->isColumnFlexDirection() && flexItemHasStretchAlignment(flexitem)) + if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && flexItemHasStretchAlignment(flexitem)) return true; return false; } @@ -1820,7 +1820,7 @@ bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const // stretched size to avoid an extra layout when applying alignment. if (parent()->isFlexibleBox()) { // For multiline columns, we need to apply align-content first, so we can't stretch now. - if (!parent()->style()->isColumnFlexDirection() || parent()->style()->flexWrap() != FlexWrapNone) + if (!parent()->style()->isColumnFlexDirection() || parent()->style()->flexWrap() != FlexNoWrap) return true; if (!flexItemHasStretchAlignment(this)) return true; @@ -3831,10 +3831,10 @@ LayoutUnit RenderBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction return 0; } -LayoutUnit RenderBox::baselinePosition(FontBaseline baselineType, bool /*firstLine*/, LineDirectionMode direction, LinePositionMode /*linePositionMode*/) const +int RenderBox::baselinePosition(FontBaseline baselineType, bool /*firstLine*/, LineDirectionMode direction, LinePositionMode /*linePositionMode*/) const { if (isReplaced()) { - LayoutUnit result = direction == HorizontalLine ? m_marginBox.top() + height() + m_marginBox.bottom() : m_marginBox.right() + width() + m_marginBox.left(); + int result = direction == HorizontalLine ? m_marginBox.top() + height() + m_marginBox.bottom() : m_marginBox.right() + width() + m_marginBox.left(); if (baselineType == AlphabeticBaseline) return result; return result - result / 2; diff --git a/Source/WebCore/rendering/RenderBox.h b/Source/WebCore/rendering/RenderBox.h index 50150bd66..4d1328cfa 100644 --- a/Source/WebCore/rendering/RenderBox.h +++ b/Source/WebCore/rendering/RenderBox.h @@ -472,8 +472,8 @@ public: RenderLayer* enclosingFloatPaintingLayer() const; - virtual LayoutUnit firstLineBoxBaseline() const { return -1; } - virtual LayoutUnit lastLineBoxBaseline() const { return -1; } + virtual int firstLineBoxBaseline() const { return -1; } + virtual int inlineBlockBaseline(LineDirectionMode) const { return -1; } // Returns -1 if we should skip this box when computing the baseline of an inline-block. bool shrinkToAvoidFloats() const; virtual bool avoidsFloats() const; @@ -485,7 +485,7 @@ public: bool isDeprecatedFlexItem() const { return !isInline() && !isFloatingOrOutOfFlowPositioned() && parent() && parent()->isDeprecatedFlexibleBox(); } virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE; virtual LayoutUnit offsetLeft() const OVERRIDE; virtual LayoutUnit offsetTop() const OVERRIDE; diff --git a/Source/WebCore/rendering/RenderBoxModelObject.h b/Source/WebCore/rendering/RenderBoxModelObject.h index b2fa38583..4e08d9993 100644 --- a/Source/WebCore/rendering/RenderBoxModelObject.h +++ b/Source/WebCore/rendering/RenderBoxModelObject.h @@ -156,7 +156,7 @@ public: // Overridden by subclasses to determine line height and baseline position. virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0; virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const OVERRIDE; diff --git a/Source/WebCore/rendering/RenderFlexibleBox.cpp b/Source/WebCore/rendering/RenderFlexibleBox.cpp index 86e655e89..ee425b3f4 100644 --- a/Source/WebCore/rendering/RenderFlexibleBox.cpp +++ b/Source/WebCore/rendering/RenderFlexibleBox.cpp @@ -235,18 +235,22 @@ void RenderFlexibleBox::computePreferredLogicalWidths() setPreferredLogicalWidthsDirty(false); } -LayoutUnit RenderFlexibleBox::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +static int synthesizedBaselineFromContentBox(const RenderBox* box, LineDirectionMode direction) { - LayoutUnit baseline = firstLineBoxBaseline(); - if (baseline != -1) { - LayoutUnit marginAscent = direction == HorizontalLine ? marginTop() : marginRight(); - return baseline + marginAscent; - } + return direction == HorizontalLine ? box->borderTop() + box->paddingTop() + box->contentHeight() : box->borderRight() + box->paddingRight() + box->contentWidth(); +} + +int RenderFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode direction, LinePositionMode) const +{ + int baseline = firstLineBoxBaseline(); + if (baseline == -1) + baseline = synthesizedBaselineFromContentBox(this, direction); - return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode); + int marginAscent = direction == HorizontalLine ? marginTop() : marginRight(); + return baseline + marginAscent; } -LayoutUnit RenderFlexibleBox::firstLineBoxBaseline() const +int RenderFlexibleBox::firstLineBoxBaseline() const { ASSERT(m_orderIterator); @@ -273,13 +277,27 @@ LayoutUnit RenderFlexibleBox::firstLineBoxBaseline() const if (isColumnFlow() && !hasOrthogonalFlow(baselineChild)) return mainAxisExtentForChild(baselineChild) + baselineChild->logicalTop(); - LayoutUnit baseline = baselineChild->firstLineBoxBaseline(); - if (baseline == -1) - return -1; + int baseline = baselineChild->firstLineBoxBaseline(); + if (baseline == -1) { + // FIXME: We should pass |direction| into firstLineBoxBaseline and stop bailing out if we're a writing mode root. + // This would also fix some cases where the flexbox is orthogonal to its container. + LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine : VerticalLine; + return synthesizedBaselineFromContentBox(baselineChild, direction) + baselineChild->logicalTop(); + } return baseline + baselineChild->logicalTop(); } +int RenderFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const +{ + int baseline = firstLineBoxBaseline(); + if (baseline != -1) + return baseline; + + int marginAscent = direction == HorizontalLine ? marginTop() : marginRight(); + return synthesizedBaselineFromContentBox(this, direction) + marginAscent; +} + void RenderFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit) { ASSERT(needsLayout()); @@ -407,7 +425,7 @@ bool RenderFlexibleBox::isLeftToRightFlow() const bool RenderFlexibleBox::isMultiline() const { - return style()->flexWrap() != FlexWrapNone; + return style()->flexWrap() != FlexNoWrap; } Length RenderFlexibleBox::flexBasisForChild(RenderBox* child) const diff --git a/Source/WebCore/rendering/RenderFlexibleBox.h b/Source/WebCore/rendering/RenderFlexibleBox.h index 495179659..acbdba928 100644 --- a/Source/WebCore/rendering/RenderFlexibleBox.h +++ b/Source/WebCore/rendering/RenderFlexibleBox.h @@ -49,8 +49,9 @@ public: virtual void computePreferredLogicalWidths() OVERRIDE; virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE; - virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE; + virtual int firstLineBoxBaseline() const OVERRIDE; + virtual int inlineBlockBaseline(LineDirectionMode) const OVERRIDE; virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect) OVERRIDE; diff --git a/Source/WebCore/rendering/RenderInline.cpp b/Source/WebCore/rendering/RenderInline.cpp index 9f71ff15f..51f54b452 100644 --- a/Source/WebCore/rendering/RenderInline.cpp +++ b/Source/WebCore/rendering/RenderInline.cpp @@ -1301,7 +1301,7 @@ LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*directio return style()->computedLineHeight(view()); } -LayoutUnit RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2; diff --git a/Source/WebCore/rendering/RenderInline.h b/Source/WebCore/rendering/RenderInline.h index 59b8fcb80..562ff47b9 100644 --- a/Source/WebCore/rendering/RenderInline.h +++ b/Source/WebCore/rendering/RenderInline.h @@ -153,7 +153,7 @@ private: virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); } virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void childBecameNonInline(RenderObject* child); diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index 32471d88b..69908af42 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -1719,6 +1719,9 @@ void RenderLayer::scrollTo(int x, int y) return; m_scrollOffset = newScrollOffset; + Frame* frame = renderer()->frame(); + InspectorInstrumentation::willScrollLayer(frame); + // Update the positions of our child layers (if needed as only fixed layers should be impacted by a scroll). // We don't update compositing layers, because we need to do a deep update from the compositing ancestor. updateLayerPositionsAfterScroll(); @@ -1745,7 +1748,6 @@ void RenderLayer::scrollTo(int x, int y) } RenderLayerModelObject* repaintContainer = renderer()->containerForRepaint(); - Frame* frame = renderer()->frame(); if (frame) { // The caret rect needs to be invalidated after scrolling frame->selection()->setCaretRectNeedsUpdate(); @@ -1763,6 +1765,8 @@ void RenderLayer::scrollTo(int x, int y) // Schedule the scroll DOM event. if (renderer()->node()) renderer()->node()->document()->eventQueue()->enqueueOrDispatchScrollEvent(renderer()->node(), DocumentEventQueue::ScrollEventElementTarget); + + InspectorInstrumentation::didScrollLayer(frame); } static inline bool frameElementAndViewPermitScroll(HTMLFrameElement* frameElement, FrameView* frameView) diff --git a/Source/WebCore/rendering/RenderListBox.cpp b/Source/WebCore/rendering/RenderListBox.cpp index 2af9635d4..b92d9f08d 100644 --- a/Source/WebCore/rendering/RenderListBox.cpp +++ b/Source/WebCore/rendering/RenderListBox.cpp @@ -269,7 +269,7 @@ void RenderListBox::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTop, Logi RenderBox::computeLogicalHeight(height, logicalTop, computedValues); } -LayoutUnit RenderListBox::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const +int RenderListBox::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const { return RenderBox::baselinePosition(baselineType, firstLine, lineDirection, linePositionMode) - baselineAdjustment; } diff --git a/Source/WebCore/rendering/RenderListBox.h b/Source/WebCore/rendering/RenderListBox.h index e936dc2ce..c662af27f 100644 --- a/Source/WebCore/rendering/RenderListBox.h +++ b/Source/WebCore/rendering/RenderListBox.h @@ -76,7 +76,7 @@ private: virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0); virtual void computePreferredLogicalWidths(); - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const OVERRIDE; virtual void layout(); diff --git a/Source/WebCore/rendering/RenderListMarker.cpp b/Source/WebCore/rendering/RenderListMarker.cpp index b7cbaa038..a7a3791fd 100644 --- a/Source/WebCore/rendering/RenderListMarker.cpp +++ b/Source/WebCore/rendering/RenderListMarker.cpp @@ -1542,7 +1542,7 @@ LayoutUnit RenderListMarker::lineHeight(bool firstLine, LineDirectionMode direct return RenderBox::lineHeight(firstLine, direction, linePositionMode); } -LayoutUnit RenderListMarker::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +int RenderListMarker::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { if (!isImage()) return m_listItem->baselinePosition(baselineType, firstLine, direction, PositionOfInteriorLineBoxes); diff --git a/Source/WebCore/rendering/RenderListMarker.h b/Source/WebCore/rendering/RenderListMarker.h index c1f1d676e..e220ce798 100644 --- a/Source/WebCore/rendering/RenderListMarker.h +++ b/Source/WebCore/rendering/RenderListMarker.h @@ -59,7 +59,7 @@ private: virtual InlineBox* createInlineBox(); virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; bool isImage() const; bool isText() const { return !isImage(); } diff --git a/Source/WebCore/rendering/RenderSlider.cpp b/Source/WebCore/rendering/RenderSlider.cpp index 87c4b744c..07b1d7d14 100644 --- a/Source/WebCore/rendering/RenderSlider.cpp +++ b/Source/WebCore/rendering/RenderSlider.cpp @@ -64,7 +64,7 @@ bool RenderSlider::canBeReplacedWithInlineRunIn() const return false; } -LayoutUnit RenderSlider::baselinePosition(FontBaseline, bool /*firstLine*/, LineDirectionMode, LinePositionMode) const +int RenderSlider::baselinePosition(FontBaseline, bool /*firstLine*/, LineDirectionMode, LinePositionMode) const { // FIXME: Patch this function for writing-mode. return height() + marginTop(); diff --git a/Source/WebCore/rendering/RenderSlider.h b/Source/WebCore/rendering/RenderSlider.h index 181ed915f..252cd080c 100644 --- a/Source/WebCore/rendering/RenderSlider.h +++ b/Source/WebCore/rendering/RenderSlider.h @@ -43,7 +43,7 @@ private: virtual bool isSlider() const { return true; } virtual bool canBeReplacedWithInlineRunIn() const OVERRIDE; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void computePreferredLogicalWidths(); virtual bool requiresForcedStyleRecalcPropagation() const { return true; } virtual void layout(); diff --git a/Source/WebCore/rendering/RenderTable.cpp b/Source/WebCore/rendering/RenderTable.cpp index f9bf44609..d5c58bc9c 100644 --- a/Source/WebCore/rendering/RenderTable.cpp +++ b/Source/WebCore/rendering/RenderTable.cpp @@ -378,20 +378,15 @@ void RenderTable::layout() bool collapsing = collapseBorders(); - for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { - if (child->isTableSection()) { - RenderTableSection* section = toRenderTableSection(child); - if (m_columnLogicalWidthChanged) - section->setChildNeedsLayout(true, MarkOnlyThis); - section->layoutIfNeeded(); - totalSectionLogicalHeight += section->calcRowLogicalHeight(); - if (collapsing) - section->recalcOuterBorder(); - ASSERT(!section->needsLayout()); - } else if (child->isRenderTableCol()) { - child->layoutIfNeeded(); - ASSERT(!child->needsLayout()); - } + // We ignore table col / colgroup in this iteration as they are only used to size the cell's widths during auto / fixed table layout. + for (RenderTableSection* section = topSection(); section; section = sectionBelow(section)) { + if (m_columnLogicalWidthChanged) + section->setChildNeedsLayout(true, MarkOnlyThis); + section->layoutIfNeeded(); + totalSectionLogicalHeight += section->calcRowLogicalHeight(); + if (collapsing) + section->recalcOuterBorder(); + ASSERT(!section->needsLayout()); } // If any table section moved vertically, we will just repaint everything from that @@ -1220,7 +1215,7 @@ void RenderTable::updateFirstLetter() { } -LayoutUnit RenderTable::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +int RenderTable::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { LayoutUnit baseline = firstLineBoxBaseline(); if (baseline != -1) @@ -1229,13 +1224,13 @@ LayoutUnit RenderTable::baselinePosition(FontBaseline baselineType, bool firstLi return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode); } -LayoutUnit RenderTable::lastLineBoxBaseline() const +int RenderTable::inlineBlockBaseline(LineDirectionMode) const { - // Tables don't contribute their baseline towards the computation of an inline-block's baseline. + // Tables are skipped when computing an inline-block's baseline. return -1; } -LayoutUnit RenderTable::firstLineBoxBaseline() const +int RenderTable::firstLineBoxBaseline() const { // The baseline of a 'table' is the same as the 'inline-table' baseline per CSS 3 Flexbox (CSS 2.1 // doesn't define the baseline of a 'table' only an 'inline-table'). @@ -1250,7 +1245,7 @@ LayoutUnit RenderTable::firstLineBoxBaseline() const if (!topNonEmptySection) return -1; - LayoutUnit baseline = topNonEmptySection->firstLineBoxBaseline(); + int baseline = topNonEmptySection->firstLineBoxBaseline(); if (baseline > 0) return topNonEmptySection->logicalTop() + baseline; diff --git a/Source/WebCore/rendering/RenderTable.h b/Source/WebCore/rendering/RenderTable.h index de4b5a6b0..390f2b367 100644 --- a/Source/WebCore/rendering/RenderTable.h +++ b/Source/WebCore/rendering/RenderTable.h @@ -277,9 +277,9 @@ private: virtual void computePreferredLogicalWidths(); virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE; - virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE; - virtual LayoutUnit lastLineBoxBaseline() const OVERRIDE; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE; + virtual int firstLineBoxBaseline() const OVERRIDE; + virtual int inlineBlockBaseline(LineDirectionMode) const OVERRIDE; RenderTableCol* slowColElement(unsigned col, bool* startEdge, bool* endEdge) const; diff --git a/Source/WebCore/rendering/RenderTableCol.cpp b/Source/WebCore/rendering/RenderTableCol.cpp index 7aa8341a7..6db54cca1 100644 --- a/Source/WebCore/rendering/RenderTableCol.cpp +++ b/Source/WebCore/rendering/RenderTableCol.cpp @@ -49,6 +49,9 @@ void RenderTableCol::styleDidChange(StyleDifference diff, const RenderStyle* old { RenderBox::styleDidChange(diff, oldStyle); + if (diff == StyleDifferenceLayout) + propagateLayoutCueToTable(); + // If border was changed, notify table. if (parent()) { RenderTable* table = this->table(); @@ -66,8 +69,9 @@ void RenderTableCol::updateFromElement() m_span = tc->span(); } else m_span = !(style() && style()->display() == TABLE_COLUMN_GROUP); - if (m_span != oldSpan && style() && parent()) - setNeedsLayoutAndPrefWidthsRecalc(); + + if (m_span != oldSpan && style()) + propagateLayoutCueToTable(); } void RenderTableCol::willBeRemovedFromTree() @@ -114,10 +118,25 @@ void RenderTableCol::imageChanged(WrappedImagePtr, const IntRect*) void RenderTableCol::computePreferredLogicalWidths() { - setPreferredLogicalWidthsDirty(false); + // <col> and <colgroup> don't have preferred logical widths as they have + // no content so computing our preferred logical widths is wasteful. + ASSERT_NOT_REACHED(); +} + +void RenderTableCol::layout() +{ + // There is no need to layout table <col> or <colgroup> as they have no content. + ASSERT_NOT_REACHED(); +} - for (RenderObject* child = firstChild(); child; child = child->nextSibling()) - child->setPreferredLogicalWidthsDirty(false); +void RenderTableCol::propagateLayoutCueToTable() const +{ + // Forward any layout hint to the table: this is required as the table is + // the one to layout / compute preferred logical widths on all the cells. + if (RenderTable* table = this->table()) { + table->setChildNeedsLayout(true); + table->setPreferredLogicalWidthsDirty(true); + } } RenderTable* RenderTableCol::table() const diff --git a/Source/WebCore/rendering/RenderTableCol.h b/Source/WebCore/rendering/RenderTableCol.h index 1a9fac6ec..1e8e80257 100644 --- a/Source/WebCore/rendering/RenderTableCol.h +++ b/Source/WebCore/rendering/RenderTableCol.h @@ -40,8 +40,6 @@ public: const RenderObjectChildList* children() const { return &m_children; } RenderObjectChildList* children() { return &m_children; } - virtual void computePreferredLogicalWidths(); - unsigned span() const { return m_span; } void setSpan(unsigned span) { m_span = span; } @@ -77,6 +75,9 @@ private: virtual RenderObjectChildList* virtualChildren() { return children(); } virtual const RenderObjectChildList* virtualChildren() const { return children(); } + virtual void computePreferredLogicalWidths() OVERRIDE; + virtual void layout() OVERRIDE; + virtual const char* renderName() const { return "RenderTableCol"; } virtual bool isRenderTableCol() const OVERRIDE { return true; } virtual void updateFromElement(); @@ -92,6 +93,8 @@ private: virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); + void propagateLayoutCueToTable() const; + RenderTable* table() const; RenderObjectChildList m_children; diff --git a/Source/WebCore/rendering/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp index 341c90512..1d628fe59 100644 --- a/Source/WebCore/rendering/RenderTableSection.cpp +++ b/Source/WebCore/rendering/RenderTableSection.cpp @@ -882,12 +882,12 @@ void RenderTableSection::recalcOuterBorder() m_outerBorderEnd = calcOuterBorderEnd(); } -LayoutUnit RenderTableSection::firstLineBoxBaseline() const +int RenderTableSection::firstLineBoxBaseline() const { if (!m_grid.size()) return -1; - LayoutUnit firstLineBaseline = m_grid[0].baseline; + int firstLineBaseline = m_grid[0].baseline; if (firstLineBaseline) return firstLineBaseline + m_rowPos[0]; @@ -898,7 +898,7 @@ LayoutUnit RenderTableSection::firstLineBoxBaseline() const const RenderTableCell* cell = cs.primaryCell(); // Only cells with content have a baseline if (cell && cell->contentLogicalHeight()) - firstLineBaseline = max(firstLineBaseline, cell->logicalTop() + cell->paddingBefore() + cell->borderBefore() + cell->contentLogicalHeight()); + firstLineBaseline = max<int>(firstLineBaseline, cell->logicalTop() + cell->paddingBefore() + cell->borderBefore() + cell->contentLogicalHeight()); } return firstLineBaseline; diff --git a/Source/WebCore/rendering/RenderTableSection.h b/Source/WebCore/rendering/RenderTableSection.h index 2bb9ce364..cd6eb9739 100644 --- a/Source/WebCore/rendering/RenderTableSection.h +++ b/Source/WebCore/rendering/RenderTableSection.h @@ -70,7 +70,7 @@ public: virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); - virtual LayoutUnit firstLineBoxBaseline() const; + virtual int firstLineBoxBaseline() const OVERRIDE; void addCell(RenderTableCell*, RenderTableRow* row); diff --git a/Source/WebCore/rendering/RenderTextControlMultiLine.cpp b/Source/WebCore/rendering/RenderTextControlMultiLine.cpp index be91de927..92d002829 100644 --- a/Source/WebCore/rendering/RenderTextControlMultiLine.cpp +++ b/Source/WebCore/rendering/RenderTextControlMultiLine.cpp @@ -76,7 +76,7 @@ LayoutUnit RenderTextControlMultiLine::computeControlHeight(LayoutUnit lineHeigh return lineHeight * static_cast<HTMLTextAreaElement*>(node())->rows() + nonContentHeight; } -LayoutUnit RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode); } diff --git a/Source/WebCore/rendering/RenderTextControlMultiLine.h b/Source/WebCore/rendering/RenderTextControlMultiLine.h index a4539959a..6dad346c5 100644 --- a/Source/WebCore/rendering/RenderTextControlMultiLine.h +++ b/Source/WebCore/rendering/RenderTextControlMultiLine.h @@ -39,7 +39,7 @@ private: virtual float getAvgCharWidth(AtomicString family); virtual LayoutUnit preferredContentWidth(float charWidth) const; virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual RenderStyle* textBaseStyle() const; virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const; diff --git a/Source/WebCore/rendering/RenderTheme.cpp b/Source/WebCore/rendering/RenderTheme.cpp index ed425758d..47acfc8ec 100644 --- a/Source/WebCore/rendering/RenderTheme.cpp +++ b/Source/WebCore/rendering/RenderTheme.cpp @@ -639,7 +639,7 @@ CString RenderTheme::extraCalendarPickerStyleSheet() } #endif -LayoutUnit RenderTheme::baselinePosition(const RenderObject* o) const +int RenderTheme::baselinePosition(const RenderObject* o) const { if (!o->isBox()) return 0; diff --git a/Source/WebCore/rendering/RenderTheme.h b/Source/WebCore/rendering/RenderTheme.h index 5db283605..b568953cb 100644 --- a/Source/WebCore/rendering/RenderTheme.h +++ b/Source/WebCore/rendering/RenderTheme.h @@ -102,7 +102,7 @@ public: // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of // controls that need to do this. - virtual LayoutUnit baselinePosition(const RenderObject*) const; + virtual int baselinePosition(const RenderObject*) const; // A method for asking if a control is a container or not. Leaf controls have to have some special behavior (like // the baseline position API above). diff --git a/Source/WebCore/rendering/RenderThemeSafari.cpp b/Source/WebCore/rendering/RenderThemeSafari.cpp index 4ff0fd07c..21d978c8b 100644 --- a/Source/WebCore/rendering/RenderThemeSafari.cpp +++ b/Source/WebCore/rendering/RenderThemeSafari.cpp @@ -312,7 +312,7 @@ IntRect RenderThemeSafari::inflateRect(const IntRect& r, const IntSize& size, co return result; } -LayoutUnit RenderThemeSafari::baselinePosition(const RenderObject* o) const +int RenderThemeSafari::baselinePosition(const RenderObject* o) const { if (!o->isBox()) return 0; diff --git a/Source/WebCore/rendering/RenderThemeSafari.h b/Source/WebCore/rendering/RenderThemeSafari.h index cb861e668..fe26f326b 100644 --- a/Source/WebCore/rendering/RenderThemeSafari.h +++ b/Source/WebCore/rendering/RenderThemeSafari.h @@ -52,7 +52,7 @@ public: // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of // controls that need to do this. - virtual LayoutUnit baselinePosition(const RenderObject*) const; + virtual int baselinePosition(const RenderObject*) const; // A method asking if the control changes its tint when the window has focus or not. virtual bool controlSupportsTints(const RenderObject*) const; diff --git a/Source/WebCore/rendering/RenderView.cpp b/Source/WebCore/rendering/RenderView.cpp index d40e53dcf..7e118c7d0 100644 --- a/Source/WebCore/rendering/RenderView.cpp +++ b/Source/WebCore/rendering/RenderView.cpp @@ -148,7 +148,7 @@ void RenderView::layoutContent(const LayoutState& state) #ifndef NDEBUG void RenderView::checkLayoutState(const LayoutState& state) { - ASSERT(layoutDelta() == LayoutSize()); + ASSERT(layoutDeltaMatches(LayoutSize())); ASSERT(!m_layoutStateDisableCount); ASSERT(m_layoutState == &state); } diff --git a/Source/WebCore/rendering/RenderView.h b/Source/WebCore/rendering/RenderView.h index 0f5c6e881..084d7d5a7 100644 --- a/Source/WebCore/rendering/RenderView.h +++ b/Source/WebCore/rendering/RenderView.h @@ -124,9 +124,27 @@ public: } void addLayoutDelta(const LayoutSize& delta) { - if (m_layoutState) + if (m_layoutState) { m_layoutState->m_layoutDelta += delta; +#if !ASSERT_DISABLED && ENABLE(SATURATED_LAYOUT_ARITHMETIC) + m_layoutState->m_layoutDeltaXSaturated |= m_layoutState->m_layoutDelta.width() == FractionalLayoutUnit::max() || m_layoutState->m_layoutDelta.width() == FractionalLayoutUnit::min(); + m_layoutState->m_layoutDeltaYSaturated |= m_layoutState->m_layoutDelta.height() == FractionalLayoutUnit::max() || m_layoutState->m_layoutDelta.height() == FractionalLayoutUnit::min(); +#endif + } + } + +#if !ASSERT_DISABLED + bool layoutDeltaMatches(const LayoutSize& delta) + { + if (!m_layoutState) + return false; +#if ENABLE(SATURATED_LAYOUT_ARITHMETIC) + return (delta.width() == m_layoutState->m_layoutDelta.width() || m_layoutState->m_layoutDeltaXSaturated) && (delta.height() == m_layoutState->m_layoutDelta.height() || m_layoutState->m_layoutDeltaYSaturated); +#else + return delta == m_layoutState->m_layoutDelta; +#endif } +#endif bool doingFullRepaint() const { return m_frameView->needsFullRepaint(); } diff --git a/Source/WebCore/rendering/RootInlineBox.cpp b/Source/WebCore/rendering/RootInlineBox.cpp index f932e6f21..a26025981 100644 --- a/Source/WebCore/rendering/RootInlineBox.cpp +++ b/Source/WebCore/rendering/RootInlineBox.cpp @@ -100,7 +100,7 @@ bool RootInlineBox::isHyphenated() const return false; } -LayoutUnit RootInlineBox::baselinePosition(FontBaseline baselineType) const +int RootInlineBox::baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); } @@ -261,8 +261,8 @@ LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, G LayoutUnit maxPositionTop = 0; LayoutUnit maxPositionBottom = 0; - LayoutUnit maxAscent = 0; - LayoutUnit maxDescent = 0; + int maxAscent = 0; + int maxDescent = 0; bool setMaxAscent = false; bool setMaxDescent = false; diff --git a/Source/WebCore/rendering/RootInlineBox.h b/Source/WebCore/rendering/RootInlineBox.h index 525b29503..120afaa31 100644 --- a/Source/WebCore/rendering/RootInlineBox.h +++ b/Source/WebCore/rendering/RootInlineBox.h @@ -109,7 +109,7 @@ public: bool isHyphenated() const; - virtual LayoutUnit baselinePosition(FontBaseline baselineType) const; + virtual int baselinePosition(FontBaseline baselineType) const; virtual LayoutUnit lineHeight() const; #if PLATFORM(MAC) diff --git a/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp b/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp index 0bfc1678e..5eed89fd5 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp @@ -198,7 +198,7 @@ LayoutUnit RenderMathMLBlock::preferredLogicalHeightAfterSizing(RenderObject* ch return child->style()->fontSize(); } -LayoutUnit RenderMathMLBlock::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +int RenderMathMLBlock::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { // mathml.css sets math { -webkit-line-box-contain: glyphs replaced; line-height: 0; }, so when linePositionMode == PositionOfInteriorLineBoxes we want to // return 0 here to match our line-height. This matters when RootInlineBox::ascentAndDescentForBox is called on a RootInlineBox for an inline-block. @@ -259,7 +259,7 @@ void RenderMathMLBlock::paint(PaintInfo& info, const LayoutPoint& paintOffset) } #endif // ENABLE(DEBUG_MATH_LAYOUT) -LayoutUnit RenderMathMLTable::firstLineBoxBaseline() const +int RenderMathMLTable::firstLineBoxBaseline() const { // In legal MathML, we'll have a MathML parent. That RenderFlexibleBox parent will use our firstLineBoxBaseline() for baseline alignment, per // http://dev.w3.org/csswg/css3-flexbox/#flex-baselines. We want to vertically center an <mtable>, such as a matrix. Essentially the whole <mtable> element fits on a diff --git a/Source/WebCore/rendering/mathml/RenderMathMLBlock.h b/Source/WebCore/rendering/mathml/RenderMathMLBlock.h index 5d9f4de4f..36e62ad67 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLBlock.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLBlock.h @@ -78,7 +78,7 @@ public: // computePreferredLogicalWidths() in derived classes must ensure m_preferredLogicalHeight is set to < 0 or its correct value. virtual void computePreferredLogicalWidths() OVERRIDE; - virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE; + virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE; #if ENABLE(DEBUG_MATH_LAYOUT) virtual void paint(PaintInfo&, const LayoutPoint&); @@ -124,7 +124,7 @@ class RenderMathMLTable : public RenderTable { public: explicit RenderMathMLTable(Node* node) : RenderTable(node) { } - virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE; + virtual int firstLineBoxBaseline() const OVERRIDE; private: virtual const char* renderName() const OVERRIDE { return "RenderMathMLTable"; } diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp b/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp index a08680bfd..540846493 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp @@ -149,7 +149,7 @@ void RenderMathMLFraction::paint(PaintInfo& info, const LayoutPoint& paintOffset info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + denominatorWrapper->pixelSnappedOffsetWidth(), adjustedPaintOffset.y())); } -LayoutUnit RenderMathMLFraction::firstLineBoxBaseline() const +int RenderMathMLFraction::firstLineBoxBaseline() const { if (RenderBox* denominatorWrapper = lastChildBox()) return denominatorWrapper->logicalTop() + static_cast<int>(lroundf((m_lineThickness + style()->fontMetrics().xHeight()) / 2)); diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFraction.h b/Source/WebCore/rendering/mathml/RenderMathMLFraction.h index 5b068dd31..4c10e361a 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLFraction.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLFraction.h @@ -41,7 +41,7 @@ public: virtual RenderMathMLOperator* unembellishedOperator(); - virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE; + virtual int firstLineBoxBaseline() const OVERRIDE; virtual void paint(PaintInfo&, const LayoutPoint&); protected: virtual void layout(); diff --git a/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp b/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp index ae7badac4..66a1621c2 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp @@ -381,7 +381,7 @@ RenderBlock* RenderMathMLOperator::createGlyph(UChar glyph, int lineHeight, int return container; } -LayoutUnit RenderMathMLOperator::firstLineBoxBaseline() const +int RenderMathMLOperator::firstLineBoxBaseline() const { if (m_isStacked) return m_stretchHeight * 2 / 3 - (m_stretchHeight - static_cast<int>(m_stretchHeight / gOperatorExpansion)) / 2; diff --git a/Source/WebCore/rendering/mathml/RenderMathMLOperator.h b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h index 85c2c3a8e..e2cdd0572 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLOperator.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h @@ -45,7 +45,7 @@ public: virtual RenderMathMLOperator* unembellishedOperator() OVERRIDE { return this; } void stretchToHeight(int pixelHeight); - virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE; + virtual int firstLineBoxBaseline() const OVERRIDE; protected: virtual void computePreferredLogicalWidths() OVERRIDE; diff --git a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp index 93c59a894..c65805183 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp @@ -57,7 +57,7 @@ RenderMathMLOperator* RenderMathMLUnderOver::unembellishedOperator() return toRenderMathMLBlock(base)->unembellishedOperator(); } -LayoutUnit RenderMathMLUnderOver::firstLineBoxBaseline() const +int RenderMathMLUnderOver::firstLineBoxBaseline() const { RenderBox* base = firstChildBox(); if (!base) diff --git a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h index c7593349a..caf4fc499 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h @@ -38,7 +38,7 @@ public: virtual RenderMathMLOperator* unembellishedOperator(); - virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE; + virtual int firstLineBoxBaseline() const OVERRIDE; private: virtual const char* renderName() const { return "RenderMathMLUnderOver"; } diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index 6a589714e..d1fd13e5e 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -619,6 +619,8 @@ public: ETextDecoration textDecoration() const { return static_cast<ETextDecoration>(visual->textDecoration); } #if ENABLE(CSS3_TEXT) TextDecorationStyle textDecorationStyle() const { return static_cast<TextDecorationStyle>(rareNonInheritedData->m_textDecorationStyle); } +#else + TextDecorationStyle textDecorationStyle() const { return TextDecorationStyleSolid; } #endif // CSS3_TEXT int wordSpacing() const; int letterSpacing() const; @@ -1632,7 +1634,7 @@ public: static EAlignItems initialAlignItems() { return AlignStretch; } static EAlignItems initialAlignSelf() { return AlignAuto; } static EFlexDirection initialFlexDirection() { return FlowRow; } - static EFlexWrap initialFlexWrap() { return FlexWrapNone; } + static EFlexWrap initialFlexWrap() { return FlexNoWrap; } static EJustifyContent initialJustifyContent() { return JustifyFlexStart; } static int initialMarqueeLoopCount() { return -1; } static int initialMarqueeSpeed() { return 85; } diff --git a/Source/WebCore/rendering/style/RenderStyleConstants.h b/Source/WebCore/rendering/style/RenderStyleConstants.h index c2701f9e7..d3d34e5b4 100644 --- a/Source/WebCore/rendering/style/RenderStyleConstants.h +++ b/Source/WebCore/rendering/style/RenderStyleConstants.h @@ -171,7 +171,7 @@ enum EBoxDirection { BNORMAL, BREVERSE }; enum EAlignContent { AlignContentFlexStart, AlignContentFlexEnd, AlignContentCenter, AlignContentSpaceBetween, AlignContentSpaceAround, AlignContentStretch }; enum EAlignItems { AlignAuto, AlignFlexStart, AlignFlexEnd, AlignCenter, AlignStretch, AlignBaseline }; enum EFlexDirection { FlowRow, FlowRowReverse, FlowColumn, FlowColumnReverse }; -enum EFlexWrap { FlexWrapNone, FlexWrap, FlexWrapReverse }; +enum EFlexWrap { FlexNoWrap, FlexWrap, FlexWrapReverse }; enum EJustifyContent { JustifyFlexStart, JustifyFlexEnd, JustifyCenter, JustifySpaceBetween, JustifySpaceAround }; enum ETextSecurity { @@ -336,15 +336,15 @@ enum ETextDecoration { inline ETextDecoration operator|(ETextDecoration a, ETextDecoration b) { return ETextDecoration(int(a) | int(b)); } inline ETextDecoration& operator|=(ETextDecoration& a, ETextDecoration b) { return a = a | b; } -#if ENABLE(CSS3_TEXT) enum TextDecorationStyle { TextDecorationStyleSolid, +#if ENABLE(CSS3_TEXT) TextDecorationStyleDouble, TextDecorationStyleDotted, TextDecorationStyleDashed, TextDecorationStyleWavy -}; #endif // CSS3_TEXT +}; enum EPageBreak { PBAUTO, PBALWAYS, PBAVOID diff --git a/Source/WebCore/rendering/svg/RenderSVGImage.cpp b/Source/WebCore/rendering/svg/RenderSVGImage.cpp index 5487b5e16..47947e12c 100644 --- a/Source/WebCore/rendering/svg/RenderSVGImage.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGImage.cpp @@ -179,6 +179,11 @@ void RenderSVGImage::imageChanged(WrappedImagePtr, const IntRect*) // Eventually notify parent resources, that we've changed. RenderSVGResource::markForLayoutAndParentResourceInvalidation(this, false); + // Update the SVGImageCache sizeAndScales entry in case image loading finished after layout. + // (https://bugs.webkit.org/show_bug.cgi?id=99489) + m_objectBoundingBox = FloatRect(); + updateImageViewport(); + repaint(); } |
