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

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, 6 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 3979 matching lines...) Expand 10 before | Expand all | Expand 10 after
3990 3990
3991 LayoutUnit floatLogicalWidth = min(logicalWidthForFloat(floatingObject), log icalRightOffset - logicalLeftOffset); // The width we look for. 3991 LayoutUnit floatLogicalWidth = min(logicalWidthForFloat(floatingObject), log icalRightOffset - logicalLeftOffset); // The width we look for.
3992 3992
3993 LayoutUnit floatLogicalLeft; 3993 LayoutUnit floatLogicalLeft;
3994 3994
3995 bool insideFlowThread = flowThreadContainingBlock(); 3995 bool insideFlowThread = flowThreadContainingBlock();
3996 3996
3997 if (childBox->style()->floating() == LeftFloat) { 3997 if (childBox->style()->floating() == LeftFloat) {
3998 LayoutUnit heightRemainingLeft = 1; 3998 LayoutUnit heightRemainingLeft = 1;
3999 LayoutUnit heightRemainingRight = 1; 3999 LayoutUnit heightRemainingRight = 1;
4000 floatLogicalLeft = logicalLeftOffsetForLine(logicalTopOffset, logicalLef tOffset, false, &heightRemainingLeft); 4000 floatLogicalLeft = logicalLeftOffsetForLineUsingFloatBoundingBox(logical TopOffset, logicalLeftOffset, false, &heightRemainingLeft);
4001 while (logicalRightOffsetForLine(logicalTopOffset, logicalRightOffset, f alse, &heightRemainingRight) - floatLogicalLeft < floatLogicalWidth) { 4001 while (logicalRightOffsetForLineUsingFloatBoundingBox(logicalTopOffset, logicalRightOffset, false, &heightRemainingRight) - floatLogicalLeft < floatLogi calWidth) {
4002 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); 4002 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight);
4003 floatLogicalLeft = logicalLeftOffsetForLine(logicalTopOffset, logica lLeftOffset, false, &heightRemainingLeft); 4003 floatLogicalLeft = logicalLeftOffsetForLineUsingFloatBoundingBox(log icalTopOffset, logicalLeftOffset, false, &heightRemainingLeft);
4004 if (insideFlowThread) { 4004 if (insideFlowThread) {
4005 // Have to re-evaluate all of our offsets, since they may have c hanged. 4005 // Have to re-evaluate all of our offsets, since they may have c hanged.
4006 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset. 4006 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset.
4007 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset. 4007 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset.
4008 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset); 4008 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset);
4009 } 4009 }
4010 } 4010 }
4011 floatLogicalLeft = max(logicalLeftOffset - borderAndPaddingLogicalLeft() , floatLogicalLeft); 4011 floatLogicalLeft = max(logicalLeftOffset - borderAndPaddingLogicalLeft() , floatLogicalLeft);
4012 } else { 4012 } else {
4013 LayoutUnit heightRemainingLeft = 1; 4013 LayoutUnit heightRemainingLeft = 1;
4014 LayoutUnit heightRemainingRight = 1; 4014 LayoutUnit heightRemainingRight = 1;
4015 floatLogicalLeft = logicalRightOffsetForLine(logicalTopOffset, logicalRi ghtOffset, false, &heightRemainingRight); 4015 floatLogicalLeft = logicalRightOffsetForLineUsingFloatBoundingBox(logica lTopOffset, logicalRightOffset, false, &heightRemainingRight);
4016 while (floatLogicalLeft - logicalLeftOffsetForLine(logicalTopOffset, log icalLeftOffset, false, &heightRemainingLeft) < floatLogicalWidth) { 4016 while (floatLogicalLeft - logicalLeftOffsetForLineUsingFloatBoundingBox( logicalTopOffset, logicalLeftOffset, false, &heightRemainingLeft) < floatLogical Width) {
4017 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); 4017 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight);
4018 floatLogicalLeft = logicalRightOffsetForLine(logicalTopOffset, logic alRightOffset, false, &heightRemainingRight); 4018 floatLogicalLeft = logicalRightOffsetForLineUsingFloatBoundingBox(lo gicalTopOffset, logicalRightOffset, false, &heightRemainingRight);
4019 if (insideFlowThread) { 4019 if (insideFlowThread) {
4020 // Have to re-evaluate all of our offsets, since they may have c hanged. 4020 // Have to re-evaluate all of our offsets, since they may have c hanged.
4021 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset. 4021 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset.
4022 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset. 4022 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset.
4023 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset); 4023 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset);
4024 } 4024 }
4025 } 4025 }
4026 floatLogicalLeft -= logicalWidthForFloat(floatingObject); // Use the ori ginal width of the float here, since the local variable 4026 floatLogicalLeft -= logicalWidthForFloat(floatingObject); // Use the ori ginal width of the float here, since the local variable
4027 // |floatLogic alWidth| was capped to the available line width. 4027 // |floatLogic alWidth| was capped to the available line width.
4028 // See fast/bl ock/float/clamped-right-float.html. 4028 // See fast/bl ock/float/clamped-right-float.html.
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
4293 LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region, Layou tUnit offsetFromLogicalTopOfFirstPage) const 4293 LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region, Layou tUnit offsetFromLogicalTopOfFirstPage) const
4294 { 4294 {
4295 LayoutUnit logicalRightOffset = style()->isHorizontalWritingMode() ? borderL eft() + paddingLeft() : borderTop() + paddingTop(); 4295 LayoutUnit logicalRightOffset = style()->isHorizontalWritingMode() ? borderL eft() + paddingLeft() : borderTop() + paddingTop();
4296 logicalRightOffset += availableLogicalWidth(); 4296 logicalRightOffset += availableLogicalWidth();
4297 if (!region) 4297 if (!region)
4298 return logicalRightOffset; 4298 return logicalRightOffset;
4299 LayoutRect boxRect = borderBoxRectInRegion(region, offsetFromLogicalTopOfFir stPage); 4299 LayoutRect boxRect = borderBoxRectInRegion(region, offsetFromLogicalTopOfFir stPage);
4300 return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? b oxRect.maxX() : boxRect.maxY())); 4300 return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? b oxRect.maxX() : boxRect.maxY()));
4301 } 4301 }
4302 4302
4303 LayoutUnit RenderBlock::logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUn it fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining, LayoutUnit lo gicalHeight) const 4303 LayoutUnit RenderBlock::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop, Lay outUnit fixedOffset, LayoutUnit* heightRemaining, LayoutUnit logicalHeight, Shap eOutsideFloatOffsetMode offsetMode) const
4304 { 4304 {
4305 LayoutUnit left = fixedOffset; 4305 LayoutUnit left = fixedOffset;
4306 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) { 4306 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) {
4307 if (heightRemaining) 4307 if (heightRemaining)
4308 *heightRemaining = 1; 4308 *heightRemaining = 1;
4309 4309
4310 FloatIntervalSearchAdapter<FloatingObject::FloatLeft> adapter(this, roun dToInt(logicalTop), roundToInt(logicalTop + logicalHeight), left, heightRemainin g); 4310 FloatIntervalSearchAdapter<FloatingObject::FloatLeft> adapter(this, roun dToInt(logicalTop), roundToInt(logicalTop + logicalHeight), left, heightRemainin g);
4311 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter); 4311 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter);
4312 4312
4313 if (const FloatingObject* lastFloat = adapter.lastFloat()) { 4313 const FloatingObject* lastFloat = adapter.lastFloat();
4314 if (offsetMode == ShapeOutsideFloatShapeOffset && lastFloat) {
4314 if (ExclusionShapeOutsideInfo* shapeOutside = lastFloat->renderer()- >exclusionShapeOutsideInfo()) { 4315 if (ExclusionShapeOutsideInfo* shapeOutside = lastFloat->renderer()- >exclusionShapeOutsideInfo()) {
4315 shapeOutside->computeSegmentsForLine(logicalTop - logicalTopForF loat(lastFloat) + shapeOutside->shapeLogicalTop(), logicalHeight); 4316 shapeOutside->computeSegmentsForLine(logicalTop - logicalTopForF loat(lastFloat) + shapeOutside->shapeLogicalTop(), logicalHeight);
4316 left += shapeOutside->rightSegmentShapeBoundingBoxDelta(); 4317 left += shapeOutside->rightSegmentShapeBoundingBoxDelta();
4317 } 4318 }
4318 } 4319 }
4319 } 4320 }
4321 return left;
4322 }
4323
4324 LayoutUnit RenderBlock::logicalLeftOffsetForLineWithoutFloats(LayoutUnit offsetF romFloats, bool applyTextIndent) const
4325 {
4326 LayoutUnit left = offsetFromFloats;
4320 4327
4321 if (applyTextIndent && style()->isLeftToRightDirection()) 4328 if (applyTextIndent && style()->isLeftToRightDirection())
4322 left += textIndentOffset(); 4329 left += textIndentOffset();
4323 4330
4324 if (style()->lineAlign() == LineAlignNone) 4331 if (style()->lineAlign() == LineAlignNone)
4325 return left; 4332 return left;
4326 4333
4327 // Push in our left offset so that it is aligned with the character grid. 4334 // Push in our left offset so that it is aligned with the character grid.
4328 LayoutState* layoutState = view()->layoutState(); 4335 LayoutState* layoutState = view()->layoutState();
4329 if (!layoutState) 4336 if (!layoutState)
(...skipping 15 matching lines...) Expand all
4345 // FIXME: This is wrong for RTL (https://bugs.webkit.org/show_bug.cgi?id=799 45). 4352 // FIXME: This is wrong for RTL (https://bugs.webkit.org/show_bug.cgi?id=799 45).
4346 // FIXME: This doesn't work with columns or regions (https://bugs.webkit.org /show_bug.cgi?id=79942). 4353 // FIXME: This doesn't work with columns or regions (https://bugs.webkit.org /show_bug.cgi?id=79942).
4347 // FIXME: This doesn't work when the inline position of the object isn't set ahead of time. 4354 // FIXME: This doesn't work when the inline position of the object isn't set ahead of time.
4348 // FIXME: Dynamic changes to the font or to the inline position need to resu lt in a deep relayout. 4355 // FIXME: Dynamic changes to the font or to the inline position need to resu lt in a deep relayout.
4349 // (https://bugs.webkit.org/show_bug.cgi?id=79944) 4356 // (https://bugs.webkit.org/show_bug.cgi?id=79944)
4350 float remainder = fmodf(maxCharWidth - fmodf(left + layoutOffset - lineGridO ffset, maxCharWidth), maxCharWidth); 4357 float remainder = fmodf(maxCharWidth - fmodf(left + layoutOffset - lineGridO ffset, maxCharWidth), maxCharWidth);
4351 left += remainder; 4358 left += remainder;
4352 return left; 4359 return left;
4353 } 4360 }
4354 4361
4355 LayoutUnit RenderBlock::logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutU nit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining, LayoutUnit l ogicalHeight) const 4362 LayoutUnit RenderBlock::logicalRightFloatOffsetForLine(LayoutUnit logicalTop, La youtUnit fixedOffset, LayoutUnit* heightRemaining, LayoutUnit logicalHeight, Sha peOutsideFloatOffsetMode offsetMode) const
4356 { 4363 {
4357 LayoutUnit right = fixedOffset; 4364 LayoutUnit right = fixedOffset;
4358 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) { 4365 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) {
4359 if (heightRemaining) 4366 if (heightRemaining)
4360 *heightRemaining = 1; 4367 *heightRemaining = 1;
4361 4368
4362 LayoutUnit rightFloatOffset = fixedOffset; 4369 LayoutUnit rightFloatOffset = fixedOffset;
4363 FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, rou ndToInt(logicalTop), roundToInt(logicalTop + logicalHeight), rightFloatOffset, h eightRemaining); 4370 FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, rou ndToInt(logicalTop), roundToInt(logicalTop + logicalHeight), rightFloatOffset, h eightRemaining);
4364 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter); 4371 m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter);
4365 4372
4366 if (const FloatingObject* lastFloat = adapter.lastFloat()) { 4373 const FloatingObject* lastFloat = adapter.lastFloat();
4374 if (offsetMode == ShapeOutsideFloatShapeOffset && lastFloat) {
4367 if (ExclusionShapeOutsideInfo* shapeOutside = lastFloat->renderer()- >exclusionShapeOutsideInfo()) { 4375 if (ExclusionShapeOutsideInfo* shapeOutside = lastFloat->renderer()- >exclusionShapeOutsideInfo()) {
4368 shapeOutside->computeSegmentsForLine(logicalTop - logicalTopForF loat(lastFloat) + shapeOutside->shapeLogicalTop(), logicalHeight); 4376 shapeOutside->computeSegmentsForLine(logicalTop - logicalTopForF loat(lastFloat) + shapeOutside->shapeLogicalTop(), logicalHeight);
4369 rightFloatOffset += shapeOutside->leftSegmentShapeBoundingBoxDel ta(); 4377 rightFloatOffset += shapeOutside->leftSegmentShapeBoundingBoxDel ta();
4370 } 4378 }
4371 } 4379 }
4372 4380
4373 right = min(right, rightFloatOffset); 4381 right = min(right, rightFloatOffset);
4374 } 4382 }
4383 return right;
4384 }
4375 4385
4386 LayoutUnit RenderBlock::logicalRightOffsetForLineWithoutFloats(LayoutUnit offset FromFloats, bool applyTextIndent) const
Julien - ping for review 2013/06/06 20:49:08 I am unsure about what this function intents to do
4387 {
4388 LayoutUnit right = offsetFromFloats;
4389
4376 if (applyTextIndent && !style()->isLeftToRightDirection()) 4390 if (applyTextIndent && !style()->isLeftToRightDirection())
4377 right -= textIndentOffset(); 4391 right -= textIndentOffset();
4378 4392
4379 if (style()->lineAlign() == LineAlignNone) 4393 if (style()->lineAlign() == LineAlignNone)
4380 return right; 4394 return right;
4381 4395
4382 // Push in our right offset so that it is aligned with the character grid. 4396 // Push in our right offset so that it is aligned with the character grid.
4383 LayoutState* layoutState = view()->layoutState(); 4397 LayoutState* layoutState = view()->layoutState();
4384 if (!layoutState) 4398 if (!layoutState)
4385 return right; 4399 return right;
(...skipping 3714 matching lines...) Expand 10 before | Expand all | Expand 10 after
8100 { 8114 {
8101 memoryInstrumentation->addRootObject(gColumnInfoMap, WebCoreMemoryTypes::Ren deringStructures); 8115 memoryInstrumentation->addRootObject(gColumnInfoMap, WebCoreMemoryTypes::Ren deringStructures);
8102 memoryInstrumentation->addRootObject(gPositionedDescendantsMap, WebCoreMemor yTypes::RenderingStructures); 8116 memoryInstrumentation->addRootObject(gPositionedDescendantsMap, WebCoreMemor yTypes::RenderingStructures);
8103 memoryInstrumentation->addRootObject(gPercentHeightDescendantsMap, WebCoreMe moryTypes::RenderingStructures); 8117 memoryInstrumentation->addRootObject(gPercentHeightDescendantsMap, WebCoreMe moryTypes::RenderingStructures);
8104 memoryInstrumentation->addRootObject(gPositionedContainerMap, WebCoreMemoryT ypes::RenderingStructures); 8118 memoryInstrumentation->addRootObject(gPositionedContainerMap, WebCoreMemoryT ypes::RenderingStructures);
8105 memoryInstrumentation->addRootObject(gPercentHeightContainerMap, WebCoreMemo ryTypes::RenderingStructures); 8119 memoryInstrumentation->addRootObject(gPercentHeightContainerMap, WebCoreMemo ryTypes::RenderingStructures);
8106 memoryInstrumentation->addRootObject(gDelayedUpdateScrollInfoSet, WebCoreMem oryTypes::RenderingStructures); 8120 memoryInstrumentation->addRootObject(gDelayedUpdateScrollInfoSet, WebCoreMem oryTypes::RenderingStructures);
8107 } 8121 }
8108 8122
8109 } // namespace WebCore 8123 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698