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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.h

Issue 1308273010: Adapt and reland old position sticky implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Store ancestor overflow layer on PaintLayer to compute before other dependent compositing inputs. Created 4 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
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 * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 * 21 *
22 */ 22 */
23 23
24 #ifndef LayoutBoxModelObject_h 24 #ifndef LayoutBoxModelObject_h
25 #define LayoutBoxModelObject_h 25 #define LayoutBoxModelObject_h
26 26
27 #include "core/CoreExport.h" 27 #include "core/CoreExport.h"
28 #include "core/layout/LayoutObject.h" 28 #include "core/layout/LayoutObject.h"
29 #include "core/page/scrolling/StickyPositionScrollingConstraints.h"
29 #include "core/style/ShadowData.h" 30 #include "core/style/ShadowData.h"
30 #include "platform/geometry/LayoutRect.h" 31 #include "platform/geometry/LayoutRect.h"
31 32
32 namespace blink { 33 namespace blink {
33 34
34 class LineLayoutBoxModel; 35 class LineLayoutBoxModel;
35 class PaintLayer; 36 class PaintLayer;
36 class PaintLayerScrollableArea; 37 class PaintLayerScrollableArea;
37 38
38 enum PaintLayerType { 39 enum PaintLayerType {
(...skipping 18 matching lines...) Expand all
57 }; 58 };
58 59
59 enum ContentChangeType { 60 enum ContentChangeType {
60 ImageChanged, 61 ImageChanged,
61 CanvasChanged, 62 CanvasChanged,
62 CanvasContextChanged 63 CanvasContextChanged
63 }; 64 };
64 65
65 class InlineFlowBox; 66 class InlineFlowBox;
66 67
68 struct LayoutBoxModelObjectRareData {
69 WTF_MAKE_NONCOPYABLE(LayoutBoxModelObjectRareData);
70 USING_FAST_MALLOC(LayoutBoxModelObjectRareData);
71 public:
72 LayoutBoxModelObjectRareData() {}
73
74 StickyPositionScrollingConstraints m_stickyPositionScrollingConstraints;
75 };
76
67 // This class is the base class for all CSS objects. 77 // This class is the base class for all CSS objects.
68 // 78 //
69 // All CSS objects follow the box model object. See THE BOX MODEL section in 79 // All CSS objects follow the box model object. See THE BOX MODEL section in
70 // LayoutBox for more information. 80 // LayoutBox for more information.
71 // 81 //
72 // This class actually doesn't have the box model but it exposes some common 82 // This class actually doesn't have the box model but it exposes some common
73 // functions or concepts that sub-classes can extend upon. For example, there 83 // functions or concepts that sub-classes can extend upon. For example, there
74 // are accessors for margins, borders, paddings and borderBoundingBox(). 84 // are accessors for margins, borders, paddings and borderBoundingBox().
75 // 85 //
76 // The reason for this partial implementation is that the 2 classes inheriting 86 // The reason for this partial implementation is that the 2 classes inheriting
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 public: 144 public:
135 LayoutBoxModelObject(ContainerNode*); 145 LayoutBoxModelObject(ContainerNode*);
136 ~LayoutBoxModelObject() override; 146 ~LayoutBoxModelObject() override;
137 147
138 // This is the only way layers should ever be destroyed. 148 // This is the only way layers should ever be destroyed.
139 void destroyLayer(); 149 void destroyLayer();
140 150
141 LayoutSize relativePositionOffset() const; 151 LayoutSize relativePositionOffset() const;
142 LayoutSize relativePositionLogicalOffset() const { return style()->isHorizon talWritingMode() ? relativePositionOffset() : relativePositionOffset().transpose dSize(); } 152 LayoutSize relativePositionLogicalOffset() const { return style()->isHorizon talWritingMode() ? relativePositionOffset() : relativePositionOffset().transpose dSize(); }
143 153
154 // Populates StickyPositionConstraints, setting the sticky box rect, contain ing block rect and updating
155 // the constraint offsets according to the available space.
156 FloatRect computeStickyConstrainingRect(const PaintLayer* ancestorOverflowLa yer) const;
157 void updateStickyPositionConstraints(PaintLayer* ancestorOverflowLayer) cons t;
158 LayoutSize stickyPositionOffset() const;
159
144 LayoutSize offsetForInFlowPosition() const; 160 LayoutSize offsetForInFlowPosition() const;
145 161
146 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin es (LayoutFlow) 162 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin es (LayoutFlow)
147 // to return the remaining width on a given line (and the height of a single line). 163 // to return the remaining width on a given line (and the height of a single line).
148 virtual LayoutUnit offsetLeft() const; 164 virtual LayoutUnit offsetLeft() const;
149 virtual LayoutUnit offsetTop() const; 165 virtual LayoutUnit offsetTop() const;
150 virtual LayoutUnit offsetWidth() const = 0; 166 virtual LayoutUnit offsetWidth() const = 0;
151 virtual LayoutUnit offsetHeight() const = 0; 167 virtual LayoutUnit offsetHeight() const = 0;
152 168
153 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); } 169 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 290
275 void contentChanged(ContentChangeType); 291 void contentChanged(ContentChangeType);
276 bool hasAcceleratedCompositing() const; 292 bool hasAcceleratedCompositing() const;
277 293
278 void computeLayerHitTestRects(LayerHitTestRects&) const override; 294 void computeLayerHitTestRects(LayerHitTestRects&) const override;
279 295
280 // Returns true if the background is painted opaque in the given rect. 296 // Returns true if the background is painted opaque in the given rect.
281 // The query rect is given in local coordinate system. 297 // The query rect is given in local coordinate system.
282 virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { re turn false; } 298 virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { re turn false; }
283 299
300 void invalidateScrollAncestorConstraints();
301
284 void invalidateTreeIfNeeded(PaintInvalidationState&) override; 302 void invalidateTreeIfNeeded(PaintInvalidationState&) override;
285 303
286 // Indicate that the contents of this layoutObject need to be repainted. Onl y has an effect if compositing is being used, 304 // Indicate that the contents of this layoutObject need to be repainted. Onl y has an effect if compositing is being used,
287 void setBackingNeedsPaintInvalidationInRect(const LayoutRect&, PaintInvalida tionReason) const; // r is in the coordinate space of this layout object 305 void setBackingNeedsPaintInvalidationInRect(const LayoutRect&, PaintInvalida tionReason) const; // r is in the coordinate space of this layout object
288 306
289 void invalidateDisplayItemClientOnBacking(const DisplayItemClient&, PaintInv alidationReason) const; 307 void invalidateDisplayItemClientOnBacking(const DisplayItemClient&, PaintInv alidationReason) const;
290 308
291 // http://www.w3.org/TR/css3-background/#body-background 309 // http://www.w3.org/TR/css3-background/#body-background
292 // <html> root element with no background steals background from its first < body> child. 310 // <html> root element with no background steals background from its first < body> child.
293 // The used background for such body element should be the initial value. (i .e. transparent) 311 // The used background for such body element should be the initial value. (i .e. transparent)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 373
356 enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffective Zoom }; 374 enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffective Zoom };
357 LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const; 375 LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const;
358 376
359 private: 377 private:
360 void createLayer(PaintLayerType); 378 void createLayer(PaintLayerType);
361 379
362 LayoutUnit computedCSSPadding(const Length&) const; 380 LayoutUnit computedCSSPadding(const Length&) const;
363 bool isBoxModelObject() const final { return true; } 381 bool isBoxModelObject() const final { return true; }
364 382
383 LayoutBoxModelObjectRareData& ensureRareData()
384 {
385 if (!m_rareData)
386 m_rareData = adoptPtr(new LayoutBoxModelObjectRareData());
387 return *m_rareData.get();
388 }
389
365 // The PaintLayer associated with this object. 390 // The PaintLayer associated with this object.
366 // |m_layer| can be nullptr depending on the return value of layerTypeRequir ed(). 391 // |m_layer| can be nullptr depending on the return value of layerTypeRequir ed().
367 OwnPtr<PaintLayer> m_layer; 392 OwnPtr<PaintLayer> m_layer;
393
394 OwnPtr<LayoutBoxModelObjectRareData> m_rareData;
368 }; 395 };
369 396
370 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); 397 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject());
371 398
372 } // namespace blink 399 } // namespace blink
373 400
374 #endif // LayoutBoxModelObject_h 401 #endif // LayoutBoxModelObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698