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

Side by Side Diff: Source/core/rendering/RenderView.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 unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderView.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "core/rendering/RenderView.h" 22 #include "core/rendering/RenderView.h"
23 23
24 #include "core/dom/Document.h" 24 #include "core/dom/Document.h"
25 #include "core/dom/Element.h" 25 #include "core/dom/Element.h"
26 #include "core/frame/LocalFrame.h" 26 #include "core/frame/LocalFrame.h"
27 #include "core/html/HTMLDialogElement.h"
28 #include "core/html/HTMLFrameOwnerElement.h" 27 #include "core/html/HTMLFrameOwnerElement.h"
29 #include "core/html/HTMLIFrameElement.h" 28 #include "core/html/HTMLIFrameElement.h"
30 #include "core/page/Page.h" 29 #include "core/page/Page.h"
31 #include "core/rendering/ColumnInfo.h" 30 #include "core/rendering/ColumnInfo.h"
32 #include "core/rendering/FlowThreadController.h" 31 #include "core/rendering/FlowThreadController.h"
33 #include "core/rendering/GraphicsContextAnnotator.h" 32 #include "core/rendering/GraphicsContextAnnotator.h"
34 #include "core/rendering/HitTestResult.h" 33 #include "core/rendering/HitTestResult.h"
35 #include "core/rendering/RenderFlowThread.h" 34 #include "core/rendering/RenderFlowThread.h"
36 #include "core/rendering/RenderGeometryMap.h" 35 #include "core/rendering/RenderGeometryMap.h"
37 #include "core/rendering/RenderLayer.h" 36 #include "core/rendering/RenderLayer.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (hasColumns()) 129 if (hasColumns())
131 return columnInfo()->columnHeight(); 130 return columnInfo()->columnHeight();
132 return RenderBlockFlow::availableLogicalHeight(heightType); 131 return RenderBlockFlow::availableLogicalHeight(heightType);
133 } 132 }
134 133
135 bool RenderView::isChildAllowed(RenderObject* child, RenderStyle*) const 134 bool RenderView::isChildAllowed(RenderObject* child, RenderStyle*) const
136 { 135 {
137 return child->isBox(); 136 return child->isBox();
138 } 137 }
139 138
140 static bool canCenterDialog(const RenderStyle* style)
141 {
142 return (style->position() == AbsolutePosition || style->position() == FixedP osition) && style->hasAutoTopAndBottom();
143 }
144
145 void RenderView::positionDialog(RenderBox* box)
146 {
147 HTMLDialogElement* dialog = toHTMLDialogElement(box->node());
148 if (dialog->centeringMode() == HTMLDialogElement::NotCentered)
149 return;
150 if (dialog->centeringMode() == HTMLDialogElement::Centered) {
151 if (canCenterDialog(box->style()))
152 box->setY(dialog->centeredPosition());
153 return;
154 }
155
156 ASSERT(dialog->centeringMode() == HTMLDialogElement::NeedsCentering);
157 if (!canCenterDialog(box->style())) {
158 dialog->setNotCentered();
159 return;
160 }
161 FrameView* frameView = document().view();
162 LayoutUnit top = (box->style()->position() == FixedPosition) ? 0 : frameView ->scrollOffset().height();
163 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
164 if (box->height() < visibleHeight)
165 top += (visibleHeight - box->height()) / 2;
166 box->setY(top);
167 dialog->setCentered(top);
168 }
169
170 void RenderView::positionDialogs()
171 {
172 TrackedRendererListHashSet* positionedDescendants = positionedObjects();
173 if (!positionedDescendants)
174 return;
175 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
176 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
177 RenderBox* box = *it;
178 if (isHTMLDialogElement(box->node()))
179 positionDialog(box);
180 }
181 }
182
183 void RenderView::layoutContent() 139 void RenderView::layoutContent()
184 { 140 {
185 ASSERT(needsLayout()); 141 ASSERT(needsLayout());
186 142
187 RenderBlockFlow::layout(); 143 RenderBlockFlow::layout();
188 144
189 positionDialogs();
190
191 #if ENABLE(ASSERT) 145 #if ENABLE(ASSERT)
192 checkLayoutState(); 146 checkLayoutState();
193 #endif 147 #endif
194 } 148 }
195 149
196 #if ENABLE(ASSERT) 150 #if ENABLE(ASSERT)
197 void RenderView::checkLayoutState() 151 void RenderView::checkLayoutState()
198 { 152 {
199 ASSERT(!m_layoutState->next()); 153 ASSERT(!m_layoutState->next());
200 } 154 }
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 return viewWidth(IncludeScrollbars) / scale; 964 return viewWidth(IncludeScrollbars) / scale;
1011 } 965 }
1012 966
1013 double RenderView::layoutViewportHeight() const 967 double RenderView::layoutViewportHeight() const
1014 { 968 {
1015 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; 969 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1;
1016 return viewHeight(IncludeScrollbars) / scale; 970 return viewHeight(IncludeScrollbars) / scale;
1017 } 971 }
1018 972
1019 } // namespace blink 973 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderView.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698