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

Side by Side Diff: Source/core/accessibility/AXRenderObject.cpp

Issue 295513003: add 'slow' prefix to RenderObject's firstChild() / lastChild() methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | Source/core/dom/ContainerNode.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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "core/svg/graphics/SVGImage.h" 70 #include "core/svg/graphics/SVGImage.h"
71 #include "platform/text/PlatformLocale.h" 71 #include "platform/text/PlatformLocale.h"
72 #include "wtf/StdLibExtras.h" 72 #include "wtf/StdLibExtras.h"
73 73
74 using blink::WebLocalizedString; 74 using blink::WebLocalizedString;
75 75
76 namespace WebCore { 76 namespace WebCore {
77 77
78 using namespace HTMLNames; 78 using namespace HTMLNames;
79 79
80 static inline RenderObject* firstChildInContinuation(RenderObject* renderer) 80 static inline RenderObject* firstChildInContinuation(const RenderInline& rendere r)
81 { 81 {
82 RenderObject* r = toRenderInline(renderer)->continuation(); 82 RenderBoxModelObject* r = renderer.continuation();
83 83
84 while (r) { 84 while (r) {
85 if (r->isRenderBlock()) 85 if (r->isRenderBlock())
86 return r; 86 return r;
87 if (RenderObject* child = r->firstChild()) 87 if (RenderObject* child = r->slowFirstChild())
88 return child; 88 return child;
89 r = toRenderInline(r)->continuation(); 89 r = toRenderInline(r)->continuation();
90 } 90 }
91 91
92 return 0; 92 return 0;
93 } 93 }
94 94
95 static inline bool isInlineWithContinuation(RenderObject* object) 95 static inline bool isInlineWithContinuation(RenderObject* object)
96 { 96 {
97 if (!object->isBoxModelObject()) 97 if (!object->isBoxModelObject())
98 return false; 98 return false;
99 99
100 RenderBoxModelObject* renderer = toRenderBoxModelObject(object); 100 RenderBoxModelObject* renderer = toRenderBoxModelObject(object);
101 if (!renderer->isRenderInline()) 101 if (!renderer->isRenderInline())
102 return false; 102 return false;
103 103
104 return toRenderInline(renderer)->continuation(); 104 return toRenderInline(renderer)->continuation();
105 } 105 }
106 106
107 static inline RenderObject* firstChildConsideringContinuation(RenderObject* rend erer) 107 static inline RenderObject* firstChildConsideringContinuation(RenderObject* rend erer)
108 { 108 {
109 RenderObject* firstChild = renderer->firstChild(); 109 RenderObject* firstChild = renderer->slowFirstChild();
110 110
111 if (!firstChild && isInlineWithContinuation(renderer)) 111 if (!firstChild && isInlineWithContinuation(renderer))
112 firstChild = firstChildInContinuation(renderer); 112 firstChild = firstChildInContinuation(toRenderInline(*renderer));
113 113
114 return firstChild; 114 return firstChild;
115 } 115 }
116 116
117 static inline RenderInline* startOfContinuations(RenderObject* r) 117 static inline RenderInline* startOfContinuations(RenderObject* r)
118 { 118 {
119 if (r->isInlineElementContinuation()) { 119 if (r->isInlineElementContinuation()) {
120 return toRenderInline(r->node()->renderer()); 120 return toRenderInline(r->node()->renderer());
121 } 121 }
122 122
(...skipping 20 matching lines...) Expand all
143 } else { 143 } else {
144 cur = toRenderBlock(cur)->inlineElementContinuation(); 144 cur = toRenderBlock(cur)->inlineElementContinuation();
145 } 145 }
146 } 146 }
147 147
148 return prev; 148 return prev;
149 } 149 }
150 150
151 static inline bool lastChildHasContinuation(RenderObject* renderer) 151 static inline bool lastChildHasContinuation(RenderObject* renderer)
152 { 152 {
153 return renderer->lastChild() && isInlineWithContinuation(renderer->lastChild ()); 153 RenderObject* lastChild = renderer->slowLastChild();
154 return lastChild && isInlineWithContinuation(lastChild);
154 } 155 }
155 156
156 static RenderBoxModelObject* nextContinuation(RenderObject* renderer) 157 static RenderBoxModelObject* nextContinuation(RenderObject* renderer)
157 { 158 {
158 ASSERT(renderer); 159 ASSERT(renderer);
159 if (renderer->isRenderInline() && !renderer->isReplaced()) 160 if (renderer->isRenderInline() && !renderer->isReplaced())
160 return toRenderInline(renderer)->continuation(); 161 return toRenderInline(renderer)->continuation();
161 if (renderer->isRenderBlock()) 162 if (renderer->isRenderBlock())
162 return toRenderBlock(renderer)->inlineElementContinuation(); 163 return toRenderBlock(renderer)->inlineElementContinuation();
163 return 0; 164 return 0;
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 1375
1375 RenderObject* nextSibling = 0; 1376 RenderObject* nextSibling = 0;
1376 1377
1377 RenderInline* inlineContinuation; 1378 RenderInline* inlineContinuation;
1378 if (m_renderer->isRenderBlock() && (inlineContinuation = toRenderBlock(m_ren derer)->inlineElementContinuation())) { 1379 if (m_renderer->isRenderBlock() && (inlineContinuation = toRenderBlock(m_ren derer)->inlineElementContinuation())) {
1379 // Case 1: node is a block and has an inline continuation. Next sibling is the inline continuation's first child. 1380 // Case 1: node is a block and has an inline continuation. Next sibling is the inline continuation's first child.
1380 nextSibling = firstChildConsideringContinuation(inlineContinuation); 1381 nextSibling = firstChildConsideringContinuation(inlineContinuation);
1381 } else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(m_rend erer)) { 1382 } else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(m_rend erer)) {
1382 // Case 2: Anonymous block parent of the start of a continuation - skip all the way to 1383 // Case 2: Anonymous block parent of the start of a continuation - skip all the way to
1383 // after the parent of the end, since everything in between will be link ed up via the continuation. 1384 // after the parent of the end, since everything in between will be link ed up via the continuation.
1384 RenderObject* lastParent = endOfContinuations(m_renderer->lastChild())-> parent(); 1385 RenderObject* lastParent = endOfContinuations(toRenderBlock(m_renderer)- >lastChild())->parent();
1385 while (lastChildHasContinuation(lastParent)) 1386 while (lastChildHasContinuation(lastParent))
1386 lastParent = endOfContinuations(lastParent->lastChild())->parent(); 1387 lastParent = endOfContinuations(lastParent->slowLastChild())->parent ();
1387 nextSibling = lastParent->nextSibling(); 1388 nextSibling = lastParent->nextSibling();
1388 } else if (RenderObject* ns = m_renderer->nextSibling()) { 1389 } else if (RenderObject* ns = m_renderer->nextSibling()) {
1389 // Case 3: node has an actual next sibling 1390 // Case 3: node has an actual next sibling
1390 nextSibling = ns; 1391 nextSibling = ns;
1391 } else if (isInlineWithContinuation(m_renderer)) { 1392 } else if (isInlineWithContinuation(m_renderer)) {
1392 // Case 4: node is an inline with a continuation. Next sibling is the ne xt sibling of the end 1393 // Case 4: node is an inline with a continuation. Next sibling is the ne xt sibling of the end
1393 // of the continuation chain. 1394 // of the continuation chain.
1394 nextSibling = endOfContinuations(m_renderer)->nextSibling(); 1395 nextSibling = endOfContinuations(m_renderer)->nextSibling();
1395 } else if (isInlineWithContinuation(m_renderer->parent())) { 1396 } else if (isInlineWithContinuation(m_renderer->parent())) {
1396 // Case 5: node has no next sibling, and its parent is an inline with a continuation. 1397 // Case 5: node has no next sibling, and its parent is an inline with a continuation.
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 RenderObject* startOfConts = 0; 1955 RenderObject* startOfConts = 0;
1955 RenderObject* firstChild = 0; 1956 RenderObject* firstChild = 0;
1956 if (m_renderer->isRenderBlock() && (startOfConts = startOfContinuations(m_re nderer))) { 1957 if (m_renderer->isRenderBlock() && (startOfConts = startOfContinuations(m_re nderer))) {
1957 // Case 1: node is a block and is an inline's continuation. Parent 1958 // Case 1: node is a block and is an inline's continuation. Parent
1958 // is the start of the continuation chain. 1959 // is the start of the continuation chain.
1959 parent = startOfConts; 1960 parent = startOfConts;
1960 } else if (parent && parent->isRenderInline() && (startOfConts = startOfCont inuations(parent))) { 1961 } else if (parent && parent->isRenderInline() && (startOfConts = startOfCont inuations(parent))) {
1961 // Case 2: node's parent is an inline which is some node's continuation; parent is 1962 // Case 2: node's parent is an inline which is some node's continuation; parent is
1962 // the earliest node in the continuation chain. 1963 // the earliest node in the continuation chain.
1963 parent = startOfConts; 1964 parent = startOfConts;
1964 } else if (parent && (firstChild = parent->firstChild()) && firstChild->node ()) { 1965 } else if (parent && (firstChild = parent->slowFirstChild()) && firstChild-> node()) {
1965 // Case 3: The first sibling is the beginning of a continuation chain. F ind the origin of that continuation. 1966 // Case 3: The first sibling is the beginning of a continuation chain. F ind the origin of that continuation.
1966 // Get the node's renderer and follow that continuation chain until the first child is found. 1967 // Get the node's renderer and follow that continuation chain until the first child is found.
1967 RenderObject* nodeRenderFirstChild = firstChild->node()->renderer(); 1968 RenderObject* nodeRenderFirstChild = firstChild->node()->renderer();
1968 while (nodeRenderFirstChild != firstChild) { 1969 while (nodeRenderFirstChild != firstChild) {
1969 for (RenderObject* contsTest = nodeRenderFirstChild; contsTest; cont sTest = nextContinuation(contsTest)) { 1970 for (RenderObject* contsTest = nodeRenderFirstChild; contsTest; cont sTest = nextContinuation(contsTest)) {
1970 if (contsTest == firstChild) { 1971 if (contsTest == firstChild) {
1971 parent = nodeRenderFirstChild->parent(); 1972 parent = nodeRenderFirstChild->parent();
1972 break; 1973 break;
1973 } 1974 }
1974 } 1975 }
1975 if (firstChild == parent->firstChild()) 1976 RenderObject* newFirstChild = parent->slowFirstChild();
1977 if (firstChild == newFirstChild)
1976 break; 1978 break;
1977 firstChild = parent->firstChild(); 1979 firstChild = newFirstChild;
1978 if (!firstChild->node()) 1980 if (!firstChild->node())
1979 break; 1981 break;
1980 nodeRenderFirstChild = firstChild->node()->renderer(); 1982 nodeRenderFirstChild = firstChild->node()->renderer();
1981 } 1983 }
1982 } 1984 }
1983 1985
1984 return parent; 1986 return parent;
1985 } 1987 }
1986 1988
1987 bool AXRenderObject::isDescendantOfElementType(const QualifiedName& tagName) con st 1989 bool AXRenderObject::isDescendantOfElementType(const QualifiedName& tagName) con st
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 if (label && label->renderer()) { 2309 if (label && label->renderer()) {
2308 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2310 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2309 result.unite(labelRect); 2311 result.unite(labelRect);
2310 } 2312 }
2311 } 2313 }
2312 2314
2313 return result; 2315 return result;
2314 } 2316 }
2315 2317
2316 } // namespace WebCore 2318 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/ContainerNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698