Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: Source/core/html/HTMLElement.cpp

Issue 148223004: Improve support for :read-only and :read-write pseudoclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/rendering/RenderTheme.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 { 963 {
964 if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) { 964 if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) {
965 handleKeypressEvent(toKeyboardEvent(event)); 965 handleKeypressEvent(toKeyboardEvent(event));
966 if (event->defaultHandled()) 966 if (event->defaultHandled())
967 return; 967 return;
968 } 968 }
969 969
970 Element::defaultEventHandler(event); 970 Element::defaultEventHandler(event);
971 } 971 }
972 972
973 bool HTMLElement::matchesReadOnlyPseudoClass() const
974 {
975 return !matchesReadWritePseudoClass();
976 }
977
978 bool HTMLElement::matchesReadWritePseudoClass() const
979 {
980 if (fastHasAttribute(contenteditableAttr)) {
981 const AtomicString& value = fastGetAttribute(contenteditableAttr);
982
983 if (value.isEmpty() || equalIgnoringCase(value, "true") || equalIgnoring Case(value, "plaintext-only"))
984 return true;
985 if (equalIgnoringCase(value, "false"))
986 return false;
987 // All other values should be treated as "inherit".
988 }
989
990 return rendererIsEditable();
rune 2014/01/27 12:36:44 rendererIsEditable() says that it should have an a
andersr 2014/01/30 12:27:59 Yes, you are right, of course. Checking the paren
991 }
992
973 void HTMLElement::handleKeypressEvent(KeyboardEvent* event) 993 void HTMLElement::handleKeypressEvent(KeyboardEvent* event)
974 { 994 {
975 if (!document().settings() || !document().settings()->spatialNavigationEnabl ed() || !supportsFocus()) 995 if (!document().settings() || !document().settings()->spatialNavigationEnabl ed() || !supportsFocus())
976 return; 996 return;
977 // if the element is a text form control (like <input type=text> or <textare a>) 997 // if the element is a text form control (like <input type=text> or <textare a>)
978 // or has contentEditable attribute on, we should enter a space or newline 998 // or has contentEditable attribute on, we should enter a space or newline
979 // even in spatial navigation mode instead of handling it as a "click" actio n. 999 // even in spatial navigation mode instead of handling it as a "click" actio n.
980 if (isTextFormControl() || isContentEditable()) 1000 if (isTextFormControl() || isContentEditable())
981 return; 1001 return;
982 int charCode = event->charCode(); 1002 int charCode = event->charCode();
983 if (charCode == '\r' || charCode == ' ') { 1003 if (charCode == '\r' || charCode == ' ') {
984 dispatchSimulatedClick(event); 1004 dispatchSimulatedClick(event);
985 event->setDefaultHandled(); 1005 event->setDefaultHandled();
986 } 1006 }
987 } 1007 }
988 1008
989 } // namespace WebCore 1009 } // namespace WebCore
990 1010
991 #ifndef NDEBUG 1011 #ifndef NDEBUG
992 1012
993 // For use in the debugger 1013 // For use in the debugger
994 void dumpInnerHTML(WebCore::HTMLElement*); 1014 void dumpInnerHTML(WebCore::HTMLElement*);
995 1015
996 void dumpInnerHTML(WebCore::HTMLElement* element) 1016 void dumpInnerHTML(WebCore::HTMLElement* element)
997 { 1017 {
998 printf("%s\n", element->innerHTML().ascii().data()); 1018 printf("%s\n", element->innerHTML().ascii().data());
999 } 1019 }
1000 #endif 1020 #endif
OLDNEW
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/rendering/RenderTheme.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698