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

Side by Side Diff: third_party/WebKit/Source/core/page/SpatialNavigation.cpp

Issue 1672973002: ScrollableArea::pixelsPerLine should return viewport pixels in use-zoom-for-dsf mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) 2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org> 3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org>
4 * 4 *
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (!frameView) 152 if (!frameView)
153 return true; 153 return true;
154 154
155 ASSERT(!frameView->needsLayout()); 155 ASSERT(!frameView->needsLayout());
156 156
157 LayoutRect containerViewportRect(frameView->visibleContentRect()); 157 LayoutRect containerViewportRect(frameView->visibleContentRect());
158 // We want to select a node if it is currently off screen, but will be 158 // We want to select a node if it is currently off screen, but will be
159 // exposed after we scroll. Adjust the viewport to post-scrolling position. 159 // exposed after we scroll. Adjust the viewport to post-scrolling position.
160 // If the container has overflow:hidden, we cannot scroll, so we do not pass direction 160 // If the container has overflow:hidden, we cannot scroll, so we do not pass direction
161 // and we do not adjust for scrolling. 161 // and we do not adjust for scrolling.
162 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frameView->hostWin dow());
162 switch (type) { 163 switch (type) {
163 case WebFocusTypeLeft: 164 case WebFocusTypeLeft:
164 containerViewportRect.setX(containerViewportRect.x() - ScrollableArea::p ixelsPerLineStep()); 165 containerViewportRect.setX(containerViewportRect.x() - pixelsPerLineStep );
165 containerViewportRect.setWidth(containerViewportRect.width() + Scrollabl eArea::pixelsPerLineStep()); 166 containerViewportRect.setWidth(containerViewportRect.width() + pixelsPer LineStep);
166 break; 167 break;
167 case WebFocusTypeRight: 168 case WebFocusTypeRight:
168 containerViewportRect.setWidth(containerViewportRect.width() + Scrollabl eArea::pixelsPerLineStep()); 169 containerViewportRect.setWidth(containerViewportRect.width() + pixelsPer LineStep);
169 break; 170 break;
170 case WebFocusTypeUp: 171 case WebFocusTypeUp:
171 containerViewportRect.setY(containerViewportRect.y() - ScrollableArea::p ixelsPerLineStep()); 172 containerViewportRect.setY(containerViewportRect.y() - pixelsPerLineStep );
172 containerViewportRect.setHeight(containerViewportRect.height() + Scrolla bleArea::pixelsPerLineStep()); 173 containerViewportRect.setHeight(containerViewportRect.height() + pixelsP erLineStep);
173 break; 174 break;
174 case WebFocusTypeDown: 175 case WebFocusTypeDown:
175 containerViewportRect.setHeight(containerViewportRect.height() + Scrolla bleArea::pixelsPerLineStep()); 176 containerViewportRect.setHeight(containerViewportRect.height() + pixelsP erLineStep);
176 break; 177 break;
177 default: 178 default:
178 break; 179 break;
179 } 180 }
180 181
181 LayoutObject* layoutObject = node->layoutObject(); 182 LayoutObject* layoutObject = node->layoutObject();
182 if (!layoutObject) 183 if (!layoutObject)
183 return true; 184 return true;
184 185
185 LayoutRect rect(layoutObject->absoluteClippedOverflowRect()); 186 LayoutRect rect(layoutObject->absoluteClippedOverflowRect());
186 if (rect.isEmpty()) 187 if (rect.isEmpty())
187 return true; 188 return true;
188 189
189 return !containerViewportRect.intersects(rect); 190 return !containerViewportRect.intersects(rect);
190 } 191 }
191 192
192 bool scrollInDirection(LocalFrame* frame, WebFocusType type) 193 bool scrollInDirection(LocalFrame* frame, WebFocusType type)
193 { 194 {
194 ASSERT(frame); 195 ASSERT(frame);
195 196
196 if (frame && canScrollInDirection(frame->document(), type)) { 197 if (frame && canScrollInDirection(frame->document(), type)) {
197 int dx = 0; 198 int dx = 0;
198 int dy = 0; 199 int dy = 0;
200 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frame->view()- >hostWindow());
199 switch (type) { 201 switch (type) {
200 case WebFocusTypeLeft: 202 case WebFocusTypeLeft:
201 dx = - ScrollableArea::pixelsPerLineStep(); 203 dx = - pixelsPerLineStep;
202 break; 204 break;
203 case WebFocusTypeRight: 205 case WebFocusTypeRight:
204 dx = ScrollableArea::pixelsPerLineStep(); 206 dx = pixelsPerLineStep;
205 break; 207 break;
206 case WebFocusTypeUp: 208 case WebFocusTypeUp:
207 dy = - ScrollableArea::pixelsPerLineStep(); 209 dy = - pixelsPerLineStep;
208 break; 210 break;
209 case WebFocusTypeDown: 211 case WebFocusTypeDown:
210 dy = ScrollableArea::pixelsPerLineStep(); 212 dy = pixelsPerLineStep;
211 break; 213 break;
212 default: 214 default:
213 ASSERT_NOT_REACHED(); 215 ASSERT_NOT_REACHED();
214 return false; 216 return false;
215 } 217 }
216 218
217 frame->view()->scrollBy(IntSize(dx, dy), UserScroll); 219 frame->view()->scrollBy(IntSize(dx, dy), UserScroll);
218 return true; 220 return true;
219 } 221 }
220 return false; 222 return false;
221 } 223 }
222 224
223 bool scrollInDirection(Node* container, WebFocusType type) 225 bool scrollInDirection(Node* container, WebFocusType type)
224 { 226 {
225 ASSERT(container); 227 ASSERT(container);
226 if (container->isDocumentNode()) 228 if (container->isDocumentNode())
227 return scrollInDirection(toDocument(container)->frame(), type); 229 return scrollInDirection(toDocument(container)->frame(), type);
228 230
229 if (!container->layoutBox()) 231 if (!container->layoutBox())
230 return false; 232 return false;
231 233
232 if (canScrollInDirection(container, type)) { 234 if (canScrollInDirection(container, type)) {
233 int dx = 0; 235 int dx = 0;
234 int dy = 0; 236 int dy = 0;
235 // TODO(leviw): Why are these values truncated (toInt) instead of roundi ng? 237 // TODO(leviw): Why are these values truncated (toInt) instead of roundi ng?
238 FrameView* frameView = container->document().view();
239 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frameView ? fr ameView->hostWindow() : nullptr);
236 switch (type) { 240 switch (type) {
237 case WebFocusTypeLeft: 241 case WebFocusTypeLeft:
238 dx = - std::min(ScrollableArea::pixelsPerLineStep(), container->layo utBox()->scrollLeft().toInt()); 242 dx = - std::min(pixelsPerLineStep, container->layoutBox()->scrollLef t().toInt());
239 break; 243 break;
240 case WebFocusTypeRight: 244 case WebFocusTypeRight:
241 ASSERT(container->layoutBox()->scrollWidth() > (container->layoutBox ()->scrollLeft() + container->layoutBox()->clientWidth())); 245 ASSERT(container->layoutBox()->scrollWidth() > (container->layoutBox ()->scrollLeft() + container->layoutBox()->clientWidth()));
242 dx = std::min(ScrollableArea::pixelsPerLineStep(), 246 dx = std::min(pixelsPerLineStep,
243 (container->layoutBox()->scrollWidth() - (container->layoutBox() ->scrollLeft() + container->layoutBox()->clientWidth())).toInt()); 247 (container->layoutBox()->scrollWidth() - (container->layoutBox() ->scrollLeft() + container->layoutBox()->clientWidth())).toInt());
244 break; 248 break;
245 case WebFocusTypeUp: 249 case WebFocusTypeUp:
246 dy = - std::min(ScrollableArea::pixelsPerLineStep(), container->layo utBox()->scrollTop().toInt()); 250 dy = - std::min(pixelsPerLineStep, container->layoutBox()->scrollTop ().toInt());
247 break; 251 break;
248 case WebFocusTypeDown: 252 case WebFocusTypeDown:
249 ASSERT(container->layoutBox()->scrollHeight() - (container->layoutBo x()->scrollTop() + container->layoutBox()->clientHeight())); 253 ASSERT(container->layoutBox()->scrollHeight() - (container->layoutBo x()->scrollTop() + container->layoutBox()->clientHeight()));
250 dy = std::min(ScrollableArea::pixelsPerLineStep(), 254 dy = std::min(pixelsPerLineStep,
251 (container->layoutBox()->scrollHeight() - (container->layoutBox( )->scrollTop() + container->layoutBox()->clientHeight())).toInt()); 255 (container->layoutBox()->scrollHeight() - (container->layoutBox( )->scrollTop() + container->layoutBox()->clientHeight())).toInt());
252 break; 256 break;
253 default: 257 default:
254 ASSERT_NOT_REACHED(); 258 ASSERT_NOT_REACHED();
255 return false; 259 return false;
256 } 260 }
257 261
258 container->layoutBox()->scrollByRecursively(IntSize(dx, dy)); 262 container->layoutBox()->scrollByRecursively(IntSize(dx, dy));
259 return true; 263 return true;
260 } 264 }
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar ea.document().frame(), area.computeRect(area.imageElement()->layoutObject())), L ayoutUnit(1)); 631 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar ea.document().frame(), area.computeRect(area.imageElement()->layoutObject())), L ayoutUnit(1));
628 return rect; 632 return rect;
629 } 633 }
630 634
631 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) 635 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate)
632 { 636 {
633 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v isibleNode) : nullptr; 637 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v isibleNode) : nullptr;
634 }; 638 };
635 639
636 } // namespace blink 640 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698