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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.h

Issue 2739683006: Use Opportunity Iterator to position text fragments in NGLineBuilder (Closed)
Patch Set: add font-family Created 3 years, 9 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NGLayoutOpportunityIterator_h 5 #ifndef NGLayoutOpportunityIterator_h
6 #define NGLayoutOpportunityIterator_h 6 #define NGLayoutOpportunityIterator_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/ng_layout_opportunity_tree_node.h" 9 #include "core/layout/ng/ng_layout_opportunity_tree_node.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 #include "wtf/Optional.h" 11 #include "wtf/Optional.h"
12 #include "wtf/Vector.h" 12 #include "wtf/Vector.h"
13 #include "wtf/text/StringBuilder.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class NGConstraintSpace; 17 class NGConstraintSpace;
17 typedef NGLogicalRect NGLayoutOpportunity; 18 typedef NGLogicalRect NGLayoutOpportunity;
18 typedef Vector<NGLayoutOpportunity> NGLayoutOpportunities; 19 typedef Vector<NGLayoutOpportunity> NGLayoutOpportunities;
19 20
20 class CORE_EXPORT NGLayoutOpportunityIterator final { 21 class CORE_EXPORT NGLayoutOpportunityIterator final {
21 public: 22 public:
22 // Default constructor. 23 // Default constructor.
23 // 24 //
24 // @param space Constraint space with exclusions for which this iterator needs 25 // @param space Constraint space with exclusions for which this iterator needs
25 // to generate layout opportunities. 26 // to generate layout opportunities.
26 // @param opt_origin_point Optional origin_point parameter that is used as a 27 // @param opt_offset Optional offset parameter that is used as a
27 // default start point for layout opportunities. 28 // default start point for layout opportunities.
28 // @param opt_leader_point Optional 'leader' parameter that is used to specify 29 // @param opt_leader_point Optional 'leader' parameter that is used to specify
29 // the ending point of temporary excluded rectangle 30 // the ending point of temporary excluded rectangle
30 // which starts from 'origin'. This rectangle may 31 // which starts from 'origin'. This rectangle may
31 // represent a text fragment for example. 32 // represent a text fragment for example.
32 NGLayoutOpportunityIterator( 33 NGLayoutOpportunityIterator(
33 const NGConstraintSpace* space, 34 const NGConstraintSpace* space,
34 const WTF::Optional<NGLogicalOffset>& opt_origin_point = WTF::nullopt, 35 const WTF::Optional<NGLogicalOffset>& opt_offset = WTF::nullopt,
35 const WTF::Optional<NGLogicalOffset>& opt_leader_point = WTF::nullopt); 36 const WTF::Optional<NGLogicalOffset>& opt_leader_point = WTF::nullopt);
36 37
37 // Gets the next Layout Opportunity or nullptr if the search is exhausted. 38 // Gets the next Layout Opportunity or nullptr if the search is exhausted.
38 // TODO(chrome-layout-team): Refactor with using C++ <iterator> library. 39 // TODO(chrome-layout-team): Refactor with using C++ <iterator> library.
39 const NGLayoutOpportunity Next(); 40 const NGLayoutOpportunity Next();
40 41
42 // Offset that specifies the starting point to search layout opportunities.
43 // It's either {@code opt_offset} or space->BfcOffset().
44 NGLogicalOffset Offset() const { return offset_; }
45
41 #ifndef NDEBUG 46 #ifndef NDEBUG
42 // Prints Layout Opportunity tree for debug purposes. 47 // Prints Layout Opportunity tree for debug purposes.
43 void ShowLayoutOpportunityTree() const; 48 void ShowLayoutOpportunityTree() const;
44 #endif 49 #endif
45 50
46 private: 51 private:
47 // Mutable Getters. 52 // Mutable Getters.
48 NGLayoutOpportunityTreeNode* MutableOpportunityTreeRoot() { 53 NGLayoutOpportunityTreeNode* MutableOpportunityTreeRoot() {
49 return opportunity_tree_root_.get(); 54 return opportunity_tree_root_.get();
50 } 55 }
51 56
52 // Read-only Getters. 57 // Read-only Getters.
53 const NGLayoutOpportunityTreeNode* OpportunityTreeRoot() const { 58 const NGLayoutOpportunityTreeNode* OpportunityTreeRoot() const {
54 return opportunity_tree_root_.get(); 59 return opportunity_tree_root_.get();
55 } 60 }
56 61
57 const NGConstraintSpace* constraint_space_; 62 const NGConstraintSpace* constraint_space_;
58 63
59 NGLayoutOpportunities opportunities_; 64 NGLayoutOpportunities opportunities_;
60 NGLayoutOpportunities::const_iterator opportunity_iter_; 65 NGLayoutOpportunities::const_iterator opportunity_iter_;
61 Persistent<NGLayoutOpportunityTreeNode> opportunity_tree_root_; 66 Persistent<NGLayoutOpportunityTreeNode> opportunity_tree_root_;
67 NGLogicalOffset offset_;
62 }; 68 };
63 69
64 } // namespace blink 70 } // namespace blink
65 71
66 #endif // NGLayoutOpportunityIterator_h 72 #endif // NGLayoutOpportunityIterator_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698