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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 { | 940 { |
941 if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) { | 941 if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) { |
942 handleKeypressEvent(toKeyboardEvent(event)); | 942 handleKeypressEvent(toKeyboardEvent(event)); |
943 if (event->defaultHandled()) | 943 if (event->defaultHandled()) |
944 return; | 944 return; |
945 } | 945 } |
946 | 946 |
947 Element::defaultEventHandler(event); | 947 Element::defaultEventHandler(event); |
948 } | 948 } |
949 | 949 |
| 950 bool HTMLElement::matchesReadOnlyPseudoClass() const |
| 951 { |
| 952 return !matchesReadWritePseudoClass(); |
| 953 } |
| 954 |
| 955 bool HTMLElement::matchesReadWritePseudoClass() const |
| 956 { |
| 957 if (fastHasAttribute(contenteditableAttr)) { |
| 958 const AtomicString& value = fastGetAttribute(contenteditableAttr); |
| 959 |
| 960 if (value.isEmpty() || equalIgnoringCase(value, "true") || equalIgnoring
Case(value, "plaintext-only")) |
| 961 return true; |
| 962 if (equalIgnoringCase(value, "false")) |
| 963 return false; |
| 964 // All other values should be treated as "inherit". |
| 965 } |
| 966 |
| 967 return parentElement() && parentElement()->rendererIsEditable(); |
| 968 } |
| 969 |
950 void HTMLElement::handleKeypressEvent(KeyboardEvent* event) | 970 void HTMLElement::handleKeypressEvent(KeyboardEvent* event) |
951 { | 971 { |
952 if (!document().settings() || !document().settings()->spatialNavigationEnabl
ed() || !supportsFocus()) | 972 if (!document().settings() || !document().settings()->spatialNavigationEnabl
ed() || !supportsFocus()) |
953 return; | 973 return; |
954 // if the element is a text form control (like <input type=text> or <textare
a>) | 974 // if the element is a text form control (like <input type=text> or <textare
a>) |
955 // or has contentEditable attribute on, we should enter a space or newline | 975 // or has contentEditable attribute on, we should enter a space or newline |
956 // even in spatial navigation mode instead of handling it as a "click" actio
n. | 976 // even in spatial navigation mode instead of handling it as a "click" actio
n. |
957 if (isTextFormControl() || isContentEditable()) | 977 if (isTextFormControl() || isContentEditable()) |
958 return; | 978 return; |
959 int charCode = event->charCode(); | 979 int charCode = event->charCode(); |
960 if (charCode == '\r' || charCode == ' ') { | 980 if (charCode == '\r' || charCode == ' ') { |
961 dispatchSimulatedClick(event); | 981 dispatchSimulatedClick(event); |
962 event->setDefaultHandled(); | 982 event->setDefaultHandled(); |
963 } | 983 } |
964 } | 984 } |
965 | 985 |
966 } // namespace WebCore | 986 } // namespace WebCore |
967 | 987 |
968 #ifndef NDEBUG | 988 #ifndef NDEBUG |
969 | 989 |
970 // For use in the debugger | 990 // For use in the debugger |
971 void dumpInnerHTML(WebCore::HTMLElement*); | 991 void dumpInnerHTML(WebCore::HTMLElement*); |
972 | 992 |
973 void dumpInnerHTML(WebCore::HTMLElement* element) | 993 void dumpInnerHTML(WebCore::HTMLElement* element) |
974 { | 994 { |
975 printf("%s\n", element->innerHTML().ascii().data()); | 995 printf("%s\n", element->innerHTML().ascii().data()); |
976 } | 996 } |
977 #endif | 997 #endif |
OLD | NEW |