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

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator.h

Issue 2706353004: [LayoutNG] Introduce block child iterator. (Closed)
Patch Set: address comments. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator.h
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator.h b/third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator.h
new file mode 100644
index 0000000000000000000000000000000000000000..0aee68ee038e46ac303fdcd0893cc926f2d92b1f
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator.h
@@ -0,0 +1,55 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NGBlockChildIterator_h
+#define NGBlockChildIterator_h
+
+#include "core/CoreExport.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class NGLayoutInputNode;
+class NGBreakToken;
+class NGBlockBreakToken;
+
+// A utility class for block-flow layout which given the first child and a
+// break token will iterate through unfinished children.
+//
+// This class does not handle modifications to its arguments after it has been
+// constructed.
+class CORE_EXPORT NGBlockChildIterator {
+ public:
+ NGBlockChildIterator(NGLayoutInputNode* first_child,
+ NGBlockBreakToken* break_token);
+
+ // Returns the next input node which should be laid out, along with its
+ // respective break token.
+ struct Entry;
+ Entry NextChild();
+
+ private:
+ Persistent<NGLayoutInputNode> child_;
+ Persistent<NGBlockBreakToken> break_token_;
+
+ // An index into break_token_'s ChildBreakTokens() vector. Used for keeping
+ // track of the next child break token to inspect.
+ size_t child_token_idx_;
+};
+
+struct NGBlockChildIterator::Entry {
+ Entry(NGLayoutInputNode* node, NGBreakToken* token)
+ : node(node), token(token) {}
+
+ Persistent<NGLayoutInputNode> node;
+ Persistent<NGBreakToken> token;
+
+ bool operator==(const NGBlockChildIterator::Entry& other) const {
+ return node == other.node && token == other.token;
+ }
+};
+
+} // namespace blink
+
+#endif // NGBlockChildIterator_h

Powered by Google App Engine
This is Rietveld 408576698