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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 220 } |
221 return false; | 221 return false; |
222 } | 222 } |
223 | 223 |
224 bool scrollInDirection(Node* container, WebFocusType type) | 224 bool scrollInDirection(Node* container, WebFocusType type) |
225 { | 225 { |
226 ASSERT(container); | 226 ASSERT(container); |
227 if (container->isDocumentNode()) | 227 if (container->isDocumentNode()) |
228 return scrollInDirection(toDocument(container)->frame(), type); | 228 return scrollInDirection(toDocument(container)->frame(), type); |
229 | 229 |
230 if (!container->renderBox()) | 230 if (!container->layoutBox()) |
231 return false; | 231 return false; |
232 | 232 |
233 if (canScrollInDirection(container, type)) { | 233 if (canScrollInDirection(container, type)) { |
234 LayoutUnit dx = 0; | 234 LayoutUnit dx = 0; |
235 LayoutUnit dy = 0; | 235 LayoutUnit dy = 0; |
236 switch (type) { | 236 switch (type) { |
237 case WebFocusTypeLeft: | 237 case WebFocusTypeLeft: |
238 dx = - std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), con
tainer->renderBox()->scrollLeft()); | 238 dx = - std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), con
tainer->layoutBox()->scrollLeft()); |
239 break; | 239 break; |
240 case WebFocusTypeRight: | 240 case WebFocusTypeRight: |
241 ASSERT(container->renderBox()->scrollWidth() > (container->renderBox
()->scrollLeft() + container->renderBox()->clientWidth())); | 241 ASSERT(container->layoutBox()->scrollWidth() > (container->layoutBox
()->scrollLeft() + container->layoutBox()->clientWidth())); |
242 dx = std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), conta
iner->renderBox()->scrollWidth() - (container->renderBox()->scrollLeft() + conta
iner->renderBox()->clientWidth())); | 242 dx = std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), conta
iner->layoutBox()->scrollWidth() - (container->layoutBox()->scrollLeft() + conta
iner->layoutBox()->clientWidth())); |
243 break; | 243 break; |
244 case WebFocusTypeUp: | 244 case WebFocusTypeUp: |
245 dy = - std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), con
tainer->renderBox()->scrollTop()); | 245 dy = - std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), con
tainer->layoutBox()->scrollTop()); |
246 break; | 246 break; |
247 case WebFocusTypeDown: | 247 case WebFocusTypeDown: |
248 ASSERT(container->renderBox()->scrollHeight() - (container->renderBo
x()->scrollTop() + container->renderBox()->clientHeight())); | 248 ASSERT(container->layoutBox()->scrollHeight() - (container->layoutBo
x()->scrollTop() + container->layoutBox()->clientHeight())); |
249 dy = std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), conta
iner->renderBox()->scrollHeight() - (container->renderBox()->scrollTop() + conta
iner->renderBox()->clientHeight())); | 249 dy = std::min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), conta
iner->layoutBox()->scrollHeight() - (container->layoutBox()->scrollTop() + conta
iner->layoutBox()->clientHeight())); |
250 break; | 250 break; |
251 default: | 251 default: |
252 ASSERT_NOT_REACHED(); | 252 ASSERT_NOT_REACHED(); |
253 return false; | 253 return false; |
254 } | 254 } |
255 | 255 |
256 container->renderBox()->scrollByRecursively(IntSize(dx, dy)); | 256 container->layoutBox()->scrollByRecursively(IntSize(dx, dy)); |
257 return true; | 257 return true; |
258 } | 258 } |
259 | 259 |
260 return false; | 260 return false; |
261 } | 261 } |
262 | 262 |
263 static void deflateIfOverlapped(LayoutRect& a, LayoutRect& b) | 263 static void deflateIfOverlapped(LayoutRect& a, LayoutRect& b) |
264 { | 264 { |
265 if (!a.intersects(b) || a.contains(b) || b.contains(a)) | 265 if (!a.intersects(b) || a.contains(b) || b.contains(a)) |
266 return; | 266 return; |
267 | 267 |
268 LayoutUnit deflateFactor = -fudgeFactor(); | 268 LayoutUnit deflateFactor = -fudgeFactor(); |
269 | 269 |
270 // Avoid negative width or height values. | 270 // Avoid negative width or height values. |
271 if ((a.width() + 2 * deflateFactor > 0) && (a.height() + 2 * deflateFactor >
0)) | 271 if ((a.width() + 2 * deflateFactor > 0) && (a.height() + 2 * deflateFactor >
0)) |
272 a.inflate(deflateFactor); | 272 a.inflate(deflateFactor); |
273 | 273 |
274 if ((b.width() + 2 * deflateFactor > 0) && (b.height() + 2 * deflateFactor >
0)) | 274 if ((b.width() + 2 * deflateFactor > 0) && (b.height() + 2 * deflateFactor >
0)) |
275 b.inflate(deflateFactor); | 275 b.inflate(deflateFactor); |
276 } | 276 } |
277 | 277 |
278 bool isScrollableNode(const Node* node) | 278 bool isScrollableNode(const Node* node) |
279 { | 279 { |
280 ASSERT(!node->isDocumentNode()); | 280 ASSERT(!node->isDocumentNode()); |
281 | 281 |
282 if (!node) | 282 if (!node) |
283 return false; | 283 return false; |
284 | 284 |
285 if (LayoutObject* renderer = node->renderer()) | 285 if (LayoutObject* renderer = node->renderer()) |
286 return renderer->isBox() && toRenderBox(renderer)->canBeScrolledAndHasSc
rollableArea() && node->hasChildren(); | 286 return renderer->isBox() && toLayoutBox(renderer)->canBeScrolledAndHasSc
rollableArea() && node->hasChildren(); |
287 | 287 |
288 return false; | 288 return false; |
289 } | 289 } |
290 | 290 |
291 Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(WebFocusType type, N
ode* node) | 291 Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(WebFocusType type, N
ode* node) |
292 { | 292 { |
293 ASSERT(node); | 293 ASSERT(node); |
294 Node* parent = node; | 294 Node* parent = node; |
295 do { | 295 do { |
296 // FIXME: Spatial navigation is broken for OOPI. | 296 // FIXME: Spatial navigation is broken for OOPI. |
(...skipping 10 matching lines...) Expand all Loading... |
307 { | 307 { |
308 ASSERT(container); | 308 ASSERT(container); |
309 if (container->isDocumentNode()) | 309 if (container->isDocumentNode()) |
310 return canScrollInDirection(toDocument(container)->frame(), type); | 310 return canScrollInDirection(toDocument(container)->frame(), type); |
311 | 311 |
312 if (!isScrollableNode(container)) | 312 if (!isScrollableNode(container)) |
313 return false; | 313 return false; |
314 | 314 |
315 switch (type) { | 315 switch (type) { |
316 case WebFocusTypeLeft: | 316 case WebFocusTypeLeft: |
317 return (container->renderer()->style()->overflowX() != OHIDDEN && contai
ner->renderBox()->scrollLeft() > 0); | 317 return (container->renderer()->style()->overflowX() != OHIDDEN && contai
ner->layoutBox()->scrollLeft() > 0); |
318 case WebFocusTypeUp: | 318 case WebFocusTypeUp: |
319 return (container->renderer()->style()->overflowY() != OHIDDEN && contai
ner->renderBox()->scrollTop() > 0); | 319 return (container->renderer()->style()->overflowY() != OHIDDEN && contai
ner->layoutBox()->scrollTop() > 0); |
320 case WebFocusTypeRight: | 320 case WebFocusTypeRight: |
321 return (container->renderer()->style()->overflowX() != OHIDDEN && contai
ner->renderBox()->scrollLeft() + container->renderBox()->clientWidth() < contain
er->renderBox()->scrollWidth()); | 321 return (container->renderer()->style()->overflowX() != OHIDDEN && contai
ner->layoutBox()->scrollLeft() + container->layoutBox()->clientWidth() < contain
er->layoutBox()->scrollWidth()); |
322 case WebFocusTypeDown: | 322 case WebFocusTypeDown: |
323 return (container->renderer()->style()->overflowY() != OHIDDEN && contai
ner->renderBox()->scrollTop() + container->renderBox()->clientHeight() < contain
er->renderBox()->scrollHeight()); | 323 return (container->renderer()->style()->overflowY() != OHIDDEN && contai
ner->layoutBox()->scrollTop() + container->layoutBox()->clientHeight() < contain
er->layoutBox()->scrollHeight()); |
324 default: | 324 default: |
325 ASSERT_NOT_REACHED(); | 325 ASSERT_NOT_REACHED(); |
326 return false; | 326 return false; |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 bool canScrollInDirection(const LocalFrame* frame, WebFocusType type) | 330 bool canScrollInDirection(const LocalFrame* frame, WebFocusType type) |
331 { | 331 { |
332 if (!frame->view()) | 332 if (!frame->view()) |
333 return false; | 333 return false; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar
ea.document().frame(), area.computeRect(area.imageElement()->renderer())), 1); | 622 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar
ea.document().frame(), area.computeRect(area.imageElement()->renderer())), 1); |
623 return rect; | 623 return rect; |
624 } | 624 } |
625 | 625 |
626 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) | 626 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) |
627 { | 627 { |
628 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v
isibleNode) : nullptr; | 628 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v
isibleNode) : nullptr; |
629 }; | 629 }; |
630 | 630 |
631 } // namespace blink | 631 } // namespace blink |
OLD | NEW |