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

Side by Side Diff: Source/core/layout/LayoutBox.cpp

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase to master Created 5 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Size of border belt for autoscroll. When mouse pointer in border belt, 84 // Size of border belt for autoscroll. When mouse pointer in border belt,
85 // autoscroll is started. 85 // autoscroll is started.
86 static const int autoscrollBeltSize = 20; 86 static const int autoscrollBeltSize = 20;
87 static const unsigned backgroundObscurationTestMaxDepth = 4; 87 static const unsigned backgroundObscurationTestMaxDepth = 4;
88 88
89 static bool skipBodyBackground(const LayoutBox* bodyElementRenderer) 89 static bool skipBodyBackground(const LayoutBox* bodyElementRenderer)
90 { 90 {
91 ASSERT(bodyElementRenderer->isBody()); 91 ASSERT(bodyElementRenderer->isBody());
92 // The <body> only paints its background if the root element has defined a b ackground independent of the body, 92 // The <body> only paints its background if the root element has defined a b ackground independent of the body,
93 // or if the <body>'s parent is not the document element's renderer (e.g. in side SVG foreignObject). 93 // or if the <body>'s parent is not the document element's renderer (e.g. in side SVG foreignObject).
94 LayoutObject* documentElementRenderer = bodyElementRenderer->document().docu mentElement()->renderer(); 94 LayoutObject* documentElementRenderer = bodyElementRenderer->document().docu mentElement()->layoutObject();
95 return documentElementRenderer 95 return documentElementRenderer
96 && !documentElementRenderer->hasBackground() 96 && !documentElementRenderer->hasBackground()
97 && (documentElementRenderer == bodyElementRenderer->parent()); 97 && (documentElementRenderer == bodyElementRenderer->parent());
98 } 98 }
99 99
100 LayoutBox::LayoutBox(ContainerNode* node) 100 LayoutBox::LayoutBox(ContainerNode* node)
101 : LayoutBoxModelObject(node) 101 : LayoutBoxModelObject(node)
102 , m_intrinsicContentLogicalHeight(-1) 102 , m_intrinsicContentLogicalHeight(-1)
103 , m_minPreferredLogicalWidth(-1) 103 , m_minPreferredLogicalWidth(-1)
104 , m_maxPreferredLogicalWidth(-1) 104 , m_maxPreferredLogicalWidth(-1)
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 489 }
490 490
491 if (hasOverflowClip() && !restrictedByLineClamp) { 491 if (hasOverflowClip() && !restrictedByLineClamp) {
492 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. 492 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property.
493 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. 493 // This will prevent us from revealing text hidden by the slider in Safa ri RSS.
494 newRect = layer()->scrollableArea()->exposeRect(rect, alignX, alignY); 494 newRect = layer()->scrollableArea()->exposeRect(rect, alignX, alignY);
495 } else if (!parentBox && canBeProgramaticallyScrolled()) { 495 } else if (!parentBox && canBeProgramaticallyScrolled()) {
496 if (FrameView* frameView = this->frameView()) { 496 if (FrameView* frameView = this->frameView()) {
497 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); 497 HTMLFrameOwnerElement* ownerElement = document().ownerElement();
498 498
499 if (ownerElement && ownerElement->renderer()) { 499 if (ownerElement && ownerElement->layoutObject()) {
500 HTMLFrameElementBase* frameElementBase = isHTMLFrameElementBase( *ownerElement) ? toHTMLFrameElementBase(ownerElement) : 0; 500 HTMLFrameElementBase* frameElementBase = isHTMLFrameElementBase( *ownerElement) ? toHTMLFrameElementBase(ownerElement) : 0;
501 if (frameElementAndViewPermitScroll(frameElementBase, frameView) ) { 501 if (frameElementAndViewPermitScroll(frameElementBase, frameView) ) {
502 LayoutRect viewRect(frameView->visibleContentRect()); 502 LayoutRect viewRect(frameView->visibleContentRect());
503 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(vie wRect, rect, alignX, alignY); 503 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(vie wRect, rect, alignX, alignY);
504 504
505 double xOffset = exposeRect.x(); 505 double xOffset = exposeRect.x();
506 double yOffset = exposeRect.y(); 506 double yOffset = exposeRect.y();
507 // Adjust offsets if they're outside of the allowable range. 507 // Adjust offsets if they're outside of the allowable range.
508 xOffset = std::max(0.0, std::min<double>(frameView->contents Width(), xOffset)); 508 xOffset = std::max(0.0, std::min<double>(frameView->contents Width(), xOffset));
509 yOffset = std::max(0.0, std::min<double>(frameView->contents Height(), yOffset)); 509 yOffset = std::max(0.0, std::min<double>(frameView->contents Height(), yOffset));
510 510
511 frameView->setScrollPosition(DoublePoint(xOffset, yOffset)); 511 frameView->setScrollPosition(DoublePoint(xOffset, yOffset));
512 if (frameView->safeToPropagateScrollToParent()) { 512 if (frameView->safeToPropagateScrollToParent()) {
513 parentBox = ownerElement->renderer()->enclosingBox(); 513 parentBox = ownerElement->layoutObject()->enclosingBox() ;
514 // FIXME: This doesn't correctly convert the rect to 514 // FIXME: This doesn't correctly convert the rect to
515 // absolute coordinates in the parent. 515 // absolute coordinates in the parent.
516 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x()); 516 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x());
517 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y()); 517 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y());
518 } else { 518 } else {
519 parentBox = 0; 519 parentBox = 0;
520 } 520 }
521 } 521 }
522 } else { 522 } else {
523 if (frame()->settings()->pinchVirtualViewportEnabled()) { 523 if (frame()->settings()->pinchVirtualViewportEnabled()) {
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 else if (windowAutoscrollPoint.y() > windowBox.maxY() - autoscrollBeltSize) 820 else if (windowAutoscrollPoint.y() > windowBox.maxY() - autoscrollBeltSize)
821 windowAutoscrollPoint.move(0, autoscrollBeltSize); 821 windowAutoscrollPoint.move(0, autoscrollBeltSize);
822 822
823 return windowAutoscrollPoint - windowPoint; 823 return windowAutoscrollPoint - windowPoint;
824 } 824 }
825 825
826 LayoutBox* LayoutBox::findAutoscrollable(LayoutObject* renderer) 826 LayoutBox* LayoutBox::findAutoscrollable(LayoutObject* renderer)
827 { 827 {
828 while (renderer && !(renderer->isBox() && toLayoutBox(renderer)->canAutoscro ll())) { 828 while (renderer && !(renderer->isBox() && toLayoutBox(renderer)->canAutoscro ll())) {
829 if (!renderer->parent() && renderer->node() == renderer->document() && r enderer->document().ownerElement()) 829 if (!renderer->parent() && renderer->node() == renderer->document() && r enderer->document().ownerElement())
830 renderer = renderer->document().ownerElement()->renderer(); 830 renderer = renderer->document().ownerElement()->layoutObject();
831 else 831 else
832 renderer = renderer->parent(); 832 renderer = renderer->parent();
833 } 833 }
834 834
835 return renderer && renderer->isBox() ? toLayoutBox(renderer) : 0; 835 return renderer && renderer->isBox() ? toLayoutBox(renderer) : 0;
836 } 836 }
837 837
838 static inline int adjustedScrollDelta(int beginningDelta) 838 static inline int adjustedScrollDelta(int beginningDelta)
839 { 839 {
840 // This implemention matches Firefox's. 840 // This implemention matches Firefox's.
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 paintInvalidationLayerRectsForImage(image, style()->maskLayers(), false) ; 1374 paintInvalidationLayerRectsForImage(image, style()->maskLayers(), false) ;
1375 } 1375 }
1376 1376
1377 bool LayoutBox::paintInvalidationLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground) 1377 bool LayoutBox::paintInvalidationLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground)
1378 { 1378 {
1379 Vector<LayoutObject*> layerRenderers; 1379 Vector<LayoutObject*> layerRenderers;
1380 1380
1381 // A background of the body or document must extend to the total visible siz e of the document. This means the union of the 1381 // A background of the body or document must extend to the total visible siz e of the document. This means the union of the
1382 // view and document bounds, since it can be the case that the view is large r than the document and vice-versa. 1382 // view and document bounds, since it can be the case that the view is large r than the document and vice-versa.
1383 // http://dev.w3.org/csswg/css-backgrounds/#the-background 1383 // http://dev.w3.org/csswg/css-backgrounds/#the-background
1384 if (drawingBackground && (isDocumentElement() || (isBody() && !document().do cumentElement()->renderer()->hasBackground()))) { 1384 if (drawingBackground && (isDocumentElement() || (isBody() && !document().do cumentElement()->layoutObject()->hasBackground()))) {
1385 layerRenderers.append(document().documentElement()->renderer()); 1385 layerRenderers.append(document().documentElement()->layoutObject());
1386 layerRenderers.append(view()); 1386 layerRenderers.append(view());
1387 if (view()->frameView()) 1387 if (view()->frameView())
1388 view()->frameView()->setNeedsFullPaintInvalidation(); 1388 view()->frameView()->setNeedsFullPaintInvalidation();
1389 } else { 1389 } else {
1390 layerRenderers.append(this); 1390 layerRenderers.append(this);
1391 } 1391 }
1392 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) { 1392 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) {
1393 if (curLayer->image() && image == curLayer->image()->data() && curLayer- >image()->canRender(*this, style()->effectiveZoom())) { 1393 if (curLayer->image() && image == curLayer->image()->data() && curLayer- >image()->canRender(*this, style()->effectiveZoom())) {
1394 for (LayoutObject* layerRenderer : layerRenderers) 1394 for (LayoutObject* layerRenderer : layerRenderers)
1395 layerRenderer->setShouldDoFullPaintInvalidation(); 1395 layerRenderer->setShouldDoFullPaintInvalidation();
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 computeMarginsForDirection(flowDirection, cb, containingBlockLogicalWidt hForContent(), computedValues.m_extent, computedValues.m_margins.m_before, 2343 computeMarginsForDirection(flowDirection, cb, containingBlockLogicalWidt hForContent(), computedValues.m_extent, computedValues.m_margins.m_before,
2344 computedValues.m_margins.m_after, style()->marginBefore(), style()-> marginAfter()); 2344 computedValues.m_margins.m_after, style()->marginBefore(), style()-> marginAfter());
2345 } 2345 }
2346 2346
2347 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo de. The <body> always fills the 2347 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo de. The <body> always fills the
2348 // <html> block in quirks mode. Only apply this quirk if the block is norma l flow and no height 2348 // <html> block in quirks mode. Only apply this quirk if the block is norma l flow and no height
2349 // is specified. When we're printing, we also need this quirk if the body or root has a percentage 2349 // is specified. When we're printing, we also need this quirk if the body or root has a percentage
2350 // height since we don't set a height in LayoutView when we're printing. So without this quirk, the 2350 // height since we don't set a height in LayoutView when we're printing. So without this quirk, the
2351 // height has nothing to be a percentage of, and it ends up being 0. That is bad. 2351 // height has nothing to be a percentage of, and it ends up being 0. That is bad.
2352 bool paginatedContentNeedsBaseHeight = document().printing() && h.isPercent( ) 2352 bool paginatedContentNeedsBaseHeight = document().printing() && h.isPercent( )
2353 && (isDocumentElement() || (isBody() && document().documentElement()->re nderer()->style()->logicalHeight().isPercent())) && !isInline(); 2353 && (isDocumentElement() || (isBody() && document().documentElement()->la youtObject()->style()->logicalHeight().isPercent())) && !isInline();
2354 if (stretchesToViewport() || paginatedContentNeedsBaseHeight) { 2354 if (stretchesToViewport() || paginatedContentNeedsBaseHeight) {
2355 LayoutUnit margins = collapsedMarginBefore() + collapsedMarginAfter(); 2355 LayoutUnit margins = collapsedMarginBefore() + collapsedMarginAfter();
2356 LayoutUnit visibleHeight = view()->viewLogicalHeightForPercentages(); 2356 LayoutUnit visibleHeight = view()->viewLogicalHeightForPercentages();
2357 if (isDocumentElement()) { 2357 if (isDocumentElement()) {
2358 computedValues.m_extent = std::max(computedValues.m_extent, visibleH eight - margins); 2358 computedValues.m_extent = std::max(computedValues.m_extent, visibleH eight - margins);
2359 } else { 2359 } else {
2360 LayoutUnit marginsBordersPadding = margins + parentBox()->marginBefo re() + parentBox()->marginAfter() + parentBox()->borderAndPaddingLogicalHeight() ; 2360 LayoutUnit marginsBordersPadding = margins + parentBox()->marginBefo re() + parentBox()->marginAfter() + parentBox()->borderAndPaddingLogicalHeight() ;
2361 computedValues.m_extent = std::max(computedValues.m_extent, visibleH eight - marginsBordersPadding); 2361 computedValues.m_extent = std::max(computedValues.m_extent, visibleH eight - marginsBordersPadding);
2362 } 2362 }
2363 } 2363 }
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after
4641 } 4641 }
4642 4642
4643 void LayoutBox::invalidateDisplayItemClients(DisplayItemList* displayItemList) c onst 4643 void LayoutBox::invalidateDisplayItemClients(DisplayItemList* displayItemList) c onst
4644 { 4644 {
4645 LayoutBoxModelObject::invalidateDisplayItemClients(displayItemList); 4645 LayoutBoxModelObject::invalidateDisplayItemClients(displayItemList);
4646 if (LayerScrollableArea* area = scrollableArea()) 4646 if (LayerScrollableArea* area = scrollableArea())
4647 displayItemList->invalidate(area->displayItemClient()); 4647 displayItemList->invalidate(area->displayItemClient());
4648 } 4648 }
4649 4649
4650 } // namespace blink 4650 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698