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

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_floating_object.h

Issue 2850893003: Add container_block_offset,top_offset to NGFloatingObject. (Closed)
Patch Set: update TestExpectations Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/ng_floating_object.h
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_floating_object.h b/third_party/WebKit/Source/core/layout/ng/ng_floating_object.h
index c7b5a503ddb00af02e09d999d0edafb1558d8029..8d0f50439cf50c92c012f36138b30ce8a66b3b17 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_floating_object.h
+++ b/third_party/WebKit/Source/core/layout/ng/ng_floating_object.h
@@ -39,7 +39,7 @@ struct CORE_EXPORT NGFloatingObject : public RefCounted<NGFloatingObject> {
// NGLayoutOpportunityIterator to position this floating object.
NGLogicalSize available_size;
- // To correctly position a float we need 2 offsets:
+ // To correctly **position** a float we need 2 offsets:
// - origin_offset which represents the layout point for this float.
// - from_offset which represents the point from where we need to calculate
// the relative logical offset for this float.
@@ -50,6 +50,31 @@ struct CORE_EXPORT NGFloatingObject : public RefCounted<NGFloatingObject> {
NGLogicalOffset origin_offset;
NGLogicalOffset from_offset;
+ // To correctly **paint** a float we need to know the BFC offset of the
+ // container to which we are attaching this float. It's used to calculate
+ // {@code left_offset}, {@code top_offset}.
+ // In most situations {@code (left|top)_offset} equals to float's logical
+ // offset except the cases where a float needs to be re-attached to a non-zero
+ // height parent.
+ //
+ // Example:
+ // <body>
+ // <p style="height: 60px">Example</p>
+ // <div id="zero-height-div"><float></div>
+ //
+ // Here the float's logical offset is 0 relative to its #zero-height-div
+ // parent. Because of the "zero height" div this float is re-attached to the
+ // 1st non-empty parent => body. To paint this float correctly we provide the
+ // modified {@code (top|left)_offset} which is relative to the float's new
+ // parent.
+ // I.e. for our example {@code top_offset} == #zero-height-div's BFC offset
+ // - body's BFC offset + float's logical offset
+ //
+ // For code safety reasons {@code container_block_offset} is Optional here
+ // because the block's offset can be only determined before the actual float's
+ // placement event.
+ WTF::Optional<LayoutUnit> container_block_offset;
ikilpatrick 2017/05/09 22:45:23 is a better name for the bfc_block_offset? contain
Gleb Lanbin 2017/05/09 23:12:07 renamed to parent_bfc_block_offset
+
// Writing mode of the float's constraint space.
NGWritingMode writing_mode;

Powered by Google App Engine
This is Rietveld 408576698