<commit_before>/**
 * Copyright 2014 Mozilla Foundation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Class: Mouse
module Shumway.AVM2.AS.flash.ui {
  import notImplemented = Shumway.Debug.notImplemented;
  import somewhatImplemented = Shumway.Debug.somewhatImplemented;

  import asCoerceString = Shumway.AVM2.Runtime.asCoerceString;
  import InteractiveObject = flash.display.InteractiveObject;

  import events = flash.events;

  /**
   * Dispatches AS3 mouse events.
   */
  export class MouseEventDispatcher {
    stage: flash.display.Stage = null;
    currentTarget: flash.display.InteractiveObject = null;

    /**
     * Finds the interactive object on which the event is dispatched.
     */
    private _findTarget(point: flash.geom.Point): InteractiveObject {
      var objects = this.stage.getObjectsUnderMouse(point);
      var target: InteractiveObject;
      var i = objects.length;
      while (i--) {
        var object = objects[i];
        if (!flash.display.InteractiveObject.isType(object)) {
          var j = i;
          while (j--) {
            var sibling = objects[j];
            if (sibling._parent === object._parent && InteractiveObject.isType(sibling)) {
              object = sibling;
              i = j;
            }
          }
        }
        target = object.findFurthestInteractiveAncestorOrSelf();
        if (!target) {
          continue;
        }
        if (target.mouseEnabled) {
          break;
        }
        if (flash.display.Sprite.isType(target)) {
          var hitTarget = (<flash.display.Sprite>target)._hitTarget;
          if (hitTarget && hitTarget.mouseEnabled) {
            target = hitTarget;
            break;
          }
        }
      }
      return target;
    }<commit_msg>Fix finding mouse target<commit_after>/**
 * Copyright 2014 Mozilla Foundation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Class: Mouse
module Shumway.AVM2.AS.flash.ui {
  import notImplemented = Shumway.Debug.notImplemented;
  import somewhatImplemented = Shumway.Debug.somewhatImplemented;

  import asCoerceString = Shumway.AVM2.Runtime.asCoerceString;
  import InteractiveObject = flash.display.InteractiveObject;

  import events = flash.events;

  /**
   * Dispatches AS3 mouse events.
   */
  export class MouseEventDispatcher {
    stage: flash.display.Stage = null;
    currentTarget: flash.display.InteractiveObject = null;

    /**
     * Finds the interactive object on which the event is dispatched.
     */
    private _findTarget(point: flash.geom.Point): InteractiveObject {
      var objects = this.stage.getObjectsUnderMouse(point);
      var target: InteractiveObject;
      var i = objects.length;
      while (i--) {
        var object = objects[i];
        if (!flash.display.InteractiveObject.isType(object)) {
          var j = i;
          while (j--) {
            var sibling = objects[j];
            if (sibling._parent === object._parent && InteractiveObject.isType(sibling)) {
              object = sibling;
              i = j;
              break;
            }
          }
        }
        target = object.findFurthestInteractiveAncestorOrSelf();
        if (!target) {
          continue;
        }
        if (target.mouseEnabled) {
          break;
        }
        if (flash.display.Sprite.isType(target)) {
          var hitTarget = (<flash.display.Sprite>target)._hitTarget;
          if (hitTarget && hitTarget.mouseEnabled) {
            target = hitTarget;
            break;
          }
        }
      }
      return target;
    }
{'fraction_non_alphanumeric': 0.09355828220858896, 'fraction_numerical': 0.004820333041191937, 'mean_word_length': 2.4041759880686056, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2843768', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1224, 'n_words': 368}