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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/AttributeCollection.h ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/AttributeCollection.cpp
diff --git a/Source/modules/webmidi/MIDIController.h b/Source/core/dom/AttributeCollection.cpp
similarity index 51%
copy from Source/modules/webmidi/MIDIController.h
copy to Source/core/dom/AttributeCollection.cpp
index 2aff8a39254987637d780d92baa29d0d79e64bf5..fb01fd30a2d686a8c1f9fdb8b0892888a2f8ebe5 100644
--- a/Source/modules/webmidi/MIDIController.h
+++ b/Source/core/dom/AttributeCollection.cpp
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,38 +30,45 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef MIDIController_h
-#define MIDIController_h
+#include "config.h"
+#include "core/dom/AttributeCollection.h"
-#include "core/frame/LocalFrame.h"
-#include "platform/heap/Handle.h"
+#include "core/dom/Attr.h"
namespace WebCore {
-class MIDIAccessInitializer;
-class MIDIClient;
+size_t AttributeCollection::findIndex(Attr* attr) const
+{
+ // This relies on the fact that Attr's QualifiedName == the Attribute's name.
+ const_iterator end = this->end();
+ unsigned index = 0;
+ for (const_iterator it = begin(); it != end; ++it, ++index) {
+ if (it->name() == attr->qualifiedName())
+ return index;
+ }
+ return kNotFound;
+}
-class MIDIController FINAL : public NoBaseWillBeGarbageCollectedFinalized<MIDIController>, public WillBeHeapSupplement<LocalFrame> {
- WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MIDIController);
-public:
- virtual ~MIDIController();
-
- void requestSysexPermission(MIDIAccessInitializer*);
- void cancelSysexPermissionRequest(MIDIAccessInitializer*);
-
- static PassOwnPtrWillBeRawPtr<MIDIController> create(PassOwnPtr<MIDIClient>);
- static const char* supplementName();
- static MIDIController* from(LocalFrame* frame) { return static_cast<MIDIController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName())); }
-
- virtual void trace(Visitor* visitor) OVERRIDE { WillBeHeapSupplement<LocalFrame>::trace(visitor); }
-
-protected:
- explicit MIDIController(PassOwnPtr<MIDIClient>);
-
-private:
- OwnPtr<MIDIClient> m_client;
-};
+size_t AttributeCollection::findSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const
+{
+ // Continue to checking case-insensitively and/or full namespaced names if necessary:
+ const_iterator end = this->end();
+ unsigned index = 0;
+ for (const_iterator it = begin(); it != end; ++it, ++index) {
+ // FIXME: Why check the prefix? Namespace is all that should matter
+ // and all HTML/SVG attributes have a null namespace!
+ if (!it->name().hasPrefix()) {
+ if (shouldIgnoreAttributeCase && equalIgnoringCase(name, it->localName()))
+ return index;
+ } else {
+ // FIXME: Would be faster to do this comparison without calling toString, which
+ // generates a temporary string by concatenation. But this branch is only reached
+ // if the attribute name has a prefix, which is rare in HTML.
+ if (equalPossiblyIgnoringCase(name, it->name().toString(), shouldIgnoreAttributeCase))
+ return index;
+ }
+ }
+ return kNotFound;
+}
} // namespace WebCore
-
-#endif // MIDIController_h
« 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