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

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

Issue 1954023002: Move asserts in FocusNavigationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: readding assert Created 4 years, 7 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 | third_party/WebKit/Source/core/page/FocusControllerTest.cpp » ('j') | 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 42e6f3d80c8630ca756b7d8216f3c31352b41323..55865fb3cae90150872b0dce55adc36d92d482e8 100644
--- a/third_party/WebKit/Source/core/page/FocusController.cpp
+++ b/third_party/WebKit/Source/core/page/FocusController.cpp
@@ -364,13 +364,6 @@ inline bool isShadowHostWithoutCustomFocusLogic(const Element& element)
return isShadowHost(element) && !hasCustomFocusLogic(element);
}
-#if ENABLE(ASSERT)
-inline bool isNonFocusableShadowHost(const Element& element)
-{
- return isShadowHostWithoutCustomFocusLogic(element) && !element.isFocusable();
-}
-#endif
-
inline bool isNonKeyboardFocusableShadowHost(const Element& element)
{
return isShadowHostWithoutCustomFocusLogic(element) && !(element.shadowRootIfV1() ? element.isFocusable() : element.isKeyboardFocusable());
@@ -646,7 +639,6 @@ Element* findFocusableElementDescendingDownIntoFrameDocument(WebFocusType type,
Element* findFocusableElementAcrossFocusScopesForward(ScopedFocusNavigation& scope)
{
Element* current = scope.currentElement();
- ASSERT(!current || !isNonFocusableShadowHost(*current));
Element* found;
if (current && isShadowHostWithoutCustomFocusLogic(*current)) {
ScopedFocusNavigation innerScope = ScopedFocusNavigation::ownedByShadowHost(*current);
@@ -670,7 +662,6 @@ Element* findFocusableElementAcrossFocusScopesForward(ScopedFocusNavigation& sco
Element* findFocusableElementAcrossFocusScopesBackward(ScopedFocusNavigation& scope)
{
- ASSERT(!scope.currentElement() || !isNonFocusableShadowHost(*scope.currentElement()));
Element* found = findFocusableElementRecursivelyBackward(scope);
// If there's no focusable element to advance to, move up the focus scopes until we find one.
@@ -905,6 +896,14 @@ bool FocusController::advanceFocusAcrossFrames(WebFocusType type, RemoteFrame* f
return advanceFocusInDocumentOrder(to, start, type, false, sourceCapabilities);
}
+
+#if ENABLE(ASSERT)
+inline bool isNonFocusableShadowHost(const Element& element)
+{
+ return isShadowHostWithoutCustomFocusLogic(element) && !element.isFocusable();
+}
+#endif
+
bool FocusController::advanceFocusInDocumentOrder(LocalFrame* frame, Element* start, WebFocusType type, bool initialFocus, InputDeviceCapabilities* sourceCapabilities)
{
ASSERT(frame);
@@ -912,6 +911,7 @@ bool FocusController::advanceFocusInDocumentOrder(LocalFrame* frame, Element* st
document->updateDistribution();
Element* current = start;
+ ASSERT(!current || !isNonFocusableShadowHost(*current));
if (!current && !initialFocus)
current = document->sequentialFocusNavigationStartingPoint(type);
@@ -952,8 +952,6 @@ bool FocusController::advanceFocusInDocumentOrder(LocalFrame* frame, Element* st
return false;
}
- ASSERT(element);
-
if (element == document->focusedElement()) {
// Focus wrapped around to the same element.
return true;
@@ -979,6 +977,8 @@ bool FocusController::advanceFocusInDocumentOrder(LocalFrame* frame, Element* st
return true;
}
+ ASSERT(element->isFocusable());
+
// FIXME: It would be nice to just be able to call setFocusedElement(element)
// here, but we can't do that because some elements (e.g. HTMLInputElement
// and HTMLTextAreaElement) do extra work in their focus() methods.
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/page/FocusControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698