|
Lines 286-297
bool Editor::handleTextEvent(TextEvent*
Source/WebCore/editing/Editor.cpp_sec1
|
| 286 |
|
286 |
|
| 287 |
bool Editor::canEdit() const |
287 |
bool Editor::canEdit() const |
| 288 |
{ |
288 |
{ |
| 289 |
return m_frame.selection().rootEditableElement(); |
289 |
return m_frame.selection().selection().rootEditableElement(); |
| 290 |
} |
290 |
} |
| 291 |
|
291 |
|
| 292 |
bool Editor::canEditRichly() const |
292 |
bool Editor::canEditRichly() const |
| 293 |
{ |
293 |
{ |
| 294 |
return m_frame.selection().isContentRichlyEditable(); |
294 |
return m_frame.selection().selection().isContentRichlyEditable(); |
| 295 |
} |
295 |
} |
| 296 |
|
296 |
|
| 297 |
// WinIE uses onbeforecut and onbeforepaste to enables the cut and paste menu items. They |
297 |
// WinIE uses onbeforecut and onbeforepaste to enables the cut and paste menu items. They |
|
Lines 301-312
bool Editor::canEditRichly() const
Source/WebCore/editing/Editor.cpp_sec2
|
| 301 |
|
301 |
|
| 302 |
bool Editor::canDHTMLCut() |
302 |
bool Editor::canDHTMLCut() |
| 303 |
{ |
303 |
{ |
| 304 |
return !m_frame.selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecutEvent, ClipboardNumb); |
304 |
return !m_frame.selection().selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecutEvent, ClipboardNumb); |
| 305 |
} |
305 |
} |
| 306 |
|
306 |
|
| 307 |
bool Editor::canDHTMLCopy() |
307 |
bool Editor::canDHTMLCopy() |
| 308 |
{ |
308 |
{ |
| 309 |
return !m_frame.selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecopyEvent, ClipboardNumb); |
309 |
return !m_frame.selection().selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecopyEvent, ClipboardNumb); |
| 310 |
} |
310 |
} |
| 311 |
|
311 |
|
| 312 |
bool Editor::canDHTMLPaste() |
312 |
bool Editor::canDHTMLPaste() |
|
Lines 340-346
bool Editor::canCopy() const
Source/WebCore/editing/Editor.cpp_sec3
|
| 340 |
{ |
340 |
{ |
| 341 |
if (imageElementFromImageDocument(document())) |
341 |
if (imageElementFromImageDocument(document())) |
| 342 |
return true; |
342 |
return true; |
| 343 |
FrameSelection& selection = m_frame.selection(); |
343 |
const VisibleSelection& selection = m_frame.selection().selection(); |
| 344 |
return selection.isRange() && !selection.isInPasswordField(); |
344 |
return selection.isRange() && !selection.isInPasswordField(); |
| 345 |
} |
345 |
} |
| 346 |
|
346 |
|
|
Lines 351-357
bool Editor::canPaste() const
Source/WebCore/editing/Editor.cpp_sec4
|
| 351 |
|
351 |
|
| 352 |
bool Editor::canDelete() const |
352 |
bool Editor::canDelete() const |
| 353 |
{ |
353 |
{ |
| 354 |
FrameSelection& selection = m_frame.selection(); |
354 |
const VisibleSelection& selection = m_frame.selection().selection(); |
| 355 |
return selection.isRange() && selection.rootEditableElement(); |
355 |
return selection.isRange() && selection.rootEditableElement(); |
| 356 |
} |
356 |
} |
| 357 |
|
357 |
|
|
Lines 598-604
bool Editor::shouldInsertFragment(PassRe
Source/WebCore/editing/Editor.cpp_sec5
|
| 598 |
|
598 |
|
| 599 |
void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle) |
599 |
void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle) |
| 600 |
{ |
600 |
{ |
| 601 |
if (m_frame.selection().isNone() || !m_frame.selection().isContentEditable() || !fragment) |
601 |
VisibleSelection selection = m_frame.selection().selection(); |
|
|
602 |
if (selection.isNone() || !selection.isContentEditable() || !fragment) |
| 602 |
return; |
603 |
return; |
| 603 |
|
604 |
|
| 604 |
ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting | ReplaceSelectionCommand::SanitizeFragment; |
605 |
ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting | ReplaceSelectionCommand::SanitizeFragment; |
|
Lines 611-619
void Editor::replaceSelectionWithFragmen
Source/WebCore/editing/Editor.cpp_sec6
|
| 611 |
applyCommand(ReplaceSelectionCommand::create(document(), fragment, options, EditActionPaste)); |
612 |
applyCommand(ReplaceSelectionCommand::create(document(), fragment, options, EditActionPaste)); |
| 612 |
revealSelectionAfterEditingOperation(); |
613 |
revealSelectionAfterEditingOperation(); |
| 613 |
|
614 |
|
| 614 |
if (m_frame.selection().isInPasswordField() || !isContinuousSpellCheckingEnabled()) |
615 |
selection = m_frame.selection().selection(); |
|
|
616 |
if (selection.isInPasswordField() || !isContinuousSpellCheckingEnabled()) |
| 615 |
return; |
617 |
return; |
| 616 |
Node* nodeToCheck = m_frame.selection().rootEditableElement(); |
618 |
Node* nodeToCheck = selection.rootEditableElement(); |
| 617 |
if (!nodeToCheck) |
619 |
if (!nodeToCheck) |
| 618 |
return; |
620 |
return; |
| 619 |
|
621 |
|
|
Lines 728-734
bool Editor::shouldDeleteRange(Range* ra
Source/WebCore/editing/Editor.cpp_sec7
|
| 728 |
|
730 |
|
| 729 |
bool Editor::tryDHTMLCopy() |
731 |
bool Editor::tryDHTMLCopy() |
| 730 |
{ |
732 |
{ |
| 731 |
if (m_frame.selection().isInPasswordField()) |
733 |
if (m_frame.selection().selection().isInPasswordField()) |
| 732 |
return false; |
734 |
return false; |
| 733 |
|
735 |
|
| 734 |
return !dispatchCPPEvent(eventNames().copyEvent, ClipboardWritable); |
736 |
return !dispatchCPPEvent(eventNames().copyEvent, ClipboardWritable); |
|
Lines 736-742
bool Editor::tryDHTMLCopy()
Source/WebCore/editing/Editor.cpp_sec8
|
| 736 |
|
738 |
|
| 737 |
bool Editor::tryDHTMLCut() |
739 |
bool Editor::tryDHTMLCut() |
| 738 |
{ |
740 |
{ |
| 739 |
if (m_frame.selection().isInPasswordField()) |
741 |
if (m_frame.selection().selection().isInPasswordField()) |
| 740 |
return false; |
742 |
return false; |
| 741 |
|
743 |
|
| 742 |
return !dispatchCPPEvent(eventNames().cutEvent, ClipboardWritable); |
744 |
return !dispatchCPPEvent(eventNames().cutEvent, ClipboardWritable); |
|
Lines 970-976
Node* Editor::findEventTargetFromSelecti
Source/WebCore/editing/Editor.cpp_sec9
|
| 970 |
|
972 |
|
| 971 |
void Editor::applyStyle(StyleProperties* style, EditAction editingAction) |
973 |
void Editor::applyStyle(StyleProperties* style, EditAction editingAction) |
| 972 |
{ |
974 |
{ |
| 973 |
switch (m_frame.selection().selectionType()) { |
975 |
switch (m_frame.selection().selection().selectionType()) { |
| 974 |
case VisibleSelection::NoSelection: |
976 |
case VisibleSelection::NoSelection: |
| 975 |
// do nothing |
977 |
// do nothing |
| 976 |
break; |
978 |
break; |
|
Lines 991-997
bool Editor::shouldApplyStyle(StylePrope
Source/WebCore/editing/Editor.cpp_sec10
|
| 991 |
|
993 |
|
| 992 |
void Editor::applyParagraphStyle(StyleProperties* style, EditAction editingAction) |
994 |
void Editor::applyParagraphStyle(StyleProperties* style, EditAction editingAction) |
| 993 |
{ |
995 |
{ |
| 994 |
switch (m_frame.selection().selectionType()) { |
996 |
switch (m_frame.selection().selection().selectionType()) { |
| 995 |
case VisibleSelection::NoSelection: |
997 |
case VisibleSelection::NoSelection: |
| 996 |
// do nothing |
998 |
// do nothing |
| 997 |
break; |
999 |
break; |
|
Lines 1280-1286
void Editor::cut()
Source/WebCore/editing/Editor.cpp_sec11
|
| 1280 |
willWriteSelectionToPasteboard(selection); |
1282 |
willWriteSelectionToPasteboard(selection); |
| 1281 |
if (shouldDeleteRange(selection.get())) { |
1283 |
if (shouldDeleteRange(selection.get())) { |
| 1282 |
updateMarkersForWordsAffectedByEditing(true); |
1284 |
updateMarkersForWordsAffectedByEditing(true); |
| 1283 |
if (enclosingTextFormControl(m_frame.selection().start())) |
1285 |
if (enclosingTextFormControl(m_frame.selection().selection().start())) |
| 1284 |
Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForClipboard(), canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace); |
1286 |
Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForClipboard(), canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace); |
| 1285 |
else { |
1287 |
else { |
| 1286 |
#if PLATFORM(MAC) || PLATFORM(EFL) |
1288 |
#if PLATFORM(MAC) || PLATFORM(EFL) |
|
Lines 1305-1311
void Editor::copy()
Source/WebCore/editing/Editor.cpp_sec12
|
| 1305 |
} |
1307 |
} |
| 1306 |
|
1308 |
|
| 1307 |
willWriteSelectionToPasteboard(selectedRange()); |
1309 |
willWriteSelectionToPasteboard(selectedRange()); |
| 1308 |
if (enclosingTextFormControl(m_frame.selection().start())) { |
1310 |
if (enclosingTextFormControl(m_frame.selection().selection().start())) { |
| 1309 |
Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForClipboard(), |
1311 |
Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForClipboard(), |
| 1310 |
canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace); |
1312 |
canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace); |
| 1311 |
} else { |
1313 |
} else { |
|
Lines 1342-1348
void Editor::paste(Pasteboard& pasteboar
Source/WebCore/editing/Editor.cpp_sec13
|
| 1342 |
updateMarkersForWordsAffectedByEditing(false); |
1344 |
updateMarkersForWordsAffectedByEditing(false); |
| 1343 |
CachedResourceLoader* loader = document().cachedResourceLoader(); |
1345 |
CachedResourceLoader* loader = document().cachedResourceLoader(); |
| 1344 |
ResourceCacheValidationSuppressor validationSuppressor(loader); |
1346 |
ResourceCacheValidationSuppressor validationSuppressor(loader); |
| 1345 |
if (m_frame.selection().isContentRichlyEditable()) |
1347 |
if (m_frame.selection().selection().isContentRichlyEditable()) |
| 1346 |
pasteWithPasteboard(&pasteboard, true); |
1348 |
pasteWithPasteboard(&pasteboard, true); |
| 1347 |
else |
1349 |
else |
| 1348 |
pasteAsPlainTextWithPasteboard(pasteboard); |
1350 |
pasteAsPlainTextWithPasteboard(pasteboard); |
|
Lines 1842-1849
void Editor::setComposition(const String
Source/WebCore/editing/Editor.cpp_sec14
|
| 1842 |
TypingCommand::insertText(document(), text, TypingCommand::SelectInsertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextCompositionUpdate); |
1844 |
TypingCommand::insertText(document(), text, TypingCommand::SelectInsertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextCompositionUpdate); |
| 1843 |
|
1845 |
|
| 1844 |
// Find out what node has the composition now. |
1846 |
// Find out what node has the composition now. |
| 1845 |
Position base = m_frame.selection().base().downstream(); |
1847 |
Position base = m_frame.selection().selection().base().downstream(); |
| 1846 |
Position extent = m_frame.selection().extent(); |
1848 |
Position extent = m_frame.selection().selection().extent(); |
| 1847 |
Node* baseNode = base.deprecatedNode(); |
1849 |
Node* baseNode = base.deprecatedNode(); |
| 1848 |
unsigned baseOffset = base.deprecatedEditingOffset(); |
1850 |
unsigned baseOffset = base.deprecatedEditingOffset(); |
| 1849 |
Node* extentNode = extent.deprecatedNode(); |
1851 |
Node* extentNode = extent.deprecatedNode(); |
|
Lines 2161-2173
Vector<String> Editor::guessesForMisspel
Source/WebCore/editing/Editor.cpp_sec15
|
| 2161 |
{ |
2163 |
{ |
| 2162 |
if (unifiedTextCheckerEnabled()) { |
2164 |
if (unifiedTextCheckerEnabled()) { |
| 2163 |
RefPtr<Range> range; |
2165 |
RefPtr<Range> range; |
| 2164 |
FrameSelection& frameSelection = m_frame.selection(); |
2166 |
VisibleSelection selection = m_frame.selection().selection(); |
| 2165 |
if (frameSelection.isCaret() && behavior().shouldAllowSpellingSuggestionsWithoutSelection()) { |
2167 |
if (selection.isCaret() && behavior().shouldAllowSpellingSuggestionsWithoutSelection()) { |
| 2166 |
VisibleSelection wordSelection = VisibleSelection(frameSelection.base()); |
2168 |
VisibleSelection wordSelection = VisibleSelection(selection.base()); |
| 2167 |
wordSelection.expandUsingGranularity(WordGranularity); |
2169 |
wordSelection.expandUsingGranularity(WordGranularity); |
| 2168 |
range = wordSelection.toNormalizedRange(); |
2170 |
range = wordSelection.toNormalizedRange(); |
| 2169 |
} else |
2171 |
} else |
| 2170 |
range = frameSelection.toNormalizedRange(); |
2172 |
range = selection.toNormalizedRange(); |
| 2171 |
if (!range) |
2173 |
if (!range) |
| 2172 |
return Vector<String>(); |
2174 |
return Vector<String>(); |
| 2173 |
return TextCheckingHelper(client(), range).guessesForMisspelledOrUngrammaticalRange(isGrammarCheckingEnabled(), misspelled, ungrammatical); |
2175 |
return TextCheckingHelper(client(), range).guessesForMisspelledOrUngrammaticalRange(isGrammarCheckingEnabled(), misspelled, ungrammatical); |
|
Lines 2301-2307
void Editor::markMisspellingsAfterTyping
Source/WebCore/editing/Editor.cpp_sec16
|
| 2301 |
m_frame.editor().replaceSelectionWithText(autocorrectedString, false, false); |
2303 |
m_frame.editor().replaceSelectionWithText(autocorrectedString, false, false); |
| 2302 |
|
2304 |
|
| 2303 |
// Reset the charet one character further. |
2305 |
// Reset the charet one character further. |
| 2304 |
m_frame.selection().moveTo(m_frame.selection().end()); |
2306 |
m_frame.selection().moveTo(m_frame.selection().selection().end()); |
| 2305 |
m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); |
2307 |
m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); |
| 2306 |
} |
2308 |
} |
| 2307 |
|
2309 |
|
|
Lines 2370-2376
bool Editor::isSpellCheckingEnabledFor(N
Source/WebCore/editing/Editor.cpp_sec17
|
| 2370 |
|
2372 |
|
| 2371 |
bool Editor::isSpellCheckingEnabledInFocusedNode() const |
2373 |
bool Editor::isSpellCheckingEnabledInFocusedNode() const |
| 2372 |
{ |
2374 |
{ |
| 2373 |
return isSpellCheckingEnabledFor(m_frame.selection().start().deprecatedNode()); |
2375 |
return isSpellCheckingEnabledFor(m_frame.selection().selection().start().deprecatedNode()); |
| 2374 |
} |
2376 |
} |
| 2375 |
|
2377 |
|
| 2376 |
void Editor::markMisspellings(const VisibleSelection& selection, RefPtr<Range>& firstMisspellingRange) |
2378 |
void Editor::markMisspellings(const VisibleSelection& selection, RefPtr<Range>& firstMisspellingRange) |
|
Lines 2494-2502
void Editor::markAndReplaceFor(PassRefPt
Source/WebCore/editing/Editor.cpp_sec18
|
| 2494 |
bool adjustSelectionForParagraphBoundaries = false; |
2496 |
bool adjustSelectionForParagraphBoundaries = false; |
| 2495 |
|
2497 |
|
| 2496 |
if (shouldPerformReplacement || shouldMarkSpelling || shouldCheckForCorrection) { |
2498 |
if (shouldPerformReplacement || shouldMarkSpelling || shouldCheckForCorrection) { |
| 2497 |
if (m_frame.selection().selectionType() == VisibleSelection::CaretSelection) { |
2499 |
if (m_frame.selection().selection().selectionType() == VisibleSelection::CaretSelection) { |
| 2498 |
// Attempt to save the caret position so we can restore it later if needed |
2500 |
// Attempt to save the caret position so we can restore it later if needed |
| 2499 |
Position caretPosition = m_frame.selection().end(); |
2501 |
Position caretPosition = m_frame.selection().selection().end(); |
| 2500 |
selectionOffset = paragraph.offsetTo(caretPosition, ASSERT_NO_EXCEPTION); |
2502 |
selectionOffset = paragraph.offsetTo(caretPosition, ASSERT_NO_EXCEPTION); |
| 2501 |
restoreSelectionAfterChange = true; |
2503 |
restoreSelectionAfterChange = true; |
| 2502 |
if (selectionOffset > 0 && (selectionOffset > paragraph.textLength() || paragraph.textCharAt(selectionOffset - 1) == newlineCharacter)) |
2504 |
if (selectionOffset > 0 && (selectionOffset > paragraph.textLength() || paragraph.textCharAt(selectionOffset - 1) == newlineCharacter)) |
|
Lines 2625-2631
void Editor::markAndReplaceFor(PassRefPt
Source/WebCore/editing/Editor.cpp_sec19
|
| 2625 |
m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); |
2627 |
m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); |
| 2626 |
} else { |
2628 |
} else { |
| 2627 |
// If this fails for any reason, the fallback is to go one position beyond the last replacement |
2629 |
// If this fails for any reason, the fallback is to go one position beyond the last replacement |
| 2628 |
m_frame.selection().moveTo(m_frame.selection().end()); |
2630 |
m_frame.selection().moveTo(m_frame.selection().selection().end()); |
| 2629 |
m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); |
2631 |
m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); |
| 2630 |
} |
2632 |
} |
| 2631 |
} |
2633 |
} |
|
Lines 2822-2831
bool Editor::getCompositionSelection(uns
Source/WebCore/editing/Editor.cpp_sec20
|
| 2822 |
{ |
2824 |
{ |
| 2823 |
if (!m_compositionNode) |
2825 |
if (!m_compositionNode) |
| 2824 |
return false; |
2826 |
return false; |
| 2825 |
Position start = m_frame.selection().start(); |
2827 |
const VisibleSelection& selection = m_frame.selection().selection(); |
|
|
2828 |
Position start = selection.start(); |
| 2826 |
if (start.deprecatedNode() != m_compositionNode) |
2829 |
if (start.deprecatedNode() != m_compositionNode) |
| 2827 |
return false; |
2830 |
return false; |
| 2828 |
Position end = m_frame.selection().end(); |
2831 |
Position end = selection.end(); |
| 2829 |
if (end.deprecatedNode() != m_compositionNode) |
2832 |
if (end.deprecatedNode() != m_compositionNode) |
| 2830 |
return false; |
2833 |
return false; |
| 2831 |
|
2834 |
|
|
Lines 3382-3388
static Node* findFirstMarkable(Node* nod
Source/WebCore/editing/Editor.cpp_sec21
|
| 3382 |
|
3385 |
|
| 3383 |
bool Editor::selectionStartHasMarkerFor(DocumentMarker::MarkerType markerType, int from, int length) const |
3386 |
bool Editor::selectionStartHasMarkerFor(DocumentMarker::MarkerType markerType, int from, int length) const |
| 3384 |
{ |
3387 |
{ |
| 3385 |
Node* node = findFirstMarkable(m_frame.selection().start().deprecatedNode()); |
3388 |
Node* node = findFirstMarkable(m_frame.selection().selection().start().deprecatedNode()); |
| 3386 |
if (!node) |
3389 |
if (!node) |
| 3387 |
return false; |
3390 |
return false; |
| 3388 |
|
3391 |
|