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

Side by Side Diff: third_party/WebKit/Source/modules/plugins/PluginOcclusionSupport.cpp

Issue 2845583002: Remove FrameViewBase as base class of RemoteFrameView. (Closed)
Patch Set: fix scrollbar inactive Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 element = element->ParentOrShadowHostElement(); 147 element = element->ParentOrShadowHostElement();
148 return element; 148 return element;
149 } 149 }
150 150
151 // Return a set of rectangles that should not be overdrawn by the 151 // Return a set of rectangles that should not be overdrawn by the
152 // plugin ("cutouts"). This helps implement the "iframe shim" 152 // plugin ("cutouts"). This helps implement the "iframe shim"
153 // technique of overlaying a windowed plugin with content from the 153 // technique of overlaying a windowed plugin with content from the
154 // page. In a nutshell, iframe elements should occlude plugins when 154 // page. In a nutshell, iframe elements should occlude plugins when
155 // they occur higher in the stacking order. 155 // they occur higher in the stacking order.
156 void GetPluginOcclusions(Element* element, 156 void GetPluginOcclusions(Element* element,
157 FrameViewBase* parent, 157 FrameView* parent,
158 const IntRect& frame_rect, 158 const IntRect& frame_rect,
159 Vector<IntRect>& occlusions) { 159 Vector<IntRect>& occlusions) {
160 LayoutObject* plugin_node = element->GetLayoutObject(); 160 LayoutObject* plugin_node = element->GetLayoutObject();
161 ASSERT(plugin_node); 161 ASSERT(plugin_node);
162 if (!plugin_node->Style()) 162 if (!plugin_node->Style())
163 return; 163 return;
164 Vector<const LayoutObject*> plugin_zstack; 164 Vector<const LayoutObject*> plugin_zstack;
165 Vector<const LayoutObject*> iframe_zstack; 165 Vector<const LayoutObject*> iframe_zstack;
166 GetObjectStack(plugin_node, &plugin_zstack); 166 GetObjectStack(plugin_node, &plugin_zstack);
167 167
168 if (!parent->IsFrameView())
169 return;
170
171 FrameView* parent_frame_view = ToFrameView(parent);
172
173 // Occlusions by iframes. 168 // Occlusions by iframes.
174 const FrameView::ChildrenSet* children = parent_frame_view->Children(); 169 for (const auto& child : parent->Children()) {
175 for (FrameView::ChildrenSet::const_iterator it = children->begin(); 170 if (!child->IsFrameView())
176 it != children->end(); ++it) {
177 // We only care about FrameView's because iframes show up as FrameViews.
178 if (!(*it)->IsFrameView())
179 continue; 171 continue;
180 172
181 const FrameView* frame_view = ToFrameView(it->Get()); 173 const FrameView* frame_view = ToFrameView(child);
182 // Check to make sure we can get both the element and the LayoutObject 174 // Check to make sure we can get both the element and the LayoutObject
183 // for this FrameView, if we can't just move on to the next object. 175 // for this FrameView, if we can't just move on to the next object.
184 // FIXME: Plugin occlusion by remote frames is probably broken. 176 // FIXME: Plugin occlusion by remote frames is probably broken.
185 HTMLElement* element = frame_view->GetFrame().DeprecatedLocalOwner(); 177 HTMLElement* element = frame_view->GetFrame().DeprecatedLocalOwner();
186 if (!element || !element->GetLayoutObject()) 178 if (!element || !element->GetLayoutObject())
187 continue; 179 continue;
188 180
189 LayoutObject* iframe_renderer = element->GetLayoutObject(); 181 LayoutObject* iframe_renderer = element->GetLayoutObject();
190 182
191 if (isHTMLIFrameElement(*element) && 183 if (isHTMLIFrameElement(*element) &&
192 IntersectsRect(iframe_renderer, frame_rect)) { 184 IntersectsRect(iframe_renderer, frame_rect)) {
193 GetObjectStack(iframe_renderer, &iframe_zstack); 185 GetObjectStack(iframe_renderer, &iframe_zstack);
194 if (IframeIsAbovePlugin(iframe_zstack, plugin_zstack)) 186 if (IframeIsAbovePlugin(iframe_zstack, plugin_zstack))
195 AddToOcclusions(ToLayoutBox(iframe_renderer), occlusions); 187 AddToOcclusions(ToLayoutBox(iframe_renderer), occlusions);
196 } 188 }
197 } 189 }
198 190
199 // Occlusions by top layer elements. 191 // Occlusions by top layer elements.
200 // FIXME: There's no handling yet for the interaction between top layer and 192 // FIXME: There's no handling yet for the interaction between top layer and
201 // iframes. For example, a plugin in the top layer will be occluded by an 193 // iframes. For example, a plugin in the top layer will be occluded by an
202 // iframe. And a plugin inside an iframe in the top layer won't be respected 194 // iframe. And a plugin inside an iframe in the top layer won't be respected
203 // as being in the top layer. 195 // as being in the top layer.
204 const Element* ancestor = TopLayerAncestor(element); 196 const Element* ancestor = TopLayerAncestor(element);
205 Document* document = parent_frame_view->GetFrame().GetDocument(); 197 Document* document = parent->GetFrame().GetDocument();
206 const HeapVector<Member<Element>>& elements = document->TopLayerElements(); 198 const HeapVector<Member<Element>>& elements = document->TopLayerElements();
207 size_t start = ancestor ? elements.Find(ancestor) + 1 : 0; 199 size_t start = ancestor ? elements.Find(ancestor) + 1 : 0;
208 for (size_t i = start; i < elements.size(); ++i) 200 for (size_t i = start; i < elements.size(); ++i)
209 AddTreeToOcclusions(elements[i]->GetLayoutObject(), frame_rect, occlusions); 201 AddTreeToOcclusions(elements[i]->GetLayoutObject(), frame_rect, occlusions);
210 } 202 }
211 203
212 } // namespace blink 204 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698