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

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

Issue 399423006: Move widow-avoiding code from RenderBlock down to RenderBlockFlow. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderBlockFlow.h » ('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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 struct SameSizeAsRenderBlock : public RenderBox { 80 struct SameSizeAsRenderBlock : public RenderBox {
81 void* pointers[1]; 81 void* pointers[1];
82 RenderObjectChildList children; 82 RenderObjectChildList children;
83 RenderLineBoxList lineBoxes; 83 RenderLineBoxList lineBoxes;
84 uint32_t bitfields; 84 uint32_t bitfields;
85 }; 85 };
86 86
87 struct SameSizeAsRenderBlockRareData { 87 struct SameSizeAsRenderBlockRareData {
88 int pageLogicalOffset; 88 int pageLogicalOffset;
89 uint32_t bitfields;
90 }; 89 };
91 90
92 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock _should_stay_small); 91 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock _should_stay_small);
93 COMPILE_ASSERT(sizeof(RenderBlock::RenderBlockRareData) == sizeof(SameSizeAsRend erBlockRareData), RenderBlockRareData_should_stay_small); 92 COMPILE_ASSERT(sizeof(RenderBlock::RenderBlockRareData) == sizeof(SameSizeAsRend erBlockRareData), RenderBlockRareData_should_stay_small);
94 93
95 typedef WTF::HashMap<const RenderBox*, OwnPtr<ColumnInfo> > ColumnInfoMap; 94 typedef WTF::HashMap<const RenderBox*, OwnPtr<ColumnInfo> > ColumnInfoMap;
96 static ColumnInfoMap* gColumnInfoMap = 0; 95 static ColumnInfoMap* gColumnInfoMap = 0;
97 96
98 static TrackedDescendantsMap* gPositionedDescendantsMap = 0; 97 static TrackedDescendantsMap* gPositionedDescendantsMap = 0;
99 static TrackedDescendantsMap* gPercentHeightDescendantsMap = 0; 98 static TrackedDescendantsMap* gPercentHeightDescendantsMap = 0;
(...skipping 4274 matching lines...) Expand 10 before | Expand all | Expand 10 after
4374 void RenderBlock::setPageLogicalOffset(LayoutUnit logicalOffset) 4373 void RenderBlock::setPageLogicalOffset(LayoutUnit logicalOffset)
4375 { 4374 {
4376 if (!m_rareData) { 4375 if (!m_rareData) {
4377 if (!logicalOffset) 4376 if (!logicalOffset)
4378 return; 4377 return;
4379 m_rareData = adoptPtr(new RenderBlockRareData()); 4378 m_rareData = adoptPtr(new RenderBlockRareData());
4380 } 4379 }
4381 m_rareData->m_pageLogicalOffset = logicalOffset; 4380 m_rareData->m_pageLogicalOffset = logicalOffset;
4382 } 4381 }
4383 4382
4384 void RenderBlock::setBreakAtLineToAvoidWidow(int lineToBreak)
4385 {
4386 ASSERT(lineToBreak >= 0);
4387 if (!m_rareData)
4388 m_rareData = adoptPtr(new RenderBlockRareData());
4389
4390 ASSERT(!m_rareData->m_didBreakAtLineToAvoidWidow);
4391 m_rareData->m_lineBreakToAvoidWidow = lineToBreak;
4392 }
4393
4394 void RenderBlock::setDidBreakAtLineToAvoidWidow()
4395 {
4396 ASSERT(!shouldBreakAtLineToAvoidWidow());
4397
4398 // This function should be called only after a break was applied to avoid wi dows
4399 // so assert |m_rareData| exists.
4400 ASSERT(m_rareData);
4401
4402 m_rareData->m_didBreakAtLineToAvoidWidow = true;
4403 }
4404
4405 void RenderBlock::clearDidBreakAtLineToAvoidWidow()
4406 {
4407 if (!m_rareData)
4408 return;
4409
4410 m_rareData->m_didBreakAtLineToAvoidWidow = false;
4411 }
4412
4413 void RenderBlock::clearShouldBreakAtLineToAvoidWidow() const
4414 {
4415 ASSERT(shouldBreakAtLineToAvoidWidow());
4416 if (!m_rareData)
4417 return;
4418
4419 m_rareData->m_lineBreakToAvoidWidow = -1;
4420 }
4421
4422 void RenderBlock::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accum ulatedOffset) const 4383 void RenderBlock::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accum ulatedOffset) const
4423 { 4384 {
4424 // For blocks inside inlines, we go ahead and include margins so that we run right up to the 4385 // For blocks inside inlines, we go ahead and include margins so that we run right up to the
4425 // inline boxes above and below us (thus getting merged with them to form a single irregular 4386 // inline boxes above and below us (thus getting merged with them to form a single irregular
4426 // shape). 4387 // shape).
4427 if (isAnonymousBlockContinuation()) { 4388 if (isAnonymousBlockContinuation()) {
4428 // FIXME: This is wrong for block-flows that are horizontal. 4389 // FIXME: This is wrong for block-flows that are horizontal.
4429 // https://bugs.webkit.org/show_bug.cgi?id=46781 4390 // https://bugs.webkit.org/show_bug.cgi?id=46781
4430 rects.append(pixelSnappedIntRect(accumulatedOffset.x(), accumulatedOffse t.y() - collapsedMarginBefore(), 4391 rects.append(pixelSnappedIntRect(accumulatedOffset.x(), accumulatedOffse t.y() - collapsedMarginBefore(),
4431 width(), height() + collapsedMarginBefore() + co llapsedMarginAfter())); 4392 width(), height() + collapsedMarginBefore() + co llapsedMarginAfter()));
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
4939 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 4900 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
4940 { 4901 {
4941 showRenderObject(); 4902 showRenderObject();
4942 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 4903 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
4943 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 4904 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
4944 } 4905 }
4945 4906
4946 #endif 4907 #endif
4947 4908
4948 } // namespace WebCore 4909 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderBlockFlow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698