| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 | 625 |
| 626 Element* findFocusableElementDescendingDownIntoFrameDocument(WebFocusType type,
Element* element) | 626 Element* findFocusableElementDescendingDownIntoFrameDocument(WebFocusType type,
Element* element) |
| 627 { | 627 { |
| 628 // The element we found might be a HTMLFrameOwnerElement, so descend down th
e tree until we find either: | 628 // The element we found might be a HTMLFrameOwnerElement, so descend down th
e tree until we find either: |
| 629 // 1) a focusable element, or | 629 // 1) a focusable element, or |
| 630 // 2) the deepest-nested HTMLFrameOwnerElement. | 630 // 2) the deepest-nested HTMLFrameOwnerElement. |
| 631 while (element && element->isFrameOwnerElement()) { | 631 while (element && element->isFrameOwnerElement()) { |
| 632 HTMLFrameOwnerElement& owner = toHTMLFrameOwnerElement(*element); | 632 HTMLFrameOwnerElement& owner = toHTMLFrameOwnerElement(*element); |
| 633 if (!owner.contentFrame() || !owner.contentFrame()->isLocalFrame()) | 633 if (!owner.contentFrame() || !owner.contentFrame()->isLocalFrame()) |
| 634 break; | 634 break; |
| 635 toLocalFrame(owner.contentFrame())->document()->updateLayoutIgnorePendin
gStylesheets(); | 635 toLocalFrame(owner.contentFrame())->document()->updateStyleAndLayoutIgno
rePendingStylesheets(); |
| 636 ScopedFocusNavigation scope = ScopedFocusNavigation::ownedByIFrame(owner
); | 636 ScopedFocusNavigation scope = ScopedFocusNavigation::ownedByIFrame(owner
); |
| 637 Element* foundElement = findFocusableElementRecursively(type, scope); | 637 Element* foundElement = findFocusableElementRecursively(type, scope); |
| 638 if (!foundElement) | 638 if (!foundElement) |
| 639 break; | 639 break; |
| 640 ASSERT(element != foundElement); | 640 ASSERT(element != foundElement); |
| 641 element = foundElement; | 641 element = foundElement; |
| 642 } | 642 } |
| 643 return element; | 643 return element; |
| 644 } | 644 } |
| 645 | 645 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 Element* current = start; | 914 Element* current = start; |
| 915 if (!current && !initialFocus) | 915 if (!current && !initialFocus) |
| 916 current = document->sequentialFocusNavigationStartingPoint(type); | 916 current = document->sequentialFocusNavigationStartingPoint(type); |
| 917 | 917 |
| 918 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself | 918 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself |
| 919 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); | 919 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); |
| 920 | 920 |
| 921 if (caretBrowsing && !current) | 921 if (caretBrowsing && !current) |
| 922 current = adjustToElement(frame->selection().start().anchorNode(), type)
; | 922 current = adjustToElement(frame->selection().start().anchorNode(), type)
; |
| 923 | 923 |
| 924 document->updateLayoutIgnorePendingStylesheets(); | 924 document->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 925 ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*cu
rrent) : ScopedFocusNavigation::createForDocument(*document); | 925 ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*cu
rrent) : ScopedFocusNavigation::createForDocument(*document); |
| 926 Element* element = findFocusableElementAcrossFocusScopes(type, scope); | 926 Element* element = findFocusableElementAcrossFocusScopes(type, scope); |
| 927 if (!element) { | 927 if (!element) { |
| 928 // If there's a RemoteFrame on the ancestor chain, we need to continue | 928 // If there's a RemoteFrame on the ancestor chain, we need to continue |
| 929 // searching for focusable elements there. | 929 // searching for focusable elements there. |
| 930 if (frame->localFrameRoot() != frame->tree().top()) { | 930 if (frame->localFrameRoot() != frame->tree().top()) { |
| 931 document->clearFocusedElement(); | 931 document->clearFocusedElement(); |
| 932 document->setSequentialFocusNavigationStartingPoint(nullptr); | 932 document->setSequentialFocusNavigationStartingPoint(nullptr); |
| 933 toRemoteFrame(frame->localFrameRoot()->tree().parent())->advanceFocu
s(type, frame->localFrameRoot()); | 933 toRemoteFrame(frame->localFrameRoot()->tree().parent())->advanceFocu
s(type, frame->localFrameRoot()); |
| 934 return true; | 934 return true; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 if (frameElement && frameElement->contentFrame()->isLocalFrame()) { | 1222 if (frameElement && frameElement->contentFrame()->isLocalFrame()) { |
| 1223 if (focusCandidate.isOffscreenAfterScrolling) { | 1223 if (focusCandidate.isOffscreenAfterScrolling) { |
| 1224 scrollInDirection(&focusCandidate.visibleNode->document(), type); | 1224 scrollInDirection(&focusCandidate.visibleNode->document(), type); |
| 1225 return true; | 1225 return true; |
| 1226 } | 1226 } |
| 1227 // Navigate into a new frame. | 1227 // Navigate into a new frame. |
| 1228 LayoutRect rect; | 1228 LayoutRect rect; |
| 1229 Element* focusedElement = toLocalFrame(focusedOrMainFrame())->document()
->focusedElement(); | 1229 Element* focusedElement = toLocalFrame(focusedOrMainFrame())->document()
->focusedElement(); |
| 1230 if (focusedElement && !hasOffscreenRect(focusedElement)) | 1230 if (focusedElement && !hasOffscreenRect(focusedElement)) |
| 1231 rect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore
border */); | 1231 rect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore
border */); |
| 1232 toLocalFrame(frameElement->contentFrame())->document()->updateLayoutIgno
rePendingStylesheets(); | 1232 toLocalFrame(frameElement->contentFrame())->document()->updateStyleAndLa
youtIgnorePendingStylesheets(); |
| 1233 if (!advanceFocusDirectionallyInContainer(toLocalFrame(frameElement->con
tentFrame())->document(), rect, type)) { | 1233 if (!advanceFocusDirectionallyInContainer(toLocalFrame(frameElement->con
tentFrame())->document(), rect, type)) { |
| 1234 // The new frame had nothing interesting, need to find another candi
date. | 1234 // The new frame had nothing interesting, need to find another candi
date. |
| 1235 return advanceFocusDirectionallyInContainer(container, nodeRectInAbs
oluteCoordinates(focusCandidate.visibleNode, true), type); | 1235 return advanceFocusDirectionallyInContainer(container, nodeRectInAbs
oluteCoordinates(focusCandidate.visibleNode, true), type); |
| 1236 } | 1236 } |
| 1237 return true; | 1237 return true; |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 if (canScrollInDirection(focusCandidate.visibleNode, type)) { | 1240 if (canScrollInDirection(focusCandidate.visibleNode, type)) { |
| 1241 if (focusCandidate.isOffscreenAfterScrolling) { | 1241 if (focusCandidate.isOffscreenAfterScrolling) { |
| 1242 scrollInDirection(focusCandidate.visibleNode, type); | 1242 scrollInDirection(focusCandidate.visibleNode, type); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1272 ASSERT(curFrame); | 1272 ASSERT(curFrame); |
| 1273 | 1273 |
| 1274 Document* focusedDocument = curFrame->document(); | 1274 Document* focusedDocument = curFrame->document(); |
| 1275 if (!focusedDocument) | 1275 if (!focusedDocument) |
| 1276 return false; | 1276 return false; |
| 1277 | 1277 |
| 1278 Element* focusedElement = focusedDocument->focusedElement(); | 1278 Element* focusedElement = focusedDocument->focusedElement(); |
| 1279 Node* container = focusedDocument; | 1279 Node* container = focusedDocument; |
| 1280 | 1280 |
| 1281 if (container->isDocumentNode()) | 1281 if (container->isDocumentNode()) |
| 1282 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 1282 toDocument(container)->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1283 | 1283 |
| 1284 // Figure out the starting rect. | 1284 // Figure out the starting rect. |
| 1285 LayoutRect startingRect; | 1285 LayoutRect startingRect; |
| 1286 if (focusedElement) { | 1286 if (focusedElement) { |
| 1287 if (!hasOffscreenRect(focusedElement)) { | 1287 if (!hasOffscreenRect(focusedElement)) { |
| 1288 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(ty
pe, focusedElement); | 1288 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(ty
pe, focusedElement); |
| 1289 startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true /*
ignore border */); | 1289 startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true /*
ignore border */); |
| 1290 } else if (isHTMLAreaElement(*focusedElement)) { | 1290 } else if (isHTMLAreaElement(*focusedElement)) { |
| 1291 HTMLAreaElement& area = toHTMLAreaElement(*focusedElement); | 1291 HTMLAreaElement& area = toHTMLAreaElement(*focusedElement); |
| 1292 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(ty
pe, area.imageElement()); | 1292 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(ty
pe, area.imageElement()); |
| 1293 startingRect = virtualRectForAreaElementAndDirection(area, type); | 1293 startingRect = virtualRectForAreaElementAndDirection(area, type); |
| 1294 } | 1294 } |
| 1295 } | 1295 } |
| 1296 | 1296 |
| 1297 bool consumed = false; | 1297 bool consumed = false; |
| 1298 do { | 1298 do { |
| 1299 consumed = advanceFocusDirectionallyInContainer(container, startingRect,
type); | 1299 consumed = advanceFocusDirectionallyInContainer(container, startingRect,
type); |
| 1300 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); | 1300 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); |
| 1301 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type,
container); | 1301 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type,
container); |
| 1302 if (container && container->isDocumentNode()) | 1302 if (container && container->isDocumentNode()) |
| 1303 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 1303 toDocument(container)->updateStyleAndLayoutIgnorePendingStylesheets(
); |
| 1304 } while (!consumed && container); | 1304 } while (!consumed && container); |
| 1305 | 1305 |
| 1306 return consumed; | 1306 return consumed; |
| 1307 } | 1307 } |
| 1308 | 1308 |
| 1309 DEFINE_TRACE(FocusController) | 1309 DEFINE_TRACE(FocusController) |
| 1310 { | 1310 { |
| 1311 visitor->trace(m_page); | 1311 visitor->trace(m_page); |
| 1312 visitor->trace(m_focusedFrame); | 1312 visitor->trace(m_focusedFrame); |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 } // namespace blink | 1315 } // namespace blink |
| OLD | NEW |