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 20 matching lines...) Expand all Loading... | |
31 #include "XMLNames.h" | 31 #include "XMLNames.h" |
32 #include "bindings/v8/ScriptController.h" | 32 #include "bindings/v8/ScriptController.h" |
33 #include "bindings/v8/ScriptEventListener.h" | 33 #include "bindings/v8/ScriptEventListener.h" |
34 #include "core/css/CSSParser.h" | 34 #include "core/css/CSSParser.h" |
35 #include "core/css/CSSValuePool.h" | 35 #include "core/css/CSSValuePool.h" |
36 #include "core/css/StylePropertySet.h" | 36 #include "core/css/StylePropertySet.h" |
37 #include "core/dom/DocumentFragment.h" | 37 #include "core/dom/DocumentFragment.h" |
38 #include "core/dom/EventListener.h" | 38 #include "core/dom/EventListener.h" |
39 #include "core/dom/EventNames.h" | 39 #include "core/dom/EventNames.h" |
40 #include "core/dom/ExceptionCode.h" | 40 #include "core/dom/ExceptionCode.h" |
41 #include "core/dom/KeyboardEvent.h" | |
41 #include "core/dom/NodeTraversal.h" | 42 #include "core/dom/NodeTraversal.h" |
42 #include "core/dom/Text.h" | 43 #include "core/dom/Text.h" |
43 #include "core/editing/markup.h" | 44 #include "core/editing/markup.h" |
44 #include "core/html/HTMLBRElement.h" | 45 #include "core/html/HTMLBRElement.h" |
45 #include "core/html/HTMLFormElement.h" | 46 #include "core/html/HTMLFormElement.h" |
46 #include "core/html/HTMLTemplateElement.h" | 47 #include "core/html/HTMLTemplateElement.h" |
47 #include "core/html/HTMLTextFormControlElement.h" | 48 #include "core/html/HTMLTextFormControlElement.h" |
48 #include "core/html/parser/HTMLParserIdioms.h" | 49 #include "core/html/parser/HTMLParserIdioms.h" |
49 #include "core/loader/FrameLoader.h" | 50 #include "core/loader/FrameLoader.h" |
50 #include "core/page/Frame.h" | 51 #include "core/page/Frame.h" |
52 #include "core/page/Settings.h" | |
51 #include "core/rendering/RenderWordBreak.h" | 53 #include "core/rendering/RenderWordBreak.h" |
52 #include <wtf/StdLibExtras.h> | 54 #include <wtf/StdLibExtras.h> |
53 #include <wtf/text/CString.h> | 55 #include <wtf/text/CString.h> |
54 | 56 |
55 namespace WebCore { | 57 namespace WebCore { |
56 | 58 |
57 using namespace HTMLNames; | 59 using namespace HTMLNames; |
58 using namespace WTF; | 60 using namespace WTF; |
59 | 61 |
60 using std::min; | 62 using std::min; |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 | 593 |
592 if (verticalAlignValue != CSSValueInvalid) | 594 if (verticalAlignValue != CSSValueInvalid) |
593 addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, verticalAlignValue); | 595 addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, verticalAlignValue); |
594 } | 596 } |
595 | 597 |
596 bool HTMLElement::hasCustomFocusLogic() const | 598 bool HTMLElement::hasCustomFocusLogic() const |
597 { | 599 { |
598 return false; | 600 return false; |
599 } | 601 } |
600 | 602 |
603 bool HTMLElement::supportsSpatialNavigationFocus() const | |
604 { | |
605 // This function checks whether the element satisfies the extended criteria | |
606 // for the element to be focusable, introduced by spatial navigation feature , | |
607 // i.e. checks if click or keyboard event handler is specified. | |
608 // This is the way to make it possible to navigate to (focus) elements | |
609 // which web designer meant for being active (made them respond to click eve nts). | |
610 | |
611 if (!document()->settings()->spatialNavigationEnabled()) | |
tkent
2013/06/21 02:36:53
document()->settings() can be NULL.
Krzysztof Olczyk
2013/06/21 07:22:51
Done.
| |
612 return false; | |
613 EventTarget* target = const_cast<HTMLElement*>(this); | |
614 return target->hasEventListeners(eventNames().clickEvent) | |
615 || target->hasEventListeners(eventNames().keydownEvent) | |
616 || target->hasEventListeners(eventNames().keypressEvent) | |
617 || target->hasEventListeners(eventNames().keyupEvent); | |
618 } | |
619 | |
601 bool HTMLElement::supportsFocus() const | 620 bool HTMLElement::supportsFocus() const |
602 { | 621 { |
603 // FIXME: supportsFocus() can be called when layout is not up to date. | 622 // FIXME: supportsFocus() can be called when layout is not up to date. |
604 // Logic that deals with the renderer should be moved to rendererIsFocusable (). | 623 // Logic that deals with the renderer should be moved to rendererIsFocusable (). |
605 // But supportsFocus must return true when the element is editable, or else | 624 // But supportsFocus must return true when the element is editable, or else |
606 // it won't be focusable. Furthermore, supportsFocus cannot just return true | 625 // it won't be focusable. Furthermore, supportsFocus cannot just return true |
607 // always or else tabIndex() will change for all HTML elements. | 626 // always or else tabIndex() will change for all HTML elements. |
608 return Element::supportsFocus() || (rendererIsEditable() && parentNode() && !parentNode()->rendererIsEditable()); | 627 return Element::supportsFocus() || (rendererIsEditable() && parentNode() && !parentNode()->rendererIsEditable()) |
628 || supportsSpatialNavigationFocus(); | |
609 } | 629 } |
610 | 630 |
611 String HTMLElement::contentEditable() const | 631 String HTMLElement::contentEditable() const |
612 { | 632 { |
613 const AtomicString& value = fastGetAttribute(contenteditableAttr); | 633 const AtomicString& value = fastGetAttribute(contenteditableAttr); |
614 | 634 |
615 if (value.isNull()) | 635 if (value.isNull()) |
616 return "inherit"; | 636 return "inherit"; |
617 if (value.isEmpty() || equalIgnoringCase(value, "true")) | 637 if (value.isEmpty() || equalIgnoringCase(value, "true")) |
618 return "true"; | 638 return "true"; |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1022 return; | 1042 return; |
1023 | 1043 |
1024 // If the string is a named CSS color or a 3/6-digit hex color, use that. | 1044 // If the string is a named CSS color or a 3/6-digit hex color, use that. |
1025 Color parsedColor(colorString); | 1045 Color parsedColor(colorString); |
1026 if (!parsedColor.isValid()) | 1046 if (!parsedColor.isValid()) |
1027 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString)); | 1047 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString)); |
1028 | 1048 |
1029 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r gb())); | 1049 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r gb())); |
1030 } | 1050 } |
1031 | 1051 |
1052 void HTMLElement::defaultEventHandler(Event* event) | |
1053 { | |
1054 if (event->type() == eventNames().keypressEvent && event->isKeyboardEvent()) { | |
1055 handleKeypressEvent(toKeyboardEvent(event)); | |
1056 if (event->defaultHandled()) | |
1057 return; | |
1058 } | |
1059 | |
1060 StyledElement::defaultEventHandler(event); | |
1061 } | |
1062 | |
1063 void HTMLElement::handleKeypressEvent(KeyboardEvent* event) | |
1064 { | |
1065 if (!document()->settings()->spatialNavigationEnabled() || !supportsFocus()) | |
1066 return; | |
1067 int charCode = event->charCode(); | |
1068 if (charCode == '\r' || charCode == ' ') { | |
1069 dispatchSimulatedClick(event); | |
1070 event->setDefaultHandled(); | |
1071 } | |
1072 } | |
1073 | |
1032 } // namespace WebCore | 1074 } // namespace WebCore |
1033 | 1075 |
1034 #ifndef NDEBUG | 1076 #ifndef NDEBUG |
1035 | 1077 |
1036 // For use in the debugger | 1078 // For use in the debugger |
1037 void dumpInnerHTML(WebCore::HTMLElement*); | 1079 void dumpInnerHTML(WebCore::HTMLElement*); |
1038 | 1080 |
1039 void dumpInnerHTML(WebCore::HTMLElement* element) | 1081 void dumpInnerHTML(WebCore::HTMLElement* element) |
1040 { | 1082 { |
1041 printf("%s\n", element->innerHTML().ascii().data()); | 1083 printf("%s\n", element->innerHTML().ascii().data()); |
1042 } | 1084 } |
1043 #endif | 1085 #endif |
OLD | NEW |