<commit_before>// Copyright (c) 2012 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.

'use strict';

base.require('base.range');
base.require('base.event_target');

base.exportTo('ui', function() {
  var DEFAULT_PAD_PERCENTAGE = 0.75;

  function QuadViewViewport(bbox,
                            opt_scale,
                            opt_padding, opt_devicePixelRatio) {
    base.EventTarget.call(this);
    if (bbox.isEmpty)
      throw new Error('Cannot initialize a viewport with an empty bbox');

    this.layoutRect = undefined;
    this.setWorldBBox(bbox, opt_padding);

    var devicePixelRatio;
    if (opt_devicePixelRatio)
      devicePixelRatio = opt_devicePixelRatio;
    else
      devicePixelRatio = window.devicePixelRatio || 1;

    var scale;
    if (opt_scale) {
      scale = opt_scale;
    } else {
      if (devicePixelRatio > 1)
        scale = 0.25;
      else
        scale = 0.125;
    }
    this.scale_ = scale;
    this.updateScale_();
  }

  QuadViewViewport.prototype = {

    __proto__: base.EventTarget.prototype,

    set scale(scale) {
      this.scale_ = scale;
      this.updateScale_();
      this.didChange_();
    },

    get scale() {
      return this.scale_;
    },

    updateScale_: function() {
      this.worldPixelsPerDevicePixel_ = this.scale_;
      this.devicePixelsPerLayoutPixel_ = 1 / devicePixelRatio;

      this.deviceWidth =
          this.worldRect.width * this.worldPixelsPerDevicePixel_;
      this.deviceHeight =
          this.worldRect.height * this.worldPixelsPerDevicePixel_;

      this.layoutRect = base.Rect.FromXYWH(
          this.worldRect.x * this.devicePixelsPerLayoutPixel_,
          this.worldRect.y * this.devicePixelsPerLayoutPixel_,
          this.deviceWidth * this.devicePixelsPerLayoutPixel_,
          this.deviceHeight * this.devicePixelsPerLayoutPixel_);
      this.effectiveWorldRect = this.worldRect.clone().scale(this.scale_);
<commit_msg>Use the viewport device pixel ratio instead of the raw device pixel ratio.<commit_after>// Copyright (c) 2012 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.

'use strict';

base.require('base.range');
base.require('base.event_target');

base.exportTo('ui', function() {
  var DEFAULT_PAD_PERCENTAGE = 0.75;

  function QuadViewViewport(bbox,
                            opt_scale,
                            opt_padding, opt_devicePixelRatio) {
    base.EventTarget.call(this);
    if (bbox.isEmpty)
      throw new Error('Cannot initialize a viewport with an empty bbox');

    this.layoutRect = undefined;
    this.setWorldBBox(bbox, opt_padding);

    var devicePixelRatio;
    if (opt_devicePixelRatio)
      this.devicePixelRatio = opt_devicePixelRatio;
    else
      this.devicePixelRatio = window.devicePixelRatio || 1;

    var scale;
    if (opt_scale) {
      scale = opt_scale;
    } else {
      if (this.devicePixelRatio > 1)
        scale = 0.25;
      else
        scale = 0.125;
    }
    this.scale_ = scale;
    this.updateScale_();
  }

  QuadViewViewport.prototype = {

    __proto__: base.EventTarget.prototype,

    set scale(scale) {
      this.scale_ = scale;
      this.updateScale_();
      this.didChange_();
    },

    get scale() {
      return this.scale_;
    },

    updateScale_: function() {
      this.worldPixelsPerDevicePixel_ = this.scale_;
      this.devicePixelsPerLayoutPixel_ = 1 / this.devicePixelRatio;

      this.deviceWidth =
          this.worldRect.width * this.worldPixelsPerDevicePixel_;
      this.deviceHeight =
          this.worldRect.height * this.worldPixelsPerDevicePixel_;

      this.layoutRect = base.Rect.FromXYWH(
          this.worldRect.x * this.devicePixelsPerLayoutPixel_,
          this.worldRect.y * this.devicePixelsPerLayoutPixel_,
          this.deviceWidth * this.devicePixelsPerLayoutPixel_,
          this.deviceHeight * this.devicePixelsPerLayoutPixel_);
      this.effectiveWorldRect = this.worldRect.clone().scale(this.scale_);

{'fraction_non_alphanumeric': 0.09644670050761421, 'fraction_numerical': 0.00821851583272903, 'mean_word_length': 2.6684397163120566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6247582', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1213, 'n_words': 264}