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

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

Issue 339333002: Removing using declarations that import names in the C++ Standard library. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing mac error Created 6 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
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "core/rendering/shapes/ShapeOutsideInfo.h" 62 #include "core/rendering/shapes/ShapeOutsideInfo.h"
63 #include "core/rendering/style/ContentData.h" 63 #include "core/rendering/style/ContentData.h"
64 #include "core/rendering/style/RenderStyle.h" 64 #include "core/rendering/style/RenderStyle.h"
65 #include "platform/geometry/FloatQuad.h" 65 #include "platform/geometry/FloatQuad.h"
66 #include "platform/geometry/TransformState.h" 66 #include "platform/geometry/TransformState.h"
67 #include "platform/graphics/GraphicsContextCullSaver.h" 67 #include "platform/graphics/GraphicsContextCullSaver.h"
68 #include "platform/graphics/GraphicsContextStateSaver.h" 68 #include "platform/graphics/GraphicsContextStateSaver.h"
69 #include "wtf/StdLibExtras.h" 69 #include "wtf/StdLibExtras.h"
70 #include "wtf/TemporaryChange.h" 70 #include "wtf/TemporaryChange.h"
71 71
72 using namespace std;
73 using namespace WTF; 72 using namespace WTF;
74 using namespace Unicode; 73 using namespace Unicode;
75 74
76 namespace WebCore { 75 namespace WebCore {
77 76
78 using namespace HTMLNames; 77 using namespace HTMLNames;
79 78
80 struct SameSizeAsRenderBlock : public RenderBox { 79 struct SameSizeAsRenderBlock : public RenderBox {
81 void* pointers[1]; 80 void* pointers[1];
82 RenderObjectChildList children; 81 RenderObjectChildList children;
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 // Add in the overflow from positioned objects. 1456 // Add in the overflow from positioned objects.
1458 addOverflowFromPositionedObjects(); 1457 addOverflowFromPositionedObjects();
1459 1458
1460 if (hasOverflowClip()) { 1459 if (hasOverflowClip()) {
1461 // When we have overflow clip, propagate the original spillout since it will include collapsed bottom margins 1460 // When we have overflow clip, propagate the original spillout since it will include collapsed bottom margins
1462 // and bottom padding. Set the axis we don't care about to be 1, since we want this overflow to always 1461 // and bottom padding. Set the axis we don't care about to be 1, since we want this overflow to always
1463 // be considered reachable. 1462 // be considered reachable.
1464 LayoutRect clientRect(noOverflowRect()); 1463 LayoutRect clientRect(noOverflowRect());
1465 LayoutRect rectToApply; 1464 LayoutRect rectToApply;
1466 if (isHorizontalWritingMode()) 1465 if (isHorizontalWritingMode())
1467 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, max<Layo utUnit>(0, oldClientAfterEdge - clientRect.y())); 1466 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, std::max <LayoutUnit>(0, oldClientAfterEdge - clientRect.y()));
1468 else 1467 else
1469 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), max<LayoutU nit>(0, oldClientAfterEdge - clientRect.x()), 1); 1468 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), std::max<La youtUnit>(0, oldClientAfterEdge - clientRect.x()), 1);
1470 addLayoutOverflow(rectToApply); 1469 addLayoutOverflow(rectToApply);
1471 if (hasRenderOverflow()) 1470 if (hasRenderOverflow())
1472 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); 1471 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge);
1473 } 1472 }
1474 1473
1475 addVisualEffectOverflow(); 1474 addVisualEffectOverflow();
1476 1475
1477 addVisualOverflowFromTheme(); 1476 addVisualOverflowFromTheme();
1478 } 1477 }
1479 1478
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 2426
2428 LayoutRect RenderBlock::blockSelectionGap(RenderBlock* rootBlock, const LayoutPo int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 2427 LayoutRect RenderBlock::blockSelectionGap(RenderBlock* rootBlock, const LayoutPo int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2429 LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogicalRight, LayoutUnit logicalBottom, const Pa intInfo* paintInfo) 2428 LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogicalRight, LayoutUnit logicalBottom, const Pa intInfo* paintInfo)
2430 { 2429 {
2431 LayoutUnit logicalTop = lastLogicalTop; 2430 LayoutUnit logicalTop = lastLogicalTop;
2432 LayoutUnit logicalHeight = rootBlock->blockDirectionOffset(offsetFromRootBlo ck) + logicalBottom - logicalTop; 2431 LayoutUnit logicalHeight = rootBlock->blockDirectionOffset(offsetFromRootBlo ck) + logicalBottom - logicalTop;
2433 if (logicalHeight <= 0) 2432 if (logicalHeight <= 0)
2434 return LayoutRect(); 2433 return LayoutRect();
2435 2434
2436 // Get the selection offsets for the bottom of the gap 2435 // Get the selection offsets for the bottom of the gap
2437 LayoutUnit logicalLeft = max(lastLogicalLeft, logicalLeftSelectionOffset(roo tBlock, logicalBottom)); 2436 LayoutUnit logicalLeft = std::max(lastLogicalLeft, logicalLeftSelectionOffse t(rootBlock, logicalBottom));
2438 LayoutUnit logicalRight = min(lastLogicalRight, logicalRightSelectionOffset( rootBlock, logicalBottom)); 2437 LayoutUnit logicalRight = std::min(lastLogicalRight, logicalRightSelectionOf fset(rootBlock, logicalBottom));
2439 LayoutUnit logicalWidth = logicalRight - logicalLeft; 2438 LayoutUnit logicalWidth = logicalRight - logicalLeft;
2440 if (logicalWidth <= 0) 2439 if (logicalWidth <= 0)
2441 return LayoutRect(); 2440 return LayoutRect();
2442 2441
2443 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight)); 2442 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight));
2444 if (paintInfo) 2443 if (paintInfo)
2445 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selectionBack groundColor()); 2444 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selectionBack groundColor());
2446 return gapRect; 2445 return gapRect;
2447 } 2446 }
2448 2447
2449 LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const La youtPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 2448 LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const La youtPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2450 RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) 2449 RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo)
2451 { 2450 {
2452 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop; 2451 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2453 LayoutUnit rootBlockLogicalLeft = max(logicalLeftSelectionOffset(rootBlock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)); 2452 LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBl ock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeig ht));
2454 LayoutUnit rootBlockLogicalRight = min(rootBlock->inlineDirectionOffset(offs etFromRootBlock) + floorToInt(logicalLeft), min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight))); 2453 LayoutUnit rootBlockLogicalRight = std::min(rootBlock->inlineDirectionOffset (offsetFromRootBlock) + floorToInt(logicalLeft), std::min(logicalRightSelectionO ffset(rootBlock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight)));
2455 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 2454 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2456 if (rootBlockLogicalWidth <= 0) 2455 if (rootBlockLogicalWidth <= 0)
2457 return LayoutRect(); 2456 return LayoutRect();
2458 2457
2459 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 2458 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2460 if (paintInfo) 2459 if (paintInfo)
2461 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selec tionBackgroundColor()); 2460 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selec tionBackgroundColor());
2462 return gapRect; 2461 return gapRect;
2463 } 2462 }
2464 2463
2465 LayoutRect RenderBlock::logicalRightSelectionGap(RenderBlock* rootBlock, const L ayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 2464 LayoutRect RenderBlock::logicalRightSelectionGap(RenderBlock* rootBlock, const L ayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2466 RenderObject* selObj, LayoutUni t logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo * paintInfo) 2465 RenderObject* selObj, LayoutUni t logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo * paintInfo)
2467 { 2466 {
2468 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop; 2467 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2469 LayoutUnit rootBlockLogicalLeft = max(rootBlock->inlineDirectionOffset(offse tFromRootBlock) + floorToInt(logicalRight), max(logicalLeftSelectionOffset(rootB lock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHei ght))); 2468 LayoutUnit rootBlockLogicalLeft = std::max(rootBlock->inlineDirectionOffset( offsetFromRootBlock) + floorToInt(logicalRight), max(logicalLeftSelectionOffset( rootBlock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logic alHeight)));
2470 LayoutUnit rootBlockLogicalRight = min(logicalRightSelectionOffset(rootBlock , logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight )); 2469 LayoutUnit rootBlockLogicalRight = std::min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight));
2471 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 2470 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2472 if (rootBlockLogicalWidth <= 0) 2471 if (rootBlockLogicalWidth <= 0)
2473 return LayoutRect(); 2472 return LayoutRect();
2474 2473
2475 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 2474 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2476 if (paintInfo) 2475 if (paintInfo)
2477 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selec tionBackgroundColor()); 2476 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selec tionBackgroundColor());
2478 return gapRect; 2477 return gapRect;
2479 } 2478 }
2480 2479
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
3091 3090
3092 bool moveCaretToBoundary = document().frame()->editor().behavior().shouldMov eCaretToHorizontalBoundaryWhenPastTopOrBottom(); 3091 bool moveCaretToBoundary = document().frame()->editor().behavior().shouldMov eCaretToHorizontalBoundaryWhenPastTopOrBottom();
3093 3092
3094 if (!moveCaretToBoundary && !closestBox && lastRootBoxWithChildren) { 3093 if (!moveCaretToBoundary && !closestBox && lastRootBoxWithChildren) {
3095 // y coordinate is below last root line box, pretend we hit it 3094 // y coordinate is below last root line box, pretend we hit it
3096 closestBox = lastRootBoxWithChildren->closestLeafChildForLogicalLeftPosi tion(pointInLogicalContents.x()); 3095 closestBox = lastRootBoxWithChildren->closestLeafChildForLogicalLeftPosi tion(pointInLogicalContents.x());
3097 } 3096 }
3098 3097
3099 if (closestBox) { 3098 if (closestBox) {
3100 if (moveCaretToBoundary) { 3099 if (moveCaretToBoundary) {
3101 LayoutUnit firstRootBoxWithChildrenTop = min<LayoutUnit>(firstRootBo xWithChildren->selectionTop(), firstRootBoxWithChildren->logicalTop()); 3100 LayoutUnit firstRootBoxWithChildrenTop = std::min<LayoutUnit>(firstR ootBoxWithChildren->selectionTop(), firstRootBoxWithChildren->logicalTop());
3102 if (pointInLogicalContents.y() < firstRootBoxWithChildrenTop 3101 if (pointInLogicalContents.y() < firstRootBoxWithChildrenTop
3103 || (blocksAreFlipped && pointInLogicalContents.y() == firstRootB oxWithChildrenTop)) { 3102 || (blocksAreFlipped && pointInLogicalContents.y() == firstRootB oxWithChildrenTop)) {
3104 InlineBox* box = firstRootBoxWithChildren->firstLeafChild(); 3103 InlineBox* box = firstRootBoxWithChildren->firstLeafChild();
3105 if (box->isLineBreak()) { 3104 if (box->isLineBreak()) {
3106 if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak( )) 3105 if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak( ))
3107 box = newBox; 3106 box = newBox;
3108 } 3107 }
3109 // y coordinate is above first root line box, so return the star t of the first 3108 // y coordinate is above first root line box, so return the star t of the first
3110 return PositionWithAffinity(positionForBox(box, true), DOWNSTREA M); 3109 return PositionWithAffinity(positionForBox(box, true), DOWNSTREA M);
3111 } 3110 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3232 LayoutUnit desiredColumnWidth = contentLogicalWidth(); 3231 LayoutUnit desiredColumnWidth = contentLogicalWidth();
3233 3232
3234 // For now, we don't support multi-column layouts when printing, since we ha ve to do a lot of work for proper pagination. 3233 // For now, we don't support multi-column layouts when printing, since we ha ve to do a lot of work for proper pagination.
3235 if (document().paginated() || !style()->specifiesColumns()) { 3234 if (document().paginated() || !style()->specifiesColumns()) {
3236 setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth); 3235 setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth);
3237 return; 3236 return;
3238 } 3237 }
3239 3238
3240 LayoutUnit availWidth = desiredColumnWidth; 3239 LayoutUnit availWidth = desiredColumnWidth;
3241 LayoutUnit colGap = columnGap(); 3240 LayoutUnit colGap = columnGap();
3242 LayoutUnit colWidth = max<LayoutUnit>(1, LayoutUnit(style()->columnWidth())) ; 3241 LayoutUnit colWidth = std::max<LayoutUnit>(1, LayoutUnit(style()->columnWidt h()));
3243 int colCount = max<int>(1, style()->columnCount()); 3242 int colCount = std::max<int>(1, style()->columnCount());
3244 3243
3245 if (style()->hasAutoColumnWidth() && !style()->hasAutoColumnCount()) { 3244 if (style()->hasAutoColumnWidth() && !style()->hasAutoColumnCount()) {
3246 desiredColumnCount = colCount; 3245 desiredColumnCount = colCount;
3247 desiredColumnWidth = max<LayoutUnit>(0, (availWidth - ((desiredColumnCou nt - 1) * colGap)) / desiredColumnCount); 3246 desiredColumnWidth = std::max<LayoutUnit>(0, (availWidth - ((desiredColu mnCount - 1) * colGap)) / desiredColumnCount);
3248 } else if (!style()->hasAutoColumnWidth() && style()->hasAutoColumnCount()) { 3247 } else if (!style()->hasAutoColumnWidth() && style()->hasAutoColumnCount()) {
3249 desiredColumnCount = max<LayoutUnit>(1, (availWidth + colGap) / (colWidt h + colGap)); 3248 desiredColumnCount = std::max<LayoutUnit>(1, (availWidth + colGap) / (co lWidth + colGap));
3250 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colG ap; 3249 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colG ap;
3251 } else { 3250 } else {
3252 desiredColumnCount = max<LayoutUnit>(min<LayoutUnit>(colCount, (availWid th + colGap) / (colWidth + colGap)), 1); 3251 desiredColumnCount = std::max<LayoutUnit>(std::min<LayoutUnit>(colCount, (availWidth + colGap) / (colWidth + colGap)), 1);
3253 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colG ap; 3252 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colG ap;
3254 } 3253 }
3255 setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth); 3254 setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth);
3256 } 3255 }
3257 3256
3258 bool RenderBlock::requiresColumns(int desiredColumnCount) const 3257 bool RenderBlock::requiresColumns(int desiredColumnCount) const
3259 { 3258 {
3260 // Paged overflow is treated as multicol here, unless this element was the o ne that got its 3259 // Paged overflow is treated as multicol here, unless this element was the o ne that got its
3261 // overflow propagated to the viewport. 3260 // overflow propagated to the viewport.
3262 bool isPaginated = style()->isOverflowPaged() && node() != document().viewpo rtDefiningElement(); 3261 bool isPaginated = style()->isOverflowPaged() && node() != document().viewpo rtDefiningElement();
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3444 3443
3445 // Begin with a result rect that is empty. 3444 // Begin with a result rect that is empty.
3446 LayoutRect result; 3445 LayoutRect result;
3447 3446
3448 bool isHorizontal = isHorizontalWritingMode(); 3447 bool isHorizontal = isHorizontalWritingMode();
3449 LayoutUnit beforeBorderPadding = borderBefore() + paddingBefore(); 3448 LayoutUnit beforeBorderPadding = borderBefore() + paddingBefore();
3450 LayoutUnit colHeight = colInfo->columnHeight(); 3449 LayoutUnit colHeight = colInfo->columnHeight();
3451 if (!colHeight) 3450 if (!colHeight)
3452 return; 3451 return;
3453 3452
3454 LayoutUnit startOffset = max(isHorizontal ? r.y() : r.x(), beforeBorderPaddi ng); 3453 LayoutUnit startOffset = std::max(isHorizontal ? r.y() : r.x(), beforeBorder Padding);
3455 LayoutUnit endOffset = max(min<LayoutUnit>(isHorizontal ? r.maxY() : r.maxX( ), beforeBorderPadding + colCount * colHeight), beforeBorderPadding); 3454 LayoutUnit endOffset = std::max(std::min<LayoutUnit>(isHorizontal ? r.maxY() : r.maxX(), beforeBorderPadding + colCount * colHeight), beforeBorderPadding);
3456 3455
3457 // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibli ng4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744 3456 // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibli ng4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744
3458 unsigned startColumn = (startOffset - beforeBorderPadding) / colHeight; 3457 unsigned startColumn = (startOffset - beforeBorderPadding) / colHeight;
3459 unsigned endColumn = (endOffset - beforeBorderPadding) / colHeight; 3458 unsigned endColumn = (endOffset - beforeBorderPadding) / colHeight;
3460 3459
3461 if (startColumn == endColumn) { 3460 if (startColumn == endColumn) {
3462 // The rect is fully contained within one column. Adjust for our offsets 3461 // The rect is fully contained within one column. Adjust for our offsets
3463 // and repaint only that portion. 3462 // and repaint only that portion.
3464 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); 3463 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent();
3465 LayoutRect colRect = columnRectAt(colInfo, startColumn); 3464 LayoutRect colRect = columnRectAt(colInfo, startColumn);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3558 3557
3559 void RenderBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay outUnit& maxLogicalWidth) const 3558 void RenderBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay outUnit& maxLogicalWidth) const
3560 { 3559 {
3561 if (childrenInline()) { 3560 if (childrenInline()) {
3562 // FIXME: Remove this const_cast. 3561 // FIXME: Remove this const_cast.
3563 toRenderBlockFlow(const_cast<RenderBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth); 3562 toRenderBlockFlow(const_cast<RenderBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth);
3564 } else { 3563 } else {
3565 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth); 3564 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
3566 } 3565 }
3567 3566
3568 maxLogicalWidth = max(minLogicalWidth, maxLogicalWidth); 3567 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
3569 3568
3570 adjustIntrinsicLogicalWidthsForColumns(minLogicalWidth, maxLogicalWidth); 3569 adjustIntrinsicLogicalWidthsForColumns(minLogicalWidth, maxLogicalWidth);
3571 3570
3572 // A horizontal marquee with inline children has no minimum width. 3571 // A horizontal marquee with inline children has no minimum width.
3573 if (childrenInline() && isMarquee() && toRenderMarquee(this)->isHorizontal() ) 3572 if (childrenInline() && isMarquee() && toRenderMarquee(this)->isHorizontal() )
3574 minLogicalWidth = 0; 3573 minLogicalWidth = 0;
3575 3574
3576 if (isTableCell()) { 3575 if (isTableCell()) {
3577 Length tableCellWidth = toRenderTableCell(this)->styleOrColLogicalWidth( ); 3576 Length tableCellWidth = toRenderTableCell(this)->styleOrColLogicalWidth( );
3578 if (tableCellWidth.isFixed() && tableCellWidth.value() > 0) 3577 if (tableCellWidth.isFixed() && tableCellWidth.value() > 0)
3579 maxLogicalWidth = max(minLogicalWidth, adjustContentBoxLogicalWidthF orBoxSizing(tableCellWidth.value())); 3578 maxLogicalWidth = std::max(minLogicalWidth, adjustContentBoxLogicalW idthForBoxSizing(tableCellWidth.value()));
3580 } 3579 }
3581 3580
3582 int scrollbarWidth = instrinsicScrollbarLogicalWidth(); 3581 int scrollbarWidth = instrinsicScrollbarLogicalWidth();
3583 maxLogicalWidth += scrollbarWidth; 3582 maxLogicalWidth += scrollbarWidth;
3584 minLogicalWidth += scrollbarWidth; 3583 minLogicalWidth += scrollbarWidth;
3585 } 3584 }
3586 3585
3587 void RenderBlock::computePreferredLogicalWidths() 3586 void RenderBlock::computePreferredLogicalWidths()
3588 { 3587 {
3589 ASSERT(preferredLogicalWidthsDirty()); 3588 ASSERT(preferredLogicalWidthsDirty());
3590 3589
3591 updateFirstLetter(); 3590 updateFirstLetter();
3592 3591
3593 m_minPreferredLogicalWidth = 0; 3592 m_minPreferredLogicalWidth = 0;
3594 m_maxPreferredLogicalWidth = 0; 3593 m_maxPreferredLogicalWidth = 0;
3595 3594
3596 // FIXME: The isFixed() calls here should probably be checking for isSpecifi ed since you 3595 // FIXME: The isFixed() calls here should probably be checking for isSpecifi ed since you
3597 // should be able to use percentage, calc or viewport relative values for wi dth. 3596 // should be able to use percentage, calc or viewport relative values for wi dth.
3598 RenderStyle* styleToUse = style(); 3597 RenderStyle* styleToUse = style();
3599 if (!isTableCell() && styleToUse->logicalWidth().isFixed() && styleToUse->lo gicalWidth().value() >= 0 3598 if (!isTableCell() && styleToUse->logicalWidth().isFixed() && styleToUse->lo gicalWidth().value() >= 0
3600 && !(isDeprecatedFlexItem() && !styleToUse->logicalWidth().intValue())) 3599 && !(isDeprecatedFlexItem() && !styleToUse->logicalWidth().intValue()))
3601 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentB oxLogicalWidthForBoxSizing(styleToUse->logicalWidth().value()); 3600 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentB oxLogicalWidthForBoxSizing(styleToUse->logicalWidth().value());
3602 else 3601 else
3603 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred LogicalWidth); 3602 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred LogicalWidth);
3604 3603
3605 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth() .value() > 0) { 3604 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth() .value() > 0) {
3606 m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustConte ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); 3605 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
3607 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustConte ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); 3606 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
3608 } 3607 }
3609 3608
3610 if (styleToUse->logicalMaxWidth().isFixed()) { 3609 if (styleToUse->logicalMaxWidth().isFixed()) {
3611 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustConte ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); 3610 m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
3612 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustConte ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); 3611 m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
3613 } 3612 }
3614 3613
3615 // Table layout uses integers, ceil the preferred widths to ensure that they can contain the contents. 3614 // Table layout uses integers, ceil the preferred widths to ensure that they can contain the contents.
3616 if (isTableCell()) { 3615 if (isTableCell()) {
3617 m_minPreferredLogicalWidth = m_minPreferredLogicalWidth.ceil(); 3616 m_minPreferredLogicalWidth = m_minPreferredLogicalWidth.ceil();
3618 m_maxPreferredLogicalWidth = m_maxPreferredLogicalWidth.ceil(); 3617 m_maxPreferredLogicalWidth = m_maxPreferredLogicalWidth.ceil();
3619 } 3618 }
3620 3619
3621 LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth(); 3620 LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth();
3622 m_minPreferredLogicalWidth += borderAndPadding; 3621 m_minPreferredLogicalWidth += borderAndPadding;
3623 m_maxPreferredLogicalWidth += borderAndPadding; 3622 m_maxPreferredLogicalWidth += borderAndPadding;
3624 3623
3625 clearPreferredLogicalWidthsDirty(); 3624 clearPreferredLogicalWidthsDirty();
3626 } 3625 }
3627 3626
3628 void RenderBlock::adjustIntrinsicLogicalWidthsForColumns(LayoutUnit& minLogicalW idth, LayoutUnit& maxLogicalWidth) const 3627 void RenderBlock::adjustIntrinsicLogicalWidthsForColumns(LayoutUnit& minLogicalW idth, LayoutUnit& maxLogicalWidth) const
3629 { 3628 {
3630 if (!style()->hasAutoColumnCount() || !style()->hasAutoColumnWidth()) { 3629 if (!style()->hasAutoColumnCount() || !style()->hasAutoColumnWidth()) {
3631 // The min/max intrinsic widths calculated really tell how much space el ements need when 3630 // The min/max intrinsic widths calculated really tell how much space el ements need when
3632 // laid out inside the columns. In order to eventually end up with the d esired column width, 3631 // laid out inside the columns. In order to eventually end up with the d esired column width,
3633 // we need to convert them to values pertaining to the multicol containe r. 3632 // we need to convert them to values pertaining to the multicol containe r.
3634 int columnCount = style()->hasAutoColumnCount() ? 1 : style()->columnCou nt(); 3633 int columnCount = style()->hasAutoColumnCount() ? 1 : style()->columnCou nt();
3635 LayoutUnit columnWidth; 3634 LayoutUnit columnWidth;
3636 LayoutUnit gapExtra = (columnCount - 1) * columnGap(); 3635 LayoutUnit gapExtra = (columnCount - 1) * columnGap();
3637 if (style()->hasAutoColumnWidth()) { 3636 if (style()->hasAutoColumnWidth()) {
3638 minLogicalWidth = minLogicalWidth * columnCount + gapExtra; 3637 minLogicalWidth = minLogicalWidth * columnCount + gapExtra;
3639 } else { 3638 } else {
3640 columnWidth = style()->columnWidth(); 3639 columnWidth = style()->columnWidth();
3641 minLogicalWidth = min(minLogicalWidth, columnWidth); 3640 minLogicalWidth = std::min(minLogicalWidth, columnWidth);
3642 } 3641 }
3643 // FIXME: If column-count is auto here, we should resolve it to calculat e the maximum 3642 // FIXME: If column-count is auto here, we should resolve it to calculat e the maximum
3644 // intrinsic width, instead of pretending that it's 1. The only way to d o that is by 3643 // intrinsic width, instead of pretending that it's 1. The only way to d o that is by
3645 // performing a layout pass, but this is not an appropriate time or plac e for layout. The 3644 // performing a layout pass, but this is not an appropriate time or plac e for layout. The
3646 // good news is that if height is unconstrained and there are no explici t breaks, the 3645 // good news is that if height is unconstrained and there are no explici t breaks, the
3647 // resolved column-count really should be 1. 3646 // resolved column-count really should be 1.
3648 maxLogicalWidth = max(maxLogicalWidth, columnWidth) * columnCount + gapE xtra; 3647 maxLogicalWidth = std::max(maxLogicalWidth, columnWidth) * columnCount + gapExtra;
3649 } 3648 }
3650 } 3649 }
3651 3650
3652 void RenderBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth , LayoutUnit& maxLogicalWidth) const 3651 void RenderBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth , LayoutUnit& maxLogicalWidth) const
3653 { 3652 {
3654 RenderStyle* styleToUse = style(); 3653 RenderStyle* styleToUse = style();
3655 bool nowrap = styleToUse->whiteSpace() == NOWRAP; 3654 bool nowrap = styleToUse->whiteSpace() == NOWRAP;
3656 3655
3657 RenderObject* child = firstChild(); 3656 RenderObject* child = firstChild();
3658 RenderBlock* containingBlock = this->containingBlock(); 3657 RenderBlock* containingBlock = this->containingBlock();
3659 LayoutUnit floatLeftWidth = 0, floatRightWidth = 0; 3658 LayoutUnit floatLeftWidth = 0, floatRightWidth = 0;
3660 while (child) { 3659 while (child) {
3661 // Positioned children don't affect the min/max width 3660 // Positioned children don't affect the min/max width
3662 if (child->isOutOfFlowPositioned()) { 3661 if (child->isOutOfFlowPositioned()) {
3663 child = child->nextSibling(); 3662 child = child->nextSibling();
3664 continue; 3663 continue;
3665 } 3664 }
3666 3665
3667 RenderStyle* childStyle = child->style(); 3666 RenderStyle* childStyle = child->style();
3668 if (child->isFloating() || (child->isBox() && toRenderBox(child)->avoids Floats())) { 3667 if (child->isFloating() || (child->isBox() && toRenderBox(child)->avoids Floats())) {
3669 LayoutUnit floatTotalWidth = floatLeftWidth + floatRightWidth; 3668 LayoutUnit floatTotalWidth = floatLeftWidth + floatRightWidth;
3670 if (childStyle->clear() & CLEFT) { 3669 if (childStyle->clear() & CLEFT) {
3671 maxLogicalWidth = max(floatTotalWidth, maxLogicalWidth); 3670 maxLogicalWidth = std::max(floatTotalWidth, maxLogicalWidth);
3672 floatLeftWidth = 0; 3671 floatLeftWidth = 0;
3673 } 3672 }
3674 if (childStyle->clear() & CRIGHT) { 3673 if (childStyle->clear() & CRIGHT) {
3675 maxLogicalWidth = max(floatTotalWidth, maxLogicalWidth); 3674 maxLogicalWidth = std::max(floatTotalWidth, maxLogicalWidth);
3676 floatRightWidth = 0; 3675 floatRightWidth = 0;
3677 } 3676 }
3678 } 3677 }
3679 3678
3680 // A margin basically has three types: fixed, percentage, and auto (vari able). 3679 // A margin basically has three types: fixed, percentage, and auto (vari able).
3681 // Auto and percentage margins simply become 0 when computing min/max wi dth. 3680 // Auto and percentage margins simply become 0 when computing min/max wi dth.
3682 // Fixed margins can be added in as is. 3681 // Fixed margins can be added in as is.
3683 Length startMarginLength = childStyle->marginStartUsing(styleToUse); 3682 Length startMarginLength = childStyle->marginStartUsing(styleToUse);
3684 Length endMarginLength = childStyle->marginEndUsing(styleToUse); 3683 Length endMarginLength = childStyle->marginEndUsing(styleToUse);
3685 LayoutUnit margin = 0; 3684 LayoutUnit margin = 0;
(...skipping 10 matching lines...) Expand all
3696 RenderBox* childBox = toRenderBox(child); 3695 RenderBox* childBox = toRenderBox(child);
3697 LogicalExtentComputedValues computedValues; 3696 LogicalExtentComputedValues computedValues;
3698 childBox->computeLogicalHeight(childBox->borderAndPaddingLogicalHeig ht(), 0, computedValues); 3697 childBox->computeLogicalHeight(childBox->borderAndPaddingLogicalHeig ht(), 0, computedValues);
3699 childMinPreferredLogicalWidth = childMaxPreferredLogicalWidth = comp utedValues.m_extent; 3698 childMinPreferredLogicalWidth = childMaxPreferredLogicalWidth = comp utedValues.m_extent;
3700 } else { 3699 } else {
3701 childMinPreferredLogicalWidth = child->minPreferredLogicalWidth(); 3700 childMinPreferredLogicalWidth = child->minPreferredLogicalWidth();
3702 childMaxPreferredLogicalWidth = child->maxPreferredLogicalWidth(); 3701 childMaxPreferredLogicalWidth = child->maxPreferredLogicalWidth();
3703 } 3702 }
3704 3703
3705 LayoutUnit w = childMinPreferredLogicalWidth + margin; 3704 LayoutUnit w = childMinPreferredLogicalWidth + margin;
3706 minLogicalWidth = max(w, minLogicalWidth); 3705 minLogicalWidth = std::max(w, minLogicalWidth);
3707 3706
3708 // IE ignores tables for calculation of nowrap. Makes some sense. 3707 // IE ignores tables for calculation of nowrap. Makes some sense.
3709 if (nowrap && !child->isTable()) 3708 if (nowrap && !child->isTable())
3710 maxLogicalWidth = max(w, maxLogicalWidth); 3709 maxLogicalWidth = std::max(w, maxLogicalWidth);
3711 3710
3712 w = childMaxPreferredLogicalWidth + margin; 3711 w = childMaxPreferredLogicalWidth + margin;
3713 3712
3714 if (!child->isFloating()) { 3713 if (!child->isFloating()) {
3715 if (child->isBox() && toRenderBox(child)->avoidsFloats()) { 3714 if (child->isBox() && toRenderBox(child)->avoidsFloats()) {
3716 // Determine a left and right max value based off whether or not the floats can fit in the 3715 // Determine a left and right max value based off whether or not the floats can fit in the
3717 // margins of the object. For negative margins, we will attempt to overlap the float if the negative margin 3716 // margins of the object. For negative margins, we will attempt to overlap the float if the negative margin
3718 // is smaller than the float width. 3717 // is smaller than the float width.
3719 bool ltr = containingBlock ? containingBlock->style()->isLeftToR ightDirection() : styleToUse->isLeftToRightDirection(); 3718 bool ltr = containingBlock ? containingBlock->style()->isLeftToR ightDirection() : styleToUse->isLeftToRightDirection();
3720 LayoutUnit marginLogicalLeft = ltr ? marginStart : marginEnd; 3719 LayoutUnit marginLogicalLeft = ltr ? marginStart : marginEnd;
3721 LayoutUnit marginLogicalRight = ltr ? marginEnd : marginStart; 3720 LayoutUnit marginLogicalRight = ltr ? marginEnd : marginStart;
3722 LayoutUnit maxLeft = marginLogicalLeft > 0 ? max(floatLeftWidth, marginLogicalLeft) : floatLeftWidth + marginLogicalLeft; 3721 LayoutUnit maxLeft = marginLogicalLeft > 0 ? std::max(floatLeftW idth, marginLogicalLeft) : floatLeftWidth + marginLogicalLeft;
3723 LayoutUnit maxRight = marginLogicalRight > 0 ? max(floatRightWid th, marginLogicalRight) : floatRightWidth + marginLogicalRight; 3722 LayoutUnit maxRight = marginLogicalRight > 0 ? std::max(floatRig htWidth, marginLogicalRight) : floatRightWidth + marginLogicalRight;
3724 w = childMaxPreferredLogicalWidth + maxLeft + maxRight; 3723 w = childMaxPreferredLogicalWidth + maxLeft + maxRight;
3725 w = max(w, floatLeftWidth + floatRightWidth); 3724 w = std::max(w, floatLeftWidth + floatRightWidth);
3725 } else {
3726 maxLogicalWidth = std::max(floatLeftWidth + floatRightWidth, max LogicalWidth);
3726 } 3727 }
3727 else
3728 maxLogicalWidth = max(floatLeftWidth + floatRightWidth, maxLogic alWidth);
3729 floatLeftWidth = floatRightWidth = 0; 3728 floatLeftWidth = floatRightWidth = 0;
3730 } 3729 }
3731 3730
3732 if (child->isFloating()) { 3731 if (child->isFloating()) {
3733 if (childStyle->floating() == LeftFloat) 3732 if (childStyle->floating() == LeftFloat)
3734 floatLeftWidth += w; 3733 floatLeftWidth += w;
3735 else 3734 else
3736 floatRightWidth += w; 3735 floatRightWidth += w;
3737 } else 3736 } else {
3738 maxLogicalWidth = max(w, maxLogicalWidth); 3737 maxLogicalWidth = std::max(w, maxLogicalWidth);
3738 }
3739 3739
3740 child = child->nextSibling(); 3740 child = child->nextSibling();
3741 } 3741 }
3742 3742
3743 // Always make sure these values are non-negative. 3743 // Always make sure these values are non-negative.
3744 minLogicalWidth = max<LayoutUnit>(0, minLogicalWidth); 3744 minLogicalWidth = std::max<LayoutUnit>(0, minLogicalWidth);
3745 maxLogicalWidth = max<LayoutUnit>(0, maxLogicalWidth); 3745 maxLogicalWidth = std::max<LayoutUnit>(0, maxLogicalWidth);
3746 3746
3747 maxLogicalWidth = max(floatLeftWidth + floatRightWidth, maxLogicalWidth); 3747 maxLogicalWidth = std::max(floatLeftWidth + floatRightWidth, maxLogicalWidth );
3748 } 3748 }
3749 3749
3750 bool RenderBlock::hasLineIfEmpty() const 3750 bool RenderBlock::hasLineIfEmpty() const
3751 { 3751 {
3752 if (!node()) 3752 if (!node())
3753 return false; 3753 return false;
3754 3754
3755 if (node()->isRootEditableElement()) 3755 if (node()->isRootEditableElement())
3756 return true; 3756 return true;
3757 3757
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
4288 } 4288 }
4289 4289
4290 void RenderBlock::adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutUnit& right) const 4290 void RenderBlock::adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutUnit& right) const
4291 { 4291 {
4292 // We don't deal with relative positioning. Our assumption is that you shri nk to fit the lines without accounting 4292 // We don't deal with relative positioning. Our assumption is that you shri nk to fit the lines without accounting
4293 // for either overflow or translations via relative positioning. 4293 // for either overflow or translations via relative positioning.
4294 if (style()->visibility() == VISIBLE) { 4294 if (style()->visibility() == VISIBLE) {
4295 if (childrenInline()) { 4295 if (childrenInline()) {
4296 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBo x()) { 4296 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBo x()) {
4297 if (box->firstChild()) 4297 if (box->firstChild())
4298 left = min(left, x + static_cast<LayoutUnit>(box->firstChild ()->x())); 4298 left = std::min(left, x + static_cast<LayoutUnit>(box->first Child()->x()));
4299 if (box->lastChild()) 4299 if (box->lastChild())
4300 right = max(right, x + static_cast<LayoutUnit>(ceilf(box->la stChild()->logicalRight()))); 4300 right = std::max(right, x + static_cast<LayoutUnit>(ceilf(bo x->lastChild()->logicalRight())));
4301 } 4301 }
4302 } else { 4302 } else {
4303 for (RenderBox* obj = firstChildBox(); obj; obj = obj->nextSiblingBo x()) { 4303 for (RenderBox* obj = firstChildBox(); obj; obj = obj->nextSiblingBo x()) {
4304 if (!obj->isFloatingOrOutOfFlowPositioned()) { 4304 if (!obj->isFloatingOrOutOfFlowPositioned()) {
4305 if (obj->isRenderBlockFlow() && !obj->hasOverflowClip()) 4305 if (obj->isRenderBlockFlow() && !obj->hasOverflowClip())
4306 toRenderBlock(obj)->adjustForBorderFit(x + obj->x(), lef t, right); 4306 toRenderBlock(obj)->adjustForBorderFit(x + obj->x(), lef t, right);
4307 else if (obj->style()->visibility() == VISIBLE) { 4307 else if (obj->style()->visibility() == VISIBLE) {
4308 // We are a replaced element or some kind of non-block-f low object. 4308 // We are a replaced element or some kind of non-block-f low object.
4309 left = min(left, x + obj->x()); 4309 left = std::min(left, x + obj->x());
4310 right = max(right, x + obj->x() + obj->width()); 4310 right = std::max(right, x + obj->x() + obj->width());
4311 } 4311 }
4312 } 4312 }
4313 } 4313 }
4314 } 4314 }
4315 } 4315 }
4316 } 4316 }
4317 4317
4318 void RenderBlock::fitBorderToLinesIfNeeded() 4318 void RenderBlock::fitBorderToLinesIfNeeded()
4319 { 4319 {
4320 if (style()->borderFit() == BorderFitBorder || hasOverrideWidth()) 4320 if (style()->borderFit() == BorderFitBorder || hasOverrideWidth())
4321 return; 4321 return;
4322 4322
4323 // Walk any normal flow lines to snugly fit. 4323 // Walk any normal flow lines to snugly fit.
4324 LayoutUnit left = LayoutUnit::max(); 4324 LayoutUnit left = LayoutUnit::max();
4325 LayoutUnit right = LayoutUnit::min(); 4325 LayoutUnit right = LayoutUnit::min();
4326 LayoutUnit oldWidth = contentWidth(); 4326 LayoutUnit oldWidth = contentWidth();
4327 adjustForBorderFit(0, left, right); 4327 adjustForBorderFit(0, left, right);
4328 4328
4329 // Clamp to our existing edges. We can never grow. We only shrink. 4329 // Clamp to our existing edges. We can never grow. We only shrink.
4330 LayoutUnit leftEdge = borderLeft() + paddingLeft(); 4330 LayoutUnit leftEdge = borderLeft() + paddingLeft();
4331 LayoutUnit rightEdge = leftEdge + oldWidth; 4331 LayoutUnit rightEdge = leftEdge + oldWidth;
4332 left = min(rightEdge, max(leftEdge, left)); 4332 left = std::min(rightEdge, std::max(leftEdge, left));
4333 right = max(left, min(rightEdge, right)); 4333 right = std::max(left, std::min(rightEdge, right));
4334 4334
4335 LayoutUnit newContentWidth = right - left; 4335 LayoutUnit newContentWidth = right - left;
4336 if (newContentWidth == oldWidth) 4336 if (newContentWidth == oldWidth)
4337 return; 4337 return;
4338 4338
4339 setOverrideLogicalContentWidth(newContentWidth); 4339 setOverrideLogicalContentWidth(newContentWidth);
4340 layoutBlock(false); 4340 layoutBlock(false);
4341 clearOverrideLogicalContentWidth(); 4341 clearOverrideLogicalContentWidth();
4342 } 4342 }
4343 4343
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
4539 LayoutUnit topMargin = prevInlineHasLineBox ? collapsedMarginBefore() : LayoutUnit(); 4539 LayoutUnit topMargin = prevInlineHasLineBox ? collapsedMarginBefore() : LayoutUnit();
4540 LayoutUnit bottomMargin = nextInlineHasLineBox ? collapsedMarginAfter() : LayoutUnit(); 4540 LayoutUnit bottomMargin = nextInlineHasLineBox ? collapsedMarginAfter() : LayoutUnit();
4541 LayoutRect rect(additionalOffset.x(), additionalOffset.y() - topMargin, width(), height() + topMargin + bottomMargin); 4541 LayoutRect rect(additionalOffset.x(), additionalOffset.y() - topMargin, width(), height() + topMargin + bottomMargin);
4542 if (!rect.isEmpty()) 4542 if (!rect.isEmpty())
4543 rects.append(pixelSnappedIntRect(rect)); 4543 rects.append(pixelSnappedIntRect(rect));
4544 } else if (width() && height()) 4544 } else if (width() && height())
4545 rects.append(pixelSnappedIntRect(additionalOffset, size())); 4545 rects.append(pixelSnappedIntRect(additionalOffset, size()));
4546 4546
4547 if (!hasOverflowClip() && !hasControlClip()) { 4547 if (!hasOverflowClip() && !hasControlClip()) {
4548 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBo x()) { 4548 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBo x()) {
4549 LayoutUnit top = max<LayoutUnit>(curr->lineTop(), curr->top()); 4549 LayoutUnit top = std::max<LayoutUnit>(curr->lineTop(), curr->top());
4550 LayoutUnit bottom = min<LayoutUnit>(curr->lineBottom(), curr->top() + curr->height()); 4550 LayoutUnit bottom = std::min<LayoutUnit>(curr->lineBottom(), curr->t op() + curr->height());
4551 LayoutRect rect(additionalOffset.x() + curr->x(), additionalOffset.y () + top, curr->width(), bottom - top); 4551 LayoutRect rect(additionalOffset.x() + curr->x(), additionalOffset.y () + top, curr->width(), bottom - top);
4552 if (!rect.isEmpty()) 4552 if (!rect.isEmpty())
4553 rects.append(pixelSnappedIntRect(rect)); 4553 rects.append(pixelSnappedIntRect(rect));
4554 } 4554 }
4555 4555
4556 addChildFocusRingRects(rects, additionalOffset, paintContainer); 4556 addChildFocusRingRects(rects, additionalOffset, paintContainer);
4557 } 4557 }
4558 4558
4559 if (inlineElementContinuation()) 4559 if (inlineElementContinuation())
4560 inlineElementContinuation()->addFocusRingRects(rects, flooredLayoutPoint (additionalOffset + inlineElementContinuation()->containingBlock()->location() - location()), paintContainer); 4560 inlineElementContinuation()->addFocusRingRects(rects, flooredLayoutPoint (additionalOffset + inlineElementContinuation()->containingBlock()->location() - location()), paintContainer);
4561 } 4561 }
4562 4562
4563 void RenderBlock::computeSelfHitTestRects(Vector<LayoutRect>& rects, const Layou tPoint& layerOffset) const 4563 void RenderBlock::computeSelfHitTestRects(Vector<LayoutRect>& rects, const Layou tPoint& layerOffset) const
4564 { 4564 {
4565 RenderBox::computeSelfHitTestRects(rects, layerOffset); 4565 RenderBox::computeSelfHitTestRects(rects, layerOffset);
4566 4566
4567 if (hasHorizontalLayoutOverflow() || hasVerticalLayoutOverflow()) { 4567 if (hasHorizontalLayoutOverflow() || hasVerticalLayoutOverflow()) {
4568 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBo x()) { 4568 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBo x()) {
4569 LayoutUnit top = max<LayoutUnit>(curr->lineTop(), curr->top()); 4569 LayoutUnit top = std::max<LayoutUnit>(curr->lineTop(), curr->top());
4570 LayoutUnit bottom = min<LayoutUnit>(curr->lineBottom(), curr->top() + curr->height()); 4570 LayoutUnit bottom = std::min<LayoutUnit>(curr->lineBottom(), curr->t op() + curr->height());
4571 LayoutRect rect(layerOffset.x() + curr->x(), layerOffset.y() + top, curr->width(), bottom - top); 4571 LayoutRect rect(layerOffset.x() + curr->x(), layerOffset.y() + top, curr->width(), bottom - top);
4572 // It's common for this rect to be entirely contained in our box, so exclude that simple case. 4572 // It's common for this rect to be entirely contained in our box, so exclude that simple case.
4573 if (!rect.isEmpty() && (rects.isEmpty() || !rects[0].contains(rect)) ) 4573 if (!rect.isEmpty() && (rects.isEmpty() || !rects[0].contains(rect)) )
4574 rects.append(rect); 4574 rects.append(rect);
4575 } 4575 }
4576 } 4576 }
4577 } 4577 }
4578 4578
4579 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par ent) const 4579 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par ent) const
4580 { 4580 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4674 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) 4674 if (RenderFlowThread* flowThread = flowThreadContainingBlock())
4675 flowThread->updateMinimumPageHeight(offsetFromLogicalTopOfFirstPage() + offset, minHeight); 4675 flowThread->updateMinimumPageHeight(offsetFromLogicalTopOfFirstPage() + offset, minHeight);
4676 else if (ColumnInfo* colInfo = view()->layoutState()->columnInfo()) 4676 else if (ColumnInfo* colInfo = view()->layoutState()->columnInfo())
4677 colInfo->updateMinimumColumnHeight(minHeight); 4677 colInfo->updateMinimumColumnHeight(minHeight);
4678 } 4678 }
4679 4679
4680 static inline LayoutUnit calculateMinimumPageHeight(RenderStyle* renderStyle, Ro otInlineBox* lastLine, LayoutUnit lineTop, LayoutUnit lineBottom) 4680 static inline LayoutUnit calculateMinimumPageHeight(RenderStyle* renderStyle, Ro otInlineBox* lastLine, LayoutUnit lineTop, LayoutUnit lineBottom)
4681 { 4681 {
4682 // We may require a certain minimum number of lines per page in order to sat isfy 4682 // We may require a certain minimum number of lines per page in order to sat isfy
4683 // orphans and widows, and that may affect the minimum page height. 4683 // orphans and widows, and that may affect the minimum page height.
4684 unsigned lineCount = max<unsigned>(renderStyle->hasAutoOrphans() ? 1 : rende rStyle->orphans(), renderStyle->hasAutoWidows() ? 1 : renderStyle->widows()); 4684 unsigned lineCount = std::max<unsigned>(renderStyle->hasAutoOrphans() ? 1 : renderStyle->orphans(), renderStyle->hasAutoWidows() ? 1 : renderStyle->widows() );
4685 if (lineCount > 1) { 4685 if (lineCount > 1) {
4686 RootInlineBox* line = lastLine; 4686 RootInlineBox* line = lastLine;
4687 for (unsigned i = 1; i < lineCount && line->prevRootBox(); i++) 4687 for (unsigned i = 1; i < lineCount && line->prevRootBox(); i++)
4688 line = line->prevRootBox(); 4688 line = line->prevRootBox();
4689 4689
4690 // FIXME: Paginating using line overflow isn't all fine. See FIXME in 4690 // FIXME: Paginating using line overflow isn't all fine. See FIXME in
4691 // adjustLinePositionForPagination() for more details. 4691 // adjustLinePositionForPagination() for more details.
4692 LayoutRect overflow = line->logicalVisualOverflowRect(line->lineTop(), l ine->lineBottom()); 4692 LayoutRect overflow = line->logicalVisualOverflowRect(line->lineTop(), l ine->lineBottom());
4693 lineTop = min(line->lineTopWithLeading(), overflow.y()); 4693 lineTop = std::min(line->lineTopWithLeading(), overflow.y());
4694 } 4694 }
4695 return lineBottom - lineTop; 4695 return lineBottom - lineTop;
4696 } 4696 }
4697 4697
4698 void RenderBlock::adjustLinePositionForPagination(RootInlineBox* lineBox, Layout Unit& delta, RenderFlowThread* flowThread) 4698 void RenderBlock::adjustLinePositionForPagination(RootInlineBox* lineBox, Layout Unit& delta, RenderFlowThread* flowThread)
4699 { 4699 {
4700 // FIXME: For now we paginate using line overflow. This ensures that lines don't overlap at all when we 4700 // FIXME: For now we paginate using line overflow. This ensures that lines don't overlap at all when we
4701 // put a strut between them for pagination purposes. However, this really i sn't the desired rendering, since 4701 // put a strut between them for pagination purposes. However, this really i sn't the desired rendering, since
4702 // the line on the top of the next page will appear too far down relative to the same kind of line at the top 4702 // the line on the top of the next page will appear too far down relative to the same kind of line at the top
4703 // of the first column. 4703 // of the first column.
4704 // 4704 //
4705 // The rendering we would like to see is one where the lineTopWithLeading is at the top of the column, and any line overflow 4705 // The rendering we would like to see is one where the lineTopWithLeading is at the top of the column, and any line overflow
4706 // simply spills out above the top of the column. This effect would match w hat happens at the top of the first column. 4706 // simply spills out above the top of the column. This effect would match w hat happens at the top of the first column.
4707 // We can't achieve this rendering, however, until we stop columns from clip ping to the column bounds (thus allowing 4707 // We can't achieve this rendering, however, until we stop columns from clip ping to the column bounds (thus allowing
4708 // for overflow to occur), and then cache visible overflow for each column r ect. 4708 // for overflow to occur), and then cache visible overflow for each column r ect.
4709 // 4709 //
4710 // Furthermore, the paint we have to do when a column has overflow has to be special. We need to exclude 4710 // Furthermore, the paint we have to do when a column has overflow has to be special. We need to exclude
4711 // content that paints in a previous column (and content that paints in the following column). 4711 // content that paints in a previous column (and content that paints in the following column).
4712 // 4712 //
4713 // For now we'll at least honor the lineTopWithLeading when paginating if it is above the logical top overflow. This will 4713 // For now we'll at least honor the lineTopWithLeading when paginating if it is above the logical top overflow. This will
4714 // at least make positive leading work in typical cases. 4714 // at least make positive leading work in typical cases.
4715 // 4715 //
4716 // FIXME: Another problem with simply moving lines is that the available lin e width may change (because of floats). 4716 // FIXME: Another problem with simply moving lines is that the available lin e width may change (because of floats).
4717 // Technically if the location we move the line to has a different line widt h than our old position, then we need to dirty the 4717 // Technically if the location we move the line to has a different line widt h than our old position, then we need to dirty the
4718 // line and all following lines. 4718 // line and all following lines.
4719 LayoutRect logicalVisualOverflow = lineBox->logicalVisualOverflowRect(lineBo x->lineTop(), lineBox->lineBottom()); 4719 LayoutRect logicalVisualOverflow = lineBox->logicalVisualOverflowRect(lineBo x->lineTop(), lineBox->lineBottom());
4720 LayoutUnit logicalOffset = min(lineBox->lineTopWithLeading(), logicalVisualO verflow.y()); 4720 LayoutUnit logicalOffset = std::min(lineBox->lineTopWithLeading(), logicalVi sualOverflow.y());
4721 LayoutUnit logicalBottom = max(lineBox->lineBottomWithLeading(), logicalVisu alOverflow.maxY()); 4721 LayoutUnit logicalBottom = std::max(lineBox->lineBottomWithLeading(), logica lVisualOverflow.maxY());
4722 LayoutUnit lineHeight = logicalBottom - logicalOffset; 4722 LayoutUnit lineHeight = logicalBottom - logicalOffset;
4723 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(style(), l ineBox, logicalOffset, logicalBottom)); 4723 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(style(), l ineBox, logicalOffset, logicalBottom));
4724 logicalOffset += delta; 4724 logicalOffset += delta;
4725 lineBox->setPaginationStrut(0); 4725 lineBox->setPaginationStrut(0);
4726 lineBox->setIsFirstAfterPageBreak(false); 4726 lineBox->setIsFirstAfterPageBreak(false);
4727 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 4727 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
4728 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni formLogicalHeight(); 4728 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni formLogicalHeight();
4729 // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflo w.height() still fits, we are 4729 // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflo w.height() still fits, we are
4730 // still going to add a strut, so that the visible overflow fits on a single page. 4730 // still going to add a strut, so that the visible overflow fits on a single page.
4731 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverf low.height() > pageLogicalHeight)) 4731 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverf low.height() > pageLogicalHeight))
4732 // FIXME: In case the line aligns with the top of the page (or it's slig htly shifted downwards) it will not be marked as the first line in the page. 4732 // FIXME: In case the line aligns with the top of the page (or it's slig htly shifted downwards) it will not be marked as the first line in the page.
4733 // From here, the fix is not straightforward because it's not easy to al ways determine when the current line is the first in the page. 4733 // From here, the fix is not straightforward because it's not easy to al ways determine when the current line is the first in the page.
4734 return; 4734 return;
4735 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); 4735 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary);
4736 4736
4737 int lineIndex = lineCount(lineBox); 4737 int lineIndex = lineCount(lineBox);
4738 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) { 4738 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) {
4739 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) { 4739 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) {
4740 clearShouldBreakAtLineToAvoidWidow(); 4740 clearShouldBreakAtLineToAvoidWidow();
4741 setDidBreakAtLineToAvoidWidow(); 4741 setDidBreakAtLineToAvoidWidow();
4742 } 4742 }
4743 if (lineHeight > pageLogicalHeight) { 4743 if (lineHeight > pageLogicalHeight) {
4744 // Split the top margin in order to avoid splitting the visible part of the line. 4744 // Split the top margin in order to avoid splitting the visible part of the line.
4745 remainingLogicalHeight -= min(lineHeight - pageLogicalHeight, max<La youtUnit>(0, logicalVisualOverflow.y() - lineBox->lineTopWithLeading())); 4745 remainingLogicalHeight -= std::min(lineHeight - pageLogicalHeight, s td::max<LayoutUnit>(0, logicalVisualOverflow.y() - lineBox->lineTopWithLeading() ));
4746 } 4746 }
4747 LayoutUnit totalLogicalHeight = lineHeight + max<LayoutUnit>(0, logicalO ffset); 4747 LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, log icalOffset);
4748 LayoutUnit pageLogicalHeightAtNewOffset = hasUniformPageLogicalHeight ? pageLogicalHeight : pageLogicalHeightForOffset(logicalOffset + remainingLogicalH eight); 4748 LayoutUnit pageLogicalHeightAtNewOffset = hasUniformPageLogicalHeight ? pageLogicalHeight : pageLogicalHeightForOffset(logicalOffset + remainingLogicalH eight);
4749 setPageBreak(logicalOffset, lineHeight - remainingLogicalHeight); 4749 setPageBreak(logicalOffset, lineHeight - remainingLogicalHeight);
4750 if (((lineBox == firstRootBox() && totalLogicalHeight < pageLogicalHeigh tAtNewOffset) || (!style()->hasAutoOrphans() && style()->orphans() >= lineIndex) ) 4750 if (((lineBox == firstRootBox() && totalLogicalHeight < pageLogicalHeigh tAtNewOffset) || (!style()->hasAutoOrphans() && style()->orphans() >= lineIndex) )
4751 && !isOutOfFlowPositioned() && !isTableCell()) 4751 && !isOutOfFlowPositioned() && !isTableCell())
4752 setPaginationStrut(remainingLogicalHeight + max<LayoutUnit>(0, logic alOffset)); 4752 setPaginationStrut(remainingLogicalHeight + std::max<LayoutUnit>(0, logicalOffset));
4753 else { 4753 else {
4754 delta += remainingLogicalHeight; 4754 delta += remainingLogicalHeight;
4755 lineBox->setPaginationStrut(remainingLogicalHeight); 4755 lineBox->setPaginationStrut(remainingLogicalHeight);
4756 lineBox->setIsFirstAfterPageBreak(true); 4756 lineBox->setIsFirstAfterPageBreak(true);
4757 } 4757 }
4758 } else if (remainingLogicalHeight == pageLogicalHeight) { 4758 } else if (remainingLogicalHeight == pageLogicalHeight) {
4759 // We're at the very top of a page or column. 4759 // We're at the very top of a page or column.
4760 if (lineBox != firstRootBox()) 4760 if (lineBox != firstRootBox())
4761 lineBox->setIsFirstAfterPageBreak(true); 4761 lineBox->setIsFirstAfterPageBreak(true);
4762 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) 4762 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage())
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
5025 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5025 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5026 { 5026 {
5027 showRenderObject(); 5027 showRenderObject();
5028 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5028 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5029 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5029 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5030 } 5030 }
5031 5031
5032 #endif 5032 #endif
5033 5033
5034 } // namespace WebCore 5034 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698