Changeset 76226 in webkit
- Timestamp:
- Jan 20, 2011 4:36:22 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r76225 r76226 1 2011-01-20 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r76215. 4 http://trac.webkit.org/changeset/76215 5 https://bugs.webkit.org/show_bug.cgi?id=52799 6 7 Caused regressions in Chromium; morrita is going to look at it 8 tomrorow (Requested by jorlow on #webkit). 9 10 * editing/inserting/insert-composition-whitespace-expected.txt: Removed. 11 * editing/inserting/insert-composition-whitespace.html: Removed. 12 1 13 2011-01-19 Pavel Podivilov <podivilov@chromium.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r76224 r76226 1 2011-01-20 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r76215. 4 http://trac.webkit.org/changeset/76215 5 https://bugs.webkit.org/show_bug.cgi?id=52799 6 7 Caused regressions in Chromium; morrita is going to look at it 8 tomrorow (Requested by jorlow on #webkit). 9 10 * dom/TextEvent.h: 11 * dom/TextEventInputType.h: 12 * editing/CompositeEditCommand.cpp: 13 (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): 14 * editing/CompositeEditCommand.h: 15 * editing/Editor.cpp: 16 (WebCore::Editor::insertTextWithoutSendingTextEvent): 17 (WebCore::Editor::confirmComposition): 18 (WebCore::Editor::setComposition): 19 * editing/Editor.h: 20 * editing/InsertTextCommand.cpp: 21 (WebCore::InsertTextCommand::input): 22 * editing/InsertTextCommand.h: 23 * editing/TypingCommand.cpp: 24 (WebCore::TypingCommand::TypingCommand): 25 (WebCore::TypingCommand::insertText): 26 (WebCore::TypingCommand::insertTextRunWithoutNewlines): 27 * editing/TypingCommand.h: 28 (WebCore::TypingCommand::create): 29 1 30 2010-12-14 Yury Semikhatsky <yurys@chromium.org> 2 31 -
trunk/Source/WebCore/dom/TextEvent.h
r76215 r76226 52 52 53 53 bool isLineBreak() const { return m_inputType == TextEventInputLineBreak; } 54 bool isComposition() const { return m_inputType == TextEventInputComposition; }55 54 bool isBackTab() const { return m_inputType == TextEventInputBackTab; } 56 55 bool isPaste() const { return m_inputType == TextEventInputPaste; } -
trunk/Source/WebCore/dom/TextEventInputType.h
r76215 r76226 32 32 TextEventInputKeyboard, // any newline characters in the text are line breaks only, not paragraph separators. 33 33 TextEventInputLineBreak, // any tab characters in the text are backtabs. 34 TextEventInputComposition,35 34 TextEventInputBackTab, 36 35 TextEventInputPaste, -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r76215 r76226 396 396 } 397 397 398 static inline bool containsOnlyWhitespace(const String& text) 399 { 400 for (unsigned i = 0; i < text.length(); ++i) { 401 if (!isWhitespace(text.characters()[i])) 402 return false; 403 } 404 405 return true; 406 } 407 408 bool CompositeEditCommand::shouldRebalanceLeadingWhitespaceFor(const String& text) const 409 { 410 return containsOnlyWhitespace(text); 411 } 412 413 bool CompositeEditCommand::canRebalance(const Position& position) const 398 // FIXME: Doesn't go into text nodes that contribute adjacent text (siblings, cousins, etc). 399 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) 414 400 { 415 401 Node* node = position.containerNode(); 416 402 if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node || !node->isTextNode()) 417 return false; 418 403 return; 419 404 Text* textNode = static_cast<Text*>(node); 405 420 406 if (textNode->length() == 0) 421 return false; 422 407 return; 423 408 RenderObject* renderer = textNode->renderer(); 424 409 if (renderer && !renderer->style()->collapseWhiteSpace()) 425 return false; 426 427 return true; 428 } 429 430 // FIXME: Doesn't go into text nodes that contribute adjacent text (siblings, cousins, etc). 431 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) 432 { 433 Node* node = position.containerNode(); 434 if (!canRebalance(position)) 435 return; 436 437 // If the rebalance is for the single offset, and neither text[offset] nor text[offset - 1] are some form of whitespace, do nothing. 410 return; 411 412 String text = textNode->data(); 413 ASSERT(!text.isEmpty()); 414 438 415 int offset = position.deprecatedEditingOffset(); 439 String text = static_cast<Text*>(node)->data();416 // If neither text[offset] nor text[offset - 1] are some form of whitespace, do nothing. 440 417 if (!isWhitespace(text[offset])) { 441 418 offset--; … … 443 420 return; 444 421 } 445 446 rebalanceWhitespaceOnTextSubstring(static_cast<Text*>(node), position.offsetInContainerNode(), position.offsetInContainerNode()); 447 } 448 449 void CompositeEditCommand::rebalanceWhitespaceOnTextSubstring(RefPtr<Text> textNode, int startOffset, int endOffset) 450 { 451 String text = textNode->data(); 452 ASSERT(!text.isEmpty()); 453 422 454 423 // Set upstream and downstream to define the extent of the whitespace surrounding text[offset]. 455 int upstream = startOffset;424 int upstream = offset; 456 425 while (upstream > 0 && isWhitespace(text[upstream - 1])) 457 426 upstream--; 458 427 459 int downstream = endOffset;460 while ((unsigned)downstream < text.length() && isWhitespace(text[downstream]))428 int downstream = offset; 429 while ((unsigned)downstream + 1 < text.length() && isWhitespace(text[downstream + 1])) 461 430 downstream++; 462 431 463 int length = downstream - upstream; 464 if (!length) 465 return; 466 467 VisiblePosition visibleUpstreamPos(Position(textNode, upstream, Position::PositionIsOffsetInAnchor)); 468 VisiblePosition visibleDownstreamPos(Position(textNode, downstream, Position::PositionIsOffsetInAnchor)); 432 int length = downstream - upstream + 1; 433 ASSERT(length > 0); 434 435 VisiblePosition visibleUpstreamPos(Position(position.containerNode(), upstream, Position::PositionIsOffsetInAnchor)); 436 VisiblePosition visibleDownstreamPos(Position(position.containerNode(), downstream + 1, Position::PositionIsOffsetInAnchor)); 469 437 470 438 String string = text.substring(upstream, length); … … 473 441 // this function doesn't get all surrounding whitespace, just the whitespace in the current text node. 474 442 isStartOfParagraph(visibleUpstreamPos) || upstream == 0, 475 isEndOfParagraph(visibleDownstreamPos) || (unsigned)downstream == text.length() );443 isEndOfParagraph(visibleDownstreamPos) || (unsigned)downstream == text.length() - 1); 476 444 477 445 if (string != rebalancedString) -
trunk/Source/WebCore/editing/CompositeEditCommand.h
r76215 r76226 72 72 void rebalanceWhitespace(); 73 73 void rebalanceWhitespaceAt(const Position&); 74 void rebalanceWhitespaceOnTextSubstring(RefPtr<Text>, int startOffset, int endOffset);75 74 void prepareWhitespaceAtPositionForSplit(Position&); 76 bool canRebalance(const Position&) const;77 bool shouldRebalanceLeadingWhitespaceFor(const String&) const;78 75 void removeCSSProperty(PassRefPtr<StyledElement>, CSSPropertyID); 79 76 void removeNodeAttribute(PassRefPtr<Element>, const QualifiedName& attribute); -
trunk/Source/WebCore/editing/Editor.cpp
r76215 r76226 1174 1174 } 1175 1175 1176 bool Editor::insertTextForConfirmedComposition(const String& text) 1177 { 1178 return m_frame->eventHandler()->handleTextInputEvent(text, 0, TextEventInputComposition); 1179 } 1180 1181 bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectInsertedText, TextEvent* triggeringEvent) 1176 bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectInsertedText, Event* triggeringEvent) 1182 1177 { 1183 1178 if (text.isEmpty()) … … 1201 1196 1202 1197 // Insert the text 1203 TypingCommand::insertText(document.get(), text, selection, selectInsertedText, 1204 triggeringEvent && triggeringEvent->isComposition() ? TypingCommand::TextCompositionConfirm : TypingCommand::TextCompositionNone); 1198 TypingCommand::insertText(document.get(), text, selection, selectInsertedText); 1205 1199 1206 1200 // Reveal the current selection … … 1625 1619 m_customCompositionUnderlines.clear(); 1626 1620 1627 insertText ForConfirmedComposition(text);1621 insertText(text, 0); 1628 1622 1629 1623 if (preserveSelection) { … … 1694 1688 1695 1689 if (!text.isEmpty()) { 1696 TypingCommand::insertText(m_frame->document(), text, true, TypingCommand::TextCompositionUpdate);1690 TypingCommand::insertText(m_frame->document(), text, true, true); 1697 1691 1698 1692 // Find out what node has the composition now. -
trunk/Source/WebCore/editing/Editor.h
r76215 r76226 199 199 200 200 bool insertText(const String&, Event* triggeringEvent); 201 bool insertTextForConfirmedComposition(const String& text); 202 bool insertTextWithoutSendingTextEvent(const String&, bool selectInsertedText, TextEvent* triggeringEvent); 201 bool insertTextWithoutSendingTextEvent(const String&, bool selectInsertedText, Event* triggeringEvent); 203 202 bool insertLineBreak(); 204 203 bool insertParagraphSeparator(); -
trunk/Source/WebCore/editing/InsertTextCommand.cpp
r76215 r76226 107 107 } 108 108 109 void InsertTextCommand::input(const String& text, bool selectInsertedText , RebalanceType whitespaceRebalance)109 void InsertTextCommand::input(const String& text, bool selectInsertedText) 110 110 { 111 111 … … 173 173 endPosition = Position(textNode, offset + text.length()); 174 174 175 if (whitespaceRebalance == RebalanceLeadingAndTrailingWhitespaces) { 176 // The insertion may require adjusting adjacent whitespace, if it is present. 177 rebalanceWhitespaceAt(endPosition); 178 // Rebalancing on both sides isn't necessary if we've inserted only spaces. 179 if (!shouldRebalanceLeadingWhitespaceFor(text)) 180 rebalanceWhitespaceAt(startPosition); 181 } else { 182 ASSERT(whitespaceRebalance == RebalanceAllWhitespaces); 183 if (canRebalance(startPosition) && canRebalance(endPosition)) 184 rebalanceWhitespaceOnTextSubstring(textNode, startPosition.deprecatedEditingOffset(), endPosition.deprecatedEditingOffset()); 185 } 175 // The insertion may require adjusting adjacent whitespace, if it is present. 176 rebalanceWhitespaceAt(endPosition); 177 // Rebalancing on both sides isn't necessary if we've inserted a space. 178 if (text != " ") 179 rebalanceWhitespaceAt(startPosition); 186 180 } 187 181 -
trunk/Source/WebCore/editing/InsertTextCommand.h
r76215 r76226 33 33 class InsertTextCommand : public CompositeEditCommand { 34 34 public: 35 enum RebalanceType {36 RebalanceLeadingAndTrailingWhitespaces,37 RebalanceAllWhitespaces38 };39 40 35 static PassRefPtr<InsertTextCommand> create(Document* document) 41 36 { … … 43 38 } 44 39 45 void input(const String& text, bool selectInsertedText = false , RebalanceType = RebalanceLeadingAndTrailingWhitespaces);40 void input(const String& text, bool selectInsertedText = false); 46 41 47 42 private: 48 49 43 InsertTextCommand(Document*); 50 44 -
trunk/Source/WebCore/editing/TypingCommand.cpp
r76215 r76226 48 48 using namespace HTMLNames; 49 49 50 TypingCommand::TypingCommand(Document *document, ETypingCommand commandType, const String &textToInsert, bool selectInsertedText, TextGranularity granularity, TextCompositionType compositionType, 51 bool killRing) 50 TypingCommand::TypingCommand(Document *document, ETypingCommand commandType, const String &textToInsert, bool selectInsertedText, TextGranularity granularity, bool killRing) 52 51 : CompositeEditCommand(document), 53 52 m_commandType(commandType), … … 57 56 m_smartDelete(false), 58 57 m_granularity(granularity), 59 m_compositionType(compositionType),60 58 m_killRing(killRing), 61 59 m_openedByBackwardDelete(false) … … 136 134 137 135 138 void TypingCommand::insertText(Document* document, const String& text, bool selectInsertedText, TextCompositionType composition)136 void TypingCommand::insertText(Document* document, const String& text, bool selectInsertedText, bool insertedTextIsComposition) 139 137 { 140 138 ASSERT(document); … … 143 141 ASSERT(frame); 144 142 145 insertText(document, text, frame->selection()->selection(), selectInsertedText, composition);143 insertText(document, text, frame->selection()->selection(), selectInsertedText, insertedTextIsComposition); 146 144 } 147 145 148 146 // FIXME: We shouldn't need to take selectionForInsertion. It should be identical to SelectionController's current selection. 149 void TypingCommand::insertText(Document* document, const String& text, const VisibleSelection& selectionForInsertion, bool selectInsertedText, TextCompositionType compositionType)147 void TypingCommand::insertText(Document* document, const String& text, const VisibleSelection& selectionForInsertion, bool selectInsertedText, bool insertedTextIsComposition) 150 148 { 151 149 #if REMOVE_MARKERS_UPON_EDITING … … 164 162 Node* startNode = selectionForInsertion.start().node(); 165 163 166 if (startNode && startNode->rootEditableElement() && compositionType != TextCompositionUpdate) {164 if (startNode && startNode->rootEditableElement() && !insertedTextIsComposition) { 167 165 // Send BeforeTextInsertedEvent. The event handler will update text if necessary. 168 166 ExceptionCode ec = 0; … … 185 183 lastTypingCommand->setEndingSelection(selectionForInsertion); 186 184 } 187 188 lastTypingCommand->setCompositionType(compositionType);189 185 lastTypingCommand->insertText(newText, selectInsertedText); 190 186 return; 191 187 } 192 188 193 RefPtr<TypingCommand> cmd = TypingCommand::create(document, InsertText, newText, selectInsertedText , compositionType);189 RefPtr<TypingCommand> cmd = TypingCommand::create(document, InsertText, newText, selectInsertedText); 194 190 if (changeSelection) { 195 191 cmd->setStartingSelection(selectionForInsertion); … … 391 387 command->setEndingSelection(endingSelection()); 392 388 } 393 command->input(text, selectInsertedText, 394 m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces); 389 command->input(text, selectInsertedText); 395 390 typingAddedToOpenCommand(InsertText); 396 391 } -
trunk/Source/WebCore/editing/TypingCommand.h
r76215 r76226 43 43 }; 44 44 45 enum TextCompositionType {46 TextCompositionNone,47 TextCompositionUpdate,48 TextCompositionConfirm49 };50 51 45 static void deleteSelection(Document*, bool smartDelete = false); 52 46 static void deleteKeyPressed(Document*, bool smartDelete = false, TextGranularity = CharacterGranularity, bool killRing = false); 53 47 static void forwardDeleteKeyPressed(Document*, bool smartDelete = false, TextGranularity = CharacterGranularity, bool killRing = false); 54 static void insertText(Document*, const String&, bool selectInsertedText = false, TextCompositionType = TextCompositionNone);55 static void insertText(Document*, const String&, const VisibleSelection&, bool selectInsertedText = false, TextCompositionType = TextCompositionNone);48 static void insertText(Document*, const String&, bool selectInsertedText = false, bool insertedTextIsComposition = false); 49 static void insertText(Document*, const String&, const VisibleSelection&, bool selectInsertedText = false, bool insertedTextIsComposition = false); 56 50 static void insertLineBreak(Document*); 57 51 static void insertParagraphSeparator(Document*); … … 71 65 void forwardDeleteKeyPressed(TextGranularity, bool killRing); 72 66 void deleteSelection(bool smartDelete); 73 void setCompositionType(TextCompositionType type) { m_compositionType = type; }74 67 75 68 private: 76 69 static PassRefPtr<TypingCommand> create(Document* document, ETypingCommand command, const String& text = "", bool selectInsertedText = false, TextGranularity granularity = CharacterGranularity, bool killRing = false) 77 70 { 78 return adoptRef(new TypingCommand(document, command, text, selectInsertedText, granularity, TextCompositionNone,killRing));71 return adoptRef(new TypingCommand(document, command, text, selectInsertedText, granularity, killRing)); 79 72 } 80 73 81 static PassRefPtr<TypingCommand> create(Document* document, ETypingCommand command, const String& text, bool selectInsertedText, TextCompositionType compositionType) 82 { 83 return adoptRef(new TypingCommand(document, command, text, selectInsertedText, CharacterGranularity, compositionType, false)); 84 } 85 86 TypingCommand(Document*, ETypingCommand, const String& text, bool selectInsertedText, TextGranularity, TextCompositionType, bool killRing); 74 TypingCommand(Document*, ETypingCommand, const String& text, bool selectInsertedText, TextGranularity, bool killRing); 87 75 88 76 bool smartDelete() const { return m_smartDelete; } … … 107 95 bool m_smartDelete; 108 96 TextGranularity m_granularity; 109 TextCompositionType m_compositionType;110 97 bool m_killRing; 111 98 bool m_preservesTypingStyle;
Note: See TracChangeset
for help on using the changeset viewer.