Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(726)

Side by Side Diff: Source/core/page/FrameView.cpp

Issue 23654013: Cleanup, added a helper to FrameView, isMainFrame(). No behavior change (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Style fix Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/page/FrameView.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 , m_shouldAutoSize(false) 178 , m_shouldAutoSize(false)
179 , m_inAutoSize(false) 179 , m_inAutoSize(false)
180 , m_didRunAutosize(false) 180 , m_didRunAutosize(false)
181 , m_hasSoftwareFilters(false) 181 , m_hasSoftwareFilters(false)
182 , m_visibleContentScaleFactor(1) 182 , m_visibleContentScaleFactor(1)
183 , m_partialLayout() 183 , m_partialLayout()
184 { 184 {
185 ASSERT(m_frame); 185 ASSERT(m_frame);
186 init(); 186 init();
187 187
188 Page* page = m_frame->page(); 188 if (!isMainFrame())
189 if (!page)
190 return; 189 return;
191 190
192 if (m_frame == page->mainFrame()) { 191 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed);
193 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); 192 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed);
194 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed);
195 }
196 } 193 }
197 194
198 PassRefPtr<FrameView> FrameView::create(Frame* frame) 195 PassRefPtr<FrameView> FrameView::create(Frame* frame)
199 { 196 {
200 RefPtr<FrameView> view = adoptRef(new FrameView(frame)); 197 RefPtr<FrameView> view = adoptRef(new FrameView(frame));
201 view->show(); 198 view->show();
202 return view.release(); 199 return view.release();
203 } 200 }
204 201
205 PassRefPtr<FrameView> FrameView::create(Frame* frame, const IntSize& initialSize ) 202 PassRefPtr<FrameView> FrameView::create(Frame* frame, const IntSize& initialSize )
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 408
412 void FrameView::setFrameRect(const IntRect& newRect) 409 void FrameView::setFrameRect(const IntRect& newRect)
413 { 410 {
414 IntRect oldRect = frameRect(); 411 IntRect oldRect = frameRect();
415 if (newRect == oldRect) 412 if (newRect == oldRect)
416 return; 413 return;
417 414
418 // Autosized font sizes depend on the width of the viewing area. 415 // Autosized font sizes depend on the width of the viewing area.
419 if (newRect.width() != oldRect.width()) { 416 if (newRect.width() != oldRect.width()) {
420 Page* page = m_frame->page(); 417 Page* page = m_frame->page();
421 if (page && page->mainFrame() == m_frame && page->settings().textAutosiz ingEnabled()) { 418 if (isMainFrame() && page->settings().textAutosizingEnabled()) {
422 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()- >traverseNext()) 419 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()- >traverseNext())
423 m_frame->document()->textAutosizer()->recalculateMultipliers(); 420 m_frame->document()->textAutosizer()->recalculateMultipliers();
424 } 421 }
425 } 422 }
426 423
427 ScrollView::setFrameRect(newRect); 424 ScrollView::setFrameRect(newRect);
428 425
429 updateScrollableAreaSet(); 426 updateScrollableAreaSet();
430 427
431 if (RenderView* renderView = this->renderView()) { 428 if (RenderView* renderView = this->renderView()) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 scrollbarModes(hMode, vMode); 482 scrollbarModes(hMode, vMode);
486 if (hMode == ScrollbarAlwaysOff && vMode == ScrollbarAlwaysOff) 483 if (hMode == ScrollbarAlwaysOff && vMode == ScrollbarAlwaysOff)
487 setCanHaveScrollbars(false); 484 setCanHaveScrollbars(false);
488 else 485 else
489 setCanHaveScrollbars(true); 486 setCanHaveScrollbars(true);
490 } 487 }
491 488
492 PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientatio n) 489 PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientatio n)
493 { 490 {
494 if (Settings* settings = m_frame->settings()) { 491 if (Settings* settings = m_frame->settings()) {
495 if (!settings->allowCustomScrollbarInMainFrame() && m_frame->page() && m _frame->page()->mainFrame() == m_frame) 492 if (!settings->allowCustomScrollbarInMainFrame() && isMainFrame())
496 return ScrollView::createScrollbar(orientation); 493 return ScrollView::createScrollbar(orientation);
497 } 494 }
498 495
499 // FIXME: We need to update the scrollbar dynamically as documents change (o r as doc elements and bodies get discovered that have custom styles). 496 // FIXME: We need to update the scrollbar dynamically as documents change (o r as doc elements and bodies get discovered that have custom styles).
500 Document* doc = m_frame->document(); 497 Document* doc = m_frame->document();
501 498
502 // Try the <body> element first as a scrollbar source. 499 // Try the <body> element first as a scrollbar source.
503 Element* body = doc ? doc->body() : 0; 500 Element* body = doc ? doc->body() : 0;
504 if (body && body->renderer() && body->renderer()->style()->hasPseudoStyle(SC ROLLBAR)) 501 if (body && body->renderer() && body->renderer()->style()->hasPseudoStyle(SC ROLLBAR))
505 return RenderScrollbar::createCustomScrollbar(this, orientation, body); 502 return RenderScrollbar::createCustomScrollbar(this, orientation, body);
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 1710
1714 if (RenderView* renderView = this->renderView()) { 1711 if (RenderView* renderView = this->renderView()) {
1715 if (renderView->usesCompositing()) 1712 if (renderView->usesCompositing())
1716 renderView->compositor()->frameViewDidChangeSize(); 1713 renderView->compositor()->frameViewDidChangeSize();
1717 } 1714 }
1718 } 1715 }
1719 1716
1720 void FrameView::beginDeferredRepaints() 1717 void FrameView::beginDeferredRepaints()
1721 { 1718 {
1722 Page* page = m_frame->page(); 1719 Page* page = m_frame->page();
1723 if (page->mainFrame() != m_frame) { 1720 ASSERT(page);
1721
1722 if (!isMainFrame()) {
1724 page->mainFrame()->view()->beginDeferredRepaints(); 1723 page->mainFrame()->view()->beginDeferredRepaints();
1725 return; 1724 return;
1726 } 1725 }
1727 1726
1728 m_deferringRepaints++; 1727 m_deferringRepaints++;
1729 } 1728 }
1730 1729
1731 void FrameView::endDeferredRepaints() 1730 void FrameView::endDeferredRepaints()
1732 { 1731 {
1733 Page* page = m_frame->page(); 1732 Page* page = m_frame->page();
1734 if (page->mainFrame() != m_frame) { 1733 ASSERT(page);
1734
1735 if (!isMainFrame()) {
1735 page->mainFrame()->view()->endDeferredRepaints(); 1736 page->mainFrame()->view()->endDeferredRepaints();
1736 return; 1737 return;
1737 } 1738 }
1738 1739
1739 ASSERT(m_deferringRepaints > 0); 1740 ASSERT(m_deferringRepaints > 0);
1740 1741
1741 if (--m_deferringRepaints) 1742 if (--m_deferringRepaints)
1742 return; 1743 return;
1743 1744
1744 if (m_deferredRepaintTimer.isActive()) 1745 if (m_deferredRepaintTimer.isActive())
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2201 Page* page = m_frame->page(); 2202 Page* page = m_frame->page();
2202 if (page) 2203 if (page)
2203 milestonesOfInterest = page->layoutMilestones(); 2204 milestonesOfInterest = page->layoutMilestones();
2204 2205
2205 if (m_nestedLayoutCount <= 1) { 2206 if (m_nestedLayoutCount <= 1) {
2206 if (m_firstLayoutCallbackPending) { 2207 if (m_firstLayoutCallbackPending) {
2207 m_firstLayoutCallbackPending = false; 2208 m_firstLayoutCallbackPending = false;
2208 m_frame->loader()->didFirstLayout(); 2209 m_frame->loader()->didFirstLayout();
2209 if (milestonesOfInterest & DidFirstLayout) 2210 if (milestonesOfInterest & DidFirstLayout)
2210 milestonesAchieved |= DidFirstLayout; 2211 milestonesAchieved |= DidFirstLayout;
2211 if (page) { 2212 if (isMainFrame())
2212 if (page->mainFrame() == m_frame) 2213 page->startCountingRelevantRepaintedObjects();
2213 page->startCountingRelevantRepaintedObjects();
2214 }
2215 } 2214 }
2216 2215
2217 // Ensure that we always send this eventually. 2216 // Ensure that we always send this eventually.
2218 if (!m_frame->document()->parsing() && m_frame->loader()->stateMachine() ->committedFirstRealDocumentLoad()) 2217 if (!m_frame->document()->parsing() && m_frame->loader()->stateMachine() ->committedFirstRealDocumentLoad())
2219 m_isVisuallyNonEmpty = true; 2218 m_isVisuallyNonEmpty = true;
2220 2219
2221 // If the layout was done with pending sheets, we are not in fact visual ly non-empty yet. 2220 // If the layout was done with pending sheets, we are not in fact visual ly non-empty yet.
2222 if (m_isVisuallyNonEmpty && !m_frame->document()->didLayoutWithPendingSt ylesheets() && m_firstVisuallyNonEmptyLayoutCallbackPending) { 2221 if (m_isVisuallyNonEmpty && !m_frame->document()->didLayoutWithPendingSt ylesheets() && m_firstVisuallyNonEmptyLayoutCallbackPending) {
2223 m_firstVisuallyNonEmptyLayoutCallbackPending = false; 2222 m_firstVisuallyNonEmptyLayoutCallbackPending = false;
2224 if (milestonesOfInterest & DidFirstVisuallyNonEmptyLayout) 2223 if (milestonesOfInterest & DidFirstVisuallyNonEmptyLayout)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 2264
2266 m_lastViewportSize = currentSize; 2265 m_lastViewportSize = currentSize;
2267 m_lastZoomFactor = currentZoomFactor; 2266 m_lastZoomFactor = currentZoomFactor;
2268 2267
2269 if (!shouldSendResizeEvent) 2268 if (!shouldSendResizeEvent)
2270 return; 2269 return;
2271 2270
2272 m_frame->eventHandler()->sendResizeEvent(); 2271 m_frame->eventHandler()->sendResizeEvent();
2273 2272
2274 Page* page = m_frame->page(); 2273 Page* page = m_frame->page();
2275 if (page && page->mainFrame() == m_frame) 2274 if (isMainFrame())
2276 InspectorInstrumentation::didResizeMainFrame(page); 2275 InspectorInstrumentation::didResizeMainFrame(page);
2277 } 2276 }
2278 2277
2279 void FrameView::postLayoutTimerFired(Timer<FrameView>*) 2278 void FrameView::postLayoutTimerFired(Timer<FrameView>*)
2280 { 2279 {
2281 performPostLayoutTasks(); 2280 performPostLayoutTasks();
2282 } 2281 }
2283 2282
2284 void FrameView::updateCounters() 2283 void FrameView::updateCounters()
2285 { 2284 {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 m_viewportRenderer->node()); 2415 m_viewportRenderer->node());
2417 } 2416 }
2418 2417
2419 } 2418 }
2420 2419
2421 const Pagination& FrameView::pagination() const 2420 const Pagination& FrameView::pagination() const
2422 { 2421 {
2423 if (m_pagination != Pagination()) 2422 if (m_pagination != Pagination())
2424 return m_pagination; 2423 return m_pagination;
2425 2424
2426 if (Page* page = m_frame->page()) { 2425 if (isMainFrame())
2427 if (page->mainFrame() == m_frame) 2426 return m_frame->page()->pagination();
2428 return page->pagination();
2429 }
2430 2427
2431 return m_pagination; 2428 return m_pagination;
2432 } 2429 }
2433 2430
2434 void FrameView::setPagination(const Pagination& pagination) 2431 void FrameView::setPagination(const Pagination& pagination)
2435 { 2432 {
2436 if (m_pagination == pagination) 2433 if (m_pagination == pagination)
2437 return; 2434 return;
2438 2435
2439 m_pagination = pagination; 2436 m_pagination = pagination;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 parentFrameView->addScrollableArea(this); 2592 parentFrameView->addScrollableArea(this);
2596 } 2593 }
2597 2594
2598 bool FrameView::shouldSuspendScrollAnimations() const 2595 bool FrameView::shouldSuspendScrollAnimations() const
2599 { 2596 {
2600 return m_frame->loader()->state() != FrameStateComplete; 2597 return m_frame->loader()->state() != FrameStateComplete;
2601 } 2598 }
2602 2599
2603 void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate) 2600 void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate)
2604 { 2601 {
2605 Page* page = m_frame->page(); 2602 if (!isMainFrame())
2606 if (!page)
2607 return;
2608 if (page->mainFrame() != m_frame)
2609 return; 2603 return;
2610 2604
2611 if (forceUpdate) 2605 if (forceUpdate)
2612 ScrollView::scrollbarStyleChanged(newStyle, forceUpdate); 2606 ScrollView::scrollbarStyleChanged(newStyle, forceUpdate);
2613 } 2607 }
2614 2608
2615 void FrameView::setAnimatorsAreActive() 2609 void FrameView::setAnimatorsAreActive()
2616 { 2610 {
2617 Page* page = m_frame->page(); 2611 Page* page = m_frame->page();
2618 if (!page) 2612 if (!page)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 } 2710 }
2717 2711
2718 void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& corne rRect) 2712 void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& corne rRect)
2719 { 2713 {
2720 if (context->updatingControlTints()) { 2714 if (context->updatingControlTints()) {
2721 updateScrollCorner(); 2715 updateScrollCorner();
2722 return; 2716 return;
2723 } 2717 }
2724 2718
2725 if (m_scrollCorner) { 2719 if (m_scrollCorner) {
2726 bool needsBackgorund = m_frame->page() && m_frame->page()->mainFrame() = = m_frame; 2720 bool needsBackgorund = isMainFrame();
2727 if (needsBackgorund) 2721 if (needsBackgorund)
2728 context->fillRect(cornerRect, baseBackgroundColor()); 2722 context->fillRect(cornerRect, baseBackgroundColor());
2729 m_scrollCorner->paintIntoRect(context, cornerRect.location(), cornerRect ); 2723 m_scrollCorner->paintIntoRect(context, cornerRect.location(), cornerRect );
2730 return; 2724 return;
2731 } 2725 }
2732 2726
2733 ScrollView::paintScrollCorner(context, cornerRect); 2727 ScrollView::paintScrollCorner(context, cornerRect);
2734 } 2728 }
2735 2729
2736 void FrameView::paintScrollbar(GraphicsContext* context, Scrollbar* bar, const I ntRect& rect) 2730 void FrameView::paintScrollbar(GraphicsContext* context, Scrollbar* bar, const I ntRect& rect)
2737 { 2731 {
2738 bool needsBackgorund = bar->isCustomScrollbar() && (m_frame->page() && m_fra me->page()->mainFrame() == m_frame); 2732 bool needsBackgorund = bar->isCustomScrollbar() && isMainFrame();
2739 if (needsBackgorund) { 2733 if (needsBackgorund) {
2740 IntRect toFill = bar->frameRect(); 2734 IntRect toFill = bar->frameRect();
2741 toFill.intersect(rect); 2735 toFill.intersect(rect);
2742 context->fillRect(toFill, baseBackgroundColor()); 2736 context->fillRect(toFill, baseBackgroundColor());
2743 } 2737 }
2744 2738
2745 ScrollView::paintScrollbar(context, bar, rect); 2739 ScrollView::paintScrollbar(context, bar, rect);
2746 } 2740 }
2747 2741
2748 Color FrameView::documentBackgroundColor() const 2742 Color FrameView::documentBackgroundColor() const
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 } 2956 }
2963 2957
2964 void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& hori zontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRec t) 2958 void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& hori zontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRec t)
2965 { 2959 {
2966 if (context->paintingDisabled()) 2960 if (context->paintingDisabled())
2967 return; 2961 return;
2968 2962
2969 if (m_frame->document()->printing()) 2963 if (m_frame->document()->printing())
2970 return; 2964 return;
2971 2965
2972 Page* page = m_frame->page(); 2966 if (isMainFrame()) {
2973 if (page->mainFrame() == m_frame) { 2967 if (m_frame->page()->chrome().client().paintCustomOverhangArea(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect))
2974 if (page->chrome().client().paintCustomOverhangArea(context, horizontalO verhangArea, verticalOverhangArea, dirtyRect))
2975 return; 2968 return;
2976 } 2969 }
2977 2970
2978 ScrollView::paintOverhangAreas(context, horizontalOverhangArea, verticalOver hangArea, dirtyRect); 2971 ScrollView::paintOverhangAreas(context, horizontalOverhangArea, verticalOver hangArea, dirtyRect);
2979 } 2972 }
2980 2973
2981 void FrameView::updateLayoutAndStyleIfNeededRecursive() 2974 void FrameView::updateLayoutAndStyleIfNeededRecursive()
2982 { 2975 {
2983 // We have to crawl our entire tree looking for any FrameViews that need 2976 // We have to crawl our entire tree looking for any FrameViews that need
2984 // layout and make sure they are up to date. 2977 // layout and make sure they are up to date.
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 return false; 3349 return false;
3357 #endif 3350 #endif
3358 3351
3359 // We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled. 3352 // We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
3360 if (!canHaveScrollbars()) 3353 if (!canHaveScrollbars())
3361 return false; 3354 return false;
3362 3355
3363 return ScrollableArea::handleWheelEvent(wheelEvent); 3356 return ScrollableArea::handleWheelEvent(wheelEvent);
3364 } 3357 }
3365 3358
3366
3367 bool FrameView::isVerticalDocument() const 3359 bool FrameView::isVerticalDocument() const
3368 { 3360 {
3369 RenderView* renderView = this->renderView(); 3361 RenderView* renderView = this->renderView();
3370 if (!renderView) 3362 if (!renderView)
3371 return true; 3363 return true;
3372 3364
3373 return renderView->style()->isHorizontalWritingMode(); 3365 return renderView->style()->isHorizontalWritingMode();
3374 } 3366 }
3375 3367
3376 bool FrameView::isFlippedDocument() const 3368 bool FrameView::isFlippedDocument() const
3377 { 3369 {
3378 RenderView* renderView = this->renderView(); 3370 RenderView* renderView = this->renderView();
3379 if (!renderView) 3371 if (!renderView)
3380 return false; 3372 return false;
3381 3373
3382 return renderView->style()->isFlippedBlocksWritingMode(); 3374 return renderView->style()->isFlippedBlocksWritingMode();
3383 } 3375 }
3384 3376
3385 AXObjectCache* FrameView::axObjectCache() const 3377 AXObjectCache* FrameView::axObjectCache() const
3386 { 3378 {
3387 if (frame().document()) 3379 if (frame().document())
3388 return frame().document()->existingAXObjectCache(); 3380 return frame().document()->existingAXObjectCache();
3389 return 0; 3381 return 0;
3390 } 3382 }
3391 3383
3384 bool FrameView::isMainFrame() const
3385 {
3386 return m_frame->page() && m_frame->page()->mainFrame() == m_frame;
3387 }
3388
3392 } // namespace WebCore 3389 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/FrameView.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698