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

Side by Side Diff: Source/core/frame/LocalFrame.cpp

Issue 317493002: Change FrameTree to return Frames instead of LocalFrames. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: dcheng's comment addressed Created 6 years, 6 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
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/loader/DocumentLoader.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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "wtf/StdLibExtras.h" 67 #include "wtf/StdLibExtras.h"
68 68
69 using namespace std; 69 using namespace std;
70 70
71 namespace WebCore { 71 namespace WebCore {
72 72
73 using namespace HTMLNames; 73 using namespace HTMLNames;
74 74
75 static inline float parentPageZoomFactor(LocalFrame* frame) 75 static inline float parentPageZoomFactor(LocalFrame* frame)
76 { 76 {
77 LocalFrame* parent = frame->tree().parent(); 77 Frame* parent = frame->tree().parent();
78 if (!parent) 78 if (!parent || !parent->isLocalFrame())
79 return 1; 79 return 1;
80 return parent->pageZoomFactor(); 80 return toLocalFrame(parent)->pageZoomFactor();
81 } 81 }
82 82
83 static inline float parentTextZoomFactor(LocalFrame* frame) 83 static inline float parentTextZoomFactor(LocalFrame* frame)
84 { 84 {
85 LocalFrame* parent = frame->tree().parent(); 85 Frame* parent = frame->tree().parent();
86 if (!parent) 86 if (!parent || !parent->isLocalFrame())
87 return 1; 87 return 1;
88 return parent->textZoomFactor(); 88 return toLocalFrame(parent)->textZoomFactor();
89 } 89 }
90 90
91 inline LocalFrame::LocalFrame(FrameLoaderClient* client, FrameHost* host, FrameO wner* owner) 91 inline LocalFrame::LocalFrame(FrameLoaderClient* client, FrameHost* host, FrameO wner* owner)
92 : Frame(client, host, owner) 92 : Frame(client, host, owner)
93 , m_loader(this) 93 , m_loader(this)
94 , m_navigationScheduler(this) 94 , m_navigationScheduler(this)
95 , m_script(adoptPtr(new ScriptController(this))) 95 , m_script(adoptPtr(new ScriptController(this)))
96 , m_editor(Editor::create(*this)) 96 , m_editor(Editor::create(*this))
97 , m_spellChecker(SpellChecker::create(*this)) 97 , m_spellChecker(SpellChecker::create(*this))
98 , m_selection(FrameSelection::create(this)) 98 , m_selection(FrameSelection::create(this))
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (page()->visibilityState() != PageVisibilityStateVisible) 171 if (page()->visibilityState() != PageVisibilityStateVisible)
172 return; 172 return;
173 173
174 DOMWindow* window = domWindow(); 174 DOMWindow* window = domWindow();
175 if (!window) 175 if (!window)
176 return; 176 return;
177 window->dispatchEvent(Event::create(EventTypeNames::orientationchange)); 177 window->dispatchEvent(Event::create(EventTypeNames::orientationchange));
178 178
179 // Notify subframes. 179 // Notify subframes.
180 Vector<RefPtr<LocalFrame> > childFrames; 180 Vector<RefPtr<LocalFrame> > childFrames;
181 for (LocalFrame* child = tree().firstChild(); child; child = child->tree().n extSibling()) 181 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) {
182 childFrames.append(child); 182 if (child->isLocalFrame())
183 childFrames.append(toLocalFrame(child));
184 }
183 185
184 for (size_t i = 0; i < childFrames.size(); ++i) 186 for (size_t i = 0; i < childFrames.size(); ++i)
185 childFrames[i]->sendOrientationChangeEvent(); 187 childFrames[i]->sendOrientationChangeEvent();
186 } 188 }
187 189
188 void LocalFrame::setPrinting(bool printing, const FloatSize& pageSize, const Flo atSize& originalPageSize, float maximumShrinkRatio) 190 void LocalFrame::setPrinting(bool printing, const FloatSize& pageSize, const Flo atSize& originalPageSize, float maximumShrinkRatio)
189 { 191 {
190 // In setting printing, we should not validate resources already cached for the document. 192 // In setting printing, we should not validate resources already cached for the document.
191 // See https://bugs.webkit.org/show_bug.cgi?id=43704 193 // See https://bugs.webkit.org/show_bug.cgi?id=43704
192 ResourceCacheValidationSuppressor validationSuppressor(document()->fetcher() ); 194 ResourceCacheValidationSuppressor validationSuppressor(document()->fetcher() );
193 195
194 document()->setPrinting(printing); 196 document()->setPrinting(printing);
195 view()->adjustMediaTypeForPrinting(printing); 197 view()->adjustMediaTypeForPrinting(printing);
196 198
197 document()->styleResolverChanged(); 199 document()->styleResolverChanged();
198 if (shouldUsePrintingLayout()) { 200 if (shouldUsePrintingLayout()) {
199 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShri nkRatio); 201 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShri nkRatio);
200 } else { 202 } else {
201 view()->forceLayout(); 203 view()->forceLayout();
202 view()->adjustViewSize(); 204 view()->adjustViewSize();
203 } 205 }
204 206
205 // Subframes of the one we're printing don't lay out to the page size. 207 // Subframes of the one we're printing don't lay out to the page size.
206 for (RefPtr<LocalFrame> child = tree().firstChild(); child; child = child->t ree().nextSibling()) 208 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) {
207 child->setPrinting(printing, FloatSize(), FloatSize(), 0); 209 if (child->isLocalFrame())
210 toLocalFrame(child.get())->setPrinting(printing, FloatSize(), FloatS ize(), 0);
211 }
208 } 212 }
209 213
210 bool LocalFrame::shouldUsePrintingLayout() const 214 bool LocalFrame::shouldUsePrintingLayout() const
211 { 215 {
212 // Only top frame being printed should be fit to page size. 216 // Only top frame being printed should be fit to page size.
213 // Subframes should be constrained by parents only. 217 // Subframes should be constrained by parents only.
214 return document()->printing() && (!tree().parent() || !tree().parent()->docu ment()->printing()); 218 return document()->printing() && (!tree().parent() || !tree().parent()->isLo calFrame() || !toLocalFrame(tree().parent())->document()->printing());
215 } 219 }
216 220
217 FloatSize LocalFrame::resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize) 221 FloatSize LocalFrame::resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize)
218 { 222 {
219 FloatSize resultSize; 223 FloatSize resultSize;
220 if (!contentRenderer()) 224 if (!contentRenderer())
221 return FloatSize(); 225 return FloatSize();
222 226
223 if (contentRenderer()->style()->isHorizontalWritingMode()) { 227 if (contentRenderer()->style()->isHorizontalWritingMode()) {
224 ASSERT(fabs(originalSize.width()) > numeric_limits<float>::epsilon()); 228 ASSERT(fabs(originalSize.width()) > numeric_limits<float>::epsilon());
(...skipping 16 matching lines...) Expand all
241 script().clearWindowShell(); 245 script().clearWindowShell();
242 Frame::setDOMWindow(domWindow); 246 Frame::setDOMWindow(domWindow);
243 } 247 }
244 248
245 void LocalFrame::didChangeVisibilityState() 249 void LocalFrame::didChangeVisibilityState()
246 { 250 {
247 if (document()) 251 if (document())
248 document()->didChangeVisibilityState(); 252 document()->didChangeVisibilityState();
249 253
250 Vector<RefPtr<LocalFrame> > childFrames; 254 Vector<RefPtr<LocalFrame> > childFrames;
251 for (LocalFrame* child = tree().firstChild(); child; child = child->tree().n extSibling()) 255 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) {
252 childFrames.append(child); 256 if (child->isLocalFrame())
257 childFrames.append(toLocalFrame(child));
258 }
253 259
254 for (size_t i = 0; i < childFrames.size(); ++i) 260 for (size_t i = 0; i < childFrames.size(); ++i)
255 childFrames[i]->didChangeVisibilityState(); 261 childFrames[i]->didChangeVisibilityState();
256 } 262 }
257 263
258 void LocalFrame::willDetachFrameHost() 264 void LocalFrame::willDetachFrameHost()
259 { 265 {
260 // We should never be detatching the page during a Layout. 266 // We should never be detatching the page during a Layout.
261 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout()); 267 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout());
262 268
263 if (LocalFrame* parent = tree().parent()) 269 Frame* parent = tree().parent();
264 parent->loader().checkLoadComplete(); 270 if (parent && parent->isLocalFrame())
271 toLocalFrame(parent)->loader().checkLoadComplete();
265 272
266 Frame::willDetachFrameHost(); 273 Frame::willDetachFrameHost();
267 script().clearScriptObjects(); 274 script().clearScriptObjects();
268 275
269 if (page() && page()->scrollingCoordinator() && m_view) 276 if (page() && page()->scrollingCoordinator() && m_view)
270 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); 277 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get());
271 } 278 }
272 279
273 void LocalFrame::detachFromFrameHost() 280 void LocalFrame::detachFromFrameHost()
274 { 281 {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (o->needsLayout()) 425 if (o->needsLayout())
419 ++needsLayoutObjects; 426 ++needsLayoutObjects;
420 } 427 }
421 } 428 }
422 429
423 String LocalFrame::layerTreeAsText(LayerTreeFlags flags) const 430 String LocalFrame::layerTreeAsText(LayerTreeFlags flags) const
424 { 431 {
425 TextStream textStream; 432 TextStream textStream;
426 textStream << localLayerTreeAsText(flags); 433 textStream << localLayerTreeAsText(flags);
427 434
428 for (LocalFrame* child = tree().firstChild(); child; child = child->tree().t raverseNext(this)) { 435 for (Frame* child = tree().firstChild(); child; child = child->tree().traver seNext(this)) {
429 String childLayerTree = child->localLayerTreeAsText(flags); 436 if (!child->isLocalFrame())
437 continue;
438 String childLayerTree = toLocalFrame(child)->localLayerTreeAsText(flags) ;
430 if (!childLayerTree.length()) 439 if (!childLayerTree.length())
431 continue; 440 continue;
432 441
433 textStream << "\n\n--------\nFrame: '"; 442 textStream << "\n\n--------\nFrame: '";
434 textStream << child->tree().uniqueName(); 443 textStream << child->tree().uniqueName();
435 textStream << "'\n--------\n"; 444 textStream << "'\n--------\n";
436 textStream << childLayerTree; 445 textStream << childLayerTree;
437 } 446 }
438 447
439 return textStream.release(); 448 return textStream.release();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // Update the scroll position when doing a full page zoom, so the co ntent stays in relatively the same position. 498 // Update the scroll position when doing a full page zoom, so the co ntent stays in relatively the same position.
490 LayoutPoint scrollPosition = view->scrollPosition(); 499 LayoutPoint scrollPosition = view->scrollPosition();
491 float percentDifference = (pageZoomFactor / m_pageZoomFactor); 500 float percentDifference = (pageZoomFactor / m_pageZoomFactor);
492 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference)); 501 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference));
493 } 502 }
494 } 503 }
495 504
496 m_pageZoomFactor = pageZoomFactor; 505 m_pageZoomFactor = pageZoomFactor;
497 m_textZoomFactor = textZoomFactor; 506 m_textZoomFactor = textZoomFactor;
498 507
499 for (RefPtr<LocalFrame> child = tree().firstChild(); child; child = child->t ree().nextSibling()) 508 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) {
500 child->setPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor); 509 if (child->isLocalFrame())
510 toLocalFrame(child.get())->setPageAndTextZoomFactors(m_pageZoomFacto r, m_textZoomFactor);
511 }
501 512
502 document->setNeedsStyleRecalc(SubtreeStyleChange); 513 document->setNeedsStyleRecalc(SubtreeStyleChange);
503 document->updateLayoutIgnorePendingStylesheets(); 514 document->updateLayoutIgnorePendingStylesheets();
504 } 515 }
505 516
506 void LocalFrame::deviceOrPageScaleFactorChanged() 517 void LocalFrame::deviceOrPageScaleFactorChanged()
507 { 518 {
508 document()->mediaQueryAffectingValueChanged(); 519 document()->mediaQueryAffectingValueChanged();
509 for (RefPtr<LocalFrame> child = tree().firstChild(); child; child = child->t ree().nextSibling()) 520 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) {
510 child->deviceOrPageScaleFactorChanged(); 521 if (child->isLocalFrame())
522 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged();
523 }
511 } 524 }
512 525
513 bool LocalFrame::isURLAllowed(const KURL& url) const 526 bool LocalFrame::isURLAllowed(const KURL& url) const
514 { 527 {
515 // We allow one level of self-reference because some sites depend on that, 528 // We allow one level of self-reference because some sites depend on that,
516 // but we don't allow more than one. 529 // but we don't allow more than one.
517 if (page()->subframeCount() >= Page::maxNumberOfFrames) 530 if (page()->subframeCount() >= Page::maxNumberOfFrames)
518 return false; 531 return false;
519 bool foundSelfReference = false; 532 bool foundSelfReference = false;
520 for (const LocalFrame* frame = this; frame; frame = frame->tree().parent()) { 533 for (const Frame* frame = this; frame; frame = frame->tree().parent()) {
521 if (equalIgnoringFragmentIdentifier(frame->document()->url(), url)) { 534 if (!frame->isLocalFrame())
535 continue;
536 if (equalIgnoringFragmentIdentifier(toLocalFrame(frame)->document()->url (), url)) {
522 if (foundSelfReference) 537 if (foundSelfReference)
523 return false; 538 return false;
524 foundSelfReference = true; 539 foundSelfReference = true;
525 } 540 }
526 } 541 }
527 return true; 542 return true;
528 } 543 }
529 544
530 struct ScopedFramePaintingState { 545 struct ScopedFramePaintingState {
531 ScopedFramePaintingState(LocalFrame* frame, Node* node) 546 ScopedFramePaintingState(LocalFrame* frame, Node* node)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 if (Document* doc = document()) 650 if (Document* doc = document())
636 doc->topDocument().clearAXObjectCache(); 651 doc->topDocument().clearAXObjectCache();
637 } 652 }
638 Frame::disconnectOwnerElement(); 653 Frame::disconnectOwnerElement();
639 } 654 }
640 655
641 LocalFrame* LocalFrame::localFrameRoot() 656 LocalFrame* LocalFrame::localFrameRoot()
642 { 657 {
643 LocalFrame* curFrame = this; 658 LocalFrame* curFrame = this;
644 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame()) 659 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame())
645 curFrame = curFrame->tree().parent(); 660 curFrame = toLocalFrame(curFrame->tree().parent());
646 661
647 return curFrame; 662 return curFrame;
648 } 663 }
649 664
650 } // namespace WebCore 665 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698