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

Side by Side Diff: sky/engine/core/rendering/RenderBlock.cpp

Issue 877043002: Remove RenderLayerScrollableArea (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « sky/engine/core/rendering/RenderBlock.h ('k') | sky/engine/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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 }; 65 };
66 66
67 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock _should_stay_small); 67 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock _should_stay_small);
68 68
69 static TrackedDescendantsMap* gPositionedDescendantsMap = 0; 69 static TrackedDescendantsMap* gPositionedDescendantsMap = 0;
70 static TrackedDescendantsMap* gPercentHeightDescendantsMap = 0; 70 static TrackedDescendantsMap* gPercentHeightDescendantsMap = 0;
71 71
72 static TrackedContainerMap* gPositionedContainerMap = 0; 72 static TrackedContainerMap* gPositionedContainerMap = 0;
73 static TrackedContainerMap* gPercentHeightContainerMap = 0; 73 static TrackedContainerMap* gPercentHeightContainerMap = 0;
74 74
75 typedef WTF::HashSet<RenderBlock*> DelayedUpdateScrollInfoSet;
76 static int gDelayUpdateScrollInfo = 0;
77 static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = 0;
78
79 RenderBlock::RenderBlock(ContainerNode* node) 75 RenderBlock::RenderBlock(ContainerNode* node)
80 : RenderBox(node) 76 : RenderBox(node)
81 , m_hasMarginBeforeQuirk(false) 77 , m_hasMarginBeforeQuirk(false)
82 , m_hasMarginAfterQuirk(false) 78 , m_hasMarginAfterQuirk(false)
83 , m_beingDestroyed(false) 79 , m_beingDestroyed(false)
84 , m_hasBorderOrPaddingLogicalWidthChanged(false) 80 , m_hasBorderOrPaddingLogicalWidthChanged(false)
85 { 81 {
86 } 82 }
87 83
88 static void removeBlockFromDescendantAndContainerMaps(RenderBlock* block, Tracke dDescendantsMap*& descendantMap, TrackedContainerMap*& containerMap) 84 static void removeBlockFromDescendantAndContainerMaps(RenderBlock* block, Tracke dDescendantsMap*& descendantMap, TrackedContainerMap*& containerMap)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 while (InlineBox* childBox = box->firstChild()) 148 while (InlineBox* childBox = box->firstChild())
153 childBox->remove(); 149 childBox->remove();
154 } 150 }
155 } 151 }
156 } else if (parent()) 152 } else if (parent())
157 parent()->dirtyLinesFromChangedChild(this); 153 parent()->dirtyLinesFromChangedChild(this);
158 } 154 }
159 155
160 m_lineBoxes.deleteLineBoxes(); 156 m_lineBoxes.deleteLineBoxes();
161 157
162 if (UNLIKELY(gDelayedUpdateScrollInfoSet != 0))
163 gDelayedUpdateScrollInfoSet->remove(this);
164
165 RenderBox::willBeDestroyed(); 158 RenderBox::willBeDestroyed();
166 } 159 }
167 160
168 void RenderBlock::styleWillChange(StyleDifference diff, const RenderStyle& newSt yle) 161 void RenderBlock::styleWillChange(StyleDifference diff, const RenderStyle& newSt yle)
169 { 162 {
170 RenderStyle* oldStyle = style(); 163 RenderStyle* oldStyle = style();
171 164
172 setReplaced(newStyle.isDisplayInlineType()); 165 setReplaced(newStyle.isDisplayInlineType());
173 166
174 if (oldStyle && parent()) { 167 if (oldStyle && parent()) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 251
259 // No need to waste time deleting the line box tree if we're getting destroy ed. 252 // No need to waste time deleting the line box tree if we're getting destroy ed.
260 if (documentBeingDestroyed()) 253 if (documentBeingDestroyed())
261 return; 254 return;
262 255
263 // If this was our last child be sure to clear out our line boxes. 256 // If this was our last child be sure to clear out our line boxes.
264 if (!firstChild() && isRenderParagraph()) 257 if (!firstChild() && isRenderParagraph())
265 deleteLineBoxTree(); 258 deleteLineBoxTree();
266 } 259 }
267 260
268 void RenderBlock::startDelayUpdateScrollInfo()
269 {
270 if (gDelayUpdateScrollInfo == 0) {
271 ASSERT(!gDelayedUpdateScrollInfoSet);
272 gDelayedUpdateScrollInfoSet = new DelayedUpdateScrollInfoSet;
273 }
274 ASSERT(gDelayedUpdateScrollInfoSet);
275 ++gDelayUpdateScrollInfo;
276 }
277
278 void RenderBlock::finishDelayUpdateScrollInfo()
279 {
280 --gDelayUpdateScrollInfo;
281 ASSERT(gDelayUpdateScrollInfo >= 0);
282 if (gDelayUpdateScrollInfo == 0) {
283 ASSERT(gDelayedUpdateScrollInfoSet);
284
285 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll InfoSet));
286 gDelayedUpdateScrollInfoSet = 0;
287
288 for (DelayedUpdateScrollInfoSet::iterator it = infoSet->begin(); it != i nfoSet->end(); ++it) {
289 RenderBlock* block = *it;
290 if (block->hasOverflowClip()) {
291 block->layer()->scrollableArea()->updateAfterLayout();
292 }
293 }
294 }
295 }
296
297 void RenderBlock::updateScrollInfoAfterLayout()
298 {
299 if (hasOverflowClip()) {
300 if (gDelayUpdateScrollInfo)
301 gDelayedUpdateScrollInfoSet->add(this);
302 else
303 layer()->scrollableArea()->updateAfterLayout();
304 }
305 }
306
307 bool RenderBlock::widthAvailableToChildrenHasChanged() 261 bool RenderBlock::widthAvailableToChildrenHasChanged()
308 { 262 {
309 bool widthAvailableToChildrenHasChanged = m_hasBorderOrPaddingLogicalWidthCh anged; 263 bool widthAvailableToChildrenHasChanged = m_hasBorderOrPaddingLogicalWidthCh anged;
310 m_hasBorderOrPaddingLogicalWidthChanged = false; 264 m_hasBorderOrPaddingLogicalWidthChanged = false;
311 265
312 // If we use border-box sizing, have percentage padding, and our parent has changed width then the width available to our children has changed even 266 // If we use border-box sizing, have percentage padding, and our parent has changed width then the width available to our children has changed even
313 // though our own width has remained the same. 267 // though our own width has remained the same.
314 widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX && needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLog icalWidthChanged(); 268 widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX && needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLog icalWidthChanged();
315 269
316 return widthAvailableToChildrenHasChanged; 270 return widthAvailableToChildrenHasChanged;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // For now just always recompute overflow. This is no worse performance- wise than the old code that called rightmostPosition and 380 // For now just always recompute overflow. This is no worse performance- wise than the old code that called rightmostPosition and
427 // lowestPosition on every relayout so it's not a regression. 381 // lowestPosition on every relayout so it's not a regression.
428 // computeOverflow expects the bottom edge before we clamp our height. S ince this information isn't available during 382 // computeOverflow expects the bottom edge before we clamp our height. S ince this information isn't available during
429 // simplifiedLayout, we cache the value in m_overflow. 383 // simplifiedLayout, we cache the value in m_overflow.
430 LayoutUnit oldClientAfterEdge = hasRenderOverflow() ? m_overflow->layout ClientAfterEdge() : clientLogicalBottom(); 384 LayoutUnit oldClientAfterEdge = hasRenderOverflow() ? m_overflow->layout ClientAfterEdge() : clientLogicalBottom();
431 computeOverflow(oldClientAfterEdge, true); 385 computeOverflow(oldClientAfterEdge, true);
432 } 386 }
433 387
434 updateLayerTransformAfterLayout(); 388 updateLayerTransformAfterLayout();
435 389
436 updateScrollInfoAfterLayout();
437
438 clearNeedsLayout(); 390 clearNeedsLayout();
439 return true; 391 return true;
440 } 392 }
441 393
442 LayoutUnit RenderBlock::marginIntrinsicLogicalWidthForChild(RenderBox* child) co nst 394 LayoutUnit RenderBlock::marginIntrinsicLogicalWidthForChild(RenderBox* child) co nst
443 { 395 {
444 // A margin has three types: fixed, percentage, and auto (variable). 396 // A margin has three types: fixed, percentage, and auto (variable).
445 // Auto and percentage margins become 0 when computing min/max width. 397 // Auto and percentage margins become 0 when computing min/max width.
446 // Fixed margins can be added in as is. 398 // Fixed margins can be added in as is.
447 Length marginLeft = child->style()->marginStartUsing(style()); 399 Length marginLeft = child->style()->marginStartUsing(style());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 ContentsClipBehavior contentsClipBehavior = ForceContentsClip; 468 ContentsClipBehavior contentsClipBehavior = ForceContentsClip;
517 if (hasOverflowClip() && !(shouldPaintSelectionGaps() && phase == PaintPhase Foreground) && !hasCaret()) 469 if (hasOverflowClip() && !(shouldPaintSelectionGaps() && phase == PaintPhase Foreground) && !hasCaret())
518 contentsClipBehavior = SkipContentsClipIfPossible; 470 contentsClipBehavior = SkipContentsClipIfPossible;
519 471
520 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsC lipBehavior); 472 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsC lipBehavior);
521 { 473 {
522 paintObject(paintInfo, adjustedPaintOffset); 474 paintObject(paintInfo, adjustedPaintOffset);
523 } 475 }
524 if (pushedClip) 476 if (pushedClip)
525 popContentsClip(paintInfo, phase, adjustedPaintOffset); 477 popContentsClip(paintInfo, phase, adjustedPaintOffset);
526
527 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with
528 // z-index. We paint after we painted the background/border, so that the sc rollbars will
529 // sit above the background/border.
530 if (hasOverflowClip() && phase == PaintPhaseForeground && paintInfo.shouldPa intWithinRoot(this))
531 layer()->scrollableArea()->paintOverflowControls(paintInfo.context, roun dedIntPoint(adjustedPaintOffset), paintInfo.rect, false /* paintingOverlayContro ls */);
532 } 478 }
533 479
534 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 480 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
535 { 481 {
536 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? PaintPh aseOutline : paintInfo.phase; 482 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? PaintPh aseOutline : paintInfo.phase;
537 483
538 // We don't paint our own background, but we do let the kids paint their bac kgrounds. 484 // We don't paint our own background, but we do let the kids paint their bac kgrounds.
539 PaintInfo paintInfoForChild(paintInfo); 485 PaintInfo paintInfoForChild(paintInfo);
540 paintInfoForChild.phase = newPhase; 486 paintInfoForChild.phase = newPhase;
541 paintInfoForChild.updatePaintingRootForChildren(this); 487 paintInfoForChild.updatePaintingRootForChildren(this);
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 // Inline blocks are replaced elements. Otherwise, just pass off to 1480 // Inline blocks are replaced elements. Otherwise, just pass off to
1535 // the base class. If we're being queried as though we're the root line 1481 // the base class. If we're being queried as though we're the root line
1536 // box, then the fact that we're an inline-block is irrelevant, and we behav e 1482 // box, then the fact that we're an inline-block is irrelevant, and we behav e
1537 // just like a block. 1483 // just like a block.
1538 if (isInline() && linePositionMode == PositionOnContainingLine) { 1484 if (isInline() && linePositionMode == PositionOnContainingLine) {
1539 // CSS2.1 states that the baseline of an inline block is the baseline of the last line box in 1485 // CSS2.1 states that the baseline of an inline block is the baseline of the last line box in
1540 // the normal flow. We make an exception for marquees, since their base lines are meaningless 1486 // the normal flow. We make an exception for marquees, since their base lines are meaningless
1541 // (the content inside them moves). This matches WinIE as well, which j ust bottom-aligns them. 1487 // (the content inside them moves). This matches WinIE as well, which j ust bottom-aligns them.
1542 // We also give up on finding a baseline if we have a vertical scrollbar , or if we are scrolled 1488 // We also give up on finding a baseline if we have a vertical scrollbar , or if we are scrolled
1543 // vertically (e.g., an overflow:hidden block that has had scrollTop mov ed). 1489 // vertically (e.g., an overflow:hidden block that has had scrollTop mov ed).
1544 bool ignoreBaseline = (layer() && layer()->scrollableArea() && ((directi on == HorizontalLine ? (layer()->scrollableArea()->verticalScrollbar() || layer( )->scrollableArea()->scrollYOffset()) 1490 int baselinePos = inlineBlockBaseline(direction);
1545 : (layer()->scrollableArea()->horizontalScrollbar() || layer()->scro llableArea()->scrollXOffset()))));
1546
1547 int baselinePos = ignoreBaseline ? -1 : inlineBlockBaseline(direction);
1548
1549 if (baselinePos != -1) 1491 if (baselinePos != -1)
1550 return beforeMarginInLineDirection(direction) + baselinePos; 1492 return beforeMarginInLineDirection(direction) + baselinePos;
1551 1493
1552 return RenderBox::baselinePosition(baselineType, firstLine, direction, l inePositionMode); 1494 return RenderBox::baselinePosition(baselineType, firstLine, direction, l inePositionMode);
1553 } 1495 }
1554 1496
1555 // If we're not replaced, we'll only get called with PositionOfInteriorLineB oxes. 1497 // If we're not replaced, we'll only get called with PositionOfInteriorLineB oxes.
1556 // Note that inline-block counts as replaced here. 1498 // Note that inline-block counts as replaced here.
1557 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); 1499 ASSERT(linePositionMode == PositionOfInteriorLineBoxes);
1558 1500
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 1815
1874 setSelfNeedsOverflowRecalcAfterStyleChange(false); 1816 setSelfNeedsOverflowRecalcAfterStyleChange(false);
1875 // If the current block needs layout, overflow will be recalculated during 1817 // If the current block needs layout, overflow will be recalculated during
1876 // layout time anyway. We can safely exit here. 1818 // layout time anyway. We can safely exit here.
1877 if (needsLayout()) 1819 if (needsLayout())
1878 return false; 1820 return false;
1879 1821
1880 LayoutUnit oldClientAfterEdge = hasRenderOverflow() ? m_overflow->layoutClie ntAfterEdge() : clientLogicalBottom(); 1822 LayoutUnit oldClientAfterEdge = hasRenderOverflow() ? m_overflow->layoutClie ntAfterEdge() : clientLogicalBottom();
1881 computeOverflow(oldClientAfterEdge, true); 1823 computeOverflow(oldClientAfterEdge, true);
1882 1824
1883 if (hasOverflowClip())
1884 layer()->scrollableArea()->updateAfterOverflowRecalc();
1885
1886 return !hasOverflowClip(); 1825 return !hasOverflowClip();
1887 } 1826 }
1888 1827
1889 #if ENABLE(ASSERT) 1828 #if ENABLE(ASSERT)
1890 void RenderBlock::checkPositionedObjectsNeedLayout() 1829 void RenderBlock::checkPositionedObjectsNeedLayout()
1891 { 1830 {
1892 if (!gPositionedDescendantsMap) 1831 if (!gPositionedDescendantsMap)
1893 return; 1832 return;
1894 1833
1895 if (TrackedRendererListHashSet* positionedDescendantSet = positionedObjects( )) { 1834 if (TrackedRendererListHashSet* positionedDescendantSet = positionedObjects( )) {
(...skipping 12 matching lines...) Expand all
1908 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 1847 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
1909 { 1848 {
1910 showRenderObject(); 1849 showRenderObject();
1911 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 1850 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
1912 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 1851 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
1913 } 1852 }
1914 1853
1915 #endif 1854 #endif
1916 1855
1917 } // namespace blink 1856 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBlock.h ('k') | sky/engine/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698