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

Side by Side Diff: Source/WebCore/page/DragController.cpp

Issue 10750006: Merge 121031 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 years, 5 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 | « LayoutTests/editing/pasteboard/drop-text-events-sideeffect-crash-expected.txt ('k') | no next file » | 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) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 m_fileInputElementUnderMouse = 0; 435 m_fileInputElementUnderMouse = 0;
436 } 436 }
437 437
438 if (!m_documentUnderMouse) 438 if (!m_documentUnderMouse)
439 return false; 439 return false;
440 440
441 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl ientPosition()); 441 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl ientPosition());
442 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); 442 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point);
443 if (!element) 443 if (!element)
444 return false; 444 return false;
445 Frame* innerFrame = element->ownerDocument()->frame(); 445 RefPtr<Frame> innerFrame = element->ownerDocument()->frame();
446 ASSERT(innerFrame); 446 ASSERT(innerFrame);
447 447
448 if (m_page->dragCaretController()->hasCaret() && !dispatchTextInputEventFor( innerFrame, dragData)) 448 if (m_page->dragCaretController()->hasCaret() && !dispatchTextInputEventFor( innerFrame.get(), dragData))
449 return true; 449 return true;
450 450
451 if (dragData->containsColor()) { 451 if (dragData->containsColor()) {
452 Color color = dragData->asColor(); 452 Color color = dragData->asColor();
453 if (!color.isValid()) 453 if (!color.isValid())
454 return false; 454 return false;
455 RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange(); 455 RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange();
456 RefPtr<StylePropertySet> style = StylePropertySet::create(); 456 RefPtr<StylePropertySet> style = StylePropertySet::create();
457 style->setProperty(CSSPropertyColor, color.serialized(), false); 457 style->setProperty(CSSPropertyColor, color.serialized(), false);
458 if (!innerFrame->editor()->shouldApplyStyle(style.get(), innerRange.get( ))) 458 if (!innerFrame->editor()->shouldApplyStyle(style.get(), innerRange.get( )))
(...skipping 24 matching lines...) Expand all
483 RefPtr<Element> rootEditableElement = innerFrame->selection()->rootEditableE lement(); 483 RefPtr<Element> rootEditableElement = innerFrame->selection()->rootEditableE lement();
484 484
485 // For range to be null a WebKit client must have done something bad while 485 // For range to be null a WebKit client must have done something bad while
486 // manually controlling drag behaviour 486 // manually controlling drag behaviour
487 if (!range) 487 if (!range)
488 return false; 488 return false;
489 CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedR esourceLoader(); 489 CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedR esourceLoader();
490 ResourceCacheValidationSuppressor validationSuppressor(cachedResourceLoader) ; 490 ResourceCacheValidationSuppressor validationSuppressor(cachedResourceLoader) ;
491 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich lyEditable()) { 491 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich lyEditable()) {
492 bool chosePlainText = false; 492 bool chosePlainText = false;
493 RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragDat a, innerFrame, range, true, chosePlainText); 493 RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragDat a, innerFrame.get(), range, true, chosePlainText);
494 if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, r ange, EditorInsertActionDropped)) { 494 if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, r ange, EditorInsertActionDropped)) {
495 return false; 495 return false;
496 } 496 }
497 497
498 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr agData); 498 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr agData);
499 if (dragIsMove(innerFrame->selection(), dragData)) { 499 if (dragIsMove(innerFrame->selection(), dragData)) {
500 // NSTextView behavior is to always smart delete on moving a selecti on, 500 // NSTextView behavior is to always smart delete on moving a selecti on,
501 // but only to smart insert if the selection granularity is word gra nularity. 501 // but only to smart insert if the selection granularity is word gra nularity.
502 bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled(); 502 bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled();
503 bool smartInsert = smartDelete && innerFrame->selection()->granulari ty() == WordGranularity && dragData->canSmartReplace(); 503 bool smartInsert = smartDelete && innerFrame->selection()->granulari ty() == WordGranularity && dragData->canSmartReplace();
504 applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base() , smartInsert, smartDelete)); 504 applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base() , smartInsert, smartDelete));
505 } else { 505 } else {
506 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) { 506 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, poin t)) {
507 ReplaceSelectionCommand::CommandOptions options = ReplaceSelecti onCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting; 507 ReplaceSelectionCommand::CommandOptions options = ReplaceSelecti onCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting;
508 if (dragData->canSmartReplace()) 508 if (dragData->canSmartReplace())
509 options |= ReplaceSelectionCommand::SmartReplace; 509 options |= ReplaceSelectionCommand::SmartReplace;
510 if (chosePlainText) 510 if (chosePlainText)
511 options |= ReplaceSelectionCommand::MatchStyle; 511 options |= ReplaceSelectionCommand::MatchStyle;
512 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMous e.get(), fragment, options)); 512 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMous e.get(), fragment, options));
513 } 513 }
514 } 514 }
515 } else { 515 } else {
516 String text = dragData->asPlainText(innerFrame); 516 String text = dragData->asPlainText(innerFrame.get());
517 if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, rang e.get(), EditorInsertActionDropped)) { 517 if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, rang e.get(), EditorInsertActionDropped)) {
518 return false; 518 return false;
519 } 519 }
520 520
521 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr agData); 521 m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dr agData);
522 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) 522 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point))
523 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.ge t(), createFragmentFromText(range.get(), text), ReplaceSelectionCommand::Select Replacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::Pre ventNesting)); 523 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.ge t(), createFragmentFromText(range.get(), text), ReplaceSelectionCommand::Select Replacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::Pre ventNesting));
524 } 524 }
525 525
526 if (rootEditableElement) { 526 if (rootEditableElement) {
527 if (Frame* frame = rootEditableElement->document()->frame()) 527 if (Frame* frame = rootEditableElement->document()->frame())
528 frame->eventHandler()->updateDragStateAfterEditDragIfNeeded(rootEdit ableElement.get()); 528 frame->eventHandler()->updateDragStateAfterEditDragIfNeeded(rootEdit ableElement.get());
529 } 529 }
530 530
531 return true; 531 return true;
532 } 532 }
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 if (!frameView) 906 if (!frameView)
907 return; 907 return;
908 IntPoint framePoint = frameView->windowToContents(windowPoint); 908 IntPoint framePoint = frameView->windowToContents(windowPoint);
909 909
910 m_page->dragCaretController()->setCaretPosition(frame->visiblePositionForPoi nt(framePoint)); 910 m_page->dragCaretController()->setCaretPosition(frame->visiblePositionForPoi nt(framePoint));
911 } 911 }
912 912
913 } // namespace WebCore 913 } // namespace WebCore
914 914
915 #endif // ENABLE(DRAG_SUPPORT) 915 #endif // ENABLE(DRAG_SUPPORT)
OLDNEW
« no previous file with comments | « LayoutTests/editing/pasteboard/drop-text-events-sideeffect-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698