 Chromium Code Reviews
 Chromium Code Reviews Issue 157553002:
  Remove the Pagination struct, clean up viewport scroll policy propagation.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 157553002:
  Remove the Pagination struct, clean up viewport scroll policy propagation.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| OLD | NEW | 
|---|---|
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 | 99 | 
| 100 if (didFullRepaint) { | 100 if (didFullRepaint) { | 
| 101 flags &= ~RenderLayer::CheckForRepaint; | 101 flags &= ~RenderLayer::CheckForRepaint; | 
| 102 flags |= RenderLayer::NeedsFullRepaintInBacking; | 102 flags |= RenderLayer::NeedsFullRepaintInBacking; | 
| 103 } | 103 } | 
| 104 if (isRelayoutingSubtree && layer->isPaginated()) | 104 if (isRelayoutingSubtree && layer->isPaginated()) | 
| 105 flags |= RenderLayer::UpdatePagination; | 105 flags |= RenderLayer::UpdatePagination; | 
| 106 return flags; | 106 return flags; | 
| 107 } | 107 } | 
| 108 | 108 | 
| 109 Pagination::Mode paginationModeForRenderStyle(RenderStyle* style) | |
| 110 { | |
| 111 EOverflow overflow = style->overflowY(); | |
| 112 if (overflow != OPAGEDX && overflow != OPAGEDY) | |
| 113 return Pagination::Unpaginated; | |
| 114 | |
| 115 bool isHorizontalWritingMode = style->isHorizontalWritingMode(); | |
| 116 TextDirection textDirection = style->direction(); | |
| 117 WritingMode writingMode = style->writingMode(); | |
| 118 | |
| 119 // paged-x always corresponds to LeftToRightPaginated or RightToLeftPaginate d. If the WritingMode | |
| 120 // is horizontal, then we use TextDirection to choose between those options. If the WritingMode | |
| 121 // is vertical, then the direction of the verticality dictates the choice. | |
| 122 if (overflow == OPAGEDX) { | |
| 123 if ((isHorizontalWritingMode && textDirection == LTR) || writingMode == LeftToRightWritingMode) | |
| 124 return Pagination::LeftToRightPaginated; | |
| 125 return Pagination::RightToLeftPaginated; | |
| 126 } | |
| 127 | |
| 128 // paged-y always corresponds to TopToBottomPaginated or BottomToTopPaginate d. If the WritingMode | |
| 129 // is horizontal, then the direction of the horizontality dictates the choic e. If the WritingMode | |
| 130 // is vertical, then we use TextDirection to choose between those options. | |
| 131 if (writingMode == TopToBottomWritingMode || (!isHorizontalWritingMode && te xtDirection == LTR)) | |
| 132 return Pagination::TopToBottomPaginated; | |
| 133 return Pagination::BottomToTopPaginated; | |
| 134 } | |
| 135 | |
| 136 FrameView::FrameView(Frame* frame) | 109 FrameView::FrameView(Frame* frame) | 
| 137 : m_frame(frame) | 110 : m_frame(frame) | 
| 138 , m_canHaveScrollbars(true) | 111 , m_canHaveScrollbars(true) | 
| 139 , m_slowRepaintObjectCount(0) | 112 , m_slowRepaintObjectCount(0) | 
| 140 , m_hasPendingLayout(false) | 113 , m_hasPendingLayout(false) | 
| 141 , m_layoutSubtreeRoot(0) | 114 , m_layoutSubtreeRoot(0) | 
| 142 , m_inSynchronousPostLayout(false) | 115 , m_inSynchronousPostLayout(false) | 
| 143 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) | 116 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) | 
| 144 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired) | 117 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired) | 
| 145 , m_isTransparent(false) | 118 , m_isTransparent(false) | 
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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* o = viewportElement->renderer()) { | 
| 
ojan
2014/02/08 01:40:19
Nit: while you're in this code, s/o/viewportRender
 
mstensho (USE GERRIT)
2014/02/11 10:44:14
Done.
 | |
| 618 // It's sufficient to just check the X overflow, | |
| 619 // since it's illegal to have visible in only one direction. | |
| 620 RenderObject* o = rootRenderer->style()->overflowX() == OVISIBLE && document->documentElement()->hasTagName(htmlTag) ? body->renderer() : rootRe nderer; | |
| 621 if (o->style()) | 561 if (o->style()) | 
| 622 applyOverflowToViewportAndSetRenderer(o, hMode, vMode); | 562 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 document->styleResolverChanged(RecalcStyleDeferred); | 734 document->styleResolverChanged(RecalcStyleDeferred); | 
| 797 document->mediaQueryAffectingValueChanged(); | 735 document->mediaQueryAffectingValueChanged(); | 
| 798 | 736 | 
| 799 // FIXME: This instrumentation event is not strictly accurate since cach ed media query results | 737 // FIXME: This instrumentation event is not strictly accurate since cach ed media query results | 
| 800 // do not persist across StyleResolver rebuilds. | 738 // do not persist across StyleResolver rebuilds. | 
| 801 InspectorInstrumentation::mediaQueryResultChanged(document); | 739 InspectorInstrumentation::mediaQueryResultChanged(document); | 
| 802 } else { | 740 } else { | 
| 803 document->evaluateMediaQueryList(); | 741 document->evaluateMediaQueryList(); | 
| 804 } | 742 } | 
| 805 | 743 | 
| 806 // If there is any pagination to apply, it will affect the RenderView's styl e, so we should | |
| 807 // take care of that now. | |
| 808 applyPaginationToViewport(); | |
| 809 | |
| 810 // Always ensure our style info is up-to-date. This can happen in situations where | 744 // Always ensure our style info is up-to-date. This can happen in situations where | 
| 811 // the layout beats any sort of style recalc update that needs to occur. | 745 // the layout beats any sort of style recalc update that needs to occur. | 
| 812 TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleU pdate, true); | 746 TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleU pdate, true); | 
| 813 document->updateStyleIfNeeded(); | 747 document->updateStyleIfNeeded(); | 
| 814 } | 748 } | 
| 815 | 749 | 
| 816 void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay out) | 750 void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay out) | 
| 817 { | 751 { | 
| 818 ASSERT(!m_inPerformLayout); | 752 ASSERT(!m_inPerformLayout); | 
| 819 | 753 | 
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2234 m_horizontalOverflow = horizontalOverflow; | 2168 m_horizontalOverflow = horizontalOverflow; | 
| 2235 m_verticalOverflow = verticalOverflow; | 2169 m_verticalOverflow = verticalOverflow; | 
| 2236 | 2170 | 
| 2237 RefPtr<OverflowEvent> event = OverflowEvent::create(horizontalOverflowCh anged, horizontalOverflow, verticalOverflowChanged, verticalOverflow); | 2171 RefPtr<OverflowEvent> event = OverflowEvent::create(horizontalOverflowCh anged, horizontalOverflow, verticalOverflowChanged, verticalOverflow); | 
| 2238 event->setTarget(m_viewportRenderer->node()); | 2172 event->setTarget(m_viewportRenderer->node()); | 
| 2239 m_frame->document()->enqueueAnimationFrameEvent(event.release()); | 2173 m_frame->document()->enqueueAnimationFrameEvent(event.release()); | 
| 2240 } | 2174 } | 
| 2241 | 2175 | 
| 2242 } | 2176 } | 
| 2243 | 2177 | 
| 2244 void FrameView::setPagination(const Pagination& pagination) | |
| 2245 { | |
| 2246 if (m_pagination == pagination) | |
| 2247 return; | |
| 2248 | |
| 2249 m_pagination = pagination; | |
| 2250 m_frame->document()->styleResolverChanged(RecalcStyleDeferred); | |
| 2251 } | |
| 2252 | |
| 2253 IntRect FrameView::windowClipRect(bool clipToContents) const | 2178 IntRect FrameView::windowClipRect(bool clipToContents) const | 
| 2254 { | 2179 { | 
| 2255 ASSERT(m_frame->view() == this); | 2180 ASSERT(m_frame->view() == this); | 
| 2256 | 2181 | 
| 2257 if (paintsEntireContents()) | 2182 if (paintsEntireContents()) | 
| 2258 return IntRect(IntPoint(), contentsSize()); | 2183 return IntRect(IntPoint(), contentsSize()); | 
| 2259 | 2184 | 
| 2260 // Set our clip rect to be our contents. | 2185 // Set our clip rect to be our contents. | 
| 2261 IntRect clipRect = contentsToWindow(visibleContentRect(clipToContents ? Excl udeScrollbars : IncludeScrollbars)); | 2186 IntRect clipRect = contentsToWindow(visibleContentRect(clipToContents ? Excl udeScrollbars : IncludeScrollbars)); | 
| 2262 if (!m_frame->ownerElement()) | 2187 if (!m_frame->ownerElement()) | 
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3219 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation) | 3144 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation) | 
| 3220 { | 3145 { | 
| 3221 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); | 3146 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); | 
| 3222 if (AXObjectCache* cache = axObjectCache()) { | 3147 if (AXObjectCache* cache = axObjectCache()) { | 
| 3223 cache->remove(scrollbar); | 3148 cache->remove(scrollbar); | 
| 3224 cache->handleScrollbarUpdate(this); | 3149 cache->handleScrollbarUpdate(this); | 
| 3225 } | 3150 } | 
| 3226 } | 3151 } | 
| 3227 | 3152 | 
| 3228 } // namespace WebCore | 3153 } // namespace WebCore | 
| OLD | NEW |