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

Unified Diff: Source/WebCore/rendering/RenderDialog.cpp

Issue 13792002: Fix <dialog> centering (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: get working for relpos Created 7 years, 8 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: Source/WebCore/rendering/RenderDialog.cpp
diff --git a/Source/WebCore/rendering/RenderDialog.cpp b/Source/WebCore/rendering/RenderDialog.cpp
index b8f3d198574f083664500983f180aa2d93850e9d..2619a3a3277d08f5997335c97c6c5c8d7ee7ef8a 100644
--- a/Source/WebCore/rendering/RenderDialog.cpp
+++ b/Source/WebCore/rendering/RenderDialog.cpp
@@ -40,26 +40,40 @@ void RenderDialog::layout()
LayoutRepainter repainter(*this, true);
LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
+ bool hadLayout = everHadLayout();
+ if (hadLayout) {
+ if (layer())
+ layer()->setStaticBlockPosition(m_staticTop);
+ if (style()->position() == RelativePosition)
+ containingBlock()->setLogicalTopForChild(this, m_staticTop, ApplyLayoutDelta);
+ }
RenderBlock::layout();
RenderStyle* styleToUse = style();
- if (styleToUse->position() != AbsolutePosition || !styleToUse->top().isAuto() || !styleToUse->bottom().isAuto()) {
+ if (!(styleToUse->position() == AbsolutePosition && styleToUse->top().isAuto() && styleToUse->bottom().isAuto()) &&
+ styleToUse->position() != RelativePosition) {
statePusher.pop();
return;
}
- // Adjust the dialog's position to be centered in or at the top of the viewport.
- // FIXME: Figure out what to do in vertical writing mode.
- FrameView* frameView = document()->view();
- int scrollTop = frameView->scrollOffset().height();
- FloatPoint absolutePoint(0, scrollTop);
- int visibleHeight = frameView->visibleContentRect(ScrollableArea::IncludeScrollbars).height();
- if (height() < visibleHeight)
- absolutePoint.move(0, (visibleHeight - height()) / 2);
- FloatPoint localPoint = containingBlock()->absoluteToLocal(absolutePoint);
- LayoutUnit localTop = LayoutSize(localPoint.x(), localPoint.y()).height();
- setY(localTop);
+ if (!hadLayout) {
+ FrameView* frameView = document()->view();
+ int scrollTop = frameView->scrollOffset().height();
+ FloatPoint absolutePoint(0, scrollTop);
+ int visibleHeight = frameView->visibleContentRect(ScrollableArea::IncludeScrollbars).height();
+ if (height() < visibleHeight)
+ absolutePoint.move(0, (visibleHeight - height()) / 2);
+ FloatPoint localPoint = absolutePoint;
+ LayoutUnit localTop = LayoutSize(localPoint.x(), localPoint.y()).height();
+ m_staticTop = localTop;
+ if (styleToUse->position() == AbsolutePosition)
+ layer()->setStaticBlockPosition(m_staticTop);
+ else if (styleToUse->position() == RelativePosition)
+ containingBlock()->setLogicalTopForChild(this, m_staticTop, ApplyLayoutDelta);
+ setNeedsLayout(true);
+ RenderBlock::layout();
+ }
statePusher.pop();
// FIXME: Since there is always a layer here, repainter shouldn't be necessary. But without it, the dialog is sometimes not painted (see bug 90670).
repainter.repaintAfterLayout();
« Source/WebCore/rendering/RenderBlock.cpp ('K') | « Source/WebCore/rendering/RenderDialog.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698