| 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 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 // WebCore inserts <div><br></div> *before* the current block, which correct
ly moves the paragraph down but which doesn't | 1156 // WebCore inserts <div><br></div> *before* the current block, which correct
ly moves the paragraph down but which doesn't |
| 1157 // change the caret's DOM position (["hello", 0]). In these situations the a
bove FrameSelection::setSelection call | 1157 // change the caret's DOM position (["hello", 0]). In these situations the a
bove FrameSelection::setSelection call |
| 1158 // does not call EditorClient::respondToChangedSelection(), which, on the Ma
c, sends selection change notifications and | 1158 // does not call EditorClient::respondToChangedSelection(), which, on the Ma
c, sends selection change notifications and |
| 1159 // starts a new kill ring sequence, but we want to do these things (matches
AppKit). | 1159 // starts a new kill ring sequence, but we want to do these things (matches
AppKit). |
| 1160 if (selectionDidNotChangeDOMPosition) | 1160 if (selectionDidNotChangeDOMPosition) |
| 1161 client().respondToChangedSelection(m_frame, frame().selection().getSelec
tionType()); | 1161 client().respondToChangedSelection(m_frame, frame().selection().getSelec
tionType()); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 IntRect Editor::firstRectForRange(const EphemeralRange& range) const | 1164 IntRect Editor::firstRectForRange(const EphemeralRange& range) const |
| 1165 { | 1165 { |
| 1166 DCHECK(!frame().document()->needsLayoutTreeUpdate()); |
| 1167 DocumentLifecycle::DisallowTransitionScope disallowTransition(frame().docume
nt()->lifecycle()); |
| 1168 |
| 1166 LayoutUnit extraWidthToEndOfLine; | 1169 LayoutUnit extraWidthToEndOfLine; |
| 1167 DCHECK(range.isNotNull()); | 1170 DCHECK(range.isNotNull()); |
| 1168 | 1171 |
| 1169 IntRect startCaretRect = RenderedPosition(createVisiblePositionDeprecated(ra
nge.startPosition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&e
xtraWidthToEndOfLine); | 1172 IntRect startCaretRect = RenderedPosition(createVisiblePosition(range.startP
osition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&extraWidthT
oEndOfLine); |
| 1170 if (startCaretRect.isEmpty()) | 1173 if (startCaretRect.isEmpty()) |
| 1171 return IntRect(); | 1174 return IntRect(); |
| 1172 | 1175 |
| 1173 IntRect endCaretRect = RenderedPosition(createVisiblePositionDeprecated(rang
e.endPosition()).deepEquivalent(), TextAffinity::Upstream).absoluteRect(); | 1176 IntRect endCaretRect = RenderedPosition(createVisiblePosition(range.endPosit
ion()).deepEquivalent(), TextAffinity::Upstream).absoluteRect(); |
| 1174 if (endCaretRect.isEmpty()) | 1177 if (endCaretRect.isEmpty()) |
| 1175 return IntRect(); | 1178 return IntRect(); |
| 1176 | 1179 |
| 1177 if (startCaretRect.y() == endCaretRect.y()) { | 1180 if (startCaretRect.y() == endCaretRect.y()) { |
| 1178 // start and end are on the same line | 1181 // start and end are on the same line |
| 1179 return IntRect(std::min(startCaretRect.x(), endCaretRect.x()), | 1182 return IntRect(std::min(startCaretRect.x(), endCaretRect.x()), |
| 1180 startCaretRect.y(), | 1183 startCaretRect.y(), |
| 1181 abs(endCaretRect.x() - startCaretRect.x()), | 1184 abs(endCaretRect.x() - startCaretRect.x()), |
| 1182 std::max(startCaretRect.height(), endCaretRect.height())); | 1185 std::max(startCaretRect.height(), endCaretRect.height())); |
| 1183 } | 1186 } |
| 1184 | 1187 |
| 1185 // start and end aren't on the same line, so go from start to the end of its
line | 1188 // start and end aren't on the same line, so go from start to the end of its
line |
| 1186 return IntRect(startCaretRect.x(), | 1189 return IntRect(startCaretRect.x(), |
| 1187 startCaretRect.y(), | 1190 startCaretRect.y(), |
| 1188 (startCaretRect.width() + extraWidthToEndOfLine).toInt(), | 1191 (startCaretRect.width() + extraWidthToEndOfLine).toInt(), |
| 1189 startCaretRect.height()); | 1192 startCaretRect.height()); |
| 1190 } | 1193 } |
| 1191 | 1194 |
| 1192 IntRect Editor::firstRectForRange(const Range* range) const | |
| 1193 { | |
| 1194 DCHECK(range); | |
| 1195 return firstRectForRange(EphemeralRange(range)); | |
| 1196 } | |
| 1197 | |
| 1198 void Editor::computeAndSetTypingStyle(StylePropertySet* style, InputEvent::Input
Type inputType) | 1195 void Editor::computeAndSetTypingStyle(StylePropertySet* style, InputEvent::Input
Type inputType) |
| 1199 { | 1196 { |
| 1200 if (!style || style->isEmpty()) { | 1197 if (!style || style->isEmpty()) { |
| 1201 frame().selection().clearTypingStyle(); | 1198 frame().selection().clearTypingStyle(); |
| 1202 return; | 1199 return; |
| 1203 } | 1200 } |
| 1204 | 1201 |
| 1205 // Calculate the current typing style. | 1202 // Calculate the current typing style. |
| 1206 EditingStyle* typingStyle = nullptr; | 1203 EditingStyle* typingStyle = nullptr; |
| 1207 if (frame().selection().typingStyle()) { | 1204 if (frame().selection().typingStyle()) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 | 1417 |
| 1421 DEFINE_TRACE(Editor) | 1418 DEFINE_TRACE(Editor) |
| 1422 { | 1419 { |
| 1423 visitor->trace(m_frame); | 1420 visitor->trace(m_frame); |
| 1424 visitor->trace(m_lastEditCommand); | 1421 visitor->trace(m_lastEditCommand); |
| 1425 visitor->trace(m_undoStack); | 1422 visitor->trace(m_undoStack); |
| 1426 visitor->trace(m_mark); | 1423 visitor->trace(m_mark); |
| 1427 } | 1424 } |
| 1428 | 1425 |
| 1429 } // namespace blink | 1426 } // namespace blink |
| OLD | NEW |