summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/frame/layout_subtree_root_list.cc
blob: d4e535101e141d57d46d33ac889ef793c328c9c4 (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
// Copyright 2015 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.

#include "third_party/blink/renderer/core/frame/layout_subtree_root_list.h"

#include "third_party/blink/renderer/core/layout/layout_object.h"

namespace blink {

void LayoutSubtreeRootList::ClearAndMarkContainingBlocksForLayout() {
  for (auto* const iter : Unordered())
    iter->MarkContainerChainForLayout(false);
  Clear();
}

LayoutObject* LayoutSubtreeRootList::RandomRoot() {
  DCHECK(!IsEmpty());
  return *Unordered().begin();
}

void LayoutSubtreeRootList::CountObjectsNeedingLayoutInRoot(
    const LayoutObject* object,
    unsigned& needs_layout_objects,
    unsigned& total_objects) {
  for (const LayoutObject* o = object; o; o = o->NextInPreOrder(object)) {
    ++total_objects;
    if (o->NeedsLayout())
      ++needs_layout_objects;
  }
}

void LayoutSubtreeRootList::CountObjectsNeedingLayout(
    unsigned& needs_layout_objects,
    unsigned& total_objects) {
  // TODO(leviw): This will double-count nested roots crbug.com/509141
  for (auto* const root : Unordered())
    CountObjectsNeedingLayoutInRoot(root, needs_layout_objects, total_objects);
}

}  // namespace blink