summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/layout/ng/ng_relative_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/ng/ng_relative_utils.h')
-rw-r--r--chromium/third_party/blink/renderer/core/layout/ng/ng_relative_utils.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/ng/ng_relative_utils.h b/chromium/third_party/blink/renderer/core/layout/ng/ng_relative_utils.h
index 1257d23f984..f930dec9012 100644
--- a/chromium/third_party/blink/renderer/core/layout/ng/ng_relative_utils.h
+++ b/chromium/third_party/blink/renderer/core/layout/ng/ng_relative_utils.h
@@ -7,13 +7,14 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_size.h"
+#include "third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h"
+#include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h"
+#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/text/text_direction.h"
namespace blink {
-class ComputedStyle;
class NGConstraintSpace;
-class NGPhysicalBoxFragment;
// Implements relative positioning:
// https://www.w3.org/TR/css-position-3/#rel-pos
@@ -32,6 +33,22 @@ CORE_EXPORT LogicalOffset
ComputeRelativeOffsetForInline(const NGConstraintSpace& space,
const ComputedStyle& child_style);
+// Un-apply any offset caused by relative positioning. When re-using a previous
+// fragment's offset (from the cache), we need to convert from "paint offset" to
+// "layout offset" before re-adding the fragment, in order to get overflow
+// calculation right.
+inline void RemoveRelativeOffset(const NGBoxFragmentBuilder& builder,
+ const NGPhysicalFragment& fragment,
+ LogicalOffset* offset) {
+ if (fragment.Style().GetPosition() != EPosition::kRelative)
+ return;
+ if (const auto* box_fragment = DynamicTo<NGPhysicalBoxFragment>(&fragment)) {
+ *offset -= ComputeRelativeOffsetForBoxFragment(
+ *box_fragment, builder.GetWritingDirection(),
+ builder.ChildAvailableSize());
+ }
+}
+
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_NG_RELATIVE_UTILS_H_