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

Side by Side Diff: Source/core/page/FrameTree.cpp

Issue 1157563004: Revert of Update Blink to use the tree scope info on WebFrame for scoping checks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | « Source/core/frame/LocalFrame.cpp ('k') | Source/web/WebEmbeddedWorkerImpl.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) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * Copyright (C) 2006 Apple Computer, Inc. 3 * Copyright (C) 2006 Apple Computer, Inc.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 name.appendLiteral("/<!--frame"); 166 name.appendLiteral("/<!--frame");
167 name.appendNumber(childCount() - 1); 167 name.appendNumber(childCount() - 1);
168 name.appendLiteral("-->-->"); 168 name.appendLiteral("-->-->");
169 169
170 return name.toAtomicString(); 170 return name.toAtomicString();
171 } 171 }
172 172
173 Frame* FrameTree::scopedChild(unsigned index) const 173 Frame* FrameTree::scopedChild(unsigned index) const
174 { 174 {
175 // TODO(dcheng, alexmos): Currently, all children of a RemoteFrame are
176 // visible, even through a shadow DOM scope. Once RemoteFrames have a
177 // TreeScope, it should be used here.
178 TreeScope* scope = nullptr;
179 if (m_thisFrame->isLocalFrame()) {
180 scope = toLocalFrame(m_thisFrame)->document();
181 if (!scope)
182 return nullptr;
183 }
184
175 unsigned scopedIndex = 0; 185 unsigned scopedIndex = 0;
176 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) { 186 for (Frame* result = firstChild(); result; result = result->tree().nextSibli ng()) {
177 if (child->client()->inShadowTree()) 187 // TODO(dcheng, alexmos): Currently, RemoteFrames are always visible,
188 // even through a shadow DOM scope. Once RemoteFrames have a TreeScope,
189 // the scoping check should apply to RemoteFrames too.
190 if (scope && result->isLocalFrame() && !toLocalFrame(result)->inScope(sc ope))
178 continue; 191 continue;
179 if (scopedIndex == index) 192 if (scopedIndex == index)
180 return child; 193 return result;
181 scopedIndex++; 194 scopedIndex++;
182 } 195 }
183 196
184 return nullptr; 197 return nullptr;
185 } 198 }
186 199
187 Frame* FrameTree::scopedChild(const AtomicString& name) const 200 Frame* FrameTree::scopedChild(const AtomicString& name) const
188 { 201 {
189 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) { 202 // TODO(dcheng, alexmos): Currently, all children of a RemoteFrame are
190 if (child->client()->inShadowTree()) 203 // visible, even through a shadow DOM scope. Once RemoteFrames have a
191 continue; 204 // TreeScope, it should be used here.
192 if (child->tree().name() == name) 205 TreeScope* scope = nullptr;
206 if (m_thisFrame->isLocalFrame()) {
207 scope = toLocalFrame(m_thisFrame)->document();
208 if (!scope)
209 return nullptr;
210 }
211
212 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() )
213 // TODO(dcheng, alexmos): Currently, RemoteFrames are always visible,
214 // even through a shadow DOM scope. Once RemoteFrames have a TreeScope,
215 // the scoping check should apply to RemoteFrames too.
216 if (child->tree().name() == name && (!scope || !child->isLocalFrame() || toLocalFrame(child)->inScope(scope)))
193 return child; 217 return child;
194 }
195 return nullptr; 218 return nullptr;
196 } 219 }
197 220
198 inline unsigned FrameTree::scopedChildCount(TreeScope* scope) const 221 inline unsigned FrameTree::scopedChildCount(TreeScope* scope) const
199 { 222 {
223 // TODO(dcheng, alexmos): Once RemoteFrames have a TreeScope, this should
224 // return 0 if there is no scope.
225
200 unsigned scopedCount = 0; 226 unsigned scopedCount = 0;
201 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) { 227 for (Frame* result = firstChild(); result; result = result->tree().nextSibli ng()) {
202 if (child->client()->inShadowTree()) 228 // FIXME: Currently, RemoteFrames are always visible, even through a sha dow DOM scope.
229 // Once RemoteFrames have a TreeScope, the scoping check should apply to RemoteFrames too.
230 if (scope && result->isLocalFrame() && !toLocalFrame(result)->inScope(sc ope))
203 continue; 231 continue;
204 scopedCount++; 232 scopedCount++;
205 } 233 }
206 234
207 return scopedCount; 235 return scopedCount;
208 } 236 }
209 237
210 unsigned FrameTree::scopedChildCount() const 238 unsigned FrameTree::scopedChildCount() const
211 { 239 {
212 if (m_scopedChildCount == invalidChildCount) { 240 if (m_scopedChildCount == invalidChildCount) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 { 438 {
411 if (!frame) { 439 if (!frame) {
412 printf("Null input frame\n"); 440 printf("Null input frame\n");
413 return; 441 return;
414 } 442 }
415 443
416 printFrames(frame->tree().top(), frame, 0); 444 printFrames(frame->tree().top(), frame, 0);
417 } 445 }
418 446
419 #endif 447 #endif
OLDNEW
« no previous file with comments | « Source/core/frame/LocalFrame.cpp ('k') | Source/web/WebEmbeddedWorkerImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698