#include "third_party/blink/renderer/core/mobile_metrics/mobile_friendliness_checker.h"
#include <cmath>
#include <optional>
#include "base/metrics/histogram_functions.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_get_root_node_options.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/page_scale_constraints_set.h"
#include "third_party/blink/renderer/core/frame/root_frame_viewport.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_form_control_element.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/layout/adjust_for_absolute_zoom.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_offset.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_size.h"
#include "third_party/blink/renderer/core/layout/layout_image.h"
#include "third_party/blink/renderer/core/layout/layout_view.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/core/page/viewport_description.h"
#include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h"
#include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "ui/display/screen_info.h"
namespace blink {
namespace {
int32_t BucketWithOffsetAndUnit(int32_t num, int32_t offset, int32_t unit) { … }
int32_t GetBucketedViewportInitialScale(int32_t initial_scale_x10) { … }
int32_t GetBucketedViewportHardcodedWidth(int32_t hardcoded_width) { … }
}
static constexpr int kSmallFontThresholdInDips = …;
static constexpr double kMaximumScalePreventsZoomingThreshold = …;
static constexpr base::TimeDelta kEvaluationInterval = …;
static constexpr base::TimeDelta kEvaluationDelay = …;
static constexpr base::TimeDelta kFirstEvaluationOffsetTime = …;
MobileFriendlinessChecker::MobileFriendlinessChecker(LocalFrameView& frame_view)
: … { … }
MobileFriendlinessChecker::~MobileFriendlinessChecker() = default;
void MobileFriendlinessChecker::NotifyPaintBegin() { … }
void MobileFriendlinessChecker::NotifyPaintEnd() { … }
MobileFriendlinessChecker* MobileFriendlinessChecker::Create(
LocalFrameView& frame_view) { … }
MobileFriendlinessChecker* MobileFriendlinessChecker::From(
const Document& document) { … }
void MobileFriendlinessChecker::MaybeRecompute() { … }
void MobileFriendlinessChecker::ComputeNow() { … }
int MobileFriendlinessChecker::AreaSizes::SmallTextRatio() const { … }
int MobileFriendlinessChecker::AreaSizes::TextContentsOutsideViewportPercentage(
double viewport_area) const { … }
void MobileFriendlinessChecker::UpdateTextAreaSizes(
const PhysicalRect& text_rect,
int font_size) { … }
void MobileFriendlinessChecker::UpdateBeyondViewportAreaSizes(
const PhysicalRect& paint_rect,
const TransformPaintPropertyNodeOrAlias& current_transform) { … }
void MobileFriendlinessChecker::NotifyPaintTextFragment(
const PhysicalRect& paint_rect,
int font_size,
const TransformPaintPropertyNodeOrAlias& current_transform) { … }
void MobileFriendlinessChecker::NotifyPaintReplaced(
const PhysicalRect& paint_rect,
const TransformPaintPropertyNodeOrAlias& current_transform) { … }
void MobileFriendlinessChecker::Trace(Visitor* visitor) const { … }
}