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 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 LayoutUnit extraWidthToEndOfLine; | 1166 LayoutUnit extraWidthToEndOfLine; |
1167 DCHECK(range.isNotNull()); | 1167 DCHECK(range.isNotNull()); |
1168 | 1168 |
1169 IntRect startCaretRect = RenderedPosition(createVisiblePositionDeprecated(ra
nge.startPosition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&e
xtraWidthToEndOfLine); | 1169 IntRect startCaretRect = RenderedPosition(createVisiblePosition(range.startP
osition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&extraWidthT
oEndOfLine); |
1170 if (startCaretRect.isEmpty()) | 1170 if (startCaretRect.isEmpty()) |
1171 return IntRect(); | 1171 return IntRect(); |
1172 | 1172 |
1173 IntRect endCaretRect = RenderedPosition(createVisiblePositionDeprecated(rang
e.endPosition()).deepEquivalent(), TextAffinity::Upstream).absoluteRect(); | 1173 IntRect endCaretRect = RenderedPosition(createVisiblePosition(range.endPosit
ion()).deepEquivalent(), TextAffinity::Upstream).absoluteRect(); |
1174 if (endCaretRect.isEmpty()) | 1174 if (endCaretRect.isEmpty()) |
1175 return IntRect(); | 1175 return IntRect(); |
1176 | 1176 |
1177 if (startCaretRect.y() == endCaretRect.y()) { | 1177 if (startCaretRect.y() == endCaretRect.y()) { |
1178 // start and end are on the same line | 1178 // start and end are on the same line |
1179 return IntRect(std::min(startCaretRect.x(), endCaretRect.x()), | 1179 return IntRect(std::min(startCaretRect.x(), endCaretRect.x()), |
1180 startCaretRect.y(), | 1180 startCaretRect.y(), |
1181 abs(endCaretRect.x() - startCaretRect.x()), | 1181 abs(endCaretRect.x() - startCaretRect.x()), |
1182 std::max(startCaretRect.height(), endCaretRect.height())); | 1182 std::max(startCaretRect.height(), endCaretRect.height())); |
1183 } | 1183 } |
1184 | 1184 |
1185 // start and end aren't on the same line, so go from start to the end of its
line | 1185 // start and end aren't on the same line, so go from start to the end of its
line |
1186 return IntRect(startCaretRect.x(), | 1186 return IntRect(startCaretRect.x(), |
1187 startCaretRect.y(), | 1187 startCaretRect.y(), |
1188 (startCaretRect.width() + extraWidthToEndOfLine).toInt(), | 1188 (startCaretRect.width() + extraWidthToEndOfLine).toInt(), |
1189 startCaretRect.height()); | 1189 startCaretRect.height()); |
1190 } | 1190 } |
1191 | 1191 |
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) | 1192 void Editor::computeAndSetTypingStyle(StylePropertySet* style, InputEvent::Input
Type inputType) |
1199 { | 1193 { |
1200 if (!style || style->isEmpty()) { | 1194 if (!style || style->isEmpty()) { |
1201 frame().selection().clearTypingStyle(); | 1195 frame().selection().clearTypingStyle(); |
1202 return; | 1196 return; |
1203 } | 1197 } |
1204 | 1198 |
1205 // Calculate the current typing style. | 1199 // Calculate the current typing style. |
1206 EditingStyle* typingStyle = nullptr; | 1200 EditingStyle* typingStyle = nullptr; |
1207 if (frame().selection().typingStyle()) { | 1201 if (frame().selection().typingStyle()) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 | 1414 |
1421 DEFINE_TRACE(Editor) | 1415 DEFINE_TRACE(Editor) |
1422 { | 1416 { |
1423 visitor->trace(m_frame); | 1417 visitor->trace(m_frame); |
1424 visitor->trace(m_lastEditCommand); | 1418 visitor->trace(m_lastEditCommand); |
1425 visitor->trace(m_undoStack); | 1419 visitor->trace(m_undoStack); |
1426 visitor->trace(m_mark); | 1420 visitor->trace(m_mark); |
1427 } | 1421 } |
1428 | 1422 |
1429 } // namespace blink | 1423 } // namespace blink |
OLD | NEW |