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

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

Issue 321023002: Avoid branching in createAttributeEventListener (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing 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
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLFormElement.cpp » ('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 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 void HTMLElement::parseAttribute(const QualifiedName& name, const AtomicString& value) 307 void HTMLElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
308 { 308 {
309 if (name == tabindexAttr) 309 if (name == tabindexAttr)
310 return Element::parseAttribute(name, value); 310 return Element::parseAttribute(name, value);
311 311
312 if (name == dirAttr) { 312 if (name == dirAttr) {
313 dirAttributeChanged(value); 313 dirAttributeChanged(value);
314 } else { 314 } else {
315 const AtomicString& eventName = eventNameForAttributeName(name); 315 const AtomicString& eventName = eventNameForAttributeName(name);
316 if (!eventName.isNull()) 316 if (!eventName.isNull())
317 setAttributeEventListener(eventName, createAttributeEventListener(th is, name, value)); 317 setAttributeEventListener(eventName, createAttributeEventListener(th is, name, value, eventParameterName()));
318 } 318 }
319 } 319 }
320 320
321 PassRefPtrWillBeRawPtr<DocumentFragment> HTMLElement::textToFragment(const Strin g& text, ExceptionState& exceptionState) 321 PassRefPtrWillBeRawPtr<DocumentFragment> HTMLElement::textToFragment(const Strin g& text, ExceptionState& exceptionState)
322 { 322 {
323 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument()); 323 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument());
324 unsigned i, length = text.length(); 324 unsigned i, length = text.length();
325 UChar c = 0; 325 UChar c = 0;
326 for (unsigned start = 0; start < length; ) { 326 for (unsigned start = 0; start < length; ) {
327 327
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 // even in spatial navigation mode instead of handling it as a "click" actio n. 943 // even in spatial navigation mode instead of handling it as a "click" actio n.
944 if (isTextFormControl() || isContentEditable()) 944 if (isTextFormControl() || isContentEditable())
945 return; 945 return;
946 int charCode = event->charCode(); 946 int charCode = event->charCode();
947 if (charCode == '\r' || charCode == ' ') { 947 if (charCode == '\r' || charCode == ' ') {
948 dispatchSimulatedClick(event); 948 dispatchSimulatedClick(event);
949 event->setDefaultHandled(); 949 event->setDefaultHandled();
950 } 950 }
951 } 951 }
952 952
953 const AtomicString& HTMLElement::eventParameterName()
954 {
955 DEFINE_STATIC_LOCAL(const AtomicString, eventString, ("event", AtomicString: :ConstructFromLiteral));
956 return eventString;
957 }
958
953 } // namespace WebCore 959 } // namespace WebCore
954 960
955 #ifndef NDEBUG 961 #ifndef NDEBUG
956 962
957 // For use in the debugger 963 // For use in the debugger
958 void dumpInnerHTML(WebCore::HTMLElement*); 964 void dumpInnerHTML(WebCore::HTMLElement*);
959 965
960 void dumpInnerHTML(WebCore::HTMLElement* element) 966 void dumpInnerHTML(WebCore::HTMLElement* element)
961 { 967 {
962 printf("%s\n", element->innerHTML().ascii().data()); 968 printf("%s\n", element->innerHTML().ascii().data());
963 } 969 }
964 #endif 970 #endif
OLDNEW
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLFormElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698