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

Side by Side Diff: Source/core/rendering/RenderBlock.cpp

Issue 13909006: Merge patch for stacked floats with shape-outside from WebKit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update for review comments Created 7 years, 7 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 4015 matching lines...) Expand 10 before | Expand all | Expand 10 after
4026 4026
4027 LayoutUnit floatLogicalWidth = min(logicalWidthForFloat(floatingObject), log icalRightOffset - logicalLeftOffset); // The width we look for. 4027 LayoutUnit floatLogicalWidth = min(logicalWidthForFloat(floatingObject), log icalRightOffset - logicalLeftOffset); // The width we look for.
4028 4028
4029 LayoutUnit floatLogicalLeft; 4029 LayoutUnit floatLogicalLeft;
4030 4030
4031 bool insideFlowThread = flowThreadContainingBlock(); 4031 bool insideFlowThread = flowThreadContainingBlock();
4032 4032
4033 if (childBox->style()->floating() == LeftFloat) { 4033 if (childBox->style()->floating() == LeftFloat) {
4034 LayoutUnit heightRemainingLeft = 1; 4034 LayoutUnit heightRemainingLeft = 1;
4035 LayoutUnit heightRemainingRight = 1; 4035 LayoutUnit heightRemainingRight = 1;
4036 floatLogicalLeft = logicalLeftOffsetForLine(logicalTopOffset, logicalLef tOffset, false, &heightRemainingLeft); 4036 floatLogicalLeft = logicalLeftOffsetForLineUsingFloatBoundingBox(logical TopOffset, logicalLeftOffset, false, &heightRemainingLeft, 0);
Julien - ping for review 2013/05/29 17:14:49 The last argument (0) is optional, it's probably b
4037 while (logicalRightOffsetForLine(logicalTopOffset, logicalRightOffset, f alse, &heightRemainingRight) - floatLogicalLeft < floatLogicalWidth) { 4037 while (logicalRightOffsetForLineUsingFloatBoundingBox(logicalTopOffset, logicalRightOffset, false, &heightRemainingRight, 0) - floatLogicalLeft < floatL ogicalWidth) {
4038 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); 4038 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight);
4039 floatLogicalLeft = logicalLeftOffsetForLine(logicalTopOffset, logica lLeftOffset, false, &heightRemainingLeft); 4039 floatLogicalLeft = logicalLeftOffsetForLineUsingFloatBoundingBox(log icalTopOffset, logicalLeftOffset, false, &heightRemainingLeft, 0);
4040 if (insideFlowThread) { 4040 if (insideFlowThread) {
4041 // Have to re-evaluate all of our offsets, since they may have c hanged. 4041 // Have to re-evaluate all of our offsets, since they may have c hanged.
4042 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset. 4042 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset.
4043 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset. 4043 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset.
4044 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset); 4044 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset);
4045 } 4045 }
4046 } 4046 }
4047 floatLogicalLeft = max(logicalLeftOffset - borderAndPaddingLogicalLeft() , floatLogicalLeft); 4047 floatLogicalLeft = max(logicalLeftOffset - borderAndPaddingLogicalLeft() , floatLogicalLeft);
4048 } else { 4048 } else {
4049 LayoutUnit heightRemainingLeft = 1; 4049 LayoutUnit heightRemainingLeft = 1;
4050 LayoutUnit heightRemainingRight = 1; 4050 LayoutUnit heightRemainingRight = 1;
4051 floatLogicalLeft = logicalRightOffsetForLine(logicalTopOffset, logicalRi ghtOffset, false, &heightRemainingRight); 4051 floatLogicalLeft = logicalRightOffsetForLineUsingFloatBoundingBox(logica lTopOffset, logicalRightOffset, false, &heightRemainingRight, 0);
4052 while (floatLogicalLeft - logicalLeftOffsetForLine(logicalTopOffset, log icalLeftOffset, false, &heightRemainingLeft) < floatLogicalWidth) { 4052 while (floatLogicalLeft - logicalLeftOffsetForLineUsingFloatBoundingBox( logicalTopOffset, logicalLeftOffset, false, &heightRemainingLeft, 0) < floatLogi calWidth) {
4053 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); 4053 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight);
4054 floatLogicalLeft = logicalRightOffsetForLine(logicalTopOffset, logic alRightOffset, false, &heightRemainingRight); 4054 floatLogicalLeft = logicalRightOffsetForLineUsingFloatBoundingBox(lo gicalTopOffset, logicalRightOffset, false, &heightRemainingRight, 0);
4055 if (insideFlowThread) { 4055 if (insideFlowThread) {
4056 // Have to re-evaluate all of our offsets, since they may have c hanged. 4056 // Have to re-evaluate all of our offsets, since they may have c hanged.
4057 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset. 4057 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset.
4058 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset. 4058 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset.
4059 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset); 4059 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset);
4060 } 4060 }
4061 } 4061 }
4062 floatLogicalLeft -= logicalWidthForFloat(floatingObject); // Use the ori ginal width of the float here, since the local variable 4062 floatLogicalLeft -= logicalWidthForFloat(floatingObject); // Use the ori ginal width of the float here, since the local variable
4063 // |floatLogic alWidth| was capped to the available line width. 4063 // |floatLogic alWidth| was capped to the available line width.
4064 // See fast/bl ock/float/clamped-right-float.html. 4064 // See fast/bl ock/float/clamped-right-float.html.
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
4329 LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region, Layou tUnit offsetFromLogicalTopOfFirstPage) const 4329 LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region, Layou tUnit offsetFromLogicalTopOfFirstPage) const
4330 { 4330 {
4331 LayoutUnit logicalRightOffset = style()->isHorizontalWritingMode() ? borderL eft() + paddingLeft() : borderTop() + paddingTop(); 4331 LayoutUnit logicalRightOffset = style()->isHorizontalWritingMode() ? borderL eft() + paddingLeft() : borderTop() + paddingTop();
4332 logicalRightOffset += availableLogicalWidth(); 4332 logicalRightOffset += availableLogicalWidth();
4333 if (!region) 4333 if (!region)
4334 return logicalRightOffset; 4334 return logicalRightOffset;
4335 LayoutRect boxRect = borderBoxRectInRegion(region, offsetFromLogicalTopOfFir stPage); 4335 LayoutRect boxRect = borderBoxRectInRegion(region, offsetFromLogicalTopOfFir stPage);
4336 return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? b oxRect.maxX() : boxRect.maxY())); 4336 return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? b oxRect.maxX() : boxRect.maxY()));
4337 } 4337 }
4338 4338
4339 LayoutUnit RenderBlock::logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUn it fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining, LayoutUnit lo gicalHeight) const 4339 LayoutUnit RenderBlock::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop, Lay outUnit fixedOffset, LayoutUnit* heightRemaining, LayoutUnit logicalHeight, Shap eOutsideFloatOffsetMode offsetMode) const
4340 { 4340 {
4341 LayoutUnit left = fixedOffset; 4341 LayoutUnit left = fixedOffset;
4342 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) { 4342 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) {
4343 if (heightRemaining) 4343 if (heightRemaining)
4344 *heightRemaining = 1; 4344 *heightRemaining = 1;
4345 4345
4346 FloatIntervalSearchAdapter<FloatingObject::FloatLeft> adapter(this, roun dToInt(logicalTop), roundToInt(logicalTop + logicalHeight), left, heightRemainin g); 4346 FloatIntervalSearchAdapter<FloatingObject::FloatLeft> adapter(this, roun dToInt(logicalTop), roundToInt(logicalTop + logicalHeight), left, heightRemainin g);
4347 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter); 4347 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter);
4348 4348
4349 if (const FloatingObject* lastFloat = adapter.lastFloat()) { 4349 const FloatingObject* lastFloat = adapter.lastFloat();
4350 if (offsetMode == ShapeOutsideFloatShapeOffset && lastFloat) {
4350 if (ExclusionShapeOutsideInfo* shapeOutside = lastFloat->renderer()- >exclusionShapeOutsideInfo()) { 4351 if (ExclusionShapeOutsideInfo* shapeOutside = lastFloat->renderer()- >exclusionShapeOutsideInfo()) {
4351 shapeOutside->computeSegmentsForLine(logicalTop - logicalTopForF loat(lastFloat) + shapeOutside->shapeLogicalTop(), logicalHeight); 4352 shapeOutside->computeSegmentsForLine(logicalTop - logicalTopForF loat(lastFloat) + shapeOutside->shapeLogicalTop(), logicalHeight);
4352 left += shapeOutside->rightSegmentShapeBoundingBoxDelta(); 4353 left += shapeOutside->rightSegmentShapeBoundingBoxDelta();
4353 } 4354 }
4354 } 4355 }
4355 } 4356 }
4357 return left;
4358 }
4359
4360 LayoutUnit RenderBlock::logicalLeftOffsetForLineWithoutFloats(LayoutUnit fixedOf fset, bool applyTextIndent) const
Julien - ping for review 2013/05/29 17:14:49 Ideally we should ASSERT that there is no floats t
4361 {
4362 LayoutUnit left = fixedOffset;
4356 4363
4357 if (applyTextIndent && style()->isLeftToRightDirection()) 4364 if (applyTextIndent && style()->isLeftToRightDirection())
4358 left += textIndentOffset(); 4365 left += textIndentOffset();
4359 4366
4360 if (style()->lineAlign() == LineAlignNone) 4367 if (style()->lineAlign() == LineAlignNone)
4361 return left; 4368 return left;
4362 4369
4363 // Push in our left offset so that it is aligned with the character grid. 4370 // Push in our left offset so that it is aligned with the character grid.
4364 LayoutState* layoutState = view()->layoutState(); 4371 LayoutState* layoutState = view()->layoutState();
4365 if (!layoutState) 4372 if (!layoutState)
(...skipping 15 matching lines...) Expand all
4381 // FIXME: This is wrong for RTL (https://bugs.webkit.org/show_bug.cgi?id=799 45). 4388 // FIXME: This is wrong for RTL (https://bugs.webkit.org/show_bug.cgi?id=799 45).
4382 // FIXME: This doesn't work with columns or regions (https://bugs.webkit.org /show_bug.cgi?id=79942). 4389 // FIXME: This doesn't work with columns or regions (https://bugs.webkit.org /show_bug.cgi?id=79942).
4383 // FIXME: This doesn't work when the inline position of the object isn't set ahead of time. 4390 // FIXME: This doesn't work when the inline position of the object isn't set ahead of time.
4384 // FIXME: Dynamic changes to the font or to the inline position need to resu lt in a deep relayout. 4391 // FIXME: Dynamic changes to the font or to the inline position need to resu lt in a deep relayout.
4385 // (https://bugs.webkit.org/show_bug.cgi?id=79944) 4392 // (https://bugs.webkit.org/show_bug.cgi?id=79944)
4386 float remainder = fmodf(maxCharWidth - fmodf(left + layoutOffset - lineGridO ffset, maxCharWidth), maxCharWidth); 4393 float remainder = fmodf(maxCharWidth - fmodf(left + layoutOffset - lineGridO ffset, maxCharWidth), maxCharWidth);
4387 left += remainder; 4394 left += remainder;
4388 return left; 4395 return left;
4389 } 4396 }
4390 4397
4391 LayoutUnit RenderBlock::logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutU nit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining, LayoutUnit l ogicalHeight) const 4398 LayoutUnit RenderBlock::logicalRightFloatOffsetForLine(LayoutUnit logicalTop, La youtUnit fixedOffset, LayoutUnit* heightRemaining, LayoutUnit logicalHeight, Sha peOutsideFloatOffsetMode offsetMode) const
4392 { 4399 {
4393 LayoutUnit right = fixedOffset; 4400 LayoutUnit right = fixedOffset;
4394 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) { 4401 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) {
4395 if (heightRemaining) 4402 if (heightRemaining)
4396 *heightRemaining = 1; 4403 *heightRemaining = 1;
4397 4404
4398 LayoutUnit rightFloatOffset = fixedOffset; 4405 LayoutUnit rightFloatOffset = fixedOffset;
4399 FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, rou ndToInt(logicalTop), roundToInt(logicalTop + logicalHeight), rightFloatOffset, h eightRemaining); 4406 FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, rou ndToInt(logicalTop), roundToInt(logicalTop + logicalHeight), rightFloatOffset, h eightRemaining);
4400 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter); 4407 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter);
4401 4408
4402 if (const FloatingObject* lastFloat = adapter.lastFloat()) { 4409 const FloatingObject* lastFloat = adapter.lastFloat();
4410 if (offsetMode == ShapeOutsideFloatShapeOffset && lastFloat) {
4403 if (ExclusionShapeOutsideInfo* shapeOutside = lastFloat->renderer()- >exclusionShapeOutsideInfo()) { 4411 if (ExclusionShapeOutsideInfo* shapeOutside = lastFloat->renderer()- >exclusionShapeOutsideInfo()) {
4404 shapeOutside->computeSegmentsForLine(logicalTop - logicalTopForF loat(lastFloat) + shapeOutside->shapeLogicalTop(), logicalHeight); 4412 shapeOutside->computeSegmentsForLine(logicalTop - logicalTopForF loat(lastFloat) + shapeOutside->shapeLogicalTop(), logicalHeight);
4405 rightFloatOffset += shapeOutside->leftSegmentShapeBoundingBoxDel ta(); 4413 rightFloatOffset += shapeOutside->leftSegmentShapeBoundingBoxDel ta();
4406 } 4414 }
4407 } 4415 }
4408 4416
4409 right = min(right, rightFloatOffset); 4417 right = min(right, rightFloatOffset);
4410 } 4418 }
4419 return right;
4420 }
4411 4421
4422 LayoutUnit RenderBlock::logicalRightOffsetForLineWithoutFloats(LayoutUnit fixedO ffset, bool applyTextIndent) const
Julien - ping for review 2013/05/29 17:14:49 Ditto.
4423 {
4424 LayoutUnit right = fixedOffset;
4425
4412 if (applyTextIndent && !style()->isLeftToRightDirection()) 4426 if (applyTextIndent && !style()->isLeftToRightDirection())
4413 right -= textIndentOffset(); 4427 right -= textIndentOffset();
4414 4428
4415 if (style()->lineAlign() == LineAlignNone) 4429 if (style()->lineAlign() == LineAlignNone)
4416 return right; 4430 return right;
4417 4431
4418 // Push in our right offset so that it is aligned with the character grid. 4432 // Push in our right offset so that it is aligned with the character grid.
4419 LayoutState* layoutState = view()->layoutState(); 4433 LayoutState* layoutState = view()->layoutState();
4420 if (!layoutState) 4434 if (!layoutState)
4421 return right; 4435 return right;
(...skipping 3714 matching lines...) Expand 10 before | Expand all | Expand 10 after
8136 { 8150 {
8137 memoryInstrumentation->addRootObject(gColumnInfoMap, WebCoreMemoryTypes::Ren deringStructures); 8151 memoryInstrumentation->addRootObject(gColumnInfoMap, WebCoreMemoryTypes::Ren deringStructures);
8138 memoryInstrumentation->addRootObject(gPositionedDescendantsMap, WebCoreMemor yTypes::RenderingStructures); 8152 memoryInstrumentation->addRootObject(gPositionedDescendantsMap, WebCoreMemor yTypes::RenderingStructures);
8139 memoryInstrumentation->addRootObject(gPercentHeightDescendantsMap, WebCoreMe moryTypes::RenderingStructures); 8153 memoryInstrumentation->addRootObject(gPercentHeightDescendantsMap, WebCoreMe moryTypes::RenderingStructures);
8140 memoryInstrumentation->addRootObject(gPositionedContainerMap, WebCoreMemoryT ypes::RenderingStructures); 8154 memoryInstrumentation->addRootObject(gPositionedContainerMap, WebCoreMemoryT ypes::RenderingStructures);
8141 memoryInstrumentation->addRootObject(gPercentHeightContainerMap, WebCoreMemo ryTypes::RenderingStructures); 8155 memoryInstrumentation->addRootObject(gPercentHeightContainerMap, WebCoreMemo ryTypes::RenderingStructures);
8142 memoryInstrumentation->addRootObject(gDelayedUpdateScrollInfoSet, WebCoreMem oryTypes::RenderingStructures); 8156 memoryInstrumentation->addRootObject(gDelayedUpdateScrollInfoSet, WebCoreMem oryTypes::RenderingStructures);
8143 } 8157 }
8144 8158
8145 } // namespace WebCore 8159 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698