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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 { | 286 { |
287 Node* startContainer = range.startPosition().computeContainerNode(); | 287 Node* startContainer = range.startPosition().computeContainerNode(); |
288 Node* endContainer = range.endPosition().computeContainerNode(); | 288 Node* endContainer = range.endPosition().computeContainerNode(); |
289 if (!startContainer || !endContainer) | 289 if (!startContainer || !endContainer) |
290 return false; | 290 return false; |
291 | 291 |
292 if (!hasEditableStyle(*startContainer) || !hasEditableStyle(*endContainer)) | 292 if (!hasEditableStyle(*startContainer) || !hasEditableStyle(*endContainer)) |
293 return false; | 293 return false; |
294 | 294 |
295 if (range.isCollapsed()) { | 295 if (range.isCollapsed()) { |
296 VisiblePosition start = createVisiblePosition(range.startPosition()); | 296 VisiblePosition start = createVisiblePositionDeprecated(range.startPosit
ion()); |
297 VisiblePosition previous = previousPositionOf(start); | 297 VisiblePosition previous = previousPositionOf(start); |
298 // FIXME: We sometimes allow deletions at the start of editable roots, l
ike when the caret is in an empty list item. | 298 // FIXME: We sometimes allow deletions at the start of editable roots, l
ike when the caret is in an empty list item. |
299 if (previous.isNull() || rootEditableElement(*previous.deepEquivalent().
anchorNode()) != rootEditableElement(*startContainer)) | 299 if (previous.isNull() || rootEditableElement(*previous.deepEquivalent().
anchorNode()) != rootEditableElement(*startContainer)) |
300 return false; | 300 return false; |
301 } | 301 } |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 bool Editor::smartInsertDeleteEnabled() const | 305 bool Editor::smartInsertDeleteEnabled() const |
306 { | 306 { |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 // starts a new kill ring sequence, but we want to do these things (matches
AppKit). | 1174 // starts a new kill ring sequence, but we want to do these things (matches
AppKit). |
1175 if (selectionDidNotChangeDOMPosition) | 1175 if (selectionDidNotChangeDOMPosition) |
1176 client().respondToChangedSelection(m_frame, frame().selection().getSelec
tionType()); | 1176 client().respondToChangedSelection(m_frame, frame().selection().getSelec
tionType()); |
1177 } | 1177 } |
1178 | 1178 |
1179 IntRect Editor::firstRectForRange(const EphemeralRange& range) const | 1179 IntRect Editor::firstRectForRange(const EphemeralRange& range) const |
1180 { | 1180 { |
1181 LayoutUnit extraWidthToEndOfLine; | 1181 LayoutUnit extraWidthToEndOfLine; |
1182 DCHECK(range.isNotNull()); | 1182 DCHECK(range.isNotNull()); |
1183 | 1183 |
1184 IntRect startCaretRect = RenderedPosition(createVisiblePosition(range.startP
osition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&extraWidthT
oEndOfLine); | 1184 IntRect startCaretRect = RenderedPosition(createVisiblePositionDeprecated(ra
nge.startPosition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&e
xtraWidthToEndOfLine); |
1185 if (startCaretRect.isEmpty()) | 1185 if (startCaretRect.isEmpty()) |
1186 return IntRect(); | 1186 return IntRect(); |
1187 | 1187 |
1188 IntRect endCaretRect = RenderedPosition(createVisiblePosition(range.endPosit
ion()).deepEquivalent(), TextAffinity::Upstream).absoluteRect(); | 1188 IntRect endCaretRect = RenderedPosition(createVisiblePositionDeprecated(rang
e.endPosition()).deepEquivalent(), TextAffinity::Upstream).absoluteRect(); |
1189 if (endCaretRect.isEmpty()) | 1189 if (endCaretRect.isEmpty()) |
1190 return IntRect(); | 1190 return IntRect(); |
1191 | 1191 |
1192 if (startCaretRect.y() == endCaretRect.y()) { | 1192 if (startCaretRect.y() == endCaretRect.y()) { |
1193 // start and end are on the same line | 1193 // start and end are on the same line |
1194 return IntRect(std::min(startCaretRect.x(), endCaretRect.x()), | 1194 return IntRect(std::min(startCaretRect.x(), endCaretRect.x()), |
1195 startCaretRect.y(), | 1195 startCaretRect.y(), |
1196 abs(endCaretRect.x() - startCaretRect.x()), | 1196 abs(endCaretRect.x() - startCaretRect.x()), |
1197 std::max(startCaretRect.height(), endCaretRect.height())); | 1197 std::max(startCaretRect.height(), endCaretRect.height())); |
1198 } | 1198 } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 | 1435 |
1436 DEFINE_TRACE(Editor) | 1436 DEFINE_TRACE(Editor) |
1437 { | 1437 { |
1438 visitor->trace(m_frame); | 1438 visitor->trace(m_frame); |
1439 visitor->trace(m_lastEditCommand); | 1439 visitor->trace(m_lastEditCommand); |
1440 visitor->trace(m_undoStack); | 1440 visitor->trace(m_undoStack); |
1441 visitor->trace(m_mark); | 1441 visitor->trace(m_mark); |
1442 } | 1442 } |
1443 | 1443 |
1444 } // namespace blink | 1444 } // namespace blink |
OLD | NEW |