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

Side by Side 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: remove assertion 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 unified diff | Download patch
OLDNEW
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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 inline bool hasCustomFocusLogic(const Element& element) 357 inline bool hasCustomFocusLogic(const Element& element)
358 { 358 {
359 return element.isHTMLElement() && toHTMLElement(element).hasCustomFocusLogic (); 359 return element.isHTMLElement() && toHTMLElement(element).hasCustomFocusLogic ();
360 } 360 }
361 361
362 inline bool isShadowHostWithoutCustomFocusLogic(const Element& element) 362 inline bool isShadowHostWithoutCustomFocusLogic(const Element& element)
363 { 363 {
364 return isShadowHost(element) && !hasCustomFocusLogic(element); 364 return isShadowHost(element) && !hasCustomFocusLogic(element);
365 } 365 }
366 366
367 #if ENABLE(ASSERT)
368 inline bool isNonFocusableShadowHost(const Element& element)
369 {
370 return isShadowHostWithoutCustomFocusLogic(element) && !element.isFocusable( );
371 }
372 #endif
373
374 inline bool isNonKeyboardFocusableShadowHost(const Element& element) 367 inline bool isNonKeyboardFocusableShadowHost(const Element& element)
375 { 368 {
376 return isShadowHostWithoutCustomFocusLogic(element) && !(element.shadowRootI fV1() ? element.isFocusable() : element.isKeyboardFocusable()); 369 return isShadowHostWithoutCustomFocusLogic(element) && !(element.shadowRootI fV1() ? element.isFocusable() : element.isKeyboardFocusable());
377 } 370 }
378 371
379 inline bool isKeyboardFocusableShadowHost(const Element& element) 372 inline bool isKeyboardFocusableShadowHost(const Element& element)
380 { 373 {
381 return isShadowHostWithoutCustomFocusLogic(element) && element.isKeyboardFoc usable(); 374 return isShadowHostWithoutCustomFocusLogic(element) && element.isKeyboardFoc usable();
382 } 375 }
383 376
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 break; 632 break;
640 ASSERT(element != foundElement); 633 ASSERT(element != foundElement);
641 element = foundElement; 634 element = foundElement;
642 } 635 }
643 return element; 636 return element;
644 } 637 }
645 638
646 Element* findFocusableElementAcrossFocusScopesForward(ScopedFocusNavigation& sco pe) 639 Element* findFocusableElementAcrossFocusScopesForward(ScopedFocusNavigation& sco pe)
647 { 640 {
648 Element* current = scope.currentElement(); 641 Element* current = scope.currentElement();
649 ASSERT(!current || !isNonFocusableShadowHost(*current));
hayato 2016/05/10 07:58:15 Could you help me to understand how this ASSERT hi
kochi 2016/05/10 09:49:51 This assertion is, if de morgan's law is applied:
650 Element* found; 642 Element* found;
651 if (current && isShadowHostWithoutCustomFocusLogic(*current)) { 643 if (current && isShadowHostWithoutCustomFocusLogic(*current)) {
652 ScopedFocusNavigation innerScope = ScopedFocusNavigation::ownedByShadowH ost(*current); 644 ScopedFocusNavigation innerScope = ScopedFocusNavigation::ownedByShadowH ost(*current);
653 Element* foundInInnerFocusScope = findFocusableElementRecursivelyForward (innerScope); 645 Element* foundInInnerFocusScope = findFocusableElementRecursivelyForward (innerScope);
654 found = foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableE lementRecursivelyForward(scope); 646 found = foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableE lementRecursivelyForward(scope);
655 } else { 647 } else {
656 found = findFocusableElementRecursivelyForward(scope); 648 found = findFocusableElementRecursivelyForward(scope);
657 } 649 }
658 650
659 // If there's no focusable element to advance to, move up the focus scopes u ntil we find one. 651 // If there's no focusable element to advance to, move up the focus scopes u ntil we find one.
660 ScopedFocusNavigation currentScope = scope; 652 ScopedFocusNavigation currentScope = scope;
661 while (!found) { 653 while (!found) {
662 Element* owner = currentScope.owner(); 654 Element* owner = currentScope.owner();
663 if (!owner) 655 if (!owner)
664 break; 656 break;
665 currentScope = ScopedFocusNavigation::createFor(*owner); 657 currentScope = ScopedFocusNavigation::createFor(*owner);
666 found = findFocusableElementRecursivelyForward(currentScope); 658 found = findFocusableElementRecursivelyForward(currentScope);
667 } 659 }
668 return findFocusableElementDescendingDownIntoFrameDocument(WebFocusTypeForwa rd, found); 660 return findFocusableElementDescendingDownIntoFrameDocument(WebFocusTypeForwa rd, found);
669 } 661 }
670 662
671 Element* findFocusableElementAcrossFocusScopesBackward(ScopedFocusNavigation& sc ope) 663 Element* findFocusableElementAcrossFocusScopesBackward(ScopedFocusNavigation& sc ope)
672 { 664 {
673 ASSERT(!scope.currentElement() || !isNonFocusableShadowHost(*scope.currentEl ement()));
674 Element* found = findFocusableElementRecursivelyBackward(scope); 665 Element* found = findFocusableElementRecursivelyBackward(scope);
675 666
676 // If there's no focusable element to advance to, move up the focus scopes u ntil we find one. 667 // If there's no focusable element to advance to, move up the focus scopes u ntil we find one.
677 ScopedFocusNavigation currentScope = scope; 668 ScopedFocusNavigation currentScope = scope;
678 while (!found) { 669 while (!found) {
679 Element* owner = currentScope.owner(); 670 Element* owner = currentScope.owner();
680 if (!owner) 671 if (!owner)
681 break; 672 break;
682 currentScope = ScopedFocusNavigation::createFor(*owner); 673 currentScope = ScopedFocusNavigation::createFor(*owner);
683 if (isKeyboardFocusableShadowHost(*owner) && !isShadowHostDelegatesFocus (*owner)) { 674 if (isKeyboardFocusableShadowHost(*owner) && !isShadowHostDelegatesFocus (*owner)) {
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 return consumed; 1297 return consumed;
1307 } 1298 }
1308 1299
1309 DEFINE_TRACE(FocusController) 1300 DEFINE_TRACE(FocusController)
1310 { 1301 {
1311 visitor->trace(m_page); 1302 visitor->trace(m_page);
1312 visitor->trace(m_focusedFrame); 1303 visitor->trace(m_focusedFrame);
1313 } 1304 }
1314 1305
1315 } // namespace blink 1306 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698