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

Side by Side Diff: Source/core/dom/ContainerNode.cpp

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase to master Created 5 years, 9 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 | Annotate | Revision Log
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 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 void ContainerNode::cloneChildNodes(ContainerNode *clone) 860 void ContainerNode::cloneChildNodes(ContainerNode *clone)
861 { 861 {
862 TrackExceptionState exceptionState; 862 TrackExceptionState exceptionState;
863 for (Node* n = firstChild(); n && !exceptionState.hadException(); n = n->nex tSibling()) 863 for (Node* n = firstChild(); n && !exceptionState.hadException(); n = n->nex tSibling())
864 clone->appendChild(n->cloneNode(true), exceptionState); 864 clone->appendChild(n->cloneNode(true), exceptionState);
865 } 865 }
866 866
867 867
868 bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const 868 bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const
869 { 869 {
870 if (!renderer()) 870 if (!layoutObject())
871 return false; 871 return false;
872 872
873 // FIXME: What is this code really trying to do? 873 // FIXME: What is this code really trying to do?
874 LayoutObject* o = renderer(); 874 LayoutObject* o = layoutObject();
875 if (!o->isInline() || o->isReplaced()) { 875 if (!o->isInline() || o->isReplaced()) {
876 point = o->localToAbsolute(FloatPoint(), UseTransforms); 876 point = o->localToAbsolute(FloatPoint(), UseTransforms);
877 return true; 877 return true;
878 } 878 }
879 879
880 // Find the next text/image child, to get a position. 880 // Find the next text/image child, to get a position.
881 while (o) { 881 while (o) {
882 LayoutObject* p = o; 882 LayoutObject* p = o;
883 if (LayoutObject* oFirstChild = o->slowFirstChild()) { 883 if (LayoutObject* oFirstChild = o->slowFirstChild()) {
884 o = oFirstChild; 884 o = oFirstChild;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 cur = toLayoutInline(cur)->continuation(); 940 cur = toLayoutInline(cur)->continuation();
941 else 941 else
942 cur = toLayoutBlock(cur)->continuation(); 942 cur = toLayoutBlock(cur)->continuation();
943 } 943 }
944 944
945 return prev; 945 return prev;
946 } 946 }
947 947
948 bool ContainerNode::getLowerRightCorner(FloatPoint& point) const 948 bool ContainerNode::getLowerRightCorner(FloatPoint& point) const
949 { 949 {
950 if (!renderer()) 950 if (!layoutObject())
951 return false; 951 return false;
952 952
953 LayoutObject* o = renderer(); 953 LayoutObject* o = layoutObject();
954 if (!o->isInline() || o->isReplaced()) { 954 if (!o->isInline() || o->isReplaced()) {
955 LayoutBox* box = toLayoutBox(o); 955 LayoutBox* box = toLayoutBox(o);
956 point = o->localToAbsolute(FloatPoint(box->size()), UseTransforms); 956 point = o->localToAbsolute(FloatPoint(box->size()), UseTransforms);
957 return true; 957 return true;
958 } 958 }
959 959
960 LayoutObject* startContinuation = nullptr; 960 LayoutObject* startContinuation = nullptr;
961 // Find the last text/image child, to get a position. 961 // Find the last text/image child, to get a position.
962 while (o) { 962 while (o) {
963 if (LayoutObject* oLastChild = o->slowLastChild()) { 963 if (LayoutObject* oLastChild = o->slowLastChild()) {
964 o = oLastChild; 964 o = oLastChild;
965 } else if (o != renderer() && o->previousSibling()) { 965 } else if (o != layoutObject() && o->previousSibling()) {
966 o = o->previousSibling(); 966 o = o->previousSibling();
967 } else { 967 } else {
968 LayoutObject* prev = nullptr; 968 LayoutObject* prev = nullptr;
969 while (!prev) { 969 while (!prev) {
970 // Check if the current renderer has contiunation and move the l ocation for finding the renderer 970 // Check if the current renderer has contiunation and move the l ocation for finding the renderer
971 // to the end of continuations if there is the continuation. 971 // to the end of continuations if there is the continuation.
972 // Skip to check the contiunation on contiunations section 972 // Skip to check the contiunation on contiunations section
973 if (startContinuation == o) { 973 if (startContinuation == o) {
974 startContinuation = nullptr; 974 startContinuation = nullptr;
975 } else if (!startContinuation) { 975 } else if (!startContinuation) {
976 if (LayoutObject* continuation = endOfContinuations(o)) { 976 if (LayoutObject* continuation = endOfContinuations(o)) {
977 startContinuation = o; 977 startContinuation = o;
978 prev = continuation; 978 prev = continuation;
979 break; 979 break;
980 } 980 }
981 } 981 }
982 // Prevent to overrun out of own render tree 982 // Prevent to overrun out of own render tree
983 if (o == renderer()) { 983 if (o == layoutObject()) {
984 return false; 984 return false;
985 } 985 }
986 o = o->parent(); 986 o = o->parent();
987 if (!o) 987 if (!o)
988 return false; 988 return false;
989 prev = o->previousSibling(); 989 prev = o->previousSibling();
990 } 990 }
991 o = prev; 991 o = prev;
992 } 992 }
993 ASSERT(o); 993 ASSERT(o);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1031
1032 return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperL eft) - upperLeft)); 1032 return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperL eft) - upperLeft));
1033 } 1033 }
1034 1034
1035 // This is used by FrameSelection to denote when the active-state of the page ha s changed 1035 // This is used by FrameSelection to denote when the active-state of the page ha s changed
1036 // independent of the focused element changing. 1036 // independent of the focused element changing.
1037 void ContainerNode::focusStateChanged() 1037 void ContainerNode::focusStateChanged()
1038 { 1038 {
1039 // If we're just changing the window's active state and the focused node has no 1039 // If we're just changing the window's active state and the focused node has no
1040 // renderer we can just ignore the state change. 1040 // renderer we can just ignore the state change.
1041 if (!renderer()) 1041 if (!layoutObject())
1042 return; 1042 return;
1043 1043
1044 if (styleChangeType() < SubtreeStyleChange) { 1044 if (styleChangeType() < SubtreeStyleChange) {
1045 if (layoutStyle()->affectedByFocus() && layoutStyle()->hasPseudoStyle(FI RST_LETTER)) 1045 if (layoutStyle()->affectedByFocus() && layoutStyle()->hasPseudoStyle(FI RST_LETTER))
1046 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing: :createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus )); 1046 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing: :createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus ));
1047 else if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedB yFocus()) 1047 else if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedB yFocus())
1048 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().sched uleStyleInvalidationForPseudoChange(CSSSelector::PseudoFocus, *toElement(this)); 1048 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().sched uleStyleInvalidationForPseudoChange(CSSSelector::PseudoFocus, *toElement(this));
1049 else if (layoutStyle()->affectedByFocus()) 1049 else if (layoutStyle()->affectedByFocus())
1050 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)) ; 1050 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)) ;
1051 } 1051 }
1052 1052
1053 if (renderer() && renderer()->style()->hasAppearance()) 1053 if (layoutObject() && layoutObject()->style()->hasAppearance())
1054 LayoutTheme::theme().stateChanged(renderer(), FocusControlState); 1054 LayoutTheme::theme().stateChanged(layoutObject(), FocusControlState);
1055 } 1055 }
1056 1056
1057 void ContainerNode::setFocus(bool received) 1057 void ContainerNode::setFocus(bool received)
1058 { 1058 {
1059 if (focused() == received) 1059 if (focused() == received)
1060 return; 1060 return;
1061 1061
1062 Node::setFocus(received); 1062 Node::setFocus(received);
1063 1063
1064 focusStateChanged(); 1064 focusStateChanged();
1065 1065
1066 if (renderer() || received) 1066 if (layoutObject() || received)
1067 return; 1067 return;
1068 1068
1069 // If :focus sets display: none, we lose focus but still need to recalc our style. 1069 // If :focus sets display: none, we lose focus but still need to recalc our style.
1070 if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedByFocus() && styleChangeType() < SubtreeStyleChange) 1070 if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedByFocus() && styleChangeType() < SubtreeStyleChange)
1071 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().scheduleS tyleInvalidationForPseudoChange(CSSSelector::PseudoFocus, *toElement(this)); 1071 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().scheduleS tyleInvalidationForPseudoChange(CSSSelector::PseudoFocus, *toElement(this));
1072 else 1072 else
1073 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::creat eWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); 1073 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::creat eWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus));
1074 } 1074 }
1075 1075
1076 void ContainerNode::setActive(bool down) 1076 void ContainerNode::setActive(bool down)
1077 { 1077 {
1078 if (down == active()) 1078 if (down == active())
1079 return; 1079 return;
1080 1080
1081 Node::setActive(down); 1081 Node::setActive(down);
1082 1082
1083 // FIXME: Why does this not need to handle the display: none transition like :hover does? 1083 // FIXME: Why does this not need to handle the display: none transition like :hover does?
1084 if (renderer()) { 1084 if (layoutObject()) {
1085 if (styleChangeType() < SubtreeStyleChange) { 1085 if (styleChangeType() < SubtreeStyleChange) {
1086 if (layoutStyle()->affectedByActive() && layoutStyle()->hasPseudoSty le(FIRST_LETTER)) 1086 if (layoutStyle()->affectedByActive() && layoutStyle()->hasPseudoSty le(FIRST_LETTER))
1087 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::A ctive)); 1087 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::A ctive));
1088 else if (isElementNode() && toElement(this)->childrenOrSiblingsAffec tedByActive()) 1088 else if (isElementNode() && toElement(this)->childrenOrSiblingsAffec tedByActive())
1089 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().s cheduleStyleInvalidationForPseudoChange(CSSSelector::PseudoActive, *toElement(th is)); 1089 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().s cheduleStyleInvalidationForPseudoChange(CSSSelector::PseudoActive, *toElement(th is));
1090 else if (layoutStyle()->affectedByActive()) 1090 else if (layoutStyle()->affectedByActive())
1091 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Act ive)); 1091 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Act ive));
1092 } 1092 }
1093 1093
1094 if (layoutStyle()->hasAppearance()) 1094 if (layoutStyle()->hasAppearance())
1095 LayoutTheme::theme().stateChanged(renderer(), PressedControlState); 1095 LayoutTheme::theme().stateChanged(layoutObject(), PressedControlStat e);
1096 } 1096 }
1097 } 1097 }
1098 1098
1099 void ContainerNode::setHovered(bool over) 1099 void ContainerNode::setHovered(bool over)
1100 { 1100 {
1101 if (over == hovered()) 1101 if (over == hovered())
1102 return; 1102 return;
1103 1103
1104 Node::setHovered(over); 1104 Node::setHovered(over);
1105 1105
1106 // If :hover sets display: none we lose our hover but still need to recalc o ur style. 1106 // If :hover sets display: none we lose our hover but still need to recalc o ur style.
1107 if (!renderer()) { 1107 if (!layoutObject()) {
1108 if (over) 1108 if (over)
1109 return; 1109 return;
1110 if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedByHove r() && styleChangeType() < SubtreeStyleChange) 1110 if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedByHove r() && styleChangeType() < SubtreeStyleChange)
1111 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().sched uleStyleInvalidationForPseudoChange(CSSSelector::PseudoHover, *toElement(this)); 1111 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().sched uleStyleInvalidationForPseudoChange(CSSSelector::PseudoHover, *toElement(this));
1112 else 1112 else
1113 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Hover)) ; 1113 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Hover)) ;
1114 return; 1114 return;
1115 } 1115 }
1116 1116
1117 if (styleChangeType() < SubtreeStyleChange) { 1117 if (styleChangeType() < SubtreeStyleChange) {
1118 if (layoutStyle()->affectedByHover() && layoutStyle()->hasPseudoStyle(FI RST_LETTER)) 1118 if (layoutStyle()->affectedByHover() && layoutStyle()->hasPseudoStyle(FI RST_LETTER))
1119 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing: :createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Hover )); 1119 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing: :createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Hover ));
1120 else if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedB yHover()) 1120 else if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedB yHover())
1121 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().sched uleStyleInvalidationForPseudoChange(CSSSelector::PseudoHover, *toElement(this)); 1121 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().sched uleStyleInvalidationForPseudoChange(CSSSelector::PseudoHover, *toElement(this));
1122 else if (layoutStyle()->affectedByHover()) 1122 else if (layoutStyle()->affectedByHover())
1123 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Hover)) ; 1123 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Hover)) ;
1124 } 1124 }
1125 1125
1126 if (renderer()->style()->hasAppearance()) 1126 if (layoutObject()->style()->hasAppearance())
1127 LayoutTheme::theme().stateChanged(renderer(), HoverControlState); 1127 LayoutTheme::theme().stateChanged(layoutObject(), HoverControlState);
1128 } 1128 }
1129 1129
1130 PassRefPtrWillBeRawPtr<HTMLCollection> ContainerNode::children() 1130 PassRefPtrWillBeRawPtr<HTMLCollection> ContainerNode::children()
1131 { 1131 {
1132 return ensureCachedCollection<HTMLCollection>(NodeChildren); 1132 return ensureCachedCollection<HTMLCollection>(NodeChildren);
1133 } 1133 }
1134 1134
1135 unsigned ContainerNode::countChildren() const 1135 unsigned ContainerNode::countChildren() const
1136 { 1136 {
1137 unsigned count = 0; 1137 unsigned count = 0;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 for (Node* child = lastChild(); child; child = child->previousSibling()) { 1264 for (Node* child = lastChild(); child; child = child->previousSibling()) {
1265 if (child->isTextNode()) { 1265 if (child->isTextNode()) {
1266 toText(child)->recalcTextStyle(change, lastTextNode); 1266 toText(child)->recalcTextStyle(change, lastTextNode);
1267 lastTextNode = toText(child); 1267 lastTextNode = toText(child);
1268 } else if (child->isElementNode()) { 1268 } else if (child->isElementNode()) {
1269 Element* element = toElement(child); 1269 Element* element = toElement(child);
1270 if (element->shouldCallRecalcStyle(change)) 1270 if (element->shouldCallRecalcStyle(change))
1271 element->recalcStyle(change, lastTextNode); 1271 element->recalcStyle(change, lastTextNode);
1272 else if (element->supportsStyleSharing()) 1272 else if (element->supportsStyleSharing())
1273 styleResolver.addToStyleSharingList(*element); 1273 styleResolver.addToStyleSharingList(*element);
1274 if (element->renderer()) 1274 if (element->layoutObject())
1275 lastTextNode = nullptr; 1275 lastTextNode = nullptr;
1276 } 1276 }
1277 } 1277 }
1278 } 1278 }
1279 1279
1280 void ContainerNode::checkForChildrenAdjacentRuleChanges() 1280 void ContainerNode::checkForChildrenAdjacentRuleChanges()
1281 { 1281 {
1282 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules(); 1282 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules();
1283 bool hasIndirectAdjacentRules = childrenAffectedByIndirectAdjacentRules(); 1283 bool hasIndirectAdjacentRules = childrenAffectedByIndirectAdjacentRules();
1284 1284
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 return true; 1478 return true;
1479 1479
1480 if (node->isElementNode() && toElement(node)->shadow()) 1480 if (node->isElementNode() && toElement(node)->shadow())
1481 return true; 1481 return true;
1482 1482
1483 return false; 1483 return false;
1484 } 1484 }
1485 #endif 1485 #endif
1486 1486
1487 } // namespace blink 1487 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698