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 619f9cf4c670d2e556b25b3dbf66708ee0bdb714..4c49a5be69e2a6aa5e5e2a988332c1bc37c5dfd7 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 |
@@ -40,7 +40,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. |
@@ -51,6 +51,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; |
+ |
// Calculated logical offset. It's never {@code nullopt} for a positioned |
// float. |
WTF::Optional<NGLogicalOffset> logical_offset; |
@@ -68,6 +93,7 @@ struct CORE_EXPORT NGFloatingObject : public RefCounted<NGFloatingObject> { |
// {@code left_offset} is calculated when we know to which parent this float |
// would be attached. |
ikilpatrick
2017/05/01 17:48:32
does this comment block need to be updated?
|
LayoutUnit left_offset; |
+ LayoutUnit top_offset; |
bool IsLeft() const { return exclusion_type == NGExclusion::kFloatLeft; } |