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

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

Issue 2384273007: reflow comments in core/html/*.{cpp,h},core/html/imports (Closed)
Patch Set: comments Created 4 years, 2 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
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-2008, 2013, 2014 Apple Inc. All rights reserved. 4 * Copyright (C) 2004-2008, 2013, 2014 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.
6 * (http://www.torchmobile.com/)
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
7 * 8 *
8 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 11 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 12 * version 2 of the License, or (at your option) any later version.
12 * 13 *
13 * This library is distributed in the hope that it will be useful, 14 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 118 }
118 return Element::nodeName(); 119 return Element::nodeName();
119 } 120 }
120 121
121 String HTMLElement::nodeName() const { 122 String HTMLElement::nodeName() const {
122 // localNameUpper may intern and cache an AtomicString. 123 // localNameUpper may intern and cache an AtomicString.
123 DCHECK(isMainThread()); 124 DCHECK(isMainThread());
124 125
125 // FIXME: Would be nice to have an atomicstring lookup based off uppercase 126 // FIXME: Would be nice to have an atomicstring lookup based off uppercase
126 // chars that does not have to copy the string on a hit in the hash. 127 // chars that does not have to copy the string on a hit in the hash.
127 // FIXME: We should have a way to detect XHTML elements and replace the hasPre fix() check with it. 128 // FIXME: We should have a way to detect XHTML elements and replace the
129 // hasPrefix() check with it.
128 if (document().isHTMLDocument()) { 130 if (document().isHTMLDocument()) {
129 if (!tagQName().hasPrefix()) 131 if (!tagQName().hasPrefix())
130 return tagQName().localNameUpper(); 132 return tagQName().localNameUpper();
131 return Element::nodeName().upper(); 133 return Element::nodeName().upper();
132 } 134 }
133 return Element::nodeName(); 135 return Element::nodeName();
134 } 136 }
135 137
136 bool HTMLElement::ieForbidsInsertHTML() const { 138 bool HTMLElement::ieForbidsInsertHTML() const {
137 // FIXME: Supposedly IE disallows settting innerHTML, outerHTML 139 // FIXME: Supposedly IE disallows settting innerHTML, outerHTML
(...skipping 11 matching lines...) Expand all
149 hasTagName(menuitemTag)) || 151 hasTagName(menuitemTag)) ||
150 hasTagName(metaTag) || hasTagName(paramTag) || hasTagName(sourceTag) || 152 hasTagName(metaTag) || hasTagName(paramTag) || hasTagName(sourceTag) ||
151 hasTagName(trackTag) || hasTagName(wbrTag)) 153 hasTagName(trackTag) || hasTagName(wbrTag))
152 return true; 154 return true;
153 return false; 155 return false;
154 } 156 }
155 157
156 static inline CSSValueID unicodeBidiAttributeForDirAuto(HTMLElement* element) { 158 static inline CSSValueID unicodeBidiAttributeForDirAuto(HTMLElement* element) {
157 if (element->hasTagName(preTag) || element->hasTagName(textareaTag)) 159 if (element->hasTagName(preTag) || element->hasTagName(textareaTag))
158 return CSSValueWebkitPlaintext; 160 return CSSValueWebkitPlaintext;
159 // FIXME: For bdo element, dir="auto" should result in "bidi-override isolate" but we don't support having multiple values in unicode-bidi yet. 161 // FIXME: For bdo element, dir="auto" should result in "bidi-override isolate"
162 // but we don't support having multiple values in unicode-bidi yet.
160 // See https://bugs.webkit.org/show_bug.cgi?id=73164. 163 // See https://bugs.webkit.org/show_bug.cgi?id=73164.
161 return CSSValueWebkitIsolate; 164 return CSSValueWebkitIsolate;
162 } 165 }
163 166
164 unsigned HTMLElement::parseBorderWidthAttribute( 167 unsigned HTMLElement::parseBorderWidthAttribute(
165 const AtomicString& value) const { 168 const AtomicString& value) const {
166 unsigned borderWidth = 0; 169 unsigned borderWidth = 0;
167 if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, borderWidth)) { 170 if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, borderWidth)) {
168 if (hasTagName(tableTag) && !value.isNull()) 171 if (hasTagName(tableTag) && !value.isNull())
169 return 1; 172 return 1;
170 } 173 }
171 return borderWidth; 174 return borderWidth;
172 } 175 }
173 176
174 void HTMLElement::applyBorderAttributeToStyle(const AtomicString& value, 177 void HTMLElement::applyBorderAttributeToStyle(const AtomicString& value,
175 MutableStylePropertySet* style) { 178 MutableStylePropertySet* style) {
176 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, 179 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth,
177 parseBorderWidthAttribute(value), 180 parseBorderWidthAttribute(value),
178 CSSPrimitiveValue::UnitType::Pixels); 181 CSSPrimitiveValue::UnitType::Pixels);
179 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderStyle, 182 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderStyle,
180 CSSValueSolid); 183 CSSValueSolid);
181 } 184 }
182 185
183 void HTMLElement::mapLanguageAttributeToLocale(const AtomicString& value, 186 void HTMLElement::mapLanguageAttributeToLocale(const AtomicString& value,
184 MutableStylePropertySet* style) { 187 MutableStylePropertySet* style) {
185 if (!value.isEmpty()) { 188 if (!value.isEmpty()) {
186 // Have to quote so the locale id is treated as a string instead of as a CSS keyword. 189 // Have to quote so the locale id is treated as a string instead of as a CSS
190 // keyword.
187 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, 191 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale,
188 serializeString(value)); 192 serializeString(value));
189 193
190 // FIXME: Remove the following UseCounter code when we collect enough 194 // FIXME: Remove the following UseCounter code when we collect enough
191 // data. 195 // data.
192 UseCounter::count(document(), UseCounter::LangAttribute); 196 UseCounter::count(document(), UseCounter::LangAttribute);
193 if (isHTMLHtmlElement(*this)) 197 if (isHTMLHtmlElement(*this))
194 UseCounter::count(document(), UseCounter::LangAttributeOnHTML); 198 UseCounter::count(document(), UseCounter::LangAttributeOnHTML);
195 else if (isHTMLBodyElement(*this)) 199 else if (isHTMLBodyElement(*this))
196 UseCounter::count(document(), UseCounter::LangAttributeOnBody); 200 UseCounter::count(document(), UseCounter::LangAttributeOnBody);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 498
495 if (!text.contains('\n') && !text.contains('\r')) { 499 if (!text.contains('\n') && !text.contains('\r')) {
496 if (text.isEmpty()) { 500 if (text.isEmpty()) {
497 removeChildren(); 501 removeChildren();
498 return; 502 return;
499 } 503 }
500 replaceChildrenWithText(this, text, exceptionState); 504 replaceChildrenWithText(this, text, exceptionState);
501 return; 505 return;
502 } 506 }
503 507
504 // FIXME: Do we need to be able to detect preserveNewline style even when ther e's no layoutObject? 508 // FIXME: Do we need to be able to detect preserveNewline style even when
505 // FIXME: Can the layoutObject be out of date here? Do we need to call updateS tyleIfNeeded? 509 // there's no layoutObject?
506 // For example, for the contents of textarea elements that are display:none? 510 // FIXME: Can the layoutObject be out of date here? Do we need to call
511 // updateStyleIfNeeded? For example, for the contents of textarea elements
512 // that are display:none?
507 LayoutObject* r = layoutObject(); 513 LayoutObject* r = layoutObject();
508 if (r && r->style()->preserveNewline()) { 514 if (r && r->style()->preserveNewline()) {
509 if (!text.contains('\r')) { 515 if (!text.contains('\r')) {
510 replaceChildrenWithText(this, text, exceptionState); 516 replaceChildrenWithText(this, text, exceptionState);
511 return; 517 return;
512 } 518 }
513 String textWithConsistentLineBreaks = text; 519 String textWithConsistentLineBreaks = text;
514 textWithConsistentLineBreaks.replace("\r\n", "\n"); 520 textWithConsistentLineBreaks.replace("\r\n", "\n");
515 textWithConsistentLineBreaks.replace('\r', '\n'); 521 textWithConsistentLineBreaks.replace('\r', '\n');
516 replaceChildrenWithText(this, textWithConsistentLineBreaks, exceptionState); 522 replaceChildrenWithText(this, textWithConsistentLineBreaks, exceptionState);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 718 }
713 719
714 // Default on the root element is translate=yes. 720 // Default on the root element is translate=yes.
715 return true; 721 return true;
716 } 722 }
717 723
718 void HTMLElement::setTranslate(bool enable) { 724 void HTMLElement::setTranslate(bool enable) {
719 setAttribute(translateAttr, enable ? "yes" : "no"); 725 setAttribute(translateAttr, enable ? "yes" : "no");
720 } 726 }
721 727
722 // Returns the conforming 'dir' value associated with the state the attribute is in (in its canonical case), if any, 728 // Returns the conforming 'dir' value associated with the state the attribute is
723 // or the empty string if the attribute is in a state that has no associated key word value or if the attribute is 729 // in (in its canonical case), if any, or the empty string if the attribute is
724 // not in a defined state (e.g. the attribute is missing and there is no missing value default). 730 // in a state that has no associated keyword value or if the attribute is not in
731 // a defined state (e.g. the attribute is missing and there is no missing value
732 // default).
725 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interf aces.html#limited-to-only-known-values 733 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interf aces.html#limited-to-only-known-values
726 static inline const AtomicString& toValidDirValue(const AtomicString& value) { 734 static inline const AtomicString& toValidDirValue(const AtomicString& value) {
727 DEFINE_STATIC_LOCAL(const AtomicString, ltrValue, ("ltr")); 735 DEFINE_STATIC_LOCAL(const AtomicString, ltrValue, ("ltr"));
728 DEFINE_STATIC_LOCAL(const AtomicString, rtlValue, ("rtl")); 736 DEFINE_STATIC_LOCAL(const AtomicString, rtlValue, ("rtl"));
729 DEFINE_STATIC_LOCAL(const AtomicString, autoValue, ("auto")); 737 DEFINE_STATIC_LOCAL(const AtomicString, autoValue, ("auto"));
730 738
731 if (equalIgnoringCase(value, ltrValue)) 739 if (equalIgnoringCase(value, ltrValue))
732 return ltrValue; 740 return ltrValue;
733 if (equalIgnoringCase(value, rtlValue)) 741 if (equalIgnoringCase(value, rtlValue))
734 return rtlValue; 742 return rtlValue;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 if (elementAffectsDirectionality(elementToAdjust)) { 897 if (elementAffectsDirectionality(elementToAdjust)) {
890 toHTMLElement(elementToAdjust)->calculateAndAdjustDirectionality(); 898 toHTMLElement(elementToAdjust)->calculateAndAdjustDirectionality();
891 return; 899 return;
892 } 900 }
893 } 901 }
894 } 902 }
895 903
896 void HTMLElement::addHTMLLengthToStyle(MutableStylePropertySet* style, 904 void HTMLElement::addHTMLLengthToStyle(MutableStylePropertySet* style,
897 CSSPropertyID propertyID, 905 CSSPropertyID propertyID,
898 const String& value) { 906 const String& value) {
899 // FIXME: This function should not spin up the CSS parser, but should instead just figure out the correct 907 // FIXME: This function should not spin up the CSS parser, but should instead
900 // length unit and make the appropriate parsed value. 908 // just figure out the correct length unit and make the appropriate parsed
909 // value.
901 910
902 // strip attribute garbage.. 911 // strip attribute garbage..
903 StringImpl* v = value.impl(); 912 StringImpl* v = value.impl();
904 if (v) { 913 if (v) {
905 unsigned length = 0; 914 unsigned length = 0;
906 915
907 while (length < v->length() && (*v)[length] <= ' ') 916 while (length < v->length() && (*v)[length] <= ' ')
908 length++; 917 length++;
909 918
910 for (; length < v->length(); length++) { 919 for (; length < v->length(); length++) {
(...skipping 18 matching lines...) Expand all
929 return; 938 return;
930 } 939 }
931 } 940 }
932 941
933 addPropertyToPresentationAttributeStyle(style, propertyID, value); 942 addPropertyToPresentationAttributeStyle(style, propertyID, value);
934 } 943 }
935 944
936 static RGBA32 parseColorStringWithCrazyLegacyRules(const String& colorString) { 945 static RGBA32 parseColorStringWithCrazyLegacyRules(const String& colorString) {
937 // Per spec, only look at the first 128 digits of the string. 946 // Per spec, only look at the first 128 digits of the string.
938 const size_t maxColorLength = 128; 947 const size_t maxColorLength = 128;
939 // We'll pad the buffer with two extra 0s later, so reserve two more than the max. 948 // We'll pad the buffer with two extra 0s later, so reserve two more than the
949 // max.
940 Vector<char, maxColorLength + 2> digitBuffer; 950 Vector<char, maxColorLength + 2> digitBuffer;
941 951
942 size_t i = 0; 952 size_t i = 0;
943 // Skip a leading #. 953 // Skip a leading #.
944 if (colorString[0] == '#') 954 if (colorString[0] == '#')
945 i = 1; 955 i = 1;
946 956
947 // Grab the first 128 characters, replacing non-hex characters with 0. 957 // Grab the first 128 characters, replacing non-hex characters with 0.
948 // Non-BMP characters are replaced with "00" due to them appearing as two "cha racters" in the String. 958 // Non-BMP characters are replaced with "00" due to them appearing as two
959 // "characters" in the String.
949 for (; i < colorString.length() && digitBuffer.size() < maxColorLength; i++) { 960 for (; i < colorString.length() && digitBuffer.size() < maxColorLength; i++) {
950 if (!isASCIIHexDigit(colorString[i])) 961 if (!isASCIIHexDigit(colorString[i]))
951 digitBuffer.append('0'); 962 digitBuffer.append('0');
952 else 963 else
953 digitBuffer.append(colorString[i]); 964 digitBuffer.append(colorString[i]);
954 } 965 }
955 966
956 if (!digitBuffer.size()) 967 if (!digitBuffer.size())
957 return Color::black; 968 return Color::black;
958 969
959 // Pad the buffer out to at least the next multiple of three in size. 970 // Pad the buffer out to at least the next multiple of three in size.
960 digitBuffer.append('0'); 971 digitBuffer.append('0');
961 digitBuffer.append('0'); 972 digitBuffer.append('0');
962 973
963 if (digitBuffer.size() < 6) 974 if (digitBuffer.size() < 6)
964 return makeRGB(toASCIIHexValue(digitBuffer[0]), 975 return makeRGB(toASCIIHexValue(digitBuffer[0]),
965 toASCIIHexValue(digitBuffer[1]), 976 toASCIIHexValue(digitBuffer[1]),
966 toASCIIHexValue(digitBuffer[2])); 977 toASCIIHexValue(digitBuffer[2]));
967 978
968 // Split the digits into three components, then search the last 8 digits of ea ch component. 979 // Split the digits into three components, then search the last 8 digits of
980 // each component.
969 DCHECK_GE(digitBuffer.size(), 6u); 981 DCHECK_GE(digitBuffer.size(), 6u);
970 size_t componentLength = digitBuffer.size() / 3; 982 size_t componentLength = digitBuffer.size() / 3;
971 size_t componentSearchWindowLength = min<size_t>(componentLength, 8); 983 size_t componentSearchWindowLength = min<size_t>(componentLength, 8);
972 size_t redIndex = componentLength - componentSearchWindowLength; 984 size_t redIndex = componentLength - componentSearchWindowLength;
973 size_t greenIndex = componentLength * 2 - componentSearchWindowLength; 985 size_t greenIndex = componentLength * 2 - componentSearchWindowLength;
974 size_t blueIndex = componentLength * 3 - componentSearchWindowLength; 986 size_t blueIndex = componentLength * 3 - componentSearchWindowLength;
975 // Skip digits until one of them is non-zero, or we've only got two digits lef t in the component. 987 // Skip digits until one of them is non-zero, or we've only got two digits
988 // left in the component.
976 while (digitBuffer[redIndex] == '0' && digitBuffer[greenIndex] == '0' && 989 while (digitBuffer[redIndex] == '0' && digitBuffer[greenIndex] == '0' &&
977 digitBuffer[blueIndex] == '0' && (componentLength - redIndex) > 2) { 990 digitBuffer[blueIndex] == '0' && (componentLength - redIndex) > 2) {
978 redIndex++; 991 redIndex++;
979 greenIndex++; 992 greenIndex++;
980 blueIndex++; 993 blueIndex++;
981 } 994 }
982 DCHECK_LT(redIndex + 1, componentLength); 995 DCHECK_LT(redIndex + 1, componentLength);
983 DCHECK_GE(greenIndex, componentLength); 996 DCHECK_GE(greenIndex, componentLength);
984 DCHECK_LT(greenIndex + 1, componentLength * 2); 997 DCHECK_LT(greenIndex + 1, componentLength * 2);
985 DCHECK_GE(blueIndex, componentLength * 2); 998 DCHECK_GE(blueIndex, componentLength * 2);
986 SECURITY_DCHECK(blueIndex + 1 < digitBuffer.size()); 999 SECURITY_DCHECK(blueIndex + 1 < digitBuffer.size());
987 1000
988 int redValue = 1001 int redValue =
989 toASCIIHexValue(digitBuffer[redIndex], digitBuffer[redIndex + 1]); 1002 toASCIIHexValue(digitBuffer[redIndex], digitBuffer[redIndex + 1]);
990 int greenValue = 1003 int greenValue =
991 toASCIIHexValue(digitBuffer[greenIndex], digitBuffer[greenIndex + 1]); 1004 toASCIIHexValue(digitBuffer[greenIndex], digitBuffer[greenIndex + 1]);
992 int blueValue = 1005 int blueValue =
993 toASCIIHexValue(digitBuffer[blueIndex], digitBuffer[blueIndex + 1]); 1006 toASCIIHexValue(digitBuffer[blueIndex], digitBuffer[blueIndex + 1]);
994 return makeRGB(redValue, greenValue, blueValue); 1007 return makeRGB(redValue, greenValue, blueValue);
995 } 1008 }
996 1009
997 // Color parsing that matches HTML's "rules for parsing a legacy color value" 1010 // Color parsing that matches HTML's "rules for parsing a legacy color value"
998 bool HTMLElement::parseColorWithLegacyRules(const String& attributeValue, 1011 bool HTMLElement::parseColorWithLegacyRules(const String& attributeValue,
999 Color& parsedColor) { 1012 Color& parsedColor) {
1000 // An empty string doesn't apply a color. (One containing only whitespace does , which is why this check occurs before stripping.) 1013 // An empty string doesn't apply a color. (One containing only whitespace
1014 // does, which is why this check occurs before stripping.)
1001 if (attributeValue.isEmpty()) 1015 if (attributeValue.isEmpty())
1002 return false; 1016 return false;
1003 1017
1004 String colorString = attributeValue.stripWhiteSpace(); 1018 String colorString = attributeValue.stripWhiteSpace();
1005 1019
1006 // "transparent" doesn't apply a color either. 1020 // "transparent" doesn't apply a color either.
1007 if (equalIgnoringCase(colorString, "transparent")) 1021 if (equalIgnoringCase(colorString, "transparent"))
1008 return false; 1022 return false;
1009 1023
1010 // If the string is a 3/6-digit hex color or a named CSS color, use that. Appl y legacy rules otherwise. Note color.setFromString() 1024 // If the string is a 3/6-digit hex color or a named CSS color, use that.
1011 // accepts 4/8-digit hex color, so restrict its use with length checks here to support legacy HTML attributes. 1025 // Apply legacy rules otherwise. Note color.setFromString() accepts 4/8-digit
1026 // hex color, so restrict its use with length checks here to support legacy
1027 // HTML attributes.
1012 1028
1013 bool success = false; 1029 bool success = false;
1014 if ((colorString.length() == 4 || colorString.length() == 7) && 1030 if ((colorString.length() == 4 || colorString.length() == 7) &&
1015 colorString[0] == '#') 1031 colorString[0] == '#')
1016 success = parsedColor.setFromString(colorString); 1032 success = parsedColor.setFromString(colorString);
1017 if (!success) 1033 if (!success)
1018 success = parsedColor.setNamedColor(colorString); 1034 success = parsedColor.setNamedColor(colorString);
1019 if (!success) { 1035 if (!success) {
1020 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString)); 1036 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString));
1021 success = true; 1037 success = true;
(...skipping 25 matching lines...) Expand all
1047 : nullptr; 1063 : nullptr;
1048 } 1064 }
1049 1065
1050 HTMLMenuElement* HTMLElement::contextMenu() const { 1066 HTMLMenuElement* HTMLElement::contextMenu() const {
1051 const AtomicString& contextMenuId(fastGetAttribute(contextmenuAttr)); 1067 const AtomicString& contextMenuId(fastGetAttribute(contextmenuAttr));
1052 if (contextMenuId.isNull()) 1068 if (contextMenuId.isNull())
1053 return nullptr; 1069 return nullptr;
1054 1070
1055 Element* element = treeScope().getElementById(contextMenuId); 1071 Element* element = treeScope().getElementById(contextMenuId);
1056 // Not checking if the menu element is of type "popup". 1072 // Not checking if the menu element is of type "popup".
1057 // Ignoring menu element type attribute is intentional according to the standa rd. 1073 // Ignoring menu element type attribute is intentional according to the
1074 // standard.
1058 return isHTMLMenuElement(element) ? toHTMLMenuElement(element) : nullptr; 1075 return isHTMLMenuElement(element) ? toHTMLMenuElement(element) : nullptr;
1059 } 1076 }
1060 1077
1061 void HTMLElement::setContextMenu(HTMLMenuElement* contextMenu) { 1078 void HTMLElement::setContextMenu(HTMLMenuElement* contextMenu) {
1062 if (!contextMenu) { 1079 if (!contextMenu) {
1063 setAttribute(contextmenuAttr, ""); 1080 setAttribute(contextmenuAttr, "");
1064 return; 1081 return;
1065 } 1082 }
1066 1083
1067 // http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure. html#reflecting-content-attributes-in-idl-attributes 1084 // http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure. html#reflecting-content-attributes-in-idl-attributes
1068 // On setting, if the given element has an id attribute, and has the same home 1085 // On setting, if the given element has an id attribute, and has the same home
1069 // subtree as the element of the attribute being set, and the given element is the 1086 // subtree as the element of the attribute being set, and the given element is
1070 // first element in that home subtree whose ID is the value of that id attribu te, 1087 // the first element in that home subtree whose ID is the value of that id
1071 // then the content attribute must be set to the value of that id attribute. 1088 // attribute, then the content attribute must be set to the value of that id
1072 // Otherwise, the content attribute must be set to the empty string. 1089 // attribute. Otherwise, the content attribute must be set to the empty
1090 // string.
1073 const AtomicString& contextMenuId(contextMenu->fastGetAttribute(idAttr)); 1091 const AtomicString& contextMenuId(contextMenu->fastGetAttribute(idAttr));
1074 1092
1075 if (!contextMenuId.isNull() && 1093 if (!contextMenuId.isNull() &&
1076 contextMenu == treeScope().getElementById(contextMenuId)) 1094 contextMenu == treeScope().getElementById(contextMenuId))
1077 setAttribute(contextmenuAttr, contextMenuId); 1095 setAttribute(contextmenuAttr, contextMenuId);
1078 else 1096 else
1079 setAttribute(contextmenuAttr, ""); 1097 setAttribute(contextmenuAttr, "");
1080 } 1098 }
1081 1099
1082 void HTMLElement::defaultEventHandler(Event* event) { 1100 void HTMLElement::defaultEventHandler(Event* event) {
(...skipping 22 matching lines...) Expand all
1105 // All other values should be treated as "inherit". 1123 // All other values should be treated as "inherit".
1106 } 1124 }
1107 1125
1108 return parentElement() && hasEditableStyle(*parentElement()); 1126 return parentElement() && hasEditableStyle(*parentElement());
1109 } 1127 }
1110 1128
1111 void HTMLElement::handleKeypressEvent(KeyboardEvent* event) { 1129 void HTMLElement::handleKeypressEvent(KeyboardEvent* event) {
1112 if (!isSpatialNavigationEnabled(document().frame()) || !supportsFocus()) 1130 if (!isSpatialNavigationEnabled(document().frame()) || !supportsFocus())
1113 return; 1131 return;
1114 document().updateStyleAndLayoutTree(); 1132 document().updateStyleAndLayoutTree();
1115 // if the element is a text form control (like <input type=text> or <textarea> ) 1133 // if the element is a text form control (like <input type=text> or
1116 // or has contentEditable attribute on, we should enter a space or newline 1134 // <textarea>) or has contentEditable attribute on, we should enter a space or
1117 // even in spatial navigation mode instead of handling it as a "click" action. 1135 // newline even in spatial navigation mode instead of handling it as a "click"
1136 // action.
1118 if (isTextFormControl() || hasEditableStyle(*this)) 1137 if (isTextFormControl() || hasEditableStyle(*this))
1119 return; 1138 return;
1120 int charCode = event->charCode(); 1139 int charCode = event->charCode();
1121 if (charCode == '\r' || charCode == ' ') { 1140 if (charCode == '\r' || charCode == ' ') {
1122 dispatchSimulatedClick(event); 1141 dispatchSimulatedClick(event);
1123 event->setDefaultHandled(); 1142 event->setDefaultHandled();
1124 } 1143 }
1125 } 1144 }
1126 1145
1127 const AtomicString& HTMLElement::eventParameterName() { 1146 const AtomicString& HTMLElement::eventParameterName() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 1203
1185 #ifndef NDEBUG 1204 #ifndef NDEBUG
1186 1205
1187 // For use in the debugger 1206 // For use in the debugger
1188 void dumpInnerHTML(blink::HTMLElement*); 1207 void dumpInnerHTML(blink::HTMLElement*);
1189 1208
1190 void dumpInnerHTML(blink::HTMLElement* element) { 1209 void dumpInnerHTML(blink::HTMLElement* element) {
1191 printf("%s\n", element->innerHTML().ascii().data()); 1210 printf("%s\n", element->innerHTML().ascii().data());
1192 } 1211 }
1193 #endif 1212 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLElement.h ('k') | third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698