Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 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 * Copyright (C) 2009 Igalia S.L. | 4 * Copyright (C) 2009 Igalia S.L. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 fragment->appendChild(content, exceptionState); | 206 fragment->appendChild(content, exceptionState); |
| 207 if (exceptionState.hadException()) | 207 if (exceptionState.hadException()) |
| 208 return false; | 208 return false; |
| 209 return executeInsertFragment(frame, fragment.release()); | 209 return executeInsertFragment(frame, fragment.release()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran ularity) | 212 static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran ularity) |
| 213 { | 213 { |
| 214 VisibleSelection selection = frame.selection().selection(); | 214 VisibleSelection selection = frame.selection().selection(); |
| 215 selection.expandUsingGranularity(granularity); | 215 selection.expandUsingGranularity(granularity); |
| 216 RefPtr<Range> newRange = selection.toNormalizedRange(); | 216 RefPtrWillBeRawPtr<Range> newRange = selection.toNormalizedRange(); |
| 217 if (!newRange) | 217 if (!newRange) |
| 218 return false; | 218 return false; |
| 219 if (newRange->collapsed(IGNORE_EXCEPTION)) | 219 if (newRange->collapsed(IGNORE_EXCEPTION)) |
| 220 return false; | 220 return false; |
| 221 RefPtr<Range> oldRange = frame.selection().selection().toNormalizedRange(); | |
|
Mads Ager (chromium)
2014/04/04 07:48:38
Ditto?
| |
| 222 EAffinity affinity = frame.selection().affinity(); | 221 EAffinity affinity = frame.selection().affinity(); |
| 223 frame.selection().setSelectedRange(newRange.get(), affinity, FrameSelection: :CloseTyping); | 222 frame.selection().setSelectedRange(newRange.get(), affinity, FrameSelection: :CloseTyping); |
| 224 return true; | 223 return true; |
| 225 } | 224 } |
| 226 | 225 |
| 227 static TriState stateStyle(LocalFrame& frame, CSSPropertyID propertyID, const ch ar* desiredValue) | 226 static TriState stateStyle(LocalFrame& frame, CSSPropertyID propertyID, const ch ar* desiredValue) |
| 228 { | 227 { |
| 229 if (frame.editor().behavior().shouldToggleStyleBasedOnStartOfSelection()) | 228 if (frame.editor().behavior().shouldToggleStyleBasedOnStartOfSelection()) |
| 230 return frame.editor().selectionStartHasStyle(propertyID, desiredValue) ? TrueTriState : FalseTriState; | 229 return frame.editor().selectionStartHasStyle(propertyID, desiredValue) ? TrueTriState : FalseTriState; |
| 231 return frame.editor().selectionHasStyle(propertyID, desiredValue); | 230 return frame.editor().selectionHasStyle(propertyID, desiredValue); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 257 return 0; | 256 return 0; |
| 258 RenderStyle* style = renderer->style(); | 257 RenderStyle* style = renderer->style(); |
| 259 if (!style) | 258 if (!style) |
| 260 return 0; | 259 return 0; |
| 261 if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focuse dElement->rendererIsEditable())) | 260 if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focuse dElement->rendererIsEditable())) |
| 262 return 0; | 261 return 0; |
| 263 int height = std::min<int>(toRenderBox(renderer)->clientHeight(), frame.view ()->visibleHeight()); | 262 int height = std::min<int>(toRenderBox(renderer)->clientHeight(), frame.view ()->visibleHeight()); |
| 264 return static_cast<unsigned>(max(max<int>(height * ScrollableArea::minFracti onToStepWhenPaging(), height - ScrollableArea::maxOverlapBetweenPages()), 1)); | 263 return static_cast<unsigned>(max(max<int>(height * ScrollableArea::minFracti onToStepWhenPaging(), height - ScrollableArea::maxOverlapBetweenPages()), 1)); |
| 265 } | 264 } |
| 266 | 265 |
| 267 static RefPtr<Range> unionDOMRanges(Range* a, Range* b) | 266 static PassRefPtrWillBeRawPtr<Range> unionDOMRanges(Range* a, Range* b) |
| 268 { | 267 { |
| 269 Range* start = a->compareBoundaryPoints(Range::START_TO_START, b, ASSERT_NO_ EXCEPTION) <= 0 ? a : b; | 268 Range* start = a->compareBoundaryPoints(Range::START_TO_START, b, ASSERT_NO_ EXCEPTION) <= 0 ? a : b; |
| 270 Range* end = a->compareBoundaryPoints(Range::END_TO_END, b, ASSERT_NO_EXCEPT ION) <= 0 ? b : a; | 269 Range* end = a->compareBoundaryPoints(Range::END_TO_END, b, ASSERT_NO_EXCEPT ION) <= 0 ? b : a; |
| 271 | 270 |
| 272 return Range::create(a->ownerDocument(), start->startContainer(), start->sta rtOffset(), end->endContainer(), end->endOffset()); | 271 return Range::create(a->ownerDocument(), start->startContainer(), start->sta rtOffset(), end->endContainer(), end->endOffset()); |
| 273 } | 272 } |
| 274 | 273 |
| 275 // Execute command functions | 274 // Execute command functions |
| 276 | 275 |
| 277 static bool executeBackColor(LocalFrame& frame, Event*, EditorCommandSource sour ce, const String& value) | 276 static bool executeBackColor(LocalFrame& frame, Event*, EditorCommandSource sour ce, const String& value) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 static bool executeDeleteToEndOfParagraph(LocalFrame& frame, Event*, EditorComma ndSource, const String&) | 372 static bool executeDeleteToEndOfParagraph(LocalFrame& frame, Event*, EditorComma ndSource, const String&) |
| 374 { | 373 { |
| 375 // Despite its name, this command should delete the newline at the end of | 374 // Despite its name, this command should delete the newline at the end of |
| 376 // a paragraph if you are at the end of a paragraph. | 375 // a paragraph if you are at the end of a paragraph. |
| 377 frame.editor().deleteWithDirection(DirectionForward, ParagraphBoundary, true , false); | 376 frame.editor().deleteWithDirection(DirectionForward, ParagraphBoundary, true , false); |
| 378 return true; | 377 return true; |
| 379 } | 378 } |
| 380 | 379 |
| 381 static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&) | 380 static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&) |
| 382 { | 381 { |
| 383 RefPtr<Range> mark = frame.editor().mark().toNormalizedRange(); | 382 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); |
| 384 if (mark) { | 383 if (mark) { |
| 385 bool selected = frame.selection().setSelectedRange(unionDOMRanges(mark.g et(), frame.editor().selectedRange().get()).get(), DOWNSTREAM, FrameSelection::C loseTyping); | 384 bool selected = frame.selection().setSelectedRange(unionDOMRanges(mark.g et(), frame.editor().selectedRange().get()).get(), DOWNSTREAM, FrameSelection::C loseTyping); |
| 386 ASSERT(selected); | 385 ASSERT(selected); |
| 387 if (!selected) | 386 if (!selected) |
| 388 return false; | 387 return false; |
| 389 } | 388 } |
| 390 frame.editor().performDelete(); | 389 frame.editor().performDelete(); |
| 391 frame.editor().setMark(frame.selection().selection()); | 390 frame.editor().setMark(frame.selection().selection()); |
| 392 return true; | 391 return true; |
| 393 } | 392 } |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1021 return expandSelectionToGranularity(frame, ParagraphGranularity); | 1020 return expandSelectionToGranularity(frame, ParagraphGranularity); |
| 1022 } | 1021 } |
| 1023 | 1022 |
| 1024 static bool executeSelectSentence(LocalFrame& frame, Event*, EditorCommandSource , const String&) | 1023 static bool executeSelectSentence(LocalFrame& frame, Event*, EditorCommandSource , const String&) |
| 1025 { | 1024 { |
| 1026 return expandSelectionToGranularity(frame, SentenceGranularity); | 1025 return expandSelectionToGranularity(frame, SentenceGranularity); |
| 1027 } | 1026 } |
| 1028 | 1027 |
| 1029 static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&) | 1028 static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource, const String&) |
| 1030 { | 1029 { |
| 1031 RefPtr<Range> mark = frame.editor().mark().toNormalizedRange(); | 1030 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); |
| 1032 RefPtr<Range> selection = frame.editor().selectedRange(); | 1031 RefPtrWillBeRawPtr<Range> selection = frame.editor().selectedRange(); |
| 1033 if (!mark || !selection) | 1032 if (!mark || !selection) |
| 1034 return false; | 1033 return false; |
| 1035 frame.selection().setSelectedRange(unionDOMRanges(mark.get(), selection.get( )).get(), DOWNSTREAM, FrameSelection::CloseTyping); | 1034 frame.selection().setSelectedRange(unionDOMRanges(mark.get(), selection.get( )).get(), DOWNSTREAM, FrameSelection::CloseTyping); |
| 1036 return true; | 1035 return true; |
| 1037 } | 1036 } |
| 1038 | 1037 |
| 1039 static bool executeSelectWord(LocalFrame& frame, Event*, EditorCommandSource, co nst String&) | 1038 static bool executeSelectWord(LocalFrame& frame, Event*, EditorCommandSource, co nst String&) |
| 1040 { | 1039 { |
| 1041 return expandSelectionToGranularity(frame, WordGranularity); | 1040 return expandSelectionToGranularity(frame, WordGranularity); |
| 1042 } | 1041 } |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1730 return m_command->state(*m_frame, triggeringEvent) == TrueTriState ? "tr ue" : "false"; | 1729 return m_command->state(*m_frame, triggeringEvent) == TrueTriState ? "tr ue" : "false"; |
| 1731 return m_command->value(*m_frame, triggeringEvent); | 1730 return m_command->value(*m_frame, triggeringEvent); |
| 1732 } | 1731 } |
| 1733 | 1732 |
| 1734 bool Editor::Command::isTextInsertion() const | 1733 bool Editor::Command::isTextInsertion() const |
| 1735 { | 1734 { |
| 1736 return m_command && m_command->isTextInsertion; | 1735 return m_command && m_command->isTextInsertion; |
| 1737 } | 1736 } |
| 1738 | 1737 |
| 1739 } // namespace WebCore | 1738 } // namespace WebCore |
| OLD | NEW |