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

Side by Side Diff: Source/core/html/HTMLTextFormControlElement.cpp

Issue 1115353002: Update renderer to layoutObject in core/html. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLTableCellElement.cpp ('k') | Source/core/html/ImageDocument.cpp » ('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) 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 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 start = std::min(start, textLength); 228 start = std::min(start, textLength);
229 end = std::min(end, textLength); 229 end = std::min(end, textLength);
230 230
231 if (start < end) 231 if (start < end)
232 text.replace(start, end - start, replacement); 232 text.replace(start, end - start, replacement);
233 else 233 else
234 text.insert(replacement, start); 234 text.insert(replacement, start);
235 235
236 setInnerEditorValue(text); 236 setInnerEditorValue(text);
237 237
238 // FIXME: What should happen to the value (as in value()) if there's no rend erer? 238 // FIXME: What should happen to the value (as in value()) if there's no layo utObject?
239 if (!layoutObject()) 239 if (!layoutObject())
240 return; 240 return;
241 241
242 subtreeHasChanged(); 242 subtreeHasChanged();
243 243
244 if (equalIgnoringCase(selectionMode, "select")) { 244 if (equalIgnoringCase(selectionMode, "select")) {
245 newSelectionStart = start; 245 newSelectionStart = start;
246 newSelectionEnd = start + replacementLength; 246 newSelectionEnd = start + replacementLength;
247 } else if (equalIgnoringCase(selectionMode, "start")) 247 } else if (equalIgnoringCase(selectionMode, "start"))
248 newSelectionStart = newSelectionEnd = start; 248 newSelectionStart = newSelectionEnd = start;
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 634 }
635 innerEditorElement()->setInnerText(value, ASSERT_NO_EXCEPTION); 635 innerEditorElement()->setInnerText(value, ASSERT_NO_EXCEPTION);
636 636
637 if (value.endsWith('\n') || value.endsWith('\r')) 637 if (value.endsWith('\n') || value.endsWith('\r'))
638 innerEditorElement()->appendChild(HTMLBRElement::create(document())) ; 638 innerEditorElement()->appendChild(HTMLBRElement::create(document())) ;
639 } 639 }
640 } 640 }
641 641
642 static String finishText(StringBuilder& result) 642 static String finishText(StringBuilder& result)
643 { 643 {
644 // Remove one trailing newline; there's always one that's collapsed out by r endering. 644 // Remove one trailing newline; there's always one that's collapsed out by l ayoutObject.
645 size_t size = result.length(); 645 size_t size = result.length();
646 if (size && result[size - 1] == '\n') 646 if (size && result[size - 1] == '\n')
647 result.resize(--size); 647 result.resize(--size);
648 return result.toString(); 648 return result.toString();
649 } 649 }
650 650
651 String HTMLTextFormControlElement::innerEditorValue() const 651 String HTMLTextFormControlElement::innerEditorValue() const
652 { 652 {
653 ASSERT(!hasOpenShadowRoot()); 653 ASSERT(!hasOpenShadowRoot());
654 HTMLElement* innerEditor = innerEditorElement(); 654 HTMLElement* innerEditor = innerEditorElement();
(...skipping 22 matching lines...) Expand all
677 line = next; 677 line = next;
678 return; 678 return;
679 } 679 }
680 } 680 }
681 breakNode = 0; 681 breakNode = 0;
682 breakOffset = 0; 682 breakOffset = 0;
683 } 683 }
684 684
685 String HTMLTextFormControlElement::valueWithHardLineBreaks() const 685 String HTMLTextFormControlElement::valueWithHardLineBreaks() const
686 { 686 {
687 // FIXME: It's not acceptable to ignore the HardWrap setting when there is n o renderer. 687 // FIXME: It's not acceptable to ignore the HardWrap setting when there is n o layoutObject.
688 // While we have no evidence this has ever been a practical problem, it woul d be best to fix it some day. 688 // While we have no evidence this has ever been a practical problem, it woul d be best to fix it some day.
689 HTMLElement* innerText = innerEditorElement(); 689 HTMLElement* innerText = innerEditorElement();
690 if (!innerText || !isTextFormControl()) 690 if (!innerText || !isTextFormControl())
691 return value(); 691 return value();
692 692
693 LayoutBlockFlow* renderer = toLayoutBlockFlow(innerText->layoutObject()); 693 LayoutBlockFlow* layoutObject = toLayoutBlockFlow(innerText->layoutObject()) ;
694 if (!renderer) 694 if (!layoutObject)
695 return value(); 695 return value();
696 696
697 Node* breakNode; 697 Node* breakNode;
698 unsigned breakOffset; 698 unsigned breakOffset;
699 RootInlineBox* line = renderer->firstRootBox(); 699 RootInlineBox* line = layoutObject->firstRootBox();
700 if (!line) 700 if (!line)
701 return value(); 701 return value();
702 702
703 getNextSoftBreak(line, breakNode, breakOffset); 703 getNextSoftBreak(line, breakNode, breakOffset);
704 704
705 StringBuilder result; 705 StringBuilder result;
706 for (Node& node : NodeTraversal::descendantsOf(*innerText)) { 706 for (Node& node : NodeTraversal::descendantsOf(*innerText)) {
707 if (isHTMLBRElement(node)) { 707 if (isHTMLBRElement(node)) {
708 result.append(newlineCharacter); 708 result.append(newlineCharacter);
709 } else if (node.isTextNode()) { 709 } else if (node.isTextNode()) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } 1007 }
1008 1008
1009 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) 1009 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source)
1010 { 1010 {
1011 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); 1011 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source);
1012 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; 1012 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit;
1013 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); 1013 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source);
1014 } 1014 }
1015 1015
1016 } // namespace blink 1016 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTableCellElement.cpp ('k') | Source/core/html/ImageDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698