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

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

Issue 184103011: Clear undo stack when text control is set programatically Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
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 15 matching lines...) Expand all
26 #include "core/html/HTMLTextFormControlElement.h" 26 #include "core/html/HTMLTextFormControlElement.h"
27 27
28 #include "HTMLNames.h" 28 #include "HTMLNames.h"
29 #include "bindings/v8/ExceptionState.h" 29 #include "bindings/v8/ExceptionState.h"
30 #include "bindings/v8/ExceptionStatePlaceholder.h" 30 #include "bindings/v8/ExceptionStatePlaceholder.h"
31 #include "core/accessibility/AXObjectCache.h" 31 #include "core/accessibility/AXObjectCache.h"
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/dom/NodeTraversal.h" 33 #include "core/dom/NodeTraversal.h"
34 #include "core/dom/Text.h" 34 #include "core/dom/Text.h"
35 #include "core/dom/shadow/ShadowRoot.h" 35 #include "core/dom/shadow/ShadowRoot.h"
36 #include "core/editing/Editor.h"
36 #include "core/editing/FrameSelection.h" 37 #include "core/editing/FrameSelection.h"
37 #include "core/editing/TextIterator.h" 38 #include "core/editing/TextIterator.h"
38 #include "core/events/Event.h" 39 #include "core/events/Event.h"
39 #include "core/events/ThreadLocalEventNames.h" 40 #include "core/events/ThreadLocalEventNames.h"
40 #include "core/frame/LocalFrame.h" 41 #include "core/frame/LocalFrame.h"
41 #include "core/frame/UseCounter.h" 42 #include "core/frame/UseCounter.h"
42 #include "core/html/HTMLBRElement.h" 43 #include "core/html/HTMLBRElement.h"
43 #include "core/html/shadow/ShadowElementNames.h" 44 #include "core/html/shadow/ShadowElementNames.h"
44 #include "core/rendering/RenderBlock.h" 45 #include "core/rendering/RenderBlock.h"
45 #include "core/rendering/RenderTheme.h" 46 #include "core/rendering/RenderTheme.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 bool textIsChanged = value != innerTextValue(); 507 bool textIsChanged = value != innerTextValue();
507 if (textIsChanged || !innerTextElement()->hasChildren()) { 508 if (textIsChanged || !innerTextElement()->hasChildren()) {
508 if (textIsChanged && renderer()) { 509 if (textIsChanged && renderer()) {
509 if (AXObjectCache* cache = document().existingAXObjectCache()) 510 if (AXObjectCache* cache = document().existingAXObjectCache())
510 cache->postNotification(this, AXObjectCache::AXValueChanged, fal se); 511 cache->postNotification(this, AXObjectCache::AXValueChanged, fal se);
511 } 512 }
512 innerTextElement()->setInnerText(value, ASSERT_NO_EXCEPTION); 513 innerTextElement()->setInnerText(value, ASSERT_NO_EXCEPTION);
513 514
514 if (value.endsWith('\n') || value.endsWith('\r')) 515 if (value.endsWith('\n') || value.endsWith('\r'))
515 innerTextElement()->appendChild(HTMLBRElement::create(document())); 516 innerTextElement()->appendChild(HTMLBRElement::create(document()));
517
518 if (LocalFrame* frame = document().frame())
519 frame->editor().clearUndoStack();
516 } 520 }
517 521
518 setFormControlValueMatchesRenderer(true); 522 setFormControlValueMatchesRenderer(true);
519 } 523 }
520 524
521 static String finishText(StringBuilder& result) 525 static String finishText(StringBuilder& result)
522 { 526 {
523 // Remove one trailing newline; there's always one that's collapsed out by r endering. 527 // Remove one trailing newline; there's always one that's collapsed out by r endering.
524 size_t size = result.length(); 528 size_t size = result.length();
525 if (size && result[size - 1] == '\n') 529 if (size && result[size - 1] == '\n')
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 651
648 return "ltr"; 652 return "ltr";
649 } 653 }
650 654
651 HTMLElement* HTMLTextFormControlElement::innerTextElement() const 655 HTMLElement* HTMLTextFormControlElement::innerTextElement() const
652 { 656 {
653 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::innerEditor())); 657 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::innerEditor()));
654 } 658 }
655 659
656 } // namespace Webcore 660 } // namespace Webcore
OLDNEW
« Source/core/editing/UndoStack.cpp ('K') | « Source/core/editing/UndoStack.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698