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

Side by Side Diff: sky/engine/core/rendering/RenderBox.cpp

Issue 953673002: Delete RenderLayerModelObject. (Closed) Base URL: git@github.com:domokit/mojo.git@master
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
« no previous file with comments | « sky/engine/core/rendering/RenderBox.h ('k') | sky/engine/core/rendering/RenderBoxModelObject.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) 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 , m_maxPreferredLogicalWidth(-1) 60 , m_maxPreferredLogicalWidth(-1)
61 { 61 {
62 setIsBox(); 62 setIsBox();
63 } 63 }
64 64
65 void RenderBox::willBeDestroyed() 65 void RenderBox::willBeDestroyed()
66 { 66 {
67 clearOverrideSize(); 67 clearOverrideSize();
68 RenderBlock::removePercentHeightDescendantIfNeeded(this); 68 RenderBlock::removePercentHeightDescendantIfNeeded(this);
69 RenderBoxModelObject::willBeDestroyed(); 69 RenderBoxModelObject::willBeDestroyed();
70 destroyLayer();
71 }
72
73 void RenderBox::destroyLayer()
74 {
75 setHasLayer(false);
76 m_layer = nullptr;
77 }
78
79 void RenderBox::createLayer(LayerType type)
80 {
81 ASSERT(!m_layer);
82 m_layer = adoptPtr(new RenderLayer(this, type));
83 setHasLayer(true);
84 m_layer->insertOnlyThisLayer();
85 }
86
87 bool RenderBox::hasSelfPaintingLayer() const
88 {
89 return m_layer && m_layer->isSelfPaintingLayer();
70 } 90 }
71 91
72 void RenderBox::removeFloatingOrPositionedChildFromBlockLists() 92 void RenderBox::removeFloatingOrPositionedChildFromBlockLists()
73 { 93 {
74 ASSERT(isFloatingOrOutOfFlowPositioned()); 94 ASSERT(isFloatingOrOutOfFlowPositioned());
75 95
76 if (documentBeingDestroyed()) 96 if (documentBeingDestroyed())
77 return; 97 return;
78 98
79 if (isOutOfFlowPositioned()) 99 if (isOutOfFlowPositioned())
80 RenderBlock::removePositionedObject(this); 100 RenderBlock::removePositionedObject(this);
81 } 101 }
82 102
83 void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle& newStyl e) 103 void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle& newStyl e)
84 { 104 {
85 RenderStyle* oldStyle = style(); 105 RenderStyle* oldStyle = style();
86 if (oldStyle) { 106 if (oldStyle && parent()) {
87 // When a layout hint happens and an object's position style changes, we have to do a layout 107 // When a layout hint happens and an object's position style changes, we have to do a layout
88 // to dirty the render tree using the old position value now. 108 // to dirty the render tree using the old position value now.
89 if (diff.needsFullLayout() && parent() && oldStyle->position() != newSty le.position()) { 109 if (diff.needsFullLayout() && oldStyle->position() != newStyle.position( )) {
90 markContainingBlocksForLayout(); 110 markContainingBlocksForLayout();
91 if (newStyle.hasOutOfFlowPosition()) 111 if (newStyle.hasOutOfFlowPosition())
92 parent()->setChildNeedsLayout(); 112 parent()->setChildNeedsLayout();
93 } 113 }
114
115 if (oldStyle->hasAutoClip() != newStyle.hasAutoClip()
116 || oldStyle->clip() != newStyle.clip())
117 layer()->clipper().clearClipRectsIncludingDescendants();
94 } 118 }
95 119
96 RenderBoxModelObject::styleWillChange(diff, newStyle); 120 RenderBoxModelObject::styleWillChange(diff, newStyle);
97 } 121 }
98 122
99 void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle ) 123 void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle )
100 { 124 {
101 RenderBoxModelObject::styleDidChange(diff, oldStyle); 125 bool hadTransform = hasTransform();
126
127 RenderObject::styleDidChange(diff, oldStyle);
128 updateFromStyle();
129
130 LayerType type = layerTypeRequired();
131 if (type != NoLayer) {
132 if (!layer()) {
133 createLayer(type);
134 if (parent() && !needsLayout()) {
135 // FIXME: We should call a specialized version of this function.
136 layer()->updateLayerPositionsAfterLayout();
137 }
138 }
139 } else if (layer() && layer()->parent()) {
140 setHasTransform(false); // Either a transform wasn't specified or the ob ject doesn't support transforms, so just null out the bit.
141 layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_l ayer
142 if (hadTransform)
143 setNeedsLayoutAndPrefWidthsRecalc();
144 }
145
146 if (layer()) {
147 // FIXME: Ideally we shouldn't need this setter but we can't easily infe r an overflow-only layer
148 // from the style.
149 layer()->setLayerType(type);
150 layer()->styleChanged(diff, oldStyle);
151 }
102 152
103 if (needsLayout() && oldStyle) 153 if (needsLayout() && oldStyle)
104 RenderBlock::removePercentHeightDescendantIfNeeded(this); 154 RenderBlock::removePercentHeightDescendantIfNeeded(this);
105 } 155 }
106 156
157 // TODO(ojan): Inline this into styleDidChange,
107 void RenderBox::updateFromStyle() 158 void RenderBox::updateFromStyle()
108 { 159 {
109 RenderBoxModelObject::updateFromStyle();
110
111 RenderStyle* styleToUse = style(); 160 RenderStyle* styleToUse = style();
112 161
162 setHasBoxDecorationBackground(hasBackground() || styleToUse->hasBorder() || styleToUse->boxShadow());
163 setInline(styleToUse->isDisplayInlineType());
164 setPositionState(styleToUse->position());
165
113 if (isRenderView()) { 166 if (isRenderView()) {
167 // TODO(ojan): Merge this into the same call above.
114 setHasBoxDecorationBackground(true); 168 setHasBoxDecorationBackground(true);
115 } else if (isRenderBlock()) { 169 } else if (isRenderBlock()) {
116 // TODO(esprehn): Why do we not want to set this on the RenderView? 170 // TODO(esprehn): Why do we not want to set this on the RenderView?
117 setHasOverflowClip(!styleToUse->isOverflowVisible()); 171 setHasOverflowClip(!styleToUse->isOverflowVisible());
118 } 172 }
119 173
120 setHasTransform(styleToUse->hasTransformRelatedProperty()); 174 setHasTransform(styleToUse->hasTransformRelatedProperty());
121 } 175 }
122 176
123 void RenderBox::layout() 177 void RenderBox::layout()
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 rect.move(absPos.x(), absPos.y()); 274 rect.move(absPos.x(), absPos.y());
221 return rect; 275 return rect;
222 } 276 }
223 277
224 FloatQuad RenderBox::absoluteContentQuad() const 278 FloatQuad RenderBox::absoluteContentQuad() const
225 { 279 {
226 LayoutRect rect = contentBoxRect(); 280 LayoutRect rect = contentBoxRect();
227 return localToAbsoluteQuad(FloatRect(rect)); 281 return localToAbsoluteQuad(FloatRect(rect));
228 } 282 }
229 283
230 void RenderBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& add itionalOffset, const RenderLayerModelObject*) const 284 void RenderBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& add itionalOffset, const RenderBox*) const
231 { 285 {
232 if (!size().isEmpty()) 286 if (!size().isEmpty())
233 rects.append(pixelSnappedIntRect(additionalOffset, size())); 287 rects.append(pixelSnappedIntRect(additionalOffset, size()));
234 } 288 }
235 289
236 bool RenderBox::needsPreferredWidthsRecalculation() const 290 bool RenderBox::needsPreferredWidthsRecalculation() const
237 { 291 {
238 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen t(); 292 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen t();
239 } 293 }
240 294
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 height -= borderAndPaddingLogicalHeight(); 403 height -= borderAndPaddingLogicalHeight();
350 return std::max<LayoutUnit>(0, height); 404 return std::max<LayoutUnit>(0, height);
351 } 405 }
352 406
353 bool RenderBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result , const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffs et) 407 bool RenderBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result , const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffs et)
354 { 408 {
355 LayoutPoint adjustedLocation = accumulatedOffset + location(); 409 LayoutPoint adjustedLocation = accumulatedOffset + location();
356 410
357 // Check kids first. 411 // Check kids first.
358 for (RenderObject* child = slowLastChild(); child; child = child->previousSi bling()) { 412 for (RenderObject* child = slowLastChild(); child; child = child->previousSi bling()) {
359 if ((!child->hasLayer() || !toRenderLayerModelObject(child)->layer()->is SelfPaintingLayer()) && child->nodeAtPoint(request, result, locationInContainer, adjustedLocation)) { 413 if ((!child->hasLayer() || !toRenderBox(child)->layer()->isSelfPaintingL ayer()) && child->nodeAtPoint(request, result, locationInContainer, adjustedLoca tion)) {
360 updateHitTestResult(result, locationInContainer.point() - toLayoutSi ze(adjustedLocation)); 414 updateHitTestResult(result, locationInContainer.point() - toLayoutSi ze(adjustedLocation));
361 return true; 415 return true;
362 } 416 }
363 } 417 }
364 418
365 // Check our bounds next. 419 // Check our bounds next.
366 LayoutRect boundsRect = borderBoxRect(); 420 LayoutRect boundsRect = borderBoxRect();
367 boundsRect.moveBy(adjustedLocation); 421 boundsRect.moveBy(adjustedLocation);
368 if (visibleToHitTestRequest(request) && locationInContainer.intersects(bound sRect)) { 422 if (visibleToHitTestRequest(request) && locationInContainer.intersects(bound sRect)) {
369 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a djustedLocation)); 423 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a djustedLocation));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 if (childZOffset > *zOffset) { 489 if (childZOffset > *zOffset) {
436 *zOffset = childZOffset; 490 *zOffset = childZOffset;
437 return true; 491 return true;
438 } 492 }
439 return false; 493 return false;
440 } 494 }
441 495
442 return true; 496 return true;
443 } 497 }
444 498
445 static inline bool reverseCompareZIndex(RenderLayerModelObject* first, RenderLay erModelObject* second) 499 static inline bool reverseCompareZIndex(RenderBox* first, RenderBox* second)
446 { 500 {
447 return first->style()->zIndex() > second->style()->zIndex(); 501 return first->style()->zIndex() > second->style()->zIndex();
448 } 502 }
449 503
450 // hitTestLocation and hitTestRect are relative to rootLayer. 504 // hitTestLocation and hitTestRect are relative to rootLayer.
451 // A 'flattening' layer is one preserves3D() == false. 505 // A 'flattening' layer is one preserves3D() == false.
452 // transformState.m_accumulatedTransform holds the transform from the containing flattening layer. 506 // transformState.m_accumulatedTransform holds the transform from the containing flattening layer.
453 // transformState.m_lastPlanarPoint is the hitTestLocation in the plane of the c ontaining flattening layer. 507 // transformState.m_lastPlanarPoint is the hitTestLocation in the plane of the c ontaining flattening layer.
454 // transformState.m_lastPlanarQuad is the hitTestRect as a quad in the plane of the containing flattening layer. 508 // transformState.m_lastPlanarQuad is the hitTestRect as a quad in the plane of the containing flattening layer.
455 // 509 //
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he ight())); 1102 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he ight()));
1049 1103
1050 return clipRect; 1104 return clipRect;
1051 } 1105 }
1052 1106
1053 LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHei ghtType heightType) const 1107 LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHei ghtType heightType) const
1054 { 1108 {
1055 return containingBlock()->availableLogicalHeight(heightType); 1109 return containingBlock()->availableLogicalHeight(heightType);
1056 } 1110 }
1057 1111
1058 void RenderBox::mapLocalToContainer(const RenderLayerModelObject* paintInvalidat ionContainer, TransformState& transformState, MapCoordinatesFlags mode) const 1112 void RenderBox::mapLocalToContainer(const RenderBox* paintInvalidationContainer, TransformState& transformState, MapCoordinatesFlags mode) const
1059 { 1113 {
1060 if (paintInvalidationContainer == this) 1114 if (paintInvalidationContainer == this)
1061 return; 1115 return;
1062 1116
1063 bool containerSkipped; 1117 bool containerSkipped;
1064 RenderObject* o = container(paintInvalidationContainer, &containerSkipped); 1118 RenderObject* o = container(paintInvalidationContainer, &containerSkipped);
1065 if (!o) 1119 if (!o)
1066 return; 1120 return;
1067 1121
1068 LayoutSize containerOffset = offsetFromContainer(o, roundedLayoutPoint(trans formState.mappedPoint())); 1122 LayoutSize containerOffset = offsetFromContainer(o, roundedLayoutPoint(trans formState.mappedPoint()));
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 3008
2955 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 3009 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
2956 { 3010 {
2957 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); 3011 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor);
2958 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 3012 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
2959 ASSERT(hasBackground == style.hasBackground()); 3013 ASSERT(hasBackground == style.hasBackground());
2960 hasBorder = style.hasBorder(); 3014 hasBorder = style.hasBorder();
2961 } 3015 }
2962 3016
2963 } // namespace blink 3017 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBox.h ('k') | sky/engine/core/rendering/RenderBoxModelObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698