diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-20 13:40:20 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-22 12:41:23 +0000 |
commit | 7961cea6d1041e3e454dae6a1da660b453efd238 (patch) | |
tree | c0eeb4a9ff9ba32986289c1653d9608e53ccb444 /chromium/third_party/blink/renderer/core/layout/ng/custom/custom_layout_scope.h | |
parent | b7034d0803538058e5c9d904ef03cf5eab34f6ef (diff) | |
download | qtwebengine-chromium-7961cea6d1041e3e454dae6a1da660b453efd238.tar.gz |
BASELINE: Update Chromium to 78.0.3904.130
Change-Id: If185e0c0061b3437531c97c9c8c78f239352a68b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/ng/custom/custom_layout_scope.h')
-rw-r--r-- | chromium/third_party/blink/renderer/core/layout/ng/custom/custom_layout_scope.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/ng/custom/custom_layout_scope.h b/chromium/third_party/blink/renderer/core/layout/ng/custom/custom_layout_scope.h new file mode 100644 index 00000000000..319ea6b778b --- /dev/null +++ b/chromium/third_party/blink/renderer/core/layout/ng/custom/custom_layout_scope.h @@ -0,0 +1,76 @@ +// Copyright 2019 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_NG_CUSTOM_CUSTOM_LAYOUT_SCOPE_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_CUSTOM_CUSTOM_LAYOUT_SCOPE_H_ + +#include "third_party/blink/renderer/core/layout/ng/custom/custom_layout_work_task.h" +#include "third_party/blink/renderer/platform/heap/handle.h" + +namespace blink { + +// The work queue is a list of work tasks which will either produce fragment(s) +// or intrinsic-size(s) for the custom-layout class. +typedef Vector<CustomLayoutWorkTask, 4> CustomLayoutWorkQueue; + +// This heap allocated class is used to indicate which custom-layout (heap) +// objects are still valid. +// +// Any objects which have a pointer to this object with |is_detached_| being +// true, or not matching the current scope token should be considered invalid. +class CustomLayoutToken : public GarbageCollected<CustomLayoutToken> { + public: + CustomLayoutToken() : is_detached_(false) {} + void Trace(Visitor* visitor) {} + bool IsValid() const; + + private: + friend class CustomLayoutScope; + bool is_detached_; +}; + +// This scope object is used to track which custom-layout (heap) objects are +// valid. +// +// Also maintains the current work queue. Work should only be pushed onto this +// queue if this is the current scope. +class CustomLayoutScope { + STACK_ALLOCATED(); + + public: + static CustomLayoutScope* Current() { return current_scope_; } + + CustomLayoutScope() + : prev_scope_(current_scope_), + token_(MakeGarbageCollected<CustomLayoutToken>()) { + current_scope_ = this; + } + + // Marks the scope-token as "detached" for any classes with a pointer to it. + ~CustomLayoutScope() { + token_->is_detached_ = true; + current_scope_ = current_scope_->prev_scope_; + } + + CustomLayoutWorkQueue* Queue() { + DCHECK_EQ(this, current_scope_); + return &queue_; + } + CustomLayoutToken* Token() { return token_; } + + private: + static CustomLayoutScope* current_scope_; + + CustomLayoutScope* prev_scope_; + CustomLayoutWorkQueue queue_; + Member<CustomLayoutToken> token_; +}; + +inline bool CustomLayoutToken::IsValid() const { + return !is_detached_ && this == CustomLayoutScope::Current()->Token(); +} + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_CUSTOM_CUSTOM_LAYOUT_SCOPE_H_ |