Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2425 flags |= WebTextInputFlagAutocorrectOn; | 2425 flags |= WebTextInputFlagAutocorrectOn; |
| 2426 else if (autocorrect == "off") | 2426 else if (autocorrect == "off") |
| 2427 flags |= WebTextInputFlagAutocorrectOff; | 2427 flags |= WebTextInputFlagAutocorrectOff; |
| 2428 | 2428 |
| 2429 const AtomicString& spellcheck = element->getAttribute(spellcheckString); | 2429 const AtomicString& spellcheck = element->getAttribute(spellcheckString); |
| 2430 if (spellcheck == "on") | 2430 if (spellcheck == "on") |
| 2431 flags |= WebTextInputFlagSpellcheckOn; | 2431 flags |= WebTextInputFlagSpellcheckOn; |
| 2432 else if (spellcheck == "off") | 2432 else if (spellcheck == "off") |
| 2433 flags |= WebTextInputFlagSpellcheckOff; | 2433 flags |= WebTextInputFlagSpellcheckOff; |
| 2434 | 2434 |
| 2435 if (wantEnterEvents(element)) { | |
| 2436 flags |= WebTextInputFlagWantEnterEvents; | |
| 2437 } | |
| 2438 | |
| 2439 if (havePreviousInput(element)) { | |
| 2440 flags |= WebTextInputFlagHavePreviousInput; | |
| 2441 } | |
| 2442 | |
| 2443 if (haveNextInput(element)) { | |
| 2444 flags |= WebTextInputFlagHaveNextInput; | |
| 2445 } | |
| 2435 return flags; | 2446 return flags; |
| 2436 } | 2447 } |
| 2437 | 2448 |
| 2449 Element* WebViewImpl::haveNextInput(Element* element) | |
| 2450 { | |
| 2451 if (!element->isFormControlElement()) | |
| 2452 return 0; | |
| 2453 | |
| 2454 HTMLFormControlElement* formControlElement = toHTMLFormControlElement(elemen t); | |
|
bcwhite
2015/02/24 17:06:23
80 character line limits
yosin_UTC9
2015/02/25 01:25:36
Blink coding style rule allows lines to over 80 ch
AKV
2015/04/08 18:38:12
Done.
| |
| 2455 Node* parentFormNode = reinterpret_cast<Node*>(formControlElement->formOwner ()); | |
|
yosin_UTC9
2015/02/25 01:25:36
We don't need to use |reinterpret_cast<Node*>|. |f
| |
| 2456 if (!parentFormNode) | |
| 2457 return 0; | |
|
yosin_UTC9
2015/02/25 01:25:36
nit: better to use |nullptr|.
AKV
2015/04/08 18:38:12
Done.
| |
| 2458 Node* nextNode = static_cast<Node*>(element)->nextSibling(); | |
|
yosin_UTC9
2015/02/25 01:25:36
nit: We don't need to cast to |Node| for |element|
| |
| 2459 // Find all children of parentForm and do the checks | |
| 2460 // NodeList childNodes = static_cast<Node*>(parentFormElement)->childNodes() ; | |
| 2461 while ((nextNode = NodeRenderingTraversal::next(nextNode, parentFormNode))) { | |
|
yosin_UTC9
2015/02/25 01:25:36
I think we should use tab order rather than render
AKV
2015/04/08 18:38:12
Done.
| |
| 2462 RenderObject* renderer = nextNode->renderer(); | |
| 2463 if (nextNode->isContentEditable() || (renderer && renderer->isTextContro l())) { | |
| 2464 if (nextNode->isElementNode()) { | |
| 2465 return toElement(nextNode); | |
| 2466 } | |
| 2467 } | |
| 2468 // TODO(AKV) Need to handle when form has an iframe/frame as its child. | |
| 2469 } | |
| 2470 return 0; | |
|
yosin_UTC9
2015/02/25 01:25:36
nit: better to use |nullptr|.
AKV
2015/04/08 18:38:12
Done.
| |
| 2471 } | |
| 2472 | |
| 2473 Element* WebViewImpl::havePreviousInput(Element* element) | |
| 2474 { | |
| 2475 if (!element->isFormControlElement()) | |
| 2476 return 0; | |
|
yosin_UTC9
2015/02/25 01:25:36
nit: better to use |nullptr|.
AKV
2015/04/08 18:38:12
Done.
AKV
2015/04/08 18:38:12
Done.
| |
| 2477 | |
| 2478 HTMLFormControlElement* formControlElement = toHTMLFormControlElement(elemen t); | |
| 2479 Node* parentFormNode = reinterpret_cast<Node*>(formControlElement->formOwner ()); | |
|
yosin_UTC9
2015/02/25 01:25:36
We don't need to use |reinterpret_cast<Node*>|. |f
AKV
2015/04/08 18:38:12
I wanted to use Node pointer to pass to FocusContr
| |
| 2480 if (!parentFormNode) | |
| 2481 return 0; | |
| 2482 Node* previousNode = static_cast<Node*>(element)->previousSibling(); | |
| 2483 while ((previousNode = NodeRenderingTraversal::previous(previousNode, parent FormNode))) { | |
| 2484 RenderObject* renderer = previousNode->renderer(); | |
| 2485 if (previousNode->isContentEditable() || (renderer && renderer->isTextCo ntrol())) { | |
| 2486 if (previousNode->isElementNode()) { | |
| 2487 return toElement(previousNode); | |
| 2488 } | |
| 2489 } | |
| 2490 // TODO(AKV) Need to handle when form has an iframe/frame as its child. | |
| 2491 } | |
| 2492 return 0; | |
| 2493 } | |
| 2494 | |
| 2495 bool WebViewImpl::wantEnterEvents(Element* element) | |
| 2496 { | |
| 2497 if (!element->isFormControlElement()) | |
| 2498 return false; | |
| 2499 | |
| 2500 if (element->hasEventListeners(EventTypeNames::keydown) || element->hasEvent Listeners(EventTypeNames::keypress) || element->hasEventListeners(EventTypeNames ::keyup)) | |
| 2501 return true; | |
| 2502 | |
| 2503 return false; | |
| 2504 } | |
| 2505 | |
| 2506 void WebViewImpl::advanceFocusToNextInputField(bool direction) | |
| 2507 { | |
| 2508 Element* element = focusedElement(); | |
| 2509 if (!element) | |
| 2510 return; | |
| 2511 | |
| 2512 HTMLFormControlElement* formControlElement = toHTMLFormControlElement(elemen t); | |
| 2513 HTMLFormElement* parentFormElement = formControlElement->formOwner(); | |
| 2514 if (!parentFormElement) // There is no form element as parent, so navigation is not required. | |
| 2515 return; | |
| 2516 | |
| 2517 Element* nextElement = element; | |
| 2518 FocusType focusType = FocusTypeNone; | |
| 2519 if (direction) { | |
| 2520 focusType = FocusTypeForward; | |
| 2521 nextElement = haveNextInput(element); | |
| 2522 } else { | |
| 2523 nextElement = havePreviousInput(element); | |
| 2524 focusType = FocusTypeBackward; | |
| 2525 } | |
| 2526 | |
| 2527 if (!nextElement) | |
| 2528 return; | |
| 2529 | |
| 2530 nextElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/); | |
| 2531 nextElement->dispatchSimulatedClick(0, SendMouseUpDownEvents); | |
| 2532 nextElement->focus(false, focusType); | |
| 2533 } | |
| 2534 | |
| 2438 WebString WebViewImpl::inputModeOfFocusedElement() | 2535 WebString WebViewImpl::inputModeOfFocusedElement() |
| 2439 { | 2536 { |
| 2440 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 2537 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
| 2441 return WebString(); | 2538 return WebString(); |
| 2442 | 2539 |
| 2443 Element* element = focusedElement(); | 2540 Element* element = focusedElement(); |
| 2444 if (!element) | 2541 if (!element) |
| 2445 return WebString(); | 2542 return WebString(); |
| 2446 | 2543 |
| 2447 if (isHTMLInputElement(*element)) { | 2544 if (isHTMLInputElement(*element)) { |
| (...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4478 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4575 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
| 4479 | 4576 |
| 4480 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4577 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4481 return false; | 4578 return false; |
| 4482 | 4579 |
| 4483 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4580 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4484 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4581 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4485 } | 4582 } |
| 4486 | 4583 |
| 4487 } // namespace blink | 4584 } // namespace blink |
| OLD | NEW |