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

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

Issue 1373003002: html_viewer/Mandoline: Avoid subclassing WebLayerImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 5 years, 2 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
« no previous file with comments | « components/html_viewer/html_frame.h ('k') | components/html_viewer/web_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "cc/blink/web_layer_impl.h"
16 #include "cc/surfaces/surface_id.h"
15 #include "components/html_viewer/ax_provider_impl.h" 17 #include "components/html_viewer/ax_provider_impl.h"
16 #include "components/html_viewer/blink_basic_type_converters.h" 18 #include "components/html_viewer/blink_basic_type_converters.h"
17 #include "components/html_viewer/blink_input_events_type_converters.h" 19 #include "components/html_viewer/blink_input_events_type_converters.h"
18 #include "components/html_viewer/blink_text_input_type_converters.h" 20 #include "components/html_viewer/blink_text_input_type_converters.h"
19 #include "components/html_viewer/blink_url_request_type_converters.h" 21 #include "components/html_viewer/blink_url_request_type_converters.h"
20 #include "components/html_viewer/devtools_agent_impl.h" 22 #include "components/html_viewer/devtools_agent_impl.h"
21 #include "components/html_viewer/geolocation_client_impl.h" 23 #include "components/html_viewer/geolocation_client_impl.h"
22 #include "components/html_viewer/global_state.h" 24 #include "components/html_viewer/global_state.h"
23 #include "components/html_viewer/html_factory.h" 25 #include "components/html_viewer/html_factory.h"
24 #include "components/html_viewer/html_frame_delegate.h" 26 #include "components/html_viewer/html_frame_delegate.h"
25 #include "components/html_viewer/html_frame_properties.h" 27 #include "components/html_viewer/html_frame_properties.h"
26 #include "components/html_viewer/html_frame_tree_manager.h" 28 #include "components/html_viewer/html_frame_tree_manager.h"
27 #include "components/html_viewer/html_widget.h" 29 #include "components/html_viewer/html_widget.h"
28 #include "components/html_viewer/media_factory.h" 30 #include "components/html_viewer/media_factory.h"
29 #include "components/html_viewer/stats_collection_controller.h" 31 #include "components/html_viewer/stats_collection_controller.h"
30 #include "components/html_viewer/touch_handler.h" 32 #include "components/html_viewer/touch_handler.h"
31 #include "components/html_viewer/web_layer_impl.h"
32 #include "components/html_viewer/web_layer_tree_view_impl.h" 33 #include "components/html_viewer/web_layer_tree_view_impl.h"
33 #include "components/html_viewer/web_storage_namespace_impl.h" 34 #include "components/html_viewer/web_storage_namespace_impl.h"
34 #include "components/html_viewer/web_url_loader_impl.h" 35 #include "components/html_viewer/web_url_loader_impl.h"
35 #include "components/mus/ids.h" 36 #include "components/mus/ids.h"
36 #include "components/mus/public/cpp/scoped_view_ptr.h" 37 #include "components/mus/public/cpp/scoped_view_ptr.h"
37 #include "components/mus/public/cpp/view.h" 38 #include "components/mus/public/cpp/view.h"
38 #include "components/mus/public/cpp/view_tree_connection.h" 39 #include "components/mus/public/cpp/view_tree_connection.h"
39 #include "mojo/application/public/cpp/application_impl.h" 40 #include "mojo/application/public/cpp/application_impl.h"
40 #include "mojo/application/public/cpp/connect.h" 41 #include "mojo/application/public/cpp/connect.h"
41 #include "mojo/application/public/interfaces/shell.mojom.h" 42 #include "mojo/application/public/interfaces/shell.mojom.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 96 }
96 } 97 }
97 98
98 HTMLFrame* GetPreviousSibling(HTMLFrame* frame) { 99 HTMLFrame* GetPreviousSibling(HTMLFrame* frame) {
99 DCHECK(frame->parent()); 100 DCHECK(frame->parent());
100 auto iter = std::find(frame->parent()->children().begin(), 101 auto iter = std::find(frame->parent()->children().begin(),
101 frame->parent()->children().end(), frame); 102 frame->parent()->children().end(), frame);
102 return (iter == frame->parent()->children().begin()) ? nullptr : *(--iter); 103 return (iter == frame->parent()->children().begin()) ? nullptr : *(--iter);
103 } 104 }
104 105
106 // See surface_layer.h for a description of this callback.
107 void SatisfyCallback(cc::SurfaceSequence sequence) {
108 // TODO(fsamuel): Implement this.
109 }
110
111 // See surface_layer.h for a description of this callback.
112 void RequireCallback(cc::SurfaceId surface_id,
113 cc::SurfaceSequence sequence) {
114 // TODO(fsamuel): Implement this.
115 }
116
105 } // namespace 117 } // namespace
106 118
107 HTMLFrame::HTMLFrame(CreateParams* params) 119 HTMLFrame::HTMLFrame(CreateParams* params)
108 : frame_tree_manager_(params->manager), 120 : frame_tree_manager_(params->manager),
109 parent_(params->parent), 121 parent_(params->parent),
110 view_(nullptr), 122 view_(nullptr),
111 id_(params->id), 123 id_(params->id),
112 web_frame_(nullptr), 124 web_frame_(nullptr),
113 delegate_(params->delegate), 125 delegate_(params->delegate),
114 weak_factory_(this) { 126 weak_factory_(this) {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 572
561 HTMLFrameDelegate* delegate = delegate_; 573 HTMLFrameDelegate* delegate = delegate_;
562 delegate_ = nullptr; 574 delegate_ = nullptr;
563 575
564 blink::WebRemoteFrame* remote_frame = 576 blink::WebRemoteFrame* remote_frame =
565 blink::WebRemoteFrame::create(state_.tree_scope, this); 577 blink::WebRemoteFrame::create(state_.tree_scope, this);
566 remote_frame->initializeFromFrame(web_frame_->toWebLocalFrame()); 578 remote_frame->initializeFromFrame(web_frame_->toWebLocalFrame());
567 // swap() ends up calling us back and we then close the frame, which deletes 579 // swap() ends up calling us back and we then close the frame, which deletes
568 // it. 580 // it.
569 web_frame_->swap(remote_frame); 581 web_frame_->swap(remote_frame);
570 // TODO(sky): this isn't quite right, but WebLayerImpl is temporary.
571 if (owned_view_) { 582 if (owned_view_) {
572 web_layer_.reset( 583 surface_layer_ =
573 new WebLayerImpl(owned_view_->view(), 584 cc::SurfaceLayer::Create(cc_blink::WebLayerImpl::LayerSettings(),
574 global_state()->device_pixel_ratio())); 585 base::Bind(&SatisfyCallback),
586 base::Bind(&RequireCallback));
587 surface_layer_->SetSurfaceId(
588 cc::SurfaceId(owned_view_->view()->id()),
589 global_state()->device_pixel_ratio(),
590 owned_view_->view()->bounds().To<gfx::Rect>().size());
591
592 web_layer_.reset(new cc_blink::WebLayerImpl(surface_layer_));
575 } 593 }
576 remote_frame->setRemoteWebLayer(web_layer_.get()); 594 remote_frame->setRemoteWebLayer(web_layer_.get());
577 remote_frame->setReplicatedName(state_.name); 595 remote_frame->setReplicatedName(state_.name);
578 remote_frame->setReplicatedOrigin(state_.origin); 596 remote_frame->setReplicatedOrigin(state_.origin);
579 remote_frame->setReplicatedSandboxFlags(state_.sandbox_flags); 597 remote_frame->setReplicatedSandboxFlags(state_.sandbox_flags);
580 // Tell the frame that it is actually loading. This prevents its parent 598 // Tell the frame that it is actually loading. This prevents its parent
581 // from prematurely dispatching load event. 599 // from prematurely dispatching load event.
582 remote_frame->didStartLoading(); 600 remote_frame->didStartLoading();
583 web_frame_ = remote_frame; 601 web_frame_ = remote_frame;
584 SetView(nullptr); 602 SetView(nullptr);
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 mojo::URLRequestPtr url_request = mojo::URLRequest::From(request); 875 mojo::URLRequestPtr url_request = mojo::URLRequest::From(request);
858 GetServerFrame()->RequestNavigate( 876 GetServerFrame()->RequestNavigate(
859 web_view::mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME, id_, 877 web_view::mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME, id_,
860 url_request.Pass()); 878 url_request.Pass());
861 } 879 }
862 880
863 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) { 881 void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) {
864 NOTIMPLEMENTED(); 882 NOTIMPLEMENTED();
865 } 883 }
866 884
867 void HTMLFrame::forwardInputEvent(const blink::WebInputEvent* event) { 885 void HTMLFrame::frameRectsChanged(const blink::WebRect& frame_rect) {
868 NOTIMPLEMENTED(); 886 // Only the owner of view can update its size.
887 if (!owned_view_)
888 return;
889
890 const gfx::Rect rect_in_dip(frame_rect.x, frame_rect.y, frame_rect.width,
891 frame_rect.height);
892 const gfx::Rect rect_in_pixels(gfx::ConvertRectToPixel(
893 global_state()->device_pixel_ratio(), rect_in_dip));
894 const mojo::RectPtr mojo_rect_in_pixels(mojo::Rect::From(rect_in_pixels));
895 owned_view_->view()->SetBounds(*mojo_rect_in_pixels);
896
897 if (!surface_layer_)
898 return;
899
900 surface_layer_->SetSurfaceId(
901 cc::SurfaceId(owned_view_->view()->id()),
902 global_state()->device_pixel_ratio(),
903 owned_view_->view()->bounds().To<gfx::Rect>().size());
869 } 904 }
870 905
871 } // namespace mojo 906 } // namespace mojo
OLDNEW
« no previous file with comments | « components/html_viewer/html_frame.h ('k') | components/html_viewer/web_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698