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

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

Issue 302233002: Revert of Empty inline elements always get a line box. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
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 11 matching lines...) Expand all
22 */ 22 */
23 23
24 #ifndef TrailingObjects_h 24 #ifndef TrailingObjects_h
25 #define TrailingObjects_h 25 #define TrailingObjects_h
26 26
27 #include "wtf/Vector.h" 27 #include "wtf/Vector.h"
28 28
29 namespace WebCore { 29 namespace WebCore {
30 30
31 class InlineIterator; 31 class InlineIterator;
32 class RenderObject; 32 class RenderBox;
33 class RenderText; 33 class RenderText;
34 34
35 struct BidiRun; 35 struct BidiRun;
36 36
37 template <class Iterator, class Run> class BidiResolver; 37 template <class Iterator, class Run> class BidiResolver;
38 template <class Iterator> class MidpointState; 38 template <class Iterator> class MidpointState;
39 typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver; 39 typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver;
40 typedef MidpointState<InlineIterator> LineMidpointState; 40 typedef MidpointState<InlineIterator> LineMidpointState;
41 41
42 // 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 // 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 // or
47 // <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 // 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 // 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 // them in the right place when we start ignoring surplus whitespace.
54
55 class TrailingObjects { 42 class TrailingObjects {
56 public: 43 public:
57 TrailingObjects() 44 TrailingObjects()
58 : m_whitespace(0) 45 : m_whitespace(0)
59 { 46 {
60 } 47 }
61 48
62 void setTrailingWhitespace(RenderText* whitespace) 49 void setTrailingWhitespace(RenderText* whitespace)
63 { 50 {
64 ASSERT(whitespace); 51 ASSERT(whitespace);
65 m_whitespace = whitespace; 52 m_whitespace = whitespace;
66 } 53 }
67 54
68 void clear() 55 void clear()
69 { 56 {
70 m_whitespace = 0; 57 m_whitespace = 0;
71 // Using resize(0) rather than clear() here saves 2% on 58 // Using resize(0) rather than clear() here saves 2% on
72 // PerformanceTests/Layout/line-layout.html because we avoid freeing and 59 // PerformanceTests/Layout/line-layout.html because we avoid freeing and
73 // re-allocating the underlying buffer repeatedly. 60 // re-allocating the underlying buffer repeatedly.
74 m_objects.resize(0); 61 m_boxes.resize(0);
75 } 62 }
76 63
77 void appendObjectIfNeeded(RenderObject* object) 64 void appendBoxIfNeeded(RenderBox* box)
78 { 65 {
79 if (m_whitespace) 66 if (m_whitespace)
80 m_objects.append(object); 67 m_boxes.append(box);
81 } 68 }
82 69
83 enum CollapseFirstSpaceOrNot { DoNotCollapseFirstSpace, CollapseFirstSpace } ; 70 enum CollapseFirstSpaceOrNot { DoNotCollapseFirstSpace, CollapseFirstSpace } ;
84 71
85 void updateMidpointsForTrailingObjects(LineMidpointState&, const InlineItera tor& lBreak, CollapseFirstSpaceOrNot); 72 void updateMidpointsForTrailingBoxes(LineMidpointState&, const InlineIterato r& lBreak, CollapseFirstSpaceOrNot);
86 73
87 private: 74 private:
88 RenderText* m_whitespace; 75 RenderText* m_whitespace;
89 Vector<RenderObject*, 4> m_objects; 76 Vector<RenderBox*, 4> m_boxes;
90 }; 77 };
91 78
92 } 79 }
93 80
94 #endif // TrailingObjects_h 81 #endif // TrailingObjects_h
OLDNEW
« no previous file with comments | « Source/core/rendering/line/BreakingContextInlineHeaders.h ('k') | Source/core/rendering/line/TrailingObjects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698