Changeset 204941 in webkit
- Timestamp:
- Aug 24, 2016 4:26:20 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r204938 r204941 1 2016-08-24 Jonathan Bedard <jbedard@apple.com> 2 3 FocusController multiple dereferenced NULL pointers 4 https://bugs.webkit.org/show_bug.cgi?id=160808 5 6 Reviewed by Darin Adler. 7 8 No new tests needed, fix does not change functionality. 9 10 This change fixes a number of NULL pointer dereferences which occur in FocusController. 11 12 * page/FocusController.cpp: 13 (WebCore::isFocusableElementOrScopeOwner): Changed KeyboardEvent reference to pointer. 14 (WebCore::isNonFocusableScopeOwner): Ditto. 15 (WebCore::isFocusableScopeOwner): Ditto. 16 (WebCore::shadowAdjustedTabIndex): Ditto. 17 18 (WebCore::FocusController::findFocusableElementAcrossFocusScope): Pass pointer instead of reference to KeyboardEvent. 19 (WebCore::FocusController::nextFocusableElementWithinScope): Ditto. 20 (WebCore::FocusController::previousFocusableElementWithinScope): Ditto. 21 (WebCore::FocusController::findElementWithExactTabIndex): Ditto. 22 (WebCore::nextElementWithGreaterTabIndex): Ditto. 23 (WebCore::previousElementWithLowerTabIndex): Ditto. 24 (WebCore::FocusController::nextFocusableElementOrScopeOwner): Ditto. 25 (WebCore::FocusController::previousFocusableElementOrScopeOwner): Ditto. 26 (WebCore::relinquishesEditingFocus): Ditto. 27 1 28 2016-08-24 Nan Wang <n_wang@apple.com> 2 29 -
trunk/Source/WebCore/page/FocusController.cpp
r202091 r204941 290 290 } 291 291 292 static inline bool isFocusableElementOrScopeOwner(Element& element, KeyboardEvent &event)293 { 294 return element.isKeyboardFocusable( &event) || isFocusScopeOwner(element);295 } 296 297 static inline bool isNonFocusableScopeOwner(Element& element, KeyboardEvent &event)298 { 299 return !element.isKeyboardFocusable( &event) && isFocusScopeOwner(element);300 } 301 302 static inline bool isFocusableScopeOwner(Element& element, KeyboardEvent &event)303 { 304 return element.isKeyboardFocusable( &event) && isFocusScopeOwner(element);305 } 306 307 static inline int shadowAdjustedTabIndex(Element& element, KeyboardEvent &event)292 static inline bool isFocusableElementOrScopeOwner(Element& element, KeyboardEvent* event) 293 { 294 return element.isKeyboardFocusable(event) || isFocusScopeOwner(element); 295 } 296 297 static inline bool isNonFocusableScopeOwner(Element& element, KeyboardEvent* event) 298 { 299 return !element.isKeyboardFocusable(event) && isFocusScopeOwner(element); 300 } 301 302 static inline bool isFocusableScopeOwner(Element& element, KeyboardEvent* event) 303 { 304 return element.isKeyboardFocusable(event) && isFocusScopeOwner(element); 305 } 306 307 static inline int shadowAdjustedTabIndex(Element& element, KeyboardEvent* event) 308 308 { 309 309 if (isNonFocusableScopeOwner(element, event)) { … … 505 505 Element* FocusController::findFocusableElementAcrossFocusScope(FocusDirection direction, const FocusNavigationScope& scope, Node* currentNode, KeyboardEvent* event) 506 506 { 507 ASSERT(!is<Element>(currentNode) || !isNonFocusableScopeOwner(downcast<Element>(*currentNode), *event));508 509 if (currentNode && direction == FocusDirectionForward && is<Element>(currentNode) && isFocusableScopeOwner(downcast<Element>(*currentNode), *event)) {507 ASSERT(!is<Element>(currentNode) || !isNonFocusableScopeOwner(downcast<Element>(*currentNode), event)); 508 509 if (currentNode && direction == FocusDirectionForward && is<Element>(currentNode) && isFocusableScopeOwner(downcast<Element>(*currentNode), event)) { 510 510 if (Element* candidateInInnerScope = findFocusableElementWithinScope(direction, FocusNavigationScope::scopeOwnedByScopeOwner(downcast<Element>(*currentNode)), 0, event)) 511 511 return candidateInInnerScope; … … 518 518 Element* owner = scope.owner(); 519 519 while (owner) { 520 if (direction == FocusDirectionBackward && isFocusableScopeOwner(*owner, *event))520 if (direction == FocusDirectionBackward && isFocusableScopeOwner(*owner, event)) 521 521 return findFocusableElementDescendingDownIntoFrameDocument(direction, owner, event); 522 522 … … 543 543 if (!found) 544 544 return nullptr; 545 if (isNonFocusableScopeOwner(*found, *event)) {545 if (isNonFocusableScopeOwner(*found, event)) { 546 546 if (Element* foundInInnerFocusScope = nextFocusableElementWithinScope(FocusNavigationScope::scopeOwnedByScopeOwner(*found), 0, event)) 547 547 return foundInInnerFocusScope; … … 556 556 if (!found) 557 557 return nullptr; 558 if (isFocusableScopeOwner(*found, *event)) {558 if (isFocusableScopeOwner(*found, event)) { 559 559 // Search an inner focusable element in the shadow tree from the end. 560 560 if (Element* foundInInnerFocusScope = previousFocusableElementWithinScope(FocusNavigationScope::scopeOwnedByScopeOwner(*found), 0, event)) … … 562 562 return found; 563 563 } 564 if (isNonFocusableScopeOwner(*found, *event)) {564 if (isNonFocusableScopeOwner(*found, event)) { 565 565 if (Element* foundInInnerFocusScope = previousFocusableElementWithinScope(FocusNavigationScope::scopeOwnedByScopeOwner(*found), 0, event)) 566 566 return foundInInnerFocusScope; … … 584 584 continue; 585 585 Element& element = downcast<Element>(*node); 586 if (isFocusableElementOrScopeOwner(element, *event) && shadowAdjustedTabIndex(element, *event) == tabIndex)586 if (isFocusableElementOrScopeOwner(element, event) && shadowAdjustedTabIndex(element, event) == tabIndex) 587 587 return &element; 588 588 } … … 590 590 } 591 591 592 static Element* nextElementWithGreaterTabIndex(const FocusNavigationScope& scope, int tabIndex, KeyboardEvent &event)592 static Element* nextElementWithGreaterTabIndex(const FocusNavigationScope& scope, int tabIndex, KeyboardEvent* event) 593 593 { 594 594 // Search is inclusive of start … … 609 609 } 610 610 611 static Element* previousElementWithLowerTabIndex(const FocusNavigationScope& scope, Node* start, int tabIndex, KeyboardEvent &event)611 static Element* previousElementWithLowerTabIndex(const FocusNavigationScope& scope, Node* start, int tabIndex, KeyboardEvent* event) 612 612 { 613 613 // Search is inclusive of start … … 645 645 int startTabIndex = 0; 646 646 if (start && is<Element>(*start)) 647 startTabIndex = shadowAdjustedTabIndex(downcast<Element>(*start), *event);647 startTabIndex = shadowAdjustedTabIndex(downcast<Element>(*start), event); 648 648 649 649 if (start) { … … 654 654 continue; 655 655 Element& element = downcast<Element>(*node); 656 if (isFocusableElementOrScopeOwner(element, *event) && shadowAdjustedTabIndex(element, *event) >= 0)656 if (isFocusableElementOrScopeOwner(element, event) && shadowAdjustedTabIndex(element, event) >= 0) 657 657 return &element; 658 658 } … … 670 670 // 1) has the lowest tabindex that is higher than start's tabindex (or 0, if start is null), and 671 671 // 2) comes first in the scope, if there's a tie. 672 if (Element* winner = nextElementWithGreaterTabIndex(scope, startTabIndex, *event))672 if (Element* winner = nextElementWithGreaterTabIndex(scope, startTabIndex, event)) 673 673 return winner; 674 674 … … 692 692 startingNode = scope.previousInScope(start); 693 693 if (is<Element>(*start)) 694 startingTabIndex = shadowAdjustedTabIndex(downcast<Element>(*start), *event);694 startingTabIndex = shadowAdjustedTabIndex(downcast<Element>(*start), event); 695 695 } else 696 696 startingNode = last; … … 702 702 continue; 703 703 Element& element = downcast<Element>(*node); 704 if (isFocusableElementOrScopeOwner(element, *event) && shadowAdjustedTabIndex(element, *event) >= 0)704 if (isFocusableElementOrScopeOwner(element, event) && shadowAdjustedTabIndex(element, event) >= 0) 705 705 return &element; 706 706 } … … 714 714 // 2) comes last in the scope, if there's a tie. 715 715 startingTabIndex = (start && startingTabIndex) ? startingTabIndex : std::numeric_limits<int>::max(); 716 return previousElementWithLowerTabIndex(scope, last, startingTabIndex, *event);716 return previousElementWithLowerTabIndex(scope, last, startingTabIndex, event); 717 717 } 718 718 -
trunk/Source/WebKit2/ChangeLog
r204916 r204941 1 2016-08-24 Jonathan Bedard <jbedard@apple.com> 2 3 FocusController multiple dereferenced NULL pointers 4 https://bugs.webkit.org/show_bug.cgi?id=160808 5 6 Reviewed by Darin Adler. 7 8 * WebProcess/WebPage/WebPage.cpp: 9 (WebKit::WebPage::setInitialFocus): Should use nullptr, not 0 to initialize NULL pointer. 10 1 11 2016-08-23 Anders Carlsson <andersca@apple.com> 2 12 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r204852 r204941 2520 2520 } 2521 2521 2522 m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);2522 m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, nullptr); 2523 2523 send(Messages::WebPageProxy::VoidCallback(callbackID)); 2524 2524 }
Note: See TracChangeset
for help on using the changeset viewer.