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

Side by Side Diff: Source/core/rendering/RenderView.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderView.h ('k') | Source/core/rendering/RenderWidget.cpp » ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (!ownerElement) 144 if (!ownerElement)
145 return 0; 145 return 0;
146 return ownerElement->renderBox(); 146 return ownerElement->renderBox();
147 } 147 }
148 148
149 void RenderView::addChild(RenderObject* newChild, RenderObject* beforeChild) 149 void RenderView::addChild(RenderObject* newChild, RenderObject* beforeChild)
150 { 150 {
151 // Seamless iframes are considered part of an enclosing render flow thread f rom the parent document. This is necessary for them to look 151 // Seamless iframes are considered part of an enclosing render flow thread f rom the parent document. This is necessary for them to look
152 // up regions in the parent document during layout. 152 // up regions in the parent document during layout.
153 if (newChild && !newChild->isRenderFlowThread()) { 153 if (newChild && !newChild->isRenderFlowThread()) {
154 RenderBox* seamlessBox = enclosingSeamlessRenderer(document()); 154 RenderBox* seamlessBox = enclosingSeamlessRenderer(&document());
155 if (seamlessBox && seamlessBox->flowThreadContainingBlock()) 155 if (seamlessBox && seamlessBox->flowThreadContainingBlock())
156 newChild->setFlowThreadState(seamlessBox->flowThreadState()); 156 newChild->setFlowThreadState(seamlessBox->flowThreadState());
157 } 157 }
158 RenderBlock::addChild(newChild, beforeChild); 158 RenderBlock::addChild(newChild, beforeChild);
159 } 159 }
160 160
161 bool RenderView::initializeLayoutState(LayoutState& state) 161 bool RenderView::initializeLayoutState(LayoutState& state)
162 { 162 {
163 bool isSeamlessAncestorInFlowThread = false; 163 bool isSeamlessAncestorInFlowThread = false;
164 164
165 // FIXME: May be better to push a clip and avoid issuing offscreen repaints. 165 // FIXME: May be better to push a clip and avoid issuing offscreen repaints.
166 state.m_clipped = false; 166 state.m_clipped = false;
167 167
168 // Check the writing mode of the seamless ancestor. It has to match our docu ment's writing mode, or we won't inherit any 168 // Check the writing mode of the seamless ancestor. It has to match our docu ment's writing mode, or we won't inherit any
169 // pagination information. 169 // pagination information.
170 RenderBox* seamlessAncestor = enclosingSeamlessRenderer(document()); 170 RenderBox* seamlessAncestor = enclosingSeamlessRenderer(&document());
171 LayoutState* seamlessLayoutState = seamlessAncestor ? seamlessAncestor->view ()->layoutState() : 0; 171 LayoutState* seamlessLayoutState = seamlessAncestor ? seamlessAncestor->view ()->layoutState() : 0;
172 bool shouldInheritPagination = seamlessLayoutState && !m_pageLogicalHeight & & seamlessAncestor->style()->writingMode() == style()->writingMode(); 172 bool shouldInheritPagination = seamlessLayoutState && !m_pageLogicalHeight & & seamlessAncestor->style()->writingMode() == style()->writingMode();
173 173
174 state.m_pageLogicalHeight = shouldInheritPagination ? seamlessLayoutState->m _pageLogicalHeight : m_pageLogicalHeight; 174 state.m_pageLogicalHeight = shouldInheritPagination ? seamlessLayoutState->m _pageLogicalHeight : m_pageLogicalHeight;
175 state.m_pageLogicalHeightChanged = shouldInheritPagination ? seamlessLayoutS tate->m_pageLogicalHeightChanged : m_pageLogicalHeightChanged; 175 state.m_pageLogicalHeightChanged = shouldInheritPagination ? seamlessLayoutS tate->m_pageLogicalHeightChanged : m_pageLogicalHeightChanged;
176 state.m_isPaginated = state.m_pageLogicalHeight; 176 state.m_isPaginated = state.m_pageLogicalHeight;
177 if (state.m_isPaginated && shouldInheritPagination) { 177 if (state.m_isPaginated && shouldInheritPagination) {
178 // Set up the correct pagination offset. We can use a negative offset in order to push the top of the RenderView into its correct place 178 // Set up the correct pagination offset. We can use a negative offset in order to push the top of the RenderView into its correct place
179 // on a page. We can take the iframe's offset from the logical top of th e first page and make the negative into the pagination offset within the child 179 // on a page. We can take the iframe's offset from the logical top of th e first page and make the negative into the pagination offset within the child
180 // view. 180 // view.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 // Do one last layout that should update the auto-height regions found in th e main flow 236 // Do one last layout that should update the auto-height regions found in th e main flow
237 // and solve pathological dependencies between regions (e.g. a non-auto-heig ht region depending 237 // and solve pathological dependencies between regions (e.g. a non-auto-heig ht region depending
238 // on an auto-height one). 238 // on an auto-height one).
239 if (needsLayout()) 239 if (needsLayout())
240 layoutContent(state); 240 layoutContent(state);
241 } 241 }
242 242
243 void RenderView::layout() 243 void RenderView::layout()
244 { 244 {
245 if (!document()->paginated()) 245 if (!document().paginated())
246 setPageLogicalHeight(0); 246 setPageLogicalHeight(0);
247 247
248 if (shouldUsePrintingLayout()) 248 if (shouldUsePrintingLayout())
249 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth() ; 249 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth() ;
250 250
251 SubtreeLayoutScope layoutScope(this); 251 SubtreeLayoutScope layoutScope(this);
252 252
253 // Use calcWidth/Height to get the new width/height, since this will take th e full page zoom factor into account. 253 // Use calcWidth/Height to get the new width/height, since this will take th e full page zoom factor into account.
254 bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView || width () != viewWidth() || height() != viewHeight()); 254 bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView || width () != viewWidth() || height() != viewHeight());
255 if (relayoutChildren) { 255 if (relayoutChildren) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 444 }
445 445
446 void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&) 446 void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)
447 { 447 {
448 // Check to see if we are enclosed by a layer that requires complex painting rules. If so, we cannot blit 448 // Check to see if we are enclosed by a layer that requires complex painting rules. If so, we cannot blit
449 // when scrolling, and we need to use slow repaints. Examples of layers tha t require this are transparent layers, 449 // when scrolling, and we need to use slow repaints. Examples of layers tha t require this are transparent layers,
450 // layers with reflections, or transformed layers. 450 // layers with reflections, or transformed layers.
451 // FIXME: This needs to be dynamic. We should be able to go back to blittin g if we ever stop being inside 451 // FIXME: This needs to be dynamic. We should be able to go back to blittin g if we ever stop being inside
452 // a transform, transparency layer, etc. 452 // a transform, transparency layer, etc.
453 Element* elt; 453 Element* elt;
454 for (elt = document()->ownerElement(); view() && elt && elt->renderer(); elt = elt->document()->ownerElement()) { 454 for (elt = document().ownerElement(); view() && elt && elt->renderer(); elt = elt->document().ownerElement()) {
455 RenderLayer* layer = elt->renderer()->enclosingLayer(); 455 RenderLayer* layer = elt->renderer()->enclosingLayer();
456 if (layer->cannotBlitToWindow()) { 456 if (layer->cannotBlitToWindow()) {
457 frameView()->setCannotBlitToWindow(); 457 frameView()->setCannotBlitToWindow();
458 break; 458 break;
459 } 459 }
460 460
461 if (RenderLayer* compositingLayer = layer->enclosingCompositingLayerForR epaint()) { 461 if (RenderLayer* compositingLayer = layer->enclosingCompositingLayerForR epaint()) {
462 frameView()->setCannotBlitToWindow(); 462 frameView()->setCannotBlitToWindow();
463 break; 463 break;
464 } 464 }
465 } 465 }
466 466
467 if (document()->ownerElement() || !view()) 467 if (document().ownerElement() || !view())
468 return; 468 return;
469 469
470 if (paintInfo.skipRootBackground()) 470 if (paintInfo.skipRootBackground())
471 return; 471 return;
472 472
473 bool rootFillsViewport = false; 473 bool rootFillsViewport = false;
474 bool rootObscuresBackground = false; 474 bool rootObscuresBackground = false;
475 Node* documentElement = document()->documentElement(); 475 Node* documentElement = document().documentElement();
476 if (RenderObject* rootRenderer = documentElement ? documentElement->renderer () : 0) { 476 if (RenderObject* rootRenderer = documentElement ? documentElement->renderer () : 0) {
477 // The document element's renderer is currently forced to be a block, bu t may not always be. 477 // The document element's renderer is currently forced to be a block, bu t may not always be.
478 RenderBox* rootBox = rootRenderer->isBox() ? toRenderBox(rootRenderer) : 0; 478 RenderBox* rootBox = rootRenderer->isBox() ? toRenderBox(rootRenderer) : 0;
479 rootFillsViewport = rootBox && !rootBox->x() && !rootBox->y() && rootBox ->width() >= width() && rootBox->height() >= height(); 479 rootFillsViewport = rootBox && !rootBox->x() && !rootBox->y() && rootBox ->width() >= width() && rootBox->height() >= height();
480 rootObscuresBackground = rendererObscuresBackground(rootRenderer); 480 rootObscuresBackground = rendererObscuresBackground(rootRenderer);
481 } 481 }
482 482
483 Page* page = document()->page(); 483 Page* page = document().page();
484 float pageScaleFactor = page ? page->pageScaleFactor() : 1; 484 float pageScaleFactor = page ? page->pageScaleFactor() : 1;
485 485
486 // If painting will entirely fill the view, no need to fill the background. 486 // If painting will entirely fill the view, no need to fill the background.
487 if (rootFillsViewport && rootObscuresBackground && pageScaleFactor >= 1) 487 if (rootFillsViewport && rootObscuresBackground && pageScaleFactor >= 1)
488 return; 488 return;
489 489
490 // This code typically only executes if the root element's visibility has be en set to hidden, 490 // This code typically only executes if the root element's visibility has be en set to hidden,
491 // if there is a transform on the <html>, or if there is a page scale factor less than 1. 491 // if there is a transform on the <html>, or if there is a page scale factor less than 1.
492 // Only fill with the base background color (typically white) if we're the r oot document, 492 // Only fill with the base background color (typically white) if we're the r oot document,
493 // since iframes/frames with no background in the child document should show the parent's background. 493 // since iframes/frames with no background in the child document should show the parent's background.
(...skipping 26 matching lines...) Expand all
520 return true; 520 return true;
521 } 521 }
522 522
523 void RenderView::repaintViewRectangle(const LayoutRect& ur) const 523 void RenderView::repaintViewRectangle(const LayoutRect& ur) const
524 { 524 {
525 if (!shouldRepaint(ur)) 525 if (!shouldRepaint(ur))
526 return; 526 return;
527 527
528 // We always just invalidate the root view, since we could be an iframe that is clipped out 528 // We always just invalidate the root view, since we could be an iframe that is clipped out
529 // or even invisible. 529 // or even invisible.
530 Element* elt = document()->ownerElement(); 530 Element* elt = document().ownerElement();
531 if (!elt) 531 if (!elt)
532 m_frameView->repaintContentRectangle(pixelSnappedIntRect(ur)); 532 m_frameView->repaintContentRectangle(pixelSnappedIntRect(ur));
533 else if (RenderBox* obj = elt->renderBox()) { 533 else if (RenderBox* obj = elt->renderBox()) {
534 LayoutRect vr = viewRect(); 534 LayoutRect vr = viewRect();
535 LayoutRect r = intersection(ur, vr); 535 LayoutRect r = intersection(ur, vr);
536 536
537 // Subtract out the contentsX and contentsY offsets to get our coords wi thin the viewing 537 // Subtract out the contentsX and contentsY offsets to get our coords wi thin the viewing
538 // rectangle. 538 // rectangle.
539 r.moveBy(-vr.location()); 539 r.moveBy(-vr.location());
540 540
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 { 607 {
608 if (!object) 608 if (!object)
609 return 0; 609 return 0;
610 610
611 RenderObject* child = object->childAt(offset); 611 RenderObject* child = object->childAt(offset);
612 return child ? child : object->nextInPreOrderAfterChildren(); 612 return child ? child : object->nextInPreOrderAfterChildren();
613 } 613 }
614 614
615 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const 615 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const
616 { 616 {
617 document()->updateStyleIfNeeded(); 617 document().updateStyleIfNeeded();
618 618
619 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap; 619 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap;
620 SelectionMap selectedObjects; 620 SelectionMap selectedObjects;
621 621
622 RenderObject* os = m_selectionStart; 622 RenderObject* os = m_selectionStart;
623 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos ); 623 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos );
624 while (os && os != stop) { 624 while (os && os != stop) {
625 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec tionEnd) && os->selectionState() != SelectionNone) { 625 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec tionEnd) && os->selectionState() != SelectionNone) {
626 // Blocks are responsible for painting line gaps and margin gaps. Th ey must be examined as well. 626 // Blocks are responsible for painting line gaps and margin gaps. Th ey must be examined as well.
627 selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToV isibleContent))); 627 selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToV isibleContent)));
(...skipping 21 matching lines...) Expand all
649 FloatQuad absQuad = repaintContainer->localToAbsoluteQuad(FloatRect( currRect)); 649 FloatQuad absQuad = repaintContainer->localToAbsoluteQuad(FloatRect( currRect));
650 currRect = absQuad.enclosingBoundingBox(); 650 currRect = absQuad.enclosingBoundingBox();
651 } 651 }
652 selRect.unite(currRect); 652 selRect.unite(currRect);
653 } 653 }
654 return pixelSnappedIntRect(selRect); 654 return pixelSnappedIntRect(selRect);
655 } 655 }
656 656
657 void RenderView::repaintSelection() const 657 void RenderView::repaintSelection() const
658 { 658 {
659 document()->updateStyleIfNeeded(); 659 document().updateStyleIfNeeded();
660 660
661 HashSet<RenderBlock*> processedBlocks; 661 HashSet<RenderBlock*> processedBlocks;
662 662
663 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ; 663 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ;
664 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) { 664 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) {
665 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd) 665 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd)
666 continue; 666 continue;
667 if (o->selectionState() == SelectionNone) 667 if (o->selectionState() == SelectionNone)
668 continue; 668 continue;
669 669
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 } 860 }
861 861
862 void RenderView::selectionStartEnd(int& startPos, int& endPos) const 862 void RenderView::selectionStartEnd(int& startPos, int& endPos) const
863 { 863 {
864 startPos = m_selectionStartPos; 864 startPos = m_selectionStartPos;
865 endPos = m_selectionEndPos; 865 endPos = m_selectionEndPos;
866 } 866 }
867 867
868 bool RenderView::printing() const 868 bool RenderView::printing() const
869 { 869 {
870 return document()->printing(); 870 return document().printing();
871 } 871 }
872 872
873 bool RenderView::shouldUsePrintingLayout() const 873 bool RenderView::shouldUsePrintingLayout() const
874 { 874 {
875 if (!printing() || !m_frameView) 875 if (!printing() || !m_frameView)
876 return false; 876 return false;
877 Frame* frame = m_frameView->frame(); 877 Frame* frame = m_frameView->frame();
878 return frame && frame->shouldUsePrintingLayout(); 878 return frame && frame->shouldUsePrintingLayout();
879 } 879 }
880 880
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 940
941 IntRect RenderView::unscaledDocumentRect() const 941 IntRect RenderView::unscaledDocumentRect() const
942 { 942 {
943 LayoutRect overflowRect(layoutOverflowRect()); 943 LayoutRect overflowRect(layoutOverflowRect());
944 flipForWritingMode(overflowRect); 944 flipForWritingMode(overflowRect);
945 return pixelSnappedIntRect(overflowRect); 945 return pixelSnappedIntRect(overflowRect);
946 } 946 }
947 947
948 bool RenderView::rootBackgroundIsEntirelyFixed() const 948 bool RenderView::rootBackgroundIsEntirelyFixed() const
949 { 949 {
950 RenderObject* rootObject = document()->documentElement() ? document()->docum entElement()->renderer() : 0; 950 RenderObject* rootObject = document().documentElement() ? document().documen tElement()->renderer() : 0;
951 if (!rootObject) 951 if (!rootObject)
952 return false; 952 return false;
953 953
954 RenderObject* rootRenderer = rootObject->rendererForRootBackground(); 954 RenderObject* rootRenderer = rootObject->rendererForRootBackground();
955 return rootRenderer->hasEntirelyFixedBackground(); 955 return rootRenderer->hasEntirelyFixedBackground();
956 } 956 }
957 957
958 LayoutRect RenderView::backgroundRect(RenderBox* backgroundRenderer) const 958 LayoutRect RenderView::backgroundRect(RenderBox* backgroundRenderer) const
959 { 959 {
960 if (!hasColumns()) 960 if (!hasColumns())
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 o = o->container(); 1032 o = o->container();
1033 } 1033 }
1034 return false; 1034 return false;
1035 } 1035 }
1036 1036
1037 void RenderView::updateHitTestResult(HitTestResult& result, const LayoutPoint& p oint) 1037 void RenderView::updateHitTestResult(HitTestResult& result, const LayoutPoint& p oint)
1038 { 1038 {
1039 if (result.innerNode()) 1039 if (result.innerNode())
1040 return; 1040 return;
1041 1041
1042 Node* node = document()->documentElement(); 1042 Node* node = document().documentElement();
1043 if (node) { 1043 if (node) {
1044 result.setInnerNode(node); 1044 result.setInnerNode(node);
1045 if (!result.innerNonSharedNode()) 1045 if (!result.innerNonSharedNode())
1046 result.setInnerNonSharedNode(node); 1046 result.setInnerNonSharedNode(node);
1047 1047
1048 LayoutPoint adjustedPoint = point; 1048 LayoutPoint adjustedPoint = point;
1049 offsetForContents(adjustedPoint); 1049 offsetForContents(adjustedPoint);
1050 1050
1051 result.setLocalPoint(adjustedPoint); 1051 result.setLocalPoint(adjustedPoint);
1052 } 1052 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 IntervalArena* RenderView::intervalArena() 1106 IntervalArena* RenderView::intervalArena()
1107 { 1107 {
1108 if (!m_intervalArena) 1108 if (!m_intervalArena)
1109 m_intervalArena = IntervalArena::create(); 1109 m_intervalArena = IntervalArena::create();
1110 return m_intervalArena.get(); 1110 return m_intervalArena.get();
1111 } 1111 }
1112 1112
1113 bool RenderView::backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const 1113 bool RenderView::backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const
1114 { 1114 {
1115 // FIXME: Remove this main frame check. Same concept applies to subframes to o. 1115 // FIXME: Remove this main frame check. Same concept applies to subframes to o.
1116 Page* page = document()->page(); 1116 Page* page = document().page();
1117 Frame* mainFrame = page ? page->mainFrame() : 0; 1117 Frame* mainFrame = page ? page->mainFrame() : 0;
1118 if (!m_frameView || m_frameView->frame() != mainFrame) 1118 if (!m_frameView || m_frameView->frame() != mainFrame)
1119 return false; 1119 return false;
1120 1120
1121 return m_frameView->hasOpaqueBackground(); 1121 return m_frameView->hasOpaqueBackground();
1122 } 1122 }
1123 1123
1124 FragmentationDisabler::FragmentationDisabler(RenderObject* root) 1124 FragmentationDisabler::FragmentationDisabler(RenderObject* root)
1125 { 1125 {
1126 RenderView* renderView = root->view(); 1126 RenderView* renderView = root->view();
(...skipping 26 matching lines...) Expand all
1153 #endif 1153 #endif
1154 1154
1155 if (layoutState) 1155 if (layoutState)
1156 layoutState->m_isPaginated = m_fragmenting; 1156 layoutState->m_isPaginated = m_fragmenting;
1157 1157
1158 if (m_flowThreadState != RenderObject::NotInsideFlowThread) 1158 if (m_flowThreadState != RenderObject::NotInsideFlowThread)
1159 m_root->setFlowThreadStateIncludingDescendants(m_flowThreadState); 1159 m_root->setFlowThreadStateIncludingDescendants(m_flowThreadState);
1160 } 1160 }
1161 1161
1162 } // namespace WebCore 1162 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderView.h ('k') | Source/core/rendering/RenderWidget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698