Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1198)

Unified Diff: Source/core/rendering/RenderBlockFlow.cpp

Issue 404993002: Move fitBorderToLinesIfNeeded and most of deleteLineBoxTree into RenderBlockFlow. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderBlockFlow.cpp
diff --git a/Source/core/rendering/RenderBlockFlow.cpp b/Source/core/rendering/RenderBlockFlow.cpp
index af11419cff588bc51a70fd8fb193c711600d6e4b..8994e1bd549d5e9a7cccdd86ba17a7c13e7d55be 100644
--- a/Source/core/rendering/RenderBlockFlow.cpp
+++ b/Source/core/rendering/RenderBlockFlow.cpp
@@ -1778,7 +1778,11 @@ void RenderBlockFlow::deleteLineBoxTree()
{
if (containsFloats())
m_floatingObjects->clearLineBoxTreePointers();
- RenderBlock::deleteLineBoxTree();
+
+ m_lineBoxes.deleteLineBoxTree();
+
+ if (AXObjectCache* cache = document().existingAXObjectCache())
+ cache->recomputeIsIgnored(this);
}
void RenderBlockFlow::markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove, bool inLayout)
@@ -2650,8 +2654,33 @@ bool RenderBlockFlow::hitTestFloats(const HitTestRequest& request, HitTestResult
void RenderBlockFlow::adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutUnit& right) const
{
- RenderBlock::adjustForBorderFit(x, left, right);
- if (m_floatingObjects && style()->visibility() == VISIBLE) {
+ if (style()->visibility() != VISIBLE)
+ return;
+
+ // We don't deal with relative positioning. Our assumption is that you shrink to fit the lines without accounting
+ // for either overflow or translations via relative positioning.
+ if (childrenInline()) {
+ for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) {
+ if (box->firstChild())
+ left = std::min(left, x + static_cast<LayoutUnit>(box->firstChild()->x()));
+ if (box->lastChild())
+ right = std::max(right, x + static_cast<LayoutUnit>(ceilf(box->lastChild()->logicalRight())));
+ }
+ } else {
+ for (RenderBox* obj = firstChildBox(); obj; obj = obj->nextSiblingBox()) {
+ if (!obj->isFloatingOrOutOfFlowPositioned()) {
+ if (obj->isRenderBlockFlow() && !obj->hasOverflowClip()) {
+ toRenderBlockFlow(obj)->adjustForBorderFit(x + obj->x(), left, right);
+ } else if (obj->style()->visibility() == VISIBLE) {
+ // We are a replaced element or some kind of non-block-flow object.
+ left = std::min(left, x + obj->x());
+ right = std::max(right, x + obj->x() + obj->width());
+ }
+ }
+ }
+ }
+
+ if (m_floatingObjects) {
const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
FloatingObjectSetIterator end = floatingObjectSet.end();
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
@@ -2667,6 +2696,32 @@ void RenderBlockFlow::adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutU
}
}
+void RenderBlockFlow::fitBorderToLinesIfNeeded()
+{
+ if (style()->borderFit() == BorderFitBorder || hasOverrideWidth())
+ return;
+
+ // Walk any normal flow lines to snugly fit.
+ LayoutUnit left = LayoutUnit::max();
+ LayoutUnit right = LayoutUnit::min();
+ LayoutUnit oldWidth = contentWidth();
+ adjustForBorderFit(0, left, right);
+
+ // Clamp to our existing edges. We can never grow. We only shrink.
+ LayoutUnit leftEdge = borderLeft() + paddingLeft();
+ LayoutUnit rightEdge = leftEdge + oldWidth;
+ left = std::min(rightEdge, std::max(leftEdge, left));
+ right = std::max(left, std::min(rightEdge, right));
+
+ LayoutUnit newContentWidth = right - left;
+ if (newContentWidth == oldWidth)
+ return;
+
+ setOverrideLogicalContentWidth(newContentWidth);
+ layoutBlock(false);
+ clearOverrideLogicalContentWidth();
+}
+
LayoutUnit RenderBlockFlow::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, LayoutUnit logicalHeight) const
{
if (m_floatingObjects && m_floatingObjects->hasLeftObjects())
« Source/core/rendering/RenderBlock.cpp ('K') | « Source/core/rendering/RenderBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698