chromium/third_party/blink/renderer/core/layout/text_autosizer.cc

/*
 * Copyright (C) 2013 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

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

#include <algorithm>
#include <memory>
#include <utility>

#include "base/memory/ptr_util.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/security_context.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/viewport_data.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/html/forms/html_text_area_element.h"
#include "third_party/blink/renderer/core/layout/layout_block.h"
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_multi_column_flow_thread.h"
#include "third_party/blink/renderer/core/layout/layout_ruby_column.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/list/layout_list_item.h"
#include "third_party/blink/renderer/core/layout/table/layout_table.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_cell.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_row.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_section.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/platform/network/network_utils.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "ui/gfx/geometry/rect.h"

namespace blink {

namespace {

inline int GetLayoutInlineSize(const Document& document,
                               const LocalFrameView& main_frame_view) {}

}  // namespace

static LayoutObject* ParentElementLayoutObject(
    const LayoutObject* layout_object) {}

static bool IsNonTextAreaFormControl(const LayoutObject* layout_object) {}

static bool IsPotentialClusterRoot(const LayoutObject* layout_object) {}

static bool IsIndependentDescendant(const LayoutBlock* layout_object) {}

static bool BlockIsRowOfLinks(const LayoutBlock* block) {}

static inline bool HasAnySizingKeyword(const Length& length) {}

static bool BlockHeightConstrained(const LayoutBlock* block) {}

static bool BlockOrImmediateChildrenAreFormControls(const LayoutBlock* block) {}

// Some blocks are not autosized even if their parent cluster wants them to.
static bool BlockSuppressesAutosizing(const LayoutBlock* block) {}

static bool HasExplicitWidth(const LayoutBlock* block) {}

static LayoutObject* GetParent(const LayoutObject* object) {}

TextAutosizer::TextAutosizer(const Document* document)
    :{}

TextAutosizer::~TextAutosizer() = default;

void TextAutosizer::Record(LayoutBlock* block) {}

void TextAutosizer::Record(LayoutText* text) {}

void TextAutosizer::Destroy(LayoutObject* layout_object) {}

TextAutosizer::BeginLayoutBehavior TextAutosizer::PrepareForLayout(
    LayoutBlock* block) {}

void TextAutosizer::PrepareClusterStack(LayoutObject* layout_object) {}

void TextAutosizer::BeginLayout(LayoutBlock* block) {}

void TextAutosizer::InflateAutoTable(LayoutTable* table) {}

void TextAutosizer::EndLayout(LayoutBlock* block) {}

float TextAutosizer::Inflate(LayoutObject* parent,
                             InflateBehavior behavior,
                             float multiplier) {}

bool TextAutosizer::ShouldHandleLayout() const {}

bool TextAutosizer::PageNeedsAutosizing() const {}

void TextAutosizer::MarkSuperclusterForConsistencyCheck(LayoutObject* object) {}

bool TextAutosizer::HasLayoutInlineSizeChanged() const {}

// Static.
void TextAutosizer::UpdatePageInfoInAllFrames(Frame* main_frame) {}

void TextAutosizer::UpdatePageInfo() {}

gfx::Size TextAutosizer::WindowSize() const {}

void TextAutosizer::ResetMultipliers() {}

void TextAutosizer::SetAllTextNeedsLayout(LayoutBlock* container) {}

TextAutosizer::BlockFlags TextAutosizer::ClassifyBlock(
    const LayoutObject* layout_object,
    BlockFlags mask) const {}

bool TextAutosizer::ClusterWouldHaveEnoughTextToAutosize(
    const LayoutBlock* root,
    const LayoutBlock* width_provider) {}

bool TextAutosizer::ClusterHasEnoughTextToAutosize(
    Cluster* cluster,
    const LayoutBlock* width_provider) {}

TextAutosizer::Fingerprint TextAutosizer::GetFingerprint(
    LayoutObject* layout_object) {}

TextAutosizer::Fingerprint TextAutosizer::ComputeFingerprint(
    const LayoutObject* layout_object) {}

TextAutosizer::Cluster* TextAutosizer::MaybeCreateCluster(LayoutBlock* block) {}

TextAutosizer::Supercluster*
TextAutosizer::FingerprintMapper::CreateSuperclusterIfNeeded(
    LayoutBlock* block,
    bool& is_new_entry) {}

float TextAutosizer::ClusterMultiplier(Cluster* cluster) {}

bool TextAutosizer::SuperclusterHasEnoughTextToAutosize(
    Supercluster* supercluster,
    const LayoutBlock* width_provider,
    const bool skip_layouted_nodes) {}

float TextAutosizer::SuperclusterMultiplier(Cluster* cluster) {}

const LayoutBlock* TextAutosizer::ClusterWidthProvider(
    const LayoutBlock* root) const {}

const LayoutBlock* TextAutosizer::MaxClusterWidthProvider(
    Supercluster* supercluster,
    const LayoutBlock* current_root) const {}

float TextAutosizer::WidthFromBlock(const LayoutBlock* block) const {}

float TextAutosizer::MultiplierFromBlock(const LayoutBlock* block) {}

const LayoutBlock* TextAutosizer::DeepestBlockContainingAllText(
    Cluster* cluster) {}

// FIXME: Refactor this to look more like TextAutosizer::deepestCommonAncestor.
const LayoutBlock* TextAutosizer::DeepestBlockContainingAllText(
    const LayoutBlock* root) const {}

const LayoutObject* TextAutosizer::FindTextLeaf(
    const LayoutObject* parent,
    size_t& depth,
    TextLeafSearch first_or_last) const {}

static bool IsCrossSite(const Frame& frame1, const Frame& frame2) {}

void TextAutosizer::ReportIfCrossSiteFrame() {}

void TextAutosizer::ApplyMultiplier(LayoutObject* layout_object,
                                    float multiplier,
                                    RelayoutBehavior relayout_behavior) {}

bool TextAutosizer::IsWiderOrNarrowerDescendant(Cluster* cluster) {}

void TextAutosizer::Supercluster::Trace(Visitor* visitor) const {}

TextAutosizer::Cluster* TextAutosizer::CurrentCluster() const {}

TextAutosizer::Cluster::Cluster(const LayoutBlock* root,
                                BlockFlags flags,
                                Cluster* parent,
                                Supercluster* supercluster)
    :{}

void TextAutosizer::Cluster::Trace(Visitor* visitor) const {}

#if DCHECK_IS_ON()
void TextAutosizer::FingerprintMapper::AssertMapsAreConsistent() {}
#endif

void TextAutosizer::FingerprintMapper::Add(LayoutObject* layout_object,
                                           Fingerprint fingerprint) {}

void TextAutosizer::FingerprintMapper::AddTentativeClusterRoot(
    LayoutBlock* block,
    Fingerprint fingerprint) {}

bool TextAutosizer::FingerprintMapper::Remove(LayoutObject* layout_object) {}

TextAutosizer::Fingerprint TextAutosizer::FingerprintMapper::Get(
    const LayoutObject* layout_object) {}

TextAutosizer::BlockSet*
TextAutosizer::FingerprintMapper::GetTentativeClusterRoots(
    Fingerprint fingerprint) {}

TextAutosizer::LayoutScope::LayoutScope(LayoutBlock* block)
    :{}

TextAutosizer::LayoutScope::~LayoutScope() {}

TextAutosizer::TableLayoutScope::TableLayoutScope(LayoutTable* table)
    :{}

TextAutosizer::DeferUpdatePageInfo::DeferUpdatePageInfo(Page* page)
    :{}

// static
void TextAutosizer::MaybeRegisterInlineSize(const LayoutBlock& ng_block,
                                            LayoutUnit inline_size) {}

TextAutosizer::NGLayoutScope::NGLayoutScope(LayoutBox* box,
                                            LayoutUnit inline_size)
    :{}

TextAutosizer::NGLayoutScope::~NGLayoutScope() {}

TextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() {}

float TextAutosizer::ComputeAutosizedFontSize(float computed_size,
                                              float multiplier,
                                              float effective_zoom) {}

void TextAutosizer::CheckSuperclusterConsistency() {}

float TextAutosizer::ContentInlineSize(const LayoutBlock* block) const {}

void TextAutosizer::RegisterInlineSize(const LayoutBlock& ng_block,
                                       LayoutUnit inline_size) {}

void TextAutosizer::UnregisterInlineSize(const LayoutBlock& ng_block) {}

void TextAutosizer::Trace(Visitor* visitor) const {}

void TextAutosizer::FingerprintMapper::Trace(Visitor* visitor) const {}

}  // namespace blink