| OLD | NEW |
| 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 Loading... |
| 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_staticTop); |
| 47 if (style()->position() == RelativePosition) |
| 48 containingBlock()->setLogicalTopForChild(this, m_staticTop, ApplyLay
outDelta); |
| 49 } |
| 43 RenderBlock::layout(); | 50 RenderBlock::layout(); |
| 44 | 51 |
| 45 RenderStyle* styleToUse = style(); | 52 RenderStyle* styleToUse = style(); |
| 46 if (styleToUse->position() != AbsolutePosition || !styleToUse->top().isAuto(
) || !styleToUse->bottom().isAuto()) { | 53 if (!(styleToUse->position() == AbsolutePosition && styleToUse->top().isAuto
() && styleToUse->bottom().isAuto()) && |
| 54 styleToUse->position() != RelativePosition) { |
| 47 statePusher.pop(); | 55 statePusher.pop(); |
| 48 return; | 56 return; |
| 49 } | 57 } |
| 50 | 58 |
| 51 // Adjust the dialog's position to be centered in or at the top of the viewp
ort. | 59 if (!hadLayout) { |
| 52 // FIXME: Figure out what to do in vertical writing mode. | 60 FrameView* frameView = document()->view(); |
| 53 FrameView* frameView = document()->view(); | 61 int scrollTop = frameView->scrollOffset().height(); |
| 54 int scrollTop = frameView->scrollOffset().height(); | 62 FloatPoint absolutePoint(0, scrollTop); |
| 55 FloatPoint absolutePoint(0, scrollTop); | 63 int visibleHeight = frameView->visibleContentRect(ScrollableArea::Includ
eScrollbars).height(); |
| 56 int visibleHeight = frameView->visibleContentRect(ScrollableArea::IncludeScr
ollbars).height(); | 64 if (height() < visibleHeight) |
| 57 if (height() < visibleHeight) | 65 absolutePoint.move(0, (visibleHeight - height()) / 2); |
| 58 absolutePoint.move(0, (visibleHeight - height()) / 2); | 66 FloatPoint localPoint = absolutePoint; |
| 59 FloatPoint localPoint = containingBlock()->absoluteToLocal(absolutePoint); | 67 LayoutUnit localTop = LayoutSize(localPoint.x(), localPoint.y()).height(
); |
| 60 LayoutUnit localTop = LayoutSize(localPoint.x(), localPoint.y()).height(); | |
| 61 setY(localTop); | |
| 62 | 68 |
| 69 m_staticTop = localTop; |
| 70 if (styleToUse->position() == AbsolutePosition) |
| 71 layer()->setStaticBlockPosition(m_staticTop); |
| 72 else if (styleToUse->position() == RelativePosition) |
| 73 containingBlock()->setLogicalTopForChild(this, m_staticTop, ApplyLay
outDelta); |
| 74 setNeedsLayout(true); |
| 75 RenderBlock::layout(); |
| 76 } |
| 63 statePusher.pop(); | 77 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). | 78 // 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(); | 79 repainter.repaintAfterLayout(); |
| 66 } | 80 } |
| 67 | 81 |
| 68 } | 82 } |
| 69 | 83 |
| 70 #endif | 84 #endif |
| OLD | NEW |