| OLD | NEW |
| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 // In case of exceeding the left boundary. | 393 // In case of exceeding the left boundary. |
| 394 int selectionOffsetsStart = static_cast<int>(getSelectionOffsets().start()); | 394 int selectionOffsetsStart = static_cast<int>(getSelectionOffsets().start()); |
| 395 int start = std::max(selectionOffsetsStart + selectionStart, 0); | 395 int start = std::max(selectionOffsetsStart + selectionStart, 0); |
| 396 int end = std::max(selectionOffsetsStart + selectionEnd, start); | 396 int end = std::max(selectionOffsetsStart + selectionEnd, start); |
| 397 | 397 |
| 398 Element* rootEditableElement = frame().selection().rootEditableElement(); | 398 Element* rootEditableElement = frame().selection().rootEditableElement(); |
| 399 if (!rootEditableElement) | 399 if (!rootEditableElement) |
| 400 return; | 400 return; |
| 401 | 401 |
| 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 |
| 402 // In case of exceeding the right boundary. | 406 // In case of exceeding the right boundary. |
| 403 // If both |value1| and |value2| exceed right boundary, | 407 // If both |value1| and |value2| exceed right boundary, |
| 404 // PlainTextRange(value1, value2)::createRange() will return a default | 408 // PlainTextRange(value1, value2)::createRange() will return a default |
| 405 // 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, |
| 406 // we should make sure |value1| is within range at least. | 410 // we should make sure |value1| is within range at least. |
| 407 const EphemeralRange& startRange = PlainTextRange(0, start).createRange(*roo
tEditableElement); | 411 const EphemeralRange& startRange = PlainTextRange(0, start).createRange(*roo
tEditableElement); |
| 408 const EphemeralRange& endRange = PlainTextRange(0, end).createRange(*rootEdi
tableElement); | 412 const EphemeralRange& endRange = PlainTextRange(0, end).createRange(*rootEdi
tableElement); |
| 409 | 413 |
| 410 // 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 |
| 411 // |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 17 matching lines...) Expand all Loading... |
| 429 frame().document()->markers().addCompositionMarker(ephemeralLineRange.st
artPosition(), ephemeralLineRange.endPosition(), underline.color, underline.thic
k, underline.backgroundColor); | 433 frame().document()->markers().addCompositionMarker(ephemeralLineRange.st
artPosition(), ephemeralLineRange.endPosition(), underline.color, underline.thic
k, underline.backgroundColor); |
| 430 } | 434 } |
| 431 } | 435 } |
| 432 | 436 |
| 433 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) | 437 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) |
| 434 { | 438 { |
| 435 Element* editable = frame().selection().rootEditableElement(); | 439 Element* editable = frame().selection().rootEditableElement(); |
| 436 if (!editable) | 440 if (!editable) |
| 437 return; | 441 return; |
| 438 | 442 |
| 443 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n
eeds to be audited. |
| 444 // see http://crbug.com/590369 for more details. |
| 445 editable->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 446 |
| 439 const EphemeralRange range = PlainTextRange(compositionStart, compositionEnd
).createRange(*editable); | 447 const EphemeralRange range = PlainTextRange(compositionStart, compositionEnd
).createRange(*editable); |
| 440 if (range.isNull()) | 448 if (range.isNull()) |
| 441 return; | 449 return; |
| 442 | 450 |
| 443 const Position start = range.startPosition(); | 451 const Position start = range.startPosition(); |
| 444 if (rootEditableElementOf(start) != editable) | 452 if (rootEditableElementOf(start) != editable) |
| 445 return; | 453 return; |
| 446 | 454 |
| 447 const Position end = range.endPosition(); | 455 const Position end = range.endPosition(); |
| 448 if (rootEditableElementOf(end) != editable) | 456 if (rootEditableElementOf(end) != editable) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 } | 502 } |
| 495 | 503 |
| 496 bool InputMethodController::setSelectionOffsets(const PlainTextRange& selectionO
ffsets) | 504 bool InputMethodController::setSelectionOffsets(const PlainTextRange& selectionO
ffsets) |
| 497 { | 505 { |
| 498 if (selectionOffsets.isNull()) | 506 if (selectionOffsets.isNull()) |
| 499 return false; | 507 return false; |
| 500 Element* rootEditableElement = frame().selection().rootEditableElement(); | 508 Element* rootEditableElement = frame().selection().rootEditableElement(); |
| 501 if (!rootEditableElement) | 509 if (!rootEditableElement) |
| 502 return false; | 510 return false; |
| 503 | 511 |
| 512 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n
eeds to be audited. |
| 513 // see http://crbug.com/590369 for more details. |
| 514 rootEditableElement->document().updateStyleAndLayoutIgnorePendingStylesheets
(); |
| 515 |
| 504 const EphemeralRange range = selectionOffsets.createRange(*rootEditableEleme
nt); | 516 const EphemeralRange range = selectionOffsets.createRange(*rootEditableEleme
nt); |
| 505 if (range.isNull()) | 517 if (range.isNull()) |
| 506 return false; | 518 return false; |
| 507 | 519 |
| 508 return frame().selection().setSelectedRange(range, VP_DEFAULT_AFFINITY, Sele
ctionDirectionalMode::NonDirectional, FrameSelection::CloseTyping); | 520 return frame().selection().setSelectedRange(range, VP_DEFAULT_AFFINITY, Sele
ctionDirectionalMode::NonDirectional, FrameSelection::CloseTyping); |
| 509 } | 521 } |
| 510 | 522 |
| 511 bool InputMethodController::setEditableSelectionOffsets(const PlainTextRange& se
lectionOffsets) | 523 bool InputMethodController::setEditableSelectionOffsets(const PlainTextRange& se
lectionOffsets) |
| 512 { | 524 { |
| 513 if (!editor().canEdit()) | 525 if (!editor().canEdit()) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 TypingCommand::deleteSelection(*frame().document()); | 560 TypingCommand::deleteSelection(*frame().document()); |
| 549 } | 561 } |
| 550 | 562 |
| 551 DEFINE_TRACE(InputMethodController) | 563 DEFINE_TRACE(InputMethodController) |
| 552 { | 564 { |
| 553 visitor->trace(m_frame); | 565 visitor->trace(m_frame); |
| 554 visitor->trace(m_compositionRange); | 566 visitor->trace(m_compositionRange); |
| 555 } | 567 } |
| 556 | 568 |
| 557 } // namespace blink | 569 } // namespace blink |
| OLD | NEW |