diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-09 14:16:12 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-09 14:16:12 +0100 |
commit | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (patch) | |
tree | 52599cd0ab782b1768e23ad176f7618f98333cb6 /Source/WebCore/rendering | |
parent | cd44dc59cdfc39534aef4d417e9f3c412e3be139 (diff) | |
download | qtwebkit-03e12282df9aa1e1fb05a8b90f1cfc2e08764cec.tar.gz |
Imported WebKit commit e09a82039aa4273ab318b71122e92d8e5f233525 (http://svn.webkit.org/repository/webkit/trunk@107223)
Diffstat (limited to 'Source/WebCore/rendering')
80 files changed, 701 insertions, 472 deletions
diff --git a/Source/WebCore/rendering/ColumnInfo.h b/Source/WebCore/rendering/ColumnInfo.h index 94b130d3f..c8191cf1d 100644 --- a/Source/WebCore/rendering/ColumnInfo.h +++ b/Source/WebCore/rendering/ColumnInfo.h @@ -75,8 +75,8 @@ public: LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } int forcedBreaks() const { return m_forcedBreaks; } - int forcedBreakOffset() const { return m_forcedBreakOffset; } - int maximumDistanceBetweenForcedBreaks() const { return m_maximumDistanceBetweenForcedBreaks; } + LayoutUnit forcedBreakOffset() const { return m_forcedBreakOffset; } + LayoutUnit maximumDistanceBetweenForcedBreaks() const { return m_maximumDistanceBetweenForcedBreaks; } void clearForcedBreaks() { m_forcedBreaks = 0; @@ -107,8 +107,8 @@ private: LayoutUnit m_columnHeight; LayoutUnit m_minimumColumnHeight; int m_forcedBreaks; // FIXME: We will ultimately need to cache more information to balance around forced breaks properly. - int m_maximumDistanceBetweenForcedBreaks; - int m_forcedBreakOffset; + LayoutUnit m_maximumDistanceBetweenForcedBreaks; + LayoutUnit m_forcedBreakOffset; PaginationUnit m_paginationUnit; }; diff --git a/Source/WebCore/rendering/HitTestResult.cpp b/Source/WebCore/rendering/HitTestResult.cpp index 2292a8844..dc987c802 100644 --- a/Source/WebCore/rendering/HitTestResult.cpp +++ b/Source/WebCore/rendering/HitTestResult.cpp @@ -552,7 +552,7 @@ bool HitTestResult::isContentEditable() const if (!m_innerNonSharedNode) return false; - if (m_innerNonSharedNode->hasTagName(textareaTag) || m_innerNonSharedNode->hasTagName(isindexTag)) + if (m_innerNonSharedNode->hasTagName(textareaTag)) return true; if (m_innerNonSharedNode->hasTagName(inputTag)) diff --git a/Source/WebCore/rendering/InlineIterator.h b/Source/WebCore/rendering/InlineIterator.h index 8e8912d21..446174e02 100755 --- a/Source/WebCore/rendering/InlineIterator.h +++ b/Source/WebCore/rendering/InlineIterator.h @@ -131,14 +131,13 @@ static inline void notifyObserverEnteredObject(Observer* observer, RenderObject* // Thus we ignore any possible dir= attribute on the span. return; } - if (unicodeBidi == Isolate) { + if (isIsolated(unicodeBidi)) { observer->enterIsolate(); // Embedding/Override characters implied by dir= are handled when // we process the isolated span, not when laying out the "parent" run. return; } - // FIXME: Should unicode-bidi: plaintext really be embedding override/embed characters here? if (!observer->inIsolate()) observer->embed(embedCharFromDirection(style->direction(), unicodeBidi), FromStyleOrDOM); } @@ -152,7 +151,7 @@ static inline void notifyObserverWillExitObject(Observer* observer, RenderObject EUnicodeBidi unicodeBidi = object->style()->unicodeBidi(); if (unicodeBidi == UBNormal) return; // Nothing to do for unicode-bidi: normal - if (unicodeBidi == Isolate) { + if (isIsolated(unicodeBidi)) { observer->exitIsolate(); return; } @@ -255,9 +254,8 @@ static inline RenderObject* bidiNextIncludingEmptyInlines(RenderObject* root, Re return bidiNextShared(root, current, observer, IncludeEmptyInlines, endOfInlinePtr); } -static inline RenderObject* bidiFirstSkippingEmptyInlines(RenderObject* root, InlineBidiResolver* resolver) +static inline RenderObject* bidiFirstSkippingEmptyInlines(RenderObject* root, InlineBidiResolver* resolver = 0) { - ASSERT(resolver); RenderObject* o = root->firstChild(); if (!o) return 0; @@ -278,7 +276,8 @@ static inline RenderObject* bidiFirstSkippingEmptyInlines(RenderObject* root, In if (o && !isIteratorTarget(o)) o = bidiNextSkippingEmptyInlines(root, o, resolver); - resolver->commitExplicitEmbedding(); + if (resolver) + resolver->commitExplicitEmbedding(); return o; } @@ -392,7 +391,7 @@ inline void InlineBidiResolver::increment() static inline bool isIsolatedInline(RenderObject* object) { ASSERT(object); - return object->isRenderInline() && object->style()->unicodeBidi() == Isolate; + return object->isRenderInline() && isIsolated(object->style()->unicodeBidi()); } static inline RenderObject* containingIsolate(RenderObject* object, RenderObject* root) diff --git a/Source/WebCore/rendering/LayoutState.cpp b/Source/WebCore/rendering/LayoutState.cpp index c59e97002..c9018c599 100644 --- a/Source/WebCore/rendering/LayoutState.cpp +++ b/Source/WebCore/rendering/LayoutState.cpp @@ -37,7 +37,7 @@ namespace WebCore { LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo) : m_columnInfo(columnInfo) - , m_currentLineGrid(0) + , m_lineGrid(0) , m_next(prev) #ifndef NDEBUG , m_renderer(renderer) @@ -102,6 +102,9 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSiz m_pageLogicalHeight = 0; } + // Propagate line grid information. + propagateLineGridInfo(renderer); + if (!m_columnInfo) m_columnInfo = m_next->m_columnInfo; @@ -109,8 +112,8 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSiz m_isPaginated = m_pageLogicalHeight || m_columnInfo; - // Propagate line grid information. - propagateLineGridInfo(renderer); + if (lineGrid() && renderer->hasColumns() && renderer->style()->hasInlineColumnAxis()) + computeLineGridPaginationOrigin(renderer); // If we have a new grid to track, then add it to our set. if (renderer->style()->lineGrid() != RenderStyle::initialLineGrid() && renderer->isBlockFlow()) @@ -125,7 +128,7 @@ LayoutState::LayoutState(LayoutState* prev, RenderFlowThread* flowThread, bool r , m_pageLogicalHeight(1) // Use a fake height here. That value is not important, just needs to be non-zero. , m_pageLogicalHeightChanged(regionsChanged) , m_columnInfo(0) - , m_currentLineGrid(0) + , m_lineGrid(0) , m_next(prev) #ifndef NDEBUG , m_renderer(flowThread) @@ -142,7 +145,7 @@ LayoutState::LayoutState(RenderObject* root) , m_pageLogicalHeight(0) , m_pageLogicalHeightChanged(false) , m_columnInfo(0) - , m_currentLineGrid(0) + , m_lineGrid(0) , m_next(0) #ifndef NDEBUG , m_renderer(root) @@ -213,34 +216,77 @@ void LayoutState::propagateLineGridInfo(RenderBox* renderer) if (!m_next || renderer->isUnsplittableForPagination()) return; - m_currentLineGrid = m_next->m_currentLineGrid; - m_currentLineGridOffset = m_next->m_currentLineGridOffset; + m_lineGrid = m_next->m_lineGrid; + m_lineGridOffset = m_next->m_lineGridOffset; + m_lineGridPaginationOrigin = m_next->m_lineGridPaginationOrigin; } void LayoutState::establishLineGrid(RenderBlock* block) { // First check to see if this grid has been established already. - if (m_currentLineGrid) { - if (m_currentLineGrid->style()->lineGrid() == block->style()->lineGrid()) + if (m_lineGrid) { + if (m_lineGrid->style()->lineGrid() == block->style()->lineGrid()) return; - RenderBlock* currentGrid = m_currentLineGrid; + RenderBlock* currentGrid = m_lineGrid; for (LayoutState* currentState = m_next; currentState; currentState = currentState->m_next) { - if (currentState->m_currentLineGrid == currentGrid) + if (currentState->m_lineGrid == currentGrid) continue; - currentGrid = currentState->m_currentLineGrid; + currentGrid = currentState->m_lineGrid; if (!currentGrid) break; if (currentGrid->style()->lineGrid() == block->style()->lineGrid()) { - m_currentLineGrid = currentGrid; - m_currentLineGridOffset = currentState->m_currentLineGridOffset; + m_lineGrid = currentGrid; + m_lineGridOffset = currentState->m_lineGridOffset; return; } } } // We didn't find an already-established grid with this identifier. Our render object establishes the grid. - m_currentLineGrid = block; - m_currentLineGridOffset = m_layoutOffset; + m_lineGrid = block; + m_lineGridOffset = m_layoutOffset; +} + +void LayoutState::computeLineGridPaginationOrigin(RenderBox* renderer) +{ + // We need to cache a line grid pagination origin so that we understand how to reset the line grid + // at the top of each column. + // Get the current line grid and offset. + if (!lineGrid() || lineGrid()->style()->writingMode() != renderer->style()->writingMode()) + return; + + // Get the hypothetical line box used to establish the grid. + RootInlineBox* lineGridBox = lineGrid()->lineGridBox(); + if (!lineGridBox) + return; + + bool isHorizontalWritingMode = lineGrid()->isHorizontalWritingMode(); + + LayoutUnit lineGridBlockOffset = isHorizontalWritingMode ? lineGridOffset().height() : lineGridOffset().width(); + + // Now determine our position on the grid. Our baseline needs to be adjusted to the nearest baseline multiple + // as established by the line box. + // FIXME: Need to handle crazy line-box-contain values that cause the root line box to not be considered. I assume + // the grid should honor line-box-contain. + LayoutUnit gridLineHeight = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading(); + if (!gridLineHeight) + return; + + LayoutUnit firstLineTopWithLeading = lineGridBlockOffset + lineGridBox->lineTopWithLeading(); + + if (isPaginated() && pageLogicalHeight()) { + LayoutUnit pageLogicalTop = renderer->isHorizontalWritingMode() ? m_pageOffset.height() : m_pageOffset.width(); + if (pageLogicalTop > firstLineTopWithLeading) { + // Shift to the next highest line grid multiple past the page logical top. Cache the delta + // between this new value and the page logical top as the pagination origin. + LayoutUnit remainder = (pageLogicalTop - firstLineTopWithLeading) % gridLineHeight; + LayoutUnit paginationDelta = gridLineHeight - remainder; + if (isHorizontalWritingMode) + m_lineGridPaginationOrigin.setHeight(paginationDelta); + else + m_lineGridPaginationOrigin.setWidth(paginationDelta); + } + } } } // namespace WebCore diff --git a/Source/WebCore/rendering/LayoutState.h b/Source/WebCore/rendering/LayoutState.h index 951be3f7b..e1df24b4e 100644 --- a/Source/WebCore/rendering/LayoutState.h +++ b/Source/WebCore/rendering/LayoutState.h @@ -48,7 +48,7 @@ public: , m_pageLogicalHeight(0) , m_pageLogicalHeightChanged(false) , m_columnInfo(0) - , m_currentLineGrid(0) + , m_lineGrid(0) , m_next(0) #ifndef NDEBUG , m_renderer(0) @@ -81,12 +81,13 @@ public: LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; } bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; } - RenderBlock* currentLineGrid() const { return m_currentLineGrid; } - LayoutSize currentLineGridOffset() const { return m_currentLineGridOffset; } + RenderBlock* lineGrid() const { return m_lineGrid; } + LayoutSize lineGridOffset() const { return m_lineGridOffset; } + LayoutSize lineGridPaginationOrigin() const { return m_lineGridPaginationOrigin; } LayoutSize layoutOffset() const { return m_layoutOffset; } - bool needsBlockDirectionLocationSetBeforeLayout() const { return m_currentLineGrid || (m_isPaginated && m_pageLogicalHeight); } + bool needsBlockDirectionLocationSetBeforeLayout() const { return m_lineGrid || (m_isPaginated && m_pageLogicalHeight); } private: // The normal operator new is disallowed. @@ -95,6 +96,8 @@ private: void propagateLineGridInfo(RenderBox*); void establishLineGrid(RenderBlock*); + void computeLineGridPaginationOrigin(RenderBox*); + public: bool m_clipped; bool m_isPaginated; @@ -119,9 +122,10 @@ public: ColumnInfo* m_columnInfo; // The current line grid that we're snapping to and the offset of the start of the grid. - RenderBlock* m_currentLineGrid; - LayoutSize m_currentLineGridOffset; - + RenderBlock* m_lineGrid; + LayoutSize m_lineGridOffset; + LayoutSize m_lineGridPaginationOrigin; + LayoutState* m_next; #ifndef NDEBUG RenderObject* m_renderer; diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp index d9cadadb8..9b2bca5a9 100755 --- a/Source/WebCore/rendering/RenderBlock.cpp +++ b/Source/WebCore/rendering/RenderBlock.cpp @@ -1024,8 +1024,9 @@ void RenderBlock::collapseAnonymousBoxChild(RenderBlock* parent, RenderObject* c { parent->setNeedsLayoutAndPrefWidthsRecalc(); parent->setChildrenInline(child->childrenInline()); + RenderObject* nextSibling = child->nextSibling(); RenderBlock* anonBlock = toRenderBlock(parent->children()->removeChildNode(parent, child, child->hasLayer())); - anonBlock->moveAllChildrenTo(parent, child->hasLayer()); + anonBlock->moveAllChildrenTo(parent, nextSibling, child->hasLayer()); // Delete the now-empty block's lines and nuke it. if (!parent->documentBeingDestroyed()) anonBlock->deleteLineBoxTree(); @@ -1089,7 +1090,7 @@ void RenderBlock::removeChild(RenderObject* oldChild) // box. We can go ahead and pull the content right back up into our // box. collapseAnonymousBoxChild(this, child); - } else if ((prev && prev->isAnonymousBlock()) || (next && next->isAnonymousBlock())) { + } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymousBlock())) && !isFlexibleBoxIncludingDeprecated()) { // It's possible that the removal has knocked us down to a single anonymous // block with pseudo-style element siblings (e.g. first-letter). If these // are floating, then we need to pull the content up also. @@ -1207,6 +1208,27 @@ void RenderBlock::layout() clearLayoutOverflow(); } +void RenderBlock::computeInitialRegionRangeForBlock() +{ + if (inRenderFlowThread()) { + // Set our start and end regions. No regions above or below us will be considered by our children. They are + // effectively clamped to our region range. + LayoutUnit oldHeight = logicalHeight(); + LayoutUnit oldLogicalTop = logicalTop(); + setLogicalHeight(numeric_limits<LayoutUnit>::max() / 2); + computeLogicalHeight(); + enclosingRenderFlowThread()->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage()); + setLogicalHeight(oldHeight); + setLogicalTop(oldLogicalTop); + } +} + +void RenderBlock::computeRegionRangeForBlock() +{ + if (inRenderFlowThread()) + enclosingRenderFlowThread()->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage()); +} + void RenderBlock::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight, BlockLayoutPass layoutPass) { ASSERT(needsLayout()); @@ -1268,22 +1290,13 @@ void RenderBlock::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeigh RenderView* renderView = view(); RenderStyle* styleToUse = style(); LayoutStateMaintainer statePusher(renderView, this, locationOffset(), hasColumns() || hasTransform() || hasReflection() || styleToUse->isFlippedBlocksWritingMode(), pageLogicalHeight, pageLogicalHeightChanged, colInfo); - + if (inRenderFlowThread()) { // Regions changing widths can force us to relayout our children. if (logicalWidthChangedInRegions()) relayoutChildren = true; - - // Set our start and end regions. No regions above or below us will be considered by our children. They are - // effectively clamped to our region range. - LayoutUnit oldHeight = logicalHeight(); - LayoutUnit oldLogicalTop = logicalTop(); - setLogicalHeight(numeric_limits<LayoutUnit>::max() / 2); - computeLogicalHeight(); - enclosingRenderFlowThread()->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage()); - setLogicalHeight(oldHeight); - setLogicalTop(oldLogicalTop); } + computeInitialRegionRangeForBlock(); // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track // our current maximal positive and negative margins. These values are used when we @@ -1313,7 +1326,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeigh } // For overflow:scroll blocks, ensure we have both scrollbars in place always. - if (scrollsOverflow()) { + if (scrollsOverflow() && style()->appearance() != ListboxPart) { if (styleToUse->overflowX() == OSCROLL) layer()->setHasHorizontalScrollbar(true); if (styleToUse->overflowY() == OSCROLL) @@ -1361,8 +1374,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeigh bool needAnotherLayoutPass = layoutPositionedObjects(relayoutChildren || isRoot()); - if (inRenderFlowThread()) - enclosingRenderFlowThread()->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage()); + computeRegionRangeForBlock(); // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). computeOverflow(oldClientAfterEdge); @@ -2010,7 +2022,7 @@ void RenderBlock::layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloa setLogicalHeight(beforeEdge); // Lay out our hypothetical grid line as though it occurs at the top of the block. - if (view()->layoutState()->currentLineGrid() == this) + if (view()->layoutState()->lineGrid() == this) layoutLineGridBox(); // The margin struct caches all our current margin collapsing state. The compact struct caches state when we encounter compacts, @@ -3661,7 +3673,7 @@ inline void RenderBlock::FloatIntervalSearchAdapter<FloatTypeValue>::collectIfNe const FloatingObject* r = interval.data(); if (r->type() == FloatTypeValue && interval.low() <= m_value && m_value < interval.high()) { // All the objects returned from the tree should be already placed. - ASSERT(r->isPlaced() && m_renderer->logicalTopForFloat(r) <= m_value && m_renderer->logicalBottomForFloat(r) > m_value); + ASSERT(r->isPlaced() && m_renderer->pixelSnappedLogicalTopForFloat(r) <= m_value && m_renderer->pixelSnappedLogicalBottomForFloat(r) > m_value); if (FloatTypeValue == FloatingObject::FloatLeft && m_renderer->logicalRightForFloat(r) > m_offset) { @@ -3909,9 +3921,17 @@ void RenderBlock::clearFloats(BlockLayoutPass layoutPass) if (logicalWidthForFloat(f) != logicalWidthForFloat(oldFloatingObject) || logicalLeftForFloat(f) != logicalLeftForFloat(oldFloatingObject)) { changeLogicalTop = 0; changeLogicalBottom = max(changeLogicalBottom, max(logicalBottom, oldLogicalBottom)); - } else if (logicalBottom != oldLogicalBottom) { - changeLogicalTop = min(changeLogicalTop, min(logicalBottom, oldLogicalBottom)); - changeLogicalBottom = max(changeLogicalBottom, max(logicalBottom, oldLogicalBottom)); + } else { + if (logicalBottom != oldLogicalBottom) { + changeLogicalTop = min(changeLogicalTop, min(logicalBottom, oldLogicalBottom)); + changeLogicalBottom = max(changeLogicalBottom, max(logicalBottom, oldLogicalBottom)); + } + LayoutUnit logicalTop = logicalTopForFloat(f); + LayoutUnit oldLogicalTop = logicalTopForFloat(oldFloatingObject); + if (logicalTop != oldLogicalTop) { + changeLogicalTop = min(changeLogicalTop, min(logicalTop, oldLogicalTop)); + changeLogicalBottom = max(changeLogicalBottom, max(logicalTop, oldLogicalTop)); + } } floatMap.remove(f->m_renderer); diff --git a/Source/WebCore/rendering/RenderBlock.h b/Source/WebCore/rendering/RenderBlock.h index 2d47374d3..2ccf0aa25 100644 --- a/Source/WebCore/rendering/RenderBlock.h +++ b/Source/WebCore/rendering/RenderBlock.h @@ -163,6 +163,17 @@ public: return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, firstLine) : logicalWidth() - logicalRightOffsetForLine(position, firstLine); } + + // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318. + int pixelSnappedLogicalRightOffsetForLine(LayoutUnit position, bool firstLine) const + { + return logicalRightOffsetForLine(position, logicalRightOffsetForContent(position), firstLine, 0); + } + + int pixelSnappedLogicalLeftOffsetForLine(LayoutUnit position, bool firstLine) const + { + return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(position), firstLine, 0); + } LayoutUnit startAlignedOffsetForLine(RenderBox* child, LayoutUnit position, bool firstLine); LayoutUnit textIndentOffset() const; @@ -448,6 +459,8 @@ protected: } #endif + void computeInitialRegionRangeForBlock(); + void computeRegionRangeForBlock(); private: virtual RenderObjectChildList* virtualChildren() { return children(); } virtual const RenderObjectChildList* virtualChildren() const { return children(); } @@ -468,6 +481,7 @@ private: void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild); void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild); void addChildToAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild); + virtual void addChildIgnoringAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild = 0); virtual bool isSelfCollapsingBlock() const; @@ -558,6 +572,14 @@ private: LayoutUnit width() const { return m_frameRect.width(); } LayoutUnit height() const { return m_frameRect.height(); } + // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318. + int pixelSnappedX() const { return x(); } + int pixelSnappedMaxX() const { return maxX(); } + int pixelSnappedY() const { return y(); } + int pixelSnappedMaxY() const { return maxY(); } + int pixelSnappedWidth() const { return width(); } + int pixelSnappedHeight() const { return height(); } + void setX(LayoutUnit x) { ASSERT(!isInPlacedTree()); m_frameRect.setX(x); } void setY(LayoutUnit y) { ASSERT(!isInPlacedTree()); m_frameRect.setY(y); } void setWidth(LayoutUnit width) { ASSERT(!isInPlacedTree()); m_frameRect.setWidth(width); } @@ -592,6 +614,12 @@ private: LayoutUnit logicalRightForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxX() : child->maxY(); } LayoutUnit logicalWidthForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); } + // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318. + int pixelSnappedLogicalTopForFloat(const FloatingObject* child) const { return logicalTopForFloat(child); } + int pixelSnappedLogicalBottomForFloat(const FloatingObject* child) const { return logicalBottomForFloat(child); } + int pixelSnappedLogicalLeftForFloat(const FloatingObject* child) const { return logicalLeftForFloat(child); } + int pixelSnappedLogicalRightForFloat(const FloatingObject* child) const { return logicalRightForFloat(child); } + void setLogicalTopForFloat(FloatingObject* child, LayoutUnit logicalTop) { if (isHorizontalWritingMode()) diff --git a/Source/WebCore/rendering/RenderBlockLineLayout.cpp b/Source/WebCore/rendering/RenderBlockLineLayout.cpp index da74ea6c3..406930fc1 100755 --- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp +++ b/Source/WebCore/rendering/RenderBlockLineLayout.cpp @@ -128,11 +128,11 @@ inline void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(RenderBlock::Floa return; if (newFloat->type() == RenderBlock::FloatingObject::FloatLeft) { - m_left = m_block->logicalRightForFloat(newFloat); + m_left = m_block->pixelSnappedLogicalRightForFloat(newFloat); if (m_isFirstLine && m_block->style()->isLeftToRightDirection()) m_left += m_block->textIndentOffset(); } else { - m_right = m_block->logicalLeftForFloat(newFloat); + m_right = m_block->pixelSnappedLogicalLeftForFloat(newFloat); if (m_isFirstLine && !m_block->style()->isLeftToRightDirection()) m_right -= m_block->textIndentOffset(); } @@ -258,7 +258,7 @@ static LayoutUnit inlineLogicalWidth(RenderObject* child, bool start = true, boo return extraWidth; } -static void determineParagraphDirection(TextDirection& dir, InlineIterator iter) +static void determineDirectionality(TextDirection& dir, InlineIterator iter) { while (!iter.atEnd()) { if (iter.atParagraphSeparator()) @@ -970,18 +970,27 @@ static inline void constructBidiRuns(InlineBidiResolver& topResolver, BidiRunLis // tree to see which parent inline is the isolate. We could change enterIsolate // to take a RenderObject and do this logic there, but that would be a layering // violation for BidiResolver (which knows nothing about RenderObject). - RenderInline* isolatedSpan = toRenderInline(containingIsolate(startObj, currentRoot)); + RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj, currentRoot)); InlineBidiResolver isolatedResolver; - isolatedResolver.setStatus(statusWithDirection(isolatedSpan->style()->direction())); + EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); + TextDirection direction; + if (unicodeBidi == Plaintext) + determineDirectionality(direction, InlineIterator(isolatedInline, isolatedRun->object(), 0)); + else { + ASSERT(unicodeBidi == Isolate); + direction = isolatedInline->style()->direction(); + } + isolatedResolver.setStatus(statusWithDirection(direction)); // FIXME: The fact that we have to construct an Iterator here // currently prevents this code from moving into BidiResolver. - if (!bidiFirstSkippingEmptyInlines(isolatedSpan, &isolatedResolver)) + if (!bidiFirstSkippingEmptyInlines(isolatedInline, &isolatedResolver)) continue; + // The starting position is the beginning of the first run within the isolate that was identified // during the earlier call to createBidiRunsForLine. This can be but is not necessarily the // first run within the isolate. - InlineIterator iter = InlineIterator(isolatedSpan, startObj, isolatedRun->m_start); + InlineIterator iter = InlineIterator(isolatedInline, startObj, isolatedRun->m_start); isolatedResolver.setPositionIgnoringNestedIsolates(iter); // We stop at the next end of line; we may re-enter this isolate in the next call to constructBidiRuns(). @@ -1240,7 +1249,7 @@ void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, Inlin FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0; end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBreakIteratorInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines); if (resolver.position().atEnd()) { - // FIXME: We shouldn't be creating any runs in findNextLineBreak to begin with! + // FIXME: We shouldn't be creating any runs in nextLineBreak to begin with! // Once BidiRunList is separated from BidiResolver this will not be needed. resolver.runs().deleteRuns(); resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced by an ASSERT (or just removed). @@ -1259,7 +1268,7 @@ void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, Inlin if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && !resolver.context()->parent()) { TextDirection direction = styleToUse->direction(); - determineParagraphDirection(direction, resolver.position()); + determineDirectionality(direction, resolver.position()); resolver.setStatus(BidiStatus(direction, styleToUse->unicodeBidi() == Override)); } // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. @@ -1441,7 +1450,7 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, LayoutUnit& repain setLogicalHeight(borderBefore() + paddingBefore()); // Lay out our hypothetical grid line as though it occurs at the top of the block. - if (view()->layoutState() && view()->layoutState()->currentLineGrid() == this) + if (view()->layoutState() && view()->layoutState()->lineGrid() == this) layoutLineGridBox(); // Figure out if we should clear out our line boxes. @@ -1668,10 +1677,8 @@ RootInlineBox* RenderBlock::determineStartPosition(LineLayoutState& layoutState, resolver.setStatus(last->lineBreakBidiStatus()); } else { TextDirection direction = style()->direction(); - if (style()->unicodeBidi() == Plaintext) { - // FIXME: Why does "unicode-bidi: plaintext" bidiFirstIncludingEmptyInlines when all other line layout code uses bidiFirstSkippingEmptyInlines? - determineParagraphDirection(direction, InlineIterator(this, bidiFirstIncludingEmptyInlines(this), 0)); - } + if (style()->unicodeBidi() == Plaintext) + determineDirectionality(direction, InlineIterator(this, bidiFirstSkippingEmptyInlines(this), 0)); resolver.setStatus(BidiStatus(direction, style()->unicodeBidi() == Override)); InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines(this, &resolver), 0); resolver.setPosition(iter, numberOfIsolateAncestors(iter)); diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp index 63fd6f807..f3ca0b1d1 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -478,6 +478,16 @@ LayoutUnit RenderBox::clientHeight() const return height() - borderTop() - borderBottom() - horizontalScrollbarHeight(); } +int RenderBox::pixelSnappedClientWidth() const +{ + return clientWidth(); +} + +int RenderBox::pixelSnappedClientHeight() const +{ + return clientHeight(); +} + int RenderBox::scrollWidth() const { if (hasOverflowClip()) @@ -495,7 +505,7 @@ int RenderBox::scrollHeight() const return layer()->scrollHeight(); // For objects with visible overflow, this matches IE. // FIXME: Need to work right with writing modes. - return max(clientHeight(), maxYLayoutOverflow() - borderTop()); + return max(pixelSnappedClientHeight(), maxYLayoutOverflow() - borderTop()); } int RenderBox::scrollLeft() const diff --git a/Source/WebCore/rendering/RenderBox.h b/Source/WebCore/rendering/RenderBox.h index d1637faa2..f9b852c54 100644 --- a/Source/WebCore/rendering/RenderBox.h +++ b/Source/WebCore/rendering/RenderBox.h @@ -51,6 +51,10 @@ public: LayoutUnit width() const { return m_frameRect.width(); } LayoutUnit height() const { return m_frameRect.height(); } + // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318. + int pixelSnappedWidth() const { return m_frameRect.width(); } + int pixelSnappedHeight() const { return m_frameRect.height(); } + // These represent your location relative to your container as a physical offset. // In layout related methods you almost always want the logical location (e.g. x() and y()). LayoutUnit top() const { return topLeftLocation().y(); } @@ -183,17 +187,24 @@ public: virtual LayoutUnit offsetWidth() const { return width(); } virtual LayoutUnit offsetHeight() const { return height(); } + // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318. + virtual int pixelSnappedOffsetWidth() const { return pixelSnappedWidth(); } + virtual int pixelSnappedOffsetHeight() const { return pixelSnappedHeight(); } + // More IE extensions. clientWidth and clientHeight represent the interior of an object // excluding border and scrollbar. clientLeft/Top are just the borderLeftWidth and borderTopWidth. LayoutUnit clientLeft() const { return borderLeft(); } LayoutUnit clientTop() const { return borderTop(); } LayoutUnit clientWidth() const; LayoutUnit clientHeight() const; - LayoutUnit clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? clientWidth() : clientHeight(); } - LayoutUnit clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? clientHeight() : clientWidth(); } + LayoutUnit clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? pixelSnappedClientWidth() : pixelSnappedClientHeight(); } + LayoutUnit clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? pixelSnappedClientHeight() : pixelSnappedClientWidth(); } LayoutUnit clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); } LayoutRect clientBoxRect() const { return LayoutRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); } + int pixelSnappedClientWidth() const; + int pixelSnappedClientHeight() const; + // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the // object has overflow:hidden/scroll/auto specified and also has overflow. // scrollLeft/Top return the current scroll position. These methods are virtual so that objects like diff --git a/Source/WebCore/rendering/RenderBoxModelObject.cpp b/Source/WebCore/rendering/RenderBoxModelObject.cpp index 37eedf4fe..3aadee902 100644 --- a/Source/WebCore/rendering/RenderBoxModelObject.cpp +++ b/Source/WebCore/rendering/RenderBoxModelObject.cpp @@ -512,6 +512,16 @@ LayoutUnit RenderBoxModelObject::offsetTop() const return yPos; } +int RenderBoxModelObject::pixelSnappedOffsetWidth() const +{ + return offsetWidth(); +} + +int RenderBoxModelObject::pixelSnappedOffsetHeight() const +{ + return offsetHeight(); +} + LayoutUnit RenderBoxModelObject::paddingTop(bool) const { LayoutUnit w = 0; diff --git a/Source/WebCore/rendering/RenderBoxModelObject.h b/Source/WebCore/rendering/RenderBoxModelObject.h index bb81bd3be..027b1fb89 100644 --- a/Source/WebCore/rendering/RenderBoxModelObject.h +++ b/Source/WebCore/rendering/RenderBoxModelObject.h @@ -60,6 +60,12 @@ public: virtual LayoutUnit offsetWidth() const = 0; virtual LayoutUnit offsetHeight() const = 0; + // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318. + int pixelSnappedOffsetLeft() const { return offsetLeft(); } + int pixelSnappedOffsetTop() const { return offsetTop(); } + int pixelSnappedOffsetWidth() const; + int pixelSnappedOffsetHeight() const; + virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle); virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); virtual void updateBoxModelInfoFromStyle(); diff --git a/Source/WebCore/rendering/RenderCounter.cpp b/Source/WebCore/rendering/RenderCounter.cpp index 399da930a..0807ea9dd 100644 --- a/Source/WebCore/rendering/RenderCounter.cpp +++ b/Source/WebCore/rendering/RenderCounter.cpp @@ -301,7 +301,7 @@ static bool planCounter(RenderObject* object, const AtomicString& identifier, bo // reset node. // - Non-reset CounterNodes cannot have descendants. -static bool findPlaceForCounter(RenderObject* counterOwner, const AtomicString& identifier, bool isReset, CounterNode*& parent, CounterNode*& previousSibling) +static bool findPlaceForCounter(RenderObject* counterOwner, const AtomicString& identifier, bool isReset, RefPtr<CounterNode>& parent, RefPtr<CounterNode>& previousSibling) { // We cannot stop searching for counters with the same identifier before we also // check this renderer, because it may affect the positioning in the tree of our counter. @@ -346,7 +346,9 @@ static bool findPlaceForCounter(RenderObject* counterOwner, const AtomicString& if (!isReset || !areRenderersElementsSiblings(currentRenderer, counterOwner)) { // If the node we are placing is not reset or we have found a counter that is attached // to an ancestor of the placed counter's owner renderer we know we are a sibling of that node. - ASSERT(currentCounter->parent() == previousSiblingProtector->parent()); + if (currentCounter->parent() != previousSiblingProtector->parent()) + return false; + parent = currentCounter->parent(); previousSibling = previousSiblingProtector.get(); return true; @@ -428,11 +430,11 @@ static CounterNode* makeCounterNode(RenderObject* object, const AtomicString& id if (!planCounter(object, identifier, isReset, value) && !alwaysCreateCounter) return 0; - CounterNode* newParent = 0; - CounterNode* newPreviousSibling = 0; + RefPtr<CounterNode> newParent = 0; + RefPtr<CounterNode> newPreviousSibling = 0; RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value); if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousSibling)) - newParent->insertAfter(newNode.get(), newPreviousSibling, identifier); + newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifier); CounterMap* nodeMap; if (object->hasCounterNodeMap()) nodeMap = counterMaps().get(object); @@ -628,8 +630,8 @@ static void updateCounters(RenderObject* renderer) makeCounterNode(renderer, AtomicString(it->first.get()), false); continue; } - CounterNode* newParent = 0; - CounterNode* newPreviousSibling; + RefPtr<CounterNode> newParent = 0; + RefPtr<CounterNode> newPreviousSibling = 0; findPlaceForCounter(renderer, AtomicString(it->first.get()), node->hasResetType(), newParent, newPreviousSibling); if (node != counterMap->get(it->first.get())) @@ -640,7 +642,7 @@ static void updateCounters(RenderObject* renderer) if (parent) parent->removeChild(node.get()); if (newParent) - newParent->insertAfter(node.get(), newPreviousSibling, it->first.get()); + newParent->insertAfter(node.get(), newPreviousSibling.get(), it->first.get()); } } diff --git a/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp b/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp index 3342fc590..4e88d5c6b 100644 --- a/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp +++ b/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp @@ -228,6 +228,13 @@ void RenderDeprecatedFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); LayoutStateMaintainer statePusher(view(), this, LayoutSize(x(), y()), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); + if (inRenderFlowThread()) { + // Regions changing widths can force us to relayout our children. + if (logicalWidthChangedInRegions()) + relayoutChildren = true; + } + computeInitialRegionRangeForBlock(); + LayoutSize previousSize = size(); computeLogicalWidth(); @@ -267,6 +274,8 @@ void RenderDeprecatedFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit bool needAnotherLayoutPass = layoutPositionedObjects(relayoutChildren || isRoot()); + computeRegionRangeForBlock(); + if (!isFloatingOrPositioned() && height() == 0) { // We are a block with no border and padding and a computed height // of 0. The CSS spec states that zero-height blocks collapse their margins diff --git a/Source/WebCore/rendering/RenderFlexibleBox.cpp b/Source/WebCore/rendering/RenderFlexibleBox.cpp index 45543fe90..b025cd317 100644 --- a/Source/WebCore/rendering/RenderFlexibleBox.cpp +++ b/Source/WebCore/rendering/RenderFlexibleBox.cpp @@ -166,6 +166,13 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, int, BlockLayoutPass) LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); + if (inRenderFlowThread()) { + // Regions changing widths can force us to relayout our children. + if (logicalWidthChangedInRegions()) + relayoutChildren = true; + } + computeInitialRegionRangeForBlock(); + IntSize previousSize = size(); setLogicalHeight(0); @@ -193,6 +200,8 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, int, BlockLayoutPass) layoutPositionedObjects(relayoutChildren || isRoot()); + computeRegionRangeForBlock(); + // FIXME: css3/flexbox/repaint-rtl-column.html seems to repaint more overflow than it needs to. computeOverflow(oldClientAfterEdge); statePusher.pop(); @@ -444,7 +453,7 @@ LayoutUnit RenderFlexibleBox::mainAxisScrollbarExtentForChild(RenderBox* child) return isHorizontalFlow() ? child->verticalScrollbarWidth() : child->horizontalScrollbarHeight(); } -LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForFlexItem(RenderBox* child) const +LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child) const { Length mainAxisLength = mainAxisLengthForChild(child); if (mainAxisLength.isAuto()) { @@ -456,12 +465,15 @@ LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForFlexItem(RenderBo void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren) { - LayoutUnit preferredMainAxisExtent; float totalPositiveFlexibility; float totalNegativeFlexibility; TreeOrderIterator treeIterator(this); - computePreferredMainAxisExtent(relayoutChildren, treeIterator, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility); + WTF::Vector<LayoutUnit> preferredSizes; + computeMainAxisPreferredSizes(relayoutChildren, treeIterator, preferredSizes, totalPositiveFlexibility, totalNegativeFlexibility); + LayoutUnit preferredMainAxisExtent = 0; + for (size_t i = 0; i < preferredSizes.size(); ++i) + preferredMainAxisExtent += preferredSizes[i]; LayoutUnit availableFreeSpace = mainAxisContentExtent() - preferredMainAxisExtent; FlexOrderIterator flexIterator(this, treeIterator.flexOrderValues()); @@ -500,15 +512,16 @@ LayoutUnit RenderFlexibleBox::marginBoxAscent(RenderBox* child) return ascent + flowAwareMarginBeforeForChild(child); } -void RenderFlexibleBox::computePreferredMainAxisExtent(bool relayoutChildren, TreeOrderIterator& iterator, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility) +void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, TreeOrderIterator& iterator, WTF::Vector<LayoutUnit>& preferredSizes, float& totalPositiveFlexibility, float& totalNegativeFlexibility) { - preferredMainAxisExtent = 0; totalPositiveFlexibility = totalNegativeFlexibility = 0; LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent(); for (RenderBox* child = iterator.first(); child; child = iterator.next()) { - if (child->isPositioned()) + if (child->isPositioned()) { + preferredSizes.append(0); continue; + } child->clearOverrideSize(); if (mainAxisLengthForChild(child).isAuto()) { @@ -517,21 +530,22 @@ void RenderFlexibleBox::computePreferredMainAxisExtent(bool relayoutChildren, Tr child->layoutIfNeeded(); } + LayoutUnit preferredSize = mainAxisBorderAndPaddingExtentForChild(child) + preferredMainAxisContentExtentForChild(child); + // We set the margins because we want to make sure 'auto' has a margin // of 0 and because if we're not auto sizing, we don't do a layout that // computes the start/end margins. if (isHorizontalFlow()) { child->setMarginLeft(child->style()->marginLeft().calcMinValue(flexboxAvailableContentExtent)); child->setMarginRight(child->style()->marginRight().calcMinValue(flexboxAvailableContentExtent)); - preferredMainAxisExtent += child->marginLeft() + child->marginRight(); + preferredSize += child->marginLeft() + child->marginRight(); } else { child->setMarginTop(child->style()->marginTop().calcMinValue(flexboxAvailableContentExtent)); child->setMarginBottom(child->style()->marginBottom().calcMinValue(flexboxAvailableContentExtent)); - preferredMainAxisExtent += child->marginTop() + child->marginBottom(); + preferredSize += child->marginTop() + child->marginBottom(); } - preferredMainAxisExtent += mainAxisBorderAndPaddingExtentForChild(child); - preferredMainAxisExtent += preferredMainAxisContentExtentForFlexItem(child); + preferredSizes.append(preferredSize); totalPositiveFlexibility += positiveFlexForChild(child); totalNegativeFlexibility += negativeFlexForChild(child); @@ -554,14 +568,14 @@ bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithm(FlexOrderIterator& itera if (inflexibleItems.contains(child)) childPreferredSize = inflexibleItems.get(child); else { - childPreferredSize = preferredMainAxisContentExtentForFlexItem(child); + childPreferredSize = preferredMainAxisContentExtentForChild(child); if (availableFreeSpace > 0 && totalPositiveFlexibility > 0) { childPreferredSize += lroundf(availableFreeSpace * positiveFlexForChild(child) / totalPositiveFlexibility); Length childLogicalMaxWidth = isHorizontalFlow() ? child->style()->maxWidth() : child->style()->maxHeight(); if (!childLogicalMaxWidth.isUndefined() && childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent)) { childPreferredSize = childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent); - availableFreeSpace -= childPreferredSize - preferredMainAxisContentExtentForFlexItem(child); + availableFreeSpace -= childPreferredSize - preferredMainAxisContentExtentForChild(child); totalPositiveFlexibility -= positiveFlexForChild(child); inflexibleItems.set(child, childPreferredSize); @@ -573,7 +587,7 @@ bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithm(FlexOrderIterator& itera Length childLogicalMinWidth = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight(); if (!childLogicalMinWidth.isUndefined() && childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableContentExtent)) { childPreferredSize = childLogicalMinWidth.calcValue(flexboxAvailableContentExtent); - availableFreeSpace += preferredMainAxisContentExtentForFlexItem(child) - childPreferredSize; + availableFreeSpace += preferredMainAxisContentExtentForChild(child) - childPreferredSize; totalNegativeFlexibility -= negativeFlexForChild(child); inflexibleItems.set(child, childPreferredSize); diff --git a/Source/WebCore/rendering/RenderFlexibleBox.h b/Source/WebCore/rendering/RenderFlexibleBox.h index 3ec4c2a6b..0833217b6 100644 --- a/Source/WebCore/rendering/RenderFlexibleBox.h +++ b/Source/WebCore/rendering/RenderFlexibleBox.h @@ -85,7 +85,7 @@ private: void adjustAlignmentForChild(RenderBox* child, LayoutUnit); LayoutUnit mainAxisBorderAndPaddingExtentForChild(RenderBox* child) const; LayoutUnit mainAxisScrollbarExtentForChild(RenderBox* child) const; - LayoutUnit preferredMainAxisContentExtentForFlexItem(RenderBox* child) const; + LayoutUnit preferredMainAxisContentExtentForChild(RenderBox* child) const; void layoutFlexItems(bool relayoutChildren); @@ -95,7 +95,7 @@ private: LayoutUnit availableAlignmentSpaceForChild(RenderBox*); LayoutUnit marginBoxAscent(RenderBox*); - void computePreferredMainAxisExtent(bool relayoutChildren, TreeOrderIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility); + void computeMainAxisPreferredSizes(bool relayoutChildren, TreeOrderIterator&, WTF::Vector<LayoutUnit>&, float& totalPositiveFlexibility, float& totalNegativeFlexibility); bool runFreeSpaceAllocationAlgorithm(FlexOrderIterator&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes); void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize); void prepareChildForPositionedLayout(RenderBox* child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset); diff --git a/Source/WebCore/rendering/RenderFlowThread.cpp b/Source/WebCore/rendering/RenderFlowThread.cpp index 8539a1208..9e39d9607 100644 --- a/Source/WebCore/rendering/RenderFlowThread.cpp +++ b/Source/WebCore/rendering/RenderFlowThread.cpp @@ -204,6 +204,7 @@ void RenderFlowThread::addRegionToThread(RenderRegion* renderRegion) void RenderFlowThread::removeRegionFromThread(RenderRegion* renderRegion) { ASSERT(renderRegion); + m_regionRangeMap.clear(); m_regionList.remove(renderRegion); @@ -653,7 +654,7 @@ void RenderFlowThread::removeRenderBoxRegionInfo(RenderBox* box) RenderRegion* startRegion; RenderRegion* endRegion; getRegionRangeForBox(box, startRegion, endRegion); - + for (RenderRegionList::iterator iter = m_regionList.find(startRegion); iter != m_regionList.end(); ++iter) { RenderRegion* region = *iter; if (!region->isValid()) @@ -662,7 +663,17 @@ void RenderFlowThread::removeRenderBoxRegionInfo(RenderBox* box) if (region == endRegion) break; } - + +#ifndef NDEBUG + // We have to make sure we did not left any boxes with region info attached in regions. + for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) { + RenderRegion* region = *iter; + if (!region->isValid()) + continue; + ASSERT(!region->renderBoxRegionInfo(box)); + } +#endif + m_regionRangeMap.remove(box); } diff --git a/Source/WebCore/rendering/RenderFrameSet.cpp b/Source/WebCore/rendering/RenderFrameSet.cpp index 6b6d23981..fc2c97f17 100644 --- a/Source/WebCore/rendering/RenderFrameSet.cpp +++ b/Source/WebCore/rendering/RenderFrameSet.cpp @@ -80,7 +80,7 @@ static Color borderFillColor() return Color(208, 208, 208); } -void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect& borderRect) +void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const LayoutRect& borderRect) { if (!paintInfo.rect.intersects(borderRect)) return; @@ -100,7 +100,7 @@ void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect } } -void RenderFrameSet::paintRowBorder(const PaintInfo& paintInfo, const IntRect& borderRect) +void RenderFrameSet::paintRowBorder(const PaintInfo& paintInfo, const LayoutRect& borderRect) { if (!paintInfo.rect.intersects(borderRect)) return; diff --git a/Source/WebCore/rendering/RenderFrameSet.h b/Source/WebCore/rendering/RenderFrameSet.h index 63ae2a824..373d0d02c 100644 --- a/Source/WebCore/rendering/RenderFrameSet.h +++ b/Source/WebCore/rendering/RenderFrameSet.h @@ -119,8 +119,8 @@ private: void startResizing(GridAxis&, int position); void continueResizing(GridAxis&, int position); - void paintRowBorder(const PaintInfo&, const IntRect&); - void paintColumnBorder(const PaintInfo&, const IntRect&); + void paintRowBorder(const PaintInfo&, const LayoutRect&); + void paintColumnBorder(const PaintInfo&, const LayoutRect&); RenderObjectChildList m_children; diff --git a/Source/WebCore/rendering/RenderInline.cpp b/Source/WebCore/rendering/RenderInline.cpp index 12a9dfcf8..a4d95c003 100644 --- a/Source/WebCore/rendering/RenderInline.cpp +++ b/Source/WebCore/rendering/RenderInline.cpp @@ -383,7 +383,7 @@ void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox madeNewBeforeBlock = true; } - RenderBlock* post = block->createAnonymousBlock(); + RenderBlock* post = block->createAnonymousBlockWithSameTypeAs(pre); RenderObject* boxFirst = madeNewBeforeBlock ? block->firstChild() : pre->nextSibling(); if (madeNewBeforeBlock) diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index d06b30d7d..ee6e8beea 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -45,7 +45,6 @@ #include "RenderLayer.h" #include "ColumnInfo.h" -#include "CSSMutableStyleDeclaration.h" #include "CSSPropertyNames.h" #include "CSSStyleSelector.h" #include "Chrome.h" @@ -67,6 +66,7 @@ #include "FrameView.h" #include "Gradient.h" #include "GraphicsContext.h" +#include "HTMLFrameElement.h" #include "HTMLFrameOwnerElement.h" #include "HTMLNames.h" #include "HitTestingTransformState.h" @@ -90,6 +90,7 @@ #include "ScrollbarTheme.h" #include "Settings.h" #include "SourceGraphic.h" +#include "StylePropertySet.h" #include "TextStream.h" #include "TransformationMatrix.h" #include "TranslateTransformOperation.h" @@ -184,7 +185,6 @@ RenderLayer::RenderLayer(RenderBoxModelObject* renderer) , m_reflection(0) , m_scrollCorner(0) , m_resizer(0) - , m_scrollableAreaPage(0) { m_isNormalFlowOnly = shouldBeNormalFlowOnly(); @@ -203,8 +203,10 @@ RenderLayer::~RenderLayer() frame->eventHandler()->resizeLayerDestroyed(); } - if (m_scrollableAreaPage) - m_scrollableAreaPage->removeScrollableArea(this); + if (Frame* frame = renderer()->frame()) { + if (FrameView* frameView = frame->view()) + frameView->removeScrollableArea(this); + } destroyScrollbar(HorizontalScrollbar); destroyScrollbar(VerticalScrollbar); @@ -884,6 +886,11 @@ RenderLayer* RenderLayer::enclosingScrollableLayer() const return 0; } +IntRect RenderLayer::scrollableAreaBoundingBox() const +{ + return renderer()->absoluteBoundingBoxRect(); +} + RenderLayer* RenderLayer::enclosingTransformedAncestor() const { RenderLayer* curr = parent(); @@ -1542,20 +1549,31 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignm } } else if (!parentLayer && renderer()->isBox() && renderBox()->canBeProgramaticallyScrolled()) { if (frameView) { - if (renderer()->document() && renderer()->document()->ownerElement() && renderer()->document()->ownerElement()->renderer()) { - LayoutRect viewRect = frameView->visibleContentRect(); - LayoutRect r = getRectToExpose(viewRect, rect, alignX, alignY); - - LayoutUnit xOffset = r.x(); - LayoutUnit yOffset = r.y(); - // Adjust offsets if they're outside of the allowable range. - xOffset = max<LayoutUnit>(0, min(frameView->contentsWidth(), xOffset)); - yOffset = max<LayoutUnit>(0, min(frameView->contentsHeight(), yOffset)); - - frameView->setScrollPosition(IntPoint(xOffset, yOffset)); - parentLayer = renderer()->document()->ownerElement()->renderer()->enclosingLayer(); - newRect.setX(rect.x() - frameView->scrollX() + frameView->x()); - newRect.setY(rect.y() - frameView->scrollY() + frameView->y()); + Element* ownerElement = 0; + if (renderer()->document()) + ownerElement = renderer()->document()->ownerElement(); + + if (ownerElement && ownerElement->renderer()) { + HTMLFrameElement* frameElement = 0; + + if (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag)) + frameElement = static_cast<HTMLFrameElement*>(ownerElement); + + if (frameElement && frameElement->scrollingMode() != ScrollbarAlwaysOff) { + LayoutRect viewRect = frameView->visibleContentRect(); + LayoutRect exposeRect = getRectToExpose(viewRect, rect, alignX, alignY); + + LayoutUnit xOffset = exposeRect.x(); + LayoutUnit yOffset = exposeRect.y(); + // Adjust offsets if they're outside of the allowable range. + xOffset = max<LayoutUnit>(0, min(frameView->contentsWidth(), xOffset)); + yOffset = max<LayoutUnit>(0, min(frameView->contentsHeight(), yOffset)); + + frameView->setScrollPosition(IntPoint(xOffset, yOffset)); + parentLayer = ownerElement->renderer()->enclosingLayer(); + newRect.setX(rect.x() - frameView->scrollX() + frameView->x()); + newRect.setY(rect.y() - frameView->scrollY() + frameView->y()); + } } else { LayoutRect viewRect = frameView->visibleContentRect(); LayoutRect r = getRectToExpose(viewRect, rect, alignX, alignY); @@ -1707,7 +1725,7 @@ void RenderLayer::resize(const PlatformMouseEvent& evt, const LayoutSize& oldOff LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - currentSize; ASSERT(element->isStyledElement()); - CSSMutableStyleDeclaration* styleDeclaration = static_cast<StyledElement*>(element)->ensureInlineStyleDecl(); + StylePropertySet* styleDeclaration = static_cast<StyledElement*>(element)->ensureInlineStyleDecl(); bool isBoxSizingBorder = renderer->style()->boxSizing() == BORDER_BOX; if (resize != RESIZE_VERTICAL && difference.width()) { @@ -2043,19 +2061,6 @@ bool RenderLayer::allowsScrolling() const return (m_hBar && m_hBar->enabled()) || (m_vBar && m_vBar->enabled()); } -void RenderLayer::didAddHorizontalScrollbar(Scrollbar* scrollbar) -{ - m_renderer->document()->didAddWheelEventHandler(); - ScrollableArea::didAddHorizontalScrollbar(scrollbar); -} - -void RenderLayer::willRemoveHorizontalScrollbar(Scrollbar* scrollbar) -{ - ScrollableArea::willRemoveHorizontalScrollbar(scrollbar); - // FIXME: maybe need a separate ScrollableArea::didRemoveHorizontalScrollbar callback? - m_renderer->document()->didRemoveWheelEventHandler(); -} - void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar) { if (hasScrollbar == (m_hBar != 0)) @@ -2208,6 +2213,16 @@ LayoutUnit RenderLayer::scrollHeight() return m_scrollSize.height(); } +int RenderLayer::pixelSnappedScrollWidth() +{ + return scrollWidth(); +} + +int RenderLayer::pixelSnappedScrollHeight() +{ + return scrollHeight(); +} + LayoutUnit RenderLayer::overflowTop() const { RenderBox* box = renderBox(); @@ -2256,9 +2271,9 @@ void RenderLayer::computeScrollDimensions(bool* needHBar, bool* needVBar) setScrollOrigin(IntPoint(-m_scrollOverflow.width(), -m_scrollOverflow.height())); if (needHBar) - *needHBar = m_scrollSize.width() > box->clientWidth(); + *needHBar = pixelSnappedScrollWidth() > box->pixelSnappedClientWidth(); if (needVBar) - *needVBar = m_scrollSize.height() > box->clientHeight(); + *needVBar = pixelSnappedScrollHeight() > box->pixelSnappedClientHeight(); } void RenderLayer::updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow) @@ -2309,9 +2324,9 @@ void RenderLayer::updateScrollInfoAfterLayout() bool haveVerticalBar = m_vBar; // overflow:scroll should just enable/disable. - if (renderer()->style()->overflowX() == OSCROLL) + if (m_hBar && renderer()->style()->overflowX() == OSCROLL) m_hBar->setEnabled(horizontalOverflow); - if (renderer()->style()->overflowY() == OSCROLL) + if (m_vBar && renderer()->style()->overflowY() == OSCROLL) m_vBar->setEnabled(verticalOverflow); // A dynamic change from a scrolling overflow to overflow:hidden means we need to get rid of any @@ -2363,14 +2378,14 @@ void RenderLayer::updateScrollInfoAfterLayout() // Set up the range (and page step/line step). if (m_hBar) { - LayoutUnit clientWidth = box->clientWidth(); - LayoutUnit pageStep = max<LayoutUnit>(max<LayoutUnit>(clientWidth * Scrollbar::minFractionToStepWhenPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1); + int clientWidth = box->pixelSnappedClientWidth(); + int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWhenPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1); m_hBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); m_hBar->setProportion(clientWidth, m_scrollSize.width()); } if (m_vBar) { - LayoutUnit clientHeight = box->clientHeight(); - LayoutUnit pageStep = max<LayoutUnit>(max<LayoutUnit>(clientHeight * Scrollbar::minFractionToStepWhenPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); + int clientHeight = box->pixelSnappedClientHeight(); + int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepWhenPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); m_vBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); m_vBar->setProportion(clientHeight, m_scrollSize.height()); } @@ -4334,19 +4349,14 @@ void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) #if ENABLE(CSS_FILTERS) updateOrRemoveFilterEffect(); #endif - - if (scrollsOverflow()) { - if (!m_scrollableAreaPage) { - if (Frame* frame = renderer()->frame()) { - if (Page* page = frame->page()) { - m_scrollableAreaPage = page; - m_scrollableAreaPage->addScrollableArea(this); - } - } + + if (Frame* frame = renderer()->frame()) { + if (FrameView* frameView = frame->view()) { + if (scrollsOverflow()) + frameView->addScrollableArea(this); + else + frameView->removeScrollableArea(this); } - } else if (m_scrollableAreaPage) { - m_scrollableAreaPage->removeScrollableArea(this); - m_scrollableAreaPage = 0; } // FIXME: Need to detect a swap from custom to native scrollbars (and vice versa). diff --git a/Source/WebCore/rendering/RenderLayer.h b/Source/WebCore/rendering/RenderLayer.h index de75f245d..bb4797bb2 100644 --- a/Source/WebCore/rendering/RenderLayer.h +++ b/Source/WebCore/rendering/RenderLayer.h @@ -282,6 +282,8 @@ public: LayoutUnit scrollWidth(); LayoutUnit scrollHeight(); + int pixelSnappedScrollWidth(); + int pixelSnappedScrollHeight(); void panScrollFromPoint(const LayoutPoint&); @@ -310,8 +312,6 @@ public: bool scrollsOverflow() const; bool allowsScrolling() const; // Returns true if at least one scrollbar is visible and enabled. bool hasScrollbars() const { return m_hBar || m_vBar; } - virtual void didAddHorizontalScrollbar(Scrollbar*); - virtual void willRemoveHorizontalScrollbar(Scrollbar*); void setHasHorizontalScrollbar(bool); void setHasVerticalScrollbar(bool); @@ -664,12 +664,11 @@ private: virtual IntPoint currentMousePosition() const; virtual bool shouldSuspendScrollAnimations() const; virtual bool isOnActivePage() const; + virtual IntRect scrollableAreaBoundingBox() const OVERRIDE; // Rectangle encompassing the scroll corner and resizer rect. IntRect scrollCornerAndResizerRect() const; - virtual void disconnectFromPage() { m_scrollableAreaPage = 0; } - // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. void scrollTo(int, int); @@ -868,8 +867,6 @@ private: #if USE(ACCELERATED_COMPOSITING) OwnPtr<RenderLayerBacking> m_backing; #endif - - Page* m_scrollableAreaPage; // Page on which this is registered as a scrollable area. }; inline void RenderLayer::updateZOrderLists() diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp index b85b807f1..5c0ab779f 100644 --- a/Source/WebCore/rendering/RenderLayerCompositor.cpp +++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp @@ -50,6 +50,7 @@ #include "RenderReplica.h" #include "RenderVideo.h" #include "RenderView.h" +#include "ScrollbarTheme.h" #include "Settings.h" #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) @@ -971,11 +972,6 @@ void RenderLayerCompositor::frameViewDidChangeSize() if (m_layerForOverhangAreas) m_layerForOverhangAreas->setSize(frameView->frameRect().size()); #endif - -#if ENABLE(THREADED_SCROLLING) - if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) - scrollingCoordinator->syncFrameViewGeometry(frameView); -#endif } } @@ -1236,9 +1232,16 @@ void RenderLayerCompositor::updateRootLayerPosition() m_clipLayer->setSize(frameView->visibleContentRect(false /* exclude scrollbars */).size()); } -#if ENABLE(THREADED_SCROLLING) - if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) - scrollingCoordinator->syncFrameViewGeometry(m_renderView->frameView()); +#if ENABLE(RUBBER_BANDING) + if (m_contentShadowLayer) { + m_contentShadowLayer->setPosition(m_rootContentLayer->position()); + + FloatSize rootContentLayerSize = m_rootContentLayer->size(); + if (m_contentShadowLayer->size() != rootContentLayerSize) { + m_contentShadowLayer->setSize(rootContentLayerSize); + ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get()); + } + } #endif } @@ -1270,7 +1273,7 @@ bool RenderLayerCompositor::shouldPropagateCompositingToEnclosingFrame() const // Parent document content needs to be able to render on top of a composited frame, so correct behavior // is to have the parent document become composited too. However, this can cause problems on platforms that // use native views for frames (like Mac), so disable that behavior on those platforms for now. - HTMLFrameOwnerElement* ownerElement = enclosingFrameElement(); + HTMLFrameOwnerElement* ownerElement = m_renderView->document()->ownerElement(); RenderObject* renderer = ownerElement ? ownerElement->renderer() : 0; // If we are the top-level frame, don't propagate. @@ -1301,14 +1304,6 @@ bool RenderLayerCompositor::shouldPropagateCompositingToEnclosingFrame() const return false; } -HTMLFrameOwnerElement* RenderLayerCompositor::enclosingFrameElement() const -{ - if (HTMLFrameOwnerElement* ownerElement = m_renderView->document()->ownerElement()) - return (ownerElement->hasTagName(iframeTag) || ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(objectTag)) ? ownerElement : 0; - - return 0; -} - bool RenderLayerCompositor::needsToBeComposited(const RenderLayer* layer) const { if (!canBeComposited(layer)) @@ -1739,6 +1734,21 @@ bool RenderLayerCompositor::requiresOverhangAreasLayer() const return false; } + +bool RenderLayerCompositor::requiresContentShadowLayer() const +{ + // We don't want a layer if this is a subframe. + if (m_renderView->document()->ownerElement()) + return false; + +#if PLATFORM(MAC) && ENABLE(THREADED_SCROLLING) + // On Mac, we want a content shadow layer if we have a scrolling coordinator. + if (scrollingCoordinator()) + return true; +#endif + + return false; +} #endif void RenderLayerCompositor::updateOverflowControlsLayers() @@ -1753,6 +1763,8 @@ void RenderLayerCompositor::updateOverflowControlsLayers() m_layerForOverhangAreas->setDrawsContent(false); m_layerForOverhangAreas->setSize(m_renderView->frameView()->frameRect().size()); + ScrollbarTheme::theme()->setUpOverhangAreasLayerContents(m_layerForOverhangAreas.get()); + // We want the overhang areas layer to be positioned below the frame contents, // so insert it below the clip layer. m_overflowControlsHostLayer->addChildBelow(m_layerForOverhangAreas.get(), m_clipLayer.get()); @@ -1761,6 +1773,23 @@ void RenderLayerCompositor::updateOverflowControlsLayers() m_layerForOverhangAreas->removeFromParent(); m_layerForOverhangAreas = nullptr; } + + if (requiresContentShadowLayer()) { + if (!m_contentShadowLayer) { + m_contentShadowLayer = GraphicsLayer::create(this); +#ifndef NDEBUG + m_contentShadowLayer->setName("content shadow"); +#endif + m_contentShadowLayer->setSize(m_rootContentLayer->size()); + m_contentShadowLayer->setPosition(m_rootContentLayer->position()); + ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get()); + + m_scrollLayer->addChildBelow(m_contentShadowLayer.get(), m_rootContentLayer.get()); + } + } else if (m_contentShadowLayer) { + m_contentShadowLayer->removeFromParent(); + m_contentShadowLayer = nullptr; + } #endif if (requiresHorizontalScrollbarLayer()) { diff --git a/Source/WebCore/rendering/RenderLayerCompositor.h b/Source/WebCore/rendering/RenderLayerCompositor.h index 167d5a875..00518f3df 100644 --- a/Source/WebCore/rendering/RenderLayerCompositor.h +++ b/Source/WebCore/rendering/RenderLayerCompositor.h @@ -178,8 +178,6 @@ public: static bool allowsIndependentlyCompositedFrames(const FrameView*); bool shouldPropagateCompositingToEnclosingFrame() const; - HTMLFrameOwnerElement* enclosingFrameElement() const; - static RenderLayerCompositor* frameContentsCompositor(RenderPart*); // Return true if the layers changed. static bool parentFrameContentLayers(RenderPart*); @@ -293,6 +291,7 @@ private: bool requiresScrollCornerLayer() const; #if ENABLE(RUBBER_BANDING) bool requiresOverhangAreasLayer() const; + bool requiresContentShadowLayer() const; #endif #if ENABLE(THREADED_SCROLLING) @@ -339,6 +338,7 @@ private: OwnPtr<GraphicsLayer> m_layerForScrollCorner; #if ENABLE(RUBBER_BANDING) OwnPtr<GraphicsLayer> m_layerForOverhangAreas; + OwnPtr<GraphicsLayer> m_contentShadowLayer; #endif #if PROFILE_LAYER_REBUILD int m_rootLayerUpdateCount; diff --git a/Source/WebCore/rendering/RenderListBox.cpp b/Source/WebCore/rendering/RenderListBox.cpp index 1c001eddd..d47a1801e 100644 --- a/Source/WebCore/rendering/RenderListBox.cpp +++ b/Source/WebCore/rendering/RenderListBox.cpp @@ -92,17 +92,17 @@ RenderListBox::RenderListBox(Element* element) ASSERT(element); ASSERT(element->isHTMLElement()); ASSERT(element->hasTagName(HTMLNames::selectTag)); - if (Page* page = frame()->page()) { - m_page = page; - m_page->addScrollableArea(this); - } + + if (FrameView* frameView = frame()->view()) + frameView->addScrollableArea(this); } RenderListBox::~RenderListBox() { setHasVerticalScrollbar(false); - if (m_page) - m_page->removeScrollableArea(this); + + if (FrameView* frameView = frame()->view()) + frameView->removeScrollableArea(this); } void RenderListBox::updateFromElement() @@ -651,7 +651,7 @@ LayoutUnit RenderListBox::scrollWidth() const int RenderListBox::scrollHeight() const { - return max(clientHeight(), listHeight()); + return max(pixelSnappedClientHeight(), listHeight()); } int RenderListBox::scrollLeft() const @@ -821,6 +821,11 @@ ScrollableArea* RenderListBox::enclosingScrollableArea() const return 0; } +IntRect RenderListBox::scrollableAreaBoundingBox() const +{ + return absoluteBoundingBoxRect(); +} + PassRefPtr<Scrollbar> RenderListBox::createScrollbar() { RefPtr<Scrollbar> widget; diff --git a/Source/WebCore/rendering/RenderListBox.h b/Source/WebCore/rendering/RenderListBox.h index 4d8b35faf..e63e00386 100644 --- a/Source/WebCore/rendering/RenderListBox.h +++ b/Source/WebCore/rendering/RenderListBox.h @@ -120,8 +120,7 @@ private: virtual bool isOnActivePage() const; virtual ScrollableArea* enclosingScrollableArea() const; - - virtual void disconnectFromPage() { m_page = 0; } + virtual IntRect scrollableAreaBoundingBox() const OVERRIDE; // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. void scrollTo(int newOffset); @@ -147,8 +146,6 @@ private: int m_indexOffset; RefPtr<Scrollbar> m_vBar; - - Page* m_page; }; inline RenderListBox* toRenderListBox(RenderObject* object) diff --git a/Source/WebCore/rendering/RenderListMarker.cpp b/Source/WebCore/rendering/RenderListMarker.cpp index 13dad9814..e7f85283a 100644 --- a/Source/WebCore/rendering/RenderListMarker.cpp +++ b/Source/WebCore/rendering/RenderListMarker.cpp @@ -1534,14 +1534,14 @@ void RenderListMarker::updateMargins() style()->setMarginEnd(Length(marginEnd, Fixed)); } -int RenderListMarker::lineHeight(bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +LayoutUnit RenderListMarker::lineHeight(bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { if (!isImage()) return m_listItem->lineHeight(firstLine, direction, PositionOfInteriorLineBoxes); return RenderBox::lineHeight(firstLine, direction, linePositionMode); } -int RenderListMarker::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +LayoutUnit 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 00a2c5a12..50e666dbf 100644 --- a/Source/WebCore/rendering/RenderListMarker.h +++ b/Source/WebCore/rendering/RenderListMarker.h @@ -58,8 +58,8 @@ private: virtual InlineBox* createInlineBox(); - virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; - virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; bool isImage() const; bool isText() const { return !isImage(); } diff --git a/Source/WebCore/rendering/RenderMenuList.h b/Source/WebCore/rendering/RenderMenuList.h index d06a9c919..b6f44364f 100644 --- a/Source/WebCore/rendering/RenderMenuList.h +++ b/Source/WebCore/rendering/RenderMenuList.h @@ -91,8 +91,8 @@ private: virtual PopupMenuStyle menuStyle() const OVERRIDE; virtual int clientInsetLeft() const OVERRIDE; virtual int clientInsetRight() const OVERRIDE; - virtual int clientPaddingLeft() const OVERRIDE; - virtual int clientPaddingRight() const OVERRIDE; + virtual LayoutUnit clientPaddingLeft() const OVERRIDE; + virtual LayoutUnit clientPaddingRight() const OVERRIDE; virtual int listSize() const OVERRIDE; virtual int selectedIndex() const OVERRIDE; virtual void popupDidHide() OVERRIDE; diff --git a/Source/WebCore/rendering/RenderRegion.cpp b/Source/WebCore/rendering/RenderRegion.cpp index b1abd83bd..8df1ced4c 100644 --- a/Source/WebCore/rendering/RenderRegion.cpp +++ b/Source/WebCore/rendering/RenderRegion.cpp @@ -13,7 +13,7 @@ * disclaimer in the documentation and/or other materials * provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE @@ -47,9 +47,6 @@ RenderRegion::RenderRegion(Node* node, RenderFlowThread* flowThread) , m_parentFlowThread(0) , m_isValid(false) , m_hasCustomRegionStyle(false) -#ifndef NDEBUG - , m_insideRegionPaint(false) -#endif { } @@ -145,17 +142,9 @@ void RenderRegion::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintO page->addRelevantRepaintedObject(this, paintInfo.rect); } -#ifndef NDEBUG - m_insideRegionPaint = true; -#endif - setRegionBoxesRegionStyle(); m_flowThread->paintIntoRegion(paintInfo, this, LayoutPoint(paintOffset.x() + borderLeft() + paddingLeft(), paintOffset.y() + borderTop() + paddingTop())); restoreRegionBoxesOriginalStyle(); - -#ifndef NDEBUG - m_insideRegionPaint = false; -#endif } // Hit Testing diff --git a/Source/WebCore/rendering/RenderRegion.h b/Source/WebCore/rendering/RenderRegion.h index 913c42e09..6bdcdf672 100644 --- a/Source/WebCore/rendering/RenderRegion.h +++ b/Source/WebCore/rendering/RenderRegion.h @@ -109,10 +109,6 @@ private: bool m_isValid; bool m_hasCustomRegionStyle; - -#ifndef NDEBUG - bool m_insideRegionPaint; -#endif }; inline RenderRegion* toRenderRegion(RenderObject* object) diff --git a/Source/WebCore/rendering/RenderSlider.cpp b/Source/WebCore/rendering/RenderSlider.cpp index 07395f98b..e1d6ccc52 100644 --- a/Source/WebCore/rendering/RenderSlider.cpp +++ b/Source/WebCore/rendering/RenderSlider.cpp @@ -59,7 +59,7 @@ RenderSlider::~RenderSlider() { } -int RenderSlider::baselinePosition(FontBaseline, bool /*firstLine*/, LineDirectionMode, LinePositionMode) const +LayoutUnit 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 c1261bb26..5709e2d13 100644 --- a/Source/WebCore/rendering/RenderSlider.h +++ b/Source/WebCore/rendering/RenderSlider.h @@ -40,7 +40,7 @@ namespace WebCore { virtual const char* renderName() const { return "RenderSlider"; } virtual bool isSlider() const { return true; } - virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual LayoutUnit 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/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp index 1557c3f16..fd55a6321 100644 --- a/Source/WebCore/rendering/RenderTableSection.cpp +++ b/Source/WebCore/rendering/RenderTableSection.cpp @@ -277,7 +277,7 @@ void RenderTableSection::addCell(RenderTableCell* cell, RenderTableRow* row) void RenderTableSection::setCellLogicalWidths() { - Vector<LayoutUnit>& columnPos = table()->columnPositions(); + Vector<int>& columnPos = table()->columnPositions(); LayoutStateMaintainer statePusher(view()); @@ -296,8 +296,8 @@ void RenderTableSection::setCellLogicalWidths() cspan -= table()->columns()[endCol].span; endCol++; } - LayoutUnit w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing(); - LayoutUnit oldLogicalWidth = cell->logicalWidth(); + int w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing(); + int oldLogicalWidth = cell->logicalWidth(); if (w != oldLogicalWidth) { cell->setNeedsLayout(true); if (!table()->selfNeedsLayout() && cell->checkForRepaintDuringLayout()) { @@ -316,7 +316,7 @@ void RenderTableSection::setCellLogicalWidths() statePusher.pop(); // only pops if we pushed } -LayoutUnit RenderTableSection::calcRowLogicalHeight() +int RenderTableSection::calcRowLogicalHeight() { #ifndef NDEBUG setNeedsLayoutIsForbidden(true); @@ -326,7 +326,7 @@ LayoutUnit RenderTableSection::calcRowLogicalHeight() RenderTableCell* cell; - LayoutUnit spacing = table()->vBorderSpacing(); + int spacing = table()->vBorderSpacing(); LayoutStateMaintainer statePusher(view()); @@ -337,9 +337,9 @@ LayoutUnit RenderTableSection::calcRowLogicalHeight() m_rowPos[r + 1] = 0; m_grid[r].baseline = 0; LayoutUnit baseline = 0; - LayoutUnit bdesc = 0; - LayoutUnit ch = m_grid[r].logicalHeight.calcMinValue(0); - LayoutUnit pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 0); + int bdesc = 0; + int ch = m_grid[r].logicalHeight.calcMinValue(0); + int pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 0); m_rowPos[r + 1] = max(m_rowPos[r + 1], pos); @@ -370,7 +370,7 @@ LayoutUnit RenderTableSection::calcRowLogicalHeight() cell->layoutIfNeeded(); } - LayoutUnit adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter()); + int adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter()); ch = cell->style()->logicalHeight().calcValue(0); if (document()->inQuirksMode() || cell->style()->boxSizing() == BORDER_BOX) { @@ -379,8 +379,8 @@ LayoutUnit RenderTableSection::calcRowLogicalHeight() } else { // In strict mode, box-sizing: content-box do the right // thing and actually add in the border and padding. - LayoutUnit adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore(); - LayoutUnit adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter(); + int adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore(); + int adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter(); ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore() + cell->borderAfter(); } ch = max(ch, adjustedLogicalHeight); @@ -392,9 +392,9 @@ LayoutUnit RenderTableSection::calcRowLogicalHeight() // find out the baseline EVerticalAlign va = cell->style()->verticalAlign(); if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) { - LayoutUnit b = cell->cellBaselinePosition(); + int b = cell->cellBaselinePosition(); if (b > cell->borderBefore() + cell->paddingBefore()) { - baseline = max(baseline, b - cell->intrinsicPaddingBefore()); + baseline = max<LayoutUnit>(baseline, b - cell->intrinsicPaddingBefore()); bdesc = max(bdesc, m_rowPos[indx] + ch - (b - cell->intrinsicPaddingBefore())); } } @@ -436,7 +436,7 @@ void RenderTableSection::layout() setNeedsLayout(false); } -LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) +int RenderTableSection::layoutRows(int toAdd) { #ifndef NDEBUG setNeedsLayoutIsForbidden(true); @@ -444,7 +444,7 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) ASSERT(!needsLayout()); - LayoutUnit rHeight; + int rHeight; unsigned rindx; unsigned totalRows = m_grid.size(); @@ -455,9 +455,9 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) m_forceSlowPaintPathWithOverflowingCell = false; if (toAdd && totalRows && (m_rowPos[totalRows] || !nextSibling())) { - LayoutUnit totalHeight = m_rowPos[totalRows] + toAdd; + int totalHeight = m_rowPos[totalRows] + toAdd; - LayoutUnit dh = toAdd; + int dh = toAdd; int totalPercent = 0; int numAuto = 0; for (unsigned r = 0; r < totalRows; r++) { @@ -468,15 +468,15 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) } if (totalPercent) { // try to satisfy percent - LayoutUnit add = 0; + int add = 0; totalPercent = min(totalPercent, 100); - LayoutUnit rh = m_rowPos[1] - m_rowPos[0]; + int rh = m_rowPos[1] - m_rowPos[0]; for (unsigned r = 0; r < totalRows; r++) { if (totalPercent > 0 && m_grid[r].logicalHeight.isPercent()) { - LayoutUnit toAdd = min<LayoutUnit>(dh, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh); + int toAdd = min<int>(dh, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh); // If toAdd is negative, then we don't want to shrink the row (this bug // affected Outlook Web Access). - toAdd = max<LayoutUnit>(0, toAdd); + toAdd = max(0, toAdd); add += toAdd; dh -= toAdd; totalPercent -= m_grid[r].logicalHeight.percent(); @@ -489,10 +489,10 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) } if (numAuto) { // distribute over variable cols - LayoutUnit add = 0; + int add = 0; for (unsigned r = 0; r < totalRows; r++) { if (numAuto > 0 && m_grid[r].logicalHeight.isAuto()) { - LayoutUnit toAdd = dh / numAuto; + int toAdd = dh / numAuto; add += toAdd; dh -= toAdd; numAuto--; @@ -502,9 +502,9 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) } if (dh > 0 && m_rowPos[totalRows]) { // if some left overs, distribute equally. - LayoutUnit tot = m_rowPos[totalRows]; - LayoutUnit add = 0; - LayoutUnit prev = m_rowPos[0]; + int tot = m_rowPos[totalRows]; + int add = 0; + int prev = m_rowPos[0]; for (unsigned r = 0; r < totalRows; r++) { // weight with the original height add += dh * (m_rowPos[r + 1] - prev) / tot; @@ -514,8 +514,8 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) } } - LayoutUnit hspacing = table()->hBorderSpacing(); - LayoutUnit vspacing = table()->vBorderSpacing(); + int hspacing = table()->hBorderSpacing(); + int vspacing = table()->vBorderSpacing(); unsigned nEffCols = table()->numEffCols(); LayoutStateMaintainer statePusher(view(), this, LayoutSize(x(), y()), style()->isFlippedBlocksWritingMode()); @@ -603,18 +603,18 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) } } - LayoutUnit oldIntrinsicPaddingBefore = cell->intrinsicPaddingBefore(); - LayoutUnit oldIntrinsicPaddingAfter = cell->intrinsicPaddingAfter(); - LayoutUnit logicalHeightWithoutIntrinsicPadding = cell->logicalHeight() - oldIntrinsicPaddingBefore - oldIntrinsicPaddingAfter; + int oldIntrinsicPaddingBefore = cell->intrinsicPaddingBefore(); + int oldIntrinsicPaddingAfter = cell->intrinsicPaddingAfter(); + int logicalHeightWithoutIntrinsicPadding = cell->logicalHeight() - oldIntrinsicPaddingBefore - oldIntrinsicPaddingAfter; - LayoutUnit intrinsicPaddingBefore = 0; + int intrinsicPaddingBefore = 0; switch (cell->style()->verticalAlign()) { case SUB: case SUPER: case TEXT_TOP: case TEXT_BOTTOM: case BASELINE: { - LayoutUnit b = cell->cellBaselinePosition(); + int b = cell->cellBaselinePosition(); if (b > cell->borderBefore() + cell->paddingBefore()) intrinsicPaddingBefore = getBaseline(r) - (b - oldIntrinsicPaddingBefore); break; @@ -631,7 +631,7 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) break; } - LayoutUnit intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore; + int intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore; cell->setIntrinsicPaddingBefore(intrinsicPaddingBefore); cell->setIntrinsicPaddingAfter(intrinsicPaddingAfter); @@ -715,7 +715,7 @@ LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd) return height(); } -LayoutUnit RenderTableSection::calcOuterBorderBefore() const +int RenderTableSection::calcOuterBorderBefore() const { unsigned totalCols = table()->numEffCols(); if (!m_grid.size() || !totalCols) @@ -766,7 +766,7 @@ LayoutUnit RenderTableSection::calcOuterBorderBefore() const return borderWidth / 2; } -LayoutUnit RenderTableSection::calcOuterBorderAfter() const +int RenderTableSection::calcOuterBorderAfter() const { unsigned totalCols = table()->numEffCols(); if (!m_grid.size() || !totalCols) @@ -817,7 +817,7 @@ LayoutUnit RenderTableSection::calcOuterBorderAfter() const return (borderWidth + 1) / 2; } -LayoutUnit RenderTableSection::calcOuterBorderStart() const +int RenderTableSection::calcOuterBorderStart() const { unsigned totalCols = table()->numEffCols(); if (!m_grid.size() || !totalCols) @@ -861,7 +861,7 @@ LayoutUnit RenderTableSection::calcOuterBorderStart() const return (borderWidth + (table()->style()->isLeftToRightDirection() ? 0 : 1)) / 2; } -LayoutUnit RenderTableSection::calcOuterBorderEnd() const +int RenderTableSection::calcOuterBorderEnd() const { unsigned totalCols = table()->numEffCols(); if (!m_grid.size() || !totalCols) @@ -1055,7 +1055,7 @@ void RenderTableSection::paintObject(PaintInfo& paintInfo, const LayoutPoint& pa // FIXME: Implement RTL. if (!m_forceSlowPaintPathWithOverflowingCell && style()->isLeftToRightDirection()) { LayoutUnit start = (style()->isHorizontalWritingMode() ? localRepaintRect.x() : localRepaintRect.y()) - os; - Vector<LayoutUnit>& columnPos = table()->columnPositions(); + Vector<int>& columnPos = table()->columnPositions(); startcol = std::lower_bound(columnPos.begin(), columnPos.end(), start) - columnPos.begin(); if ((startcol == columnPos.size()) || (startcol > 0 && (columnPos[startcol] > start))) --startcol; @@ -1313,7 +1313,7 @@ bool RenderTableSection::nodeAtPoint(const HitTestRequest& request, HitTestResul // Now set hitRow to the index of the hit row, or 0. unsigned hitRow = nextRow > 0 ? nextRow - 1 : 0; - Vector<LayoutUnit>& columnPos = table()->columnPositions(); + Vector<int>& columnPos = table()->columnPositions(); LayoutUnit offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y(); if (!style()->isLeftToRightDirection()) offsetInRowDirection = columnPos[columnPos.size() - 1] - offsetInRowDirection; diff --git a/Source/WebCore/rendering/RenderTableSection.h b/Source/WebCore/rendering/RenderTableSection.h index 7517a0ac0..d12c87041 100644 --- a/Source/WebCore/rendering/RenderTableSection.h +++ b/Source/WebCore/rendering/RenderTableSection.h @@ -55,8 +55,8 @@ public: void addCell(RenderTableCell*, RenderTableRow* row); void setCellLogicalWidths(); - LayoutUnit calcRowLogicalHeight(); - LayoutUnit layoutRows(LayoutUnit logicalHeight); + int calcRowLogicalHeight(); + int layoutRows(int logicalHeight); RenderTable* table() const { return toRenderTable(parent()); } @@ -87,7 +87,7 @@ public: struct RowStruct { RowStruct() : rowRenderer(0) - , baseline(0) + , baseline() { } @@ -108,16 +108,16 @@ public: void appendColumn(unsigned pos); void splitColumn(unsigned pos, unsigned first); - LayoutUnit calcOuterBorderBefore() const; - LayoutUnit calcOuterBorderAfter() const; - LayoutUnit calcOuterBorderStart() const; - LayoutUnit calcOuterBorderEnd() const; + int calcOuterBorderBefore() const; + int calcOuterBorderAfter() const; + int calcOuterBorderStart() const; + int calcOuterBorderEnd() const; void recalcOuterBorder(); - LayoutUnit outerBorderBefore() const { return m_outerBorderBefore; } - LayoutUnit outerBorderAfter() const { return m_outerBorderAfter; } - LayoutUnit outerBorderStart() const { return m_outerBorderStart; } - LayoutUnit outerBorderEnd() const { return m_outerBorderEnd; } + int outerBorderBefore() const { return m_outerBorderBefore; } + int outerBorderAfter() const { return m_outerBorderAfter; } + int outerBorderStart() const { return m_outerBorderStart; } + int outerBorderEnd() const { return m_outerBorderEnd; } unsigned numRows() const { return m_grid.size(); } unsigned numColumns() const; @@ -173,16 +173,16 @@ private: RenderObjectChildList m_children; Vector<RowStruct> m_grid; - Vector<LayoutUnit> m_rowPos; + Vector<int> m_rowPos; // the current insertion position unsigned m_cCol; unsigned m_cRow; - LayoutUnit m_outerBorderStart; - LayoutUnit m_outerBorderEnd; - LayoutUnit m_outerBorderBefore; - LayoutUnit m_outerBorderAfter; + int m_outerBorderStart; + int m_outerBorderEnd; + int m_outerBorderBefore; + int m_outerBorderAfter; bool m_needsCellRecalc; diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp index 912ee0c33..a86850ce4 100644 --- a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp +++ b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -638,9 +638,9 @@ int RenderTextControlSingleLine::clientInsetRight() const return height() / 2; } -int RenderTextControlSingleLine::clientPaddingLeft() const +LayoutUnit RenderTextControlSingleLine::clientPaddingLeft() const { - int padding = paddingLeft(); + LayoutUnit padding = paddingLeft(); HTMLElement* resultsButton = resultsButtonElement(); if (RenderBox* resultsRenderer = resultsButton ? resultsButton->renderBox() : 0) @@ -649,9 +649,9 @@ int RenderTextControlSingleLine::clientPaddingLeft() const return padding; } -int RenderTextControlSingleLine::clientPaddingRight() const +LayoutUnit RenderTextControlSingleLine::clientPaddingRight() const { - int padding = paddingRight(); + LayoutUnit padding = paddingRight(); HTMLElement* cancelButton = cancelButtonElement(); if (RenderBox* cancelRenderer = cancelButton ? cancelButton->renderBox() : 0) diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.h b/Source/WebCore/rendering/RenderTextControlSingleLine.h index 2175c8ae7..45d19ee99 100644 --- a/Source/WebCore/rendering/RenderTextControlSingleLine.h +++ b/Source/WebCore/rendering/RenderTextControlSingleLine.h @@ -103,8 +103,8 @@ private: virtual PopupMenuStyle menuStyle() const OVERRIDE; virtual int clientInsetLeft() const OVERRIDE; virtual int clientInsetRight() const OVERRIDE; - virtual int clientPaddingLeft() const OVERRIDE; - virtual int clientPaddingRight() const OVERRIDE; + virtual LayoutUnit clientPaddingLeft() const OVERRIDE; + virtual LayoutUnit clientPaddingRight() const OVERRIDE; virtual int listSize() const OVERRIDE; virtual int selectedIndex() const OVERRIDE; virtual void popupDidHide() OVERRIDE; diff --git a/Source/WebCore/rendering/RenderTheme.cpp b/Source/WebCore/rendering/RenderTheme.cpp index 6ea025c5d..d93a27e25 100644 --- a/Source/WebCore/rendering/RenderTheme.cpp +++ b/Source/WebCore/rendering/RenderTheme.cpp @@ -242,7 +242,7 @@ void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El } } -bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) +bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const LayoutRect& r) { // If painting is disabled, but we aren't updating control tints, then just bail. // If we are updating control tints, just schedule a repaint if the theme supports tinting @@ -500,13 +500,13 @@ String RenderTheme::formatMediaControlsRemainingTime(float currentTime, float du return formatMediaControlsTime(currentTime - duration); } -IntPoint RenderTheme::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const IntSize& size) const +LayoutPoint RenderTheme::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const LayoutSize& size) const { - int y = -size.height(); - FloatPoint absPoint = muteButtonBox->localToAbsolute(FloatPoint(muteButtonBox->offsetLeft(), y), true, true); + LayoutUnit y = -size.height(); + FloatPoint absPoint = muteButtonBox->localToAbsolute(FloatPoint(muteButtonBox->pixelSnappedOffsetLeft(), y), true, true); if (absPoint.y() < 0) y = muteButtonBox->height(); - return IntPoint(0, y); + return LayoutPoint(0, y); } #endif @@ -612,7 +612,7 @@ Color RenderTheme::platformInactiveListBoxSelectionForegroundColor() const return platformInactiveSelectionForegroundColor(); } -int RenderTheme::baselinePosition(const RenderObject* o) const +LayoutUnit RenderTheme::baselinePosition(const RenderObject* o) const { if (!o->isBox()) return 0; @@ -662,7 +662,7 @@ bool RenderTheme::isControlStyled(const RenderStyle* style, const BorderData& bo } } -void RenderTheme::adjustRepaintRect(const RenderObject* o, IntRect& r) +void RenderTheme::adjustRepaintRect(const RenderObject* o, LayoutRect& r) { #if USE(NEW_THEME) m_theme->inflateControlPaintRect(o->style()->appearance(), controlStatesForRenderer(o), r, o->style()->effectiveZoom()); @@ -919,7 +919,7 @@ void RenderTheme::adjustMeterStyle(CSSStyleSelector*, RenderStyle* style, Elemen style->setBoxShadow(nullptr); } -IntSize RenderTheme::meterSizeForBounds(const RenderMeter*, const IntRect& bounds) const +LayoutSize RenderTheme::meterSizeForBounds(const RenderMeter*, const LayoutRect& bounds) const { return bounds.size(); } diff --git a/Source/WebCore/rendering/RenderTheme.h b/Source/WebCore/rendering/RenderTheme.h index 19273eb02..c243b78a5 100644 --- a/Source/WebCore/rendering/RenderTheme.h +++ b/Source/WebCore/rendering/RenderTheme.h @@ -97,7 +97,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 int baselinePosition(const RenderObject*) const; + virtual LayoutUnit 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). @@ -114,7 +114,7 @@ public: // Some controls may spill out of their containers (e.g., the check on an OS X checkbox). When these controls repaint, // the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control. - virtual void adjustRepaintRect(const RenderObject*, IntRect&); + virtual void adjustRepaintRect(const RenderObject*, LayoutRect&); // This method is called whenever a relevant state changes on a particular themed object, e.g., the mouse becomes pressed // or a control becomes disabled. @@ -176,7 +176,7 @@ public: virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return RegularScrollbar; } // Method for painting the caps lock indicator - virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&) { return 0; }; + virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const LayoutRect&) { return 0; }; #if ENABLE(PROGRESS_TAG) // Returns the repeat interval of the animation for the progress bar. @@ -198,11 +198,11 @@ public: virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const; // Returns the media volume slider container's offset from the mute button. - virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const; + virtual LayoutPoint volumeSliderOffsetFromMuteButton(RenderBox*, const LayoutSize&) const; #endif #if ENABLE(METER_TAG) - virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const; + virtual LayoutSize meterSizeForBounds(const RenderMeter*, const LayoutRect&) const; virtual bool supportsMeter(ControlPart) const; #endif diff --git a/Source/WebCore/rendering/RenderThemeChromiumMac.h b/Source/WebCore/rendering/RenderThemeChromiumMac.h index 8d4e52e56..232e0f66c 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumMac.h +++ b/Source/WebCore/rendering/RenderThemeChromiumMac.h @@ -49,7 +49,7 @@ protected: virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); - virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const; + virtual LayoutPoint volumeSliderOffsetFromMuteButton(RenderBox*, const LayoutSize&) const; virtual bool usesMediaControlStatusDisplay() { return false; } virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const { return true; } #endif diff --git a/Source/WebCore/rendering/RenderThemeChromiumMac.mm b/Source/WebCore/rendering/RenderThemeChromiumMac.mm index 5d4c9539e..82f2de1c3 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumMac.mm +++ b/Source/WebCore/rendering/RenderThemeChromiumMac.mm @@ -211,7 +211,7 @@ bool RenderThemeChromiumMac::paintMediaSliderThumb(RenderObject* object, const P return RenderMediaControlsChromium::paintMediaControlsPart(MediaSliderThumb, object, paintInfo, rect); } -IntPoint RenderThemeChromiumMac::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const IntSize& size) const +LayoutPoint RenderThemeChromiumMac::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const LayoutSize& size) const { return RenderTheme::volumeSliderOffsetFromMuteButton(muteButtonBox, size); } diff --git a/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp b/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp index 030ac35ae..5715b6684 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp +++ b/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp @@ -260,10 +260,10 @@ void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelecto style->setHeight(Length(cancelButtonSize, Fixed)); } -IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const +LayoutRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const { // Compute an offset between the part renderer and the input renderer. - IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer)); + LayoutSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer)); // Move the rect into partRenderer's coords. partRect.move(offsetFromInputRenderer); // Account for the local drawing offset. @@ -279,17 +279,17 @@ bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelB if (!input->renderer()->isBox()) return false; RenderBox* inputRenderBox = toRenderBox(input->renderer()); - IntRect inputContentBox = inputRenderBox->contentBoxRect(); + LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); // Make sure the scaled button stays square and will fit in its parent's box. - int cancelButtonSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height())); + LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), r.height())); // Calculate cancel button's coordinates relative to the input element. // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will // be one pixel closer to the bottom of the field. This tends to look better with the text. - IntRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(), - inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2, - cancelButtonSize, cancelButtonSize); - IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r); + LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(), + inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2, + cancelButtonSize, cancelButtonSize); + LayoutRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r); static Image* cancelImage = Image::loadPlatformResource("searchCancel").leakRef(); static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").leakRef(); @@ -322,17 +322,17 @@ bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* ma if (!input->renderer()->isBox()) return false; RenderBox* inputRenderBox = toRenderBox(input->renderer()); - IntRect inputContentBox = inputRenderBox->contentBoxRect(); + LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); // Make sure the scaled decoration stays square and will fit in its parent's box. - int magnifierSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height())); + LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), r.height())); // Calculate decoration's coordinates relative to the input element. // Center the decoration vertically. Round up though, so if it has to be one pixel off-center, it will // be one pixel closer to the bottom of the field. This tends to look better with the text. - IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(), - inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2, - magnifierSize, magnifierSize); - IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r); + LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(), + inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2, + magnifierSize, magnifierSize); + LayoutRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r); static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").leakRef(); paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect); @@ -357,15 +357,15 @@ bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* magnif if (!input->renderer()->isBox()) return false; RenderBox* inputRenderBox = toRenderBox(input->renderer()); - IntRect inputContentBox = inputRenderBox->contentBoxRect(); + LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); // Make sure the scaled decoration will fit in its parent's box. - int magnifierHeight = std::min(inputContentBox.height(), r.height()); - int magnifierWidth = std::min(inputContentBox.width(), static_cast<int>(magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize)); - IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(), - inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2, - magnifierWidth, magnifierHeight); - IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r); + LayoutUnit magnifierHeight = std::min<LayoutUnit>(inputContentBox.height(), r.height()); + LayoutUnit magnifierWidth = std::min<LayoutUnit>(inputContentBox.width(), magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize); + LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(), + inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2, + magnifierWidth, magnifierHeight); + LayoutRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r); static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierResults").leakRef(); paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect); diff --git a/Source/WebCore/rendering/RenderThemeChromiumSkia.h b/Source/WebCore/rendering/RenderThemeChromiumSkia.h index eed810b68..05b48be3b 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumSkia.h +++ b/Source/WebCore/rendering/RenderThemeChromiumSkia.h @@ -157,7 +157,7 @@ private: int menuListInternalPadding(RenderStyle*, int paddingType) const; bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*); - IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const; + LayoutRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const; }; } // namespace WebCore diff --git a/Source/WebCore/rendering/RenderThemeMac.h b/Source/WebCore/rendering/RenderThemeMac.h index 6451d3cf5..dc1af04d0 100644 --- a/Source/WebCore/rendering/RenderThemeMac.h +++ b/Source/WebCore/rendering/RenderThemeMac.h @@ -45,7 +45,7 @@ public: // A general method asking if any control tinting is supported at all. virtual bool supportsControlTints() const { return true; } - virtual void adjustRepaintRect(const RenderObject*, IntRect&); + virtual void adjustRepaintRect(const RenderObject*, LayoutRect&); virtual bool isControlStyled(const RenderStyle*, const BorderData&, const FillLayer&, const Color& backgroundColor) const; @@ -74,12 +74,12 @@ public: virtual int popupInternalPaddingTop(RenderStyle*) const; virtual int popupInternalPaddingBottom(RenderStyle*) const; - virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const LayoutRect&); virtual bool popsMenuByArrowKeys() const OVERRIDE { return true; } #if ENABLE(METER_TAG) - virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const; + virtual LayoutSize meterSizeForBounds(const RenderMeter*, const LayoutRect&) const; virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&); virtual bool supportsMeter(ControlPart) const; #endif @@ -169,7 +169,7 @@ protected: virtual bool usesMediaControlStatusDisplay(); virtual bool usesMediaControlVolumeSlider() const; virtual void adjustMediaSliderThumbSize(RenderStyle*) const; - virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const; + virtual LayoutPoint volumeSliderOffsetFromMuteButton(RenderBox*, const LayoutSize&) const; #endif virtual bool shouldShowPlaceholderWhenFocused() const; @@ -177,14 +177,14 @@ protected: private: virtual String fileListNameForWidth(const Vector<String>& filenames, const Font&, int width, bool multipleFilesAllowed); - IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const; + LayoutRect inflateRect(const LayoutRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const; FloatRect convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const; // Get the control size based off the font. Used by some of the controls (like buttons). NSControlSize controlSizeForFont(RenderStyle*) const; NSControlSize controlSizeForSystemFont(RenderStyle*) const; - void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f); + void setControlSize(NSCell*, const IntSize* sizes, const LayoutSize& minSize, float zoomLevel = 1.0f); void setSizeFromFont(RenderStyle*, const IntSize* sizes) const; IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const; IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const; @@ -199,7 +199,7 @@ private: // Helpers for adjusting appearance and for painting - void setPopupButtonCellState(const RenderObject*, const IntRect&); + void setPopupButtonCellState(const RenderObject*, const LayoutRect&); const IntSize* popupButtonSizes() const; const int* popupButtonMargins() const; const int* popupButtonPadding(NSControlSize) const; diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm index 48a04cf94..e405f6ceb 100644 --- a/Source/WebCore/rendering/RenderThemeMac.mm +++ b/Source/WebCore/rendering/RenderThemeMac.mm @@ -500,7 +500,7 @@ bool RenderThemeMac::isControlStyled(const RenderStyle* style, const BorderData& return RenderTheme::isControlStyled(style, border, background, backgroundColor); } -void RenderThemeMac::adjustRepaintRect(const RenderObject* o, IntRect& r) +void RenderThemeMac::adjustRepaintRect(const RenderObject* o, LayoutRect& r) { ControlPart part = o->style()->appearance(); @@ -531,13 +531,13 @@ void RenderThemeMac::adjustRepaintRect(const RenderObject* o, IntRect& r) } } -IntRect RenderThemeMac::inflateRect(const IntRect& r, const IntSize& size, const int* margins, float zoomLevel) const +LayoutRect RenderThemeMac::inflateRect(const LayoutRect& r, const IntSize& size, const int* margins, float zoomLevel) const { // Only do the inflation if the available width/height are too small. Otherwise try to // fit the glow/check space into the available box's width/height. - int widthDelta = r.width() - (size.width() + margins[leftMargin] * zoomLevel + margins[rightMargin] * zoomLevel); - int heightDelta = r.height() - (size.height() + margins[topMargin] * zoomLevel + margins[bottomMargin] * zoomLevel); - IntRect result(r); + LayoutUnit widthDelta = r.width() - (size.width() + margins[leftMargin] * zoomLevel + margins[rightMargin] * zoomLevel); + LayoutUnit heightDelta = r.height() - (size.height() + margins[topMargin] * zoomLevel + margins[bottomMargin] * zoomLevel); + LayoutRect result(r); if (widthDelta < 0) { result.setX(result.x() - margins[leftMargin] * zoomLevel); result.setWidth(result.width() - widthDelta); @@ -639,14 +639,14 @@ NSControlSize RenderThemeMac::controlSizeForFont(RenderStyle* style) const return NSMiniControlSize; } -void RenderThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minSize, float zoomLevel) +void RenderThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const LayoutSize& minSize, float zoomLevel) { NSControlSize size; - if (minSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomLevel) && - minSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomLevel)) + if (minSize.width() >= static_cast<LayoutUnit>(sizes[NSRegularControlSize].width() * zoomLevel) && + minSize.height() >= static_cast<LayoutUnit>(sizes[NSRegularControlSize].height() * zoomLevel)) size = NSRegularControlSize; - else if (minSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomLevel) && - minSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomLevel)) + else if (minSize.width() >= static_cast<LayoutUnit>(sizes[NSSmallControlSize].width() * zoomLevel) && + minSize.height() >= static_cast<LayoutUnit>(sizes[NSSmallControlSize].height() * zoomLevel)) size = NSSmallControlSize; else size = NSMiniControlSize; @@ -729,7 +729,7 @@ void RenderThemeMac::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Eleme { } -bool RenderThemeMac::paintCapsLockIndicator(RenderObject*, const PaintInfo& paintInfo, const IntRect& r) +bool RenderThemeMac::paintCapsLockIndicator(RenderObject*, const PaintInfo& paintInfo, const LayoutRect& r) { if (paintInfo.context->paintingDisabled()) return true; @@ -792,7 +792,7 @@ bool RenderThemeMac::paintMenuList(RenderObject* o, const PaintInfo& paintInfo, size.setWidth(r.width()); // Now inflate it to account for the shadow. - IntRect inflatedRect = r; + LayoutRect inflatedRect = r; if (r.width() >= minimumMenuListSize(o->style())) inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins(), zoomLevel); @@ -817,16 +817,16 @@ bool RenderThemeMac::paintMenuList(RenderObject* o, const PaintInfo& paintInfo, #if ENABLE(METER_TAG) -IntSize RenderThemeMac::meterSizeForBounds(const RenderMeter* renderMeter, const IntRect& bounds) const +LayoutSize RenderThemeMac::meterSizeForBounds(const RenderMeter* renderMeter, const LayoutRect& bounds) const { if (NoControlPart == renderMeter->style()->appearance()) return bounds.size(); NSLevelIndicatorCell* cell = levelIndicatorFor(renderMeter); // Makes enough room for cell's intrinsic size. - NSSize cellSize = [cell cellSizeForBounds:IntRect(IntPoint(), bounds.size())]; - return IntSize(bounds.width() < cellSize.width ? cellSize.width : bounds.width(), - bounds.height() < cellSize.height ? cellSize.height : bounds.height()); + NSSize cellSize = [cell cellSizeForBounds:LayoutRect(LayoutPoint(), bounds.size())]; + return LayoutSize(bounds.width() < cellSize.width ? cellSize.width : bounds.width(), + bounds.height() < cellSize.height ? cellSize.height : bounds.height()); } bool RenderThemeMac::paintMeter(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect) @@ -1106,7 +1106,7 @@ void RenderThemeMac::paintMenuListButtonGradients(RenderObject* o, const PaintIn { GraphicsContextStateSaver stateSaver(*paintInfo.context); CGContextClipToRect(context, topGradient); - paintInfo.context->addRoundedRectClip(RoundedRect(enclosingLayoutRect(topGradient), border.radii().topLeft(), border.radii().topRight(), IntSize(), IntSize())); + paintInfo.context->addRoundedRectClip(RoundedRect(enclosingIntRect(topGradient), border.radii().topLeft(), border.radii().topRight(), IntSize(), IntSize())); context = cgContextContainer.context(); CGContextDrawShading(context, topShading.get()); } @@ -1114,7 +1114,7 @@ void RenderThemeMac::paintMenuListButtonGradients(RenderObject* o, const PaintIn if (!bottomGradient.isEmpty()) { GraphicsContextStateSaver stateSaver(*paintInfo.context); CGContextClipToRect(context, bottomGradient); - paintInfo.context->addRoundedRectClip(RoundedRect(enclosingLayoutRect(bottomGradient), IntSize(), IntSize(), border.radii().bottomLeft(), border.radii().bottomRight())); + paintInfo.context->addRoundedRectClip(RoundedRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), border.radii().bottomLeft(), border.radii().bottomRight())); context = cgContextContainer.context(); CGContextDrawShading(context, bottomShading.get()); } @@ -1276,7 +1276,7 @@ void RenderThemeMac::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle* s style->setLineHeight(RenderStyle::initialLineHeight()); } -void RenderThemeMac::setPopupButtonCellState(const RenderObject* o, const IntRect& r) +void RenderThemeMac::setPopupButtonCellState(const RenderObject* o, const LayoutRect& r) { NSPopUpButtonCell* popupButton = this->popupButton(); @@ -1538,9 +1538,9 @@ bool RenderThemeMac::paintSearchFieldCancelButton(RenderObject* o, const PaintIn #if ENABLE(INPUT_SPEECH) // Take care of cases where the cancel button was not aligned with the right border of the input element (for e.g. // when speech input is enabled for the input element. - IntRect absBoundingBox = input->renderer()->absoluteBoundingBoxRect(); - int absRight = absBoundingBox.x() + absBoundingBox.width() - input->renderBox()->paddingRight() - input->renderBox()->borderRight(); - int spaceToRightOfCancelButton = absRight - (r.x() + r.width()); + LayoutRect absBoundingBox = input->renderer()->absoluteBoundingBoxRect(); + LayoutUnit absRight = absBoundingBox.x() + absBoundingBox.width() - input->renderBox()->paddingRight() - input->renderBox()->borderRight(); + LayoutUnit spaceToRightOfCancelButton = absRight - (r.x() + r.width()); localBounds.setX(localBounds.x() - spaceToRightOfCancelButton); #endif @@ -2024,7 +2024,7 @@ bool RenderThemeMac::usesMediaControlVolumeSlider() const return mediaControllerTheme() == MediaControllerThemeQuickTime; } -IntPoint RenderThemeMac::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const IntSize& size) const +LayoutPoint RenderThemeMac::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const LayoutSize& size) const { return RenderMediaControls::volumeSliderOffsetFromMuteButton(muteButtonBox, size); } diff --git a/Source/WebCore/rendering/RenderThemeSafari.cpp b/Source/WebCore/rendering/RenderThemeSafari.cpp index 999f2f73d..771f19426 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; } -int RenderThemeSafari::baselinePosition(const RenderObject* o) const +LayoutUnit 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 9ffe2fa0c..85ddb4d50 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 int baselinePosition(const RenderObject*) const; + virtual LayoutUnit 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/RenderThemeWin.cpp b/Source/WebCore/rendering/RenderThemeWin.cpp index 0b79e40f9..64b5c8a95 100644 --- a/Source/WebCore/rendering/RenderThemeWin.cpp +++ b/Source/WebCore/rendering/RenderThemeWin.cpp @@ -874,14 +874,14 @@ void RenderThemeWin::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderSt bool RenderThemeWin::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { - IntRect bounds = r; + LayoutRect bounds = r; ASSERT(o->parent()); if (!o->parent() || !o->parent()->isBox()) return false; RenderBox* parentRenderBox = toRenderBox(o->parent()); - IntRect parentBox = parentRenderBox->absoluteContentBox(); + LayoutRect parentBox = parentRenderBox->absoluteContentBox(); // Make sure the scaled button stays square and will fit in its parent's box bounds.setHeight(min(parentBox.width(), min(parentBox.height(), bounds.height()))); @@ -925,13 +925,13 @@ void RenderThemeWin::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* s bool RenderThemeWin::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { - IntRect bounds = r; + LayoutRect bounds = r; ASSERT(o->parent()); if (!o->parent() || !o->parent()->isBox()) return false; RenderBox* parentRenderBox = toRenderBox(o->parent()); - IntRect parentBox = parentRenderBox->absoluteContentBox(); + LayoutRect parentBox = parentRenderBox->absoluteContentBox(); // Make sure the scaled decoration stays square and will fit in its parent's box bounds.setHeight(min(parentBox.width(), min(parentBox.height(), bounds.height()))); @@ -959,7 +959,7 @@ void RenderThemeWin::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* selec bool RenderThemeWin::paintSearchFieldResultsButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { - IntRect bounds = r; + LayoutRect bounds = r; ASSERT(o->parent()); if (!o->parent()) return false; @@ -967,11 +967,11 @@ bool RenderThemeWin::paintSearchFieldResultsButton(RenderObject* o, const PaintI return false; RenderBox* parentRenderBox = toRenderBox(o->parent()); - IntRect parentBox = parentRenderBox->absoluteContentBox(); + LayoutRect parentBox = parentRenderBox->absoluteContentBox(); // Make sure the scaled decoration will fit in its parent's box bounds.setHeight(min(parentBox.height(), bounds.height())); - bounds.setWidth(min(parentBox.width(), static_cast<int>(bounds.height() * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize))); + bounds.setWidth(min<LayoutUnit>(parentBox.width(), bounds.height() * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize)); // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will // be one pixel closer to the bottom of the field. This tends to look better with the text. @@ -1117,7 +1117,7 @@ bool RenderThemeWin::paintMediaVolumeSliderThumb(RenderObject* o, const PaintInf return RenderMediaControls::paintMediaControlsPart(MediaVolumeSliderThumb, o, paintInfo, r); } -IntPoint RenderThemeWin::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const IntSize& size) const +LayoutPoint RenderThemeWin::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const LayoutSize& size) const { return RenderMediaControls::volumeSliderOffsetFromMuteButton(muteButtonBox, size); } diff --git a/Source/WebCore/rendering/RenderThemeWin.h b/Source/WebCore/rendering/RenderThemeWin.h index 4b7f8283b..293796c90 100644 --- a/Source/WebCore/rendering/RenderThemeWin.h +++ b/Source/WebCore/rendering/RenderThemeWin.h @@ -141,7 +141,7 @@ public: virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); - virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const; + virtual LayoutPoint volumeSliderOffsetFromMuteButton(RenderBox*, const LayoutSize&) const; #endif virtual bool shouldShowPlaceholderWhenFocused() const { return true; } diff --git a/Source/WebCore/rendering/RenderTreeAsText.cpp b/Source/WebCore/rendering/RenderTreeAsText.cpp index 88ad4ac35..06e0fe98e 100644 --- a/Source/WebCore/rendering/RenderTreeAsText.cpp +++ b/Source/WebCore/rendering/RenderTreeAsText.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "RenderTreeAsText.h" -#include "CSSMutableStyleDeclaration.h" #include "Document.h" #include "Frame.h" #include "FrameSelection.h" @@ -48,6 +47,7 @@ #include "RenderTableCell.h" #include "RenderView.h" #include "RenderWidget.h" +#include "StylePropertySet.h" #include <wtf/HexNumber.h> #include <wtf/UnusedParam.h> #include <wtf/Vector.h> @@ -183,7 +183,7 @@ static bool isEmptyOrUnstyledAppleStyleSpan(const Node* node) if (!node->hasChildNodes()) return true; - CSSMutableStyleDeclaration* inlineStyleDecl = elem->inlineStyleDecl(); + StylePropertySet* inlineStyleDecl = elem->inlineStyleDecl(); return (!inlineStyleDecl || inlineStyleDecl->isEmpty()); } @@ -617,10 +617,10 @@ static void write(TextStream& ts, RenderLayer& l, ts << " scrollX " << l.scrollXOffset(); if (l.scrollYOffset()) ts << " scrollY " << l.scrollYOffset(); - if (l.renderBox() && l.renderBox()->clientWidth() != l.scrollWidth()) - ts << " scrollWidth " << l.scrollWidth(); - if (l.renderBox() && l.renderBox()->clientHeight() != l.scrollHeight()) - ts << " scrollHeight " << l.scrollHeight(); + if (l.renderBox() && l.renderBox()->pixelSnappedClientWidth() != l.pixelSnappedScrollWidth()) + ts << " scrollWidth " << l.pixelSnappedScrollWidth(); + if (l.renderBox() && l.renderBox()->pixelSnappedClientHeight() != l.pixelSnappedScrollHeight()) + ts << " scrollHeight " << l.pixelSnappedScrollHeight(); } if (paintPhase == LayerPaintPhaseBackground) diff --git a/Source/WebCore/rendering/RenderView.h b/Source/WebCore/rendering/RenderView.h index 5307c3f51..9ee7a1d6d 100644 --- a/Source/WebCore/rendering/RenderView.h +++ b/Source/WebCore/rendering/RenderView.h @@ -208,7 +208,7 @@ private: { // We push LayoutState even if layoutState is disabled because it stores layoutDelta too. if (!doingFullRepaint() || m_layoutState->isPaginated() || renderer->hasColumns() || renderer->inRenderFlowThread() - || m_layoutState->currentLineGrid() || (renderer->style()->lineGrid() != RenderStyle::initialLineGrid() && renderer->isBlockFlow())) { + || m_layoutState->lineGrid() || (renderer->style()->lineGrid() != RenderStyle::initialLineGrid() && renderer->isBlockFlow())) { m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset, pageHeight, pageHeightChanged, colInfo); return true; } diff --git a/Source/WebCore/rendering/RootInlineBox.cpp b/Source/WebCore/rendering/RootInlineBox.cpp index 081b3b75e..2acfaf02c 100644 --- a/Source/WebCore/rendering/RootInlineBox.cpp +++ b/Source/WebCore/rendering/RootInlineBox.cpp @@ -330,13 +330,13 @@ LayoutUnit RootInlineBox::lineGridSnapAdjustment(LayoutUnit delta) const { // If our block doesn't have snapping turned on, do nothing. // FIXME: Implement bounds snapping. - if (block()->style()->lineGridSnap() != LineGridSnapBaseline) + if (block()->style()->lineGridSnap() == LineGridSnapNone) return 0; // Get the current line grid and offset. LayoutState* layoutState = block()->view()->layoutState(); - RenderBlock* lineGrid = layoutState->currentLineGrid(); - LayoutSize lineGridOffset = layoutState->currentLineGridOffset(); + RenderBlock* lineGrid = layoutState->lineGrid(); + LayoutSize lineGridOffset = layoutState->lineGridOffset(); if (!lineGrid || lineGrid->style()->writingMode() != block()->style()->writingMode()) return 0; @@ -352,45 +352,69 @@ LayoutUnit RootInlineBox::lineGridSnapAdjustment(LayoutUnit delta) const // as established by the line box. // FIXME: Need to handle crazy line-box-contain values that cause the root line box to not be considered. I assume // the grid should honor line-box-contain. - LayoutUnit baselineMultiple = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading(); - if (!baselineMultiple) + LayoutUnit gridLineHeight = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading(); + if (!gridLineHeight) return 0; - LayoutUnit lineGridAscent = lineGrid->style()->fontMetrics().ascent(baselineType()); - LayoutUnit firstBaselinePosition = lineGridBlockOffset + lineGridAscent + lineGridBox->logicalTop(); - LayoutUnit currentBaselinePosition = blockOffset + logicalTop() + delta + block()->style()->fontMetrics().ascent(baselineType()); + LayoutUnit lineGridFontAscent = lineGrid->style()->fontMetrics().ascent(baselineType()); + LayoutUnit lineGridFontHeight = lineGridBox->logicalHeight(); + LayoutUnit firstTextTop = lineGridBlockOffset + lineGridBox->logicalTop(); + LayoutUnit firstLineTopWithLeading = lineGridBlockOffset + lineGridBox->lineTopWithLeading(); + LayoutUnit firstBaselinePosition = firstTextTop + lineGridFontAscent; + + LayoutUnit currentTextTop = blockOffset + logicalTop() + delta; + LayoutUnit currentFontAscent = block()->style()->fontMetrics().ascent(baselineType()); + LayoutUnit currentBaselinePosition = currentTextTop + currentFontAscent; + + LayoutUnit lineGridPaginationOrigin = isHorizontal() ? layoutState->lineGridPaginationOrigin().height() : layoutState->lineGridPaginationOrigin().width(); // If we're paginated, see if we're on a page after the first one. If so, the grid resets on subsequent pages. // FIXME: If the grid is an ancestor of the pagination establisher, then this is incorrect. LayoutUnit pageLogicalTop = 0; if (layoutState->isPaginated() && layoutState->pageLogicalHeight()) { - pageLogicalTop = block()->pageLogicalTopForOffset(logicalTop() + delta); - if (pageLogicalTop > lineGridBlockOffset + lineGridBox->logicalTop()) - firstBaselinePosition = lineGridAscent + pageLogicalTop + lineGridBox->logicalTop() - lineGrid->borderBefore() - lineGrid->paddingBefore(); + pageLogicalTop = block()->pageLogicalTopForOffset(lineTopWithLeading() + delta); + if (pageLogicalTop > firstLineTopWithLeading) + firstTextTop = pageLogicalTop + lineGridBox->logicalTop() - lineGrid->borderBefore() - lineGrid->paddingBefore() + lineGridPaginationOrigin; } - + + if (block()->style()->lineGridSnap() == LineGridSnapContain) { + // Compute the desired offset from the text-top of a grid line. + // Look at our height (logicalHeight()). + // Look at the total available height. It's going to be (textBottom - textTop) + (n-1)*(multiple with leading) + // where n is number of grid lines required to enclose us. + if (logicalHeight() <= lineGridFontHeight) + firstTextTop += (lineGridFontHeight - logicalHeight()) / 2; + else { + LayoutUnit numberOfLinesWithLeading = ceilf(static_cast<float>(logicalHeight() - lineGridFontHeight) / gridLineHeight); + LayoutUnit totalHeight = lineGridFontHeight + numberOfLinesWithLeading * gridLineHeight; + firstTextTop += (totalHeight - logicalHeight()) / 2; + } + firstBaselinePosition = firstTextTop + currentFontAscent; + } else + firstBaselinePosition = firstTextTop + lineGridFontAscent; + // If we're above the first line, just push to the first line. if (currentBaselinePosition < firstBaselinePosition) return delta + firstBaselinePosition - currentBaselinePosition; // Otherwise we're in the middle of the grid somewhere. Just push to the next line. LayoutUnit baselineOffset = currentBaselinePosition - firstBaselinePosition; - LayoutUnit remainder = baselineOffset % baselineMultiple; + LayoutUnit remainder = baselineOffset % gridLineHeight; LayoutUnit result = delta; if (remainder) - result += baselineMultiple - remainder; + result += gridLineHeight - remainder; // If we aren't paginated we can return the result. if (!layoutState->isPaginated() || !layoutState->pageLogicalHeight() || result == delta) return result; - // We may have shifted to a new page. We need to do a re-snap when that happens. - LayoutUnit newPageLogicalTop = block()->pageLogicalTopForOffset(logicalTop() + result); + // We may end up shifted to a new page. We need to do a re-snap when that happens. + LayoutUnit newPageLogicalTop = block()->pageLogicalTopForOffset(lineBottomWithLeading() + result); if (newPageLogicalTop == pageLogicalTop) return result; // Put ourselves at the top of the next page to force a snap onto the new grid established by that page. - return lineGridSnapAdjustment(newPageLogicalTop - (blockOffset + logicalTop())); + return lineGridSnapAdjustment(newPageLogicalTop - (blockOffset + lineTopWithLeading())); } GapRects RootInlineBox::lineSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, diff --git a/Source/WebCore/rendering/RootInlineBox.h b/Source/WebCore/rendering/RootInlineBox.h index b7487ae5d..fef7ced22 100644 --- a/Source/WebCore/rendering/RootInlineBox.h +++ b/Source/WebCore/rendering/RootInlineBox.h @@ -101,8 +101,8 @@ public: bool isHyphenated() const; - virtual int baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); } - virtual int lineHeight() const { return boxModelObject()->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); } + virtual LayoutUnit baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); } + virtual LayoutUnit lineHeight() const { return boxModelObject()->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); } #if PLATFORM(MAC) void addHighlightOverflow(); diff --git a/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp b/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp index e2491f0a1..2bdccec2c 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp @@ -109,7 +109,6 @@ void RenderMathMLBlock::paint(PaintInfo& info, const LayoutPoint& paintOffset) } #endif // ENABLE(DEBUG_MATH_LAYOUT) - } #endif diff --git a/Source/WebCore/rendering/mathml/RenderMathMLBlock.h b/Source/WebCore/rendering/mathml/RenderMathMLBlock.h index d11bf78e4..4d8184bcf 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLBlock.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLBlock.h @@ -52,16 +52,7 @@ public: #endif protected: - int getBoxModelObjectHeight(RenderObject* object) - { - if (object && object->isBoxModelObject()) { - RenderBoxModelObject* box = toRenderBoxModelObject(object); - return box->offsetHeight(); - } - - return 0; - } - int getBoxModelObjectHeight(const RenderObject* object) + static LayoutUnit getBoxModelObjectHeight(const RenderObject* object) { if (object && object->isBoxModelObject()) { const RenderBoxModelObject* box = toRenderBoxModelObject(object); @@ -70,16 +61,7 @@ protected: return 0; } - int getBoxModelObjectWidth(RenderObject* object) - { - if (object && object->isBoxModelObject()) { - RenderBoxModelObject* box = toRenderBoxModelObject(object); - return box->offsetWidth(); - } - - return 0; - } - int getBoxModelObjectWidth(const RenderObject* object) + static LayoutUnit getBoxModelObjectWidth(const RenderObject* object) { if (object && object->isBoxModelObject()) { const RenderBoxModelObject* box = toRenderBoxModelObject(object); @@ -106,8 +88,10 @@ inline const RenderMathMLBlock* toRenderMathMLBlock(const RenderObject* object) return static_cast<const RenderMathMLBlock*>(object); } -} +// This will catch anyone doing an unnecessary cast. +void toRenderMathMLBlock(const RenderMathMLBlock*); +} #endif // ENABLE(MATHML) #endif // RenderMathMLBlock_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp b/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp index e2eddcbd8..aeaab20f7 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp @@ -165,7 +165,7 @@ void RenderMathMLFraction::paint(PaintInfo& info, const LayoutPoint& paintOffset info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y())); } -int RenderMathMLFraction::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const +LayoutUnit RenderMathMLFraction::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const { if (firstChild() && firstChild()->isRenderMathMLBlock()) { RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild()); @@ -182,5 +182,4 @@ int RenderMathMLFraction::baselinePosition(FontBaseline, bool firstLine, LineDir } - #endif // ENABLE(MATHML) diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFraction.h b/Source/WebCore/rendering/mathml/RenderMathMLFraction.h index d9f624762..3971a1e13 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLFraction.h +++ b/Source/WebCore/rendering/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(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void paint(PaintInfo&, const LayoutPoint&); protected: virtual void layout(); diff --git a/Source/WebCore/rendering/mathml/RenderMathMLMath.cpp b/Source/WebCore/rendering/mathml/RenderMathMLMath.cpp index 2b65f69a4..006fea31c 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLMath.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLMath.cpp @@ -43,4 +43,3 @@ RenderMathMLMath::RenderMathMLMath(Node* math) } #endif // ENABLE(MATHML) - diff --git a/Source/WebCore/rendering/mathml/RenderMathMLMath.h b/Source/WebCore/rendering/mathml/RenderMathMLMath.h index 443fc7a2e..a81d5a890 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLMath.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLMath.h @@ -43,6 +43,5 @@ private: } - #endif // ENABLE(MATHML) #endif // RenderMathMLMath_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp b/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp index 4734b2a01..2702c0656 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp @@ -334,7 +334,7 @@ RenderBlock* RenderMathMLOperator::createGlyph(UChar glyph, int size, int charRe return container; } -int RenderMathMLOperator::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const +LayoutUnit RenderMathMLOperator::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) 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 26423238f..5ee0660f5 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLOperator.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h @@ -41,7 +41,7 @@ public: virtual void stretchToHeight(int pixelHeight); virtual void updateFromElement(); virtual bool isChildAllowed(RenderObject*, RenderStyle*) const; - virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; protected: virtual void layout(); @@ -68,6 +68,9 @@ inline const RenderMathMLOperator* toRenderMathMLOperator(const RenderMathMLBloc return static_cast<const RenderMathMLOperator*>(block); } +// This will catch anyone doing an unnecessary cast. +void toRenderMathMLOperator(const RenderMathMLOperator*); + inline UChar convertHyphenMinusToMinusSign(UChar glyph) { // When rendered as a mathematical operator, minus glyph should be larger. diff --git a/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp b/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp index dbfe5e22d..24e79ba7e 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp @@ -252,5 +252,3 @@ void RenderMathMLRoot::layout() } #endif // ENABLE(MATHML) - - diff --git a/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp b/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp index a615e521c..922fa9245 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp @@ -119,7 +119,7 @@ void RenderMathMLRow::layout() } -int RenderMathMLRow::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +LayoutUnit RenderMathMLRow::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { if (firstChild() && firstChild()->isRenderMathMLBlock()) { RenderMathMLBlock* block = toRenderMathMLBlock(firstChild()); @@ -133,4 +133,3 @@ int RenderMathMLRow::baselinePosition(FontBaseline, bool firstLine, LineDirectio } #endif // ENABLE(MATHML) - diff --git a/Source/WebCore/rendering/mathml/RenderMathMLRow.h b/Source/WebCore/rendering/mathml/RenderMathMLRow.h index f9573e23a..73c5a26e5 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLRow.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLRow.h @@ -37,7 +37,7 @@ public: RenderMathMLRow(Node* container); virtual bool isRenderMathMLRow() const { return true; } virtual int nonOperatorHeight() const; - virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void stretchToHeight(int) {} protected: virtual void layout(); @@ -48,6 +48,5 @@ private: } - #endif // ENABLE(MATHML) #endif // RenderMathMLRow_h diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp b/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp index 736c6d900..38ab1c1c0 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp @@ -189,5 +189,3 @@ void RenderMathMLSquareRoot::layout() } #endif // ENABLE(MATHML) - - diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h b/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h index f6c4feb80..c8e41cdfb 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h @@ -48,6 +48,3 @@ private: #endif // ENABLE(MATHML) #endif // RenderMathMLSquareRoot_h - - - diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp b/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp index 76e92c89c..9a06b0236 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp @@ -29,14 +29,7 @@ #include "RenderMathMLSubSup.h" -#include "FontSelector.h" #include "MathMLNames.h" -#include "RenderInline.h" -#include "RenderTable.h" -#include "RenderTableCell.h" -#include "RenderTableRow.h" -#include "RenderTableSection.h" -#include "RenderText.h" namespace WebCore { @@ -181,13 +174,13 @@ void RenderMathMLSubSup::layout() } } -int RenderMathMLSubSup::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +LayoutUnit RenderMathMLSubSup::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { RenderObject* base = firstChild(); if (!base) return offsetHeight(); - int baseline = offsetHeight(); + LayoutUnit baseline = offsetHeight(); if (!base || !base->isBoxModelObject()) return baseline; diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h b/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h index db72716fe..2ba466cb4 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h @@ -23,14 +23,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #ifndef RenderMathMLSubSup_h #define RenderMathMLSubSup_h #if ENABLE(MATHML) #include "RenderMathMLBlock.h" -#include "RenderTable.h" namespace WebCore { @@ -41,7 +39,7 @@ public: virtual bool hasBase() const { return true; } virtual int nonOperatorHeight() const; virtual void stretchToHeight(int pixelHeight); - virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; protected: virtual void layout(); diff --git a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp index da1e975bf..75911036a 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp @@ -244,13 +244,13 @@ void RenderMathMLUnderOver::layout() RenderBlock::layout(); } -int RenderMathMLUnderOver::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const +LayoutUnit RenderMathMLUnderOver::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const { RenderObject* current = firstChild(); if (!current || linePositionMode == PositionOfInteriorLineBoxes) return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); - int baseline = 0; + LayoutUnit baseline = 0; switch (m_kind) { case UnderOver: case Over: @@ -292,5 +292,4 @@ int RenderMathMLUnderOver::nonOperatorHeight() const } - #endif // ENABLE(MATHML) diff --git a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h index 2708429a7..2fe619821 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h @@ -23,7 +23,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #ifndef RenderMathMLUnderOver_h #define RenderMathMLUnderOver_h @@ -40,7 +39,7 @@ public: virtual void layout(); virtual bool hasBase() const { return true; } virtual int nonOperatorHeight() const; - virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; + virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; virtual void stretchToHeight(int pixelHeight); private: virtual const char* renderName() const { return "RenderMathMLUnderOver"; } diff --git a/Source/WebCore/rendering/style/RenderStyleConstants.h b/Source/WebCore/rendering/style/RenderStyleConstants.h index 334ce233a..0ce3d8886 100644 --- a/Source/WebCore/rendering/style/RenderStyleConstants.h +++ b/Source/WebCore/rendering/style/RenderStyleConstants.h @@ -28,14 +28,6 @@ namespace WebCore { -/* - * WARNING: - * -------- - * - * The order of the values in the enums have to agree with the order specified - * in CSSValueKeywords.in, otherwise some optimizations in the parser will fail, - * and produce invalid results. - */ static const size_t PrintColorAdjustBits = 1; enum PrintColorAdjust { PrintColorAdjustEconomy, @@ -93,7 +85,7 @@ enum ColumnSpan { ColumnSpanOne = 0, ColumnSpanAll}; enum EBorderCollapse { BSEPARATE = 0, BCOLLAPSE = 1 }; // These have been defined in the order of their precedence for border-collapsing. Do -// not change this order! +// not change this order! This order also must match the order in CSSValueKeywords.in. enum EBorderStyle { BNONE, BHIDDEN, INSET, GROOVE, OUTSET, RIDGE, DOTTED, DASHED, SOLID, DOUBLE }; enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL }; @@ -229,7 +221,7 @@ enum EResize { RESIZE_NONE, RESIZE_BOTH, RESIZE_HORIZONTAL, RESIZE_VERTICAL }; -// The order of this enum must match the order of the list style types in CSSValueKeywords.in. +// The order of this enum must match the order of the list style types in CSSValueKeywords.in. enum EListStyleType { Disc, Circle, @@ -335,6 +327,7 @@ enum EWhiteSpace { NORMAL, PRE, PRE_WRAP, PRE_LINE, NOWRAP, KHTML_NOWRAP }; +// The order of this enum must match the order of the text align values in CSSValueKeywords.in. enum ETextAlign { TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, WEBKIT_LEFT, WEBKIT_RIGHT, WEBKIT_CENTER, TASTART, TAEND, }; @@ -408,6 +401,7 @@ enum ECursor { CURSOR_NONE }; +// The order of this enum must match the order of the display values in CSSValueKeywords.in. enum EDisplay { INLINE, BLOCK, LIST_ITEM, RUN_IN, COMPACT, INLINE_BLOCK, TABLE, INLINE_TABLE, TABLE_ROW_GROUP, diff --git a/Source/WebCore/rendering/svg/RenderSVGContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGContainer.cpp index cffa755b7..515565521 100644 --- a/Source/WebCore/rendering/svg/RenderSVGContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGContainer.cpp @@ -63,6 +63,9 @@ void RenderSVGContainer::layout() // Allow RenderSVGTransformableContainer to update its transform. bool updatedTransform = calculateLocalTransform(); + // RenderSVGViewportContainer needs to set the 'layout size changed' flag. + determineIfLayoutSizeChanged(); + SVGRenderSupport::layoutChildren(this, selfNeedsLayout() || SVGRenderSupport::filtersForceContainerLayout(this)); // Invalidate all resources of this client if our layout changed. diff --git a/Source/WebCore/rendering/svg/RenderSVGContainer.h b/Source/WebCore/rendering/svg/RenderSVGContainer.h index 60b91e14c..c7d9f205f 100644 --- a/Source/WebCore/rendering/svg/RenderSVGContainer.h +++ b/Source/WebCore/rendering/svg/RenderSVGContainer.h @@ -67,6 +67,8 @@ protected: virtual void applyViewportClip(PaintInfo&) { } virtual bool pointIsInsideViewportClip(const FloatPoint& /*pointInParent*/) { return true; } + virtual void determineIfLayoutSizeChanged() { } + bool selfWillPaint(); void updateCachedBoundaries(); diff --git a/Source/WebCore/rendering/svg/RenderSVGResource.cpp b/Source/WebCore/rendering/svg/RenderSVGResource.cpp index 24adf5bf4..4fc5e2376 100644 --- a/Source/WebCore/rendering/svg/RenderSVGResource.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResource.cpp @@ -161,37 +161,42 @@ RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource() return s_sharedSolidPaintingResource; } -void RenderSVGResource::removeFromFilterCache(RenderObject* object) +static inline void removeFromFilterCacheAndInvalidateDependencies(RenderObject* object, bool needsLayout) { -#if ENABLE(FILTERS) ASSERT(object); - - SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object); - if (!resources) +#if ENABLE(FILTERS) + if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object)) { + if (RenderSVGResourceFilter* filter = resources->filter()) + filter->removeClientFromCache(object); + } +#endif + if (!object->node() || !object->node()->isSVGElement()) return; - - RenderSVGResourceFilter* filter = resources->filter(); - if (!filter) + HashSet<SVGElement*>* dependencies = object->document()->accessSVGExtensions()->setOfElementsReferencingTarget(static_cast<SVGElement*>(object->node())); + if (!dependencies) return; - - filter->removeClientFromCache(object); -#else - UNUSED_PARAM(object); -#endif + HashSet<SVGElement*>::iterator end = dependencies->end(); + for (HashSet<SVGElement*>::iterator it = dependencies->begin(); it != end; ++it) { + if (RenderObject* renderer = (*it)->renderer()) + RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, needsLayout); + } } void RenderSVGResource::markForLayoutAndParentResourceInvalidation(RenderObject* object, bool needsLayout) { ASSERT(object); + ASSERT(object->document()); + ASSERT(object->node()); + if (needsLayout) object->setNeedsLayout(true); - removeFromFilterCache(object); + removeFromFilterCacheAndInvalidateDependencies(object, needsLayout); // Invalidate resources in ancestor chain, if needed. RenderObject* current = object->parent(); while (current) { - removeFromFilterCache(current); + removeFromFilterCacheAndInvalidateDependencies(current, needsLayout); if (current->isSVGResourceContainer()) { // This will process the rest of the ancestors. diff --git a/Source/WebCore/rendering/svg/RenderSVGResource.h b/Source/WebCore/rendering/svg/RenderSVGResource.h index 8ff552bb1..e02015410 100644 --- a/Source/WebCore/rendering/svg/RenderSVGResource.h +++ b/Source/WebCore/rendering/svg/RenderSVGResource.h @@ -82,9 +82,6 @@ public: static RenderSVGResourceSolidColor* sharedSolidPaintingResource(); static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool needsLayout = true); - -private: - static void removeFromFilterCache(RenderObject*); }; } diff --git a/Source/WebCore/rendering/svg/RenderSVGRoot.cpp b/Source/WebCore/rendering/svg/RenderSVGRoot.cpp index 507f38324..ba821cca2 100644 --- a/Source/WebCore/rendering/svg/RenderSVGRoot.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGRoot.cpp @@ -214,7 +214,6 @@ void RenderSVGRoot::layout() SVGSVGElement* svg = static_cast<SVGSVGElement*>(node()); m_isLayoutSizeChanged = needsLayout || (svg->hasRelativeLengths() && oldSize != size()); SVGRenderSupport::layoutChildren(this, needsLayout || SVGRenderSupport::filtersForceContainerLayout(this)); - m_isLayoutSizeChanged = false; // At this point LayoutRepainter already grabbed the old bounds, // recalculate them now so repaintAfterLayout() uses the new bounds. diff --git a/Source/WebCore/rendering/svg/RenderSVGShape.cpp b/Source/WebCore/rendering/svg/RenderSVGShape.cpp index 136a53cf9..31f15251b 100755 --- a/Source/WebCore/rendering/svg/RenderSVGShape.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGShape.cpp @@ -136,13 +136,21 @@ bool RenderSVGShape::strokeContains(const FloatPoint& point, bool requiresStroke if (requiresStroke && !RenderSVGResource::strokePaintingResource(this, style(), fallbackColor)) return false; - // FIXME: This is not correct for round linecaps. https://bugs.webkit.org/show_bug.cgi?id=76931 + const SVGRenderStyle* svgStyle = style()->svgStyle(); for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) { - if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], this->strokeWidth()).contains(point)) - return true; + ASSERT(style()->svgStyle()->hasStroke()); + float strokeWidth = this->strokeWidth(); + if (style()->svgStyle()->capStyle() == SquareCap) { + if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWidth).contains(point)) + return true; + } else { + ASSERT(style()->svgStyle()->capStyle() == RoundCap); + FloatPoint radiusVector(point.x() - m_zeroLengthLinecapLocations[i].x(), point.y() - m_zeroLengthLinecapLocations[i].y()); + if (radiusVector.lengthSquared() < strokeWidth * strokeWidth * .25f) + return true; + } } - const SVGRenderStyle* svgStyle = style()->svgStyle(); if (!svgStyle->strokeDashArray().isEmpty() || svgStyle->strokeMiterLimit() != svgStyle->initialStrokeMiterLimit() || svgStyle->joinStyle() != svgStyle->initialJoinStyle() || svgStyle->capStyle() != svgStyle->initialCapStyle() || static_cast<SVGElement*>(node())->isStyled()) { if (!m_path) diff --git a/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp index 8b7e65b65..1021aff00 100644 --- a/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp @@ -34,9 +34,18 @@ namespace WebCore { RenderSVGViewportContainer::RenderSVGViewportContainer(SVGStyledElement* node) : RenderSVGContainer(node) + , m_isLayoutSizeChanged(false) { } +void RenderSVGViewportContainer::determineIfLayoutSizeChanged() +{ + if (!node()->hasTagName(SVGNames::svgTag)) + return; + + m_isLayoutSizeChanged = static_cast<SVGSVGElement*>(node())->hasRelativeLengths() && selfNeedsLayout(); +} + void RenderSVGViewportContainer::applyViewportClip(PaintInfo& paintInfo) { if (SVGRenderSupport::isOverflowHidden(this)) diff --git a/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h index 07be7eb9a..808d6727b 100644 --- a/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h +++ b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h @@ -35,6 +35,10 @@ public: explicit RenderSVGViewportContainer(SVGStyledElement*); FloatRect viewport() const { return m_viewport; } + bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; } + + virtual void determineIfLayoutSizeChanged(); + private: virtual bool isSVGContainer() const { return true; } virtual bool isSVGViewportContainer() const { return true; } @@ -50,6 +54,7 @@ private: FloatRect m_viewport; mutable AffineTransform m_localToParentTransform; + bool m_isLayoutSizeChanged : 1; }; inline RenderSVGViewportContainer* toRenderSVGViewportContainer(RenderObject* object) @@ -58,6 +63,12 @@ inline RenderSVGViewportContainer* toRenderSVGViewportContainer(RenderObject* ob return static_cast<RenderSVGViewportContainer*>(object); } +inline const RenderSVGViewportContainer* toRenderSVGViewportContainer(const RenderObject* object) +{ + ASSERT(!object || !strcmp(object->renderName(), "RenderSVGViewportContainer")); + return static_cast<const RenderSVGViewportContainer*>(object); +} + // This will catch anyone doing an unnecessary cast. void toRenderSVGViewportContainer(const RenderSVGViewportContainer*); diff --git a/Source/WebCore/rendering/svg/SVGRenderSupport.cpp b/Source/WebCore/rendering/svg/SVGRenderSupport.cpp index 2a3801bb2..6457ac006 100644 --- a/Source/WebCore/rendering/svg/SVGRenderSupport.cpp +++ b/Source/WebCore/rendering/svg/SVGRenderSupport.cpp @@ -39,6 +39,7 @@ #include "RenderSVGResourceMarker.h" #include "RenderSVGResourceMasker.h" #include "RenderSVGRoot.h" +#include "RenderSVGViewportContainer.h" #include "SVGResources.h" #include "SVGResourcesCache.h" #include "SVGStyledElement.h" @@ -231,9 +232,22 @@ static inline void invalidateResourcesOfChildren(RenderObject* start) invalidateResourcesOfChildren(child); } +static inline bool layoutSizeOfNearestViewportChanged(const RenderObject* start) +{ + while (start && !start->isSVGRoot() && !start->isSVGViewportContainer()) + start = start->parent(); + + ASSERT(start); + ASSERT(start->isSVGRoot() || start->isSVGViewportContainer()); + if (start->isSVGViewportContainer()) + return toRenderSVGViewportContainer(start)->isLayoutSizeChanged(); + + return toRenderSVGRoot(start)->isLayoutSizeChanged(); +} + void SVGRenderSupport::layoutChildren(RenderObject* start, bool selfNeedsLayout) { - bool layoutSizeChanged = findTreeRootObject(start)->isLayoutSizeChanged(); + bool layoutSizeChanged = layoutSizeOfNearestViewportChanged(start); HashSet<RenderObject*> notlayoutedObjects; for (RenderObject* child = start->firstChild(); child; child = child->nextSibling()) { |