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

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

Issue 2392463002: DO NOT SUBMIT: Fix input action type for Android
Patch Set: Created 4 years, 2 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) 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "core/frame/FrameHost.h" 54 #include "core/frame/FrameHost.h"
55 #include "core/frame/FrameView.h" 55 #include "core/frame/FrameView.h"
56 #include "core/frame/LocalFrame.h" 56 #include "core/frame/LocalFrame.h"
57 #include "core/frame/PageScaleConstraintsSet.h" 57 #include "core/frame/PageScaleConstraintsSet.h"
58 #include "core/frame/RemoteFrame.h" 58 #include "core/frame/RemoteFrame.h"
59 #include "core/frame/Settings.h" 59 #include "core/frame/Settings.h"
60 #include "core/frame/SmartClip.h" 60 #include "core/frame/SmartClip.h"
61 #include "core/frame/TopControls.h" 61 #include "core/frame/TopControls.h"
62 #include "core/frame/UseCounter.h" 62 #include "core/frame/UseCounter.h"
63 #include "core/frame/VisualViewport.h" 63 #include "core/frame/VisualViewport.h"
64 #include "core/html/HTMLFormElement.h"
64 #include "core/html/HTMLInputElement.h" 65 #include "core/html/HTMLInputElement.h"
65 #include "core/html/HTMLMediaElement.h" 66 #include "core/html/HTMLMediaElement.h"
66 #include "core/html/HTMLPlugInElement.h" 67 #include "core/html/HTMLPlugInElement.h"
67 #include "core/html/HTMLTextAreaElement.h" 68 #include "core/html/HTMLTextAreaElement.h"
68 #include "core/input/EventHandler.h" 69 #include "core/input/EventHandler.h"
69 #include "core/input/TouchActionUtil.h" 70 #include "core/input/TouchActionUtil.h"
70 #include "core/layout/LayoutPart.h" 71 #include "core/layout/LayoutPart.h"
71 #include "core/layout/TextAutosizer.h" 72 #include "core/layout/TextAutosizer.h"
72 #include "core/layout/api/LayoutViewItem.h" 73 #include "core/layout/api/LayoutViewItem.h"
73 #include "core/layout/compositing/PaintLayerCompositor.h" 74 #include "core/layout/compositing/PaintLayerCompositor.h"
(...skipping 2340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 Element* editable = focused->selection().rootEditableElementOrDocumentElemen t(); 2415 Element* editable = focused->selection().rootEditableElementOrDocumentElemen t();
2415 DCHECK(editable); 2416 DCHECK(editable);
2416 2417
2417 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 2418 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
2418 // needs to be audited. See http://crbug.com/590369 for more details. 2419 // needs to be audited. See http://crbug.com/590369 for more details.
2419 editable->document().updateStyleAndLayoutIgnorePendingStylesheets(); 2420 editable->document().updateStyleAndLayoutIgnorePendingStylesheets();
2420 2421
2421 return PlainTextRange::create(*editable, range); 2422 return PlainTextRange::create(*editable, range);
2422 } 2423 }
2423 2424
2425 int textInputActionFlags(int type, FocusController& focusController) {
2426 if (type == WebTextInputTypeSearch) {
2427 return WebTextInputFlagActionSearch;
2428 }
2429 HTMLElement* current = toHTMLElement(focusController.getCurrentElementForFoc usNavigation(WebFocusTypeForward));
2430 if (!current)
2431 return 0;
2432
2433 HTMLFormElement* currentForm = FormAssociatedElement::findAssociatedForm(cur rent);
2434
2435 bool hasNextFocusableInFormOrDocument = false;
2436 // TODO(changwan): optimize this.
2437 Element* nextFocusableElement = focusController.findNextFocusableElementInDo cumentOrder();
2438 if (nextFocusableElement) {
2439 HTMLElement* nextFocusableHtmlElement = toHTMLElement(nextFocusableEleme nt);
2440 if (nextFocusableHtmlElement) {
2441 HTMLFormElement* nextFocusableElementForm = FormAssociatedElement::f indAssociatedForm(nextFocusableHtmlElement);
2442 // Both currentForm and nextFocusableElementForm may be nullptr.
2443 hasNextFocusableInFormOrDocument = currentForm == nextFocusableEleme ntForm;
2444 }
2445 }
2446
2447 int flags = 0;
2448 if (hasNextFocusableInFormOrDocument) {
2449 flags |= WebTextInputFlagActionNext;
2450 } else if (currentForm) {
2451 flags |= WebTextInputFlagActionGo;
2452 } else {
2453 flags |= WebTextInputFlagActionNone;
2454 }
2455 return flags;
2456 }
2457
2424 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as 2458 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as
2425 // well. This code needs to be refactored (http://crbug.com/629721). 2459 // well. This code needs to be refactored (http://crbug.com/629721).
2426 WebTextInputInfo WebViewImpl::textInputInfo() 2460 WebTextInputInfo WebViewImpl::textInputInfo()
2427 { 2461 {
2428 WebTextInputInfo info; 2462 WebTextInputInfo info;
2429 2463
2430 LocalFrame* focused = focusedLocalFrameInWidget(); 2464 LocalFrame* focused = focusedLocalFrameInWidget();
2431 if (!focused) 2465 if (!focused)
2432 return info; 2466 return info;
2433 2467
(...skipping 15 matching lines...) Expand all
2449 2483
2450 if (!focused->editor().canEdit()) 2484 if (!focused->editor().canEdit())
2451 return info; 2485 return info;
2452 2486
2453 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited. 2487 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited.
2454 // see http://crbug.com/590369 for more details. 2488 // see http://crbug.com/590369 for more details.
2455 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 2489 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets();
2456 2490
2457 DocumentLifecycle::DisallowTransitionScope disallowTransition(focused->docum ent()->lifecycle()); 2491 DocumentLifecycle::DisallowTransitionScope disallowTransition(focused->docum ent()->lifecycle());
2458 2492
2493 info.flags |= textInputActionFlags(info.type, page()->focusController());
2494
2459 // Emits an object replacement character for each replaced element so that 2495 // Emits an object replacement character for each replaced element so that
2460 // it is exposed to IME and thus could be deleted by IME on android. 2496 // it is exposed to IME and thus could be deleted by IME on android.
2461 info.value = plainText(EphemeralRange::rangeOfContents(*element), TextIterat orEmitsObjectReplacementCharacter); 2497 info.value = plainText(EphemeralRange::rangeOfContents(*element), TextIterat orEmitsObjectReplacementCharacter);
2462 2498
2463 if (info.value.isEmpty()) 2499 if (info.value.isEmpty())
2464 return info; 2500 return info;
2465 2501
2466 EphemeralRange firstRange = firstEphemeralRangeOf(selection.selection()); 2502 EphemeralRange firstRange = firstEphemeralRangeOf(selection.selection());
2467 if (firstRange.isNotNull()) { 2503 if (firstRange.isNotNull()) {
2468 PlainTextRange plainTextRange(PlainTextRange::create(*element, firstRang e)); 2504 PlainTextRange plainTextRange(PlainTextRange::create(*element, firstRang e));
(...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4592 return nullptr; 4628 return nullptr;
4593 return focusedFrame; 4629 return focusedFrame;
4594 } 4630 }
4595 4631
4596 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const 4632 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const
4597 { 4633 {
4598 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4634 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4599 } 4635 }
4600 4636
4601 } // namespace blink 4637 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/FocusController.cpp ('k') | third_party/WebKit/public/web/WebTextInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698