• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * This file is part of the KDE project.
3  *
4  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5  *           (C) 2000 Simon Hausmann <hausmann@kde.org>
6  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de)
7  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public License
20  * along with this library; see the file COPYING.LIB.  If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  */
25 
26 #include "config.h"
27 #include "RenderFrame.h"
28 #include "RenderFrameSet.h"
29 #include "FrameView.h"
30 #include "HTMLFrameSetElement.h"
31 #include "HTMLNames.h"
32 
33 #ifdef FLATTEN_FRAMESET
34 #include "Frame.h"
35 #include "Document.h"
36 #include "RenderView.h"
37 #endif
38 
39 namespace WebCore {
40 
41 using namespace HTMLNames;
42 
RenderFrame(HTMLFrameElement * frame)43 RenderFrame::RenderFrame(HTMLFrameElement* frame)
44     : RenderPart(frame)
45 {
46     setInline(false);
47 }
48 
edgeInfo() const49 FrameEdgeInfo RenderFrame::edgeInfo() const
50 {
51     return FrameEdgeInfo(element()->noResize(), element()->hasFrameBorder());
52 }
53 
viewCleared()54 void RenderFrame::viewCleared()
55 {
56     if (element() && m_widget && m_widget->isFrameView()) {
57         FrameView* view = static_cast<FrameView*>(m_widget);
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 
68 #ifdef FLATTEN_FRAMESET
layout()69 void RenderFrame::layout()
70 {
71     if (m_widget && m_widget->isFrameView()) {
72         FrameView* view = static_cast<FrameView*>(m_widget);
73         RenderView* root = NULL;
74         if (view->frame() && view->frame()->document() &&
75             view->frame()->document()->renderer() && 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