| OLD | NEW |
| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/rendering/RenderFrameBase.h" | 27 #include "core/rendering/RenderFrameBase.h" |
| 28 | 28 |
| 29 #include "core/html/HTMLFrameElementBase.h" | 29 #include "core/html/HTMLFrameElementBase.h" |
| 30 #include "core/page/Frame.h" | 30 #include "core/page/Frame.h" |
| 31 #include "core/page/FrameView.h" | 31 #include "core/page/FrameView.h" |
| 32 #include "core/rendering/RenderView.h" | 32 #include "core/rendering/RenderView.h" |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 // FIXME: Remove this file. http://crbug.com/231898 |
| 37 |
| 36 RenderFrameBase::RenderFrameBase(Element* element) | 38 RenderFrameBase::RenderFrameBase(Element* element) |
| 37 : RenderPart(element) | 39 : RenderPart(element) |
| 38 { | 40 { |
| 39 } | 41 } |
| 40 | 42 |
| 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 } | 43 } |
| 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 } | |
| OLD | NEW |