| OLD | NEW |
| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 attributeNameToEventNameMap.set(onwebkitfullscreenerrorAttr.localName(),
EventTypeNames::webkitfullscreenerror); | 299 attributeNameToEventNameMap.set(onwebkitfullscreenerrorAttr.localName(),
EventTypeNames::webkitfullscreenerror); |
| 300 attributeNameToEventNameMap.set(onwebkittransitionendAttr.localName(), E
ventTypeNames::webkitTransitionEnd); | 300 attributeNameToEventNameMap.set(onwebkittransitionendAttr.localName(), E
ventTypeNames::webkitTransitionEnd); |
| 301 attributeNameToEventNameMap.set(onwheelAttr.localName(), EventTypeNames:
:wheel); | 301 attributeNameToEventNameMap.set(onwheelAttr.localName(), EventTypeNames:
:wheel); |
| 302 } | 302 } |
| 303 | 303 |
| 304 return attributeNameToEventNameMap.get(attrName.localName()); | 304 return attributeNameToEventNameMap.get(attrName.localName()); |
| 305 } | 305 } |
| 306 | 306 |
| 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 == dirAttr) | 309 if (name == tabindexAttr) |
| 310 return Element::parseAttribute(name, value); |
| 311 |
| 312 if (name == dirAttr) { |
| 310 dirAttributeChanged(value); | 313 dirAttributeChanged(value); |
| 311 else if (name == tabindexAttr) { | |
| 312 int tabindex = 0; | |
| 313 if (value.isEmpty()) { | |
| 314 clearTabIndexExplicitlyIfNeeded(); | |
| 315 if (treeScope().adjustedFocusedElement() == this) { | |
| 316 // We might want to call blur(), but it's dangerous to dispatch | |
| 317 // events here. | |
| 318 document().setNeedsFocusedElementCheck(); | |
| 319 } | |
| 320 } else if (parseHTMLInteger(value, tabindex)) { | |
| 321 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. | |
| 322 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max())))); | |
| 323 } | |
| 324 } else { | 314 } else { |
| 325 const AtomicString& eventName = eventNameForAttributeName(name); | 315 const AtomicString& eventName = eventNameForAttributeName(name); |
| 326 if (!eventName.isNull()) | 316 if (!eventName.isNull()) |
| 327 setAttributeEventListener(eventName, createAttributeEventListener(th
is, name, value)); | 317 setAttributeEventListener(eventName, createAttributeEventListener(th
is, name, value)); |
| 328 } | 318 } |
| 329 } | 319 } |
| 330 | 320 |
| 331 PassRefPtr<DocumentFragment> HTMLElement::textToFragment(const String& text, Exc
eptionState& exceptionState) | 321 PassRefPtr<DocumentFragment> HTMLElement::textToFragment(const String& text, Exc
eptionState& exceptionState) |
| 332 { | 322 { |
| 333 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document()); | 323 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 478 |
| 489 if (verticalAlignValue != CSSValueInvalid) | 479 if (verticalAlignValue != CSSValueInvalid) |
| 490 addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign,
verticalAlignValue); | 480 addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign,
verticalAlignValue); |
| 491 } | 481 } |
| 492 | 482 |
| 493 bool HTMLElement::hasCustomFocusLogic() const | 483 bool HTMLElement::hasCustomFocusLogic() const |
| 494 { | 484 { |
| 495 return false; | 485 return false; |
| 496 } | 486 } |
| 497 | 487 |
| 498 bool HTMLElement::supportsSpatialNavigationFocus() const | |
| 499 { | |
| 500 // This function checks whether the element satisfies the extended criteria | |
| 501 // for the element to be focusable, introduced by spatial navigation feature
, | |
| 502 // i.e. checks if click or keyboard event handler is specified. | |
| 503 // This is the way to make it possible to navigate to (focus) elements | |
| 504 // which web designer meant for being active (made them respond to click eve
nts). | |
| 505 | |
| 506 if (!document().settings() || !document().settings()->spatialNavigationEnabl
ed()) | |
| 507 return false; | |
| 508 return hasEventListeners(EventTypeNames::click) | |
| 509 || hasEventListeners(EventTypeNames::keydown) | |
| 510 || hasEventListeners(EventTypeNames::keypress) | |
| 511 || hasEventListeners(EventTypeNames::keyup); | |
| 512 } | |
| 513 | |
| 514 bool HTMLElement::supportsFocus() const | |
| 515 { | |
| 516 // FIXME: supportsFocus() can be called when layout is not up to date. | |
| 517 // Logic that deals with the renderer should be moved to rendererIsFocusable
(). | |
| 518 // But supportsFocus must return true when the element is editable, or else | |
| 519 // it won't be focusable. Furthermore, supportsFocus cannot just return true | |
| 520 // always or else tabIndex() will change for all HTML elements. | |
| 521 return Element::supportsFocus() || (rendererIsEditable() && parentNode() &&
!parentNode()->rendererIsEditable()) | |
| 522 || supportsSpatialNavigationFocus(); | |
| 523 } | |
| 524 | |
| 525 String HTMLElement::contentEditable() const | 488 String HTMLElement::contentEditable() const |
| 526 { | 489 { |
| 527 const AtomicString& value = fastGetAttribute(contenteditableAttr); | 490 const AtomicString& value = fastGetAttribute(contenteditableAttr); |
| 528 | 491 |
| 529 if (value.isNull()) | 492 if (value.isNull()) |
| 530 return "inherit"; | 493 return "inherit"; |
| 531 if (value.isEmpty() || equalIgnoringCase(value, "true")) | 494 if (value.isEmpty() || equalIgnoringCase(value, "true")) |
| 532 return "true"; | 495 return "true"; |
| 533 if (equalIgnoringCase(value, "false")) | 496 if (equalIgnoringCase(value, "false")) |
| 534 return "false"; | 497 return "false"; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 return fastGetAttribute(titleAttr); | 551 return fastGetAttribute(titleAttr); |
| 589 } | 552 } |
| 590 | 553 |
| 591 short HTMLElement::tabIndex() const | 554 short HTMLElement::tabIndex() const |
| 592 { | 555 { |
| 593 if (supportsFocus()) | 556 if (supportsFocus()) |
| 594 return Element::tabIndex(); | 557 return Element::tabIndex(); |
| 595 return -1; | 558 return -1; |
| 596 } | 559 } |
| 597 | 560 |
| 598 void HTMLElement::setTabIndex(int value) | |
| 599 { | |
| 600 setIntegralAttribute(tabindexAttr, value); | |
| 601 } | |
| 602 | |
| 603 TranslateAttributeMode HTMLElement::translateAttributeMode() const | 561 TranslateAttributeMode HTMLElement::translateAttributeMode() const |
| 604 { | 562 { |
| 605 const AtomicString& value = getAttribute(translateAttr); | 563 const AtomicString& value = getAttribute(translateAttr); |
| 606 | 564 |
| 607 if (value == nullAtom) | 565 if (value == nullAtom) |
| 608 return TranslateAttributeInherit; | 566 return TranslateAttributeInherit; |
| 609 if (equalIgnoringCase(value, "yes") || equalIgnoringCase(value, "")) | 567 if (equalIgnoringCase(value, "yes") || equalIgnoringCase(value, "")) |
| 610 return TranslateAttributeYes; | 568 return TranslateAttributeYes; |
| 611 if (equalIgnoringCase(value, "no")) | 569 if (equalIgnoringCase(value, "no")) |
| 612 return TranslateAttributeNo; | 570 return TranslateAttributeNo; |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 #ifndef NDEBUG | 955 #ifndef NDEBUG |
| 998 | 956 |
| 999 // For use in the debugger | 957 // For use in the debugger |
| 1000 void dumpInnerHTML(WebCore::HTMLElement*); | 958 void dumpInnerHTML(WebCore::HTMLElement*); |
| 1001 | 959 |
| 1002 void dumpInnerHTML(WebCore::HTMLElement* element) | 960 void dumpInnerHTML(WebCore::HTMLElement* element) |
| 1003 { | 961 { |
| 1004 printf("%s\n", element->innerHTML().ascii().data()); | 962 printf("%s\n", element->innerHTML().ascii().data()); |
| 1005 } | 963 } |
| 1006 #endif | 964 #endif |
| OLD | NEW |