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

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

Issue 1318713003: Make classes and structures in core/layout fast-allocated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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/LineWidth.h ('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.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 * 21 *
22 */ 22 */
23 23
24 #ifndef TrailingObjects_h 24 #ifndef TrailingObjects_h
25 #define TrailingObjects_h 25 #define TrailingObjects_h
26 26
27 #include "core/layout/api/LineLayoutItem.h" 27 #include "core/layout/api/LineLayoutItem.h"
28 #include "core/layout/api/LineLayoutText.h" 28 #include "core/layout/api/LineLayoutText.h"
29 #include "wtf/Allocator.h"
29 #include "wtf/Vector.h" 30 #include "wtf/Vector.h"
30 31
31 namespace blink { 32 namespace blink {
32 33
33 class InlineIterator; 34 class InlineIterator;
34 35
35 struct BidiRun; 36 struct BidiRun;
36 37
37 template <class Iterator, class Run> class BidiResolver; 38 template <class Iterator, class Run> class BidiResolver;
38 template <class Iterator> class MidpointState; 39 template <class Iterator> class MidpointState;
39 typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver; 40 typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver;
40 typedef MidpointState<InlineIterator> LineMidpointState; 41 typedef MidpointState<InlineIterator> LineMidpointState;
41 42
42 // This class allows us to ensure lineboxes are created in the right place on th e line when 43 // This class allows us to ensure lineboxes are created in the right place on th e line when
43 // an out-of-flow positioned object or an empty inline is encountered between a trailing space 44 // an out-of-flow positioned object or an empty inline is encountered between a trailing space
44 // and subsequent spaces and we want to ignore (i.e. collapse) surplus whitespac e. So for example: 45 // and subsequent spaces and we want to ignore (i.e. collapse) surplus whitespac e. So for example:
45 // <div>X <span></span> Y</div> 46 // <div>X <span></span> Y</div>
46 // or 47 // or
47 // <div>X <div style="position: absolute"></div> Y</div> 48 // <div>X <div style="position: absolute"></div> Y</div>
48 // In both of the above snippets the inline and the positioned object occur afte r a trailing space 49 // 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 50 // 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 51 // 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 52 // 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 53 // objects encountered after a trailing whitespace and updateMidpointsForTrailin gObjects() to put
53 // them in the right place when we start ignoring surplus whitespace. 54 // them in the right place when we start ignoring surplus whitespace.
54 55
55 class TrailingObjects { 56 class TrailingObjects {
57 STACK_ALLOCATED();
56 public: 58 public:
57 TrailingObjects() 59 TrailingObjects()
58 : m_whitespace(nullptr) 60 : m_whitespace(nullptr)
59 { 61 {
60 } 62 }
61 63
62 void setTrailingWhitespace(LineLayoutText whitespace) 64 void setTrailingWhitespace(LineLayoutText whitespace)
63 { 65 {
64 ASSERT(whitespace); 66 ASSERT(whitespace);
65 m_whitespace = whitespace; 67 m_whitespace = whitespace;
(...skipping 19 matching lines...) Expand all
85 void updateMidpointsForTrailingObjects(LineMidpointState&, const InlineItera tor& lBreak, CollapseFirstSpaceOrNot); 87 void updateMidpointsForTrailingObjects(LineMidpointState&, const InlineItera tor& lBreak, CollapseFirstSpaceOrNot);
86 88
87 private: 89 private:
88 LineLayoutText m_whitespace; 90 LineLayoutText m_whitespace;
89 Vector<LineLayoutItem, 4> m_objects; 91 Vector<LineLayoutItem, 4> m_objects;
90 }; 92 };
91 93
92 } 94 }
93 95
94 #endif // TrailingObjects_h 96 #endif // TrailingObjects_h
OLDNEW
« no previous file with comments | « Source/core/layout/line/LineWidth.h ('k') | Source/core/layout/line/WordMeasurement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698