https://bugs.webkit.org/show_bug.cgi?id=184213
Reviewed by Antti Koivisto.
Display.Box already has the margin values.
* LayoutReloaded/FormattingContext/FloatingContext.js:
(FloatingContext.prototype._positionForFloating):
(FloatingContext.prototype._addFloatingBox):
(FloatingContext.prototype._mapMarginBoxToFormattingRoot):
(FloatingContext.prototype._formattingRoot):
* LayoutReloaded/FormattingContext/FormattingContext.js:
(FormattingContext.prototype.absoluteMarginBox): Deleted.
* LayoutReloaded/Utils.js:
(Utils.marginBox):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230136
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-03-31 Zalan Bujtas <zalan@apple.com>
+
+ [LayoutReloaded] Remove FormattingContext::absoluteMarginBox
+ https://bugs.webkit.org/show_bug.cgi?id=184213
+
+ Reviewed by Antti Koivisto.
+
+ Display.Box already has the margin values.
+
+ * LayoutReloaded/FormattingContext/FloatingContext.js:
+ (FloatingContext.prototype._positionForFloating):
+ (FloatingContext.prototype._addFloatingBox):
+ (FloatingContext.prototype._mapMarginBoxToFormattingRoot):
+ (FloatingContext.prototype._formattingRoot):
+ * LayoutReloaded/FormattingContext/FormattingContext.js:
+ (FormattingContext.prototype.absoluteMarginBox): Deleted.
+ * LayoutReloaded/Utils.js:
+ (Utils.marginBox):
+
2018-03-31 Zalan Bujtas <zalan@apple.com>
[layoutReloaded] Introduce margin to Display.Box
}
_positionForFloating(floatingBox) {
- let absoluteFloatingBox = this._formattingContext().absoluteMarginBox(floatingBox);
+ let absoluteFloatingBox = this._mapMarginBoxToFormattingRoot(floatingBox);
if (this._isEmpty())
return this._adjustedFloatingPosition(floatingBox, absoluteFloatingBox.top());
let verticalPosition = Math.max(absoluteFloatingBox.top(), this._lastFloating().top());
_addFloatingBox(layoutBox) {
// Convert floating box to absolute.
let clonedDisplayBox = this._formattingContext().displayBox(layoutBox).clone();
- clonedDisplayBox.setRect(this._formattingContext().absoluteMarginBox(layoutBox));
+ clonedDisplayBox.setRect(this._mapMarginBoxToFormattingRoot(layoutBox));
this._floatingState().addFloating(layoutBox, clonedDisplayBox);
}
+ _mapMarginBoxToFormattingRoot(layoutBox) {
+ let displayBox = this._formattingState().displayBox(layoutBox);
+ let rootDisplayBox = this._formattingState().displayBox(this._formattingRoot());
+ return Utils.marginBox(displayBox, rootDisplayBox);
+ }
+
_floatingState() {
return this.m_floatingState;
}
return this.m_parentFormattingContext;
}
+ _formattingRoot() {
+ return this._formattingState().formattingRoot();
+ }
+
_formattingState() {
return this._floatingState().formattingState();
}
return Utils.computedMarginRight(layoutBox.node());
}
- absoluteMarginBox(layoutBox) {
- let displayBox = this.displayBox(layoutBox);
- let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), displayBox.borderBox().size());
- absoluteRect.moveBy(new LayoutSize(-displayBox.marginLeft(), -displayBox.marginTop()));
- absoluteRect.growBy(new LayoutSize(displayBox.marginLeft() + displayBox.marginRight(), displayBox.marginTop() + displayBox.marginBottom()));
- return absoluteRect;
- }
-
absoluteBorderBox(layoutBox) {
let borderBox = this.displayBox(layoutBox).borderBox();
let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), borderBox.size());
return window.getComputedStyle(node).float == "left";
}
+ static marginBox(box, container) {
+ ASSERT(box instanceof Display.Box);
+ ASSERT(container instanceof Display.Box);
+
+ let marginBox = box.marginBox();
+ if (box == container)
+ return marginBox;
+ for (let ascendant = box.parent(); ascendant && ascendant != container; ascendant = ascendant.parent())
+ marginBox.moveBy(ascendant.topLeft());
+ return marginBox;
+ }
+
+
static textRuns(text, container) {
return window.collectTextRuns(text, container.node());
}