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

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

Issue 400763002: Adding relList attr to link and anchor element Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added to relList to anchor element and LayoutTest Created 6 years, 5 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
« Source/core/html/RelList.h ('K') | « Source/core/html/RelList.h ('k') | no next file » | 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26 #include "core/html/ClassList.h" 26 #include "core/html/RelList.h"
27 27
28 #include "core/dom/Document.h" 28 #include "core/dom/Document.h"
29 29
30 namespace WebCore { 30 namespace WebCore {
31 31
32 using namespace HTMLNames; 32 using namespace HTMLNames;
33 33
34 ClassList::ClassList(Element* element) : m_element(element) { } 34 RelList::RelList(Element* element)
35 : m_element(element)
36 {
37 }
35 38
36 #if !ENABLE(OILPAN) 39 #if !ENABLE(OILPAN)
37 void ClassList::ref() 40 void RelList::ref()
38 { 41 {
39 m_element->ref(); 42 m_element->ref();
40 } 43 }
41 44
42 void ClassList::deref() 45 void RelList::deref()
43 { 46 {
44 m_element->deref(); 47 m_element->deref();
45 } 48 }
46 #endif 49 #endif
47 50
48 unsigned ClassList::length() const 51 unsigned RelList::length() const
49 { 52 {
50 return m_element->hasClass() ? classNames().size() : 0; 53 return m_element->hasAttribute(relAttr) ? relListAttr().size() : 0;
51 } 54 }
52 55
53 const AtomicString ClassList::item(unsigned index) const 56 const AtomicString RelList::item(unsigned index) const
54 { 57 {
55 if (index >= length()) 58 if (index >= length())
56 return AtomicString(); 59 return AtomicString();
57 return classNames()[index]; 60 return relListAttr()[index];
58 } 61 }
59 62
60 bool ClassList::containsInternal(const AtomicString& token) const 63 bool RelList::containsInternal(const AtomicString& token) const
61 { 64 {
62 return m_element->hasClass() && classNames().contains(token); 65 return m_element->hasAttribute(relAttr) && relListAttr().contains(token);
63 } 66 }
64 67
65 const SpaceSplitString& ClassList::classNames() const 68 const SpaceSplitString& RelList::relListAttr() const
66 { 69 {
67 ASSERT(m_element->hasClass()); 70 if (!m_relAttrNames)
68 if (m_element->document().inQuirksMode()) { 71 m_relAttrNames = adoptPtr(new SpaceSplitString(value(), false));
69 if (!m_classNamesForQuirksMode) 72 return *m_relAttrNames;
70 m_classNamesForQuirksMode = adoptPtr(new SpaceSplitString(value(), f alse));
71 return *m_classNamesForQuirksMode.get();
72 }
73 return m_element->elementData()->classNames();
74 } 73 }
75 74
76 void ClassList::trace(Visitor* visitor) 75 void RelList::setValue(const AtomicString& relAttrvalue)
76 {
77 if (!m_relAttrNames)
78 return;
79 m_relAttrNames->set(relAttrvalue, false);
80 }
81
82 void RelList::trace(Visitor* visitor)
77 { 83 {
78 visitor->trace(m_element); 84 visitor->trace(m_element);
Inactive 2014/07/24 15:36:41 You probably need to trace m_relAttrNames as well
79 DOMTokenList::trace(visitor); 85 DOMTokenList::trace(visitor);
80 } 86 }
81 87
82 } // namespace WebCore 88 } // namespace WebCore
OLDNEW
« Source/core/html/RelList.h ('K') | « Source/core/html/RelList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698