Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 return true; | 187 return true; |
| 188 | 188 |
| 189 return !containerViewportRect.intersects(rect); | 189 return !containerViewportRect.intersects(rect); |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool scrollInDirection(LocalFrame* frame, WebFocusType type) | 192 bool scrollInDirection(LocalFrame* frame, WebFocusType type) |
| 193 { | 193 { |
| 194 ASSERT(frame); | 194 ASSERT(frame); |
| 195 | 195 |
| 196 if (frame && canScrollInDirection(frame->document(), type)) { | 196 if (frame && canScrollInDirection(frame->document(), type)) { |
| 197 LayoutUnit dx; | 197 int dx = 0; |
| 198 LayoutUnit dy; | 198 int dy = 0; |
| 199 switch (type) { | 199 switch (type) { |
| 200 case WebFocusTypeLeft: | 200 case WebFocusTypeLeft: |
| 201 dx = - ScrollableArea::pixelsPerLineStep(); | 201 dx = - ScrollableArea::pixelsPerLineStep(); |
| 202 break; | 202 break; |
| 203 case WebFocusTypeRight: | 203 case WebFocusTypeRight: |
| 204 dx = ScrollableArea::pixelsPerLineStep(); | 204 dx = ScrollableArea::pixelsPerLineStep(); |
| 205 break; | 205 break; |
| 206 case WebFocusTypeUp: | 206 case WebFocusTypeUp: |
| 207 dy = - ScrollableArea::pixelsPerLineStep(); | 207 dy = - ScrollableArea::pixelsPerLineStep(); |
| 208 break; | 208 break; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 223 bool scrollInDirection(Node* container, WebFocusType type) | 223 bool scrollInDirection(Node* container, WebFocusType type) |
| 224 { | 224 { |
| 225 ASSERT(container); | 225 ASSERT(container); |
| 226 if (container->isDocumentNode()) | 226 if (container->isDocumentNode()) |
| 227 return scrollInDirection(toDocument(container)->frame(), type); | 227 return scrollInDirection(toDocument(container)->frame(), type); |
| 228 | 228 |
| 229 if (!container->layoutBox()) | 229 if (!container->layoutBox()) |
| 230 return false; | 230 return false; |
| 231 | 231 |
| 232 if (canScrollInDirection(container, type)) { | 232 if (canScrollInDirection(container, type)) { |
| 233 LayoutUnit dx; | 233 int dx = 0; |
| 234 LayoutUnit dy; | 234 int dy = 0; |
| 235 // TODO(leviw): Why are these values truncated (toInt) instead of roundi ng? | |
|
eae
2016/01/30 23:58:24
These should probably be snapped based on the cont
leviw_travelin_and_unemployed
2016/01/31 00:33:13
Yup! I'm avoiding for this round to keep from conf
| |
| 235 switch (type) { | 236 switch (type) { |
| 236 case WebFocusTypeLeft: | 237 case WebFocusTypeLeft: |
| 237 dx = - std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), con tainer->layoutBox()->scrollLeft()); | 238 dx = - std::min(ScrollableArea::pixelsPerLineStep(), container->layo utBox()->scrollLeft().toInt()); |
| 238 break; | 239 break; |
| 239 case WebFocusTypeRight: | 240 case WebFocusTypeRight: |
| 240 ASSERT(container->layoutBox()->scrollWidth() > (container->layoutBox ()->scrollLeft() + container->layoutBox()->clientWidth())); | 241 ASSERT(container->layoutBox()->scrollWidth() > (container->layoutBox ()->scrollLeft() + container->layoutBox()->clientWidth())); |
| 241 dx = std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), conta iner->layoutBox()->scrollWidth() - (container->layoutBox()->scrollLeft() + conta iner->layoutBox()->clientWidth())); | 242 dx = std::min(ScrollableArea::pixelsPerLineStep(), |
| 243 (container->layoutBox()->scrollWidth() - (container->layoutBox() ->scrollLeft() + container->layoutBox()->clientWidth())).toInt()); | |
| 242 break; | 244 break; |
| 243 case WebFocusTypeUp: | 245 case WebFocusTypeUp: |
| 244 dy = - std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), con tainer->layoutBox()->scrollTop()); | 246 dy = - std::min(ScrollableArea::pixelsPerLineStep(), container->layo utBox()->scrollTop().toInt()); |
| 245 break; | 247 break; |
| 246 case WebFocusTypeDown: | 248 case WebFocusTypeDown: |
| 247 ASSERT(container->layoutBox()->scrollHeight() - (container->layoutBo x()->scrollTop() + container->layoutBox()->clientHeight())); | 249 ASSERT(container->layoutBox()->scrollHeight() - (container->layoutBo x()->scrollTop() + container->layoutBox()->clientHeight())); |
| 248 dy = std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), conta iner->layoutBox()->scrollHeight() - (container->layoutBox()->scrollTop() + conta iner->layoutBox()->clientHeight())); | 250 dy = std::min(ScrollableArea::pixelsPerLineStep(), |
| 251 (container->layoutBox()->scrollHeight() - (container->layoutBox( )->scrollTop() + container->layoutBox()->clientHeight())).toInt()); | |
| 249 break; | 252 break; |
| 250 default: | 253 default: |
| 251 ASSERT_NOT_REACHED(); | 254 ASSERT_NOT_REACHED(); |
| 252 return false; | 255 return false; |
| 253 } | 256 } |
| 254 | 257 |
| 255 container->layoutBox()->scrollByRecursively(IntSize(dx, dy)); | 258 container->layoutBox()->scrollByRecursively(IntSize(dx, dy)); |
| 256 return true; | 259 return true; |
| 257 } | 260 } |
| 258 | 261 |
| 259 return false; | 262 return false; |
| 260 } | 263 } |
| 261 | 264 |
| 262 static void deflateIfOverlapped(LayoutRect& a, LayoutRect& b) | 265 static void deflateIfOverlapped(LayoutRect& a, LayoutRect& b) |
| 263 { | 266 { |
| 264 if (!a.intersects(b) || a.contains(b) || b.contains(a)) | 267 if (!a.intersects(b) || a.contains(b) || b.contains(a)) |
| 265 return; | 268 return; |
| 266 | 269 |
| 267 LayoutUnit deflateFactor = -fudgeFactor(); | 270 LayoutUnit deflateFactor = LayoutUnit(-fudgeFactor()); |
| 268 | 271 |
| 269 // Avoid negative width or height values. | 272 // Avoid negative width or height values. |
| 270 if ((a.width() + 2 * deflateFactor > 0) && (a.height() + 2 * deflateFactor > 0)) | 273 if ((a.width() + 2 * deflateFactor > 0) && (a.height() + 2 * deflateFactor > 0)) |
| 271 a.inflate(deflateFactor); | 274 a.inflate(deflateFactor); |
| 272 | 275 |
| 273 if ((b.width() + 2 * deflateFactor > 0) && (b.height() + 2 * deflateFactor > 0)) | 276 if ((b.width() + 2 * deflateFactor > 0) && (b.height() + 2 * deflateFactor > 0)) |
| 274 b.inflate(deflateFactor); | 277 b.inflate(deflateFactor); |
| 275 } | 278 } |
| 276 | 279 |
| 277 bool isScrollableNode(const Node* node) | 280 bool isScrollableNode(const Node* node) |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar ea.document().frame(), area.computeRect(area.imageElement()->layoutObject())), 1 ); | 627 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar ea.document().frame(), area.computeRect(area.imageElement()->layoutObject())), 1 ); |
| 625 return rect; | 628 return rect; |
| 626 } | 629 } |
| 627 | 630 |
| 628 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) | 631 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) |
| 629 { | 632 { |
| 630 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v isibleNode) : nullptr; | 633 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v isibleNode) : nullptr; |
| 631 }; | 634 }; |
| 632 | 635 |
| 633 } // namespace blink | 636 } // namespace blink |
| OLD | NEW |