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

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: Make sticky vertical ref tests expectations not dependent on font size. Created 4 years, 8 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;
157 void updateStickyPositionConstraints() const;
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 LayoutBlock* containingBlockForAutoHeightDetection(Length logicalHeight) con st; 337 LayoutBlock* containingBlockForAutoHeightDetection(Length logicalHeight) con st;
322 338
323 void addOutlineRectsForNormalChildren(Vector<LayoutRect>&, const LayoutPoint & additionalOffset, IncludeBlockVisualOverflowOrNot) const; 339 void addOutlineRectsForNormalChildren(Vector<LayoutRect>&, const LayoutPoint & additionalOffset, IncludeBlockVisualOverflowOrNot) const;
324 void addOutlineRectsForDescendant(const LayoutObject& descendant, Vector<Lay outRect>&, const LayoutPoint& additionalOffset, IncludeBlockVisualOverflowOrNot) const; 340 void addOutlineRectsForDescendant(const LayoutObject& descendant, Vector<Lay outRect>&, const LayoutPoint& additionalOffset, IncludeBlockVisualOverflowOrNot) const;
325 341
326 void addLayerHitTestRects(LayerHitTestRects&, const PaintLayer*, const Layou tPoint&, const LayoutRect&) const override; 342 void addLayerHitTestRects(LayerHitTestRects&, const PaintLayer*, const Layou tPoint&, const LayoutRect&) const override;
327 343
328 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid e; 344 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid e;
329 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override ; 345 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override ;
330 346
347 void invalidateStickyConstraints();
348
331 public: 349 public:
332 // These functions are only used internally to manipulate the layout tree st ructure via remove/insert/appendChildNode. 350 // These functions are only used internally to manipulate the layout tree st ructure via remove/insert/appendChildNode.
333 // Since they are typically called only to move objects around within anonym ous blocks (which only have layers in 351 // Since they are typically called only to move objects around within anonym ous blocks (which only have layers in
334 // the case of column spans), the default for fullRemoveInsert is false rath er than true. 352 // the case of column spans), the default for fullRemoveInsert is false rath er than true.
335 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child , LayoutObject* beforeChild, bool fullRemoveInsert = false); 353 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child , LayoutObject* beforeChild, bool fullRemoveInsert = false);
336 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child , bool fullRemoveInsert = false) 354 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child , bool fullRemoveInsert = false)
337 { 355 {
338 moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert); 356 moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert);
339 } 357 }
340 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, bool fullRemo veInsert = false) 358 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, bool fullRemo veInsert = false)
(...skipping 11 matching lines...) Expand all
352 moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInse rt); 370 moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInse rt);
353 } 371 }
354 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe moveInsert = false); 372 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe moveInsert = false);
355 373
356 private: 374 private:
357 void createLayer(PaintLayerType); 375 void createLayer(PaintLayerType);
358 376
359 LayoutUnit computedCSSPadding(const Length&) const; 377 LayoutUnit computedCSSPadding(const Length&) const;
360 bool isBoxModelObject() const final { return true; } 378 bool isBoxModelObject() const final { return true; }
361 379
380 LayoutBoxModelObjectRareData& ensureRareData()
381 {
382 if (!m_rareData)
383 m_rareData = adoptPtr(new LayoutBoxModelObjectRareData());
384 return *m_rareData.get();
385 }
386
362 // The PaintLayer associated with this object. 387 // The PaintLayer associated with this object.
363 // |m_layer| can be nullptr depending on the return value of layerTypeRequir ed(). 388 // |m_layer| can be nullptr depending on the return value of layerTypeRequir ed().
364 OwnPtr<PaintLayer> m_layer; 389 OwnPtr<PaintLayer> m_layer;
390
391 OwnPtr<LayoutBoxModelObjectRareData> m_rareData;
365 }; 392 };
366 393
367 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); 394 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject());
368 395
369 } // namespace blink 396 } // namespace blink
370 397
371 #endif // LayoutBoxModelObject_h 398 #endif // LayoutBoxModelObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698