blob: 5a58fe51f1ed8a896660ef9e4893f309bb484d34 [file] [log] [blame]
// 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 NGInlineLayoutAlgorithm_h
#define NGInlineLayoutAlgorithm_h
#include "core/CoreExport.h"
#include "core/layout/ng/ng_break_token.h"
#include "core/layout/ng/ng_layout_algorithm.h"
#include "platform/heap/Handle.h"
#include "wtf/RefPtr.h"
namespace blink {
class ComputedStyle;
class LayoutObject;
class NGConstraintSpace;
class NGFragmentBuilder;
class NGInlineNode;
// A class for inline layout (e.g. a anonymous block with inline-level children
// only).
//
// This algorithm may at some point be merged with NGBlockLayoutAlgorithm in
// the future. Currently it exists as its own class to simplify the LayoutNG
// transition period.
class CORE_EXPORT NGInlineLayoutAlgorithm : public NGLayoutAlgorithm {
public:
// Default constructor.
// @param layout_object The LayoutObject associated with this anonymous block.
// @param style Style reference of the block that is being laid out.
// @param first_child Our first child; the algorithm will use its NextSibling
// method to access all the children.
// @param space The constraint space which the algorithm should generate a
// fragment within.
NGInlineLayoutAlgorithm(LayoutObject* layout_object,
PassRefPtr<const ComputedStyle> style,
NGInlineNode* first_child,
NGConstraintSpace* space,
NGBreakToken* break_token = nullptr);
NGPhysicalFragment* Layout() override;
private:
// Read-only Getters.
const ComputedStyle& Style() const { return *style_; }
NGConstraintSpace* CreateConstraintSpaceForChild(const NGInlineNode&) const;
RefPtr<const ComputedStyle> style_;
Persistent<NGInlineNode> first_child_;
Persistent<NGConstraintSpace> constraint_space_;
Persistent<NGBreakToken> break_token_;
Persistent<NGFragmentBuilder> builder_;
};
} // namespace blink
#endif // NGInlineLayoutAlgorithm_h