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

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

Issue 2891723002: Do not create child node for Option constructor with no arguments/undefined text (Closed)
Patch Set: Rebased and added IsEmpty check Created 3 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
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 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 5 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved. 8 * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 HTMLOptionElement* HTMLOptionElement::CreateForJSConstructor( 66 HTMLOptionElement* HTMLOptionElement::CreateForJSConstructor(
67 Document& document, 67 Document& document,
68 const String& data, 68 const String& data,
69 const AtomicString& value, 69 const AtomicString& value,
70 bool default_selected, 70 bool default_selected,
71 bool selected, 71 bool selected,
72 ExceptionState& exception_state) { 72 ExceptionState& exception_state) {
73 HTMLOptionElement* element = new HTMLOptionElement(document); 73 HTMLOptionElement* element = new HTMLOptionElement(document);
74 element->EnsureUserAgentShadowRoot(); 74 element->EnsureUserAgentShadowRoot();
75 element->AppendChild(Text::Create(document, data.IsNull() ? "" : data), 75 if (!data.IsEmpty()) {
76 exception_state); 76 element->AppendChild(Text::Create(document, data), exception_state);
77 if (exception_state.HadException()) 77 if (exception_state.HadException())
78 return nullptr; 78 return nullptr;
79 }
79 80
80 if (!value.IsNull()) 81 if (!value.IsNull())
81 element->setValue(value); 82 element->setValue(value);
82 if (default_selected) 83 if (default_selected)
83 element->setAttribute(selectedAttr, g_empty_atom); 84 element->setAttribute(selectedAttr, g_empty_atom);
84 element->SetSelected(selected); 85 element->SetSelected(selected);
85 86
86 return element; 87 return element;
87 } 88 }
88 89
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 434 }
434 435
435 String HTMLOptionElement::innerText() { 436 String HTMLOptionElement::innerText() {
436 // A workaround for crbug.com/424578. We add ShadowRoot to an OPTION, but 437 // A workaround for crbug.com/424578. We add ShadowRoot to an OPTION, but
437 // innerText behavior for Shadow DOM is unclear. We just return the same 438 // innerText behavior for Shadow DOM is unclear. We just return the same
438 // string before adding ShadowRoot. 439 // string before adding ShadowRoot.
439 return textContent(); 440 return textContent();
440 } 441 }
441 442
442 } // namespace blink 443 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-option-element/option-element-constructor-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698