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

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

Issue 157553002: Remove the Pagination struct, clean up viewport scroll policy propagation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase master Created 6 years, 10 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/frame/FrameView.h ('k') | Source/core/page/Page.h » ('j') | 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 if (didFullRepaint) { 99 if (didFullRepaint) {
100 flags &= ~RenderLayer::CheckForRepaint; 100 flags &= ~RenderLayer::CheckForRepaint;
101 flags |= RenderLayer::NeedsFullRepaintInBacking; 101 flags |= RenderLayer::NeedsFullRepaintInBacking;
102 } 102 }
103 if (isRelayoutingSubtree && layer->isPaginated()) 103 if (isRelayoutingSubtree && layer->isPaginated())
104 flags |= RenderLayer::UpdatePagination; 104 flags |= RenderLayer::UpdatePagination;
105 return flags; 105 return flags;
106 } 106 }
107 107
108 Pagination::Mode paginationModeForRenderStyle(RenderStyle* style)
109 {
110 EOverflow overflow = style->overflowY();
111 if (overflow != OPAGEDX && overflow != OPAGEDY)
112 return Pagination::Unpaginated;
113
114 bool isHorizontalWritingMode = style->isHorizontalWritingMode();
115 TextDirection textDirection = style->direction();
116 WritingMode writingMode = style->writingMode();
117
118 // paged-x always corresponds to LeftToRightPaginated or RightToLeftPaginate d. If the WritingMode
119 // is horizontal, then we use TextDirection to choose between those options. If the WritingMode
120 // is vertical, then the direction of the verticality dictates the choice.
121 if (overflow == OPAGEDX) {
122 if ((isHorizontalWritingMode && textDirection == LTR) || writingMode == LeftToRightWritingMode)
123 return Pagination::LeftToRightPaginated;
124 return Pagination::RightToLeftPaginated;
125 }
126
127 // paged-y always corresponds to TopToBottomPaginated or BottomToTopPaginate d. If the WritingMode
128 // is horizontal, then the direction of the horizontality dictates the choic e. If the WritingMode
129 // is vertical, then we use TextDirection to choose between those options.
130 if (writingMode == TopToBottomWritingMode || (!isHorizontalWritingMode && te xtDirection == LTR))
131 return Pagination::TopToBottomPaginated;
132 return Pagination::BottomToTopPaginated;
133 }
134
135 FrameView::FrameView(Frame* frame) 108 FrameView::FrameView(Frame* frame)
136 : m_frame(frame) 109 : m_frame(frame)
137 , m_canHaveScrollbars(true) 110 , m_canHaveScrollbars(true)
138 , m_slowRepaintObjectCount(0) 111 , m_slowRepaintObjectCount(0)
139 , m_hasPendingLayout(false) 112 , m_hasPendingLayout(false)
140 , m_layoutSubtreeRoot(0) 113 , m_layoutSubtreeRoot(0)
141 , m_inSynchronousPostLayout(false) 114 , m_inSynchronousPostLayout(false)
142 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) 115 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
143 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired) 116 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired)
144 , m_isTransparent(false) 117 , m_isTransparent(false)
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 if (!ignoreOverflowHidden) 517 if (!ignoreOverflowHidden)
545 vMode = ScrollbarAlwaysOff; 518 vMode = ScrollbarAlwaysOff;
546 break; 519 break;
547 case OSCROLL: 520 case OSCROLL:
548 vMode = ScrollbarAlwaysOn; 521 vMode = ScrollbarAlwaysOn;
549 break; 522 break;
550 case OAUTO: 523 case OAUTO:
551 vMode = ScrollbarAuto; 524 vMode = ScrollbarAuto;
552 break; 525 break;
553 default: 526 default:
554 // Don't set it at all. Values of OPAGEDX and OPAGEDY are handled by applyPaginationToViewPort(). 527 // Don't set it at all.
555 ; 528 ;
556 } 529 }
557 530
558 m_viewportRenderer = o; 531 m_viewportRenderer = o;
559 } 532 }
560 533
561 void FrameView::applyPaginationToViewport()
562 {
563 Document* document = m_frame->document();
564 Node* documentElement = document->documentElement();
565 RenderObject* documentRenderer = documentElement ? documentElement->renderer () : 0;
566 RenderObject* documentOrBodyRenderer = documentRenderer;
567 Node* body = document->body();
568 if (body && body->renderer()) {
569 if (body->hasTagName(bodyTag))
570 documentOrBodyRenderer = documentRenderer->style()->overflowX() == O VISIBLE && documentElement->hasTagName(htmlTag) ? body->renderer() : documentRen derer;
571 }
572
573 Pagination pagination;
574
575 if (!documentOrBodyRenderer) {
576 setPagination(pagination);
577 return;
578 }
579
580 EOverflow overflowY = documentOrBodyRenderer->style()->overflowY();
581 if (overflowY == OPAGEDX || overflowY == OPAGEDY) {
582 pagination.mode = WebCore::paginationModeForRenderStyle(documentOrBodyRe nderer->style());
583 pagination.gap = static_cast<unsigned>(documentOrBodyRenderer->style()-> columnGap());
584 }
585
586 setPagination(pagination);
587 }
588
589 void FrameView::calculateScrollbarModesForLayoutAndSetViewportRenderer(Scrollbar Mode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy strategy) 534 void FrameView::calculateScrollbarModesForLayoutAndSetViewportRenderer(Scrollbar Mode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy strategy)
590 { 535 {
591 m_viewportRenderer = 0; 536 m_viewportRenderer = 0;
592 537
593 const HTMLFrameOwnerElement* owner = m_frame->ownerElement(); 538 const HTMLFrameOwnerElement* owner = m_frame->ownerElement();
594 if (owner && (owner->scrollingMode() == ScrollbarAlwaysOff)) { 539 if (owner && (owner->scrollingMode() == ScrollbarAlwaysOff)) {
595 hMode = ScrollbarAlwaysOff; 540 hMode = ScrollbarAlwaysOff;
596 vMode = ScrollbarAlwaysOff; 541 vMode = ScrollbarAlwaysOff;
597 return; 542 return;
598 } 543 }
599 544
600 if (m_canHaveScrollbars || strategy == RulesFromWebContentOnly) { 545 if (m_canHaveScrollbars || strategy == RulesFromWebContentOnly) {
601 hMode = ScrollbarAuto; 546 hMode = ScrollbarAuto;
602 vMode = ScrollbarAuto; 547 vMode = ScrollbarAuto;
603 } else { 548 } else {
604 hMode = ScrollbarAlwaysOff; 549 hMode = ScrollbarAlwaysOff;
605 vMode = ScrollbarAlwaysOff; 550 vMode = ScrollbarAlwaysOff;
606 } 551 }
607 552
608 if (!isSubtreeLayout()) { 553 if (!isSubtreeLayout()) {
609 Document* document = m_frame->document(); 554 Document* document = m_frame->document();
610 Node* documentElement = document->documentElement();
611 RenderObject* rootRenderer = documentElement ? documentElement->renderer () : 0;
612 Node* body = document->body(); 555 Node* body = document->body();
613 if (body && body->renderer()) { 556 if (body && body->renderer() && body->hasTagName(framesetTag)) {
614 if (body->hasTagName(framesetTag)) { 557 vMode = ScrollbarAlwaysOff;
615 vMode = ScrollbarAlwaysOff; 558 hMode = ScrollbarAlwaysOff;
616 hMode = ScrollbarAlwaysOff; 559 } else if (Element* viewportElement = document->viewportDefiningElement( )) {
617 } else if (body->hasTagName(bodyTag)) { 560 if (RenderObject* viewportRenderer = viewportElement->renderer()) {
618 // It's sufficient to just check the X overflow, 561 if (viewportRenderer->style())
619 // since it's illegal to have visible in only one direction. 562 applyOverflowToViewportAndSetRenderer(viewportRenderer, hMod e, vMode);
620 RenderObject* o = rootRenderer->style()->overflowX() == OVISIBLE && document->documentElement()->hasTagName(htmlTag) ? body->renderer() : rootRe nderer;
621 if (o->style())
622 applyOverflowToViewportAndSetRenderer(o, hMode, vMode);
623 } 563 }
624 } else if (rootRenderer) {
625 applyOverflowToViewportAndSetRenderer(rootRenderer, hMode, vMode);
626 } 564 }
627 } 565 }
628 } 566 }
629 567
630 void FrameView::updateCompositingLayersAfterStyleChange() 568 void FrameView::updateCompositingLayersAfterStyleChange()
631 { 569 {
632 TRACE_EVENT0("webkit", "FrameView::updateCompositingLayersAfterStyleChange") ; 570 TRACE_EVENT0("webkit", "FrameView::updateCompositingLayersAfterStyleChange") ;
633 RenderView* renderView = this->renderView(); 571 RenderView* renderView = this->renderView();
634 if (!renderView) 572 if (!renderView)
635 return; 573 return;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 document->styleResolverChanged(RecalcStyleDeferred); 735 document->styleResolverChanged(RecalcStyleDeferred);
798 document->mediaQueryAffectingValueChanged(); 736 document->mediaQueryAffectingValueChanged();
799 737
800 // FIXME: This instrumentation event is not strictly accurate since cach ed media query results 738 // FIXME: This instrumentation event is not strictly accurate since cach ed media query results
801 // do not persist across StyleResolver rebuilds. 739 // do not persist across StyleResolver rebuilds.
802 InspectorInstrumentation::mediaQueryResultChanged(document); 740 InspectorInstrumentation::mediaQueryResultChanged(document);
803 } else { 741 } else {
804 document->evaluateMediaQueryList(); 742 document->evaluateMediaQueryList();
805 } 743 }
806 744
807 // If there is any pagination to apply, it will affect the RenderView's styl e, so we should
808 // take care of that now.
809 applyPaginationToViewport();
810
811 // Always ensure our style info is up-to-date. This can happen in situations where 745 // Always ensure our style info is up-to-date. This can happen in situations where
812 // the layout beats any sort of style recalc update that needs to occur. 746 // the layout beats any sort of style recalc update that needs to occur.
813 TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleU pdate, true); 747 TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleU pdate, true);
814 document->updateStyleIfNeeded(); 748 document->updateStyleIfNeeded();
815 lifecycle().advanceTo(DocumentLifecycle::StyleClean); 749 lifecycle().advanceTo(DocumentLifecycle::StyleClean);
816 } 750 }
817 751
818 void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay out) 752 void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay out)
819 { 753 {
820 TRACE_EVENT0("webkit", "FrameView::performLayout"); 754 TRACE_EVENT0("webkit", "FrameView::performLayout");
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 m_horizontalOverflow = horizontalOverflow; 2187 m_horizontalOverflow = horizontalOverflow;
2254 m_verticalOverflow = verticalOverflow; 2188 m_verticalOverflow = verticalOverflow;
2255 2189
2256 RefPtr<OverflowEvent> event = OverflowEvent::create(horizontalOverflowCh anged, horizontalOverflow, verticalOverflowChanged, verticalOverflow); 2190 RefPtr<OverflowEvent> event = OverflowEvent::create(horizontalOverflowCh anged, horizontalOverflow, verticalOverflowChanged, verticalOverflow);
2257 event->setTarget(m_viewportRenderer->node()); 2191 event->setTarget(m_viewportRenderer->node());
2258 m_frame->document()->enqueueAnimationFrameEvent(event.release()); 2192 m_frame->document()->enqueueAnimationFrameEvent(event.release());
2259 } 2193 }
2260 2194
2261 } 2195 }
2262 2196
2263 void FrameView::setPagination(const Pagination& pagination)
2264 {
2265 if (m_pagination == pagination)
2266 return;
2267
2268 m_pagination = pagination;
2269 m_frame->document()->styleResolverChanged(RecalcStyleDeferred);
2270 }
2271
2272 IntRect FrameView::windowClipRect(bool clipToContents) const 2197 IntRect FrameView::windowClipRect(bool clipToContents) const
2273 { 2198 {
2274 ASSERT(m_frame->view() == this); 2199 ASSERT(m_frame->view() == this);
2275 2200
2276 if (paintsEntireContents()) 2201 if (paintsEntireContents())
2277 return IntRect(IntPoint(), contentsSize()); 2202 return IntRect(IntPoint(), contentsSize());
2278 2203
2279 // Set our clip rect to be our contents. 2204 // Set our clip rect to be our contents.
2280 IntRect clipRect = contentsToWindow(visibleContentRect(clipToContents ? Excl udeScrollbars : IncludeScrollbars)); 2205 IntRect clipRect = contentsToWindow(visibleContentRect(clipToContents ? Excl udeScrollbars : IncludeScrollbars));
2281 if (!m_frame->ownerElement()) 2206 if (!m_frame->ownerElement())
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation) 3163 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation)
3239 { 3164 {
3240 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); 3165 ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
3241 if (AXObjectCache* cache = axObjectCache()) { 3166 if (AXObjectCache* cache = axObjectCache()) {
3242 cache->remove(scrollbar); 3167 cache->remove(scrollbar);
3243 cache->handleScrollbarUpdate(this); 3168 cache->handleScrollbarUpdate(this);
3244 } 3169 }
3245 } 3170 }
3246 3171
3247 } // namespace WebCore 3172 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/page/Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698