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

#include "chrome/views/hwnd_view.h"

#include "chrome/common/gfx/chrome_canvas.h"
#include "chrome/common/win_util.h"
#include "chrome/views/focus_manager.h"
#include "chrome/views/scroll_view.h"
#include "chrome/views/widget.h"
#include "base/logging.h"

namespace views {

static const char kViewClassName[] = "chrome/views/HWNDView";

HWNDView::HWNDView() :
    hwnd_(0),
    installed_clip_(false),
    fast_resize_(false),
    focus_view_(NULL) {
  // HWNDs are placed relative to the root. As such, we need to
  // know when the position of any ancestor changes, or our visibility relative
  // to other views changed as it'll effect our position relative to the root.
  SetNotifyWhenVisibleBoundsInRootChanges(true);
}

HWNDView::~HWNDView() {
}

void HWNDView::Attach(HWND hwnd) {
  DCHECK(hwnd_ == NULL);
  hwnd_ = hwnd;

  // First hide the new window. We don't want anything to draw (like sub-hwnd
  // borders), when we change the parent below.
  ShowWindow(hwnd_, SW_HIDE);

  // Need to set the HWND's parent before changing its size to avoid flashing.
  ::SetParent(hwnd_, GetWidget()->GetHWND());
  UpdateHWNDBounds();

  // Register with the focus manager so the associated view is focused when the
  // native control gets the focus.
  FocusManager::InstallFocusSubclass(hwnd_, focus_view_ ? focus_view_ : this);
}

void HWNDView::Detach() {
  DCHECK(hwnd_);
  FocusManager::UninstallFocusSubclass(hwnd_);
  hwnd_ = NULL;
  installed_clip_ = false;
}

void HWNDView::SetAssociatedFocusView(View* view) {
  DCHECK(!::IsWindow(hwnd_));
  focus_view_ = view;
}

HWND HWNDView::GetHWND() const {
  return hwnd_;
}<commit_msg>Add debugging info to hopefully catch what's causing 6316<commit_after>// Copyright (c) 2006-2008 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.

#include "chrome/views/hwnd_view.h"

#include "chrome/common/gfx/chrome_canvas.h"
#include "chrome/common/win_util.h"
#include "chrome/views/focus_manager.h"
#include "chrome/views/scroll_view.h"
#include "chrome/views/widget.h"
#include "base/logging.h"

namespace views {

static const char kViewClassName[] = "chrome/views/HWNDView";

HWNDView::HWNDView() :
    hwnd_(0),
    installed_clip_(false),
    fast_resize_(false),
    focus_view_(NULL) {
  // HWNDs are placed relative to the root. As such, we need to
  // know when the position of any ancestor changes, or our visibility relative
  // to other views changed as it'll effect our position relative to the root.
  SetNotifyWhenVisibleBoundsInRootChanges(true);
}

HWNDView::~HWNDView() {
}

void HWNDView::Attach(HWND hwnd) {
  DCHECK(hwnd_ == NULL);
  DCHECK(hwnd) << "Impossible detatched tab case; See crbug.com/6316";

  hwnd_ = hwnd;

  // First hide the new window. We don't want anything to draw (like sub-hwnd
  // borders), when we change the parent below.
  ShowWindow(hwnd_, SW_HIDE);

  // Need to set the HWND's parent before changing its size to avoid flashing.
  ::SetParent(hwnd_, GetWidget()->GetHWND());
  UpdateHWNDBounds();

  // Register with the focus manager so the associated view is focused when the
  // native control gets the focus.
  FocusManager::InstallFocusSubclass(hwnd_, focus_view_ ? focus_view_ : this);
}

void HWNDView::Detach() {
  DCHECK(hwnd_);
  FocusManager::UninstallFocusSubclass(hwnd_);
  hwnd_ = NULL;
  installed_clip_ = false;
}

void HWNDView::SetAssociatedFocusView(View* view) {
  DCHECK(!::IsWindow(hwnd_));
  focus_view_ = view;
}

HWND HWNDView::GetHWND() const {
  return hwnd_;
}
{'fraction_non_alphanumeric': 0.11314255431902491, 'fraction_numerical': 0.00688924218335983, 'mean_word_length': 4.347025495750708, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2233651', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1248, 'n_words': 375}