Home | History | Annotate | Download | only in frame
      1 /*
      2  * Copyright (C) 1998, 1999 Torben Weis <weis (at) kde.org>
      3  *                     1999-2001 Lars Knoll <knoll (at) kde.org>
      4  *                     1999-2001 Antti Koivisto <koivisto (at) kde.org>
      5  *                     2000-2001 Simon Hausmann <hausmann (at) kde.org>
      6  *                     2000-2001 Dirk Mueller <mueller (at) kde.org>
      7  *                     2000 Stefan Schimanski <1Stein (at) gmx.de>
      8  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
      9  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     10  * Copyright (C) 2008 Eric Seidel <eric (at) webkit.org>
     11  *
     12  * This library is free software; you can redistribute it and/or
     13  * modify it under the terms of the GNU Library General Public
     14  * License as published by the Free Software Foundation; either
     15  * version 2 of the License, or (at your option) any later version.
     16  *
     17  * This library is distributed in the hope that it will be useful,
     18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     20  * Library General Public License for more details.
     21  *
     22  * You should have received a copy of the GNU Library General Public License
     23  * along with this library; see the file COPYING.LIB.  If not, write to
     24  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     25  * Boston, MA 02110-1301, USA.
     26  */
     27 
     28 #ifndef Frame_h
     29 #define Frame_h
     30 
     31 #include "core/page/FrameTree.h"
     32 #include "platform/heap/Handle.h"
     33 #include "wtf/Forward.h"
     34 #include "wtf/RefCounted.h"
     35 
     36 namespace blink {
     37 
     38 class ChromeClient;
     39 class FrameClient;
     40 class FrameHost;
     41 class FrameOwner;
     42 class HTMLFrameOwnerElement;
     43 class LocalDOMWindow;
     44 class Page;
     45 class RenderPart;
     46 class Settings;
     47 class WebLayer;
     48 
     49 class Frame : public RefCountedWillBeGarbageCollectedFinalized<Frame> {
     50 public:
     51     virtual bool isLocalFrame() const { return false; }
     52     virtual bool isRemoteFrame() const { return false; }
     53 
     54     virtual ~Frame();
     55     virtual void trace(Visitor*);
     56 
     57     virtual void detach() = 0;
     58     void detachChildren();
     59 
     60     FrameClient* client() const;
     61     void clearClient();
     62 
     63     // NOTE: Page is moving out of Blink up into the browser process as
     64     // part of the site-isolation (out of process iframes) work.
     65     // FrameHost should be used instead where possible.
     66     Page* page() const;
     67     FrameHost* host() const; // Null when the frame is detached.
     68 
     69     bool isMainFrame() const;
     70     bool isLocalRoot() const;
     71 
     72     virtual void disconnectOwnerElement();
     73 
     74     FrameOwner* owner() const;
     75     HTMLFrameOwnerElement* deprecatedLocalOwner() const;
     76 
     77     // FIXME: LocalDOMWindow and Document should both be moved to LocalFrame
     78     // after RemoteFrame is complete enough to exist without them.
     79     virtual void setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow>);
     80     LocalDOMWindow* domWindow() const;
     81 
     82     FrameTree& tree() const;
     83     ChromeClient& chromeClient() const;
     84 
     85     RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
     86 
     87     // FIXME: These should move to RemoteFrame when that is instantiated.
     88     void setRemotePlatformLayer(WebLayer*);
     89     WebLayer* remotePlatformLayer() const { return m_remotePlatformLayer; }
     90 
     91     Settings* settings() const; // can be null
     92 
     93     // FIXME: This method identifies a LocalFrame that is acting as a RemoteFrame.
     94     // It is necessary only until we can instantiate a RemoteFrame, at which point
     95     // it can be removed and its callers can be converted to use the isRemoteFrame()
     96     // method.
     97     bool isRemoteFrameTemporary() const { return m_remotePlatformLayer; }
     98 
     99 protected:
    100     Frame(FrameClient*, FrameHost*, FrameOwner*);
    101 
    102     mutable FrameTree m_treeNode;
    103 
    104     RawPtrWillBeMember<FrameHost> m_host;
    105     RawPtrWillBeMember<FrameOwner> m_owner;
    106 
    107     RefPtrWillBeMember<LocalDOMWindow> m_domWindow;
    108 
    109 private:
    110     FrameClient* m_client;
    111     WebLayer* m_remotePlatformLayer;
    112 };
    113 
    114 inline FrameClient* Frame::client() const
    115 {
    116     return m_client;
    117 }
    118 
    119 inline void Frame::clearClient()
    120 {
    121     m_client = 0;
    122 }
    123 
    124 inline LocalDOMWindow* Frame::domWindow() const
    125 {
    126     return m_domWindow.get();
    127 }
    128 
    129 inline FrameOwner* Frame::owner() const
    130 {
    131     return m_owner;
    132 }
    133 
    134 inline FrameTree& Frame::tree() const
    135 {
    136     return m_treeNode;
    137 }
    138 
    139 // Allow equality comparisons of Frames by reference or pointer, interchangeably.
    140 DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES_REFCOUNTED(Frame)
    141 
    142 } // namespace blink
    143 
    144 #endif // Frame_h
    145