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

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

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