Chromium Code Reviews| Index: Source/core/page/FrameView.cpp |
| diff --git a/Source/core/page/FrameView.cpp b/Source/core/page/FrameView.cpp |
| index f49395957c7544622562574de7c461f37297215c..73941eed069aa87efd30e636091366b6e98cf3f2 100644 |
| --- a/Source/core/page/FrameView.cpp |
| +++ b/Source/core/page/FrameView.cpp |
| @@ -188,7 +188,7 @@ FrameView::FrameView(Frame* frame) |
| if (!page) |
| return; |
| - if (m_frame == page->mainFrame()) { |
| + if (isMainFrame()) { |
| ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); |
| ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); |
| } |
| @@ -205,6 +205,8 @@ PassRefPtr<FrameView> FrameView::create(Frame* frame, const IntSize& initialSize |
| { |
| RefPtr<FrameView> view = adoptRef(new FrameView(frame)); |
| view->Widget::setFrameRect(IntRect(view->location(), initialSize)); |
| + view->setLayoutSize(initialSize); |
| + |
| view->show(); |
| return view.release(); |
| } |
| @@ -229,12 +231,12 @@ FrameView::~FrameView() |
| ASSERT(!m_scrollCorner); |
| ASSERT(m_actionScheduler->isEmpty()); |
| - if (m_frame) { |
| - ASSERT(m_frame->view() != this || !m_frame->contentRenderer()); |
| - RenderPart* renderer = m_frame->ownerRenderer(); |
| - if (renderer && renderer->widget() == this) |
| - renderer->setWidget(0); |
| - } |
| + ASSERT(m_frame); |
| + |
| + ASSERT(m_frame->view() != this || !m_frame->contentRenderer()); |
| + RenderPart* renderer = m_frame->ownerRenderer(); |
| + if (renderer && renderer->widget() == this) |
| + renderer->setWidget(0); |
| } |
| void FrameView::reset() |
| @@ -331,7 +333,7 @@ void FrameView::prepareForDetach() |
| // right now, otherwise it won't be able to reach the topDocument()'s axObject cache later. |
| removeFromAXObjectCache(); |
| - if (m_frame && m_frame->page()) { |
| + if (m_frame->page()) { |
| if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scrollingCoordinator()) |
| scrollingCoordinator->willDestroyScrollableArea(this); |
| } |
| @@ -379,10 +381,8 @@ void FrameView::clear() |
| reset(); |
| - if (m_frame) { |
| - if (RenderPart* renderer = m_frame->ownerRenderer()) |
| - renderer->viewCleared(); |
| - } |
| + if (RenderPart* renderer = m_frame->ownerRenderer()) |
| + renderer->viewCleared(); |
| setScrollbarsSuppressed(true); |
| } |
| @@ -419,7 +419,7 @@ void FrameView::setFrameRect(const IntRect& newRect) |
| // Autosized font sizes depend on the width of the viewing area. |
| if (newRect.width() != oldRect.width()) { |
| Page* page = m_frame->page(); |
| - if (page && page->mainFrame() == m_frame && page->settings().textAutosizingEnabled()) { |
| + if (page && isMainFrame() && page->settings().textAutosizingEnabled()) { |
| for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) |
| m_frame->document()->textAutosizer()->recalculateMultipliers(); |
| } |
| @@ -478,7 +478,7 @@ void FrameView::updateCanHaveScrollbars() |
| PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientation) |
| { |
| if (Settings* settings = m_frame->settings()) { |
| - if (!settings->allowCustomScrollbarInMainFrame() && m_frame->page() && m_frame->page()->mainFrame() == m_frame) |
| + if (!settings->allowCustomScrollbarInMainFrame() && m_frame->page() && isMainFrame()) |
| return ScrollView::createScrollbar(orientation); |
| } |
| @@ -1021,7 +1021,7 @@ void FrameView::layout(bool allowSubtree) |
| LayoutSize oldSize = m_size; |
| - m_size = LayoutSize(layoutWidth(), layoutHeight()); |
| + m_size = LayoutSize(layoutSize().width(), layoutSize().height()); |
| if (oldSize != m_size) { |
| m_doFullRepaint = true; |
| @@ -1076,7 +1076,7 @@ void FrameView::layout(bool allowSubtree) |
| updateCanBlitOnScrollRecursively(); |
| if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER)) |
| - updateOverflowStatus(layoutWidth() < contentsWidth(), layoutHeight() < contentsHeight()); |
| + updateOverflowStatus(layoutSize().width() < contentsWidth(), layoutSize().height() < contentsHeight()); |
| // Resume scheduled events (FrameActionScheduler m_actionScheduler) |
| // and ensure post layout tasks are executed or scheduled to be. |
| @@ -1553,6 +1553,20 @@ void FrameView::setViewportConstrainedObjectsNeedLayout() |
| } |
| } |
| +IntSize FrameView::layoutSize(VisibleContentRectIncludesScrollbars scrollbarInclusion) const |
| +{ |
| + return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(m_layoutSize) : m_layoutSize; |
| +} |
| + |
| +void FrameView::setLayoutSize(const IntSize& size) |
| +{ |
| + if (m_layoutSize == size) |
| + return; |
| + |
| + m_layoutSize = size; |
| + updateScrollbars(scrollOffset()); |
| + contentsResized(); |
| +} |
| void FrameView::scrollPositionChanged() |
| { |
| @@ -1678,7 +1692,7 @@ void FrameView::visibleContentsResized() |
| if (!frame().view()) |
| return; |
| - if (!useFixedLayout() && needsLayout()) |
| + if (needsLayout()) |
| layout(); |
| if (RenderView* renderView = this->renderView()) { |
| @@ -1690,7 +1704,7 @@ void FrameView::visibleContentsResized() |
| void FrameView::beginDeferredRepaints() |
| { |
| Page* page = m_frame->page(); |
| - if (page->mainFrame() != m_frame) { |
| + if (!isMainFrame()) { |
| page->mainFrame()->view()->beginDeferredRepaints(); |
| return; |
| } |
| @@ -1701,7 +1715,7 @@ void FrameView::beginDeferredRepaints() |
| void FrameView::endDeferredRepaints() |
| { |
| Page* page = m_frame->page(); |
| - if (page->mainFrame() != m_frame) { |
| + if (!isMainFrame()) { |
| page->mainFrame()->view()->endDeferredRepaints(); |
| return; |
| } |
| @@ -2178,10 +2192,8 @@ void FrameView::performPostLayoutTasks() |
| m_frame->loader()->didFirstLayout(); |
| if (milestonesOfInterest & DidFirstLayout) |
| milestonesAchieved |= DidFirstLayout; |
| - if (page) { |
| - if (page->mainFrame() == m_frame) |
| - page->startCountingRelevantRepaintedObjects(); |
| - } |
| + if (isMainFrame()) |
| + page->startCountingRelevantRepaintedObjects(); |
| } |
| // Ensure that we always send this eventually. |
| @@ -2242,7 +2254,7 @@ void FrameView::sendResizeEventIfNeeded() |
| m_frame->eventHandler()->sendResizeEvent(); |
| Page* page = m_frame->page(); |
| - if (page && page->mainFrame() == m_frame) |
| + if (isMainFrame()) |
| InspectorInstrumentation::didResizeMainFrame(page); |
| } |
| @@ -2353,6 +2365,7 @@ void FrameView::autoSizeIfEnabled() |
| break; |
| resize(newSize.width(), newSize.height()); |
| + setLayoutSize(newSize); |
| // Force the scrollbar state to avoid the scrollbar code adding them and causing them to be needed. For example, |
| // a vertical scrollbar may cause text to wrap and thus increase the height (which is the only reason the scollbar is needed). |
| setVerticalScrollbarLock(false); |
| @@ -2394,7 +2407,7 @@ const Pagination& FrameView::pagination() const |
| return m_pagination; |
| if (Page* page = m_frame->page()) { |
| - if (page->mainFrame() == m_frame) |
| + if (isMainFrame()) |
| return page->pagination(); |
| } |
| @@ -2408,8 +2421,7 @@ void FrameView::setPagination(const Pagination& pagination) |
| m_pagination = pagination; |
| - if (m_frame) |
| - m_frame->document()->styleResolverChanged(RecalcStyleDeferred); |
| + m_frame->document()->styleResolverChanged(RecalcStyleDeferred); |
| } |
| IntRect FrameView::windowClipRect(bool clipToContents) const |
| @@ -2576,7 +2588,7 @@ void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate) |
| Page* page = m_frame->page(); |
| if (!page) |
| return; |
| - if (page->mainFrame() != m_frame) |
| + if (!isMainFrame()) |
|
kenneth.r.christiansen
2013/09/05 08:03:07
Why don't you make this -> isMainFrame() as a sepa
bokan
2013/09/05 20:03:36
Done in https://codereview.chromium.org/23654013/
|
| return; |
| if (forceUpdate) |
| @@ -2694,7 +2706,7 @@ void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& corne |
| } |
| if (m_scrollCorner) { |
| - bool needsBackgorund = m_frame->page() && m_frame->page()->mainFrame() == m_frame; |
| + bool needsBackgorund = isMainFrame(); |
| if (needsBackgorund) |
| context->fillRect(cornerRect, baseBackgroundColor()); |
| m_scrollCorner->paintIntoRect(context, cornerRect.location(), cornerRect); |
| @@ -2706,7 +2718,7 @@ void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& corne |
| void FrameView::paintScrollbar(GraphicsContext* context, Scrollbar* bar, const IntRect& rect) |
| { |
| - bool needsBackgorund = bar->isCustomScrollbar() && (m_frame->page() && m_frame->page()->mainFrame() == m_frame); |
| + bool needsBackgorund = bar->isCustomScrollbar() && (isMainFrame()); |
| if (needsBackgorund) { |
| IntRect toFill = bar->frameRect(); |
| toFill.intersect(rect); |
| @@ -2941,7 +2953,7 @@ void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& hori |
| return; |
| Page* page = m_frame->page(); |
| - if (page->mainFrame() == m_frame) { |
| + if (isMainFrame()) { |
| if (page->chrome().client().paintCustomOverhangArea(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect)) |
| return; |
| } |
| @@ -3360,4 +3372,23 @@ AXObjectCache* FrameView::axObjectCache() const |
| return 0; |
| } |
| +void FrameView::frameRectsChanged() |
| +{ |
| + Document* doc = m_frame->document(); |
| + bool layoutSizeIsExplicitlySet = |
| + isMainFrame() && doc && (doc->isHTMLDocument() || doc->isXHTMLDocument()); |
| + |
| + // Non-main frames' layout size should always match the frame size. For main frames we |
| + // explicitly set the layout size from WebViewImpl |
| + if (!layoutSizeIsExplicitlySet) |
| + setLayoutSize(frameRect().size()); |
| + |
| + ScrollView::frameRectsChanged(); |
| +} |
| + |
| +bool FrameView::isMainFrame() const |
| +{ |
| + return m_frame->page() && m_frame->page()->mainFrame() == m_frame; |
| +} |
| + |
| } // namespace WebCore |