• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3  *           (C) 2000 Simon Hausmann <hausmann@kde.org>
4  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5  * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 #include "config.h"
25 #include "RenderFrame.h"
26 
27 #include "FrameView.h"
28 #include "HTMLFrameElement.h"
29 
30 #ifdef FLATTEN_FRAMESET
31 #include "Frame.h"
32 #include "Document.h"
33 #include "RenderView.h"
34 #endif
35 
36 namespace WebCore {
37 
RenderFrame(HTMLFrameElement * frame)38 RenderFrame::RenderFrame(HTMLFrameElement* frame)
39     : RenderPart(frame)
40 {
41     setInline(false);
42 }
43 
edgeInfo() const44 FrameEdgeInfo RenderFrame::edgeInfo() const
45 {
46     HTMLFrameElement* element = static_cast<HTMLFrameElement*>(node());
47     return FrameEdgeInfo(element->noResize(), element->hasFrameBorder());
48 }
49 
viewCleared()50 void RenderFrame::viewCleared()
51 {
52     HTMLFrameElement* element = static_cast<HTMLFrameElement*>(node());
53     if (!element || !widget() || !widget()->isFrameView())
54         return;
55 
56     FrameView* view = static_cast<FrameView*>(widget());
57 
58     int marginw = element->getMarginWidth();
59     int marginh = element->getMarginHeight();
60 
61     if (marginw != -1)
62         view->setMarginWidth(marginw);
63     if (marginh != -1)
64         view->setMarginHeight(marginh);
65 }
66 
67 #ifdef FLATTEN_FRAMESET
layout()68 void RenderFrame::layout()
69 {
70     if (widget() && widget()->isFrameView()) {
71         FrameView* view = static_cast<FrameView*>(widget());
72         RenderView* root = NULL;
73         if (view->frame() && view->frame()->document() &&
74             view->frame()->document()->renderer() &&
75             view->frame()->document()->renderer()->isRenderView())
76             root = static_cast<RenderView*>(view->frame()->document()->renderer());
77         if (root) {
78             // Resize the widget so that the RenderView will layout according to those dimensions.
79             view->resize(width(), height());
80             view->layout();
81             // We can only grow in width and height because if positionFrames gives us a width and we become smaller,
82             // then the fixup process of forcing the frame to fill extra space will fail.
83             if (width() > root->docWidth()) {
84                 view->resize(root->docWidth(), 0);
85                 view->layout();
86             }
87             // Honor the height set by RenderFrameSet::positionFrames unless our document height is larger.
88             setHeight(max(root->docHeight(), height()));
89             setWidth(max(root->docWidth(), width()));
90         }
91     }
92     setNeedsLayout(false);
93 }
94 #endif
95 
96 } // namespace WebCore
97