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

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

Issue 2748103015: Replace ASSERT with DCHECK in core/layout/<sub dirs> (Closed)
Patch Set: Rebase with latest 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 void InlineTextBox::destroy() { 55 void InlineTextBox::destroy() {
56 AbstractInlineTextBox::willDestroy(this); 56 AbstractInlineTextBox::willDestroy(this);
57 57
58 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) 58 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow)
59 gTextBoxesWithOverflow->erase(this); 59 gTextBoxesWithOverflow->erase(this);
60 InlineBox::destroy(); 60 InlineBox::destroy();
61 } 61 }
62 62
63 void InlineTextBox::offsetRun(int delta) { 63 void InlineTextBox::offsetRun(int delta) {
64 ASSERT(!isDirty()); 64 DCHECK(!isDirty());
65 m_start += delta; 65 m_start += delta;
66 } 66 }
67 67
68 void InlineTextBox::markDirty() { 68 void InlineTextBox::markDirty() {
69 m_len = 0; 69 m_len = 0;
70 m_start = 0; 70 m_start = 0;
71 InlineBox::markDirty(); 71 InlineBox::markDirty();
72 } 72 }
73 73
74 LayoutRect InlineTextBox::logicalOverflowRect() const { 74 LayoutRect InlineTextBox::logicalOverflowRect() const {
75 if (knownToHaveNoOverflow() || !gTextBoxesWithOverflow) 75 if (knownToHaveNoOverflow() || !gTextBoxesWithOverflow)
76 return logicalFrameRect(); 76 return logicalFrameRect();
77 77
78 const auto& it = gTextBoxesWithOverflow->find(this); 78 const auto& it = gTextBoxesWithOverflow->find(this);
79 if (it != gTextBoxesWithOverflow->end()) 79 if (it != gTextBoxesWithOverflow->end())
80 return it->value; 80 return it->value;
81 81
82 return logicalFrameRect(); 82 return logicalFrameRect();
83 } 83 }
84 84
85 void InlineTextBox::setLogicalOverflowRect(const LayoutRect& rect) { 85 void InlineTextBox::setLogicalOverflowRect(const LayoutRect& rect) {
86 ASSERT(!knownToHaveNoOverflow()); 86 DCHECK(!knownToHaveNoOverflow());
87 DCHECK(rect != logicalFrameRect()); 87 DCHECK(rect != logicalFrameRect());
88 if (!gTextBoxesWithOverflow) 88 if (!gTextBoxesWithOverflow)
89 gTextBoxesWithOverflow = new InlineTextBoxOverflowMap; 89 gTextBoxesWithOverflow = new InlineTextBoxOverflowMap;
90 gTextBoxesWithOverflow->set(this, rect); 90 gTextBoxesWithOverflow->set(this, rect);
91 } 91 }
92 92
93 void InlineTextBox::move(const LayoutSize& delta) { 93 void InlineTextBox::move(const LayoutSize& delta) {
94 InlineBox::move(delta); 94 InlineBox::move(delta);
95 95
96 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) { 96 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 569
570 LineLayoutText text = getLineLayoutItem(); 570 LineLayoutText text = getLineLayoutItem();
571 const ComputedStyle& style = text.styleRef(isFirstLineStyle()); 571 const ComputedStyle& style = text.styleRef(isFirstLineStyle());
572 const Font& font = style.font(); 572 const Font& font = style.font();
573 return font.offsetForPosition(constructTextRun(style), 573 return font.offsetForPosition(constructTextRun(style),
574 (lineOffset - logicalLeft()).toFloat(), 574 (lineOffset - logicalLeft()).toFloat(),
575 includePartialGlyphs); 575 includePartialGlyphs);
576 } 576 }
577 577
578 LayoutUnit InlineTextBox::positionForOffset(int offset) const { 578 LayoutUnit InlineTextBox::positionForOffset(int offset) const {
579 ASSERT(offset >= m_start); 579 DCHECK_GE(offset, m_start);
580 ASSERT(offset <= m_start + m_len); 580 DCHECK_LE(offset, m_start + m_len);
581 581
582 if (isLineBreak()) 582 if (isLineBreak())
583 return logicalLeft(); 583 return logicalLeft();
584 584
585 LineLayoutText text = getLineLayoutItem(); 585 LineLayoutText text = getLineLayoutItem();
586 const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle()); 586 const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle());
587 const Font& font = styleToUse.font(); 587 const Font& font = styleToUse.font();
588 int from = !isLeftToRightDirection() ? offset - m_start : 0; 588 int from = !isLeftToRightDirection() ? offset - m_start : 0;
589 int to = !isLeftToRightDirection() ? m_len : offset - m_start; 589 int to = !isLeftToRightDirection() ? m_len : offset - m_start;
590 // FIXME: Do we need to add rightBearing here? 590 // FIXME: Do we need to add rightBearing here?
(...skipping 25 matching lines...) Expand all
616 // Offsets at the end are "in" for normal boxes (but the caller has to check 616 // Offsets at the end are "in" for normal boxes (but the caller has to check
617 // affinity). 617 // affinity).
618 return true; 618 return true;
619 } 619 }
620 620
621 void InlineTextBox::characterWidths(Vector<float>& widths) const { 621 void InlineTextBox::characterWidths(Vector<float>& widths) const {
622 if (!m_len) 622 if (!m_len)
623 return; 623 return;
624 624
625 FontCachePurgePreventer fontCachePurgePreventer; 625 FontCachePurgePreventer fontCachePurgePreventer;
626 ASSERT(getLineLayoutItem().text()); 626 DCHECK(getLineLayoutItem().text());
627 627
628 const ComputedStyle& styleToUse = 628 const ComputedStyle& styleToUse =
629 getLineLayoutItem().styleRef(isFirstLineStyle()); 629 getLineLayoutItem().styleRef(isFirstLineStyle());
630 const Font& font = styleToUse.font(); 630 const Font& font = styleToUse.font();
631 631
632 TextRun textRun = constructTextRun(styleToUse); 632 TextRun textRun = constructTextRun(styleToUse);
633 Vector<CharacterRange> ranges = font.individualCharacterRanges(textRun); 633 Vector<CharacterRange> ranges = font.individualCharacterRanges(textRun);
634 DCHECK_EQ(ranges.size(), m_len); 634 DCHECK_EQ(ranges.size(), m_len);
635 635
636 widths.resize(ranges.size()); 636 widths.resize(ranges.size());
637 for (unsigned i = 0; i < ranges.size(); i++) 637 for (unsigned i = 0; i < ranges.size(); i++)
638 widths[i] = ranges[i].width(); 638 widths[i] = ranges[i].width();
639 } 639 }
640 640
641 TextRun InlineTextBox::constructTextRun( 641 TextRun InlineTextBox::constructTextRun(
642 const ComputedStyle& style, 642 const ComputedStyle& style,
643 StringBuilder* charactersWithHyphen) const { 643 StringBuilder* charactersWithHyphen) const {
644 ASSERT(getLineLayoutItem().text()); 644 DCHECK(getLineLayoutItem().text());
645 645
646 String string = getLineLayoutItem().text(); 646 String string = getLineLayoutItem().text();
647 unsigned startPos = start(); 647 unsigned startPos = start();
648 unsigned length = len(); 648 unsigned length = len();
649 // Ensure |this| is in sync with the corresponding LayoutText. Checking here 649 // Ensure |this| is in sync with the corresponding LayoutText. Checking here
650 // has less binary size/perf impact than in StringView(). 650 // has less binary size/perf impact than in StringView().
651 CHECK_LE(startPos, string.length()); 651 CHECK_LE(startPos, string.length());
652 CHECK_LE(length, string.length() - startPos); 652 CHECK_LE(length, string.length() - startPos);
653 return constructTextRun(style, StringView(string, startPos, length), 653 return constructTextRun(style, StringView(string, startPos, length),
654 getLineLayoutItem().textLength() - startPos, 654 getLineLayoutItem().textLength() - startPos,
655 charactersWithHyphen); 655 charactersWithHyphen);
656 } 656 }
657 657
658 TextRun InlineTextBox::constructTextRun( 658 TextRun InlineTextBox::constructTextRun(
659 const ComputedStyle& style, 659 const ComputedStyle& style,
660 StringView string, 660 StringView string,
661 int maximumLength, 661 int maximumLength,
662 StringBuilder* charactersWithHyphen) const { 662 StringBuilder* charactersWithHyphen) const {
663 if (charactersWithHyphen) { 663 if (charactersWithHyphen) {
664 const AtomicString& hyphenString = style.hyphenString(); 664 const AtomicString& hyphenString = style.hyphenString();
665 charactersWithHyphen->reserveCapacity(string.length() + 665 charactersWithHyphen->reserveCapacity(string.length() +
666 hyphenString.length()); 666 hyphenString.length());
667 charactersWithHyphen->append(string); 667 charactersWithHyphen->append(string);
668 charactersWithHyphen->append(hyphenString); 668 charactersWithHyphen->append(hyphenString);
669 string = charactersWithHyphen->toString(); 669 string = charactersWithHyphen->toString();
670 maximumLength = string.length(); 670 maximumLength = string.length();
671 } 671 }
672 672
673 ASSERT(maximumLength >= static_cast<int>(string.length())); 673 DCHECK_GE(maximumLength, static_cast<int>(string.length()));
674 674
675 TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(), 675 TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(),
676 direction(), 676 direction(),
677 dirOverride() || style.rtlOrdering() == EOrder::kVisual); 677 dirOverride() || style.rtlOrdering() == EOrder::kVisual);
678 run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize()); 678 run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize());
679 run.setTextJustify(style.getTextJustify()); 679 run.setTextJustify(style.getTextJustify());
680 680
681 // Propagate the maximum length of the characters buffer to the TextRun, even 681 // Propagate the maximum length of the characters buffer to the TextRun, even
682 // when we're only processing a substring. 682 // when we're only processing a substring.
683 run.setCharactersLength(maximumLength); 683 run.setCharactersLength(maximumLength);
684 ASSERT(run.charactersLength() >= run.length()); 684 DCHECK_GE(run.charactersLength(), run.length());
685 return run; 685 return run;
686 } 686 }
687 687
688 TextRun InlineTextBox::constructTextRunForInspector( 688 TextRun InlineTextBox::constructTextRunForInspector(
689 const ComputedStyle& style) const { 689 const ComputedStyle& style) const {
690 return InlineTextBox::constructTextRun(style); 690 return InlineTextBox::constructTextRun(style);
691 } 691 }
692 692
693 const char* InlineTextBox::boxName() const { 693 const char* InlineTextBox::boxName() const {
694 return "InlineTextBox"; 694 return "InlineTextBox";
(...skipping 22 matching lines...) Expand all
717 const int layoutObjectCharacterOffset = 75; 717 const int layoutObjectCharacterOffset = 75;
718 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) 718 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++)
719 fputc(' ', stderr); 719 fputc(' ', stderr);
720 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), 720 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(),
721 value.utf8().data()); 721 value.utf8().data());
722 } 722 }
723 723
724 #endif 724 #endif
725 725
726 } // namespace blink 726 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/line/InlineTextBox.h ('k') | third_party/WebKit/Source/core/layout/line/LineBoxList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698