Home | History | Annotate | Download | only in html
      1 /*
      2  * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org)
      3  *           (C) 1999 Antti Koivisto (koivisto (at) kde.org)
      4  * Copyright (C) 2004, 2006, 2007, 2008, 2009, 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 HTMLPlugInElement_h
     24 #define HTMLPlugInElement_h
     25 
     26 #include "core/html/HTMLFrameOwnerElement.h"
     27 
     28 #include "bindings/v8/ScriptInstance.h"
     29 
     30 struct NPObject;
     31 
     32 namespace WebCore {
     33 
     34 class RenderEmbeddedObject;
     35 class RenderWidget;
     36 class Widget;
     37 
     38 class HTMLPlugInElement : public HTMLFrameOwnerElement {
     39 public:
     40     virtual ~HTMLPlugInElement();
     41 
     42     void resetInstance();
     43 
     44     PassScriptInstance getInstance();
     45 
     46     Widget* pluginWidget() const;
     47 
     48     enum DisplayState {
     49         Restarting,
     50         RestartingWithPendingMouseClick,
     51         Playing
     52     };
     53     DisplayState displayState() const { return m_displayState; }
     54     virtual void setDisplayState(DisplayState state) { m_displayState = state; }
     55 
     56     NPObject* getNPObject();
     57 
     58     bool isCapturingMouseEvents() const { return m_isCapturingMouseEvents; }
     59     void setIsCapturingMouseEvents(bool capturing) { m_isCapturingMouseEvents = capturing; }
     60 
     61     bool canContainRangeEndPoint() const { return false; }
     62 
     63     bool canProcessDrag() const;
     64 
     65     virtual bool willRespondToMouseClickEvents() OVERRIDE;
     66 
     67     virtual bool isPlugInImageElement() const { return false; }
     68 
     69 protected:
     70     HTMLPlugInElement(const QualifiedName& tagName, Document*);
     71 
     72     virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
     73     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     74     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
     75 
     76     virtual bool useFallbackContent() const { return false; }
     77 
     78     virtual bool dispatchBeforeLoadEvent(const String& sourceURL) OVERRIDE;
     79 
     80 private:
     81     virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
     82 
     83     virtual void defaultEventHandler(Event*);
     84 
     85     virtual RenderWidget* renderWidgetForJSBindings() const = 0;
     86 
     87     virtual bool supportsFocus() const OVERRIDE { return true; };
     88     virtual bool rendererIsFocusable() const OVERRIDE;
     89 
     90     virtual bool isKeyboardFocusable() const OVERRIDE;
     91     virtual bool isPluginElement() const;
     92 
     93     mutable ScriptInstance m_instance;
     94     NPObject* m_NPObject;
     95     bool m_isCapturingMouseEvents;
     96     bool m_inBeforeLoadEventHandler;
     97     DisplayState m_displayState;
     98 };
     99 
    100 inline HTMLPlugInElement* toHTMLPlugInElement(Node* node)
    101 {
    102     ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isPluginElement());
    103     return static_cast<HTMLPlugInElement*>(node);
    104 }
    105 
    106 inline const HTMLPlugInElement* toHTMLPlugInElement(const Node* node)
    107 {
    108     ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isPluginElement());
    109     return static_cast<const HTMLPlugInElement*>(node);
    110 }
    111 
    112 // This will catch anyone doing an unnecessary cast.
    113 void toHTMLPlugInElement(const HTMLPlugInElement*);
    114 
    115 } // namespace WebCore
    116 
    117 #endif // HTMLPlugInElement_h
    118