diff --git a/DEPS b/DEPS index 074ca29..47aef76 100644 --- a/DEPS +++ b/DEPS
@@ -40,7 +40,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '7067fc6224833941380729857ad865547bc88430', + 'skia_revision': 'b733320ab13ff591777d3bce739494c29a30968b', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other.
diff --git a/base/mac/sdk_forward_declarations.h b/base/mac/sdk_forward_declarations.h index 5416c6f..7ea7829d 100644 --- a/base/mac/sdk_forward_declarations.h +++ b/base/mac/sdk_forward_declarations.h
@@ -163,18 +163,6 @@ #endif // MAC_OS_X_VERSION_10_10 -// ---------------------------------------------------------------------------- -// Define NSStrings only available in newer versions of the OSX SDK to force -// them to be statically linked. -// ---------------------------------------------------------------------------- - -extern "C" { -#if !defined(MAC_OS_X_VERSION_10_11) || \ - MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 -BASE_EXPORT extern NSString* const CIDetectorTypeText; -#endif // MAC_OS_X_VERSION_10_11 -} // extern "C" - // Once Chrome no longer supports OSX 10.10, everything within this // preprocessor block can be removed. #if !defined(MAC_OS_X_VERSION_10_11) || \
diff --git a/base/mac/sdk_forward_declarations.mm b/base/mac/sdk_forward_declarations.mm index c624daed..25f71a95 100644 --- a/base/mac/sdk_forward_declarations.mm +++ b/base/mac/sdk_forward_declarations.mm
@@ -13,8 +13,3 @@ NSString* const NSAppearanceNameVibrantDark = @"NSAppearanceNameVibrantDark"; #endif // MAC_OS_X_VERSION_10_10 - -#if !defined(MAC_OS_X_VERSION_10_11) || \ - MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 -NSString* const CIDetectorTypeText = @"CIDetectorTypeText"; -#endif // MAC_OS_X_VERSION_10_11
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index b8817c4..7346efe 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1229,10 +1229,6 @@ registry.get(), base::Bind(&ForwardShapeDetectionRequest< shape_detection::mojom::FaceDetectionProviderRequest>)); - AddUIThreadInterface( - registry.get(), - base::Bind(&ForwardShapeDetectionRequest< - shape_detection::mojom::TextDetectionRequest>)); #endif AddUIThreadInterface( registry.get(),
diff --git a/content/public/app/mojo/content_browser_manifest.json b/content/public/app/mojo/content_browser_manifest.json index 78a5d95..5628eb4 100644 --- a/content/public/app/mojo/content_browser_manifest.json +++ b/content/public/app/mojo/content_browser_manifest.json
@@ -62,8 +62,7 @@ ], "shape_detection": [ "barcode_detection", - "face_detection", - "text_detection" + "face_detection" ] } },
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index f8761f4..a1e47d1e 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc
@@ -505,7 +505,9 @@ // implementations call DemuxerHost on the media thread. media_log_->AddEvent(media_log_->CreateTimeEvent(MediaLogEvent::DURATION_SET, "duration", duration)); - UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration); + UMA_HISTOGRAM_CUSTOM_TIMES( + "Media.Duration2", duration, base::TimeDelta::FromMilliseconds(1), + base::TimeDelta::FromDays(1), 50 /* bucket_count */); main_task_runner_->PostTask( FROM_HERE,
diff --git a/net/dns/dns_protocol.h b/net/dns/dns_protocol.h index 416738a2..2c4478c4 100644 --- a/net/dns/dns_protocol.h +++ b/net/dns/dns_protocol.h
@@ -135,12 +135,12 @@ static const uint8_t kRcodeNOTIMP = 4; static const uint8_t kRcodeREFUSED = 5; -// DNS flags. +// DNS header flags. +// +// https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-12 static const uint16_t kFlagResponse = 0x8000; -static const uint16_t kFlagRA = 0x80; -static const uint16_t kFlagRD = 0x100; -static const uint16_t kFlagTC = 0x200; -static const uint16_t kFlagAA = 0x400; +static const uint16_t kFlagRD = 0x100; // Recursion Desired - query flag. +static const uint16_t kFlagTC = 0x200; // Truncated - server flag. } // namespace dns_protocol
diff --git a/services/shape_detection/BUILD.gn b/services/shape_detection/BUILD.gn index 9a2ddbd..e4d401d 100644 --- a/services/shape_detection/BUILD.gn +++ b/services/shape_detection/BUILD.gn
@@ -12,7 +12,6 @@ "face_detection_provider_impl.h", "shape_detection_service.cc", "shape_detection_service.h", - "text_detection_impl.h", ] if (is_mac) { @@ -23,15 +22,12 @@ "detection_utils_mac.mm", "face_detection_impl_mac.h", "face_detection_impl_mac.mm", - "text_detection_impl_mac.h", - "text_detection_impl_mac.mm", ] libs = [ "QuartzCore.framework" ] } else { sources += [ "barcode_detection_impl.cc", "face_detection_provider_impl.cc", - "text_detection_impl.cc", ] } @@ -61,7 +57,6 @@ sources += [ "barcode_detection_impl_mac_unittest.mm", "face_detection_impl_mac_unittest.mm", - "text_detection_impl_mac_unittest.mm", ] libs = [
diff --git a/services/shape_detection/manifest.json b/services/shape_detection/manifest.json index 542148e..b92fb5c 100644 --- a/services/shape_detection/manifest.json +++ b/services/shape_detection/manifest.json
@@ -5,8 +5,7 @@ "service_manager:connector": { "provides": { "face_detection": [ "shape_detection::mojom::FaceDetectionProvider" ], - "barcode_detection": [ "shape_detection::mojom::BarcodeDetection" ], - "text_detection": [ "shape_detection::mojom::TextDetection" ] + "barcode_detection": [ "shape_detection::mojom::BarcodeDetection" ] }, "requires": { "service_manager": [ "service_manager:all_users" ]
diff --git a/services/shape_detection/shape_detection_service.cc b/services/shape_detection/shape_detection_service.cc index 9d4000b..c2375168 100644 --- a/services/shape_detection/shape_detection_service.cc +++ b/services/shape_detection/shape_detection_service.cc
@@ -9,7 +9,6 @@ #include "services/service_manager/public/cpp/service_context.h" #include "services/shape_detection/barcode_detection_impl.h" #include "services/shape_detection/face_detection_provider_impl.h" -#include "services/shape_detection/text_detection_impl.h" namespace shape_detection { @@ -46,7 +45,6 @@ base::Bind(&OnConnectionLost, base::Passed(&connection_ref))); registry->AddInterface(base::Bind(&BarcodeDetectionImpl::Create)); registry->AddInterface(base::Bind(&FaceDetectionProviderImpl::Create)); - registry->AddInterface(base::Bind(&TextDetectionImpl::Create)); return true; }
diff --git a/services/shape_detection/text_detection_impl.cc b/services/shape_detection/text_detection_impl.cc deleted file mode 100644 index c5a3f09..0000000 --- a/services/shape_detection/text_detection_impl.cc +++ /dev/null
@@ -1,14 +0,0 @@ -// Copyright 2017 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 "services/shape_detection/text_detection_impl.h" - -namespace shape_detection { - -// static -void TextDetectionImpl::Create(mojom::TextDetectionRequest request) { - DLOG(ERROR) << "Platform not supported for Text Detection Service."; -} - -} // namespace shape_detection
diff --git a/services/shape_detection/text_detection_impl.h b/services/shape_detection/text_detection_impl.h deleted file mode 100644 index 617f6e8..0000000 --- a/services/shape_detection/text_detection_impl.h +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2017 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 SERVICES_SHAPE_DETECTION_TEXT_DETECTION_IMPL_H_ -#define SERVICES_SHAPE_DETECTION_TEXT_DETECTION_IMPL_H_ - -#include "services/shape_detection/public/interfaces/textdetection.mojom.h" - -namespace shape_detection { - -class TextDetectionImpl { - public: - static void Create(mojom::TextDetectionRequest request); - - private: - ~TextDetectionImpl() = default; - - DISALLOW_COPY_AND_ASSIGN(TextDetectionImpl); -}; - -} // namespace shape_detection - -#endif // SERVICES_SHAPE_DETECTION_TEXT_DETECTION_IMPL_H_
diff --git a/services/shape_detection/text_detection_impl_mac.h b/services/shape_detection/text_detection_impl_mac.h deleted file mode 100644 index d86be927..0000000 --- a/services/shape_detection/text_detection_impl_mac.h +++ /dev/null
@@ -1,33 +0,0 @@ -// Copyright 2017 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 SERVICES_SHAPE_DETECTION_TEXT_DETECTION_IMPL_MAC_H_ -#define SERVICES_SHAPE_DETECTION_TEXT_DETECTION_IMPL_MAC_H_ - -#include "base/mac/scoped_nsobject.h" -#include "services/shape_detection/public/interfaces/textdetection.mojom.h" - -@class CIDetector; - -namespace shape_detection { - -class TextDetectionImplMac : public mojom::TextDetection { - public: - TextDetectionImplMac(); - ~TextDetectionImplMac() override; - - void Detect(mojo::ScopedSharedBufferHandle frame_data, - uint32_t width, - uint32_t height, - const mojom::TextDetection::DetectCallback& callback) override; - - private: - base::scoped_nsobject<CIDetector> detector_; - - DISALLOW_COPY_AND_ASSIGN(TextDetectionImplMac); -}; - -} // namespace shape_detection - -#endif // SERVICES_SHAPE_DETECTION_TEXT_DETECTION_IMPL_MAC_H_
diff --git a/services/shape_detection/text_detection_impl_mac.mm b/services/shape_detection/text_detection_impl_mac.mm deleted file mode 100644 index 3894770a..0000000 --- a/services/shape_detection/text_detection_impl_mac.mm +++ /dev/null
@@ -1,83 +0,0 @@ -// Copyright 2017 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 "services/shape_detection/text_detection_impl_mac.h" - -#include "base/mac/mac_util.h" -#include "base/mac/scoped_cftyperef.h" -#include "base/mac/sdk_forward_declarations.h" -#include "base/strings/sys_string_conversions.h" -#include "media/capture/video/scoped_result_callback.h" -#include "mojo/public/cpp/bindings/strong_binding.h" -#include "services/shape_detection/detection_utils_mac.h" -#include "services/shape_detection/text_detection_impl.h" - -namespace shape_detection { - -namespace { - -void RunCallbackWithResults( - const mojom::TextDetection::DetectCallback& callback, - std::vector<mojom::TextDetectionResultPtr> results) { - callback.Run(std::move(results)); -} - -void RunCallbackWithNoResults( - const mojom::TextDetection::DetectCallback& callback) { - callback.Run(std::vector<mojom::TextDetectionResultPtr>()); -} - -} // anonymous namespace - -// static -void TextDetectionImpl::Create(mojom::TextDetectionRequest request) { - // Text detection needs at least MAC OS X 10.11. - if (!base::mac::IsAtLeastOS10_11()) - return; - mojo::MakeStrongBinding(base::MakeUnique<TextDetectionImplMac>(), - std::move(request)); -} - -TextDetectionImplMac::TextDetectionImplMac() { - NSDictionary* const opts = @{CIDetectorAccuracy : CIDetectorAccuracyHigh}; - detector_.reset([[CIDetector detectorOfType:CIDetectorTypeText - context:nil - options:opts] retain]); -} - -TextDetectionImplMac::~TextDetectionImplMac() {} - -void TextDetectionImplMac::Detect(mojo::ScopedSharedBufferHandle frame_data, - uint32_t width, - uint32_t height, - const DetectCallback& callback) { - DCHECK(base::mac::IsAtLeastOS10_11()); - media::ScopedResultCallback<DetectCallback> scoped_callback( - base::Bind(&RunCallbackWithResults, callback), - base::Bind(&RunCallbackWithNoResults)); - - base::scoped_nsobject<CIImage> ci_image = - CreateCIImageFromSharedMemory(std::move(frame_data), width, height); - if (!ci_image) - return; - - NSArray* const features = [detector_ featuresInImage:ci_image]; - - std::vector<mojom::TextDetectionResultPtr> results; - for (CIRectangleFeature* const f in features) { - // CIRectangleFeature only has bounding box information. - auto result = mojom::TextDetectionResult::New(); - // In the default Core Graphics coordinate space, the origin is located - // in the lower-left corner, and thus |ci_image| is flipped vertically. - // We need to adjust |y| coordinate of bounding box before sending it. - gfx::RectF boundingbox(f.bounds.origin.x, - height - f.bounds.origin.y - f.bounds.size.height, - f.bounds.size.width, f.bounds.size.height); - result->bounding_box = std::move(boundingbox); - results.push_back(std::move(result)); - } - scoped_callback.Run(std::move(results)); -} - -} // namespace shape_detection
diff --git a/services/shape_detection/text_detection_impl_mac_unittest.mm b/services/shape_detection/text_detection_impl_mac_unittest.mm deleted file mode 100644 index 5333a51..0000000 --- a/services/shape_detection/text_detection_impl_mac_unittest.mm +++ /dev/null
@@ -1,111 +0,0 @@ -// Copyright 2017 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 "services/shape_detection/text_detection_impl_mac.h" - -#include "base/command_line.h" -#include "base/mac/mac_util.h" -#include "base/mac/scoped_cftyperef.h" -#include "base/mac/scoped_nsobject.h" -#include "base/mac/sdk_forward_declarations.h" -#include "base/run_loop.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gl/gl_switches.h" - -namespace shape_detection { - -ACTION_P(RunClosure, closure) { - closure.Run(); -} - -class TextDetectionImplMacTest : public ::testing::Test { - public: - ~TextDetectionImplMacTest() override = default; - - void DetectCallback(std::vector<mojom::TextDetectionResultPtr> results) { - // CIDetectorTypeText doesn't return the decoded text, juts bounding boxes. - Detection(results.size()); - } - MOCK_METHOD1(Detection, void(size_t)); - - TextDetectionImplMac impl_; - const base::MessageLoop message_loop_; -}; - -TEST_F(TextDetectionImplMacTest, CreateAndDestroy) {} - -// This test generates an image with a single text line and scans it back. -TEST_F(TextDetectionImplMacTest, ScanOnce) { - // Text detection needs at least MAC OS X 10.11, and GPU infrastructure. - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseGpuInTests) || - !base::mac::IsAtLeastOS10_11()) { - return; - } - - base::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace( - CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)); - - const int width = 200; - const int height = 50; - base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate( - nullptr, width, height, 8 /* bitsPerComponent */, - width * 4 /* rowBytes */, rgb_colorspace, - kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); - - // Draw a white background. - CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); - CGContextFillRect(context, CGRectMake(0.0, 0.0, width, height)); - - // Create a line of Helvetica 16 text, and draw it in the |context|. - base::scoped_nsobject<NSFont> helvetica( - [NSFont fontWithName:@"Helvetica" size:16]); - NSDictionary* attributes = [NSDictionary - dictionaryWithObjectsAndKeys:helvetica, kCTFontAttributeName, nil]; - - base::scoped_nsobject<NSAttributedString> info([[NSAttributedString alloc] - initWithString:@"https://www.chromium.org" - attributes:attributes]); - - base::ScopedCFTypeRef<CTLineRef> line( - CTLineCreateWithAttributedString((CFAttributedStringRef)info.get())); - - CGContextSetTextPosition(context, 10.0, height / 2.0); - CTLineDraw(line, context); - - // Extract a CGImage and its raw pixels from |context|. - base::ScopedCFTypeRef<CGImageRef> cg_image( - CGBitmapContextCreateImage(context)); - EXPECT_EQ(static_cast<size_t>(width), CGImageGetWidth(cg_image)); - EXPECT_EQ(static_cast<size_t>(height), CGImageGetHeight(cg_image)); - - base::ScopedCFTypeRef<CFDataRef> raw_cg_image_data( - CGDataProviderCopyData(CGImageGetDataProvider(cg_image))); - EXPECT_TRUE(CFDataGetBytePtr(raw_cg_image_data)); - const int num_bytes = width * height * 4; - EXPECT_EQ(num_bytes, CFDataGetLength(raw_cg_image_data)); - - // Generate a new ScopedSharedBufferHandle of the aproppriate size, map it and - // copy the generated text image pixels into it. - auto handle = mojo::SharedBufferHandle::Create(num_bytes); - ASSERT_TRUE(handle->is_valid()); - - mojo::ScopedSharedBufferMapping mapping = handle->Map(num_bytes); - ASSERT_TRUE(mapping); - - memcpy(mapping.get(), CFDataGetBytePtr(raw_cg_image_data), num_bytes); - - base::RunLoop run_loop; - base::Closure quit_closure = run_loop.QuitClosure(); - // Send the image to Detect() and expect the response in callback. - EXPECT_CALL(*this, Detection(1)).WillOnce(RunClosure(quit_closure)); - impl_.Detect(std::move(handle), width, height, - base::Bind(&TextDetectionImplMacTest::DetectCallback, - base::Unretained(this))); - - run_loop.Run(); -} - -} // shape_detection namespace
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp index 4a31146..67d3a44 100644 --- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
@@ -33,9 +33,11 @@ #include <utility> #include "bindings/core/v8/V8DOMWrapper.h" +#include "bindings/core/v8/V8Window.h" #include "core/frame/Frame.h" #include "v8/include/v8.h" #include "wtf/Assertions.h" +#include "wtf/debug/Alias.h" namespace blink { @@ -130,11 +132,40 @@ // If there are JS code holds a closure to the old inner window, // it won't be able to reach the outer window via its global object. void WindowProxy::initializeIfNeeded() { + v8::HandleScope handleScope(m_isolate); + Lifecycle oldLifecycle = m_lifecycle; + DOMWindow* window = m_frame->domWindow(); + bool isLocal = window->isLocalDOMWindow(); + // Prevent these locals from getting optimized out, and hopefully, the heap + // contents captured into minidumps. + WTF::debug::alias(&oldLifecycle); + WTF::debug::alias(&window); + WTF::debug::alias(&isLocal); + // TODO(haraken): It is wrong to re-initialize an already detached window // proxy. This must be 'if(m_lifecycle == Lifecycle::ContextUninitialized)'. if (m_lifecycle != Lifecycle::ContextInitialized) { initialize(); + // Note: this set of CHECKs is intentionally duplicated below to distinguish + // between initializing the global with null internal fields or returning a + // global that claims to be initialized but has null internal fields. + v8::Local<v8::Object> globalProxy = m_globalProxy.newLocal(m_isolate); + CHECK(!globalProxy.IsEmpty()); + CHECK(V8Window::hasInstance(globalProxy, m_isolate)); + CHECK(window); + CHECK_EQ(window, V8Window::toImpl(globalProxy)); + } else { + v8::Local<v8::Object> globalProxy = m_globalProxy.newLocal(m_isolate); + CHECK(!globalProxy.IsEmpty()); + CHECK(V8Window::hasInstance(globalProxy, m_isolate)); + CHECK(window); + CHECK_EQ(window, V8Window::toImpl(globalProxy)); } + + // Sanity check: WindowProxy's frame's window should still be the same + DOMWindow* window2 = m_frame->domWindow(); + WTF::debug::alias(&window2); + CHECK_EQ(window, window2); } } // namespace blink
diff --git a/third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp b/third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp index 3fcba55..fc2e921 100644 --- a/third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp +++ b/third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp
@@ -5,6 +5,7 @@ #include "web/WebRemoteFrameImpl.h" #include "bindings/core/v8/RemoteWindowProxy.h" +#include "bindings/core/v8/V8Window.h" #include "core/dom/Fullscreen.h" #include "core/dom/RemoteSecurityContext.h" #include "core/dom/SecurityContext.h" @@ -26,6 +27,7 @@ #include "web/RemoteFrameOwner.h" #include "web/WebLocalFrameImpl.h" #include "web/WebViewImpl.h" +#include "wtf/debug/Alias.h" namespace blink { @@ -215,9 +217,23 @@ v8::Local<v8::Context> WebRemoteFrameImpl::deprecatedMainWorldScriptContext() const { - return static_cast<RemoteWindowProxy*>( - frame()->windowProxy(DOMWrapperWorld::mainWorld())) - ->contextIfInitialized(); + v8::Local<v8::Context> context = + static_cast<RemoteWindowProxy*>( + frame()->windowProxy(DOMWrapperWorld::mainWorld())) + ->contextIfInitialized(); + + DOMWindow* window = frame()->domWindow(); + // Prevent this local from getting optimized out, and hopefully, the heap + // contents captured into minidumps. + WTF::debug::alias(&window); + + v8::Local<v8::Object> globalProxy = context->Global(); + CHECK(!globalProxy.IsEmpty()); + CHECK(V8Window::hasInstance(globalProxy, v8::Isolate::GetCurrent())); + CHECK(window); + CHECK_EQ(window, V8Window::toImpl(globalProxy)); + + return context; } void WebRemoteFrameImpl::reload(WebFrameLoadType) {
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index f834465..1a58b6f 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -26053,10 +26053,18 @@ </histogram> <histogram name="Media.Duration" units="ms"> + <obsolete> + Removed 03/2017 in favor of Media.Duration2 with larger max bucket. + </obsolete> <owner>scherkus@chromium.org</owner> <summary>Duration in milliseconds of HTML5 media (when known).</summary> </histogram> +<histogram name="Media.Duration2" units="ms"> + <owner>dalecurtis@chromium.org</owner> + <summary>Duration in milliseconds of HTML5 media (when known).</summary> +</histogram> + <histogram name="Media.EME.CdmFileIO.FileSizeKBOnError" units="KB"> <owner>xhwang@chromium.org</owner> <summary>
diff --git a/ui/aura/mus/window_tree_client_unittest.cc b/ui/aura/mus/window_tree_client_unittest.cc index c15f3b7..b4f7db24 100644 --- a/ui/aura/mus/window_tree_client_unittest.cc +++ b/ui/aura/mus/window_tree_client_unittest.cc
@@ -43,6 +43,7 @@ #include "ui/display/screen.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" +#include "ui/events/test/test_event_handler.h" #include "ui/gfx/geometry/dip_util.h" #include "ui/gfx/geometry/rect.h" @@ -536,6 +537,37 @@ DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate); }; +class InputEventBasicTestEventHandler : public ui::test::TestEventHandler { + public: + InputEventBasicTestEventHandler() {} + ~InputEventBasicTestEventHandler() override {} + + bool got_move() const { return got_move_; } + const gfx::Point& last_event_location() const { return last_event_location_; } + void set_event_id(uint32_t event_id) { event_id_ = event_id; } + + // ui::test::TestEventHandler overrides. + void OnMouseEvent(ui::MouseEvent* event) override { + if (event->type() == ui::ET_MOUSE_MOVED) + got_move_ = true; + last_event_location_ = event->location(); + event->SetHandled(); + } + + void reset() { + got_move_ = false; + last_event_location_ = gfx::Point(); + event_id_ = 0; + } + + private: + bool got_move_ = false; + gfx::Point last_event_location_; + uint32_t event_id_ = 0; + + DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestEventHandler); +}; + } // namespace TEST_F(WindowTreeClientClientTest, InputEventBasic) { @@ -779,6 +811,47 @@ capture_client.reset(); } +TEST_F(WindowTreeClientClientTest, InputEventRootWindow) { + WindowTreeHostMus window_tree_host(window_tree_client_impl()); + Window* top_level = window_tree_host.window(); + InputEventBasicTestEventHandler root_handler; + top_level->AddPreTargetHandler(&root_handler); + const gfx::Rect bounds(0, 0, 100, 100); + window_tree_host.SetBoundsInPixels(bounds); + window_tree_host.InitHost(); + window_tree_host.Show(); + EXPECT_EQ(bounds, top_level->bounds()); + EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); + InputEventBasicTestWindowDelegate child_delegate(window_tree()); + Window child(&child_delegate); + child.Init(ui::LAYER_NOT_DRAWN); + top_level->AddChild(&child); + child.SetBounds(gfx::Rect(10, 10, 100, 100)); + child.Show(); + + EXPECT_FALSE(root_handler.got_move()); + EXPECT_FALSE(child_delegate.got_move()); + + const gfx::Point event_location_in_child(20, 30); + const uint32_t event_id = 1; + root_handler.set_event_id(event_id); + child_delegate.set_event_id(event_id); + std::unique_ptr<ui::Event> ui_event( + new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child, + gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0)); + window_tree_client()->OnWindowInputEvent( + event_id, server_id(top_level), window_tree_host.display_id(), + ui::Event::Clone(*ui_event.get()), 0); + + EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); + EXPECT_EQ(ui::mojom::EventResult::HANDLED, + window_tree()->GetEventResult(event_id)); + EXPECT_TRUE(root_handler.got_move()); + EXPECT_EQ(gfx::Point(20, 30), root_handler.last_event_location()); + EXPECT_FALSE(child_delegate.got_move()); + EXPECT_EQ(gfx::Point(), child_delegate.last_event_location()); +} + class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest { public: WindowTreeClientPointerObserverTest() {}
diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc index 02885e5..78ecee4d 100644 --- a/ui/aura/window_event_dispatcher.cc +++ b/ui/aura/window_event_dispatcher.cc
@@ -455,7 +455,7 @@ } ui::EventTarget* ancestor_with_targeter = event_target; - for (ui::EventTarget* ancestor = event_target->GetParentTarget(); ancestor; + for (ui::EventTarget* ancestor = event_target; ancestor; ancestor = ancestor->GetParentTarget()) { if (ancestor->GetEventTargeter()) ancestor_with_targeter = ancestor;