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

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

Issue 354023008: Move attributes-related methods from ElementData to AttributeCollection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take feedback into consideration 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/AttributeCollection.h ('k') | Source/core/dom/Element.h » ('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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2014 Apple Inc. All rights reserved.
4 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
3 * 5 *
4 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
6 * met: 8 * met:
7 * 9 *
8 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 12 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer 13 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 14 * in the documentation and/or other materials provided with the
13 * distribution. 15 * distribution.
14 * * Neither the name of Google Inc. nor the names of its 16 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from 17 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission. 18 * this software without specific prior written permission.
17 * 19 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 31 */
30 32
31 #ifndef MIDIController_h 33 #include "config.h"
32 #define MIDIController_h 34 #include "core/dom/AttributeCollection.h"
33 35
34 #include "core/frame/LocalFrame.h" 36 #include "core/dom/Attr.h"
35 #include "platform/heap/Handle.h"
36 37
37 namespace WebCore { 38 namespace WebCore {
38 39
39 class MIDIAccessInitializer; 40 size_t AttributeCollection::findIndex(Attr* attr) const
40 class MIDIClient; 41 {
42 // This relies on the fact that Attr's QualifiedName == the Attribute's name .
43 const_iterator end = this->end();
44 unsigned index = 0;
45 for (const_iterator it = begin(); it != end; ++it, ++index) {
46 if (it->name() == attr->qualifiedName())
47 return index;
48 }
49 return kNotFound;
50 }
41 51
42 class MIDIController FINAL : public NoBaseWillBeGarbageCollectedFinalized<MIDICo ntroller>, public WillBeHeapSupplement<LocalFrame> { 52 size_t AttributeCollection::findSlowCase(const AtomicString& name, bool shouldIg noreAttributeCase) const
43 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MIDIController); 53 {
44 public: 54 // Continue to checking case-insensitively and/or full namespaced names if n ecessary:
45 virtual ~MIDIController(); 55 const_iterator end = this->end();
46 56 unsigned index = 0;
47 void requestSysexPermission(MIDIAccessInitializer*); 57 for (const_iterator it = begin(); it != end; ++it, ++index) {
48 void cancelSysexPermissionRequest(MIDIAccessInitializer*); 58 // FIXME: Why check the prefix? Namespace is all that should matter
49 59 // and all HTML/SVG attributes have a null namespace!
50 static PassOwnPtrWillBeRawPtr<MIDIController> create(PassOwnPtr<MIDIClient>) ; 60 if (!it->name().hasPrefix()) {
51 static const char* supplementName(); 61 if (shouldIgnoreAttributeCase && equalIgnoringCase(name, it->localNa me()))
52 static MIDIController* from(LocalFrame* frame) { return static_cast<MIDICont roller*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName())); } 62 return index;
53 63 } else {
54 virtual void trace(Visitor* visitor) OVERRIDE { WillBeHeapSupplement<LocalFr ame>::trace(visitor); } 64 // FIXME: Would be faster to do this comparison without calling toSt ring, which
55 65 // generates a temporary string by concatenation. But this branch is only reached
56 protected: 66 // if the attribute name has a prefix, which is rare in HTML.
57 explicit MIDIController(PassOwnPtr<MIDIClient>); 67 if (equalPossiblyIgnoringCase(name, it->name().toString(), shouldIgn oreAttributeCase))
58 68 return index;
59 private: 69 }
60 OwnPtr<MIDIClient> m_client; 70 }
61 }; 71 return kNotFound;
72 }
62 73
63 } // namespace WebCore 74 } // namespace WebCore
64
65 #endif // MIDIController_h
OLDNEW
« no previous file with comments | « Source/core/dom/AttributeCollection.h ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698