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

Side by Side Diff: Source/core/dom/Element.cpp

Issue 298063010: Remove the Element.prefix setter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove Attribute::setPrefix Created 6 years, 6 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/dom/Element.h ('k') | Source/core/dom/Element.idl » ('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 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 if (other->elementData()) 1192 if (other->elementData())
1193 return other->elementData()->isEquivalent(elementData()); 1193 return other->elementData()->isEquivalent(elementData());
1194 return true; 1194 return true;
1195 } 1195 }
1196 1196
1197 String Element::nodeName() const 1197 String Element::nodeName() const
1198 { 1198 {
1199 return m_tagName.toString(); 1199 return m_tagName.toString();
1200 } 1200 }
1201 1201
1202 void Element::setPrefix(const AtomicString& prefix, ExceptionState& exceptionSta te)
1203 {
1204 UseCounter::count(document(), UseCounter::ElementSetPrefix);
1205
1206 if (!prefix.isEmpty() && !Document::isValidName(prefix)) {
1207 exceptionState.throwDOMException(InvalidCharacterError, "The prefix '" + prefix + "' is not a valid name.");
1208 return;
1209 }
1210
1211 // FIXME: Raise NamespaceError if prefix is malformed per the Namespaces in XML specification.
1212
1213 const AtomicString& nodeNamespaceURI = namespaceURI();
1214 if (nodeNamespaceURI.isEmpty() && !prefix.isEmpty()) {
1215 exceptionState.throwDOMException(NamespaceError, "No namespace is set, s o a namespace prefix may not be set.");
1216 return;
1217 }
1218
1219 if (prefix == xmlAtom && nodeNamespaceURI != XMLNames::xmlNamespaceURI) {
1220 exceptionState.throwDOMException(NamespaceError, "The prefix '" + xmlAto m + "' may not be set on namespace '" + nodeNamespaceURI + "'.");
1221 return;
1222 }
1223
1224 if (exceptionState.hadException())
1225 return;
1226
1227 m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix);
1228 }
1229
1230 const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace ToLocate) const 1202 const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace ToLocate) const
1231 { 1203 {
1232 if (!prefix().isNull() && namespaceURI() == namespaceToLocate) 1204 if (!prefix().isNull() && namespaceURI() == namespaceToLocate)
1233 return prefix(); 1205 return prefix();
1234 1206
1235 if (hasAttributes()) { 1207 if (hasAttributes()) {
1236 unsigned attributeCount = this->attributeCount(); 1208 unsigned attributeCount = this->attributeCount();
1237 for (unsigned i = 0; i < attributeCount; ++i) { 1209 for (unsigned i = 0; i < attributeCount; ++i) {
1238 const Attribute& attr = attributeItem(i); 1210 const Attribute& attr = attributeItem(i);
1239 1211
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 3271
3300 void Element::trace(Visitor* visitor) 3272 void Element::trace(Visitor* visitor)
3301 { 3273 {
3302 if (hasRareData()) 3274 if (hasRareData())
3303 visitor->trace(elementRareData()); 3275 visitor->trace(elementRareData());
3304 3276
3305 ContainerNode::trace(visitor); 3277 ContainerNode::trace(visitor);
3306 } 3278 }
3307 3279
3308 } // namespace WebCore 3280 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698