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

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

Issue 926193003: Move rendering/RenderBox to layout/LayoutBox. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutObjectChildList.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) 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) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 if (current->hasLayer()) 551 if (current->hasLayer())
552 return toLayoutBoxModelObject(current)->layer(); 552 return toLayoutBoxModelObject(current)->layer();
553 } 553 }
554 // FIXME: we should get rid of detached render subtrees, at which point this code should 554 // FIXME: we should get rid of detached render subtrees, at which point this code should
555 // not be reached. crbug.com/411429 555 // not be reached. crbug.com/411429
556 return 0; 556 return 0;
557 } 557 }
558 558
559 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign ment& alignX, const ScrollAlignment& alignY) 559 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign ment& alignX, const ScrollAlignment& alignY)
560 { 560 {
561 RenderBox* enclosingBox = this->enclosingBox(); 561 LayoutBox* enclosingBox = this->enclosingBox();
562 if (!enclosingBox) 562 if (!enclosingBox)
563 return false; 563 return false;
564 564
565 enclosingBox->scrollRectToVisible(rect, alignX, alignY); 565 enclosingBox->scrollRectToVisible(rect, alignX, alignY);
566 return true; 566 return true;
567 } 567 }
568 568
569 RenderBox* LayoutObject::enclosingBox() const 569 LayoutBox* LayoutObject::enclosingBox() const
570 { 570 {
571 LayoutObject* curr = const_cast<LayoutObject*>(this); 571 LayoutObject* curr = const_cast<LayoutObject*>(this);
572 while (curr) { 572 while (curr) {
573 if (curr->isBox()) 573 if (curr->isBox())
574 return toRenderBox(curr); 574 return toLayoutBox(curr);
575 curr = curr->parent(); 575 curr = curr->parent();
576 } 576 }
577 577
578 ASSERT_NOT_REACHED(); 578 ASSERT_NOT_REACHED();
579 return 0; 579 return 0;
580 } 580 }
581 581
582 LayoutBoxModelObject* LayoutObject::enclosingBoxModelObject() const 582 LayoutBoxModelObject* LayoutObject::enclosingBoxModelObject() const
583 { 583 {
584 LayoutObject* curr = const_cast<LayoutObject*>(this); 584 LayoutObject* curr = const_cast<LayoutObject*>(this);
585 while (curr) { 585 while (curr) {
586 if (curr->isBoxModelObject()) 586 if (curr->isBoxModelObject())
587 return toLayoutBoxModelObject(curr); 587 return toLayoutBoxModelObject(curr);
588 curr = curr->parent(); 588 curr = curr->parent();
589 } 589 }
590 590
591 ASSERT_NOT_REACHED(); 591 ASSERT_NOT_REACHED();
592 return 0; 592 return 0;
593 } 593 }
594 594
595 RenderBox* LayoutObject::enclosingScrollableBox() const 595 LayoutBox* LayoutObject::enclosingScrollableBox() const
596 { 596 {
597 for (LayoutObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) { 597 for (LayoutObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) {
598 if (!ancestor->isBox()) 598 if (!ancestor->isBox())
599 continue; 599 continue;
600 600
601 RenderBox* ancestorBox = toRenderBox(ancestor); 601 LayoutBox* ancestorBox = toLayoutBox(ancestor);
602 if (ancestorBox->canBeScrolledAndHasScrollableArea()) 602 if (ancestorBox->canBeScrolledAndHasScrollableArea())
603 return ancestorBox; 603 return ancestorBox;
604 } 604 }
605 605
606 return 0; 606 return 0;
607 } 607 }
608 608
609 LayoutFlowThread* LayoutObject::locateFlowThreadContainingBlock() const 609 LayoutFlowThread* LayoutObject::locateFlowThreadContainingBlock() const
610 { 610 {
611 ASSERT(flowThreadState() != NotInsideFlowThread); 611 ASSERT(flowThreadState() != NotInsideFlowThread);
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 } 1385 }
1386 1386
1387 if (LayoutObject* o = parent()) { 1387 if (LayoutObject* o = parent()) {
1388 if (o->isRenderBlockFlow()) { 1388 if (o->isRenderBlockFlow()) {
1389 RenderBlock* cb = toRenderBlock(o); 1389 RenderBlock* cb = toRenderBlock(o);
1390 if (cb->hasColumns()) 1390 if (cb->hasColumns())
1391 cb->adjustRectForColumns(rect); 1391 cb->adjustRectForColumns(rect);
1392 } 1392 }
1393 1393
1394 if (o->hasOverflowClip()) { 1394 if (o->hasOverflowClip()) {
1395 RenderBox* boxParent = toRenderBox(o); 1395 LayoutBox* boxParent = toLayoutBox(o);
1396 boxParent->applyCachedClipAndScrollOffsetForPaintInvalidation(rect); 1396 boxParent->applyCachedClipAndScrollOffsetForPaintInvalidation(rect);
1397 if (rect.isEmpty()) 1397 if (rect.isEmpty())
1398 return; 1398 return;
1399 } 1399 }
1400 1400
1401 o->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, p aintInvalidationState); 1401 o->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, p aintInvalidationState);
1402 } 1402 }
1403 } 1403 }
1404 1404
1405 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*) 1405 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*)
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 // Keep layer hierarchy visibility bits up to date if visibility changes . 1706 // Keep layer hierarchy visibility bits up to date if visibility changes .
1707 if (m_style->visibility() != newStyle.visibility()) { 1707 if (m_style->visibility() != newStyle.visibility()) {
1708 // We might not have an enclosing layer yet because we might not be in the tree. 1708 // We might not have an enclosing layer yet because we might not be in the tree.
1709 if (Layer* layer = enclosingLayer()) 1709 if (Layer* layer = enclosingLayer())
1710 layer->potentiallyDirtyVisibleContentStatus(newStyle.visibility( )); 1710 layer->potentiallyDirtyVisibleContentStatus(newStyle.visibility( ));
1711 } 1711 }
1712 1712
1713 if (isFloating() && (m_style->floating() != newStyle.floating())) { 1713 if (isFloating() && (m_style->floating() != newStyle.floating())) {
1714 // For changes in float styles, we need to conceivably remove oursel ves 1714 // For changes in float styles, we need to conceivably remove oursel ves
1715 // from the floating objects list. 1715 // from the floating objects list.
1716 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); 1716 toLayoutBox(this)->removeFloatingOrPositionedChildFromBlockLists();
1717 } else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.p osition())) { 1717 } else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.p osition())) {
1718 // For changes in positioning styles, we need to conceivably remove ourselves 1718 // For changes in positioning styles, we need to conceivably remove ourselves
1719 // from the positioned objects list. 1719 // from the positioned objects list.
1720 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); 1720 toLayoutBox(this)->removeFloatingOrPositionedChildFromBlockLists();
1721 } 1721 }
1722 1722
1723 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned() 1723 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned()
1724 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition()) 1724 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition())
1725 && parent() && (parent()->isRenderBlockFlow() || parent()->isRenderI nline()); 1725 && parent() && (parent()->isRenderBlockFlow() || parent()->isRenderI nline());
1726 1726
1727 // Clearing these bits is required to avoid leaving stale renderers. 1727 // Clearing these bits is required to avoid leaving stale renderers.
1728 // FIXME: We shouldn't need that hack if our logic was totally correct. 1728 // FIXME: We shouldn't need that hack if our logic was totally correct.
1729 if (diff.needsLayout()) { 1729 if (diff.needsLayout()) {
1730 setFloating(false); 1730 setFloating(false);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 return; 1935 return;
1936 1936
1937 LayoutObject* o = parent(); 1937 LayoutObject* o = parent();
1938 if (!o) 1938 if (!o)
1939 return; 1939 return;
1940 1940
1941 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 1941 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called.
1942 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint()); 1942 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint());
1943 if (mode & ApplyContainerFlip && o->isBox()) { 1943 if (mode & ApplyContainerFlip && o->isBox()) {
1944 if (o->style()->isFlippedBlocksWritingMode()) 1944 if (o->style()->isFlippedBlocksWritingMode())
1945 transformState.move(toRenderBox(o)->flipForWritingModeIncludingColum ns(roundedLayoutPoint(transformState.mappedPoint())) - centerPoint); 1945 transformState.move(toLayoutBox(o)->flipForWritingModeIncludingColum ns(roundedLayoutPoint(transformState.mappedPoint())) - centerPoint);
1946 mode &= ~ApplyContainerFlip; 1946 mode &= ~ApplyContainerFlip;
1947 } 1947 }
1948 1948
1949 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped Point()))); 1949 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped Point())));
1950 1950
1951 if (o->hasOverflowClip()) 1951 if (o->hasOverflowClip())
1952 transformState.move(-toRenderBox(o)->scrolledContentOffset()); 1952 transformState.move(-toLayoutBox(o)->scrolledContentOffset());
1953 1953
1954 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed, paintInvalidationState); 1954 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed, paintInvalidationState);
1955 } 1955 }
1956 1956
1957 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 1957 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
1958 { 1958 {
1959 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this); 1959 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this);
1960 1960
1961 LayoutObject* container = parent(); 1961 LayoutObject* container = parent();
1962 if (!container) 1962 if (!container)
1963 return 0; 1963 return 0;
1964 1964
1965 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 1965 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called.
1966 LayoutSize offset; 1966 LayoutSize offset;
1967 if (container->hasOverflowClip()) 1967 if (container->hasOverflowClip())
1968 offset = -LayoutSize(toRenderBox(container)->scrolledContentOffset()); 1968 offset = -LayoutSize(toLayoutBox(container)->scrolledContentOffset());
1969 1969
1970 geometryMap.push(this, offset, hasColumns()); 1970 geometryMap.push(this, offset, hasColumns());
1971 1971
1972 return container; 1972 return container;
1973 } 1973 }
1974 1974
1975 void LayoutObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformSt ate& transformState) const 1975 void LayoutObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformSt ate& transformState) const
1976 { 1976 {
1977 LayoutObject* o = parent(); 1977 LayoutObject* o = parent();
1978 if (o) { 1978 if (o) {
1979 o->mapAbsoluteToLocalPoint(mode, transformState); 1979 o->mapAbsoluteToLocalPoint(mode, transformState);
1980 if (o->hasOverflowClip()) 1980 if (o->hasOverflowClip())
1981 transformState.move(toRenderBox(o)->scrolledContentOffset()); 1981 transformState.move(toLayoutBox(o)->scrolledContentOffset());
1982 } 1982 }
1983 } 1983 }
1984 1984
1985 bool LayoutObject::shouldUseTransformFromContainer(const LayoutObject* container Object) const 1985 bool LayoutObject::shouldUseTransformFromContainer(const LayoutObject* container Object) const
1986 { 1986 {
1987 // hasTransform() indicates whether the object has transform, transform-styl e or perspective. We just care about transform, 1987 // hasTransform() indicates whether the object has transform, transform-styl e or perspective. We just care about transform,
1988 // so check the layer's transform directly. 1988 // so check the layer's transform directly.
1989 return (hasLayer() && toLayoutBoxModelObject(this)->layer()->transform()) || (containerObject && containerObject->style()->hasPerspective()); 1989 return (hasLayer() && toLayoutBoxModelObject(this)->layer()->transform()) || (containerObject && containerObject->style()->hasPerspective());
1990 } 1990 }
1991 1991
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 return containerPoint; 2050 return containerPoint;
2051 } 2051 }
2052 2052
2053 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o, const Layout Point& point, bool* offsetDependsOnPoint) const 2053 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o, const Layout Point& point, bool* offsetDependsOnPoint) const
2054 { 2054 {
2055 ASSERT(o == container()); 2055 ASSERT(o == container());
2056 2056
2057 LayoutSize offset = o->columnOffset(point); 2057 LayoutSize offset = o->columnOffset(point);
2058 2058
2059 if (o->hasOverflowClip()) 2059 if (o->hasOverflowClip())
2060 offset -= toRenderBox(o)->scrolledContentOffset(); 2060 offset -= toLayoutBox(o)->scrolledContentOffset();
2061 2061
2062 if (offsetDependsOnPoint) 2062 if (offsetDependsOnPoint)
2063 *offsetDependsOnPoint = hasColumns() || o->isLayoutFlowThread(); 2063 *offsetDependsOnPoint = hasColumns() || o->isLayoutFlowThread();
2064 2064
2065 return offset; 2065 return offset;
2066 } 2066 }
2067 2067
2068 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* contain er) const 2068 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* contain er) const
2069 { 2069 {
2070 if (container == this) 2070 if (container == this)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 2105
2106 if (!hasLayer()) { 2106 if (!hasLayer()) {
2107 LayoutObject* container = this->container(); 2107 LayoutObject* container = this->container();
2108 currentLayer = container->enclosingLayer(); 2108 currentLayer = container->enclosingLayer();
2109 if (container && currentLayer->renderer() != container) { 2109 if (container && currentLayer->renderer() != container) {
2110 layerOffset.move(container->offsetFromAncestorContainer(currentLayer ->renderer())); 2110 layerOffset.move(container->offsetFromAncestorContainer(currentLayer ->renderer()));
2111 // If the layer itself is scrolled, we have to undo the subtraction of its scroll 2111 // If the layer itself is scrolled, we have to undo the subtraction of its scroll
2112 // offset since we want the offset relative to the scrolling content , not the 2112 // offset since we want the offset relative to the scrolling content , not the
2113 // element itself. 2113 // element itself.
2114 if (currentLayer->renderer()->hasOverflowClip()) 2114 if (currentLayer->renderer()->hasOverflowClip())
2115 layerOffset.move(currentLayer->renderBox()->scrolledContentOffse t()); 2115 layerOffset.move(currentLayer->layoutBox()->scrolledContentOffse t());
2116 } 2116 }
2117 } 2117 }
2118 2118
2119 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect ()); 2119 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect ());
2120 } 2120 }
2121 2121
2122 void LayoutObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Lay er* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRec t) const 2122 void LayoutObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Lay er* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRec t) const
2123 { 2123 {
2124 ASSERT(currentLayer); 2124 ASSERT(currentLayer);
2125 ASSERT(currentLayer == this->enclosingLayer()); 2125 ASSERT(currentLayer == this->enclosingLayer());
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 2778
2779 void LayoutObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) 2779 void LayoutObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions)
2780 { 2780 {
2781 // Convert the style regions to absolute coordinates. 2781 // Convert the style regions to absolute coordinates.
2782 if (style()->visibility() != VISIBLE || !isBox()) 2782 if (style()->visibility() != VISIBLE || !isBox())
2783 return; 2783 return;
2784 2784
2785 if (style()->getDraggableRegionMode() == DraggableRegionNone) 2785 if (style()->getDraggableRegionMode() == DraggableRegionNone)
2786 return; 2786 return;
2787 2787
2788 RenderBox* box = toRenderBox(this); 2788 LayoutBox* box = toLayoutBox(this);
2789 FloatRect localBounds(FloatPoint(), FloatSize(box->size())); 2789 FloatRect localBounds(FloatPoint(), FloatSize(box->size()));
2790 FloatRect absBounds = localToAbsoluteQuad(localBounds).boundingBox(); 2790 FloatRect absBounds = localToAbsoluteQuad(localBounds).boundingBox();
2791 2791
2792 AnnotatedRegionValue region; 2792 AnnotatedRegionValue region;
2793 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag; 2793 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag;
2794 region.bounds = LayoutRect(absBounds); 2794 region.bounds = LayoutRect(absBounds);
2795 regions.append(region); 2795 regions.append(region);
2796 } 2796 }
2797 2797
2798 void LayoutObject::collectAnnotatedRegions(Vector<AnnotatedRegionValue>& regions ) 2798 void LayoutObject::collectAnnotatedRegions(Vector<AnnotatedRegionValue>& regions )
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
3189 { 3189 {
3190 if (object1) { 3190 if (object1) {
3191 const blink::LayoutObject* root = object1; 3191 const blink::LayoutObject* root = object1;
3192 while (root->parent()) 3192 while (root->parent())
3193 root = root->parent(); 3193 root = root->parent();
3194 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3194 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3195 } 3195 }
3196 } 3196 }
3197 3197
3198 #endif 3198 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutObjectChildList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698