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

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

Issue 2121313003: [Editing][DOM][CodeHealth] Make Node::isContentEditable and Node::isRichEditable global functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 page()->focusController().setActive(true); 453 page()->focusController().setActive(true);
454 LocalFrame* focusedFrame = page()->focusController().focusedFrame(); 454 LocalFrame* focusedFrame = page()->focusController().focusedFrame();
455 if (focusedFrame) { 455 if (focusedFrame) {
456 Element* element = focusedFrame->document()->focusedElement(); 456 Element* element = focusedFrame->document()->focusedElement();
457 if (element && focusedFrame->selection().selection().isNone()) { 457 if (element && focusedFrame->selection().selection().isNone()) {
458 // If the selection was cleared while the WebView was not 458 // If the selection was cleared while the WebView was not
459 // focused, then the focus element shows with a focus ring but 459 // focused, then the focus element shows with a focus ring but
460 // no caret and does respond to keyboard inputs. 460 // no caret and does respond to keyboard inputs.
461 if (element->isTextFormControl()) { 461 if (element->isTextFormControl()) {
462 element->updateFocusAppearance(SelectionBehaviorOnFocus::Res tore); 462 element->updateFocusAppearance(SelectionBehaviorOnFocus::Res tore);
463 } else if (element->isContentEditable()) { 463 } else if (isContentEditable(*element)) {
464 // updateFocusAppearance() selects all the text of 464 // updateFocusAppearance() selects all the text of
465 // contentseditable DIVs. So we set the selection explicitly 465 // contentseditable DIVs. So we set the selection explicitly
466 // instead. Note that this has the side effect of moving the 466 // instead. Note that this has the side effect of moving the
467 // caret back to the beginning of the text. 467 // caret back to the beginning of the text.
468 Position position(element, 0); 468 Position position(element, 0);
469 focusedFrame->selection().setSelection(VisibleSelection(posi tion, SelDefaultAffinity)); 469 focusedFrame->selection().setSelection(VisibleSelection(posi tion, SelDefaultAffinity));
470 } 470 }
471 } 471 }
472 } 472 }
473 } else { 473 } else {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 if (!focused->editor().canEdit() && !inputMethodController.hasComposition()) 510 if (!focused->editor().canEdit() && !inputMethodController.hasComposition())
511 return false; 511 return false;
512 512
513 // We should verify the parent node of this IME composition node are 513 // We should verify the parent node of this IME composition node are
514 // editable because JavaScript may delete a parent node of the composition 514 // editable because JavaScript may delete a parent node of the composition
515 // node. In this case, WebKit crashes while deleting texts from the parent 515 // node. In this case, WebKit crashes while deleting texts from the parent
516 // node, which doesn't exist any longer. 516 // node, which doesn't exist any longer.
517 const EphemeralRange range = inputMethodController.compositionEphemeralRange (); 517 const EphemeralRange range = inputMethodController.compositionEphemeralRange ();
518 if (range.isNotNull()) { 518 if (range.isNotNull()) {
519 Node* node = range.startPosition().computeContainerNode(); 519 Node* node = range.startPosition().computeContainerNode();
520 if (!node || !node->isContentEditable()) 520 if (!node || !isContentEditable(*node))
521 return false; 521 return false;
522 } 522 }
523 523
524 // A keypress event is canceled. If an ongoing composition exists, then the 524 // A keypress event is canceled. If an ongoing composition exists, then the
525 // keydown event should have arisen from a handled key (e.g., backspace). 525 // keydown event should have arisen from a handled key (e.g., backspace).
526 // In this case we ignore the cancellation and continue; otherwise (no 526 // In this case we ignore the cancellation and continue; otherwise (no
527 // ongoing composition) we exit and signal success only for attempts to 527 // ongoing composition) we exit and signal success only for attempts to
528 // clear the composition. 528 // clear the composition.
529 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) 529 if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition())
530 return text.isEmpty(); 530 return text.isEmpty();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 if (toHTMLTextAreaElement(*element).isDisabledOrReadOnly()) 708 if (toHTMLTextAreaElement(*element).isDisabledOrReadOnly())
709 return WebTextInputTypeNone; 709 return WebTextInputTypeNone;
710 return WebTextInputTypeTextArea; 710 return WebTextInputTypeTextArea;
711 } 711 }
712 712
713 if (element->isHTMLElement()) { 713 if (element->isHTMLElement()) {
714 if (toHTMLElement(element)->isDateTimeFieldElement()) 714 if (toHTMLElement(element)->isDateTimeFieldElement())
715 return WebTextInputTypeDateTimeField; 715 return WebTextInputTypeDateTimeField;
716 } 716 }
717 717
718 if (element->isContentEditable()) 718 if (isContentEditable(*element))
719 return WebTextInputTypeContentEditable; 719 return WebTextInputTypeContentEditable;
720 720
721 return WebTextInputTypeNone; 721 return WebTextInputTypeNone;
722 } 722 }
723 723
724 WebColor WebFrameWidgetImpl::backgroundColor() const 724 WebColor WebFrameWidgetImpl::backgroundColor() const
725 { 725 {
726 if (isTransparent()) 726 if (isTransparent())
727 return Color::transparent; 727 return Color::transparent;
728 if (!m_localRoot->frameView()) 728 if (!m_localRoot->frameView())
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 } 1458 }
1459 1459
1460 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const 1460 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const
1461 { 1461 {
1462 if (!m_imeAcceptEvents) 1462 if (!m_imeAcceptEvents)
1463 return nullptr; 1463 return nullptr;
1464 return focusedLocalFrameInWidget(); 1464 return focusedLocalFrameInWidget();
1465 } 1465 }
1466 1466
1467 } // namespace blink 1467 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698