| 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 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 } else { | 750 } else { |
| 751 const SpaceSplitString& oldClasses = elementData()->classNames(); | 751 const SpaceSplitString& oldClasses = elementData()->classNames(); |
| 752 if (featureSet.checkSelectorsForClassChange(oldClasses)) | 752 if (featureSet.checkSelectorsForClassChange(oldClasses)) |
| 753 return true; | 753 return true; |
| 754 } | 754 } |
| 755 } | 755 } |
| 756 | 756 |
| 757 return featureSet.hasSelectorForAttribute(name.localName()); | 757 return featureSet.hasSelectorForAttribute(name.localName()); |
| 758 } | 758 } |
| 759 | 759 |
| 760 void Element::stripScriptingAttributes(Vector<Attribute>& attributeVector) const | |
| 761 { | |
| 762 size_t destination = 0; | |
| 763 for (size_t source = 0; source < attributeVector.size(); ++source) { | |
| 764 if (isHTMLContentAttribute(attributeVector[source])) | |
| 765 continue; | |
| 766 | |
| 767 if (source != destination) | |
| 768 attributeVector[destination] = attributeVector[source]; | |
| 769 | |
| 770 ++destination; | |
| 771 } | |
| 772 attributeVector.shrink(destination); | |
| 773 } | |
| 774 | |
| 775 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector) | 760 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector) |
| 776 { | 761 { |
| 777 ASSERT(!inDocument()); | 762 ASSERT(!inDocument()); |
| 778 ASSERT(!parentNode()); | 763 ASSERT(!parentNode()); |
| 779 ASSERT(!m_elementData); | 764 ASSERT(!m_elementData); |
| 780 | 765 |
| 781 if (attributeVector.isEmpty()) | 766 if (attributeVector.isEmpty()) |
| 782 return; | 767 return; |
| 783 | 768 |
| 784 if (document().elementDataCache()) | 769 if (document().elementDataCache()) |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 ElementShadow* Element::shadow() const | 1066 ElementShadow* Element::shadow() const |
| 1082 { | 1067 { |
| 1083 return hasRareData() ? elementRareData()->shadow() : 0; | 1068 return hasRareData() ? elementRareData()->shadow() : 0; |
| 1084 } | 1069 } |
| 1085 | 1070 |
| 1086 ElementShadow& Element::ensureShadow() | 1071 ElementShadow& Element::ensureShadow() |
| 1087 { | 1072 { |
| 1088 return ensureElementRareData().ensureShadow(); | 1073 return ensureElementRareData().ensureShadow(); |
| 1089 } | 1074 } |
| 1090 | 1075 |
| 1091 void Element::didAffectSelector(AffectedSelectorMask mask) | |
| 1092 { | |
| 1093 setNeedsStyleRecalc(SubtreeStyleChange); | |
| 1094 if (ElementShadow* elementShadow = shadowWhereNodeCanBeDistributed(*this)) | |
| 1095 elementShadow->didAffectSelector(mask); | |
| 1096 } | |
| 1097 | |
| 1098 void Element::setAnimationStyleChange(bool animationStyleChange) | 1076 void Element::setAnimationStyleChange(bool animationStyleChange) |
| 1099 { | 1077 { |
| 1100 if (animationStyleChange && document().inStyleRecalc()) | 1078 if (animationStyleChange && document().inStyleRecalc()) |
| 1101 return; | 1079 return; |
| 1102 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimations
()) | 1080 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimations
()) |
| 1103 activeAnimations->setAnimationStyleChange(animationStyleChange); | 1081 activeAnimations->setAnimationStyleChange(animationStyleChange); |
| 1104 } | 1082 } |
| 1105 | 1083 |
| 1106 void Element::setNeedsAnimationStyleRecalc() | 1084 void Element::setNeedsAnimationStyleRecalc() |
| 1107 { | 1085 { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 } | 1143 } |
| 1166 | 1144 |
| 1167 void Element::childrenChanged(const ChildrenChange& change) | 1145 void Element::childrenChanged(const ChildrenChange& change) |
| 1168 { | 1146 { |
| 1169 ContainerNode::childrenChanged(change); | 1147 ContainerNode::childrenChanged(change); |
| 1170 | 1148 |
| 1171 if (ElementShadow* shadow = this->shadow()) | 1149 if (ElementShadow* shadow = this->shadow()) |
| 1172 shadow->setNeedsDistributionRecalc(); | 1150 shadow->setNeedsDistributionRecalc(); |
| 1173 } | 1151 } |
| 1174 | 1152 |
| 1175 void Element::finishParsingChildren() | |
| 1176 { | |
| 1177 setIsFinishedParsingChildren(true); | |
| 1178 } | |
| 1179 | |
| 1180 #ifndef NDEBUG | 1153 #ifndef NDEBUG |
| 1181 void Element::formatForDebugger(char* buffer, unsigned length) const | 1154 void Element::formatForDebugger(char* buffer, unsigned length) const |
| 1182 { | 1155 { |
| 1183 StringBuilder result; | 1156 StringBuilder result; |
| 1184 String s; | 1157 String s; |
| 1185 | 1158 |
| 1186 result.append(nodeName()); | 1159 result.append(nodeName()); |
| 1187 | 1160 |
| 1188 s = getIdAttribute(); | 1161 s = getIdAttribute(); |
| 1189 if (s.length() > 0) { | 1162 if (s.length() > 0) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1216 // events here. | 1189 // events here. |
| 1217 document().setNeedsFocusedElementCheck(); | 1190 document().setNeedsFocusedElementCheck(); |
| 1218 } | 1191 } |
| 1219 } else if (parseHTMLInteger(value, tabindex)) { | 1192 } else if (parseHTMLInteger(value, tabindex)) { |
| 1220 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. | 1193 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. |
| 1221 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max()
)))); | 1194 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max()
)))); |
| 1222 } | 1195 } |
| 1223 } | 1196 } |
| 1224 } | 1197 } |
| 1225 | 1198 |
| 1226 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa
ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) | |
| 1227 { | |
| 1228 AtomicString prefix, localName; | |
| 1229 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio
nState)) | |
| 1230 return false; | |
| 1231 ASSERT(!exceptionState.hadException()); | |
| 1232 | |
| 1233 QualifiedName qName(localName); | |
| 1234 out = qName; | |
| 1235 return true; | |
| 1236 } | |
| 1237 | |
| 1238 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
te inSynchronizationOfLazyAttribute) | 1199 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
te inSynchronizationOfLazyAttribute) |
| 1239 { | 1200 { |
| 1240 MutableAttributeCollection attributes = ensureUniqueElementData().attributes
(); | 1201 MutableAttributeCollection attributes = ensureUniqueElementData().attributes
(); |
| 1241 ASSERT_WITH_SECURITY_IMPLICATION(index < attributes.size()); | 1202 ASSERT_WITH_SECURITY_IMPLICATION(index < attributes.size()); |
| 1242 | 1203 |
| 1243 QualifiedName name = attributes[index].name(); | 1204 QualifiedName name = attributes[index].name(); |
| 1244 AtomicString valueBeingRemoved = attributes[index].value(); | 1205 AtomicString valueBeingRemoved = attributes[index].value(); |
| 1245 | 1206 |
| 1246 if (!inSynchronizationOfLazyAttribute) { | 1207 if (!inSynchronizationOfLazyAttribute) { |
| 1247 if (!valueBeingRemoved.isNull()) | 1208 if (!valueBeingRemoved.isNull()) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(Foc
usEvent::create(eventType, true, false, document().domWindow(), 0, oldFocusedEle
ment))); | 1375 dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(Foc
usEvent::create(eventType, true, false, document().domWindow(), 0, oldFocusedEle
ment))); |
| 1415 } | 1376 } |
| 1416 | 1377 |
| 1417 void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newF
ocusedElement) | 1378 void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newF
ocusedElement) |
| 1418 { | 1379 { |
| 1419 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 1380 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 1420 ASSERT(eventType == EventTypeNames::focusout || eventType == EventTypeNames:
:DOMFocusOut); | 1381 ASSERT(eventType == EventTypeNames::focusout || eventType == EventTypeNames:
:DOMFocusOut); |
| 1421 dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(Fo
cusEvent::create(eventType, true, false, document().domWindow(), 0, newFocusedEl
ement))); | 1382 dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(Fo
cusEvent::create(eventType, true, false, document().domWindow(), 0, newFocusedEl
ement))); |
| 1422 } | 1383 } |
| 1423 | 1384 |
| 1424 String Element::innerText() | |
| 1425 { | |
| 1426 // We need to update layout, since plainText uses line boxes in the render t
ree. | |
| 1427 document().updateLayoutIgnorePendingStylesheets(); | |
| 1428 | |
| 1429 if (!renderer()) | |
| 1430 return textContent(true); | |
| 1431 | |
| 1432 return plainText(rangeOfContents(const_cast<Element*>(this)).get()); | |
| 1433 } | |
| 1434 | |
| 1435 String Element::outerText() | |
| 1436 { | |
| 1437 // Getting outerText is the same as getting innerText, only | |
| 1438 // setting is different. You would think this should get the plain | |
| 1439 // text for the outer range, but this is wrong, <br> for instance | |
| 1440 // would return different values for inner and outer text by such | |
| 1441 // a rule, but it doesn't in WinIE, and we want to match that. | |
| 1442 return innerText(); | |
| 1443 } | |
| 1444 | |
| 1445 String Element::textFromChildren() | 1385 String Element::textFromChildren() |
| 1446 { | 1386 { |
| 1447 Text* firstTextNode = 0; | 1387 Text* firstTextNode = 0; |
| 1448 bool foundMultipleTextNodes = false; | 1388 bool foundMultipleTextNodes = false; |
| 1449 unsigned totalLength = 0; | 1389 unsigned totalLength = 0; |
| 1450 | 1390 |
| 1451 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 1391 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 1452 if (!child->isTextNode()) | 1392 if (!child->isTextNode()) |
| 1453 continue; | 1393 continue; |
| 1454 Text* text = toText(child); | 1394 Text* text = toText(child); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1475 for (Node* child = firstTextNode; child; child = child->nextSibling()) { | 1415 for (Node* child = firstTextNode; child; child = child->nextSibling()) { |
| 1476 if (!child->isTextNode()) | 1416 if (!child->isTextNode()) |
| 1477 continue; | 1417 continue; |
| 1478 content.append(toText(child)->data()); | 1418 content.append(toText(child)->data()); |
| 1479 } | 1419 } |
| 1480 | 1420 |
| 1481 ASSERT(content.length() == totalLength); | 1421 ASSERT(content.length() == totalLength); |
| 1482 return content.toString(); | 1422 return content.toString(); |
| 1483 } | 1423 } |
| 1484 | 1424 |
| 1485 bool Element::isInDescendantTreeOf(const Element* shadowHost) const | |
| 1486 { | |
| 1487 ASSERT(shadowHost); | |
| 1488 ASSERT(isShadowHost(shadowHost)); | |
| 1489 | |
| 1490 const ShadowRoot* shadowRoot = containingShadowRoot(); | |
| 1491 while (shadowRoot) { | |
| 1492 const Element* ancestorShadowHost = shadowRoot->shadowHost(); | |
| 1493 if (ancestorShadowHost == shadowHost) | |
| 1494 return true; | |
| 1495 shadowRoot = ancestorShadowHost->containingShadowRoot(); | |
| 1496 } | |
| 1497 return false; | |
| 1498 } | |
| 1499 | |
| 1500 LayoutSize Element::minimumSizeForResizing() const | 1425 LayoutSize Element::minimumSizeForResizing() const |
| 1501 { | 1426 { |
| 1502 return hasRareData() ? elementRareData()->minimumSizeForResizing() : default
MinimumSizeForResizing(); | 1427 return hasRareData() ? elementRareData()->minimumSizeForResizing() : default
MinimumSizeForResizing(); |
| 1503 } | 1428 } |
| 1504 | 1429 |
| 1505 void Element::setMinimumSizeForResizing(const LayoutSize& size) | 1430 void Element::setMinimumSizeForResizing(const LayoutSize& size) |
| 1506 { | 1431 { |
| 1507 if (!hasRareData() && size == defaultMinimumSizeForResizing()) | 1432 if (!hasRareData() && size == defaultMinimumSizeForResizing()) |
| 1508 return; | 1433 return; |
| 1509 ensureElementRareData().setMinimumSizeForResizing(size); | 1434 ensureElementRareData().setMinimumSizeForResizing(size); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 if (hasActiveAnimations()) | 1904 if (hasActiveAnimations()) |
| 1980 return false; | 1905 return false; |
| 1981 // Turn off style sharing for elements that can gain layers for reasons outs
ide of the style system. | 1906 // Turn off style sharing for elements that can gain layers for reasons outs
ide of the style system. |
| 1982 // See comments in RenderObject::setStyle(). | 1907 // See comments in RenderObject::setStyle(). |
| 1983 // FIXME: Why does gaining a layer from outside the style system require dis
abling sharing? | 1908 // FIXME: Why does gaining a layer from outside the style system require dis
abling sharing? |
| 1984 if (isHTMLCanvasElement(*this)) | 1909 if (isHTMLCanvasElement(*this)) |
| 1985 return false; | 1910 return false; |
| 1986 return true; | 1911 return true; |
| 1987 } | 1912 } |
| 1988 | 1913 |
| 1989 void Element::trace(Visitor* visitor) | |
| 1990 { | |
| 1991 #if ENABLE(OILPAN) | |
| 1992 if (hasRareData()) | |
| 1993 visitor->trace(elementRareData()); | |
| 1994 visitor->trace(m_elementData); | |
| 1995 #endif | |
| 1996 ContainerNode::trace(visitor); | |
| 1997 } | |
| 1998 | |
| 1999 } // namespace blink | 1914 } // namespace blink |
| OLD | NEW |