Commit 94735ad6 authored by Wei Li's avatar Wei Li Committed by Commit Bot

UIDevTools: Make exiting inspector mode work

Clicking ElementInspect button would toggle entering/exiting
inspector mode. However, previously clicking that button in
inspector mode would be handled by pinned element logic. In this
CL, we capture returned window element's active state. If the
window is not active, pinned element logic should not mark the
event as handled to give frontend a chance to handle the event.

BUG=899000

Change-Id: I4356f85f0ec6d90298473bb894f197aa4ab733e3
Reviewed-on: https://chromium-review.googlesource.com/c/1306403Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Commit-Queue: Wei Li <weili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604317}
parent 684b74b9
......@@ -19,6 +19,7 @@
#include "ui/gfx/render_text.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/wm/core/window_util.h"
namespace ui_devtools {
......@@ -553,26 +554,35 @@ void OverlayAgentAura::OnMouseEvent(ui::MouseEvent* event) {
// Find node id of element whose bounds contain the mouse pointer location.
int element_id = FindElementIdTargetedByPoint(event);
if (!element_id)
return;
if (pinned_id_ == element_id) {
#if defined(USE_AURA)
aura::Window* target = static_cast<aura::Window*>(event->target());
bool active_window = ::wm::IsActiveWindow(
target->GetRootWindow()->GetEventHandlerForPoint(event->root_location()));
#else
bool active_window = true;
#endif
if (pinned_id_ == element_id && active_window) {
event->SetHandled();
return;
}
// Pin the hover element on click.
if (event->type() == ui::ET_MOUSE_PRESSED) {
if (active_window)
event->SetHandled();
if (element_id)
SetPinnedNodeId(element_id);
} else if (element_id && !pinned_id_) {
// Display only guidelines if hovering without a pinned element.
frontend()->nodeHighlightRequested(element_id);
HighlightNode(element_id, false /* show_size */);
} else if (element_id && pinned_id_) {
} else if (pinned_id_) {
// If hovering with a pinned element, then show distances between the pinned
// element and the hover element.
HighlightNode(element_id, false /* show_size */);
ShowDistancesInHighlightOverlay(pinned_id_, element_id);
} else {
// Display only guidelines if hovering without a pinned element.
frontend()->nodeHighlightRequested(element_id);
HighlightNode(element_id, false /* show_size */);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment