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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 1433103002: Use FocusParams in FocusController::setFocusedElement and Document::setFocusedElement arguments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 page()->focusController().focusDocumentView(toCoreFrame(frame)); 2811 page()->focusController().focusDocumentView(toCoreFrame(frame));
2812 } 2812 }
2813 2813
2814 void WebViewImpl::setInitialFocus(bool reverse) 2814 void WebViewImpl::setInitialFocus(bool reverse)
2815 { 2815 {
2816 if (!m_page) 2816 if (!m_page)
2817 return; 2817 return;
2818 Frame* frame = page()->focusController().focusedOrMainFrame(); 2818 Frame* frame = page()->focusController().focusedOrMainFrame();
2819 if (frame->isLocalFrame()) { 2819 if (frame->isLocalFrame()) {
2820 if (Document* document = toLocalFrame(frame)->document()) 2820 if (Document* document = toLocalFrame(frame)->document())
2821 document->setFocusedElement(nullptr); 2821 document->clearFocusedElement();
2822 } 2822 }
2823 page()->focusController().setInitialFocus(reverse ? WebFocusTypeBackward : W ebFocusTypeForward); 2823 page()->focusController().setInitialFocus(reverse ? WebFocusTypeBackward : W ebFocusTypeForward);
2824 } 2824 }
2825 2825
2826 void WebViewImpl::clearFocusedElement() 2826 void WebViewImpl::clearFocusedElement()
2827 { 2827 {
2828 RefPtrWillBeRawPtr<Frame> frame = focusedCoreFrame(); 2828 RefPtrWillBeRawPtr<Frame> frame = focusedCoreFrame();
2829 if (!frame || !frame->isLocalFrame()) 2829 if (!frame || !frame->isLocalFrame())
2830 return; 2830 return;
2831 2831
2832 LocalFrame* localFrame = toLocalFrame(frame.get()); 2832 LocalFrame* localFrame = toLocalFrame(frame.get());
2833 2833
2834 RefPtrWillBeRawPtr<Document> document = localFrame->document(); 2834 RefPtrWillBeRawPtr<Document> document = localFrame->document();
2835 if (!document) 2835 if (!document)
2836 return; 2836 return;
2837 2837
2838 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); 2838 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement();
2839 2839 document->clearFocusedElement();
2840 // Clear the focused node.
2841 document->setFocusedElement(nullptr);
2842
2843 if (!oldFocusedElement) 2840 if (!oldFocusedElement)
2844 return; 2841 return;
2845 2842
2846 // If a text field has focus, we need to make sure the selection controller 2843 // If a text field has focus, we need to make sure the selection controller
2847 // knows to remove selection from it. Otherwise, the text field is still 2844 // knows to remove selection from it. Otherwise, the text field is still
2848 // processing keyboard events even though focus has been moved to the page a nd 2845 // processing keyboard events even though focus has been moved to the page a nd
2849 // keystrokes get eaten as a result. 2846 // keystrokes get eaten as a result.
2850 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC ontrol()) 2847 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC ontrol())
2851 localFrame->selection().clear(); 2848 localFrame->selection().clear();
2852 } 2849 }
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
4466 if (m_pageColorOverlay) 4463 if (m_pageColorOverlay)
4467 m_pageColorOverlay->update(); 4464 m_pageColorOverlay->update();
4468 if (InspectorOverlay* overlay = inspectorOverlay()) { 4465 if (InspectorOverlay* overlay = inspectorOverlay()) {
4469 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); 4466 PageOverlay* inspectorPageOverlay = overlay->pageOverlay();
4470 if (inspectorPageOverlay) 4467 if (inspectorPageOverlay)
4471 inspectorPageOverlay->update(); 4468 inspectorPageOverlay->update();
4472 } 4469 }
4473 } 4470 }
4474 4471
4475 } // namespace blink 4472 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPluginContainerImpl.cpp ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698