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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp

Issue 1417363002: Revert of Use FrameSelection::selectedText where possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (currentLength + computeLengthForSubmission(event->text()) < unsignedMaxL ength) 300 if (currentLength + computeLengthForSubmission(event->text()) < unsignedMaxL ength)
301 return; 301 return;
302 302
303 // selectionLength represents the selection length of this text field to be 303 // selectionLength represents the selection length of this text field to be
304 // removed by this insertion. 304 // removed by this insertion.
305 // If the text field has no focus, we don't need to take account of the 305 // If the text field has no focus, we don't need to take account of the
306 // selection length. The selection is the source of text drag-and-drop in 306 // selection length. The selection is the source of text drag-and-drop in
307 // that case, and nothing in the text field will be removed. 307 // that case, and nothing in the text field will be removed.
308 unsigned selectionLength = 0; 308 unsigned selectionLength = 0;
309 if (focused()) { 309 if (focused()) {
310 selectionLength = computeLengthForSubmission(document().frame()->selecti on().selectedText()); 310 const EphemeralRange range = document().frame()->selection().selection() .toNormalizedEphemeralRange();
311 selectionLength = computeLengthForSubmission(plainText(range));
311 } 312 }
312 ASSERT(currentLength >= selectionLength); 313 ASSERT(currentLength >= selectionLength);
313 unsigned baseLength = currentLength - selectionLength; 314 unsigned baseLength = currentLength - selectionLength;
314 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLeng th - baseLength : 0; 315 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLeng th - baseLength : 0;
315 event->setText(sanitizeUserInputValue(event->text(), appendableLength)); 316 event->setText(sanitizeUserInputValue(event->text(), appendableLength));
316 } 317 }
317 318
318 String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue, unsigned maxLength) 319 String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue, unsigned maxLength)
319 { 320 {
320 if (maxLength > 0 && U16_IS_LEAD(proposedValue[maxLength - 1])) 321 if (maxLength > 0 && U16_IS_LEAD(proposedValue[maxLength - 1]))
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 647
647 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s ource) 648 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s ource)
648 { 649 {
649 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle ment&>(source); 650 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle ment&>(source);
650 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); 651 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion);
651 m_isDirty = sourceElement.m_isDirty; 652 m_isDirty = sourceElement.m_isDirty;
652 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); 653 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source);
653 } 654 }
654 655
655 } // namespace blink 656 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698