Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: content/browser/devtools/renderer_overrides_handler.cc

Issue 485253002: DevTools: eye dropper, only pick on mouse down. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/renderer_overrides_handler.h" 5 #include "content/browser/devtools/renderer_overrides_handler.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/barrier_closure.h" 10 #include "base/barrier_closure.h"
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 } 946 }
947 } 947 }
948 948
949 bool RendererOverridesHandler::HandleMouseEvent( 949 bool RendererOverridesHandler::HandleMouseEvent(
950 const blink::WebMouseEvent& event) { 950 const blink::WebMouseEvent& event) {
951 last_cursor_x_ = event.x; 951 last_cursor_x_ = event.x;
952 last_cursor_y_ = event.y; 952 last_cursor_y_ = event.y;
953 if (color_picker_frame_.drawsNothing()) 953 if (color_picker_frame_.drawsNothing())
954 return true; 954 return true;
955 955
956 if (event.button == blink::WebMouseEvent::ButtonLeft) { 956 if (event.button == blink::WebMouseEvent::ButtonLeft &&
957 event.type == blink::WebInputEvent::MouseDown) {
957 if (last_cursor_x_ < 0 || last_cursor_x_ >= color_picker_frame_.width() || 958 if (last_cursor_x_ < 0 || last_cursor_x_ >= color_picker_frame_.width() ||
958 last_cursor_y_ < 0 || last_cursor_y_ >= color_picker_frame_.height()) { 959 last_cursor_y_ < 0 || last_cursor_y_ >= color_picker_frame_.height()) {
959 return true; 960 return true;
960 } 961 }
961 962
962 SkAutoLockPixels lock_image(color_picker_frame_); 963 SkAutoLockPixels lock_image(color_picker_frame_);
963 SkColor color = color_picker_frame_.getColor(last_cursor_x_, 964 SkColor color = color_picker_frame_.getColor(last_cursor_x_,
964 last_cursor_y_); 965 last_cursor_y_);
965 base::DictionaryValue* color_dict = new base::DictionaryValue(); 966 base::DictionaryValue* color_dict = new base::DictionaryValue();
966 color_dict->SetInteger("r", SkColorGetR(color)); 967 color_dict->SetInteger("r", SkColorGetR(color));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 #endif 1011 #endif
1011 1012
1012 blink::WebScreenInfo screen_info; 1013 blink::WebScreenInfo screen_info;
1013 view->GetScreenInfo(&screen_info); 1014 view->GetScreenInfo(&screen_info);
1014 double device_scale_factor = screen_info.deviceScaleFactor; 1015 double device_scale_factor = screen_info.deviceScaleFactor;
1015 1016
1016 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRasterN32( 1017 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRasterN32(
1017 kCursorSize * device_scale_factor, 1018 kCursorSize * device_scale_factor,
1018 kCursorSize * device_scale_factor)); 1019 kCursorSize * device_scale_factor));
1019 canvas->scale(device_scale_factor, device_scale_factor); 1020 canvas->scale(device_scale_factor, device_scale_factor);
1021 canvas->translate(0.5f, 0.5f);
1020 1022
1021 SkPaint paint; 1023 SkPaint paint;
1022 1024
1023 // Paint original spot with cross. 1025 // Paint original spot with cross.
1024 if (kHotspotRadius) { 1026 if (kHotspotRadius) {
1025 paint.setStrokeWidth(1); 1027 paint.setStrokeWidth(1);
1026 paint.setAntiAlias(false); 1028 paint.setAntiAlias(false);
1027 paint.setColor(SK_ColorDKGRAY); 1029 paint.setColor(SK_ColorDKGRAY);
1028 paint.setStyle(SkPaint::kStroke_Style); 1030 paint.setStyle(SkPaint::kStroke_Style);
1029 1031
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 return command->InternalErrorResponse("Could not connect to view"); 1234 return command->InternalErrorResponse("Could not connect to view");
1233 1235
1234 if (event->type == WebInputEvent::MouseWheel) 1236 if (event->type == WebInputEvent::MouseWheel)
1235 host_->ForwardWheelEvent(wheel_event); 1237 host_->ForwardWheelEvent(wheel_event);
1236 else 1238 else
1237 host_->ForwardMouseEvent(mouse_event); 1239 host_->ForwardMouseEvent(mouse_event);
1238 return command->SuccessResponse(NULL); 1240 return command->SuccessResponse(NULL);
1239 } 1241 }
1240 1242
1241 } // namespace content 1243 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698