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

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

Issue 928393003: Remove the concept of document.documentElement (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return; 313 return;
314 314
315 RenderBox* positionedObject; 315 RenderBox* positionedObject;
316 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 316 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
317 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) { 317 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
318 positionedObject = *it; 318 positionedObject = *it;
319 addOverflowFromChild(positionedObject, LayoutSize(positionedObject->x(), positionedObject->y())); 319 addOverflowFromChild(positionedObject, LayoutSize(positionedObject->x(), positionedObject->y()));
320 } 320 }
321 } 321 }
322 322
323 bool RenderBlock::createsBlockFormattingContext() const
324 {
325 return isInlineBlock() || isFloatingOrOutOfFlowPositioned() || hasOverflowCl ip() || isFlexItem() || isDocumentElement();
326 }
327
328 void RenderBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, R enderBox* child) 323 void RenderBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, R enderBox* child)
329 { 324 {
330 // FIXME: Technically percentage height objects only need a relayout if thei r percentage isn't going to be turned into 325 // FIXME: Technically percentage height objects only need a relayout if thei r percentage isn't going to be turned into
331 // an auto value. Add a method to determine this, so that we can avoid the r elayout. 326 // an auto value. Add a method to determine this, so that we can avoid the r elayout.
332 if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView( ))) 327 if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView( )))
333 child->setChildNeedsLayout(MarkOnlyThis); 328 child->setChildNeedsLayout(MarkOnlyThis);
334 329
335 // If relayoutChildren is set and the child has percentage padding or an emb edded content box, we also need to invalidate the childs pref widths. 330 // If relayoutChildren is set and the child has percentage padding or an emb edded content box, we also need to invalidate the childs pref widths.
336 if (relayoutChildren && child->needsPreferredWidthsRecalculation()) 331 if (relayoutChildren && child->needsPreferredWidthsRecalculation())
337 child->setPreferredLogicalWidthsDirty(MarkOnlyThis); 332 child->setPreferredLogicalWidthsDirty(MarkOnlyThis);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 434 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
440 for (TrackedRendererListHashSet::iterator it = positionedDescendants->be gin(); it != end; ++it) 435 for (TrackedRendererListHashSet::iterator it = positionedDescendants->be gin(); it != end; ++it)
441 (*it)->setChildNeedsLayout(); 436 (*it)->setChildNeedsLayout();
442 } 437 }
443 } 438 }
444 439
445 void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Ve ctor<RenderBox*>& layers) 440 void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Ve ctor<RenderBox*>& layers)
446 { 441 {
447 LayoutPoint adjustedPaintOffset = paintOffset + location(); 442 LayoutPoint adjustedPaintOffset = paintOffset + location();
448 443
449 LayoutRect overflowBox; 444 LayoutRect overflowBox = visualOverflowRect();
450 // Check if we need to do anything at all. 445 overflowBox.moveBy(adjustedPaintOffset);
451 // FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the RenderView 446 if (!overflowBox.intersects(paintInfo.rect))
452 // paints the root's background. 447 return;
453 if (!isDocumentElement()) {
454 overflowBox = visualOverflowRect();
455 overflowBox.moveBy(adjustedPaintOffset);
456 if (!overflowBox.intersects(paintInfo.rect))
457 return;
458 }
459 448
460 // There are some cases where not all clipped visual overflow is accounted f or. 449 // There are some cases where not all clipped visual overflow is accounted f or.
461 // FIXME: reduce the number of such cases. 450 // FIXME: reduce the number of such cases.
462 ContentsClipBehavior contentsClipBehavior = ForceContentsClip; 451 ContentsClipBehavior contentsClipBehavior = ForceContentsClip;
463 if (hasOverflowClip() && !shouldPaintSelectionGaps() && !hasCaret()) 452 if (hasOverflowClip() && !shouldPaintSelectionGaps() && !hasCaret())
464 contentsClipBehavior = SkipContentsClipIfPossible; 453 contentsClipBehavior = SkipContentsClipIfPossible;
465 454
466 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsC lipBehavior); 455 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsC lipBehavior);
467 paintObject(paintInfo, adjustedPaintOffset, layers); 456 paintObject(paintInfo, adjustedPaintOffset, layers);
468 if (pushedClip) 457 if (pushedClip)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 513
525 bool RenderBlock::shouldPaintSelectionGaps() const 514 bool RenderBlock::shouldPaintSelectionGaps() const
526 { 515 {
527 return selectionState() != SelectionNone && isSelectionRoot(); 516 return selectionState() != SelectionNone && isSelectionRoot();
528 } 517 }
529 518
530 bool RenderBlock::isSelectionRoot() const 519 bool RenderBlock::isSelectionRoot() const
531 { 520 {
532 ASSERT(node() || isAnonymous()); 521 ASSERT(node() || isAnonymous());
533 522
534 if (isDocumentElement() || hasOverflowClip() 523 if (node() && node()->parentNode() == document())
524 return true;
525
526 if (hasOverflowClip()
535 || isPositioned() 527 || isPositioned()
536 || isInlineBlock() 528 || isInlineBlock()
537 || hasTransform() 529 || hasTransform()
538 || isFlexItem()) 530 || isFlexItem())
539 return true; 531 return true;
540 532
541 if (view() && view()->selectionStart()) { 533 if (view() && view()->selectionStart()) {
542 Node* startElement = view()->selectionStart()->node(); 534 Node* startElement = view()->selectionStart()->node();
543 if (startElement && startElement->rootEditableElement() == node()) 535 if (startElement && startElement->rootEditableElement() == node())
544 return true; 536 return true;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 588 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
597 LayoutUnit& lastLogicalTop, LayoutUnit& last LogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) 589 LayoutUnit& lastLogicalTop, LayoutUnit& last LogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo)
598 { 590 {
599 // IMPORTANT: Callers of this method that intend for painting to happen need to do a save/restore. 591 // IMPORTANT: Callers of this method that intend for painting to happen need to do a save/restore.
600 // Clip out floating and positioned objects when painting selection gaps. 592 // Clip out floating and positioned objects when painting selection gaps.
601 if (paintInfo) { 593 if (paintInfo) {
602 // Note that we don't clip out overflow for positioned objects. We just stick to the border box. 594 // Note that we don't clip out overflow for positioned objects. We just stick to the border box.
603 LayoutRect blockRect(offsetFromRootBlock.width(), offsetFromRootBlock.he ight(), width(), height()); 595 LayoutRect blockRect(offsetFromRootBlock.width(), offsetFromRootBlock.he ight(), width(), height());
604 blockRect.moveBy(rootBlockPhysicalPosition); 596 blockRect.moveBy(rootBlockPhysicalPosition);
605 clipOutPositionedObjects(paintInfo, blockRect.location(), positionedObje cts()); 597 clipOutPositionedObjects(paintInfo, blockRect.location(), positionedObje cts());
606 if (isDocumentElement()) // The <body> must make sure to examine its con tainingBlock's positioned objects.
607 for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView(); cb = cb->containingBlock())
608 clipOutPositionedObjects(paintInfo, LayoutPoint(cb->x(), cb->y() ), cb->positionedObjects());
609 } 598 }
610 599
611 // FIXME: overflow: auto/scroll regions need more math here, since painting in the border box is different from painting in the padding box (one is scrolled , the other is 600 // FIXME: overflow: auto/scroll regions need more math here, since painting in the border box is different from painting in the padding box (one is scrolled , the other is
612 // fixed). 601 // fixed).
613 GapRects result; 602 GapRects result;
614 if (!isRenderBlockFlow()) // FIXME: Make multi-column selection gap filling work someday. 603 if (!isRenderBlockFlow()) // FIXME: Make multi-column selection gap filling work someday.
615 return result; 604 return result;
616 605
617 if (hasTransform()) { 606 if (hasTransform()) {
618 // FIXME: We should learn how to gap fill multiple columns and transform s eventually. 607 // FIXME: We should learn how to gap fill multiple columns and transform s eventually.
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 1750 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
1762 { 1751 {
1763 showRenderObject(); 1752 showRenderObject();
1764 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 1753 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
1765 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 1754 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
1766 } 1755 }
1767 1756
1768 #endif 1757 #endif
1769 1758
1770 } // namespace blink 1759 } // 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