1/* 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * (C) 2000 Simon Hausmann <hausmann@kde.org> 4 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 * 21 */ 22 23#ifndef RenderEmbeddedObject_h 24#define RenderEmbeddedObject_h 25 26#include "RenderPart.h" 27 28namespace WebCore { 29 30class MouseEvent; 31class TextRun; 32 33// Renderer for embeds and objects, often, but not always, rendered via plug-ins. 34// For example, <embed src="foo.html"> does not invoke a plug-in. 35class RenderEmbeddedObject : public RenderPart { 36public: 37 RenderEmbeddedObject(Element*); 38 virtual ~RenderEmbeddedObject(); 39 40 enum PluginUnavailabilityReason { 41 PluginMissing, 42 PluginCrashed, 43 PluginBlockedByContentSecurityPolicy, 44 InsecurePluginVersion, 45 }; 46 void setPluginUnavailabilityReason(PluginUnavailabilityReason); 47 void setPluginUnavailabilityReasonWithDescription(PluginUnavailabilityReason, const String& description); 48 49 bool isPluginUnavailable() const { return m_isPluginUnavailable; } 50 bool showsUnavailablePluginIndicator() const { return isPluginUnavailable() && !m_isUnavailablePluginIndicatorHidden; } 51 52 void setUnavailablePluginIndicatorIsHidden(bool); 53 54 // FIXME: This belongs on HTMLObjectElement. 55 bool hasFallbackContent() const { return m_hasFallbackContent; } 56 void setHasFallbackContent(bool hasFallbackContent) { m_hasFallbackContent = hasFallbackContent; } 57 58 void handleUnavailablePluginIndicatorEvent(Event*); 59 60 bool isReplacementObscured() const; 61 62#if USE(ACCELERATED_COMPOSITING) 63 virtual bool allowsAcceleratedCompositing() const; 64#endif 65 66protected: 67 virtual void paintReplaced(PaintInfo&, const LayoutPoint&); 68 virtual void paint(PaintInfo&, const LayoutPoint&); 69 70 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const; 71 72 const RenderObjectChildList* children() const { return &m_children; } 73 RenderObjectChildList* children() { return &m_children; } 74 75protected: 76 virtual void layout() OVERRIDE; 77 78private: 79 virtual const char* renderName() const { return "RenderEmbeddedObject"; } 80 virtual bool isEmbeddedObject() const { return true; } 81 82 void paintSnapshotImage(PaintInfo&, const LayoutPoint&, Image*); 83 virtual void paintContents(PaintInfo&, const LayoutPoint&) OVERRIDE; 84 85#if USE(ACCELERATED_COMPOSITING) 86 virtual bool requiresLayer() const; 87#endif 88 89 virtual void viewCleared(); 90 91 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE; 92 93 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier, Node** stopNode); 94 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier, Node** stopNode); 95 96 void setUnavailablePluginIndicatorIsPressed(bool); 97 bool isInUnavailablePluginIndicator(MouseEvent*) const; 98 bool isInUnavailablePluginIndicator(const LayoutPoint&) const; 99 bool getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, FloatRect& indicatorRect, FloatRect& replacementTextRect, FloatRect& arrowRect, Font&, TextRun&, float& textWidth) const; 100 LayoutRect unavailablePluginIndicatorBounds(const LayoutPoint&) const; 101 102 virtual bool canHaveChildren() const; 103 virtual RenderObjectChildList* virtualChildren() { return children(); } 104 virtual const RenderObjectChildList* virtualChildren() const { return children(); } 105 106 virtual bool canHaveWidget() const { return true; } 107 108 bool m_hasFallbackContent; // FIXME: This belongs on HTMLObjectElement. 109 110 bool m_isPluginUnavailable; 111 bool m_isUnavailablePluginIndicatorHidden; 112 PluginUnavailabilityReason m_pluginUnavailabilityReason; 113 String m_unavailablePluginReplacementText; 114 bool m_unavailablePluginIndicatorIsPressed; 115 bool m_mouseDownWasInUnavailablePluginIndicator; 116 RenderObjectChildList m_children; 117 String m_unavailabilityDescription; 118}; 119 120inline RenderEmbeddedObject* toRenderEmbeddedObject(RenderObject* object) 121{ 122 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isEmbeddedObject()); 123 return static_cast<RenderEmbeddedObject*>(object); 124} 125 126// This will catch anyone doing an unnecessary cast. 127void toRenderEmbeddedObject(const RenderEmbeddedObject*); 128 129} // namespace WebCore 130 131#endif // RenderEmbeddedObject_h 132