Commit 508a9397 authored by kenneth@webkit.org's avatar kenneth@webkit.org

iframe flattening doesn't flatten

https://bugs.webkit.org/show_bug.cgi?id=36798

Reviewed by Dave Hyatt.

Fixed to the iframe flattening code so that the iframes on
http://www.samisite.com/test-csb2nf/id43.htm are actually
flattened.

Covered by current tests.

* page/FrameView.cpp: Propagate contents changes of iframes
and subframes in framesets to the parent so that it is relayouted
(WebCore::FrameView::setContentsSize):
(WebCore::FrameView::adjustViewSize):
(WebCore::FrameView::scheduleRelayout):
* rendering/RenderPart.cpp: HTMLIFrameElement do not inherit from
HTMLFrameElement, but HTMLFrameElementBase, correct cast. Correct
the use of inset border values. Avoid a sometimes unnecessary
relayout.
(WebCore::RenderPart::layoutWithFlattening):
* rendering/RenderPartObject.cpp: Make the calcHeight and calcWidth
return the right values, considering scrolling and fixed width/height
(WebCore::RenderPartObject::flattenFrame):
(WebCore::RenderPartObject::calcHeight):
(WebCore::RenderPartObject::calcWidth):
(WebCore::RenderPartObject::layout):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@57080 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent eaf6bfb1
2010-04-01 Kenneth Rohde Christiansen <kenneth@webkit.org>
Reviewed by Dave Hyatt.
iframe flattening doesn't flatten
https://bugs.webkit.org/show_bug.cgi?id=36798
Fixed to the iframe flattening code so that the iframes on
http://www.samisite.com/test-csb2nf/id43.htm are actually
flattened.
Covered by current tests.
* page/FrameView.cpp: Propagate contents changes of iframes
and subframes in framesets to the parent so that it is relayouted
(WebCore::FrameView::setContentsSize):
(WebCore::FrameView::adjustViewSize):
(WebCore::FrameView::scheduleRelayout):
* rendering/RenderPart.cpp: HTMLIFrameElement do not inherit from
HTMLFrameElement, but HTMLFrameElementBase, correct cast. Correct
the use of inset border values. Avoid a sometimes unnecessary
relayout.
(WebCore::RenderPart::layoutWithFlattening):
* rendering/RenderPartObject.cpp: Make the calcHeight and calcWidth
return the right values, considering scrolling and fixed width/height
(WebCore::RenderPartObject::flattenFrame):
(WebCore::RenderPartObject::calcHeight):
(WebCore::RenderPartObject::calcWidth):
(WebCore::RenderPartObject::layout):
2010-04-05 Vitaly Repeshko <vitalyr@chromium.org>
Reviewed by Yury Semikhatsky.
......@@ -397,7 +397,7 @@ void FrameView::setContentsSize(const IntSize& size)
return;
page->chrome()->contentsSizeChanged(frame(), size); //notify only
m_deferSetNeedsLayouts--;
if (!m_deferSetNeedsLayouts)
......@@ -410,6 +410,7 @@ void FrameView::adjustViewSize()
RenderView* root = m_frame->contentRenderer();
if (!root)
return;
setContentsSize(IntSize(root->rightLayoutOverflow(), root->bottomLayoutOverflow()));
}
......@@ -1275,10 +1276,12 @@ void FrameView::scheduleRelayout()
if (!m_frame->document()->shouldScheduleLayout())
return;
// When frameset flattening is enabled, the contents of the frame affects layout of the parent frames.
// When frame flattening is enabled, the contents of the frame affects layout of the parent frames.
// Also invalidate parent frame starting from the owner element of this frame.
if (m_frame->settings()->frameFlatteningEnabled() && m_frame->ownerRenderer() && m_frame->ownerElement()->hasTagName(frameTag))
m_frame->ownerRenderer()->setNeedsLayout(true, true);
if (m_frame->settings()->frameFlatteningEnabled() && m_frame->ownerRenderer()) {
if (m_frame->ownerElement()->hasTagName(iframeTag) || m_frame->ownerElement()->hasTagName(frameTag))
m_frame->ownerRenderer()->setNeedsLayout(true, true);
}
int delay = m_frame->document()->minimumLayoutDelay();
if (m_layoutTimer.isActive() && m_delayedLayout && !delay)
......
......@@ -27,7 +27,7 @@
#include "RenderView.h"
#include "Frame.h"
#include "FrameView.h"
#include "HTMLFrameElement.h"
#include "HTMLFrameElementBase.h"
namespace WebCore {
......@@ -60,7 +60,6 @@ void RenderPart::layoutWithFlattening(bool fixedWidth, bool fixedHeight)
{
FrameView* childFrameView = static_cast<FrameView*>(widget());
RenderView* childRoot = childFrameView ? static_cast<RenderView*>(childFrameView->frame()->contentRenderer()) : 0;
HTMLFrameElement* element = static_cast<HTMLFrameElement*>(node());
// Do not expand frames which has zero width or height
if (!width() || !height() || !childRoot) {
......@@ -80,25 +79,26 @@ void RenderPart::layoutWithFlattening(bool fixedWidth, bool fixedHeight)
// we obey them and do not expand. With frame flattening
// no subframe much ever become scrollable.
HTMLFrameElementBase* element = static_cast<HTMLFrameElementBase*>(node());
bool isScrollable = element->scrollingMode() != ScrollbarAlwaysOff;
// make sure minimum preferred width is enforced
if (isScrollable || !fixedWidth)
setWidth(max(width(), childRoot->minPrefWidth()));
// consider iframe inset border
int hBorder = borderLeft() + borderRight();
int vBorder = borderTop() + borderBottom();
// update again to pass the width to the child frame
updateWidgetPosition();
childFrameView->layout();
// make sure minimum preferred width is enforced
if (isScrollable || !fixedWidth) {
setWidth(max(width(), childRoot->minPrefWidth() + hBorder));
// update again to pass the new width to the child frame
updateWidgetPosition();
childFrameView->layout();
}
// expand the frame by setting frame height = content height
if (isScrollable || !fixedHeight || childRoot->isFrameSet())
setHeight(max(height(), childFrameView->contentsHeight()));
setHeight(max(height(), childFrameView->contentsHeight() + vBorder));
if (isScrollable || !fixedWidth || childRoot->isFrameSet())
setWidth(max(width(), childFrameView->contentsWidth()));
// make room for the inset border
setWidth(width() + borderLeft() + borderRight());
setHeight(height() + borderTop() + borderBottom());
setWidth(max(width(), childFrameView->contentsWidth() + hBorder));
updateWidgetPosition();
......
......@@ -56,37 +56,54 @@ bool RenderPartObject::flattenFrame() const
if (!node() || !node()->hasTagName(iframeTag))
return false;
HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node());
HTMLIFrameElement* frame = static_cast<HTMLIFrameElement*>(node());
bool isScrollable = frame->scrollingMode() != ScrollbarAlwaysOff;
if (element->scrollingMode() == ScrollbarAlwaysOff
&& style()->width().isFixed()
if (!isScrollable && style()->width().isFixed()
&& style()->height().isFixed())
return false;
Document* document = element ? element->document() : 0;
return document->frame() && document->frame()->settings()->frameFlatteningEnabled();
return frame->document()->frame() && frame->document()->frame()->settings()->frameFlatteningEnabled();
}
void RenderPartObject::calcHeight()
{
RenderPart::calcHeight();
if (flattenFrame())
setHeight(max(height(), static_cast<FrameView*>(widget())->contentsHeight()));
if (!flattenFrame())
return;
HTMLIFrameElement* frame = static_cast<HTMLIFrameElement*>(node());
bool isScrollable = frame->scrollingMode() != ScrollbarAlwaysOff;
if (isScrollable || !style()->height().isFixed()) {
FrameView* view = static_cast<FrameView*>(widget());
int border = borderTop() + borderBottom();
setHeight(max(height(), view->contentsHeight() + border));
}
}
void RenderPartObject::calcWidth()
{
RenderPart::calcWidth();
if (flattenFrame())
setWidth(max(width(), static_cast<FrameView*>(widget())->contentsWidth()));
if (!flattenFrame())
return;
HTMLIFrameElement* frame = static_cast<HTMLIFrameElement*>(node());
bool isScrollable = frame->scrollingMode() != ScrollbarAlwaysOff;
if (isScrollable || !style()->width().isFixed()) {
FrameView* view = static_cast<FrameView*>(widget());
int border = borderLeft() + borderRight();
setWidth(max(width(), view->contentsWidth() + border));
}
}
void RenderPartObject::layout()
{
ASSERT(needsLayout());
calcWidth();
calcHeight();
RenderPart::calcWidth();
RenderPart::calcHeight();
if (flattenFrame()) {
layoutWithFlattening(style()->width().isFixed(), style()->height().isFixed());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment