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

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

Issue 209443007: Remove shape-inside support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix Zoltan's comments Created 6 years, 9 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 struct SameSizeAsRenderBlock : public RenderBox { 79 struct SameSizeAsRenderBlock : public RenderBox {
80 void* pointers[1]; 80 void* pointers[1];
81 RenderObjectChildList children; 81 RenderObjectChildList children;
82 RenderLineBoxList lineBoxes; 82 RenderLineBoxList lineBoxes;
83 uint32_t bitfields; 83 uint32_t bitfields;
84 }; 84 };
85 85
86 struct SameSizeAsRenderBlockRareData { 86 struct SameSizeAsRenderBlockRareData {
87 int paginationStrut; 87 int paginationStrut;
88 int pageLogicalOffset; 88 int pageLogicalOffset;
89 void* pointers[1];
90 uint32_t bitfields; 89 uint32_t bitfields;
91 }; 90 };
92 91
93 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock _should_stay_small); 92 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock _should_stay_small);
94 COMPILE_ASSERT(sizeof(RenderBlock::RenderBlockRareData) == sizeof(SameSizeAsRend erBlockRareData), RenderBlockRareData_should_stay_small); 93 COMPILE_ASSERT(sizeof(RenderBlock::RenderBlockRareData) == sizeof(SameSizeAsRend erBlockRareData), RenderBlockRareData_should_stay_small);
95 94
96 typedef WTF::HashMap<const RenderBox*, OwnPtr<ColumnInfo> > ColumnInfoMap; 95 typedef WTF::HashMap<const RenderBox*, OwnPtr<ColumnInfo> > ColumnInfoMap;
97 static ColumnInfoMap* gColumnInfoMap = 0; 96 static ColumnInfoMap* gColumnInfoMap = 0;
98 97
99 static TrackedDescendantsMap* gPositionedDescendantsMap = 0; 98 static TrackedDescendantsMap* gPositionedDescendantsMap = 0;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 || oldStyle->paddingTop() != newStyle->paddingTop() 320 || oldStyle->paddingTop() != newStyle->paddingTop()
322 || oldStyle->paddingBottom() != newStyle->paddingBottom(); 321 || oldStyle->paddingBottom() != newStyle->paddingBottom();
323 } 322 }
324 323
325 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le) 324 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le)
326 { 325 {
327 RenderBox::styleDidChange(diff, oldStyle); 326 RenderBox::styleDidChange(diff, oldStyle);
328 327
329 RenderStyle* newStyle = style(); 328 RenderStyle* newStyle = style();
330 329
331 updateShapeInsideInfoAfterStyleChange(newStyle->resolvedShapeInside(), oldSt yle ? oldStyle->resolvedShapeInside() : RenderStyle::initialShapeInside());
332
333 if (!isAnonymousBlock()) { 330 if (!isAnonymousBlock()) {
334 // Ensure that all of our continuation blocks pick up the new style. 331 // Ensure that all of our continuation blocks pick up the new style.
335 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) { 332 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) {
336 RenderBoxModelObject* nextCont = currCont->continuation(); 333 RenderBoxModelObject* nextCont = currCont->continuation();
337 currCont->setContinuation(0); 334 currCont->setContinuation(0);
338 currCont->setStyle(newStyle); 335 currCont->setStyle(newStyle);
339 currCont->setContinuation(nextCont); 336 currCont->setContinuation(nextCont);
340 } 337 }
341 } 338 }
342 339
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 1317
1321 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? 1318 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ?
1322 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible; 1319 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible;
1323 1320
1324 for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end( ); it != end; ++it) 1321 for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end( ); it != end; ++it)
1325 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm ageResourceVisibility(*it, status); 1322 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm ageResourceVisibility(*it, status);
1326 1323
1327 return true; 1324 return true;
1328 } 1325 }
1329 1326
1330 void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset)
1331 {
1332 LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height ();
1333 if (!left || !child || child->shapeInsideInfo() || !layoutShapeInsideInfo())
1334 return;
1335 // Propagate layout markers only up to the child, as we are still in the mid dle
1336 // of a layout pass
1337 child->setNormalChildNeedsLayout(true);
1338 child->markShapeInsideDescendantsForLayout();
1339 child->layoutIfNeeded();
1340 }
1341
1342 ShapeInsideInfo* RenderBlock::layoutShapeInsideInfo() const
1343 {
1344 if (ShapeInsideInfo* shapeInsideInfo = view()->layoutState()->shapeInsideInf o())
1345 return shapeInsideInfo;
1346
1347 RenderFlowThread* flowThread = flowThreadContainingBlock();
1348 if (allowsShapeInsideInfoSharing(flowThread)) {
1349 LayoutUnit lineHeight = this->lineHeight(false, isHorizontalWritingMode( ) ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
1350 // regionAtBlockOffset returns regions like an array first={0,N-1}, seco nd={N,M-1}, ...
1351 LayoutUnit offset = logicalHeight() + lineHeight - LayoutUnit(1);
1352 RenderRegion* region = regionAtBlockOffset(offset);
1353 if (region && region->logicalHeight())
1354 return region->shapeInsideInfo();
1355 }
1356
1357 return 0;
1358 }
1359
1360 LayoutSize RenderBlock::logicalOffsetFromShapeAncestorContainer(const RenderBloc k* container) const 1327 LayoutSize RenderBlock::logicalOffsetFromShapeAncestorContainer(const RenderBloc k* container) const
1361 { 1328 {
1362 const RenderBlock* currentBlock = this; 1329 const RenderBlock* currentBlock = this;
1363 LayoutRect blockRect(currentBlock->borderBoxRect()); 1330 LayoutRect blockRect(currentBlock->borderBoxRect());
1364 while (currentBlock && !currentBlock->isRenderFlowThread() && currentBlock ! = container) { 1331 while (currentBlock && !currentBlock->isRenderFlowThread() && currentBlock ! = container) {
1365 RenderBlock* containerBlock = currentBlock->containingBlock(); 1332 RenderBlock* containerBlock = currentBlock->containingBlock();
1366 ASSERT(containerBlock); 1333 ASSERT(containerBlock);
1367 if (!containerBlock) 1334 if (!containerBlock)
1368 return LayoutSize(); 1335 return LayoutSize();
1369 1336
(...skipping 12 matching lines...) Expand all
1382 } 1349 }
1383 1350
1384 blockRect.moveBy(currentBlock->location()); 1351 blockRect.moveBy(currentBlock->location());
1385 currentBlock = containerBlock; 1352 currentBlock = containerBlock;
1386 } 1353 }
1387 1354
1388 LayoutSize result = isHorizontalWritingMode() ? LayoutSize(blockRect.x(), bl ockRect.y()) : LayoutSize(blockRect.y(), blockRect.x()); 1355 LayoutSize result = isHorizontalWritingMode() ? LayoutSize(blockRect.x(), bl ockRect.y()) : LayoutSize(blockRect.y(), blockRect.x());
1389 return result; 1356 return result;
1390 } 1357 }
1391 1358
1392 void RenderBlock::imageChanged(WrappedImagePtr image, const IntRect*) 1359 void RenderBlock::imageChanged(WrappedImagePtr image, const IntRect*)
Bem Jones-Bey (adobe) 2014/03/27 00:09:47 Why is this method even here? It doesn't seem to d
1393 { 1360 {
1394 RenderBox::imageChanged(image); 1361 RenderBox::imageChanged(image);
1395 1362
1396 if (!parent() || !everHadLayout()) 1363 if (!parent() || !everHadLayout())
Bem Jones-Bey (adobe) 2014/03/27 00:09:47 Even if this method needs to stay, this if stateme
1397 return; 1364 return;
1398
1399 ShapeValue* shapeValue = style()->shapeInside();
1400 if (shapeValue && shapeValue->image() && shapeValue->image()->data() == imag e) {
1401 ShapeInsideInfo& shapeInsideInfo = ensureShapeInsideInfo();
1402 shapeInsideInfo.markShapeAsDirty();
1403 markShapeInsideDescendantsForLayout();
1404 }
1405 }
1406
1407 void RenderBlock::updateShapeInsideInfoAfterStyleChange(const ShapeValue* shapeI nside, const ShapeValue* oldShapeInside)
1408 {
1409 // FIXME: A future optimization would do a deep comparison for equality.
1410 if (shapeInside == oldShapeInside)
1411 return;
1412
1413 if (shapeInside) {
1414 ShapeInsideInfo& shapeInsideInfo = ensureShapeInsideInfo();
1415 shapeInsideInfo.markShapeAsDirty();
1416 } else {
1417 setShapeInsideInfo(nullptr);
1418 markShapeInsideDescendantsForLayout();
1419 }
1420 }
1421
1422 static inline bool shapeInfoRequiresRelayout(const RenderBlock* block)
1423 {
1424 ShapeInsideInfo* info = block->shapeInsideInfo();
1425 if (info)
1426 info->setNeedsLayout(info->isShapeDirty());
1427 else
1428 info = block->layoutShapeInsideInfo();
1429 return info && info->needsLayout();
1430 }
1431
1432 bool RenderBlock::updateRegionsAndShapesLogicalSize(RenderFlowThread* flowThread )
1433 {
1434 if (!flowThread && !shapeInsideInfo())
1435 return shapeInfoRequiresRelayout(this);
1436
1437 LayoutUnit oldHeight = logicalHeight();
1438 LayoutUnit oldTop = logicalTop();
1439
1440 // Compute the maximum logical height content may cause this block to expand to
1441 // FIXME: These should eventually use the const computeLogicalHeight rather than updateLogicalHeight
1442 setLogicalHeight(RenderFlowThread::maxLogicalHeight());
1443 updateLogicalHeight();
1444
1445 computeShapeSize();
1446
1447 // Set our start and end regions. No regions above or below us will be consi dered by our children. They are
1448 // effectively clamped to our region range.
1449 computeRegionRangeForBlock(flowThread);
1450
1451 setLogicalHeight(oldHeight);
1452 setLogicalTop(oldTop);
1453
1454 return shapeInfoRequiresRelayout(this);
1455 }
1456
1457 void RenderBlock::computeShapeSize()
1458 {
1459 ShapeInsideInfo* shapeInsideInfo = this->shapeInsideInfo();
1460 if (!shapeInsideInfo)
1461 return;
1462
1463 bool percentageLogicalHeightResolvable = percentageLogicalHeightIsResolvable FromBlock(this, false);
1464 shapeInsideInfo->setReferenceBoxLogicalSize(LayoutSize(logicalWidth(), perce ntageLogicalHeightResolvable ? logicalHeight() : LayoutUnit()));
1465 } 1365 }
1466 1366
1467 void RenderBlock::updateRegionsAndShapesAfterChildLayout(RenderFlowThread* flowT hread, bool heightChanged) 1367 void RenderBlock::updateRegionsAndShapesAfterChildLayout(RenderFlowThread* flowT hread, bool heightChanged)
Bem Jones-Bey (adobe) 2014/03/27 00:09:47 You should remove this method and replace all call
1468 { 1368 {
1469 // A previous sibling has changed dimension, so we need to relayout the shap e with the content
1470 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo();
1471 if (heightChanged && shapeInsideInfo)
1472 shapeInsideInfo->markShapeAsDirty();
1473
1474 computeRegionRangeForBlock(flowThread); 1369 computeRegionRangeForBlock(flowThread);
1475 } 1370 }
1476 1371
1477 void RenderBlock::computeRegionRangeForBlock(RenderFlowThread* flowThread) 1372 void RenderBlock::computeRegionRangeForBlock(RenderFlowThread* flowThread)
1478 { 1373 {
1479 if (flowThread) 1374 if (flowThread)
1480 flowThread->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage() ); 1375 flowThread->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage() );
1481 } 1376 }
1482 1377
1483 bool RenderBlock::updateLogicalWidthAndColumnWidth() 1378 bool RenderBlock::updateLogicalWidthAndColumnWidth()
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2819 afterLowest = afterLowest->prevRootBox(); 2714 afterLowest = afterLowest->prevRootBox();
2820 } 2715 }
2821 } 2716 }
2822 2717
2823 bool RenderBlock::avoidsFloats() const 2718 bool RenderBlock::avoidsFloats() const
2824 { 2719 {
2825 // Floats can't intrude into our box if we have a non-auto column count or w idth. 2720 // Floats can't intrude into our box if we have a non-auto column count or w idth.
2826 return RenderBox::avoidsFloats() || !style()->hasAutoColumnCount() || !style ()->hasAutoColumnWidth(); 2721 return RenderBox::avoidsFloats() || !style()->hasAutoColumnCount() || !style ()->hasAutoColumnWidth();
2827 } 2722 }
2828 2723
2829 void RenderBlock::markShapeInsideDescendantsForLayout()
2830 {
2831 if (!everHadLayout())
2832 return;
2833 if (childrenInline()) {
2834 setNeedsLayout();
2835 return;
2836 }
2837 for (RenderObject* child = firstChild(); child; child = child->nextSibling() ) {
2838 if (!child->isRenderBlock())
2839 continue;
2840 RenderBlock* childBlock = toRenderBlock(child);
2841 childBlock->markShapeInsideDescendantsForLayout();
2842 }
2843 }
2844
2845 bool RenderBlock::isPointInOverflowControl(HitTestResult& result, const LayoutPo int& locationInContainer, const LayoutPoint& accumulatedOffset) 2724 bool RenderBlock::isPointInOverflowControl(HitTestResult& result, const LayoutPo int& locationInContainer, const LayoutPoint& accumulatedOffset)
2846 { 2725 {
2847 if (!scrollsOverflow()) 2726 if (!scrollsOverflow())
2848 return false; 2727 return false;
2849 2728
2850 return layer()->scrollableArea()->hitTestOverflowControls(result, roundedInt Point(locationInContainer - toLayoutSize(accumulatedOffset))); 2729 return layer()->scrollableArea()->hitTestOverflowControls(result, roundedInt Point(locationInContainer - toLayoutSize(accumulatedOffset)));
2851 } 2730 }
2852 2731
2853 Node* RenderBlock::nodeForHitTest() const 2732 Node* RenderBlock::nodeForHitTest() const
2854 { 2733 {
(...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after
5023 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 4902 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5024 { 4903 {
5025 showRenderObject(); 4904 showRenderObject();
5026 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 4905 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5027 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 4906 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5028 } 4907 }
5029 4908
5030 #endif 4909 #endif
5031 4910
5032 } // namespace WebCore 4911 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698