Region ScrollingCoordinator::computeNonFastScrollableRegion(const Frame* frame, const IntPoint& frameLocation) const { #if ENABLE(IOS_TOUCH_EVENTS) // On iOS, we use nonFastScrollableRegion to represent the region covered by elements with touch event handlers. ASSERT(frame->isMainFrame()); UNUSED_PARAM(frameLocation); Document* document = frame->document(); if (!document) return Region(); Vector<IntRect> touchRects; document->getTouchRects(touchRects); Region touchRegion; for (const auto& rect : touchRects) touchRegion.unite(rect); return touchRegion; #else Region nonFastScrollableRegion; FrameView* frameView = frame->view(); if (!frameView) return nonFastScrollableRegion; IntPoint offset = frameLocation; offset.moveBy(frameView->frameRect().location()); offset.move(0, frameView->topContentInset()); if (const FrameView::ScrollableAreaSet* scrollableAreas = frameView->scrollableAreas()) { for (FrameView::ScrollableAreaSet::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) { ScrollableArea* scrollableArea = *it; // Composited scrollable areas can be scrolled off the main thread. if (scrollableArea->usesCompositedScrolling()) continue; IntRect box = scrollableArea->scrollableAreaBoundingBox(); box.moveBy(offset); nonFastScrollableRegion.unite(box); } } for (const auto& child : frameView->children()) { if (!child->isPluginViewBase()) continue; PluginViewBase* pluginViewBase = toPluginViewBase(child.get()); if (pluginViewBase->wantsWheelEvents()) nonFastScrollableRegion.unite(pluginViewBase->frameRect()); } for (Frame* subframe = frame->tree().firstChild(); subframe; subframe = subframe->tree().nextSibling()) nonFastScrollableRegion.unite(computeNonFastScrollableRegion(subframe, offset)); return nonFastScrollableRegion; #endif }
bool HTMLPlugInElement::isKeyboardFocusable(KeyboardEvent*) const { // FIXME: Why is this check needed? if (!document().page()) return false; Widget* widget = pluginWidget(); if (!widget || !widget->isPluginViewBase()) return false; return toPluginViewBase(widget)->supportsKeyboardFocus(); }
void HTMLPlugInImageElement::subframeLoaderDidCreatePlugIn(const Widget* widget) { m_plugInWasCreated = true; if (widget->isPluginViewBase() && toPluginViewBase(widget)->shouldAlwaysAutoStart()) { LOG(Plugins, "%p Plug-in should auto-start, set to play", this); m_snapshotDecision = NeverSnapshot; setDisplayState(Playing); return; } if (m_deferredPromotionToPrimaryPlugIn) { LOG(Plugins, "%p Plug-in was created, previously deferred promotion to primary. Will promote", this); setIsPrimarySnapshottedPlugIn(true); m_deferredPromotionToPrimaryPlugIn = false; } }
void Page::collectPluginViews(Vector<RefPtr<PluginViewBase>, 32>& pluginViewBases) { for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) { FrameView* view = frame->view(); if (!view) return; const HashSet<RefPtr<Widget> >* children = view->children(); ASSERT(children); HashSet<RefPtr<Widget> >::const_iterator end = children->end(); for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) { Widget* widget = (*it).get(); if (widget->isPluginViewBase()) pluginViewBases.append(toPluginViewBase(widget)); } } }
PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widget) { ASSERT(widget); if (!widget->isPluginViewBase()) return 0; NPObject* npObject = toPluginViewBase(widget)->scriptableObject(); if (!npObject) return 0; // Frame Memory Management for NPObjects // ------------------------------------- // NPObjects are treated differently than other objects wrapped by JS. // NPObjects can be created either by the browser (e.g. the main // window object) or by the plugin (the main plugin object // for a HTMLEmbedElement). Further, unlike most DOM Objects, the frame // is especially careful to ensure NPObjects terminate at frame teardown because // if a plugin leaks a reference, it could leak its objects (or the browser's objects). // // The Frame maintains a list of plugin objects (m_pluginObjects) // which it can use to quickly find the wrapped embed object. // // Inside the NPRuntime, we've added a few methods for registering // wrapped NPObjects. The purpose of the registration is because // javascript garbage collection is non-deterministic, yet we need to // be able to tear down the plugin objects immediately. When an object // is registered, javascript can use it. When the object is destroyed, // or when the object's "owning" object is destroyed, the object will // be un-registered, and the javascript engine must not use it. // // Inside the javascript engine, the engine can keep a reference to the // NPObject as part of its wrapper. However, before accessing the object // it must consult the _NPN_Registry. v8::Local<v8::Object> wrapper = createV8ObjectForNPObject(npObject, 0); // Track the plugin object. We've been given a reference to the object. m_pluginObjects.set(widget, npObject); return V8ScriptInstance::create(wrapper); }
void HTMLPlugInImageElement::checkSizeChangeForSnapshotting() { if (!m_needsCheckForSizeChange || m_snapshotDecision != MaySnapshotWhenResized || documentHadRecentUserGesture(document())) return; m_needsCheckForSizeChange = false; LayoutRect contentBoxRect = toRenderBox(renderer())->contentBoxRect(); int contentWidth = contentBoxRect.width(); int contentHeight = contentBoxRect.height(); if (contentWidth <= sizingTinyDimensionThreshold || contentHeight <= sizingTinyDimensionThreshold) return; LOG(Plugins, "%p Plug-in originally avoided snapshotting because it was sized %dx%d. Now it is %dx%d. Tell it to snapshot.\n", this, m_sizeWhenSnapshotted.width(), m_sizeWhenSnapshotted.height(), contentWidth, contentHeight); setDisplayState(WaitingForSnapshot); m_snapshotDecision = Snapshotted; Widget* widget = pluginWidget(); if (widget && widget->isPluginViewBase()) toPluginViewBase(widget)->beginSnapshottingRunningPlugin(); }
bool RenderPart::requiresAcceleratedCompositing() const { // There are two general cases in which we can return true. First, if this is a plugin // renderer and the plugin has a layer, then we need a layer. Second, if this is // a renderer with a contentDocument and that document needs a layer, then we need // a layer. if (widget() && widget()->isPluginViewBase() && toPluginViewBase(widget())->platformLayer()) return true; if (!node() || !node()->isFrameOwnerElement()) return false; HTMLFrameOwnerElement* element = toFrameOwnerElement(node()); if (Document* contentDocument = element->contentDocument()) { if (RenderView* view = contentDocument->renderView()) return view->usesCompositing(); } return false; }
Region ScrollingCoordinator::computeNonFastScrollableRegion(const Frame* frame, const IntPoint& frameLocation) const { Region nonFastScrollableRegion; FrameView* frameView = frame->view(); if (!frameView) return nonFastScrollableRegion; IntPoint offset = frameLocation; offset.moveBy(frameView->frameRect().location()); if (const FrameView::ScrollableAreaSet* scrollableAreas = frameView->scrollableAreas()) { for (FrameView::ScrollableAreaSet::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) { ScrollableArea* scrollableArea = *it; #if USE(ACCELERATED_COMPOSITING) // Composited scrollable areas can be scrolled off the main thread. if (scrollableArea->usesCompositedScrolling()) continue; #endif IntRect box = scrollableArea->scrollableAreaBoundingBox(); box.moveBy(offset); nonFastScrollableRegion.unite(box); } } if (const HashSet<RefPtr<Widget> >* children = frameView->children()) { for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(), end = children->end(); it != end; ++it) { if (!(*it)->isPluginViewBase()) continue; PluginViewBase* pluginViewBase = toPluginViewBase((*it).get()); if (pluginViewBase->wantsWheelEvents()) nonFastScrollableRegion.unite(pluginViewBase->frameRect()); } } FrameTree* tree = frame->tree(); for (Frame* subFrame = tree->firstChild(); subFrame; subFrame = subFrame->tree()->nextSibling()) nonFastScrollableRegion.unite(computeNonFastScrollableRegion(subFrame, offset)); return nonFastScrollableRegion; }