void RenderPartObject::layout() { ASSERT(needsLayout()); ASSERT(minMaxKnown()); FrameView* childFrameView = static_cast<FrameView*>(m_widget); RenderView* childRoot = 0; bool flatten = m_widget && element()->hasTagName(iframeTag) && element() && element()->document()->frame() && element()->document()->frame()->settings()->flatFrameSetLayoutEnabled() && (static_cast<HTMLIFrameElement*>(element())->scrollingMode() != ScrollBarAlwaysOff || !style()->width().isFixed() || !style()->height().isFixed()) && (childRoot = childFrameView ? static_cast<RenderView*>(childFrameView->frame()->renderer()) : 0); if (flatten) { if (!childRoot->minMaxKnown()) childRoot->calcMinMaxWidth(); calcWidth(); calcHeight(); bool scrolling = static_cast<HTMLIFrameElement*>(element())->scrollingMode() != ScrollBarAlwaysOff; if (scrolling || !style()->width().isFixed()) m_width = max(m_width, childRoot->minWidth()); updateWidgetPosition(); do childFrameView->layout(); while (childFrameView->layoutPending() || childRoot->needsLayout()); if (scrolling || !style()->height().isFixed()) m_height = max(m_height, childFrameView->contentsHeight()); if (scrolling || !style()->width().isFixed()) m_width = max(m_width, childFrameView->contentsWidth()); updateWidgetPosition(); ASSERT(!childFrameView->layoutPending()); ASSERT(!childRoot->needsLayout()); ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChild() || !childRoot->firstChild()->firstChild()->needsLayout()); } else { calcWidth(); calcHeight(); RenderPart::layout(); } setNeedsLayout(false); }
void RenderFrameBase::layoutWithFlattening(bool fixedWidth, bool fixedHeight) { FrameView* childFrameView = static_cast<FrameView*>(widget()); RenderView* childRoot = childFrameView ? static_cast<RenderView*>(childFrameView->frame()->contentRenderer()) : 0; // Do not expand frames which has zero width or height if (!width() || !height() || !childRoot) { updateWidgetPosition(); if (childFrameView) childFrameView->layout(); setNeedsLayout(false); return; } // need to update to calculate min/max correctly updateWidgetPosition(); if (childRoot->preferredLogicalWidthsDirty()) childRoot->computePreferredLogicalWidths(); // if scrollbars are off, and the width or height are fixed // 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; // consider iframe inset border int hBorder = borderLeft() + borderRight(); int vBorder = borderTop() + borderBottom(); // make sure minimum preferred width is enforced if (isScrollable || !fixedWidth) { setWidth(max(width(), childRoot->minPreferredLogicalWidth() + 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() + vBorder)); if (isScrollable || !fixedWidth || childRoot->isFrameSet()) setWidth(max(width(), childFrameView->contentsWidth() + hBorder)); updateWidgetPosition(); ASSERT(!childFrameView->layoutPending()); ASSERT(!childRoot->needsLayout()); ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChild() || !childRoot->firstChild()->firstChild()->needsLayout()); setNeedsLayout(false); }
/** * dumpRenderTree: * @frame: a #WebKitWebFrame * * Return value: Non-recursive render tree dump of @frame */ CString DumpRenderTreeSupportGtk::dumpRenderTree(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), CString("")); Frame* coreFrame = core(frame); if (!coreFrame) return CString(""); FrameView* view = coreFrame->view(); if (view && view->layoutPending()) view->layout(); return externalRepresentation(coreFrame).utf8(); }
void RenderFrameBase::layoutWithFlattening(bool hasFixedWidth, bool hasFixedHeight) { FrameView* childFrameView = toFrameView(widget()); RenderView* childRoot = childFrameView ? childFrameView->frame().contentRenderer() : 0; if (!childRoot || !shouldExpandFrame(width(), height(), hasFixedWidth, hasFixedHeight)) { updateWidgetPosition(); if (childFrameView) childFrameView->layout(); clearNeedsLayout(); return; } // need to update to calculate min/max correctly updateWidgetPosition(); // if scrollbars are off, and the width or height are fixed // we obey them and do not expand. With frame flattening // no subframe much ever become scrollable. bool isScrollable = frameOwnerElement().scrollingMode() != ScrollbarAlwaysOff; // consider iframe inset border int hBorder = borderLeft() + borderRight(); int vBorder = borderTop() + borderBottom(); // make sure minimum preferred width is enforced if (isScrollable || !hasFixedWidth) { setWidth(std::max(width(), childRoot->minPreferredLogicalWidth() + 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 || !hasFixedHeight || childRoot->isFrameSet()) setHeight(std::max<LayoutUnit>(height(), childFrameView->contentsHeight() + vBorder)); if (isScrollable || !hasFixedWidth || childRoot->isFrameSet()) setWidth(std::max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBorder)); updateWidgetPosition(); ASSERT(!childFrameView->layoutPending()); ASSERT(!childRoot->needsLayout()); ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChildSlow() || !childRoot->firstChild()->firstChildSlow()->needsLayout()); clearNeedsLayout(); }
/** * webkit_web_frame_dump_render_tree: * @frame: a #WebKitWebFrame * * Return value: Non-recursive render tree dump of @frame */ gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); if (!coreFrame) return g_strdup(""); FrameView* view = coreFrame->view(); if (view && view->layoutPending()) view->layout(); String string = externalRepresentation(coreFrame->contentRenderer()); return g_strdup(string.utf8().data()); }
/** * getInnerText: * @frame: a #WebKitWebFrame * * Return value: inner text of @frame */ CString DumpRenderTreeSupportGtk::getInnerText(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), CString("")); Frame* coreFrame = core(frame); if (!coreFrame) return CString(""); FrameView* view = coreFrame->view(); if (view && view->layoutPending()) view->layout(); Element* documentElement = coreFrame->document()->documentElement(); return documentElement->innerText().utf8(); }
/** * webkit_web_frame_get_inner_text: * @frame: a #WebKitWebFrame * * Return value: inner text of @frame */ gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); ASSERT(coreFrame); FrameView* view = coreFrame->view(); if (view && view->layoutPending()) view->layout(); Element* documentElement = coreFrame->document()->documentElement(); String string = documentElement->innerText(); return g_strdup(string.utf8().data()); }
void RenderIFrame::layoutSeamlessly() { updateLogicalWidth(); // FIXME: Containers set their height to 0 before laying out their kids (as we're doing here) // however, this causes FrameView::layout() to add vertical scrollbars, incorrectly inflating // the resulting contentHeight(). We'll need to make FrameView::layout() smarter. setLogicalHeight(0); updateWidgetPosition(); // Tell the Widget about our new width/height (it will also layout the child document). // Laying out our kids is normally responsible for adjusting our height, so we set it here. // Replaced elements normally do not respect padding, but seamless elements should: we'll add // both padding and border to the child's logical height here. FrameView* childFrameView = toFrameView(widget()); if (childFrameView) // Widget should never be null during layout(), but just in case. setLogicalHeight(childFrameView->contentsHeight() + borderTop() + borderBottom() + paddingTop() + paddingBottom()); updateLogicalHeight(); updateWidgetPosition(); // Notify the Widget of our final height. // Assert that the child document did a complete layout. RenderView* childRoot = childFrameView ? childFrameView->frame()->contentRenderer() : 0; ASSERT(!childFrameView || !childFrameView->layoutPending()); ASSERT_UNUSED(childRoot, !childRoot || !childRoot->needsLayout()); }
void RenderPartObject::layout() { ASSERT(needsLayout()); #ifdef FLATTEN_IFRAME RenderPart::calcWidth(); RenderPart::calcHeight(); // Calculate the styled dimensions by subtracting the border and padding. int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight(); int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom(); int styleWidth = width() - extraWidth; int styleHeight = height() - extraHeight; // Some IFrames have a width and/or height of 1 when they are meant to be // hidden. If that is the case, do not try to expand. if (node()->hasTagName(iframeTag) && widget() && widget()->isFrameView() && styleWidth > 1 && styleHeight > 1) { HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node()); bool scrolling = element->scrollingMode() != ScrollbarAlwaysOff; bool widthIsFixed = style()->width().isFixed(); bool heightIsFixed = style()->height().isFixed(); // If an iframe has a fixed dimension and suppresses scrollbars, it // will disrupt layout if we force it to expand. Plus on a desktop, // the extra content is not accessible. if (scrolling || !widthIsFixed || !heightIsFixed) { FrameView* view = static_cast<FrameView*>(widget()); RenderView* root = view ? view->frame()->contentRenderer() : NULL; if (root && style()->visibility() != HIDDEN) { // Update the dimensions to get the correct minimum preferred // width updateWidgetPosition(); // Use the preferred width if it is larger and only if // scrollbars are visible or the width style is not fixed. if (scrolling || !widthIsFixed) setWidth(max(width(), root->minPrefWidth()) + extraWidth); // Resize the view to recalc the height. int h = height() - extraHeight; int w = width() - extraWidth; if (w > view->width()) h = 0; if (w != view->width() || h != view->height()) { view->resize(w, h); } // Layout the view. //SAMSUNG CHANGE >> // Browser freeze issue in http://www.enuri.com/ /* do { view->layout(); } while (view->layoutPending() || root->needsLayout()); */ node()->document()->page()->mainFrame()->view()->layoutIfNeededRecursive(); //SAMSUNG CHANGE << int contentHeight = view->contentsHeight(); int contentWidth = view->contentsWidth(); // Only change the width or height if scrollbars are visible or // if the style is not a fixed value. Use the maximum value so // that iframes never shrink. if (scrolling || !heightIsFixed) setHeight(max(height(), contentHeight + extraHeight)); if (scrolling || !widthIsFixed) setWidth(max(width(), contentWidth + extraWidth)); // Update one last time updateWidgetPosition(); // Layout one more time to ensure all objects have the correct // height. view->layout(); #if !ASSERT_DISABLED ASSERT(!view->layoutPending()); ASSERT(!root->needsLayout()); // Sanity check when assertions are enabled. RenderObject* c = root->nextInPreOrder(); while (c) { ASSERT(!c->needsLayout()); c = c->nextInPreOrder(); } #endif } } } #else calcWidth(); calcHeight(); #endif RenderPart::layout(); m_overflow.clear(); addShadowOverflow(); setNeedsLayout(false); }