Changeset 203312 in webkit
- Timestamp:
- Jul 15, 2016, 5:39:50 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 15 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/Cocoa/WebViewImpl.h (modified) (2 diffs)
-
UIProcess/Cocoa/WebViewImpl.mm (modified) (1 diff)
-
UIProcess/PageClient.h (modified) (1 diff)
-
UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
UIProcess/WebPageProxy.h (modified) (1 diff)
-
UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
UIProcess/mac/PageClientImpl.h (modified) (1 diff)
-
UIProcess/mac/PageClientImpl.mm (modified) (1 diff)
-
WebProcess/WebCoreSupport/WebChromeClient.cpp (modified) (1 diff)
-
WebProcess/WebCoreSupport/WebChromeClient.h (modified) (2 diffs)
-
WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm (modified) (1 diff)
-
WebProcess/WebPage/WebPage.cpp (modified) (7 diffs)
-
WebProcess/WebPage/WebPage.h (modified) (5 diffs)
-
WebProcess/WebPage/ios/WebPageIOS.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r203303 r203312 1 2016-07-15 Beth Dakin <bdakin@apple.com> 2 3 Mac UI process needs to know about element focus and blur, much like iOS 4 https://bugs.webkit.org/show_bug.cgi?id=159843 5 -and corresponding- 6 rdar://problem/27229504 7 8 Reviewed by Tim Horton. 9 10 This patch makes the existing iOS machinery to handle focus and blurring of 11 elements cross-platform. Instead of using the existing iOS messages for 12 startAssistingNode/stopAssistingNode, this patch adds a new message that 13 require only a boolean parameter: setEditableElementIsFocused. 14 15 Now that more of this code is shared, this patch teases 16 m_hasFocusedDueToUserInteraction out into two variables. I realized that it 17 was being used to mean two slightly different things on Mac and iOS, which 18 was very confusing. Now we have m_isAssistingNodeDueToUserInteraction to 19 represent the way iOS was using the variable, and we have 20 m_hasEverFocusedElementDueToUserInteractionSincePageTransition to represent 21 how Mac was using the variable. There should not be any behavior changes with 22 this re-name, just added clarity. 23 24 WebViewImpl has a new member variable m_editableElementIsFocused. 25 * UIProcess/Cocoa/WebViewImpl.h: 26 * UIProcess/Cocoa/WebViewImpl.mm: 27 (WebKit::WebViewImpl::setEditableElementIsFocused): 28 29 Pipe the new setEditableElementIsFocused message to WebViewImpl. 30 * UIProcess/PageClient.h: 31 * UIProcess/WebPageProxy.cpp: 32 (WebKit::WebPageProxy::setEditableElementIsFocused): 33 * UIProcess/WebPageProxy.h: 34 * UIProcess/WebPageProxy.messages.in: 35 * UIProcess/mac/PageClientImpl.h: 36 * UIProcess/mac/PageClientImpl.mm: 37 (WebKit::PageClientImpl::setEditableElementIsFocused): 38 39 elementDidFocus() and elementDidBlur() are now PLATFORM(COCOA) instead of 40 PLATFORM(IOS) 41 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 42 (WebKit::WebChromeClient::elementDidFocus): 43 (WebKit::WebChromeClient::elementDidBlur): 44 * WebProcess/WebCoreSupport/WebChromeClient.h: 45 * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm: 46 (WebKit::WebChromeClient::elementDidFocus): Deleted. 47 (WebKit::WebChromeClient::elementDidBlur): Deleted. 48 49 m_hasPendingBlurNotification is no longer iOS-only. 50 * WebProcess/WebPage/WebPage.cpp: 51 52 Use our two new bools m_isAssistingNodeDueToUserInteraction and 53 m_hasEverFocusedElementDueToUserInteractionSincePageTransition 54 (WebKit::WebPage::didStartPageTransition): 55 (WebKit::WebPage::didChangeSelection): 56 57 These functions are all newly cross-platform. The Messages they send are 58 still platform-specific, but otherwise the logic is the same. We 59 dispatch_async the blur messages so that the UI process features won’t be 60 flashy when the user is tapping, tabbing, or clicking through form fields. 61 (WebKit::WebPage::resetAssistedNodeForFrame): 62 (WebKit::WebPage::elementDidFocus): 63 (WebKit::WebPage::elementDidBlur): 64 65 resetAssistedNodeForFrame() is no longer iOS-only. 66 (WebKit::WebPage::didCommitLoad): 67 68 Move variables and functions around so that they are defined for the right 69 platform, and declare the two new bools in place of the old one. 70 * WebProcess/WebPage/WebPage.h: 71 72 These functions are now defined in WebPage.cpp 73 * WebProcess/WebPage/ios/WebPageIOS.mm: 74 (WebKit::WebPage::resetAssistedNodeForFrame): Deleted. 75 (WebKit::WebPage::elementDidFocus): Deleted. 76 (WebKit::WebPage::elementDidBlur): Deleted. 77 1 78 2016-07-15 Geoffrey Garen <ggaren@apple.com> 2 79 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
r203295 r203312 273 273 void changeFontFromFontPanel(); 274 274 bool validateUserInterfaceItem(id <NSValidatedUserInterfaceItem>); 275 void setEditableElementIsFocused(bool); 275 276 276 277 void startSpeaking(); … … 648 649 bool m_isHandlingAcceptedCandidate { false }; 649 650 bool m_requiresUserActionForEditingControlsManager { false }; 651 bool m_editableElementIsFocused { false }; 650 652 }; 651 653 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
r203295 r203312 454 454 } 455 455 456 void WebViewImpl::setEditableElementIsFocused(bool editableElementIsFocused) 457 { 458 m_editableElementIsFocused = editableElementIsFocused; 459 } 460 456 461 } // namespace WebKit 457 462 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK) -
trunk/Source/WebKit2/UIProcess/PageClient.h
r202183 r203312 276 276 #endif // USE(INSERTION_UNDO_GROUPING) 277 277 #endif // USE(APPKIT) 278 virtual void setEditableElementIsFocused(bool) = 0; 278 279 #endif // PLATFORM(MAC) 279 280 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r203075 r203312 5956 5956 #endif 5957 5957 5958 void WebPageProxy::setEditableElementIsFocused(bool editableElementIsFocused) 5959 { 5960 m_pageClient.setEditableElementIsFocused(editableElementIsFocused); 5961 } 5962 5958 5963 #endif // PLATFORM(MAC) 5959 5964 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r203085 r203312 1420 1420 void dictationAlternatives(uint64_t dictationContext, Vector<String>& result); 1421 1421 #endif 1422 1423 void setEditableElementIsFocused(bool); 1422 1424 #endif // PLATFORM(MAC) 1423 1425 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r202511 r203312 343 343 DismissCorrectionPanelSoon(int32_t reason) -> (String result) 344 344 RecordAutocorrectionResponse(int32_t responseType, String replacedString, String replacementString); 345 346 SetEditableElementIsFocused(bool editableElementIsFocused) 345 347 #endif 346 348 -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h
r202183 r203312 172 172 Vector<String> dictationAlternatives(uint64_t dictationContext) override; 173 173 #endif 174 void setEditableElementIsFocused(bool) override; 175 174 176 #if USE(INSERTION_UNDO_GROUPING) 175 177 void registerInsertionUndoGrouping() override; -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm
r202183 r203312 622 622 #endif 623 623 624 void PageClientImpl::setEditableElementIsFocused(bool editableElementIsFocused) 625 { 626 m_impl->setEditableElementIsFocused(editableElementIsFocused); 627 } 628 624 629 #if ENABLE(FULLSCREEN_API) 625 630 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r203085 r203312 170 170 171 171 #if PLATFORM(COCOA) 172 void WebChromeClient::elementDidFocus(const WebCore::Node* node) 173 { 174 m_page->elementDidFocus(const_cast<WebCore::Node*>(node)); 175 } 176 177 void WebChromeClient::elementDidBlur(const WebCore::Node* node) 178 { 179 m_page->elementDidBlur(const_cast<WebCore::Node*>(node)); 180 } 181 172 182 void WebChromeClient::makeFirstResponder() 173 183 { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
r202425 r203312 237 237 238 238 #if PLATFORM(IOS) 239 void elementDidFocus(const WebCore::Node*) override;240 void elementDidBlur(const WebCore::Node*) override;241 239 void elementDidRefocus(const WebCore::Node*) override; 242 240 #endif … … 260 258 261 259 #if PLATFORM(COCOA) 260 void elementDidFocus(const WebCore::Node*) override; 261 void elementDidBlur(const WebCore::Node*) override; 262 262 263 void makeFirstResponder() override; 263 264 #endif -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm
r188405 r203312 44 44 } 45 45 #endif 46 47 void WebChromeClient::elementDidFocus(const WebCore::Node* node)48 {49 m_page->elementDidFocus(const_cast<WebCore::Node*>(node));50 }51 52 void WebChromeClient::elementDidBlur(const WebCore::Node* node)53 {54 m_page->elementDidBlur(const_cast<WebCore::Node*>(node));55 }56 46 57 47 void WebChromeClient::elementDidRefocus(const WebCore::Node* node) -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r203085 r203312 33 33 #include "APIGeometry.h" 34 34 #include "Arguments.h" 35 #include "AssistedNodeInformation.h" 35 36 #include "DataReference.h" 36 37 #include "DragControllerAction.h" … … 349 350 , m_isShowingContextMenu(false) 350 351 #endif 352 , m_hasPendingBlurNotification(false) 351 353 #if PLATFORM(IOS) 352 354 , m_selectionAnchor(Start) … … 355 357 , m_userHasChangedPageScaleFactor(false) 356 358 , m_hasStablePageScaleFactor(true) 357 , m_hasPendingBlurNotification(false)358 359 , m_useTestingViewportConfiguration(false) 359 360 , m_isInStableState(true) … … 2609 2610 2610 2611 #if PLATFORM(MAC) 2611 bool hasPreviouslyFocusedDueToUserInteraction = m_hasFocusedDueToUserInteraction; 2612 #endif 2613 m_hasFocusedDueToUserInteraction = false; 2612 bool hasPreviouslyFocusedDueToUserInteraction = m_hasEverFocusedElementDueToUserInteractionSincePageTransition; 2613 #endif 2614 m_hasEverFocusedElementDueToUserInteractionSincePageTransition = false; 2615 m_isAssistingNodeDueToUserInteraction = false; 2614 2616 #if PLATFORM(MAC) 2615 2617 if (hasPreviouslyFocusedDueToUserInteraction) 2616 send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_has FocusedDueToUserInteraction));2618 send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasEverFocusedElementDueToUserInteractionSincePageTransition)); 2617 2619 #endif 2618 2620 } … … 4754 4756 4755 4757 #if PLATFORM(MAC) 4756 bool hasPreviouslyFocusedDueToUserInteraction = m_hasFocusedDueToUserInteraction; 4757 m_hasFocusedDueToUserInteraction |= m_userIsInteracting; 4758 if (!hasPreviouslyFocusedDueToUserInteraction && m_hasFocusedDueToUserInteraction) 4759 send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasFocusedDueToUserInteraction)); 4758 bool hasPreviouslyFocusedDueToUserInteraction = m_hasEverFocusedElementDueToUserInteractionSincePageTransition; 4759 m_hasEverFocusedElementDueToUserInteractionSincePageTransition |= m_userIsInteracting; 4760 4761 if (!hasPreviouslyFocusedDueToUserInteraction && m_hasEverFocusedElementDueToUserInteractionSincePageTransition) 4762 send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasEverFocusedElementDueToUserInteractionSincePageTransition)); 4760 4763 4761 4764 // Abandon the current inline input session if selection changed for any other reason but an input method direct action. … … 4777 4780 } 4778 4781 4782 void WebPage::resetAssistedNodeForFrame(WebFrame* frame) 4783 { 4784 if (!m_assistedNode) 4785 return; 4786 if (m_assistedNode->document().frame() == frame->coreFrame()) { 4787 #if PLATFORM(IOS) 4788 send(Messages::WebPageProxy::StopAssistingNode()); 4789 #elif PLATFORM(MAC) 4790 send(Messages::WebPageProxy::SetEditableElementIsFocused(false)); 4791 #endif 4792 m_assistedNode = nullptr; 4793 } 4794 } 4795 4796 void WebPage::elementDidFocus(WebCore::Node* node) 4797 { 4798 if (m_assistedNode == node && m_isAssistingNodeDueToUserInteraction) 4799 return; 4800 4801 if (node->hasTagName(WebCore::HTMLNames::selectTag) || node->hasTagName(WebCore::HTMLNames::inputTag) || node->hasTagName(WebCore::HTMLNames::textareaTag) || node->hasEditableStyle()) { 4802 m_assistedNode = node; 4803 m_isAssistingNodeDueToUserInteraction |= m_userIsInteracting; 4804 4805 #if PLATFORM(IOS) 4806 AssistedNodeInformation information; 4807 getAssistedNodeInformation(information); 4808 RefPtr<API::Object> userData; 4809 4810 m_formClient->willBeginInputSession(this, downcast<Element>(node), WebFrame::fromCoreFrame(*node->document().frame()), userData, m_userIsInteracting); 4811 4812 send(Messages::WebPageProxy::StartAssistingNode(information, m_userIsInteracting, m_hasPendingBlurNotification, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); 4813 #elif PLATFORM(MAC) 4814 if (node->hasTagName(WebCore::HTMLNames::selectTag)) 4815 send(Messages::WebPageProxy::SetEditableElementIsFocused(false)); 4816 else 4817 send(Messages::WebPageProxy::SetEditableElementIsFocused(true)); 4818 #endif 4819 m_hasPendingBlurNotification = false; 4820 } 4821 } 4822 4823 void WebPage::elementDidBlur(WebCore::Node* node) 4824 { 4825 if (m_assistedNode == node) { 4826 m_hasPendingBlurNotification = true; 4827 RefPtr<WebPage> protectedThis(this); 4828 callOnMainThread([protectedThis] { 4829 if (protectedThis->m_hasPendingBlurNotification) { 4830 #if PLATFORM(IOS) 4831 protectedThis->send(Messages::WebPageProxy::StopAssistingNode()); 4832 #elif PLATFORM(MAC) 4833 protectedThis->send(Messages::WebPageProxy::SetEditableElementIsFocused(false)); 4834 #endif 4835 } 4836 protectedThis->m_hasPendingBlurNotification = false; 4837 }); 4838 4839 m_isAssistingNodeDueToUserInteraction = false; 4840 m_assistedNode = nullptr; 4841 } 4842 } 4843 4779 4844 void WebPage::sendPostLayoutEditorStateIfNeeded() 4780 4845 { … … 4915 4980 frame->setFirstLayerTreeTransactionIDAfterDidCommitLoad(downcast<RemoteLayerTreeDrawingArea>(*m_drawingArea).nextTransactionID()); 4916 4981 cancelPotentialTapInFrame(*frame); 4982 #endif 4917 4983 resetAssistedNodeForFrame(frame); 4918 #endif4919 4984 4920 4985 if (!frame->isMainFrame()) -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r203085 r203312 497 497 #endif 498 498 499 void elementDidFocus(WebCore::Node*); 500 void elementDidBlur(WebCore::Node*); 501 void resetAssistedNodeForFrame(WebFrame*); 502 499 503 #if PLATFORM(IOS) 500 504 WebCore::FloatSize screenSize() const; … … 539 543 void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithAssistedNode, uint64_t callbackID); 540 544 541 void elementDidFocus(WebCore::Node*);542 void elementDidBlur(WebCore::Node*);543 545 void requestDictationContext(uint64_t callbackID); 544 546 void replaceDictatedText(const String& oldText, const String& newText); … … 558 560 void setAssistedNodeValueAsNumber(double); 559 561 void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection); 560 void resetAssistedNodeForFrame(WebFrame*);561 562 WebCore::IntRect rectForElementAtInteractionLocation(); 562 563 void updateSelectionAppearance(); … … 1389 1390 1390 1391 bool m_userIsInteracting; 1391 bool m_hasFocusedDueToUserInteraction { false }; 1392 bool m_isAssistingNodeDueToUserInteraction { false }; 1393 bool m_hasEverFocusedElementDueToUserInteractionSincePageTransition { false }; 1392 1394 1393 1395 #if ENABLE(CONTEXT_MENUS) 1394 1396 bool m_isShowingContextMenu; 1395 1397 #endif 1398 1399 RefPtr<WebCore::Node> m_assistedNode; 1400 bool m_hasPendingBlurNotification; 1396 1401 1397 1402 #if PLATFORM(IOS) 1398 RefPtr<WebCore::Node> m_assistedNode;1399 1403 RefPtr<WebCore::Range> m_currentWordRange; 1400 1404 RefPtr<WebCore::Node> m_interactionNode; … … 1415 1419 bool m_userHasChangedPageScaleFactor; 1416 1420 bool m_hasStablePageScaleFactor; 1417 bool m_hasPendingBlurNotification;1418 1421 bool m_useTestingViewportConfiguration; 1419 1422 bool m_isInStableState; -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r203145 r203312 2633 2633 } 2634 2634 2635 void WebPage::resetAssistedNodeForFrame(WebFrame* frame)2636 {2637 if (!m_assistedNode)2638 return;2639 if (m_assistedNode->document().frame() == frame->coreFrame()) {2640 send(Messages::WebPageProxy::StopAssistingNode());2641 m_assistedNode = nullptr;2642 }2643 }2644 2645 void WebPage::elementDidFocus(WebCore::Node* node)2646 {2647 if (m_assistedNode == node && m_hasFocusedDueToUserInteraction)2648 return;2649 2650 if (node->hasTagName(WebCore::HTMLNames::selectTag) || node->hasTagName(WebCore::HTMLNames::inputTag) || node->hasTagName(WebCore::HTMLNames::textareaTag) || node->hasEditableStyle()) {2651 m_assistedNode = node;2652 m_hasFocusedDueToUserInteraction |= m_userIsInteracting;2653 AssistedNodeInformation information;2654 getAssistedNodeInformation(information);2655 RefPtr<API::Object> userData;2656 2657 m_formClient->willBeginInputSession(this, downcast<Element>(node), WebFrame::fromCoreFrame(*node->document().frame()), userData, m_userIsInteracting);2658 2659 send(Messages::WebPageProxy::StartAssistingNode(information, m_userIsInteracting, m_hasPendingBlurNotification, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));2660 m_hasPendingBlurNotification = false;2661 }2662 }2663 2664 void WebPage::elementDidBlur(WebCore::Node* node)2665 {2666 if (m_assistedNode == node) {2667 m_hasPendingBlurNotification = true;2668 RefPtr<WebPage> protectedThis(this);2669 dispatch_async(dispatch_get_main_queue(), [protectedThis] {2670 if (protectedThis->m_hasPendingBlurNotification)2671 protectedThis->send(Messages::WebPageProxy::StopAssistingNode());2672 protectedThis->m_hasPendingBlurNotification = false;2673 });2674 m_hasFocusedDueToUserInteraction = false;2675 m_assistedNode = nullptr;2676 }2677 }2678 2679 2635 void WebPage::setViewportConfigurationMinimumLayoutSize(const FloatSize& size) 2680 2636 {
Note:
See TracChangeset
for help on using the changeset viewer.