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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2674353003: Enable WebViewAccessiblityTest for OOPIF webview. (Closed)
Patch Set: Address alexmos final comments. Created 3 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 1567
1568 static_cast<RenderWidgetHostViewChildFrame*>( 1568 static_cast<RenderWidgetHostViewChildFrame*>(
1569 render_manager->GetRenderWidgetHostView()) 1569 render_manager->GetRenderWidgetHostView())
1570 ->RegisterFrameSinkId(); 1570 ->RegisterFrameSinkId();
1571 1571
1572 if (outer_web_contents_impl->frame_tree_.GetFocusedFrame() == 1572 if (outer_web_contents_impl->frame_tree_.GetFocusedFrame() ==
1573 outer_contents_frame_impl->frame_tree_node()) { 1573 outer_contents_frame_impl->frame_tree_node()) {
1574 SetFocusedFrame(frame_tree_.root(), nullptr); 1574 SetFocusedFrame(frame_tree_.root(), nullptr);
1575 } 1575 }
1576 1576
1577 // Set up the the guest's AX tree to point back at the embedder's AX tree.
1578 auto* parent_frame = outer_contents_frame->GetParent();
1579 GetMainFrame()->set_browser_plugin_embedder_ax_tree_id(
1580 parent_frame->GetAXTreeID());
1581 GetMainFrame()->UpdateAXTreeData();
1582
1577 // At this point, we should destroy the TextInputManager which will notify all 1583 // At this point, we should destroy the TextInputManager which will notify all
1578 // the RWHV in this WebContents. The RWHV in this WebContents should use the 1584 // the RWHV in this WebContents. The RWHV in this WebContents should use the
1579 // TextInputManager owned by the outer WebContents. 1585 // TextInputManager owned by the outer WebContents.
1580 // TODO(ekaramad): Is it possible to have TextInputState before attaching to 1586 // TODO(ekaramad): Is it possible to have TextInputState before attaching to
1581 // outer WebContents? In such a case, is this still the right way to hand off 1587 // outer WebContents? In such a case, is this still the right way to hand off
1582 // state tracking from inner WebContents's TextInputManager to that of the 1588 // state tracking from inner WebContents's TextInputManager to that of the
1583 // outer WebContent (crbug.com/609846)? 1589 // outer WebContent (crbug.com/609846)?
1584 text_input_manager_.reset(nullptr); 1590 text_input_manager_.reset(nullptr);
1585 } 1591 }
1586 1592
(...skipping 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after
4597 return false; 4603 return false;
4598 } 4604 }
4599 4605
4600 WebContentsImpl* WebContentsImpl::GetOutermostWebContents() { 4606 WebContentsImpl* WebContentsImpl::GetOutermostWebContents() {
4601 WebContentsImpl* root = this; 4607 WebContentsImpl* root = this;
4602 while (root->GetOuterWebContents()) 4608 while (root->GetOuterWebContents())
4603 root = root->GetOuterWebContents(); 4609 root = root->GetOuterWebContents();
4604 return root; 4610 return root;
4605 } 4611 }
4606 4612
4613 void WebContentsImpl::FocusOuterAttachmentFrameChain() {
4614 WebContentsImpl* outer_contents = GetOuterWebContents();
4615 if (!outer_contents)
4616 return;
4617
4618 FrameTreeNode* outer_node =
4619 FrameTreeNode::GloballyFindByID(GetOuterDelegateFrameTreeNodeId());
4620 outer_contents->frame_tree_.SetFocusedFrame(outer_node, nullptr);
4621
4622 // For a browser initiated focus change, let embedding renderer know of the
4623 // change. Otherwise, if the currently focused element is just across a
4624 // process boundry in focus order, it will not be possible to move across that
alexmos 2017/06/21 20:29:26 nit: s/boundry/boundary/
4625 // boundary. This is because the target element will already be focused (that
4626 // renderer was not notified) and drop the event.
4627 if (GetRenderManager()->GetProxyToOuterDelegate())
4628 GetRenderManager()->GetProxyToOuterDelegate()->SetFocusedFrame();
4629
4630 outer_contents->FocusOuterAttachmentFrameChain();
4631 }
4632
4607 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { 4633 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) {
4608 // Don't send notifications if we are just creating a swapped-out RVH for 4634 // Don't send notifications if we are just creating a swapped-out RVH for
4609 // the opener chain. These won't be used for view-source or WebUI, so it's 4635 // the opener chain. These won't be used for view-source or WebUI, so it's
4610 // ok to return early. 4636 // ok to return early.
4611 if (!static_cast<RenderViewHostImpl*>(render_view_host)->is_active()) 4637 if (!static_cast<RenderViewHostImpl*>(render_view_host)->is_active())
4612 return; 4638 return;
4613 4639
4614 if (delegate_) 4640 if (delegate_)
4615 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4641 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4616 4642
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
5007 return; 5033 return;
5008 5034
5009 // Send a page level blur to the old contents so that it displays inactive UI 5035 // Send a page level blur to the old contents so that it displays inactive UI
5010 // and focus this contents to activate it. 5036 // and focus this contents to activate it.
5011 if (old_contents) 5037 if (old_contents)
5012 old_contents->GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(false); 5038 old_contents->GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(false);
5013 5039
5014 // Make sure the outer web contents knows our frame is focused. Otherwise, the 5040 // Make sure the outer web contents knows our frame is focused. Otherwise, the
5015 // outer renderer could have the element before or after the frame element 5041 // outer renderer could have the element before or after the frame element
5016 // focused which would return early without actually advancing focus. 5042 // focused which would return early without actually advancing focus.
5017 if (GetRenderManager()->GetProxyToOuterDelegate()) 5043 FocusOuterAttachmentFrameChain();
5018 GetRenderManager()->GetProxyToOuterDelegate()->SetFocusedFrame();
5019 5044
5020 if (ShowingInterstitialPage()) { 5045 if (ShowingInterstitialPage()) {
5021 static_cast<RenderFrameHostImpl*>( 5046 static_cast<RenderFrameHostImpl*>(
5022 GetRenderManager()->interstitial_page()->GetMainFrame()) 5047 GetRenderManager()->interstitial_page()->GetMainFrame())
5023 ->GetRenderWidgetHost() 5048 ->GetRenderWidgetHost()
5024 ->SetPageFocus(true); 5049 ->SetPageFocus(true);
5025 } else { 5050 } else {
5026 GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(true); 5051 GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(true);
5027 } 5052 }
5028 } 5053 }
5029 5054
5030 void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node, 5055 void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node,
5031 SiteInstance* source) { 5056 SiteInstance* source) {
5032 SetAsFocusedWebContentsIfNecessary(); 5057 SetAsFocusedWebContentsIfNecessary();
5058
5033 frame_tree_.SetFocusedFrame(node, source); 5059 frame_tree_.SetFocusedFrame(node, source);
5060
5061 WebContentsImpl* inner_contents = node_.GetInnerWebContentsInFrame(node);
5062
5063 WebContentsImpl* contents_to_focus = inner_contents ? inner_contents : this;
5064 contents_to_focus->SetAsFocusedWebContentsIfNecessary();
5065 }
5066
5067 RenderFrameHost* WebContentsImpl::GetFocusedFrameIncludingInnerWebContents() {
5068 WebContentsImpl* contents = this;
5069 FrameTreeNode* focused_node = contents->frame_tree_.GetFocusedFrame();
5070
5071 // If there is no focused frame in the outer WebContents, we need to return
5072 // null.
5073 if (!focused_node)
5074 return nullptr;
5075
5076 // If the focused frame is embedding an inner WebContents, we must descend
5077 // into that contents. If the current WebContents does not have a focused
5078 // frame, return the main frame of this contents instead of the focused empty
5079 // frmae embedding this contents.
alexmos 2017/06/21 20:29:26 nit: s/frmae/frame/
5080 while (true) {
5081 contents = contents->node_.GetInnerWebContentsInFrame(focused_node);
5082 if (!contents)
5083 return focused_node->current_frame_host();
5084
5085 focused_node = contents->frame_tree_.GetFocusedFrame();
5086 if (!focused_node)
5087 return contents->GetMainFrame();
5088 }
5034 } 5089 }
5035 5090
5036 void WebContentsImpl::OnFocusedElementChangedInFrame( 5091 void WebContentsImpl::OnFocusedElementChangedInFrame(
5037 RenderFrameHostImpl* frame, 5092 RenderFrameHostImpl* frame,
5038 const gfx::Rect& bounds_in_root_view) { 5093 const gfx::Rect& bounds_in_root_view) {
5039 RenderWidgetHostViewBase* root_view = 5094 RenderWidgetHostViewBase* root_view =
5040 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); 5095 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView());
5041 if (!root_view || !frame->GetView()) 5096 if (!root_view || !frame->GetView())
5042 return; 5097 return;
5043 5098
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
5745 new_root->SetOriginalOpener(opener->frame_tree()->root()); 5800 new_root->SetOriginalOpener(opener->frame_tree()->root());
5746 5801
5747 if (!opener_suppressed) { 5802 if (!opener_suppressed) {
5748 new_root->SetOpener(opener); 5803 new_root->SetOpener(opener);
5749 created_with_opener_ = true; 5804 created_with_opener_ = true;
5750 } 5805 }
5751 } 5806 }
5752 } 5807 }
5753 5808
5754 } // namespace content 5809 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698