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

Side by Side Diff: components/html_viewer/html_frame.cc

Issue 1362793002: Construct and check for mojo::Event's LocationData as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also audit wheel_data and brush_data. Created 5 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/html_viewer/html_frame.h" 5 #include "components/html_viewer/html_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 blink::WebNavigationPolicy HTMLFrame::decidePolicyForNavigation( 343 blink::WebNavigationPolicy HTMLFrame::decidePolicyForNavigation(
344 const NavigationPolicyInfo& info) { 344 const NavigationPolicyInfo& info) {
345 // If we have extraData() it means we already have the url response 345 // If we have extraData() it means we already have the url response
346 // (presumably because we are being called via Navigate()). In that case we 346 // (presumably because we are being called via Navigate()). In that case we
347 // can go ahead and navigate locally. 347 // can go ahead and navigate locally.
348 if (info.urlRequest.extraData()) { 348 if (info.urlRequest.extraData()) {
349 DCHECK_EQ(blink::WebNavigationPolicyCurrentTab, info.defaultPolicy); 349 DCHECK_EQ(blink::WebNavigationPolicyCurrentTab, info.defaultPolicy);
350 return blink::WebNavigationPolicyCurrentTab; 350 return blink::WebNavigationPolicyCurrentTab;
351 } 351 }
352 352
353 // about:blank is treated as the same origin and is always allowed for 353 // about:blank is treated as the same origin and is always allowed for frames.
354 // frames.
355 if (parent_ && info.urlRequest.url() == GURL(url::kAboutBlankURL) && 354 if (parent_ && info.urlRequest.url() == GURL(url::kAboutBlankURL) &&
356 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab) { 355 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab) {
357 return blink::WebNavigationPolicyCurrentTab; 356 return blink::WebNavigationPolicyCurrentTab;
358 } 357 }
359 358
360 // Ask the Frame to handle the navigation. By returning 359 // Ask the Frame to handle the navigation. By returning
361 // WebNavigationPolicyIgnore the load is suppressed. 360 // WebNavigationPolicyIgnore the load is suppressed.
362 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest); 361 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest);
363 server_->RequestNavigate( 362 server_->RequestNavigate(
364 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), id_, 363 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), id_,
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 } 642 }
644 643
645 void HTMLFrame::OnViewDestroyed(View* view) { 644 void HTMLFrame::OnViewDestroyed(View* view) {
646 DCHECK_EQ(view, view_); 645 DCHECK_EQ(view, view_);
647 view_->RemoveObserver(this); 646 view_->RemoveObserver(this);
648 view_ = nullptr; 647 view_ = nullptr;
649 Close(); 648 Close();
650 } 649 }
651 650
652 void HTMLFrame::OnViewInputEvent(View* view, const mojo::EventPtr& event) { 651 void HTMLFrame::OnViewInputEvent(View* view, const mojo::EventPtr& event) {
653 if (event->pointer_data) { 652 if (event->pointer_data && event->pointer_data->location) {
654 // Blink expects coordintes to be in DIPs. 653 // Blink expects coordintes to be in DIPs.
655 event->pointer_data->location->x /= global_state()->device_pixel_ratio(); 654 event->pointer_data->location->x /= global_state()->device_pixel_ratio();
656 event->pointer_data->location->y /= global_state()->device_pixel_ratio(); 655 event->pointer_data->location->y /= global_state()->device_pixel_ratio();
657 event->pointer_data->location->screen_x /= 656 event->pointer_data->location->screen_x /=
658 global_state()->device_pixel_ratio(); 657 global_state()->device_pixel_ratio();
659 event->pointer_data->location->screen_y /= 658 event->pointer_data->location->screen_y /=
660 global_state()->device_pixel_ratio(); 659 global_state()->device_pixel_ratio();
661 } 660 }
662 661
663 blink::WebWidget* web_widget = GetWebWidget(); 662 blink::WebWidget* web_widget = GetWebWidget();
664 663
665 if (!touch_handler_ && web_widget) 664 if (!touch_handler_ && web_widget)
666 touch_handler_.reset(new TouchHandler(web_widget)); 665 touch_handler_.reset(new TouchHandler(web_widget));
667 666
668 if (touch_handler_ && (event->action == mojo::EVENT_TYPE_POINTER_DOWN || 667 if (touch_handler_ && (event->action == mojo::EVENT_TYPE_POINTER_DOWN ||
669 event->action == mojo::EVENT_TYPE_POINTER_UP || 668 event->action == mojo::EVENT_TYPE_POINTER_UP ||
670 event->action == mojo::EVENT_TYPE_POINTER_CANCEL || 669 event->action == mojo::EVENT_TYPE_POINTER_CANCEL ||
671 event->action == mojo::EVENT_TYPE_POINTER_MOVE) && 670 event->action == mojo::EVENT_TYPE_POINTER_MOVE) &&
671 event->pointer_data &&
672 event->pointer_data->kind == mojo::POINTER_KIND_TOUCH) { 672 event->pointer_data->kind == mojo::POINTER_KIND_TOUCH) {
673 touch_handler_->OnTouchEvent(*event); 673 touch_handler_->OnTouchEvent(*event);
674 return; 674 return;
675 } 675 }
676 676
677 if (!web_widget) 677 if (!web_widget)
678 return; 678 return;
679 679
680 scoped_ptr<blink::WebInputEvent> web_event = 680 scoped_ptr<blink::WebInputEvent> web_event =
681 event.To<scoped_ptr<blink::WebInputEvent>>(); 681 event.To<scoped_ptr<blink::WebInputEvent>>();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 842
843 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { 843 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) {
844 NOTIMPLEMENTED(); 844 NOTIMPLEMENTED();
845 } 845 }
846 846
847 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) { 847 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) {
848 NOTIMPLEMENTED(); 848 NOTIMPLEMENTED();
849 } 849 }
850 850
851 } // namespace mojo 851 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698