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

Unified Diff: Source/core/rendering/RenderBlock.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderBR.cpp ('k') | Source/core/rendering/RenderBlockLineLayout.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlock.cpp
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index c61d87bb8c9af72a72c4faa8cb09e97f65e046e9..3f6f504244c271b1a0637d2eb95cce0fe7062e33 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -117,7 +117,7 @@ public:
, m_hadHorizontalLayoutOverflow(false)
, m_hadVerticalLayoutOverflow(false)
{
- m_shouldDispatchEvent = !m_block->isAnonymous() && m_block->hasOverflowClip() && m_block->document()->hasListenerType(Document::OVERFLOWCHANGED_LISTENER);
+ m_shouldDispatchEvent = !m_block->isAnonymous() && m_block->hasOverflowClip() && m_block->document().hasListenerType(Document::OVERFLOWCHANGED_LISTENER);
if (m_shouldDispatchEvent) {
m_hadHorizontalLayoutOverflow = m_block->hasHorizontalLayoutOverflow();
m_hadVerticalLayoutOverflow = m_block->hasVerticalLayoutOverflow();
@@ -135,7 +135,7 @@ public:
bool horizontalLayoutOverflowChanged = hasHorizontalLayoutOverflow != m_hadHorizontalLayoutOverflow;
bool verticalLayoutOverflowChanged = hasVerticalLayoutOverflow != m_hadVerticalLayoutOverflow;
if (horizontalLayoutOverflowChanged || verticalLayoutOverflowChanged) {
- if (FrameView* frameView = m_block->document()->view())
+ if (FrameView* frameView = m_block->document().view())
frameView->scheduleEvent(OverflowEvent::create(horizontalLayoutOverflowChanged, hasHorizontalLayoutOverflow, verticalLayoutOverflowChanged, hasVerticalLayoutOverflow), m_block->node());
}
}
@@ -961,7 +961,7 @@ void RenderBlock::deleteLineBoxTree()
m_floatingObjects->clearLineBoxTreePointers();
m_lineBoxes.deleteLineBoxTree();
- if (AXObjectCache* cache = document()->existingAXObjectCache())
+ if (AXObjectCache* cache = document().existingAXObjectCache())
cache->recomputeIsIgnored(this);
}
@@ -976,7 +976,7 @@ RootInlineBox* RenderBlock::createAndAppendRootInlineBox()
m_lineBoxes.appendLineBox(rootBox);
if (UNLIKELY(AXObjectCache::accessibilityEnabled()) && m_lineBoxes.firstLineBox() == rootBox) {
- if (AXObjectCache* cache = document()->existingAXObjectCache())
+ if (AXObjectCache* cache = document().existingAXObjectCache())
cache->recomputeIsIgnored(this);
}
@@ -1298,7 +1298,7 @@ bool RenderBlock::isSelfCollapsingBlock() const
Length logicalHeightLength = style()->logicalHeight();
bool hasAutoHeight = logicalHeightLength.isAuto();
- if (logicalHeightLength.isPercent() && !document()->inQuirksMode()) {
+ if (logicalHeightLength.isPercent() && !document().inQuirksMode()) {
hasAutoHeight = true;
for (RenderBlock* cb = containingBlock(); !cb->isRenderView(); cb = cb->containingBlock()) {
if (cb->style()->logicalHeight().isFixed() || cb->isTableCell())
@@ -2037,7 +2037,7 @@ LayoutUnit RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo
// This child is collapsing with the top of the
// block. If it has larger margin values, then we need to update
// our own maximal values.
- if (!document()->inQuirksMode() || !marginInfo.quirkContainer() || !topQuirk)
+ if (!document().inQuirksMode() || !marginInfo.quirkContainer() || !topQuirk)
setMaxMarginBeforeValues(max(posTop, maxPositiveMarginBefore()), max(negTop, maxNegativeMarginBefore()));
// The minute any of the margins involved isn't a quirk, don't
@@ -2106,7 +2106,7 @@ LayoutUnit RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo
logicalTop = logicalHeight();
} else if (!marginInfo.discardMargin() && (!marginInfo.atBeforeSideOfBlock()
|| (!marginInfo.canCollapseMarginBeforeWithChildren()
- && (!document()->inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.hasMarginBeforeQuirk())))) {
+ && (!document().inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.hasMarginBeforeQuirk())))) {
// We're collapsing with a previous sibling's margins and not
// with the top of the block.
setLogicalHeight(logicalHeight() + max(marginInfo.positiveMargin(), posTop) - max(marginInfo.negativeMargin(), negTop));
@@ -2222,7 +2222,7 @@ void RenderBlock::marginBeforeEstimateForChild(RenderBox* child, LayoutUnit& pos
// Give up if in quirks mode and we're a body/table cell and the top margin of the child box is quirky.
// Give up if the child specified -webkit-margin-collapse: separate that prevents collapsing.
// FIXME: Use writing mode independent accessor for marginBeforeCollapse.
- if ((document()->inQuirksMode() && hasMarginAfterQuirk(child) && (isTableCell() || isBody())) || child->style()->marginBeforeCollapse() == MSEPARATE)
+ if ((document().inQuirksMode() && hasMarginAfterQuirk(child) && (isTableCell() || isBody())) || child->style()->marginBeforeCollapse() == MSEPARATE)
return;
// The margins are discarded by a child that specified -webkit-margin-collapse: discard.
@@ -2399,7 +2399,7 @@ void RenderBlock::handleAfterSideOfBlock(LayoutUnit beforeSide, LayoutUnit after
// If we can't collapse with children then go ahead and add in the bottom margin.
if (!marginInfo.discardMargin() && (!marginInfo.canCollapseWithMarginAfter() && !marginInfo.canCollapseWithMarginBefore()
- && (!document()->inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.hasMarginAfterQuirk())))
+ && (!document().inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.hasMarginAfterQuirk())))
setLogicalHeight(logicalHeight() + marginInfo.margin());
// Now add in our bottom border/padding.
@@ -3079,7 +3079,7 @@ void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf
// Avoid painting descendants of the root element when stylesheets haven't loaded. This eliminates FOUC.
// It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document
// will do a full repaint.
- if (document()->didLayoutWithPendingStylesheets() && !isRenderView())
+ if (document().didLayoutWithPendingStylesheets() && !isRenderView())
return;
if (childrenInline())
@@ -3204,7 +3204,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
// 3. paint selection
// FIXME: Make this work with multi column layouts. For now don't fill gaps.
- bool isPrinting = document()->printing();
+ bool isPrinting = document().printing();
if (!isPrinting && !hasColumns())
paintSelection(paintInfo, scrolledOffset); // Fill in gaps in selection on lines and between blocks.
@@ -5184,7 +5184,7 @@ PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou
}
}
- bool moveCaretToBoundary = document()->frame()->editor().behavior().shouldMoveCaretToHorizontalBoundaryWhenPastTopOrBottom();
+ bool moveCaretToBoundary = document().frame()->editor().behavior().shouldMoveCaretToHorizontalBoundaryWhenPastTopOrBottom();
if (!moveCaretToBoundary && !closestBox && lastRootBoxWithChildren) {
// y coordinate is below last root line box, pretend we hit it
@@ -5314,7 +5314,7 @@ int RenderBlock::columnGap() const
void RenderBlock::calcColumnWidth()
{
- if (document()->regionBasedColumnsEnabled())
+ if (document().regionBasedColumnsEnabled())
return;
// Calculate our column width and column count.
@@ -5323,7 +5323,7 @@ void RenderBlock::calcColumnWidth()
LayoutUnit desiredColumnWidth = contentLogicalWidth();
// For now, we don't support multi-column layouts when printing, since we have to do a lot of work for proper pagination.
- if (document()->paginated() || (style()->hasAutoColumnCount() && style()->hasAutoColumnWidth()) || !style()->hasInlineColumnAxis()) {
+ if (document().paginated() || (style()->hasAutoColumnCount() && style()->hasAutoColumnWidth()) || !style()->hasInlineColumnAxis()) {
setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth);
return;
}
@@ -5959,7 +5959,7 @@ void RenderBlock::computeInlinePreferredLogicalWidths(LayoutUnit& minLogicalWidt
// Firefox and Opera will allow a table cell to grow to fit an image inside it under
// very specific cirucumstances (in order to match common WinIE renderings).
// Not supporting the quirk has caused us to mis-render some real sites. (See Bugzilla 10517.)
- bool allowImagesToBreak = !document()->inQuirksMode() || !isTableCell() || !styleToUse->logicalWidth().isIntrinsicOrAuto();
+ bool allowImagesToBreak = !document().inQuirksMode() || !isTableCell() || !styleToUse->logicalWidth().isIntrinsicOrAuto();
bool autoWrap, oldAutoWrap;
autoWrap = oldAutoWrap = styleToUse->autoWrap();
@@ -6362,7 +6362,7 @@ LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction,
if (isReplaced() && linePositionMode == PositionOnContainingLine)
return RenderBox::lineHeight(firstLine, direction, linePositionMode);
- if (firstLine && document()->styleSheetCollections()->usesFirstLineRules()) {
+ if (firstLine && document().styleSheetCollections()->usesFirstLineRules()) {
RenderStyle* s = style(firstLine);
if (s != style())
return s->computedLineHeight(view());
@@ -6582,13 +6582,13 @@ void RenderBlock::updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderO
RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetterContainer);
ASSERT(firstLetter->isFloating() || firstLetter->isInline());
- if (Node::diff(firstLetter->style(), pseudoStyle, document()) == Node::Reattach) {
+ if (Node::diff(firstLetter->style(), pseudoStyle, &document()) == Node::Reattach) {
// The first-letter renderer needs to be replaced. Create a new renderer of the right type.
RenderObject* newFirstLetter;
if (pseudoStyle->display() == INLINE)
- newFirstLetter = RenderInline::createAnonymous(document());
+ newFirstLetter = RenderInline::createAnonymous(&document());
else
- newFirstLetter = RenderBlock::createAnonymous(document());
+ newFirstLetter = RenderBlock::createAnonymous(&document());
newFirstLetter->setStyle(pseudoStyle);
// Move the first letter into the new renderer.
@@ -6632,9 +6632,9 @@ void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend
RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetterContainer);
RenderObject* firstLetter = 0;
if (pseudoStyle->display() == INLINE)
- firstLetter = RenderInline::createAnonymous(document());
+ firstLetter = RenderInline::createAnonymous(&document());
else
- firstLetter = RenderBlock::createAnonymous(document());
+ firstLetter = RenderBlock::createAnonymous(&document());
firstLetter->setStyle(pseudoStyle);
firstLetterContainer->addChild(firstLetter, currentChild);
@@ -6671,7 +6671,7 @@ void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend
// Construct a text fragment for the text after the first letter.
// This text fragment might be empty.
RenderTextFragment* remainingText =
- new RenderTextFragment(textObj->node() ? textObj->node() : textObj->document(), oldText.get(), length, oldText->length() - length);
+ new RenderTextFragment(textObj->node() ? textObj->node() : &textObj->document(), oldText.get(), length, oldText->length() - length);
remainingText->setStyle(textObj->style());
if (remainingText->node())
remainingText->node()->setRenderer(remainingText);
@@ -6683,7 +6683,7 @@ void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend
// construct text fragment for the first letter
RenderTextFragment* letter =
- new RenderTextFragment(remainingText->node() ? remainingText->node() : remainingText->document(), oldText.get(), 0, length);
+ new RenderTextFragment(remainingText->node() ? remainingText->node() : &remainingText->document(), oldText.get(), 0, length);
letter->setStyle(pseudoStyle);
firstLetter->addChild(letter);
@@ -6693,7 +6693,7 @@ void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend
void RenderBlock::updateFirstLetter()
{
- if (!document()->styleSheetCollections()->usesFirstLetterRules())
+ if (!document().styleSheetCollections()->usesFirstLetterRules())
return;
// Don't recur
if (style()->styleType() == FIRST_LETTER)
@@ -7985,13 +7985,13 @@ RenderBlock* RenderBlock::createAnonymousWithParentRendererAndDisplay(const Rend
RenderBlock* newBox = 0;
if (display == BOX || display == INLINE_BOX) {
// FIXME: Remove this case once we have eliminated all internal users of old flexbox
- newBox = RenderDeprecatedFlexibleBox::createAnonymous(parent->document());
+ newBox = RenderDeprecatedFlexibleBox::createAnonymous(&parent->document());
newDisplay = BOX;
} else if (display == FLEX || display == INLINE_FLEX) {
- newBox = RenderFlexibleBox::createAnonymous(parent->document());
+ newBox = RenderFlexibleBox::createAnonymous(&parent->document());
newDisplay = FLEX;
} else {
- newBox = RenderBlock::createAnonymous(parent->document());
+ newBox = RenderBlock::createAnonymous(&parent->document());
newDisplay = BLOCK;
}
@@ -8005,7 +8005,7 @@ RenderBlock* RenderBlock::createAnonymousColumnsWithParentRenderer(const RenderO
RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(parent->style(), BLOCK);
newStyle->inheritColumnPropertiesFrom(parent->style());
- RenderBlock* newBox = RenderBlock::createAnonymous(parent->document());
+ RenderBlock* newBox = RenderBlock::createAnonymous(&parent->document());
newBox->setStyle(newStyle.release());
return newBox;
}
@@ -8015,7 +8015,7 @@ RenderBlock* RenderBlock::createAnonymousColumnSpanWithParentRenderer(const Rend
RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(parent->style(), BLOCK);
newStyle->setColumnSpan(ColumnSpanAll);
- RenderBlock* newBox = RenderBlock::createAnonymous(parent->document());
+ RenderBlock* newBox = RenderBlock::createAnonymous(&parent->document());
newBox->setStyle(newStyle.release());
return newBox;
}
« no previous file with comments | « Source/core/rendering/RenderBR.cpp ('k') | Source/core/rendering/RenderBlockLineLayout.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698