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

Unified Diff: third_party/WebKit/Source/core/page/FocusController.cpp

Issue 1805483002: Refactor ScopedFocusNavigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@beta-crash
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/page/FocusController.cpp
diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp
index ddca4a63dfe4469fc61a55ac7e552e9f519809f7..096bdb946d1ec80162dd6c2c1b9d2858ce6b8144 100644
--- a/third_party/WebKit/Source/core/page/FocusController.cpp
+++ b/third_party/WebKit/Source/core/page/FocusController.cpp
@@ -81,8 +81,8 @@ public:
void moveToFirst();
void moveToLast();
Element* owner() const;
- static ScopedFocusNavigation createScopedFocusNavigation(const Element& root, const Element* current);
- static ScopedFocusNavigation createScopedFocusNavigationForDocument(Document&);
+ static ScopedFocusNavigation createFor(const Element&);
+ static ScopedFocusNavigation createForDocument(Document&);
static ScopedFocusNavigation ownedByNonFocusableFocusScopeOwner(Element&);
static ScopedFocusNavigation ownedByShadowHost(const Element&);
static ScopedFocusNavigation ownedByShadowInsertionPoint(HTMLShadowElement&);
@@ -203,14 +203,14 @@ Element* ScopedFocusNavigation::owner() const
return nullptr;
}
-ScopedFocusNavigation ScopedFocusNavigation::createScopedFocusNavigation(const Element& root, const Element* current)
+ScopedFocusNavigation ScopedFocusNavigation::createFor(const Element& current)
{
- if (SlotScopedTraversal::isSlotScoped(root))
- return ScopedFocusNavigation(*SlotScopedTraversal::findScopeOwnerSlot(root), current);
- return ScopedFocusNavigation(root.treeScope(), current);
+ if (SlotScopedTraversal::isSlotScoped(current))
+ return ScopedFocusNavigation(*SlotScopedTraversal::findScopeOwnerSlot(current), &current);
+ return ScopedFocusNavigation(current.treeScope(), &current);
}
-ScopedFocusNavigation ScopedFocusNavigation::createScopedFocusNavigationForDocument(Document& document)
+ScopedFocusNavigation ScopedFocusNavigation::createForDocument(Document& document)
{
return ScopedFocusNavigation(document, nullptr);
}
@@ -609,7 +609,7 @@ Element* findFocusableElementAcrossFocusScopesForward(ScopedFocusNavigation& sco
Element* owner = currentScope.owner();
if (!owner)
break;
- currentScope = ScopedFocusNavigation::createScopedFocusNavigation(*owner, owner);
+ currentScope = ScopedFocusNavigation::createFor(*owner);
found = findFocusableElementRecursivelyForward(currentScope);
}
return findFocusableElementDescendingDownIntoFrameDocument(WebFocusTypeForward, found);
@@ -626,7 +626,7 @@ Element* findFocusableElementAcrossFocusScopesBackward(ScopedFocusNavigation& sc
Element* owner = currentScope.owner();
if (!owner)
break;
- currentScope = ScopedFocusNavigation::createScopedFocusNavigation(*owner, owner);
+ currentScope = ScopedFocusNavigation::createFor(*owner);
if (isKeyboardFocusableShadowHost(*owner) && !isShadowHostDelegatesFocus(*owner)) {
found = owner;
break;
@@ -869,7 +869,7 @@ bool FocusController::advanceFocusInDocumentOrder(LocalFrame* frame, Element* st
current = adjustToElement(frame->selection().start().anchorNode(), type);
document->updateLayoutIgnorePendingStylesheets();
- ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createScopedFocusNavigation(*current, current) : ScopedFocusNavigation::createScopedFocusNavigationForDocument(*document);
+ ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*current) : ScopedFocusNavigation::createForDocument(*document);
RefPtrWillBeRawPtr<Element> element = findFocusableElementAcrossFocusScopes(type, scope);
if (!element) {
@@ -892,7 +892,7 @@ bool FocusController::advanceFocusInDocumentOrder(LocalFrame* frame, Element* st
}
// Chrome doesn't want focus, so we should wrap focus.
- ScopedFocusNavigation scope = ScopedFocusNavigation::createScopedFocusNavigationForDocument(*toLocalFrame(m_page->mainFrame())->document());
+ ScopedFocusNavigation scope = ScopedFocusNavigation::createForDocument(*toLocalFrame(m_page->mainFrame())->document());
element = findFocusableElementRecursively(type, scope);
element = findFocusableElementDescendingDownIntoFrameDocument(type, element.get());
@@ -953,7 +953,7 @@ Element* FocusController::findFocusableElement(WebFocusType type, Element& eleme
{
// FIXME: No spacial navigation code yet.
ASSERT(type == WebFocusTypeForward || type == WebFocusTypeBackward);
- ScopedFocusNavigation scope = ScopedFocusNavigation::createScopedFocusNavigation(element, &element);
+ ScopedFocusNavigation scope = ScopedFocusNavigation::createFor(element);
return findFocusableElementAcrossFocusScopes(type, scope);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698