RenderEmbeddedObject.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. #ifndef RenderEmbeddedObject_h
  23. #define RenderEmbeddedObject_h
  24. #include "RenderPart.h"
  25. namespace WebCore {
  26. class MouseEvent;
  27. class TextRun;
  28. // Renderer for embeds and objects, often, but not always, rendered via plug-ins.
  29. // For example, <embed src="foo.html"> does not invoke a plug-in.
  30. class RenderEmbeddedObject : public RenderPart {
  31. public:
  32. RenderEmbeddedObject(Element*);
  33. virtual ~RenderEmbeddedObject();
  34. enum PluginUnavailabilityReason {
  35. PluginMissing,
  36. PluginCrashed,
  37. PluginBlockedByContentSecurityPolicy,
  38. InsecurePluginVersion,
  39. };
  40. void setPluginUnavailabilityReason(PluginUnavailabilityReason);
  41. void setPluginUnavailabilityReasonWithDescription(PluginUnavailabilityReason, const String& description);
  42. bool isPluginUnavailable() const { return m_isPluginUnavailable; }
  43. bool showsUnavailablePluginIndicator() const { return isPluginUnavailable() && !m_isUnavailablePluginIndicatorHidden; }
  44. void setUnavailablePluginIndicatorIsHidden(bool);
  45. // FIXME: This belongs on HTMLObjectElement.
  46. bool hasFallbackContent() const { return m_hasFallbackContent; }
  47. void setHasFallbackContent(bool hasFallbackContent) { m_hasFallbackContent = hasFallbackContent; }
  48. void handleUnavailablePluginIndicatorEvent(Event*);
  49. bool isReplacementObscured() const;
  50. #if USE(ACCELERATED_COMPOSITING)
  51. virtual bool allowsAcceleratedCompositing() const;
  52. #endif
  53. protected:
  54. virtual void paintReplaced(PaintInfo&, const LayoutPoint&);
  55. virtual void paint(PaintInfo&, const LayoutPoint&);
  56. virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
  57. const RenderObjectChildList* children() const { return &m_children; }
  58. RenderObjectChildList* children() { return &m_children; }
  59. protected:
  60. virtual void layout() OVERRIDE;
  61. private:
  62. virtual const char* renderName() const { return "RenderEmbeddedObject"; }
  63. virtual bool isEmbeddedObject() const { return true; }
  64. void paintSnapshotImage(PaintInfo&, const LayoutPoint&, Image*);
  65. virtual void paintContents(PaintInfo&, const LayoutPoint&) OVERRIDE;
  66. #if USE(ACCELERATED_COMPOSITING)
  67. virtual bool requiresLayer() const;
  68. #endif
  69. virtual void viewCleared();
  70. virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
  71. virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier, Node** stopNode);
  72. virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier, Node** stopNode);
  73. void setUnavailablePluginIndicatorIsPressed(bool);
  74. bool isInUnavailablePluginIndicator(MouseEvent*) const;
  75. bool isInUnavailablePluginIndicator(const LayoutPoint&) const;
  76. bool getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, FloatRect& indicatorRect, FloatRect& replacementTextRect, FloatRect& arrowRect, Font&, TextRun&, float& textWidth) const;
  77. LayoutRect unavailablePluginIndicatorBounds(const LayoutPoint&) const;
  78. virtual bool canHaveChildren() const;
  79. virtual RenderObjectChildList* virtualChildren() { return children(); }
  80. virtual const RenderObjectChildList* virtualChildren() const { return children(); }
  81. virtual bool canHaveWidget() const { return true; }
  82. bool m_hasFallbackContent; // FIXME: This belongs on HTMLObjectElement.
  83. bool m_isPluginUnavailable;
  84. bool m_isUnavailablePluginIndicatorHidden;
  85. PluginUnavailabilityReason m_pluginUnavailabilityReason;
  86. String m_unavailablePluginReplacementText;
  87. bool m_unavailablePluginIndicatorIsPressed;
  88. bool m_mouseDownWasInUnavailablePluginIndicator;
  89. RenderObjectChildList m_children;
  90. String m_unavailabilityDescription;
  91. };
  92. inline RenderEmbeddedObject* toRenderEmbeddedObject(RenderObject* object)
  93. {
  94. ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isEmbeddedObject());
  95. return static_cast<RenderEmbeddedObject*>(object);
  96. }
  97. // This will catch anyone doing an unnecessary cast.
  98. void toRenderEmbeddedObject(const RenderEmbeddedObject*);
  99. } // namespace WebCore
  100. #endif // RenderEmbeddedObject_h