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