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

Unified Diff: Source/core/rendering/RenderBlockFlow.cpp

Issue 574143002: Center dialogs before computing overflow. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/RenderView.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlockFlow.cpp
diff --git a/Source/core/rendering/RenderBlockFlow.cpp b/Source/core/rendering/RenderBlockFlow.cpp
index 1a527c12c44c5cbc869da4a8407ae15c4f6d52cd..068627320dad05554a93bd69b39d3ba7dbdbe420 100644
--- a/Source/core/rendering/RenderBlockFlow.cpp
+++ b/Source/core/rendering/RenderBlockFlow.cpp
@@ -35,6 +35,7 @@
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
+#include "core/html/HTMLDialogElement.h"
#include "core/rendering/HitTestLocation.h"
#include "core/rendering/RenderFlowThread.h"
#include "core/rendering/RenderLayer.h"
@@ -382,6 +383,9 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren)
setShouldInvalidateOverflowForPaint(true);
}
+ if (isHTMLDialogElement(node()) && isOutOfFlowPositioned())
+ positionDialog();
+
clearNeedsLayout();
}
@@ -2911,4 +2915,34 @@ RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData()
return *m_rareData;
}
+void RenderBlockFlow::positionDialog()
+{
+ HTMLDialogElement* dialog = toHTMLDialogElement(node());
+ if (dialog->centeringMode() == HTMLDialogElement::NotCentered)
+ return;
+
+ bool canCenterDialog = (style()->position() == AbsolutePosition || style()->position() == FixedPosition)
+ && style()->hasAutoTopAndBottom();
+
+ if (dialog->centeringMode() == HTMLDialogElement::Centered) {
+ if (canCenterDialog)
+ setY(dialog->centeredPosition());
+ return;
+ }
+
+ ASSERT(dialog->centeringMode() == HTMLDialogElement::NeedsCentering);
+ if (!canCenterDialog) {
+ dialog->setNotCentered();
+ return;
+ }
+
+ FrameView* frameView = document().view();
+ LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scrollOffset().height();
+ int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height();
+ if (height() < visibleHeight)
+ top += (visibleHeight - height()) / 2;
+ setY(top);
+ dialog->setCentered(top);
+}
+
} // namespace blink
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/RenderView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698