summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/layout/fragmentainer_iterator.h
blob: 0a966fdeb99250f4521935a25df871efd7a30b87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2016 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 THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_FRAGMENTAINER_ITERATOR_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_FRAGMENTAINER_ITERATOR_H_

#include "third_party/blink/renderer/core/layout/multi_column_fragmentainer_group.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"

namespace blink {

class LayoutFlowThread;
class LayoutMultiColumnSet;

// Used to find the fragmentainers that intersect with a given portion of the
// flow thread. The portion typically corresponds to the bounds of some
// descendant layout object. The iterator walks in block direction order.
class FragmentainerIterator {
  STACK_ALLOCATED();

 public:
  // Initialize the iterator, and move to the first fragmentainer of interest.
  // The clip rectangle is optional. If it's empty, it means that no clipping
  // will be performed, and that the only thing that can limit the set of
  // fragmentainers to visit is |physicalBoundingBox|.
  FragmentainerIterator(
      const LayoutFlowThread&,
      const LayoutRect& physical_bounding_box_in_flow_thread,
      const LayoutRect& clip_rect_in_multicol_container = LayoutRect());

  // Advance to the next fragmentainer. Not allowed to call this if atEnd() is
  // true.
  void Advance();

  // Return true if we have walked through all relevant fragmentainers.
  bool AtEnd() const { return !current_column_set_; }

  // The physical translation to apply to shift the box when converting from
  // flowthread to visual coordinates.
  LayoutSize PaginationOffset() const;

  // The logical top of the current fragmentainer in flowthread.
  LayoutUnit FragmentainerLogicalTopInFlowThread() const;

  // Return the physical clip rectangle of the current fragmentainer, relative
  // to the flow thread.
  LayoutRect ClipRectInFlowThread() const;

 private:
  const LayoutFlowThread& flow_thread_;
  const LayoutRect clip_rect_in_multicol_container_;

  const LayoutMultiColumnSet* current_column_set_;
  unsigned current_fragmentainer_group_index_;
  unsigned current_fragmentainer_index_;
  unsigned end_fragmentainer_index_;

  LayoutUnit logical_top_in_flow_thread_;
  LayoutUnit logical_bottom_in_flow_thread_;

  const MultiColumnFragmentainerGroup& CurrentGroup() const;
  void MoveToNextFragmentainerGroup();
  bool SetFragmentainersOfInterest();
  void SetAtEnd() { current_column_set_ = nullptr; }
  bool HasClipRect() const {
    return !clip_rect_in_multicol_container_.IsEmpty();
  }
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_FRAGMENTAINER_ITERATOR_H_