OLD | NEW |
---|---|
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 Loading... | |
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 || oldStyle->paddingTop() != newStyle->paddingTop() | 319 || oldStyle->paddingTop() != newStyle->paddingTop() |
321 || oldStyle->paddingBottom() != newStyle->paddingBottom(); | 320 || oldStyle->paddingBottom() != newStyle->paddingBottom(); |
322 } | 321 } |
323 | 322 |
324 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le) | 323 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le) |
325 { | 324 { |
326 RenderBox::styleDidChange(diff, oldStyle); | 325 RenderBox::styleDidChange(diff, oldStyle); |
327 | 326 |
328 RenderStyle* newStyle = style(); | 327 RenderStyle* newStyle = style(); |
329 | 328 |
330 updateShapeInsideInfoAfterStyleChange(newStyle->resolvedShapeInside(), oldSt yle ? oldStyle->resolvedShapeInside() : RenderStyle::initialShapeInside()); | |
331 | |
332 if (!isAnonymousBlock()) { | 329 if (!isAnonymousBlock()) { |
333 // Ensure that all of our continuation blocks pick up the new style. | 330 // Ensure that all of our continuation blocks pick up the new style. |
334 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) { | 331 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) { |
335 RenderBoxModelObject* nextCont = currCont->continuation(); | 332 RenderBoxModelObject* nextCont = currCont->continuation(); |
336 currCont->setContinuation(0); | 333 currCont->setContinuation(0); |
337 currCont->setStyle(newStyle); | 334 currCont->setStyle(newStyle); |
338 currCont->setContinuation(nextCont); | 335 currCont->setContinuation(nextCont); |
339 } | 336 } |
340 } | 337 } |
341 | 338 |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1319 | 1316 |
1320 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? | 1317 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? |
1321 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible; | 1318 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible; |
1322 | 1319 |
1323 for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end( ); it != end; ++it) | 1320 for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end( ); it != end; ++it) |
1324 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm ageResourceVisibility(*it, status); | 1321 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm ageResourceVisibility(*it, status); |
1325 | 1322 |
1326 return true; | 1323 return true; |
1327 } | 1324 } |
1328 | 1325 |
1329 void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset) | |
1330 { | |
1331 LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height (); | |
1332 if (!left || !child || child->shapeInsideInfo() || !layoutShapeInsideInfo()) | |
1333 return; | |
1334 // Propagate layout markers only up to the child, as we are still in the mid dle | |
1335 // of a layout pass | |
1336 child->setNormalChildNeedsLayout(true); | |
1337 child->markShapeInsideDescendantsForLayout(); | |
1338 child->layoutIfNeeded(); | |
1339 } | |
1340 | |
1341 ShapeInsideInfo* RenderBlock::layoutShapeInsideInfo() const | |
1342 { | |
1343 if (ShapeInsideInfo* shapeInsideInfo = view()->layoutState()->shapeInsideInf o()) | |
1344 return shapeInsideInfo; | |
1345 | |
1346 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
1347 if (allowsShapeInsideInfoSharing(flowThread)) { | |
1348 LayoutUnit lineHeight = this->lineHeight(false, isHorizontalWritingMode( ) ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); | |
1349 // regionAtBlockOffset returns regions like an array first={0,N-1}, seco nd={N,M-1}, ... | |
1350 LayoutUnit offset = logicalHeight() + lineHeight - LayoutUnit(1); | |
1351 RenderRegion* region = regionAtBlockOffset(offset); | |
1352 if (region && region->logicalHeight()) | |
1353 return region->shapeInsideInfo(); | |
1354 } | |
1355 | |
1356 return 0; | |
1357 } | |
1358 | |
1359 LayoutSize RenderBlock::logicalOffsetFromShapeAncestorContainer(const RenderBloc k* container) const | 1326 LayoutSize RenderBlock::logicalOffsetFromShapeAncestorContainer(const RenderBloc k* container) const |
1360 { | 1327 { |
1361 const RenderBlock* currentBlock = this; | 1328 const RenderBlock* currentBlock = this; |
1362 LayoutRect blockRect(currentBlock->borderBoxRect()); | 1329 LayoutRect blockRect(currentBlock->borderBoxRect()); |
1363 while (currentBlock && !currentBlock->isRenderFlowThread() && currentBlock ! = container) { | 1330 while (currentBlock && !currentBlock->isRenderFlowThread() && currentBlock ! = container) { |
1364 RenderBlock* containerBlock = currentBlock->containingBlock(); | 1331 RenderBlock* containerBlock = currentBlock->containingBlock(); |
1365 ASSERT(containerBlock); | 1332 ASSERT(containerBlock); |
1366 if (!containerBlock) | 1333 if (!containerBlock) |
1367 return LayoutSize(); | 1334 return LayoutSize(); |
1368 | 1335 |
(...skipping 18 matching lines...) Expand all Loading... | |
1387 LayoutSize result = isHorizontalWritingMode() ? LayoutSize(blockRect.x(), bl ockRect.y()) : LayoutSize(blockRect.y(), blockRect.x()); | 1354 LayoutSize result = isHorizontalWritingMode() ? LayoutSize(blockRect.x(), bl ockRect.y()) : LayoutSize(blockRect.y(), blockRect.x()); |
1388 return result; | 1355 return result; |
1389 } | 1356 } |
1390 | 1357 |
1391 void RenderBlock::imageChanged(WrappedImagePtr image, const IntRect*) | 1358 void RenderBlock::imageChanged(WrappedImagePtr image, const IntRect*) |
1392 { | 1359 { |
1393 RenderBox::imageChanged(image); | 1360 RenderBox::imageChanged(image); |
1394 | 1361 |
1395 if (!parent() || !everHadLayout()) | 1362 if (!parent() || !everHadLayout()) |
1396 return; | 1363 return; |
1397 | |
1398 ShapeValue* shapeValue = style()->shapeInside(); | |
1399 if (shapeValue && shapeValue->image() && shapeValue->image()->data() == imag e) { | |
1400 ShapeInsideInfo& shapeInsideInfo = ensureShapeInsideInfo(); | |
1401 shapeInsideInfo.markShapeAsDirty(); | |
1402 markShapeInsideDescendantsForLayout(); | |
1403 } | |
1404 } | |
1405 | |
1406 void RenderBlock::updateShapeInsideInfoAfterStyleChange(const ShapeValue* shapeI nside, const ShapeValue* oldShapeInside) | |
1407 { | |
1408 // FIXME: A future optimization would do a deep comparison for equality. | |
1409 if (shapeInside == oldShapeInside) | |
1410 return; | |
1411 | |
1412 if (shapeInside) { | |
1413 ShapeInsideInfo& shapeInsideInfo = ensureShapeInsideInfo(); | |
1414 shapeInsideInfo.markShapeAsDirty(); | |
1415 } else { | |
1416 setShapeInsideInfo(nullptr); | |
1417 markShapeInsideDescendantsForLayout(); | |
1418 } | |
1419 } | |
1420 | |
1421 static inline bool shapeInfoRequiresRelayout(const RenderBlock* block) | |
1422 { | |
1423 ShapeInsideInfo* info = block->shapeInsideInfo(); | |
1424 if (info) | |
1425 info->setNeedsLayout(info->isShapeDirty()); | |
1426 else | |
1427 info = block->layoutShapeInsideInfo(); | |
1428 return info && info->needsLayout(); | |
1429 } | 1364 } |
1430 | 1365 |
1431 bool RenderBlock::updateRegionsAndShapesLogicalSize(RenderFlowThread* flowThread ) | 1366 bool RenderBlock::updateRegionsAndShapesLogicalSize(RenderFlowThread* flowThread ) |
Zoltan
2014/03/26 21:01:09
We could probably remove this function, since no t
| |
1432 { | 1367 { |
1433 if (!flowThread && !shapeInsideInfo()) | 1368 if (!flowThread) |
1434 return shapeInfoRequiresRelayout(this); | 1369 return false; |
1435 | 1370 |
1436 LayoutUnit oldHeight = logicalHeight(); | 1371 LayoutUnit oldHeight = logicalHeight(); |
1437 LayoutUnit oldTop = logicalTop(); | 1372 LayoutUnit oldTop = logicalTop(); |
1438 | 1373 |
1439 // Compute the maximum logical height content may cause this block to expand to | 1374 // Compute the maximum logical height content may cause this block to expand to |
1440 // FIXME: These should eventually use the const computeLogicalHeight rather than updateLogicalHeight | 1375 // FIXME: These should eventually use the const computeLogicalHeight rather than updateLogicalHeight |
1441 setLogicalHeight(RenderFlowThread::maxLogicalHeight()); | 1376 setLogicalHeight(RenderFlowThread::maxLogicalHeight()); |
1442 updateLogicalHeight(); | 1377 updateLogicalHeight(); |
1443 | 1378 |
1444 computeShapeSize(); | |
1445 | |
1446 // Set our start and end regions. No regions above or below us will be consi dered by our children. They are | 1379 // Set our start and end regions. No regions above or below us will be consi dered by our children. They are |
1447 // effectively clamped to our region range. | 1380 // effectively clamped to our region range. |
1448 computeRegionRangeForBlock(flowThread); | 1381 computeRegionRangeForBlock(flowThread); |
1449 | 1382 |
1450 setLogicalHeight(oldHeight); | 1383 setLogicalHeight(oldHeight); |
1451 setLogicalTop(oldTop); | 1384 setLogicalTop(oldTop); |
1452 | 1385 |
1453 return shapeInfoRequiresRelayout(this); | 1386 return false; |
1454 } | |
1455 | |
1456 void RenderBlock::computeShapeSize() | |
1457 { | |
1458 ShapeInsideInfo* shapeInsideInfo = this->shapeInsideInfo(); | |
1459 if (!shapeInsideInfo) | |
1460 return; | |
1461 | |
1462 bool percentageLogicalHeightResolvable = percentageLogicalHeightIsResolvable FromBlock(this, false); | |
1463 shapeInsideInfo->setReferenceBoxLogicalSize(LayoutSize(logicalWidth(), perce ntageLogicalHeightResolvable ? logicalHeight() : LayoutUnit())); | |
1464 } | 1387 } |
1465 | 1388 |
1466 void RenderBlock::updateRegionsAndShapesAfterChildLayout(RenderFlowThread* flowT hread, bool heightChanged) | 1389 void RenderBlock::updateRegionsAndShapesAfterChildLayout(RenderFlowThread* flowT hread, bool heightChanged) |
1467 { | 1390 { |
1468 // A previous sibling has changed dimension, so we need to relayout the shap e with the content | |
1469 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo(); | |
1470 if (heightChanged && shapeInsideInfo) | |
1471 shapeInsideInfo->markShapeAsDirty(); | |
1472 | |
1473 computeRegionRangeForBlock(flowThread); | 1391 computeRegionRangeForBlock(flowThread); |
1474 } | 1392 } |
1475 | 1393 |
1476 void RenderBlock::computeRegionRangeForBlock(RenderFlowThread* flowThread) | 1394 void RenderBlock::computeRegionRangeForBlock(RenderFlowThread* flowThread) |
1477 { | 1395 { |
1478 if (flowThread) | 1396 if (flowThread) |
1479 flowThread->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage() ); | 1397 flowThread->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage() ); |
1480 } | 1398 } |
1481 | 1399 |
1482 bool RenderBlock::updateLogicalWidthAndColumnWidth() | 1400 bool RenderBlock::updateLogicalWidthAndColumnWidth() |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2818 afterLowest = afterLowest->prevRootBox(); | 2736 afterLowest = afterLowest->prevRootBox(); |
2819 } | 2737 } |
2820 } | 2738 } |
2821 | 2739 |
2822 bool RenderBlock::avoidsFloats() const | 2740 bool RenderBlock::avoidsFloats() const |
2823 { | 2741 { |
2824 // Floats can't intrude into our box if we have a non-auto column count or w idth. | 2742 // Floats can't intrude into our box if we have a non-auto column count or w idth. |
2825 return RenderBox::avoidsFloats() || !style()->hasAutoColumnCount() || !style ()->hasAutoColumnWidth(); | 2743 return RenderBox::avoidsFloats() || !style()->hasAutoColumnCount() || !style ()->hasAutoColumnWidth(); |
2826 } | 2744 } |
2827 | 2745 |
2828 void RenderBlock::markShapeInsideDescendantsForLayout() | |
2829 { | |
2830 if (!everHadLayout()) | |
2831 return; | |
2832 if (childrenInline()) { | |
2833 setNeedsLayout(); | |
2834 return; | |
2835 } | |
2836 for (RenderObject* child = firstChild(); child; child = child->nextSibling() ) { | |
2837 if (!child->isRenderBlock()) | |
2838 continue; | |
2839 RenderBlock* childBlock = toRenderBlock(child); | |
2840 childBlock->markShapeInsideDescendantsForLayout(); | |
2841 } | |
2842 } | |
2843 | |
2844 bool RenderBlock::isPointInOverflowControl(HitTestResult& result, const LayoutPo int& locationInContainer, const LayoutPoint& accumulatedOffset) | 2746 bool RenderBlock::isPointInOverflowControl(HitTestResult& result, const LayoutPo int& locationInContainer, const LayoutPoint& accumulatedOffset) |
2845 { | 2747 { |
2846 if (!scrollsOverflow()) | 2748 if (!scrollsOverflow()) |
2847 return false; | 2749 return false; |
2848 | 2750 |
2849 return layer()->scrollableArea()->hitTestOverflowControls(result, roundedInt Point(locationInContainer - toLayoutSize(accumulatedOffset))); | 2751 return layer()->scrollableArea()->hitTestOverflowControls(result, roundedInt Point(locationInContainer - toLayoutSize(accumulatedOffset))); |
2850 } | 2752 } |
2851 | 2753 |
2852 Node* RenderBlock::nodeForHitTest() const | 2754 Node* RenderBlock::nodeForHitTest() const |
2853 { | 2755 { |
(...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5025 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const | 4927 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const |
5026 { | 4928 { |
5027 showRenderObject(); | 4929 showRenderObject(); |
5028 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 4930 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
5029 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 4931 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
5030 } | 4932 } |
5031 | 4933 |
5032 #endif | 4934 #endif |
5033 | 4935 |
5034 } // namespace WebCore | 4936 } // namespace WebCore |
OLD | NEW |