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

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodController.cpp

Issue 2147303003: Update layout at required place in InputMethodController::setComposition() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-15T16:00:21 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 357
358 DCHECK(!text.isEmpty()); 358 DCHECK(!text.isEmpty());
359 359
360 clear(); 360 clear();
361 361
362 insertTextDuringCompositionWithEvents(frame(), text, TypingCommand::SelectIn sertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextComposition Update); 362 insertTextDuringCompositionWithEvents(frame(), text, TypingCommand::SelectIn sertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextComposition Update);
363 // Event handlers might destroy document. 363 // Event handlers might destroy document.
364 if (!frame().document()) 364 if (!frame().document())
365 return; 365 return;
366 366
367 // TODO(yosin): The use of updateStyleAndLayoutIgnorePendingStylesheets
368 // needs to be audited. see http://crbug.com/590369 for more details.
369 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
370
367 // Find out what node has the composition now. 371 // Find out what node has the composition now.
368 Position base = mostForwardCaretPosition(frame().selection().base()); 372 Position base = mostForwardCaretPosition(frame().selection().base());
369 Node* baseNode = base.anchorNode(); 373 Node* baseNode = base.anchorNode();
370 if (!baseNode || !baseNode->isTextNode()) 374 if (!baseNode || !baseNode->isTextNode())
371 return; 375 return;
372 376
373 Position extent = frame().selection().extent(); 377 Position extent = frame().selection().extent();
374 Node* extentNode = extent.anchorNode(); 378 Node* extentNode = extent.anchorNode();
375 if (baseNode != extentNode) 379 if (baseNode != extentNode)
376 return; 380 return;
(...skipping 15 matching lines...) Expand all
392 396
393 // In case of exceeding the left boundary. 397 // In case of exceeding the left boundary.
394 int selectionOffsetsStart = static_cast<int>(getSelectionOffsets().start()); 398 int selectionOffsetsStart = static_cast<int>(getSelectionOffsets().start());
395 int start = std::max(selectionOffsetsStart + selectionStart, 0); 399 int start = std::max(selectionOffsetsStart + selectionStart, 0);
396 int end = std::max(selectionOffsetsStart + selectionEnd, start); 400 int end = std::max(selectionOffsetsStart + selectionEnd, start);
397 401
398 Element* rootEditableElement = frame().selection().rootEditableElement(); 402 Element* rootEditableElement = frame().selection().rootEditableElement();
399 if (!rootEditableElement) 403 if (!rootEditableElement)
400 return; 404 return;
401 405
402 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited.
403 // see http://crbug.com/590369 for more details.
404 rootEditableElement->document().updateStyleAndLayoutIgnorePendingStylesheets ();
405
406 // In case of exceeding the right boundary. 406 // In case of exceeding the right boundary.
407 // If both |value1| and |value2| exceed right boundary, 407 // If both |value1| and |value2| exceed right boundary,
408 // PlainTextRange(value1, value2)::createRange() will return a default 408 // PlainTextRange(value1, value2)::createRange() will return a default
409 // value, which is [0,0]. In order to get the correct Position in that case, 409 // value, which is [0,0]. In order to get the correct Position in that case,
410 // we should make sure |value1| is within range at least. 410 // we should make sure |value1| is within range at least.
411 const EphemeralRange& startRange = PlainTextRange(0, start).createRange(*roo tEditableElement); 411 const EphemeralRange& startRange = PlainTextRange(0, start).createRange(*roo tEditableElement);
412 const EphemeralRange& endRange = PlainTextRange(0, end).createRange(*rootEdi tableElement); 412 const EphemeralRange& endRange = PlainTextRange(0, end).createRange(*rootEdi tableElement);
413 413
414 // TODO(yabinh): There should be a better way to create |startPosition| and 414 // TODO(yabinh): There should be a better way to create |startPosition| and
415 // |endPosition|. But for now, since we can't get |anchorNode| and |offset|, 415 // |endPosition|. But for now, since we can't get |anchorNode| and |offset|,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 TypingCommand::deleteSelection(*frame().document()); 560 TypingCommand::deleteSelection(*frame().document());
561 } 561 }
562 562
563 DEFINE_TRACE(InputMethodController) 563 DEFINE_TRACE(InputMethodController)
564 { 564 {
565 visitor->trace(m_frame); 565 visitor->trace(m_frame);
566 visitor->trace(m_compositionRange); 566 visitor->trace(m_compositionRange);
567 } 567 }
568 568
569 } // namespace blink 569 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698