 Chromium Code Reviews
 Chromium Code Reviews Issue 799633007:
  Make Windows accessibility event firing aware of guest / child frames.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@webview_fixes
    
  
    Issue 799633007:
  Make Windows accessibility event firing aware of guest / child frames.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@webview_fixes| OLD | NEW | 
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame_host/frame_accessibility.h" | 5 #include "content/browser/frame_host/frame_accessibility.h" | 
| 6 | 6 | 
| 7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" | 
| 8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" | 
| 9 #include "content/browser/frame_host/render_frame_host_delegate.h" | 9 #include "content/browser/frame_host/render_frame_host_delegate.h" | 
| 10 #include "content/browser/frame_host/render_frame_host_impl.h" | 10 #include "content/browser/frame_host/render_frame_host_impl.h" | 
| 11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" | 
| 12 | 12 | 
| 13 namespace content { | 13 namespace content { | 
| 14 | 14 | 
| 15 // static | 15 // static | 
| 16 FrameAccessibility* FrameAccessibility::GetInstance() { | 16 FrameAccessibility* FrameAccessibility::GetInstance() { | 
| 17 return Singleton<FrameAccessibility>::get(); | 17 return Singleton<FrameAccessibility>::get(); | 
| 18 } | 18 } | 
| 19 | 19 | 
| 20 FrameAccessibility::ChildFrameMapping::ChildFrameMapping() | 20 FrameAccessibility::ChildFrameMapping::ChildFrameMapping() | 
| 21 : parent_frame_host(NULL), | 21 : parent_frame_host(nullptr), | 
| 22 accessibility_node_id(0), | 22 accessibility_node_id(0), | 
| 23 child_frame_tree_node_id(0), | 23 child_frame_tree_node_id(0), | 
| 24 browser_plugin_instance_id(0) {} | 24 browser_plugin_instance_id(0) {} | 
| 25 | 25 | 
| 26 FrameAccessibility::FrameAccessibility() {} | 26 FrameAccessibility::FrameAccessibility() {} | 
| 27 | 27 | 
| 28 FrameAccessibility::~FrameAccessibility() {} | 28 FrameAccessibility::~FrameAccessibility() {} | 
| 29 | 29 | 
| 30 void FrameAccessibility::AddChildFrame( | 30 void FrameAccessibility::AddChildFrame( | 
| 31 RenderFrameHostImpl* parent_frame_host, | 31 RenderFrameHostImpl* parent_frame_host, | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 int accessibility_node_id) { | 98 int accessibility_node_id) { | 
| 99 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | 99 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | 
| 100 iter != mappings_.end(); | 100 iter != mappings_.end(); | 
| 101 ++iter) { | 101 ++iter) { | 
| 102 if (iter->parent_frame_host != parent_frame_host || | 102 if (iter->parent_frame_host != parent_frame_host || | 
| 103 iter->accessibility_node_id != accessibility_node_id) { | 103 iter->accessibility_node_id != accessibility_node_id) { | 
| 104 continue; | 104 continue; | 
| 105 } | 105 } | 
| 106 | 106 | 
| 107 if (iter->child_frame_tree_node_id) { | 107 if (iter->child_frame_tree_node_id) { | 
| 108 FrameTreeNode* child_node = | 108 return GetRFHIFromFrameTreeNodeId( | 
| 109 FrameTree::GloballyFindByID(iter->child_frame_tree_node_id); | 109 parent_frame_host, iter->child_frame_tree_node_id); | 
| 110 if (!child_node) | |
| 111 return NULL; | |
| 112 | |
| 113 // We should have gotten a node in the same frame tree. | |
| 114 if (child_node->frame_tree() != | |
| 115 parent_frame_host->frame_tree_node()->frame_tree()) { | |
| 116 NOTREACHED(); | |
| 117 return NULL; | |
| 118 } | |
| 119 | |
| 120 return child_node->current_frame_host(); | |
| 121 } | 110 } | 
| 122 | 111 | 
| 123 if (iter->browser_plugin_instance_id) { | 112 if (iter->browser_plugin_instance_id) { | 
| 124 RenderFrameHost* guest = | 113 RenderFrameHost* guest = | 
| 125 parent_frame_host->delegate()->GetGuestByInstanceID( | 114 parent_frame_host->delegate()->GetGuestByInstanceID( | 
| 126 iter->browser_plugin_instance_id); | 115 iter->browser_plugin_instance_id); | 
| 127 if (guest) | 116 if (guest) | 
| 128 return static_cast<RenderFrameHostImpl*>(guest); | 117 return static_cast<RenderFrameHostImpl*>(guest); | 
| 129 } | 118 } | 
| 130 } | 119 } | 
| 131 | 120 | 
| 132 return NULL; | 121 return nullptr; | 
| 122 } | |
| 123 | |
| 124 void FrameAccessibility::GetAllChildFrames( | |
| 125 RenderFrameHostImpl* parent_frame_host, | |
| 126 std::vector<RenderFrameHostImpl*>* child_frame_hosts) { | |
| 127 CHECK(child_frame_hosts); | |
| 128 | |
| 129 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | |
| 130 iter != mappings_.end(); | |
| 131 ++iter) { | |
| 132 if (iter->parent_frame_host != parent_frame_host) | |
| 133 continue; | |
| 134 | |
| 135 if (iter->child_frame_tree_node_id) { | |
| 136 RenderFrameHostImpl* child_frame_host = GetRFHIFromFrameTreeNodeId( | |
| 137 parent_frame_host, iter->child_frame_tree_node_id); | |
| 138 if (child_frame_host) | |
| 139 child_frame_hosts->push_back(child_frame_host); | |
| 140 } | |
| 141 | |
| 142 if (iter->browser_plugin_instance_id) { | |
| 143 RenderFrameHost* guest = | |
| 144 parent_frame_host->delegate()->GetGuestByInstanceID( | |
| 145 iter->browser_plugin_instance_id); | |
| 146 if (guest) | |
| 147 child_frame_hosts->push_back(static_cast<RenderFrameHostImpl*>(guest)); | |
| 148 } | |
| 149 } | |
| 133 } | 150 } | 
| 134 | 151 | 
| 135 bool FrameAccessibility::GetParent( | 152 bool FrameAccessibility::GetParent( | 
| 136 RenderFrameHostImpl* child_frame_host, | 153 RenderFrameHostImpl* child_frame_host, | 
| 137 RenderFrameHostImpl** out_parent_frame_host, | 154 RenderFrameHostImpl** out_parent_frame_host, | 
| 138 int* out_accessibility_node_id) { | 155 int* out_accessibility_node_id) { | 
| 139 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | 156 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | 
| 140 iter != mappings_.end(); | 157 iter != mappings_.end(); | 
| 141 ++iter) { | 158 ++iter) { | 
| 142 if (iter->child_frame_tree_node_id) { | 159 if (iter->child_frame_tree_node_id) { | 
| 143 FrameTreeNode* child_node = | 160 FrameTreeNode* child_node = | 
| 144 FrameTree::GloballyFindByID(iter->child_frame_tree_node_id); | 161 FrameTree::GloballyFindByID(iter->child_frame_tree_node_id); | 
| 145 if (child_node && | 162 if (child_node && | 
| 146 child_node->current_frame_host() == child_frame_host) { | 163 child_node->current_frame_host() == child_frame_host) { | 
| 147 // We should have gotten a node in the same frame tree. | 164 // We should have gotten a node in the same frame tree. | 
| 
nasko
2015/01/16 00:20:33
Isn't this test now redundant if the two nodes sha
 
dmazzoni
2015/01/16 17:44:55
Done.
 | |
| 148 if (child_node->frame_tree() != | 165 if (child_node->frame_tree() != | 
| 149 iter->parent_frame_host->frame_tree_node()->frame_tree()) { | 166 iter->parent_frame_host->frame_tree_node()->frame_tree()) { | 
| 150 NOTREACHED(); | 167 NOTREACHED(); | 
| 151 return false; | 168 return false; | 
| 152 } | 169 } | 
| 153 | 170 | 
| 171 // We should have gotten a *direct* child of the parent frame. | |
| 172 if (child_node->parent() != | |
| 173 iter->parent_frame_host->frame_tree_node()) { | |
| 174 NOTREACHED(); | |
| 175 return false; | |
| 176 } | |
| 177 | |
| 154 if (out_parent_frame_host) | 178 if (out_parent_frame_host) | 
| 155 *out_parent_frame_host = iter->parent_frame_host; | 179 *out_parent_frame_host = iter->parent_frame_host; | 
| 156 if (out_accessibility_node_id) | 180 if (out_accessibility_node_id) | 
| 157 *out_accessibility_node_id = iter->accessibility_node_id; | 181 *out_accessibility_node_id = iter->accessibility_node_id; | 
| 158 return true; | 182 return true; | 
| 159 } | 183 } | 
| 160 } | 184 } | 
| 161 | 185 | 
| 162 if (iter->browser_plugin_instance_id) { | 186 if (iter->browser_plugin_instance_id) { | 
| 163 RenderFrameHost* guest = | 187 RenderFrameHost* guest = | 
| 164 iter->parent_frame_host->delegate()->GetGuestByInstanceID( | 188 iter->parent_frame_host->delegate()->GetGuestByInstanceID( | 
| 165 iter->browser_plugin_instance_id); | 189 iter->browser_plugin_instance_id); | 
| 166 if (guest == child_frame_host) { | 190 if (guest == child_frame_host) { | 
| 167 if (out_parent_frame_host) | 191 if (out_parent_frame_host) | 
| 168 *out_parent_frame_host = iter->parent_frame_host; | 192 *out_parent_frame_host = iter->parent_frame_host; | 
| 169 if (out_accessibility_node_id) | 193 if (out_accessibility_node_id) | 
| 170 *out_accessibility_node_id = iter->accessibility_node_id; | 194 *out_accessibility_node_id = iter->accessibility_node_id; | 
| 171 return true; | 195 return true; | 
| 172 } | 196 } | 
| 173 } | 197 } | 
| 174 } | 198 } | 
| 175 | 199 | 
| 176 return false; | 200 return false; | 
| 177 } | 201 } | 
| 178 | 202 | 
| 203 RenderFrameHostImpl* FrameAccessibility::GetRFHIFromFrameTreeNodeId( | |
| 204 RenderFrameHostImpl* parent_frame_host, | |
| 205 int64 child_frame_tree_node_id) { | |
| 206 FrameTreeNode* child_node = | |
| 207 FrameTree::GloballyFindByID(child_frame_tree_node_id); | |
| 208 if (!child_node) | |
| 209 return nullptr; | |
| 210 | |
| 211 // We should have gotten a node in the same frame tree. | |
| 212 if (child_node->frame_tree() != | |
| 213 parent_frame_host->frame_tree_node()->frame_tree()) { | |
| 214 NOTREACHED(); | |
| 215 return nullptr; | |
| 216 } | |
| 217 | |
| 218 return child_node->current_frame_host(); | |
| 219 } | |
| 220 | |
| 179 } // namespace content | 221 } // namespace content | 
| OLD | NEW |