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

Side by Side Diff: Source/core/layout/line/RootInlineBox.cpp

Issue 1162383003: C++11: Replace 0 with nullptr where applicable in layout code. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add one more file. Created 5 years, 6 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
« no previous file with comments | « Source/core/layout/line/LineLayoutState.h ('k') | Source/core/layout/line/TrailingObjects.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) 2003, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 27 matching lines...) Expand all
38 38
39 struct SameSizeAsRootInlineBox : public InlineFlowBox { 39 struct SameSizeAsRootInlineBox : public InlineFlowBox {
40 unsigned unsignedVariable; 40 unsigned unsignedVariable;
41 void* pointers[3]; 41 void* pointers[3];
42 LayoutUnit layoutVariables[6]; 42 LayoutUnit layoutVariables[6];
43 }; 43 };
44 44
45 static_assert(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), "RootInl ineBox should stay small"); 45 static_assert(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), "RootInl ineBox should stay small");
46 46
47 typedef WTF::HashMap<const RootInlineBox*, EllipsisBox*> EllipsisBoxMap; 47 typedef WTF::HashMap<const RootInlineBox*, EllipsisBox*> EllipsisBoxMap;
48 static EllipsisBoxMap* gEllipsisBoxMap = 0; 48 static EllipsisBoxMap* gEllipsisBoxMap = nullptr;
49 49
50 RootInlineBox::RootInlineBox(LayoutBlockFlow& block) 50 RootInlineBox::RootInlineBox(LayoutBlockFlow& block)
51 : InlineFlowBox(block) 51 : InlineFlowBox(block)
52 , m_lineBreakPos(0) 52 , m_lineBreakPos(0)
53 , m_lineBreakObj(0) 53 , m_lineBreakObj(nullptr)
54 , m_lineTop(0) 54 , m_lineTop(0)
55 , m_lineBottom(0) 55 , m_lineBottom(0)
56 , m_lineTopWithLeading(0) 56 , m_lineTopWithLeading(0)
57 , m_lineBottomWithLeading(0) 57 , m_lineBottomWithLeading(0)
58 , m_selectionBottom(0) 58 , m_selectionBottom(0)
59 , m_paginationStrut(0) 59 , m_paginationStrut(0)
60 { 60 {
61 setIsHorizontal(block.isHorizontalWritingMode()); 61 setIsHorizontal(block.isHorizontalWritingMode());
62 } 62 }
63 63
64 64
65 void RootInlineBox::destroy() 65 void RootInlineBox::destroy()
66 { 66 {
67 detachEllipsisBox(); 67 detachEllipsisBox();
68 InlineFlowBox::destroy(); 68 InlineFlowBox::destroy();
69 } 69 }
70 70
71 void RootInlineBox::detachEllipsisBox() 71 void RootInlineBox::detachEllipsisBox()
72 { 72 {
73 if (hasEllipsisBox()) { 73 if (hasEllipsisBox()) {
74 EllipsisBox* box = gEllipsisBoxMap->take(this); 74 EllipsisBox* box = gEllipsisBoxMap->take(this);
75 box->setParent(0); 75 box->setParent(nullptr);
76 box->destroy(); 76 box->destroy();
77 setHasEllipsisBox(false); 77 setHasEllipsisBox(false);
78 } 78 }
79 } 79 }
80 80
81 LineBoxList* RootInlineBox::lineBoxes() const 81 LineBoxList* RootInlineBox::lineBoxes() const
82 { 82 {
83 return block().lineBoxes(); 83 return block().lineBoxes();
84 } 84 }
85 85
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 return state; 354 return state;
355 } 355 }
356 356
357 InlineBox* RootInlineBox::firstSelectedBox() const 357 InlineBox* RootInlineBox::firstSelectedBox() const
358 { 358 {
359 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { 359 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) {
360 if (box->selectionState() != LayoutObject::SelectionNone) 360 if (box->selectionState() != LayoutObject::SelectionNone)
361 return box; 361 return box;
362 } 362 }
363 363
364 return 0; 364 return nullptr;
365 } 365 }
366 366
367 InlineBox* RootInlineBox::lastSelectedBox() const 367 InlineBox* RootInlineBox::lastSelectedBox() const
368 { 368 {
369 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) { 369 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) {
370 if (box->selectionState() != LayoutObject::SelectionNone) 370 if (box->selectionState() != LayoutObject::SelectionNone)
371 return box; 371 return box;
372 } 372 }
373 373
374 return 0; 374 return nullptr;
375 } 375 }
376 376
377 LayoutUnit RootInlineBox::selectionTop() const 377 LayoutUnit RootInlineBox::selectionTop() const
378 { 378 {
379 LayoutUnit selectionTop = m_lineTop; 379 LayoutUnit selectionTop = m_lineTop;
380 380
381 if (m_hasAnnotationsBefore) 381 if (m_hasAnnotationsBefore)
382 selectionTop -= !layoutObject().style()->isFlippedLinesWritingMode() ? c omputeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_l ineTop); 382 selectionTop -= !layoutObject().style()->isFlippedLinesWritingMode() ? c omputeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_l ineTop);
383 383
384 if (layoutObject().style()->isFlippedLinesWritingMode() || !prevRootBox()) 384 if (layoutObject().style()->isFlippedLinesWritingMode() || !prevRootBox())
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // Return it. 492 // Return it.
493 return firstLeaf; 493 return firstLeaf;
494 } 494 }
495 495
496 if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->layoutObject().is ListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) { 496 if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->layoutObject().is ListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) {
497 // The leftPosition coordinate is greater or equal to right edge of the lastLeaf. 497 // The leftPosition coordinate is greater or equal to right edge of the lastLeaf.
498 // Return it. 498 // Return it.
499 return lastLeaf; 499 return lastLeaf;
500 } 500 }
501 501
502 InlineBox* closestLeaf = 0; 502 InlineBox* closestLeaf = nullptr;
503 for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChildIgnoringLi neBreak()) { 503 for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChildIgnoringLi neBreak()) {
504 if (!leaf->layoutObject().isListMarker() && (!onlyEditableLeaves || isEd itableLeaf(leaf))) { 504 if (!leaf->layoutObject().isListMarker() && (!onlyEditableLeaves || isEd itableLeaf(leaf))) {
505 closestLeaf = leaf; 505 closestLeaf = leaf;
506 if (leftPosition < leaf->logicalRight()) { 506 if (leftPosition < leaf->logicalRight()) {
507 // The x coordinate is less than the right edge of the box. 507 // The x coordinate is less than the right edge of the box.
508 // Return it. 508 // Return it.
509 return leaf; 509 return leaf;
510 } 510 }
511 } 511 }
512 } 512 }
(...skipping 19 matching lines...) Expand all
532 m_lineBreakPos = breakPos; 532 m_lineBreakPos = breakPos;
533 m_lineBreakBidiStatusEor = status.eor; 533 m_lineBreakBidiStatusEor = status.eor;
534 m_lineBreakBidiStatusLastStrong = status.lastStrong; 534 m_lineBreakBidiStatusLastStrong = status.lastStrong;
535 m_lineBreakBidiStatusLast = status.last; 535 m_lineBreakBidiStatusLast = status.last;
536 m_lineBreakContext = status.context; 536 m_lineBreakContext = status.context;
537 } 537 }
538 538
539 EllipsisBox* RootInlineBox::ellipsisBox() const 539 EllipsisBox* RootInlineBox::ellipsisBox() const
540 { 540 {
541 if (!hasEllipsisBox()) 541 if (!hasEllipsisBox())
542 return 0; 542 return nullptr;
543 return gEllipsisBoxMap->get(this); 543 return gEllipsisBoxMap->get(this);
544 } 544 }
545 545
546 void RootInlineBox::removeLineBoxFromLayoutObject() 546 void RootInlineBox::removeLineBoxFromLayoutObject()
547 { 547 {
548 block().lineBoxes()->removeLineBox(this); 548 block().lineBoxes()->removeLineBox(this);
549 } 549 }
550 550
551 void RootInlineBox::extractLineBoxFromLayoutObject() 551 void RootInlineBox::extractLineBoxFromLayoutObject()
552 { 552 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 ascent = box->baselinePosition(baselineType()); 602 ascent = box->baselinePosition(baselineType());
603 descent = box->lineHeight() - ascent; 603 descent = box->lineHeight() - ascent;
604 604
605 // Replaced elements always affect both the ascent and descent. 605 // Replaced elements always affect both the ascent and descent.
606 affectsAscent = true; 606 affectsAscent = true;
607 affectsDescent = true; 607 affectsDescent = true;
608 } 608 }
609 return; 609 return;
610 } 610 }
611 611
612 Vector<const SimpleFontData*>* usedFonts = 0; 612 Vector<const SimpleFontData*>* usedFonts = nullptr;
613 GlyphOverflow* glyphOverflow = 0; 613 GlyphOverflow* glyphOverflow = nullptr;
614 if (box->isText()) { 614 if (box->isText()) {
615 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toIn lineTextBox(box)); 615 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toIn lineTextBox(box));
616 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; 616 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first;
617 glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second; 617 glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second;
618 } 618 }
619 619
620 bool includeLeading = includeLeadingForBox(box); 620 bool includeLeading = includeLeadingForBox(box);
621 bool includeFont = includeFontForBox(box); 621 bool includeFont = includeFontForBox(box);
622 622
623 bool setUsedFont = false; 623 bool setUsedFont = false;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const 823 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const
824 { 824 {
825 Vector<InlineBox*> leafBoxesInLogicalOrder; 825 Vector<InlineBox*> leafBoxesInLogicalOrder;
826 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); 826 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder);
827 for (size_t i = 0; i < leafBoxesInLogicalOrder.size(); ++i) { 827 for (size_t i = 0; i < leafBoxesInLogicalOrder.size(); ++i) {
828 if (leafBoxesInLogicalOrder[i]->layoutObject().nonPseudoNode()) { 828 if (leafBoxesInLogicalOrder[i]->layoutObject().nonPseudoNode()) {
829 startBox = leafBoxesInLogicalOrder[i]; 829 startBox = leafBoxesInLogicalOrder[i];
830 return startBox->layoutObject().nonPseudoNode(); 830 return startBox->layoutObject().nonPseudoNode();
831 } 831 }
832 } 832 }
833 startBox = 0; 833 startBox = nullptr;
834 return 0; 834 return nullptr;
835 } 835 }
836 836
837 Node* RootInlineBox::getLogicalEndBoxWithNode(InlineBox*& endBox) const 837 Node* RootInlineBox::getLogicalEndBoxWithNode(InlineBox*& endBox) const
838 { 838 {
839 Vector<InlineBox*> leafBoxesInLogicalOrder; 839 Vector<InlineBox*> leafBoxesInLogicalOrder;
840 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); 840 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder);
841 for (size_t i = leafBoxesInLogicalOrder.size(); i > 0; --i) { 841 for (size_t i = leafBoxesInLogicalOrder.size(); i > 0; --i) {
842 if (leafBoxesInLogicalOrder[i - 1]->layoutObject().nonPseudoNode()) { 842 if (leafBoxesInLogicalOrder[i - 1]->layoutObject().nonPseudoNode()) {
843 endBox = leafBoxesInLogicalOrder[i - 1]; 843 endBox = leafBoxesInLogicalOrder[i - 1];
844 return endBox->layoutObject().nonPseudoNode(); 844 return endBox->layoutObject().nonPseudoNode();
845 } 845 }
846 } 846 }
847 endBox = 0; 847 endBox = nullptr;
848 return 0; 848 return nullptr;
849 } 849 }
850 850
851 const char* RootInlineBox::boxName() const 851 const char* RootInlineBox::boxName() const
852 { 852 {
853 return "RootInlineBox"; 853 return "RootInlineBox";
854 } 854 }
855 855
856 } // namespace blink 856 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/line/LineLayoutState.h ('k') | Source/core/layout/line/TrailingObjects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698