| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 namespace html_viewer { | 78 namespace html_viewer { |
| 79 namespace { | 79 namespace { |
| 80 | 80 |
| 81 const size_t kMaxTitleChars = 4 * 1024; | 81 const size_t kMaxTitleChars = 4 * 1024; |
| 82 | 82 |
| 83 web_view::mojom::NavigationTargetType WebNavigationPolicyToNavigationTarget( | 83 web_view::mojom::NavigationTargetType WebNavigationPolicyToNavigationTarget( |
| 84 blink::WebNavigationPolicy policy) { | 84 blink::WebNavigationPolicy policy) { |
| 85 switch (policy) { | 85 switch (policy) { |
| 86 case blink::WebNavigationPolicyCurrentTab: | 86 case blink::WebNavigationPolicyCurrentTab: |
| 87 return web_view::mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME; | 87 return web_view::mojom::NavigationTargetType::EXISTING_FRAME; |
| 88 case blink::WebNavigationPolicyNewBackgroundTab: | 88 case blink::WebNavigationPolicyNewBackgroundTab: |
| 89 case blink::WebNavigationPolicyNewForegroundTab: | 89 case blink::WebNavigationPolicyNewForegroundTab: |
| 90 case blink::WebNavigationPolicyNewWindow: | 90 case blink::WebNavigationPolicyNewWindow: |
| 91 case blink::WebNavigationPolicyNewPopup: | 91 case blink::WebNavigationPolicyNewPopup: |
| 92 return web_view::mojom::NAVIGATION_TARGET_TYPE_NEW_FRAME; | 92 return web_view::mojom::NavigationTargetType::NEW_FRAME; |
| 93 default: | 93 default: |
| 94 return web_view::mojom::NAVIGATION_TARGET_TYPE_NO_PREFERENCE; | 94 return web_view::mojom::NavigationTargetType::NO_PREFERENCE; |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 HTMLFrame* GetPreviousSibling(HTMLFrame* frame) { | 98 HTMLFrame* GetPreviousSibling(HTMLFrame* frame) { |
| 99 DCHECK(frame->parent()); | 99 DCHECK(frame->parent()); |
| 100 auto iter = std::find(frame->parent()->children().begin(), | 100 auto iter = std::find(frame->parent()->children().begin(), |
| 101 frame->parent()->children().end(), frame); | 101 frame->parent()->children().end(), frame); |
| 102 return (iter == frame->parent()->children().begin()) ? nullptr : *(--iter); | 102 return (iter == frame->parent()->children().begin()) ? nullptr : *(--iter); |
| 103 } | 103 } |
| 104 | 104 |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 event->pointer_data->location->screen_y /= | 781 event->pointer_data->location->screen_y /= |
| 782 global_state()->device_pixel_ratio(); | 782 global_state()->device_pixel_ratio(); |
| 783 } | 783 } |
| 784 | 784 |
| 785 blink::WebWidget* web_widget = GetWebWidget(); | 785 blink::WebWidget* web_widget = GetWebWidget(); |
| 786 | 786 |
| 787 if (!touch_handler_ && web_widget) | 787 if (!touch_handler_ && web_widget) |
| 788 touch_handler_.reset(new TouchHandler(web_widget)); | 788 touch_handler_.reset(new TouchHandler(web_widget)); |
| 789 | 789 |
| 790 if (touch_handler_ && | 790 if (touch_handler_ && |
| 791 (event->action == mus::mojom::EVENT_TYPE_POINTER_DOWN || | 791 (event->action == mus::mojom::EventType::POINTER_DOWN || |
| 792 event->action == mus::mojom::EVENT_TYPE_POINTER_UP || | 792 event->action == mus::mojom::EventType::POINTER_UP || |
| 793 event->action == mus::mojom::EVENT_TYPE_POINTER_CANCEL || | 793 event->action == mus::mojom::EventType::POINTER_CANCEL || |
| 794 event->action == mus::mojom::EVENT_TYPE_POINTER_MOVE) && | 794 event->action == mus::mojom::EventType::POINTER_MOVE) && |
| 795 event->pointer_data && | 795 event->pointer_data && |
| 796 event->pointer_data->kind == mus::mojom::POINTER_KIND_TOUCH) { | 796 event->pointer_data->kind == mus::mojom::PointerKind::TOUCH) { |
| 797 touch_handler_->OnTouchEvent(*event); | 797 touch_handler_->OnTouchEvent(*event); |
| 798 return; | 798 return; |
| 799 } | 799 } |
| 800 | 800 |
| 801 if (!web_widget) | 801 if (!web_widget) |
| 802 return; | 802 return; |
| 803 | 803 |
| 804 scoped_ptr<blink::WebInputEvent> web_event = | 804 scoped_ptr<blink::WebInputEvent> web_event = |
| 805 event.To<scoped_ptr<blink::WebInputEvent>>(); | 805 event.To<scoped_ptr<blink::WebInputEvent>>(); |
| 806 if (web_event) | 806 if (web_event) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 global_state()->device_pixel_ratio(), rect_in_dip)); | 1011 global_state()->device_pixel_ratio(), rect_in_dip)); |
| 1012 window_->SetBounds(rect_in_pixels); | 1012 window_->SetBounds(rect_in_pixels); |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 void HTMLFrame::navigate(const blink::WebURLRequest& request, | 1015 void HTMLFrame::navigate(const blink::WebURLRequest& request, |
| 1016 bool should_replace_current_entry) { | 1016 bool should_replace_current_entry) { |
| 1017 // TODO: support |should_replace_current_entry|. | 1017 // TODO: support |should_replace_current_entry|. |
| 1018 NOTIMPLEMENTED(); // for |should_replace_current_entry | 1018 NOTIMPLEMENTED(); // for |should_replace_current_entry |
| 1019 mojo::URLRequestPtr url_request = mojo::URLRequest::From(request); | 1019 mojo::URLRequestPtr url_request = mojo::URLRequest::From(request); |
| 1020 GetServerFrame()->RequestNavigate( | 1020 GetServerFrame()->RequestNavigate( |
| 1021 web_view::mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME, id_, | 1021 web_view::mojom::NavigationTargetType::EXISTING_FRAME, id_, |
| 1022 std::move(url_request)); | 1022 std::move(url_request)); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { | 1025 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { |
| 1026 NOTIMPLEMENTED(); | 1026 NOTIMPLEMENTED(); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 void HTMLFrame::frameRectsChanged(const blink::WebRect& frame_rect) { | 1029 void HTMLFrame::frameRectsChanged(const blink::WebRect& frame_rect) { |
| 1030 // Only the owner of window can update its size. | 1030 // Only the owner of window can update its size. |
| 1031 if (!owned_window_) | 1031 if (!owned_window_) |
| 1032 return; | 1032 return; |
| 1033 | 1033 |
| 1034 const gfx::Rect rect_in_dip(frame_rect.x, frame_rect.y, frame_rect.width, | 1034 const gfx::Rect rect_in_dip(frame_rect.x, frame_rect.y, frame_rect.width, |
| 1035 frame_rect.height); | 1035 frame_rect.height); |
| 1036 const gfx::Rect rect_in_pixels(gfx::ConvertRectToPixel( | 1036 const gfx::Rect rect_in_pixels(gfx::ConvertRectToPixel( |
| 1037 global_state()->device_pixel_ratio(), rect_in_dip)); | 1037 global_state()->device_pixel_ratio(), rect_in_dip)); |
| 1038 owned_window_->window()->SetBounds(rect_in_pixels); | 1038 owned_window_->window()->SetBounds(rect_in_pixels); |
| 1039 | 1039 |
| 1040 if (!surface_layer_) | 1040 if (!surface_layer_) |
| 1041 return; | 1041 return; |
| 1042 | 1042 |
| 1043 surface_layer_->SetSurfaceId(cc::SurfaceId(owned_window_->window()->id()), | 1043 surface_layer_->SetSurfaceId(cc::SurfaceId(owned_window_->window()->id()), |
| 1044 global_state()->device_pixel_ratio(), | 1044 global_state()->device_pixel_ratio(), |
| 1045 owned_window_->window()->bounds().size()); | 1045 owned_window_->window()->bounds().size()); |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 } // namespace mojo | 1048 } // namespace mojo |
| OLD | NEW |