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

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

Issue 289273002: Oilpan: make DocumentFragment a heap allocated object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + add WillBeGarbageCollected FIXME. Created 6 years, 7 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 | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/page/DragData.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) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Google Inc. 3 * Copyright (C) 2008 Google Inc.
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 DragController::~DragController() 142 DragController::~DragController()
143 { 143 {
144 } 144 }
145 145
146 PassOwnPtr<DragController> DragController::create(Page* page, DragClient* client ) 146 PassOwnPtr<DragController> DragController::create(Page* page, DragClient* client )
147 { 147 {
148 return adoptPtr(new DragController(page, client)); 148 return adoptPtr(new DragController(page, client));
149 } 149 }
150 150
151 static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD ata, LocalFrame* frame, RefPtrWillBeRawPtr<Range> context, 151 static PassRefPtrWillBeRawPtr<DocumentFragment> documentFragmentFromDragData(Dra gData* dragData, LocalFrame* frame, RefPtrWillBeRawPtr<Range> context, bool allo wPlainText, bool& chosePlainText)
152 bool allowPlainText, bool& chosePlainT ext)
153 { 152 {
154 ASSERT(dragData); 153 ASSERT(dragData);
155 chosePlainText = false; 154 chosePlainText = false;
156 155
157 Document& document = context->ownerDocument(); 156 Document& document = context->ownerDocument();
158 if (dragData->containsCompatibleContent()) { 157 if (dragData->containsCompatibleContent()) {
159 if (PassRefPtr<DocumentFragment> fragment = dragData->asFragment(frame, context, allowPlainText, chosePlainText)) 158 if (PassRefPtrWillBeRawPtr<DocumentFragment> fragment = dragData->asFrag ment(frame, context, allowPlainText, chosePlainText))
160 return fragment; 159 return fragment;
161 160
162 if (dragData->containsURL(DragData::DoNotConvertFilenames)) { 161 if (dragData->containsURL(DragData::DoNotConvertFilenames)) {
163 String title; 162 String title;
164 String url = dragData->asURL(DragData::DoNotConvertFilenames, &title ); 163 String url = dragData->asURL(DragData::DoNotConvertFilenames, &title );
165 if (!url.isEmpty()) { 164 if (!url.isEmpty()) {
166 RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement ::create(document); 165 RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement ::create(document);
167 anchor->setHref(AtomicString(url)); 166 anchor->setHref(AtomicString(url));
168 if (title.isEmpty()) { 167 if (title.isEmpty()) {
169 // Try the plain text first because the url might be normali zed or escaped. 168 // Try the plain text first because the url might be normali zed or escaped.
170 if (dragData->containsPlainText()) 169 if (dragData->containsPlainText())
171 title = dragData->asPlainText(); 170 title = dragData->asPlainText();
172 if (title.isEmpty()) 171 if (title.isEmpty())
173 title = url; 172 title = url;
174 } 173 }
175 RefPtr<Node> anchorText = document.createTextNode(title); 174 RefPtr<Node> anchorText = document.createTextNode(title);
176 anchor->appendChild(anchorText); 175 anchor->appendChild(anchorText);
177 RefPtr<DocumentFragment> fragment = document.createDocumentFragm ent(); 176 RefPtrWillBeRawPtr<DocumentFragment> fragment = document.createD ocumentFragment();
178 fragment->appendChild(anchor); 177 fragment->appendChild(anchor);
179 return fragment.release(); 178 return fragment.release();
180 } 179 }
181 } 180 }
182 } 181 }
183 if (allowPlainText && dragData->containsPlainText()) { 182 if (allowPlainText && dragData->containsPlainText()) {
184 chosePlainText = true; 183 chosePlainText = true;
185 return createFragmentFromText(context.get(), dragData->asPlainText()).ge t(); 184 return createFragmentFromText(context.get(), dragData->asPlainText()).ge t();
186 } 185 }
187 186
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 RefPtr<Element> rootEditableElement = innerFrame->selection().rootEditableEl ement(); 486 RefPtr<Element> rootEditableElement = innerFrame->selection().rootEditableEl ement();
488 487
489 // For range to be null a WebKit client must have done something bad while 488 // For range to be null a WebKit client must have done something bad while
490 // manually controlling drag behaviour 489 // manually controlling drag behaviour
491 if (!range) 490 if (!range)
492 return false; 491 return false;
493 ResourceFetcher* fetcher = range->ownerDocument().fetcher(); 492 ResourceFetcher* fetcher = range->ownerDocument().fetcher();
494 ResourceCacheValidationSuppressor validationSuppressor(fetcher); 493 ResourceCacheValidationSuppressor validationSuppressor(fetcher);
495 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich lyEditable()) { 494 if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRich lyEditable()) {
496 bool chosePlainText = false; 495 bool chosePlainText = false;
497 RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragDat a, innerFrame.get(), range, true, chosePlainText); 496 RefPtrWillBeRawPtr<DocumentFragment> fragment = documentFragmentFromDrag Data(dragData, innerFrame.get(), range, true, chosePlainText);
498 if (!fragment) 497 if (!fragment)
499 return false; 498 return false;
500 499
501 if (dragIsMove(innerFrame->selection(), dragData)) { 500 if (dragIsMove(innerFrame->selection(), dragData)) {
502 // NSTextView behavior is to always smart delete on moving a selecti on, 501 // NSTextView behavior is to always smart delete on moving a selecti on,
503 // but only to smart insert if the selection granularity is word gra nularity. 502 // but only to smart insert if the selection granularity is word gra nularity.
504 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled(); 503 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled();
505 bool smartInsert = smartDelete && innerFrame->selection().granularit y() == WordGranularity && dragData->canSmartReplace(); 504 bool smartInsert = smartDelete && innerFrame->selection().granularit y() == WordGranularity && dragData->canSmartReplace();
506 MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert , smartDelete)->apply(); 505 MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert , smartDelete)->apply();
507 } else { 506 } else {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 #else 957 #else
959 return keyState & PlatformEvent::CtrlKey; 958 return keyState & PlatformEvent::CtrlKey;
960 #endif 959 #endif
961 } 960 }
962 961
963 void DragController::cleanupAfterSystemDrag() 962 void DragController::cleanupAfterSystemDrag()
964 { 963 {
965 } 964 }
966 965
967 } // namespace WebCore 966 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/page/DragData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698