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

Side by Side Diff: third_party/WebKit/Source/core/layout/MultiColumnFragmentainerGroup.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/MultiColumnFragmentainerGroup.h" 5 #include "core/layout/MultiColumnFragmentainerGroup.h"
6 6
7 #include "core/layout/ColumnBalancer.h" 7 #include "core/layout/ColumnBalancer.h"
8 #include "core/layout/FragmentationContext.h" 8 #include "core/layout/FragmentationContext.h"
9 #include "core/layout/LayoutMultiColumnSet.h" 9 #include "core/layout/LayoutMultiColumnSet.h"
10 10
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // Our flow thread portion determines our column count. We have as many 294 // Our flow thread portion determines our column count. We have as many
295 // columns as needed to fit all the content. 295 // columns as needed to fit all the content.
296 LayoutUnit flowThreadPortionHeight = logicalHeightInFlowThread(); 296 LayoutUnit flowThreadPortionHeight = logicalHeightInFlowThread();
297 if (!flowThreadPortionHeight) 297 if (!flowThreadPortionHeight)
298 return 1; 298 return 1;
299 299
300 unsigned count = (flowThreadPortionHeight / m_columnHeight).floor(); 300 unsigned count = (flowThreadPortionHeight / m_columnHeight).floor();
301 // flowThreadPortionHeight may be saturated, so detect the remainder manually. 301 // flowThreadPortionHeight may be saturated, so detect the remainder manually.
302 if (count * m_columnHeight < flowThreadPortionHeight) 302 if (count * m_columnHeight < flowThreadPortionHeight)
303 count++; 303 count++;
304 ASSERT(count >= 1); 304 DCHECK_GE(count, 1u);
305 return count; 305 return count;
306 } 306 }
307 307
308 LayoutUnit MultiColumnFragmentainerGroup::heightAdjustedForRowOffset( 308 LayoutUnit MultiColumnFragmentainerGroup::heightAdjustedForRowOffset(
309 LayoutUnit height) const { 309 LayoutUnit height) const {
310 // Let's avoid zero height, as that would cause an infinite amount of columns 310 // Let's avoid zero height, as that would cause an infinite amount of columns
311 // to be created. 311 // to be created.
312 return std::max( 312 return std::max(
313 height - logicalTop() - m_columnSet.logicalTopFromMulticolContentEdge(), 313 height - logicalTop() - m_columnSet.logicalTopFromMulticolContentEdge(),
314 LayoutUnit(1)); 314 LayoutUnit(1));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (shortageFinder.forcedBreaksCount() + 1 >= m_columnSet.usedColumnCount()) { 362 if (shortageFinder.forcedBreaksCount() + 1 >= m_columnSet.usedColumnCount()) {
363 // Too many forced breaks to allow any implicit breaks. Initial balancing 363 // Too many forced breaks to allow any implicit breaks. Initial balancing
364 // should already have set a good height. There's nothing more we should do. 364 // should already have set a good height. There's nothing more we should do.
365 return m_columnHeight; 365 return m_columnHeight;
366 } 366 }
367 367
368 // If the initial guessed column height wasn't enough, stretch it now. Stretch 368 // If the initial guessed column height wasn't enough, stretch it now. Stretch
369 // by the lowest amount of space. 369 // by the lowest amount of space.
370 LayoutUnit minSpaceShortage = shortageFinder.minimumSpaceShortage(); 370 LayoutUnit minSpaceShortage = shortageFinder.minimumSpaceShortage();
371 371
372 ASSERT(minSpaceShortage > 0); // We should never _shrink_ the height! 372 DCHECK_GT(minSpaceShortage, 0); // We should never _shrink_ the height!
373 ASSERT(minSpaceShortage != 373 DCHECK_NE(minSpaceShortage,
374 LayoutUnit::max()); // If this happens, we probably have a bug. 374 LayoutUnit::max()); // If this happens, we probably have a bug.
375 if (minSpaceShortage == LayoutUnit::max()) 375 if (minSpaceShortage == LayoutUnit::max())
376 return m_columnHeight; // So bail out rather than looping infinitely. 376 return m_columnHeight; // So bail out rather than looping infinitely.
377 377
378 return m_columnHeight + minSpaceShortage; 378 return m_columnHeight + minSpaceShortage;
379 } 379 }
380 380
381 LayoutRect MultiColumnFragmentainerGroup::columnRectAt( 381 LayoutRect MultiColumnFragmentainerGroup::columnRectAt(
382 unsigned columnIndex) const { 382 unsigned columnIndex) const {
383 LayoutUnit columnLogicalWidth = m_columnSet.pageLogicalWidth(); 383 LayoutUnit columnLogicalWidth = m_columnSet.pageLogicalWidth();
384 LayoutUnit columnLogicalHeight = logicalHeightInFlowThreadAt(columnIndex); 384 LayoutUnit columnLogicalHeight = logicalHeightInFlowThreadAt(columnIndex);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 571 }
572 } else { 572 } else {
573 if (isFlippedColumnProgression) { 573 if (isFlippedColumnProgression) {
574 firstColumn = columnIndexAtVisualPoint(rect.minXMaxYCorner()); 574 firstColumn = columnIndexAtVisualPoint(rect.minXMaxYCorner());
575 lastColumn = columnIndexAtVisualPoint(rect.minXMinYCorner()); 575 lastColumn = columnIndexAtVisualPoint(rect.minXMinYCorner());
576 } else { 576 } else {
577 firstColumn = columnIndexAtVisualPoint(rect.minXMinYCorner()); 577 firstColumn = columnIndexAtVisualPoint(rect.minXMinYCorner());
578 lastColumn = columnIndexAtVisualPoint(rect.minXMaxYCorner()); 578 lastColumn = columnIndexAtVisualPoint(rect.minXMaxYCorner());
579 } 579 }
580 } 580 }
581 ASSERT(firstColumn <= lastColumn); 581 DCHECK_LE(firstColumn, lastColumn);
582 } 582 }
583 583
584 MultiColumnFragmentainerGroupList::MultiColumnFragmentainerGroupList( 584 MultiColumnFragmentainerGroupList::MultiColumnFragmentainerGroupList(
585 LayoutMultiColumnSet& columnSet) 585 LayoutMultiColumnSet& columnSet)
586 : m_columnSet(columnSet) { 586 : m_columnSet(columnSet) {
587 append(MultiColumnFragmentainerGroup(m_columnSet)); 587 append(MultiColumnFragmentainerGroup(m_columnSet));
588 } 588 }
589 589
590 // An explicit empty destructor of MultiColumnFragmentainerGroupList should be 590 // An explicit empty destructor of MultiColumnFragmentainerGroupList should be
591 // in MultiColumnFragmentainerGroup.cpp, because if an implicit destructor is 591 // in MultiColumnFragmentainerGroup.cpp, because if an implicit destructor is
592 // used, msvc 2015 tries to generate its destructor (because the class is 592 // used, msvc 2015 tries to generate its destructor (because the class is
593 // dll-exported class) and causes a compile error because of lack of 593 // dll-exported class) and causes a compile error because of lack of
594 // MultiColumnFragmentainerGroup::operator=. Since 594 // MultiColumnFragmentainerGroup::operator=. Since
595 // MultiColumnFragmentainerGroup is non-copyable, we cannot define the 595 // MultiColumnFragmentainerGroup is non-copyable, we cannot define the
596 // operator=. 596 // operator=.
597 MultiColumnFragmentainerGroupList::~MultiColumnFragmentainerGroupList() {} 597 MultiColumnFragmentainerGroupList::~MultiColumnFragmentainerGroupList() {}
598 598
599 MultiColumnFragmentainerGroup& 599 MultiColumnFragmentainerGroup&
600 MultiColumnFragmentainerGroupList::addExtraGroup() { 600 MultiColumnFragmentainerGroupList::addExtraGroup() {
601 append(MultiColumnFragmentainerGroup(m_columnSet)); 601 append(MultiColumnFragmentainerGroup(m_columnSet));
602 return last(); 602 return last();
603 } 603 }
604 604
605 void MultiColumnFragmentainerGroupList::deleteExtraGroups() { 605 void MultiColumnFragmentainerGroupList::deleteExtraGroups() {
606 shrink(1); 606 shrink(1);
607 } 607 }
608 608
609 } // namespace blink 609 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698