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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp

Issue 2770123003: Replace ASSERT with DCHECK in core/layout/ excluding subdirs (Closed)
Patch Set: Split some DCHECKs and add DCHECK_ops wherever possible Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); 46 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread);
47 layoutObject->setDocumentForAnonymous(&document); 47 layoutObject->setDocumentForAnonymous(&document);
48 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay( 48 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(
49 parentStyle, EDisplay::kBlock)); 49 parentStyle, EDisplay::kBlock));
50 return layoutObject; 50 return layoutObject;
51 } 51 }
52 52
53 unsigned LayoutMultiColumnSet::fragmentainerGroupIndexAtFlowThreadOffset( 53 unsigned LayoutMultiColumnSet::fragmentainerGroupIndexAtFlowThreadOffset(
54 LayoutUnit flowThreadOffset, 54 LayoutUnit flowThreadOffset,
55 PageBoundaryRule rule) const { 55 PageBoundaryRule rule) const {
56 ASSERT(m_fragmentainerGroups.size() > 0); 56 DCHECK_GT(m_fragmentainerGroups.size(), 0u);
57 if (flowThreadOffset <= 0) 57 if (flowThreadOffset <= 0)
58 return 0; 58 return 0;
59 // TODO(mstensho): Introduce an interval tree or similar to speed up this. 59 // TODO(mstensho): Introduce an interval tree or similar to speed up this.
60 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) { 60 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) {
61 const auto& row = m_fragmentainerGroups[index]; 61 const auto& row = m_fragmentainerGroups[index];
62 if (rule == AssociateWithLatterPage) { 62 if (rule == AssociateWithLatterPage) {
63 if (row.logicalTopInFlowThread() <= flowThreadOffset && 63 if (row.logicalTopInFlowThread() <= flowThreadOffset &&
64 row.logicalBottomInFlowThread() > flowThreadOffset) 64 row.logicalBottomInFlowThread() > flowThreadOffset)
65 return index; 65 return index;
66 } else if (row.logicalTopInFlowThread() < flowThreadOffset && 66 } else if (row.logicalTopInFlowThread() < flowThreadOffset &&
67 row.logicalBottomInFlowThread() >= flowThreadOffset) { 67 row.logicalBottomInFlowThread() >= flowThreadOffset) {
68 return index; 68 return index;
69 } 69 }
70 } 70 }
71 return m_fragmentainerGroups.size() - 1; 71 return m_fragmentainerGroups.size() - 1;
72 } 72 }
73 73
74 const MultiColumnFragmentainerGroup& 74 const MultiColumnFragmentainerGroup&
75 LayoutMultiColumnSet::fragmentainerGroupAtVisualPoint( 75 LayoutMultiColumnSet::fragmentainerGroupAtVisualPoint(
76 const LayoutPoint& visualPoint) const { 76 const LayoutPoint& visualPoint) const {
77 ASSERT(m_fragmentainerGroups.size() > 0); 77 DCHECK_GT(m_fragmentainerGroups.size(), 0u);
78 LayoutUnit blockOffset = 78 LayoutUnit blockOffset =
79 isHorizontalWritingMode() ? visualPoint.y() : visualPoint.x(); 79 isHorizontalWritingMode() ? visualPoint.y() : visualPoint.x();
80 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) { 80 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) {
81 const auto& row = m_fragmentainerGroups[index]; 81 const auto& row = m_fragmentainerGroups[index];
82 if (row.logicalTop() + row.logicalHeight() > blockOffset) 82 if (row.logicalTop() + row.logicalHeight() > blockOffset)
83 return row; 83 return row;
84 } 84 }
85 return m_fragmentainerGroups.last(); 85 return m_fragmentainerGroups.last();
86 } 86 }
87 87
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // we need to balance at all), so we want that last fragmentainer group to 176 // we need to balance at all), so we want that last fragmentainer group to
177 // be the same one in all layout passes that follow. 177 // be the same one in all layout passes that follow.
178 return false; 178 return false;
179 } 179 }
180 return true; 180 return true;
181 } 181 }
182 182
183 LayoutUnit LayoutMultiColumnSet::nextLogicalTopForUnbreakableContent( 183 LayoutUnit LayoutMultiColumnSet::nextLogicalTopForUnbreakableContent(
184 LayoutUnit flowThreadOffset, 184 LayoutUnit flowThreadOffset,
185 LayoutUnit contentLogicalHeight) const { 185 LayoutUnit contentLogicalHeight) const {
186 ASSERT(flowThreadOffset.mightBeSaturated() || 186 DCHECK(flowThreadOffset.mightBeSaturated() ||
187 pageLogicalTopForOffset(flowThreadOffset) == flowThreadOffset); 187 pageLogicalTopForOffset(flowThreadOffset) == flowThreadOffset);
188 FragmentationContext* enclosingFragmentationContext = 188 FragmentationContext* enclosingFragmentationContext =
189 multiColumnFlowThread()->enclosingFragmentationContext(); 189 multiColumnFlowThread()->enclosingFragmentationContext();
190 if (!enclosingFragmentationContext) { 190 if (!enclosingFragmentationContext) {
191 // If there's no enclosing fragmentation context, there'll ever be only one 191 // If there's no enclosing fragmentation context, there'll ever be only one
192 // row, and all columns there will have the same height. 192 // row, and all columns there will have the same height.
193 return flowThreadOffset; 193 return flowThreadOffset;
194 } 194 }
195 195
196 // Assert the problematic situation. If we have no problem with the column 196 // Assert the problematic situation. If we have no problem with the column
197 // height, why are we even here? 197 // height, why are we even here?
198 ASSERT(pageLogicalHeightForOffset(flowThreadOffset) < contentLogicalHeight); 198 DCHECK_LT(pageLogicalHeightForOffset(flowThreadOffset), contentLogicalHeight);
199 199
200 // There's a likelihood for subsequent rows to be taller than the first one. 200 // There's a likelihood for subsequent rows to be taller than the first one.
201 // TODO(mstensho): if we're doubly nested (e.g. multicol in multicol in 201 // TODO(mstensho): if we're doubly nested (e.g. multicol in multicol in
202 // multicol), we need to look beyond the first row here. 202 // multicol), we need to look beyond the first row here.
203 const MultiColumnFragmentainerGroup& firstRow = firstFragmentainerGroup(); 203 const MultiColumnFragmentainerGroup& firstRow = firstFragmentainerGroup();
204 LayoutUnit firstRowLogicalBottomInFlowThread = 204 LayoutUnit firstRowLogicalBottomInFlowThread =
205 firstRow.logicalTopInFlowThread() + fragmentainerGroupCapacity(firstRow); 205 firstRow.logicalTopInFlowThread() + fragmentainerGroupCapacity(firstRow);
206 if (flowThreadOffset >= firstRowLogicalBottomInFlowThread) 206 if (flowThreadOffset >= firstRowLogicalBottomInFlowThread)
207 return flowThreadOffset; // We're not in the first row. Give up. 207 return flowThreadOffset; // We're not in the first row. Give up.
208 LayoutUnit newLogicalHeight = 208 LayoutUnit newLogicalHeight =
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 // Now add in column rule bounds, if present. 615 // Now add in column rule bounds, if present.
616 Vector<LayoutRect> columnRuleBounds; 616 Vector<LayoutRect> columnRuleBounds;
617 if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) { 617 if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) {
618 for (auto& bound : columnRuleBounds) 618 for (auto& bound : columnRuleBounds)
619 blockFlowBounds.unite(bound); 619 blockFlowBounds.unite(bound);
620 } 620 }
621 return blockFlowBounds; 621 return blockFlowBounds;
622 } 622 }
623 623
624 } // namespace blink 624 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698