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

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

Issue 2534873004: Avoid unchecked casts in UA shadow DOM. (Closed)
Patch Set: Created 4 years 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr); 156 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr);
157 return attributeValue.getString().find(isNotLineBreak) == kNotFound; 157 return attributeValue.getString().find(isNotLineBreak) == kNotFound;
158 } 158 }
159 159
160 bool TextControlElement::placeholderShouldBeVisible() const { 160 bool TextControlElement::placeholderShouldBeVisible() const {
161 return supportsPlaceholder() && isEmptyValue() && isEmptySuggestedValue() && 161 return supportsPlaceholder() && isEmptyValue() && isEmptySuggestedValue() &&
162 !isPlaceholderEmpty(); 162 !isPlaceholderEmpty();
163 } 163 }
164 164
165 HTMLElement* TextControlElement::placeholderElement() const { 165 HTMLElement* TextControlElement::placeholderElement() const {
166 return toHTMLElement( 166 return toHTMLElementOrDie(
167 userAgentShadowRoot()->getElementById(ShadowElementNames::placeholder())); 167 userAgentShadowRoot()->getElementById(ShadowElementNames::placeholder()));
168 } 168 }
169 169
170 void TextControlElement::updatePlaceholderVisibility() { 170 void TextControlElement::updatePlaceholderVisibility() {
171 HTMLElement* placeholder = placeholderElement(); 171 HTMLElement* placeholder = placeholderElement();
172 if (!placeholder) { 172 if (!placeholder) {
173 updatePlaceholderText(); 173 updatePlaceholderText();
174 return; 174 return;
175 } 175 }
176 176
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 TextDirection textDirection = 893 TextDirection textDirection =
894 element->directionalityIfhasDirAutoAttribute(isAuto); 894 element->directionalityIfhasDirAutoAttribute(isAuto);
895 return textDirection == RTL ? "rtl" : "ltr"; 895 return textDirection == RTL ? "rtl" : "ltr";
896 } 896 }
897 } 897 }
898 898
899 return "ltr"; 899 return "ltr";
900 } 900 }
901 901
902 HTMLElement* TextControlElement::innerEditorElement() const { 902 HTMLElement* TextControlElement::innerEditorElement() const {
903 return toHTMLElement( 903 return toHTMLElementOrDie(
904 userAgentShadowRoot()->getElementById(ShadowElementNames::innerEditor())); 904 userAgentShadowRoot()->getElementById(ShadowElementNames::innerEditor()));
905 } 905 }
906 906
907 static Position innerNodePosition(const Position& innerPosition) { 907 static Position innerNodePosition(const Position& innerPosition) {
908 DCHECK(!innerPosition.isBeforeAnchor()); 908 DCHECK(!innerPosition.isBeforeAnchor());
909 DCHECK(!innerPosition.isAfterAnchor()); 909 DCHECK(!innerPosition.isAfterAnchor());
910 HTMLElement* element = toHTMLElement(innerPosition.anchorNode()); 910 HTMLElement* element = toHTMLElement(innerPosition.anchorNode());
911 DCHECK(element); 911 DCHECK(element);
912 NodeList* childNodes = element->childNodes(); 912 NodeList* childNodes = element->childNodes();
913 if (!childNodes->length()) 913 if (!childNodes->length())
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 1165
1166 void TextControlElement::copyNonAttributePropertiesFromElement( 1166 void TextControlElement::copyNonAttributePropertiesFromElement(
1167 const Element& source) { 1167 const Element& source) {
1168 const TextControlElement& sourceElement = 1168 const TextControlElement& sourceElement =
1169 static_cast<const TextControlElement&>(source); 1169 static_cast<const TextControlElement&>(source);
1170 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; 1170 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit;
1171 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); 1171 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source);
1172 } 1172 }
1173 1173
1174 } // namespace blink 1174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698