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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "ScriptEventListener.h" | 52 #include "ScriptEventListener.h" |
53 #include "Settings.h" | 53 #include "Settings.h" |
54 #include "StylePropertySet.h" | 54 #include "StylePropertySet.h" |
55 #include "Text.h" | 55 #include "Text.h" |
56 #include "TextIterator.h" | 56 #include "TextIterator.h" |
57 #include "XMLNames.h" | 57 #include "XMLNames.h" |
58 #include "markup.h" | 58 #include "markup.h" |
59 #include <wtf/StdLibExtras.h> | 59 #include <wtf/StdLibExtras.h> |
60 #include <wtf/text/CString.h> | 60 #include <wtf/text/CString.h> |
61 | 61 |
62 #if ENABLE(MICRODATA) | |
63 #include "HTMLPropertiesCollection.h" | |
64 #include "MicroDataItemValue.h" | |
65 #endif | |
66 | |
67 namespace WebCore { | 62 namespace WebCore { |
68 | 63 |
69 using namespace HTMLNames; | 64 using namespace HTMLNames; |
70 using namespace WTF; | 65 using namespace WTF; |
71 | 66 |
72 using std::min; | 67 using std::min; |
73 using std::max; | 68 using std::max; |
74 | 69 |
75 PassRefPtr<HTMLElement> HTMLElement::create(const QualifiedName& tagName, Docume
nt* document) | 70 PassRefPtr<HTMLElement> HTMLElement::create(const QualifiedName& tagName, Docume
nt* document) |
76 { | 71 { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 if (name == dirAttr) | 289 if (name == dirAttr) |
295 dirAttributeChanged(value); | 290 dirAttributeChanged(value); |
296 else if (name == tabindexAttr) { | 291 else if (name == tabindexAttr) { |
297 int tabindex = 0; | 292 int tabindex = 0; |
298 if (value.isEmpty()) | 293 if (value.isEmpty()) |
299 clearTabIndexExplicitlyIfNeeded(); | 294 clearTabIndexExplicitlyIfNeeded(); |
300 else if (parseHTMLInteger(value, tabindex)) { | 295 else if (parseHTMLInteger(value, tabindex)) { |
301 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. | 296 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. |
302 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max())))); | 297 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max())))); |
303 } | 298 } |
304 #if ENABLE(MICRODATA) | |
305 } else if (name == itempropAttr) { | |
306 setItemProp(value); | |
307 } else if (name == itemrefAttr) { | |
308 setItemRef(value); | |
309 } else if (name == itemtypeAttr) { | |
310 setItemType(value); | |
311 #endif | |
312 } else { | 299 } else { |
313 AtomicString eventName = eventNameForAttributeName(name); | 300 AtomicString eventName = eventNameForAttributeName(name); |
314 if (!eventName.isNull()) | 301 if (!eventName.isNull()) |
315 setAttributeEventListener(eventName, createAttributeEventListener(th
is, name, value)); | 302 setAttributeEventListener(eventName, createAttributeEventListener(th
is, name, value)); |
316 } | 303 } |
317 } | 304 } |
318 | 305 |
319 String HTMLElement::innerHTML() const | 306 String HTMLElement::innerHTML() const |
320 { | 307 { |
321 return createMarkup(this, ChildrenOnly); | 308 return createMarkup(this, ChildrenOnly); |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 setHasDirAutoFlagRecursively(oldMarkedNode, false); | 921 setHasDirAutoFlagRecursively(oldMarkedNode, false); |
935 | 922 |
936 for (Element* elementToAdjust = this; elementToAdjust; elementToAdjust = ele
mentToAdjust->parentElement()) { | 923 for (Element* elementToAdjust = this; elementToAdjust; elementToAdjust = ele
mentToAdjust->parentElement()) { |
937 if (elementAffectsDirectionality(elementToAdjust)) { | 924 if (elementAffectsDirectionality(elementToAdjust)) { |
938 toHTMLElement(elementToAdjust)->calculateAndAdjustDirectionality(); | 925 toHTMLElement(elementToAdjust)->calculateAndAdjustDirectionality(); |
939 return; | 926 return; |
940 } | 927 } |
941 } | 928 } |
942 } | 929 } |
943 | 930 |
944 bool HTMLElement::isURLAttribute(const Attribute& attribute) const | |
945 { | |
946 #if ENABLE(MICRODATA) | |
947 if (attribute.name() == itemidAttr) | |
948 return true; | |
949 #endif | |
950 return StyledElement::isURLAttribute(attribute); | |
951 } | |
952 | |
953 #if ENABLE(MICRODATA) | |
954 void HTMLElement::setItemValue(const String& value, ExceptionCode& ec) | |
955 { | |
956 if (!hasAttribute(itempropAttr) || hasAttribute(itemscopeAttr)) { | |
957 ec = INVALID_ACCESS_ERR; | |
958 return; | |
959 } | |
960 | |
961 setItemValueText(value, ec); | |
962 } | |
963 | |
964 PassRefPtr<MicroDataItemValue> HTMLElement::itemValue() const | |
965 { | |
966 if (!hasAttribute(itempropAttr)) | |
967 return 0; | |
968 | |
969 if (hasAttribute(itemscopeAttr)) | |
970 return MicroDataItemValue::createFromNode(const_cast<HTMLElement* const>
(this)); | |
971 | |
972 return MicroDataItemValue::createFromString(itemValueText()); | |
973 } | |
974 | |
975 String HTMLElement::itemValueText() const | |
976 { | |
977 return textContent(true); | |
978 } | |
979 | |
980 void HTMLElement::setItemValueText(const String& value, ExceptionCode& ec) | |
981 { | |
982 setTextContent(value, ec); | |
983 } | |
984 | |
985 PassRefPtr<HTMLPropertiesCollection> HTMLElement::properties() | |
986 { | |
987 return static_cast<HTMLPropertiesCollection*>(ensureCachedHTMLCollection(Ite
mProperties).get()); | |
988 } | |
989 | |
990 void HTMLElement::getItemRefElements(Vector<HTMLElement*>& itemRefElements) | |
991 { | |
992 if (!fastHasAttribute(itemscopeAttr)) | |
993 return; | |
994 | |
995 if (!fastHasAttribute(itemrefAttr) || !itemRef()->length()) { | |
996 itemRefElements.append(this); | |
997 return; | |
998 } | |
999 | |
1000 DOMSettableTokenList* itemRefs = itemRef(); | |
1001 RefPtr<DOMSettableTokenList> processedItemRef = DOMSettableTokenList::create
(); | |
1002 | |
1003 Node* rootNode; | |
1004 if (inDocument()) | |
1005 rootNode = document(); | |
1006 else { | |
1007 rootNode = this; | |
1008 while (Node* parent = rootNode->parentNode()) | |
1009 rootNode = parent; | |
1010 } | |
1011 | |
1012 for (Node* current = rootNode; current; current = NodeTraversal::next(curren
t, rootNode)) { | |
1013 if (!current->isHTMLElement()) | |
1014 continue; | |
1015 HTMLElement* element = toHTMLElement(current); | |
1016 | |
1017 if (element == this) { | |
1018 itemRefElements.append(element); | |
1019 continue; | |
1020 } | |
1021 | |
1022 const AtomicString& id = element->getIdAttribute(); | |
1023 if (!processedItemRef->tokens().contains(id) && itemRefs->tokens().conta
ins(id)) { | |
1024 processedItemRef->setValue(id); | |
1025 if (!element->isDescendantOf(this)) | |
1026 itemRefElements.append(element); | |
1027 } | |
1028 } | |
1029 } | |
1030 #endif | |
1031 | |
1032 void HTMLElement::addHTMLLengthToStyle(MutableStylePropertySet* style, CSSProper
tyID propertyID, const String& value) | 931 void HTMLElement::addHTMLLengthToStyle(MutableStylePropertySet* style, CSSProper
tyID propertyID, const String& value) |
1033 { | 932 { |
1034 // FIXME: This function should not spin up the CSS parser, but should instea
d just figure out the correct | 933 // FIXME: This function should not spin up the CSS parser, but should instea
d just figure out the correct |
1035 // length unit and make the appropriate parsed value. | 934 // length unit and make the appropriate parsed value. |
1036 | 935 |
1037 // strip attribute garbage.. | 936 // strip attribute garbage.. |
1038 StringImpl* v = value.impl(); | 937 StringImpl* v = value.impl(); |
1039 if (v) { | 938 if (v) { |
1040 unsigned int l = 0; | 939 unsigned int l = 0; |
1041 | 940 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 #ifndef NDEBUG | 1044 #ifndef NDEBUG |
1146 | 1045 |
1147 // For use in the debugger | 1046 // For use in the debugger |
1148 void dumpInnerHTML(WebCore::HTMLElement*); | 1047 void dumpInnerHTML(WebCore::HTMLElement*); |
1149 | 1048 |
1150 void dumpInnerHTML(WebCore::HTMLElement* element) | 1049 void dumpInnerHTML(WebCore::HTMLElement* element) |
1151 { | 1050 { |
1152 printf("%s\n", element->innerHTML().ascii().data()); | 1051 printf("%s\n", element->innerHTML().ascii().data()); |
1153 } | 1052 } |
1154 #endif | 1053 #endif |
OLD | NEW |