| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 ++deletion_end; | 256 ++deletion_end; |
| 257 } | 257 } |
| 258 if (!forward_machine.AtCodePointBoundary()) | 258 if (!forward_machine.AtCodePointBoundary()) |
| 259 return kInvalidDeletionLength; | 259 return kInvalidDeletionLength; |
| 260 | 260 |
| 261 const int offset = forward_machine.GetBoundaryOffset(); | 261 const int offset = forward_machine.GetBoundaryOffset(); |
| 262 DCHECK_EQ(offset, deletion_end - selection_end); | 262 DCHECK_EQ(offset, deletion_end - selection_end); |
| 263 return offset; | 263 return offset; |
| 264 } | 264 } |
| 265 | 265 |
| 266 Element* RootEditableElementOfSelection(const FrameSelection& selection) { | 266 Element* RootEditableElementOfSelection(const FrameSelection& frameSelection) { |
| 267 return RootEditableElementOf(selection.GetSelectionInDOMTree().Base()); | 267 const SelectionInDOMTree& selection = frameSelection.GetSelectionInDOMTree(); |
| 268 if (selection.IsNone()) |
| 269 return nullptr; |
| 270 // To avoid update layout, we attempt to get root editable element from |
| 271 // a position where script/user specified. |
| 272 if (Element* editable = RootEditableElementOf(selection.Base())) |
| 273 return editable; |
| 274 |
| 275 // This is work around for applications assumes a position before editable |
| 276 // element as editable[1] |
| 277 // [1] http://crbug.com/712761 |
| 278 |
| 279 // TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets |
| 280 // needs to be audited. see http://crbug.com/590369 for more details. |
| 281 frameSelection.GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 282 const VisibleSelection& visibleSeleciton = |
| 283 frameSelection.ComputeVisibleSelectionInDOMTree(); |
| 284 return RootEditableElementOf(visibleSeleciton.Start()); |
| 268 } | 285 } |
| 269 | 286 |
| 270 } // anonymous namespace | 287 } // anonymous namespace |
| 271 | 288 |
| 272 InputMethodController* InputMethodController::Create(LocalFrame& frame) { | 289 InputMethodController* InputMethodController::Create(LocalFrame& frame) { |
| 273 return new InputMethodController(frame); | 290 return new InputMethodController(frame); |
| 274 } | 291 } |
| 275 | 292 |
| 276 InputMethodController::InputMethodController(LocalFrame& frame) | 293 InputMethodController::InputMethodController(LocalFrame& frame) |
| 277 : frame_(&frame), has_composition_(false) {} | 294 : frame_(&frame), has_composition_(false) {} |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 FinishComposingText(kKeepSelection); | 1247 FinishComposingText(kKeepSelection); |
| 1231 } | 1248 } |
| 1232 | 1249 |
| 1233 DEFINE_TRACE(InputMethodController) { | 1250 DEFINE_TRACE(InputMethodController) { |
| 1234 visitor->Trace(frame_); | 1251 visitor->Trace(frame_); |
| 1235 visitor->Trace(composition_range_); | 1252 visitor->Trace(composition_range_); |
| 1236 SynchronousMutationObserver::Trace(visitor); | 1253 SynchronousMutationObserver::Trace(visitor); |
| 1237 } | 1254 } |
| 1238 | 1255 |
| 1239 } // namespace blink | 1256 } // namespace blink |
| OLD | NEW |