Changeset 154707 in webkit
- Timestamp:
- Aug 27, 2013 1:49:57 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r154706 r154707 1 2013-08-27 Benjamin Poulain <benjamin@webkit.org> 2 3 Clean ClassList and DOMSettableTokenList 4 https://bugs.webkit.org/show_bug.cgi?id=120344 5 6 Reviewed by Ryosuke Niwa. 7 8 This patch cleans ClassList and DOMSettableTokenList to make it simpler to update 9 SpaceSplitString: 10 - Move the implementation of virtual functions to the cpp file. 11 - Clean the #includes. 12 - Make the implemented pure virtual methods final. 13 - Make the element() accessor const. 14 15 * html/ClassList.cpp: 16 (WebCore::ClassList::create): 17 (WebCore::ClassList::element): 18 (WebCore::ClassList::value): 19 (WebCore::ClassList::setValue): 20 (WebCore::ClassList::classNames): 21 * html/ClassList.h: 22 * html/DOMSettableTokenList.cpp: 23 (WebCore::DOMSettableTokenList::create): 24 (WebCore::DOMSettableTokenList::ref): 25 (WebCore::DOMSettableTokenList::deref): 26 (WebCore::DOMSettableTokenList::length): 27 (WebCore::DOMSettableTokenList::value): 28 * html/DOMSettableTokenList.h: 29 * html/DOMTokenList.h: 30 (WebCore::DOMTokenList::element): 31 1 32 2013-08-27 Arunprasad Rajkumar <arurajku@cisco.com> 2 33 -
trunk/Source/WebCore/html/ClassList.cpp
r151947 r154707 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 26 27 #include "ClassList.h" 27 28 29 #include "Element.h" 30 #include "HTMLNames.h" 28 31 #include "HTMLParserIdioms.h" 29 #include "SpaceSplitString.h"30 32 31 33 namespace WebCore { 32 34 33 using namespace HTMLNames; 34 35 ClassList::ClassList(Element* element) : m_element(element) { } 35 PassOwnPtr<ClassList> ClassList::create(Element* element) 36 { 37 return adoptPtr(new ClassList(element)); 38 } 36 39 37 40 void ClassList::ref() … … 57 60 } 58 61 62 Element* ClassList::element() const 63 { 64 return m_element; 65 } 66 59 67 bool ClassList::containsInternal(const AtomicString& token) const 60 68 { 61 69 return m_element->hasClass() && classNames().contains(token); 70 } 71 72 AtomicString ClassList::value() const 73 { 74 return m_element->getAttribute(HTMLNames::classAttr); 75 } 76 77 void ClassList::setValue(const AtomicString& value) 78 { 79 m_element->setAttribute(HTMLNames::classAttr, value); 62 80 } 63 81 … … 66 84 ASSERT(m_element->hasClass()); 67 85 if (m_element->document()->inQuirksMode()) { 68 if (!m_classNamesForQuirksMode )69 m_classNamesForQuirksMode = adoptPtr(new SpaceSplitString(value(), false));70 return *m_classNamesForQuirksMode.get();86 if (!m_classNamesForQuirksMode.size()) 87 m_classNamesForQuirksMode.set(value(), false); 88 return m_classNamesForQuirksMode; 71 89 } 72 90 return m_element->elementData()->classNames(); -
trunk/Source/WebCore/html/ClassList.h
r151947 r154707 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 28 29 #include "DOMTokenList.h" 29 #include "Element.h"30 #include "HTMLNames.h"31 30 #include "SpaceSplitString.h" 32 #include <wtf/OwnPtr.h>33 #include <wtf/PassOwnPtr.h>34 31 35 32 namespace WebCore { … … 37 34 class Element; 38 35 39 typedef int ExceptionCode;40 41 36 class ClassList : public DOMTokenList { 42 37 public: 43 static PassOwnPtr<ClassList> create(Element* element) 38 static PassOwnPtr<ClassList> create(Element*); 39 40 virtual void ref() OVERRIDE FINAL; 41 virtual void deref() OVERRIDE FINAL; 42 43 virtual unsigned length() const OVERRIDE FINAL; 44 virtual const AtomicString item(unsigned index) const OVERRIDE FINAL; 45 46 virtual Element* element() const OVERRIDE FINAL; 47 48 void clearValueForQuirksMode() { m_classNamesForQuirksMode.clear(); } 49 50 private: 51 ClassList(Element* element) 52 : m_element(element) 44 53 { 45 return adoptPtr(new ClassList(element));46 54 } 47 55 48 virtual void ref() OVERRIDE; 49 virtual void deref() OVERRIDE; 50 51 virtual unsigned length() const OVERRIDE; 52 virtual const AtomicString item(unsigned index) const OVERRIDE; 53 54 virtual Element* element() OVERRIDE { return m_element; } 55 56 void clearValueForQuirksMode() { m_classNamesForQuirksMode = nullptr; } 57 58 private: 59 ClassList(Element*); 60 61 virtual bool containsInternal(const AtomicString&) const OVERRIDE; 56 virtual bool containsInternal(const AtomicString&) const OVERRIDE FINAL; 57 virtual AtomicString value() const OVERRIDE FINAL; 58 virtual void setValue(const AtomicString&) OVERRIDE FINAL; 62 59 63 60 const SpaceSplitString& classNames() const; 64 61 65 virtual AtomicString value() const OVERRIDE { return m_element->getAttribute(HTMLNames::classAttr); }66 virtual void setValue(const AtomicString& value) OVERRIDE { m_element->setAttribute(HTMLNames::classAttr, value); }67 68 62 Element* m_element; 69 mutable OwnPtr<SpaceSplitString>m_classNamesForQuirksMode;63 mutable SpaceSplitString m_classNamesForQuirksMode; 70 64 }; 71 65 -
trunk/Source/WebCore/html/DOMSettableTokenList.cpp
r154667 r154707 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 28 29 namespace WebCore { 29 30 30 DOMSettableTokenList::DOMSettableTokenList() 31 : m_value() 32 , m_tokens() 31 PassRefPtr<DOMSettableTokenList> DOMSettableTokenList::create() 33 32 { 33 return adoptRef(new DOMSettableTokenList()); 34 34 } 35 35 36 DOMSettableTokenList::~DOMSettableTokenList()36 void DOMSettableTokenList::ref() 37 37 { 38 RefCounted<DOMSettableTokenList>::ref(); 39 } 40 41 void DOMSettableTokenList::deref() 42 { 43 RefCounted<DOMSettableTokenList>::deref(); 44 } 45 46 unsigned DOMSettableTokenList::length() const 47 { 48 return m_tokens.size(); 38 49 } 39 50 … … 50 61 } 51 62 63 AtomicString DOMSettableTokenList::value() const 64 { 65 return m_value; 66 } 67 52 68 void DOMSettableTokenList::setValue(const AtomicString& value) 53 69 { -
trunk/Source/WebCore/html/DOMSettableTokenList.h
r154667 r154707 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 38 39 WTF_MAKE_FAST_ALLOCATED; 39 40 public: 40 static PassRefPtr<DOMSettableTokenList> create() 41 { 42 return adoptRef(new DOMSettableTokenList()); 43 } 44 virtual ~DOMSettableTokenList(); 41 static PassRefPtr<DOMSettableTokenList> create(); 45 42 46 virtual void ref() OVERRIDE { RefCounted<DOMSettableTokenList>::ref(); }47 virtual void deref() OVERRIDE { RefCounted<DOMSettableTokenList>::deref(); }43 virtual void ref() OVERRIDE FINAL; 44 virtual void deref() OVERRIDE FINAL; 48 45 49 virtual unsigned length() const OVERRIDE { return m_tokens.size(); }50 virtual const AtomicString item(unsigned index) const OVERRIDE ;46 virtual unsigned length() const OVERRIDE FINAL; 47 virtual const AtomicString item(unsigned index) const OVERRIDE FINAL; 51 48 52 virtual AtomicString value() const OVERRIDE { return m_value; } 53 virtual void setValue(const AtomicString&) OVERRIDE; 54 55 const SpaceSplitString& tokens() const { return m_tokens; } 56 57 protected: 58 DOMSettableTokenList(); 49 virtual AtomicString value() const OVERRIDE FINAL; 50 virtual void setValue(const AtomicString&) OVERRIDE FINAL; 59 51 60 52 private: 61 virtual bool containsInternal(const AtomicString&) const OVERRIDE ;53 virtual bool containsInternal(const AtomicString&) const OVERRIDE FINAL; 62 54 63 55 AtomicString m_value; -
trunk/Source/WebCore/html/DOMTokenList.h
r154667 r154707 57 57 AtomicString toString() const { return value(); } 58 58 59 virtual Element* element() { return 0; }59 virtual Element* element() const { return 0; } 60 60 61 61 protected:
Note: See TracChangeset
for help on using the changeset viewer.