blob: 9b808c82a3dd7b63f01c5e594e4cddb7c8ef6a74 [file] [log] [blame]
// Copyright 2018 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 CHROME_BROWSER_VR_ELEMENTS_OMNIBOX_FORMATTING_H_
#define CHROME_BROWSER_VR_ELEMENTS_OMNIBOX_FORMATTING_H_
#include <memory>
#include "chrome/browser/vr/elements/text.h"
#include "chrome/browser/vr/model/color_scheme.h"
#include "components/omnibox/browser/autocomplete_match.h"
namespace gfx {
class RenderText;
}
namespace vr {
// Convert Autocomplete's suggestion formatting to generic VR text formatting.
TextFormatting ConvertClassification(
const ACMatchClassifications& classifications,
size_t text_length,
const ColorScheme& color_scheme);
url_formatter::FormatUrlTypes GetVrFormatUrlTypes();
struct ElisionParameters {
// The horizontal pixel offset to be applied to URL text, such that the right
// edge of the domain (along with at least a small amount of path) is visible
// within the available text field space.
int offset = 0;
// Flags indicating that either edge of the URL overflows the ends of the text
// field, after offsetting, and that fading must be applied.
bool fade_left = false;
bool fade_right = false;
};
// Based on a URL and the RenderText that will draw it, determine the required
// elision parameters. This means computing an offset such that the rightmost
// portion of the TLD is visible (along with a small part of the path), and
// fading either edge if they overflow available space.
ElisionParameters GetElisionParameters(const GURL& gurl,
const url::Parsed& parsed,
gfx::RenderText* render_text,
int min_path_pixels);
} // namespace vr
#endif // CHROME_BROWSER_VR_ELEMENTS_OMNIBOX_FORMATTING_H_