Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: Source/WebCore/rendering/RenderFrameBase.cpp

Issue 13877010: Remove frame flattening from rendering code. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Less overzealousness. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 20 matching lines...) Expand all
31 #include "HTMLFrameElementBase.h" 31 #include "HTMLFrameElementBase.h"
32 #include "RenderView.h" 32 #include "RenderView.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 RenderFrameBase::RenderFrameBase(Element* element) 36 RenderFrameBase::RenderFrameBase(Element* element)
37 : RenderPart(element) 37 : RenderPart(element)
38 { 38 {
39 } 39 }
40 40
41 inline bool shouldExpandFrame(LayoutUnit width, LayoutUnit height, bool hasFixed Width, bool hasFixedHeight)
42 {
43 // If the size computed to zero never expand.
44 if (!width || !height)
45 return false;
46 // Really small fixed size frames can't be meant to be scrolled and are ther e probably by mistake. Avoid expanding.
47 static unsigned smallestUsefullyScrollableDimension = 8;
48 if (hasFixedWidth && width < LayoutUnit(smallestUsefullyScrollableDimension) )
49 return false;
50 if (hasFixedHeight && height < LayoutUnit(smallestUsefullyScrollableDimensio n))
51 return false;
52 return true;
53 } 41 }
54
55 void RenderFrameBase::layoutWithFlattening(bool hasFixedWidth, bool hasFixedHeig ht)
56 {
57 FrameView* childFrameView = toFrameView(widget());
58 RenderView* childRoot = childFrameView ? childFrameView->frame()->contentRen derer() : 0;
59
60 if (!childRoot || !shouldExpandFrame(width(), height(), hasFixedWidth, hasFi xedHeight)) {
61 updateWidgetPosition();
62 if (childFrameView)
63 childFrameView->layout();
64 setNeedsLayout(false);
65 return;
66 }
67
68 // need to update to calculate min/max correctly
69 updateWidgetPosition();
70
71 // if scrollbars are off, and the width or height are fixed
72 // we obey them and do not expand. With frame flattening
73 // no subframe much ever become scrollable.
74
75 HTMLFrameElementBase* element = static_cast<HTMLFrameElementBase*>(node());
76 bool isScrollable = element->scrollingMode() != ScrollbarAlwaysOff;
77
78 // consider iframe inset border
79 int hBorder = borderLeft() + borderRight();
80 int vBorder = borderTop() + borderBottom();
81
82 // make sure minimum preferred width is enforced
83 if (isScrollable || !hasFixedWidth) {
84 setWidth(max(width(), childRoot->minPreferredLogicalWidth() + hBorder));
85 // update again to pass the new width to the child frame
86 updateWidgetPosition();
87 childFrameView->layout();
88 }
89
90 // expand the frame by setting frame height = content height
91 if (isScrollable || !hasFixedHeight || childRoot->isFrameSet())
92 setHeight(max<LayoutUnit>(height(), childFrameView->contentsHeight() + v Border));
93 if (isScrollable || !hasFixedWidth || childRoot->isFrameSet())
94 setWidth(max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBor der));
95
96 updateWidgetPosition();
97
98 ASSERT(!childFrameView->layoutPending());
99 ASSERT(!childRoot->needsLayout());
100 ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChild() || !childRoot->firstChild()->firstChild()->needsLayout());
101
102 setNeedsLayout(false);
103 }
104
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698