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

Side by Side Diff: Source/core/layout/line/TrailingObjects.h

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/RootInlineBox.cpp ('k') | Source/core/layout/line/WordMeasurement.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) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * Copyright (C) 2014 Adobe Systems Inc. 5 * Copyright (C) 2014 Adobe Systems Inc.
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // In both of the above snippets the inline and the positioned object occur afte r a trailing space 48 // In both of the above snippets the inline and the positioned object occur afte r a trailing space
49 // and before a space that will cause our line breaking algorithm to start ignor ing spaces. When it 49 // and before a space that will cause our line breaking algorithm to start ignor ing spaces. When it
50 // does that we want to ensure that the inline/positioned object gets a linebox and that it is part 50 // does that we want to ensure that the inline/positioned object gets a linebox and that it is part
51 // of the collapsed whitespace. So to achieve this we use appendObjectIfNeeded() to keep track of 51 // of the collapsed whitespace. So to achieve this we use appendObjectIfNeeded() to keep track of
52 // objects encountered after a trailing whitespace and updateMidpointsForTrailin gObjects() to put 52 // objects encountered after a trailing whitespace and updateMidpointsForTrailin gObjects() to put
53 // them in the right place when we start ignoring surplus whitespace. 53 // them in the right place when we start ignoring surplus whitespace.
54 54
55 class TrailingObjects { 55 class TrailingObjects {
56 public: 56 public:
57 TrailingObjects() 57 TrailingObjects()
58 : m_whitespace(0) 58 : m_whitespace(nullptr)
59 { 59 {
60 } 60 }
61 61
62 void setTrailingWhitespace(LayoutText* whitespace) 62 void setTrailingWhitespace(LayoutText* whitespace)
63 { 63 {
64 ASSERT(whitespace); 64 ASSERT(whitespace);
65 m_whitespace = whitespace; 65 m_whitespace = whitespace;
66 } 66 }
67 67
68 void clear() 68 void clear()
69 { 69 {
70 m_whitespace = 0; 70 m_whitespace = nullptr;
71 // Using resize(0) rather than clear() here saves 2% on 71 // Using resize(0) rather than clear() here saves 2% on
72 // PerformanceTests/Layout/line-layout.html because we avoid freeing and 72 // PerformanceTests/Layout/line-layout.html because we avoid freeing and
73 // re-allocating the underlying buffer repeatedly. 73 // re-allocating the underlying buffer repeatedly.
74 m_objects.resize(0); 74 m_objects.resize(0);
75 } 75 }
76 76
77 void appendObjectIfNeeded(LayoutObject* object) 77 void appendObjectIfNeeded(LayoutObject* object)
78 { 78 {
79 if (m_whitespace) 79 if (m_whitespace)
80 m_objects.append(object); 80 m_objects.append(object);
81 } 81 }
82 82
83 enum CollapseFirstSpaceOrNot { DoNotCollapseFirstSpace, CollapseFirstSpace } ; 83 enum CollapseFirstSpaceOrNot { DoNotCollapseFirstSpace, CollapseFirstSpace } ;
84 84
85 void updateMidpointsForTrailingObjects(LineMidpointState&, const InlineItera tor& lBreak, CollapseFirstSpaceOrNot); 85 void updateMidpointsForTrailingObjects(LineMidpointState&, const InlineItera tor& lBreak, CollapseFirstSpaceOrNot);
86 86
87 private: 87 private:
88 LayoutText* m_whitespace; 88 LayoutText* m_whitespace;
89 Vector<LayoutObject*, 4> m_objects; 89 Vector<LayoutObject*, 4> m_objects;
90 }; 90 };
91 91
92 } 92 }
93 93
94 #endif // TrailingObjects_h 94 #endif // TrailingObjects_h
OLDNEW
« no previous file with comments | « Source/core/layout/line/RootInlineBox.cpp ('k') | Source/core/layout/line/WordMeasurement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698