| 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 19 matching lines...) Expand all Loading... |
| 30 #include "FrameView.h" | 30 #include "FrameView.h" |
| 31 #include "HTMLIFrameElement.h" | 31 #include "HTMLIFrameElement.h" |
| 32 #include "HTMLNames.h" | 32 #include "HTMLNames.h" |
| 33 #include "Page.h" | 33 #include "Page.h" |
| 34 #include "RenderView.h" | 34 #include "RenderView.h" |
| 35 #include "Settings.h" | 35 #include "Settings.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 using namespace HTMLNames; | 39 using namespace HTMLNames; |
| 40 | 40 |
| 41 RenderIFrame::RenderIFrame(Element* element) | 41 RenderIFrame::RenderIFrame(Element* element) |
| 42 : RenderFrameBase(element) | 42 : RenderPart(element) |
| 43 { | 43 { |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool RenderIFrame::shouldComputeSizeAsReplaced() const | 46 bool RenderIFrame::shouldComputeSizeAsReplaced() const |
| 47 { | 47 { |
| 48 // When we're seamless, we use normal block/box sizing code except when inli
ne. | 48 // When we're seamless, we use normal block/box sizing code except when inli
ne. |
| 49 return !isSeamless(); | 49 return !isSeamless(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool RenderIFrame::isInlineBlockOrInlineTable() const | 52 bool RenderIFrame::isInlineBlockOrInlineTable() const |
| 53 { | 53 { |
| 54 return isSeamless() && isInline(); | 54 return isSeamless() && isInline(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 LayoutUnit RenderIFrame::minPreferredLogicalWidth() const | 57 LayoutUnit RenderIFrame::minPreferredLogicalWidth() const |
| 58 { | 58 { |
| 59 if (!isSeamless()) | 59 if (!isSeamless()) |
| 60 return RenderFrameBase::minPreferredLogicalWidth(); | 60 return RenderPart::minPreferredLogicalWidth(); |
| 61 | 61 |
| 62 RenderView* childRoot = contentRootRenderer(); | 62 RenderView* childRoot = contentRootRenderer(); |
| 63 if (!childRoot) | 63 if (!childRoot) |
| 64 return 0; | 64 return 0; |
| 65 | 65 |
| 66 return childRoot->minPreferredLogicalWidth() + borderAndPaddingLogicalWidth(
); | 66 return childRoot->minPreferredLogicalWidth() + borderAndPaddingLogicalWidth(
); |
| 67 } | 67 } |
| 68 | 68 |
| 69 LayoutUnit RenderIFrame::maxPreferredLogicalWidth() const | 69 LayoutUnit RenderIFrame::maxPreferredLogicalWidth() const |
| 70 { | 70 { |
| 71 if (!isSeamless()) | 71 if (!isSeamless()) |
| 72 return RenderFrameBase::maxPreferredLogicalWidth(); | 72 return RenderPart::maxPreferredLogicalWidth(); |
| 73 | 73 |
| 74 RenderView* childRoot = contentRootRenderer(); | 74 RenderView* childRoot = contentRootRenderer(); |
| 75 if (!childRoot) | 75 if (!childRoot) |
| 76 return 0; | 76 return 0; |
| 77 | 77 |
| 78 return childRoot->maxPreferredLogicalWidth() + borderAndPaddingLogicalWidth(
); | 78 return childRoot->maxPreferredLogicalWidth() + borderAndPaddingLogicalWidth(
); |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool RenderIFrame::isSeamless() const | 81 bool RenderIFrame::isSeamless() const |
| 82 { | 82 { |
| 83 return node() && node()->hasTagName(iframeTag) && static_cast<HTMLIFrameElem
ent*>(node())->shouldDisplaySeamlessly(); | 83 return node() && node()->hasTagName(iframeTag) && static_cast<HTMLIFrameElem
ent*>(node())->shouldDisplaySeamlessly(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool RenderIFrame::requiresLayer() const | 86 bool RenderIFrame::requiresLayer() const |
| 87 { | 87 { |
| 88 return RenderFrameBase::requiresLayer() || style()->resize() != RESIZE_NONE; | 88 return RenderPart::requiresLayer() || style()->resize() != RESIZE_NONE; |
| 89 } | 89 } |
| 90 | 90 |
| 91 RenderView* RenderIFrame::contentRootRenderer() const | 91 RenderView* RenderIFrame::contentRootRenderer() const |
| 92 { | 92 { |
| 93 // FIXME: Is this always a valid cast? What about plugins? | 93 // FIXME: Is this always a valid cast? What about plugins? |
| 94 ASSERT(!widget() || widget()->isFrameView()); | 94 ASSERT(!widget() || widget()->isFrameView()); |
| 95 FrameView* childFrameView = toFrameView(widget()); | 95 FrameView* childFrameView = toFrameView(widget()); |
| 96 return childFrameView ? childFrameView->frame()->contentRenderer() : 0; | 96 return childFrameView ? childFrameView->frame()->contentRenderer() : 0; |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool RenderIFrame::flattenFrame() const | |
| 100 { | |
| 101 if (!node() || !node()->hasTagName(iframeTag)) | |
| 102 return false; | |
| 103 | |
| 104 HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node()); | |
| 105 Frame* frame = element->document()->frame(); | |
| 106 | |
| 107 if (isSeamless()) | |
| 108 return false; // Seamless iframes are already "flat", don't try to flatt
en them. | |
| 109 | |
| 110 bool enabled = frame && frame->settings() && frame->settings()->frameFlatten
ingEnabled(); | |
| 111 | |
| 112 if (!enabled || !frame->page()) | |
| 113 return false; | |
| 114 | |
| 115 if (style()->width().isFixed() && style()->height().isFixed()) { | |
| 116 // Do not flatten iframes with scrolling="no". | |
| 117 if (element->scrollingMode() == ScrollbarAlwaysOff) | |
| 118 return false; | |
| 119 if (style()->width().value() <= 0 || style()->height().value() <= 0) | |
| 120 return false; | |
| 121 } | |
| 122 | |
| 123 // Do not flatten offscreen inner frames during frame flattening, as flatten
ing might make them visible. | |
| 124 IntRect boundingRect = absoluteBoundingBoxRectIgnoringTransforms(); | |
| 125 return boundingRect.maxX() > 0 && boundingRect.maxY() > 0; | |
| 126 } | |
| 127 | |
| 128 void RenderIFrame::layoutSeamlessly() | 99 void RenderIFrame::layoutSeamlessly() |
| 129 { | 100 { |
| 130 updateLogicalWidth(); | 101 updateLogicalWidth(); |
| 131 // FIXME: Containers set their height to 0 before laying out their kids (as
we're doing here) | 102 // FIXME: Containers set their height to 0 before laying out their kids (as
we're doing here) |
| 132 // however, this causes FrameView::layout() to add vertical scrollbars, inco
rrectly inflating | 103 // however, this causes FrameView::layout() to add vertical scrollbars, inco
rrectly inflating |
| 133 // the resulting contentHeight(). We'll need to make FrameView::layout() sma
rter. | 104 // the resulting contentHeight(). We'll need to make FrameView::layout() sma
rter. |
| 134 setLogicalHeight(0); | 105 setLogicalHeight(0); |
| 135 updateWidgetPosition(); // Tell the Widget about our new width/height (it wi
ll also layout the child document). | 106 updateWidgetPosition(); // Tell the Widget about our new width/height (it wi
ll also layout the child document). |
| 136 | 107 |
| 137 // Laying out our kids is normally responsible for adjusting our height, so
we set it here. | 108 // Laying out our kids is normally responsible for adjusting our height, so
we set it here. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 155 StackStats::LayoutCheckPoint layoutCheckPoint; | 126 StackStats::LayoutCheckPoint layoutCheckPoint; |
| 156 ASSERT(needsLayout()); | 127 ASSERT(needsLayout()); |
| 157 | 128 |
| 158 if (isSeamless()) { | 129 if (isSeamless()) { |
| 159 layoutSeamlessly(); | 130 layoutSeamlessly(); |
| 160 // Do not return so as to share the layer and overflow updates below. | 131 // Do not return so as to share the layer and overflow updates below. |
| 161 } else { | 132 } else { |
| 162 updateLogicalWidth(); | 133 updateLogicalWidth(); |
| 163 // No kids to layout as a replaced element. | 134 // No kids to layout as a replaced element. |
| 164 updateLogicalHeight(); | 135 updateLogicalHeight(); |
| 165 | |
| 166 if (flattenFrame()) | |
| 167 layoutWithFlattening(style()->width().isFixed(), style()->height().i
sFixed()); | |
| 168 } | 136 } |
| 169 | 137 |
| 170 m_overflow.clear(); | 138 m_overflow.clear(); |
| 171 addVisualEffectOverflow(); | 139 addVisualEffectOverflow(); |
| 172 updateLayerTransform(); | 140 updateLayerTransform(); |
| 173 | 141 |
| 174 setNeedsLayout(false); | 142 setNeedsLayout(false); |
| 175 } | 143 } |
| 176 | 144 |
| 177 } | 145 } |
| OLD | NEW |