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

Side by Side Diff: Source/WebCore/rendering/RenderDialog.cpp

Issue 13792002: Fix <dialog> centering (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 22 matching lines...) Expand all
33 #include "RenderView.h" 33 #include "RenderView.h"
34 34
35 namespace WebCore { 35 namespace WebCore {
36 36
37 void RenderDialog::layout() 37 void RenderDialog::layout()
38 { 38 {
39 StackStats::LayoutCheckPoint layoutCheckPoint; 39 StackStats::LayoutCheckPoint layoutCheckPoint;
40 LayoutRepainter repainter(*this, true); 40 LayoutRepainter repainter(*this, true);
41 LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransfo rm() || hasReflection() || style()->isFlippedBlocksWritingMode()); 41 LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransfo rm() || hasReflection() || style()->isFlippedBlocksWritingMode());
42 42
43 bool hadLayout = everHadLayout();
44 if (hadLayout) {
45 if (layer())
46 layer()->setStaticBlockPosition(m_staticBlockPos);
47 }
43 RenderBlock::layout(); 48 RenderBlock::layout();
44 49
45 RenderStyle* styleToUse = style(); 50 RenderStyle* styleToUse = style();
46 if (styleToUse->position() != AbsolutePosition || !styleToUse->top().isAuto( ) || !styleToUse->bottom().isAuto()) { 51 if ((styleToUse->position() != AbsolutePosition && styleToUse->position() != RelativePosition) || !styleToUse->top().isAuto() || !styleToUse->bottom().isAut o()) {
47 statePusher.pop(); 52 statePusher.pop();
48 return; 53 return;
49 } 54 }
50 55
51 // Adjust the dialog's position to be centered in or at the top of the viewp ort. 56 if (!hadLayout) {
52 // FIXME: Figure out what to do in vertical writing mode. 57 FrameView* frameView = document()->view();
53 FrameView* frameView = document()->view(); 58 int scrollTop = frameView->scrollOffset().height();
54 int scrollTop = frameView->scrollOffset().height(); 59 FloatPoint absolutePoint(0, scrollTop);
55 FloatPoint absolutePoint(0, scrollTop); 60 int visibleHeight = frameView->visibleContentRect(ScrollableArea::Includ eScrollbars).height();
56 int visibleHeight = frameView->visibleContentRect(ScrollableArea::IncludeScr ollbars).height(); 61 if (height() < visibleHeight)
57 if (height() < visibleHeight) 62 absolutePoint.move(0, (visibleHeight - height()) / 2);
58 absolutePoint.move(0, (visibleHeight - height()) / 2); 63 FloatPoint localPoint = containingBlock()->absoluteToLocal(absolutePoint );
59 FloatPoint localPoint = containingBlock()->absoluteToLocal(absolutePoint); 64 LayoutUnit localTop = LayoutSize(localPoint.x(), localPoint.y()).height( );
60 LayoutUnit localTop = LayoutSize(localPoint.x(), localPoint.y()).height();
61 setY(localTop);
62 65
66 m_staticBlockPos = localTop;
67 layer()->setStaticBlockPosition(m_staticBlockPos);
68 setNeedsLayout(true);
69 RenderBlock::layout();
70 } else {
71 ASSERT(layer()->staticBlockPosition() == m_staticBlockPos);
72 }
63 statePusher.pop(); 73 statePusher.pop();
64 // FIXME: Since there is always a layer here, repainter shouldn't be necessa ry. But without it, the dialog is sometimes not painted (see bug 90670).
65 repainter.repaintAfterLayout(); 74 repainter.repaintAfterLayout();
66 } 75 }
67 76
68 } 77 }
69 78
70 #endif 79 #endif
OLDNEW
« Source/WebCore/dom/NodeRenderingContext.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