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