| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 shadowAncestorElement = editableRoot.get(); | 169 shadowAncestorElement = editableRoot.get(); |
| 170 | 170 |
| 171 if (!editableRoot->getAttributeEventListener(EventTypeNames::webkitBeforeTex
tInserted) | 171 if (!editableRoot->getAttributeEventListener(EventTypeNames::webkitBeforeTex
tInserted) |
| 172 // FIXME: Remove these checks once textareas and textfields actually reg
ister an event handler. | 172 // FIXME: Remove these checks once textareas and textfields actually reg
ister an event handler. |
| 173 && !(shadowAncestorElement && shadowAncestorElement->layoutObject() && s
hadowAncestorElement->layoutObject()->isTextControl()) | 173 && !(shadowAncestorElement && shadowAncestorElement->layoutObject() && s
hadowAncestorElement->layoutObject()->isTextControl()) |
| 174 && editableRoot->layoutObjectIsRichlyEditable()) { | 174 && editableRoot->layoutObjectIsRichlyEditable()) { |
| 175 removeInterchangeNodes(m_fragment.get()); | 175 removeInterchangeNodes(m_fragment.get()); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 | 178 |
| 179 if (!editableRoot->layoutObjectIsRichlyEditable()) { |
| 180 bool isPlainText = true; |
| 181 for (Node& node : NodeTraversal::childrenOf(*m_fragment)) { |
| 182 if (isInterchangeHTMLBRElement(&node) && &node == m_fragment->lastCh
ild()) |
| 183 continue; |
| 184 if (!node.isTextNode()) { |
| 185 isPlainText = false; |
| 186 break; |
| 187 } |
| 188 } |
| 189 // We don't need TestRendering for plain-text editing + plain-text inser
tion. |
| 190 if (isPlainText) { |
| 191 removeInterchangeNodes(m_fragment.get()); |
| 192 String originalText = m_fragment->textContent(); |
| 193 RefPtrWillBeRawPtr<BeforeTextInsertedEvent> event = BeforeTextInsert
edEvent::create(originalText); |
| 194 editableRoot->dispatchEvent(event); |
| 195 if (originalText != event->text()) { |
| 196 m_fragment = createFragmentFromText(selection.toNormalizedEpheme
ralRange(), event->text()); |
| 197 removeInterchangeNodes(m_fragment.get()); |
| 198 } |
| 199 return; |
| 200 } |
| 201 } |
| 202 |
| 179 RefPtrWillBeRawPtr<HTMLElement> holder = insertFragmentForTestRendering(edit
ableRoot.get()); | 203 RefPtrWillBeRawPtr<HTMLElement> holder = insertFragmentForTestRendering(edit
ableRoot.get()); |
| 180 if (!holder) { | 204 if (!holder) { |
| 181 removeInterchangeNodes(m_fragment.get()); | 205 removeInterchangeNodes(m_fragment.get()); |
| 182 return; | 206 return; |
| 183 } | 207 } |
| 184 | 208 |
| 185 const EphemeralRange range = VisibleSelection::selectionFromContentsOfNode(h
older.get()).toNormalizedEphemeralRange(); | 209 const EphemeralRange range = VisibleSelection::selectionFromContentsOfNode(h
older.get()).toNormalizedEphemeralRange(); |
| 186 String text = plainText(range, static_cast<TextIteratorBehavior>(TextIterato
rEmitsOriginalText | TextIteratorIgnoresStyleVisibility)); | 210 String text = plainText(range, static_cast<TextIteratorBehavior>(TextIterato
rEmitsOriginalText | TextIteratorIgnoresStyleVisibility)); |
| 187 | 211 |
| 188 removeInterchangeNodes(holder.get()); | 212 removeInterchangeNodes(holder.get()); |
| (...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 visitor->trace(m_startOfInsertedContent); | 1698 visitor->trace(m_startOfInsertedContent); |
| 1675 visitor->trace(m_endOfInsertedContent); | 1699 visitor->trace(m_endOfInsertedContent); |
| 1676 visitor->trace(m_insertionStyle); | 1700 visitor->trace(m_insertionStyle); |
| 1677 visitor->trace(m_documentFragment); | 1701 visitor->trace(m_documentFragment); |
| 1678 visitor->trace(m_startOfInsertedRange); | 1702 visitor->trace(m_startOfInsertedRange); |
| 1679 visitor->trace(m_endOfInsertedRange); | 1703 visitor->trace(m_endOfInsertedRange); |
| 1680 CompositeEditCommand::trace(visitor); | 1704 CompositeEditCommand::trace(visitor); |
| 1681 } | 1705 } |
| 1682 | 1706 |
| 1683 } // namespace blink | 1707 } // namespace blink |
| OLD | NEW |