Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: sky/engine/core/editing/Editor.cpp

Issue 928393003: Remove the concept of document.documentElement (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/editing/Editor.h ('k') | sky/engine/core/editing/FrameSelection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 { 266 {
267 if (m_frame.selection().isNone()) 267 if (m_frame.selection().isNone())
268 return; 268 return;
269 269
270 ASSERT(m_frame.document()); 270 ASSERT(m_frame.document());
271 DeleteSelectionCommand::create(*m_frame.document(), smartDelete)->apply(); 271 DeleteSelectionCommand::create(*m_frame.document(), smartDelete)->apply();
272 } 272 }
273 273
274 void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace) 274 void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace)
275 { 275 {
276 Element* target = findEventTargetFromSelection(); 276 ContainerNode* target = findEventTargetFromSelection();
277 if (!target) 277 if (!target)
278 return; 278 return;
279 target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame.domWindow() , pastingText, smartReplace), IGNORE_EXCEPTION); 279 target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame.domWindow() , pastingText, smartReplace), IGNORE_EXCEPTION);
280 } 280 }
281 281
282 void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool smartReplace, bool matchStyle) 282 void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool smartReplace, bool matchStyle)
283 { 283 {
284 Element* target = findEventTargetFromSelection(); 284 ContainerNode* target = findEventTargetFromSelection();
285 if (!target) 285 if (!target)
286 return; 286 return;
287 target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame.domWindow(), pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION); 287 target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame.domWindow(), pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION);
288 } 288 }
289 289
290 bool Editor::tryDHTMLCopy() 290 bool Editor::tryDHTMLCopy()
291 { 291 {
292 return false; 292 return false;
293 } 293 }
294 294
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 { 345 {
346 spellChecker().updateMarkersForWordsAffectedByEditing(true); 346 spellChecker().updateMarkersForWordsAffectedByEditing(true);
347 client().respondToChangedContents(); 347 client().respondToChangedContents();
348 } 348 }
349 349
350 void Editor::clearLastEditCommand() 350 void Editor::clearLastEditCommand()
351 { 351 {
352 m_lastEditCommand.clear(); 352 m_lastEditCommand.clear();
353 } 353 }
354 354
355 Element* Editor::findEventTargetFrom(const VisibleSelection& selection) const 355 ContainerNode* Editor::findEventTargetFrom(const VisibleSelection& selection) co nst
356 { 356 {
357 Element* target = selection.start().element(); 357 if (Element* target = selection.start().element())
358 if (!target) 358 return target;
359 target = m_frame.document()->documentElement(); 359 return m_frame.document();
360
361 return target;
362 } 360 }
363 361
364 Element* Editor::findEventTargetFromSelection() const 362 ContainerNode* Editor::findEventTargetFromSelection() const
365 { 363 {
366 return findEventTargetFrom(m_frame.selection().selection()); 364 return findEventTargetFrom(m_frame.selection().selection());
367 } 365 }
368 366
369 static void dispatchEditableContentChangedEvents(PassRefPtr<Element> startRoot, PassRefPtr<Element> endRoot) 367 static void dispatchEditableContentChangedEvents(PassRefPtr<Element> startRoot, PassRefPtr<Element> endRoot)
370 { 368 {
371 if (startRoot) 369 if (startRoot)
372 startRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableCon tentChanged), IGNORE_EXCEPTION); 370 startRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableCon tentChanged), IGNORE_EXCEPTION);
373 if (endRoot && endRoot != startRoot) 371 if (endRoot && endRoot != startRoot)
374 endRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableConte ntChanged), IGNORE_EXCEPTION); 372 endRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableConte ntChanged), IGNORE_EXCEPTION);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 return m_frame.spellChecker(); 813 return m_frame.spellChecker();
816 } 814 }
817 815
818 void Editor::toggleOverwriteModeEnabled() 816 void Editor::toggleOverwriteModeEnabled()
819 { 817 {
820 m_overwriteModeEnabled = !m_overwriteModeEnabled; 818 m_overwriteModeEnabled = !m_overwriteModeEnabled;
821 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); 819 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled);
822 } 820 }
823 821
824 } // namespace blink 822 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/editing/Editor.h ('k') | sky/engine/core/editing/FrameSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698