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

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: Fixed conflicts 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
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 if (o->needsLayout()) 426 if (o->needsLayout())
420 ++needsLayoutObjects; 427 ++needsLayoutObjects;
421 } 428 }
422 } 429 }
423 430
424 String LocalFrame::layerTreeAsText(LayerTreeFlags flags) const 431 String LocalFrame::layerTreeAsText(LayerTreeFlags flags) const
425 { 432 {
426 TextStream textStream; 433 TextStream textStream;
427 textStream << localLayerTreeAsText(flags); 434 textStream << localLayerTreeAsText(flags);
428 435
429 for (LocalFrame* child = tree().firstChild(); child; child = child->tree().t raverseNext(this)) { 436 for (Frame* child = tree().firstChild(); child; child = child->tree().traver seNext(this)) {
430 String childLayerTree = child->localLayerTreeAsText(flags); 437 if (!child->isLocalFrame())
438 continue;
439 String childLayerTree = toLocalFrame(child)->localLayerTreeAsText(flags) ;
431 if (!childLayerTree.length()) 440 if (!childLayerTree.length())
432 continue; 441 continue;
433 442
434 textStream << "\n\n--------\nFrame: '"; 443 textStream << "\n\n--------\nFrame: '";
435 textStream << child->tree().uniqueName(); 444 textStream << child->tree().uniqueName();
436 textStream << "'\n--------\n"; 445 textStream << "'\n--------\n";
437 textStream << childLayerTree; 446 textStream << childLayerTree;
438 } 447 }
439 448
440 return textStream.release(); 449 return textStream.release();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // Update the scroll position when doing a full page zoom, so the co ntent stays in relatively the same position. 499 // Update the scroll position when doing a full page zoom, so the co ntent stays in relatively the same position.
491 LayoutPoint scrollPosition = view->scrollPosition(); 500 LayoutPoint scrollPosition = view->scrollPosition();
492 float percentDifference = (pageZoomFactor / m_pageZoomFactor); 501 float percentDifference = (pageZoomFactor / m_pageZoomFactor);
493 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference)); 502 view->setScrollPosition(IntPoint(scrollPosition.x() * percentDiffere nce, scrollPosition.y() * percentDifference));
494 } 503 }
495 } 504 }
496 505
497 m_pageZoomFactor = pageZoomFactor; 506 m_pageZoomFactor = pageZoomFactor;
498 m_textZoomFactor = textZoomFactor; 507 m_textZoomFactor = textZoomFactor;
499 508
500 for (RefPtr<LocalFrame> child = tree().firstChild(); child; child = child->t ree().nextSibling()) 509 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) {
501 child->setPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor); 510 if (child->isLocalFrame())
511 toLocalFrame(child.get())->setPageAndTextZoomFactors(m_pageZoomFacto r, m_textZoomFactor);
512 }
502 513
503 document->setNeedsStyleRecalc(SubtreeStyleChange); 514 document->setNeedsStyleRecalc(SubtreeStyleChange);
504 document->updateLayoutIgnorePendingStylesheets(); 515 document->updateLayoutIgnorePendingStylesheets();
505 } 516 }
506 517
507 void LocalFrame::deviceOrPageScaleFactorChanged() 518 void LocalFrame::deviceOrPageScaleFactorChanged()
508 { 519 {
509 document()->mediaQueryAffectingValueChanged(); 520 document()->mediaQueryAffectingValueChanged();
510 for (RefPtr<LocalFrame> child = tree().firstChild(); child; child = child->t ree().nextSibling()) 521 for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree() .nextSibling()) {
511 child->deviceOrPageScaleFactorChanged(); 522 if (child->isLocalFrame())
523 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged();
524 }
512 } 525 }
513 526
514 void LocalFrame::notifyChromeClientWheelEventHandlerCountChanged() const 527 void LocalFrame::notifyChromeClientWheelEventHandlerCountChanged() const
515 { 528 {
516 // FIXME: No-one is using this information, so remove this code. 529 // FIXME: No-one is using this information, so remove this code.
517 // Ensure that this method is being called on the main frame of the page. 530 // Ensure that this method is being called on the main frame of the page.
518 ASSERT(isMainFrame()); 531 ASSERT(isMainFrame());
519 532
520 EventHandlerRegistry& registry = m_host->eventHandlerRegistry(); 533 EventHandlerRegistry& registry = m_host->eventHandlerRegistry();
521 unsigned count = 0; 534 unsigned count = 0;
522 if (const EventTargetSet* targets = registry.eventHandlerTargets(EventHandle rRegistry::WheelEvent)) { 535 if (const EventTargetSet* targets = registry.eventHandlerTargets(EventHandle rRegistry::WheelEvent)) {
523 for (EventTargetSet::const_iterator iter = targets->begin(); iter != tar gets->end(); ++iter) 536 for (EventTargetSet::const_iterator iter = targets->begin(); iter != tar gets->end(); ++iter)
524 count += iter->value; 537 count += iter->value;
525 } 538 }
526 539
527 m_host->chrome().client().numWheelEventHandlersChanged(count); 540 m_host->chrome().client().numWheelEventHandlersChanged(count);
528 } 541 }
529 542
530 bool LocalFrame::isURLAllowed(const KURL& url) const 543 bool LocalFrame::isURLAllowed(const KURL& url) const
531 { 544 {
532 // We allow one level of self-reference because some sites depend on that, 545 // We allow one level of self-reference because some sites depend on that,
533 // but we don't allow more than one. 546 // but we don't allow more than one.
534 if (page()->subframeCount() >= Page::maxNumberOfFrames) 547 if (page()->subframeCount() >= Page::maxNumberOfFrames)
535 return false; 548 return false;
536 bool foundSelfReference = false; 549 bool foundSelfReference = false;
537 for (const LocalFrame* frame = this; frame; frame = frame->tree().parent()) { 550 for (const Frame* frame = this; frame; frame = frame->tree().parent()) {
538 if (equalIgnoringFragmentIdentifier(frame->document()->url(), url)) { 551 if (!frame->isLocalFrame())
552 continue;
553 if (equalIgnoringFragmentIdentifier(toLocalFrame(frame)->document()->url (), url)) {
539 if (foundSelfReference) 554 if (foundSelfReference)
540 return false; 555 return false;
541 foundSelfReference = true; 556 foundSelfReference = true;
542 } 557 }
543 } 558 }
544 return true; 559 return true;
545 } 560 }
546 561
547 struct ScopedFramePaintingState { 562 struct ScopedFramePaintingState {
548 ScopedFramePaintingState(LocalFrame* frame, Node* node) 563 ScopedFramePaintingState(LocalFrame* frame, Node* node)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 if (Document* doc = document()) 667 if (Document* doc = document())
653 doc->topDocument().clearAXObjectCache(); 668 doc->topDocument().clearAXObjectCache();
654 } 669 }
655 Frame::disconnectOwnerElement(); 670 Frame::disconnectOwnerElement();
656 } 671 }
657 672
658 LocalFrame* LocalFrame::localFrameRoot() 673 LocalFrame* LocalFrame::localFrameRoot()
659 { 674 {
660 LocalFrame* curFrame = this; 675 LocalFrame* curFrame = this;
661 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame()) 676 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame())
662 curFrame = curFrame->tree().parent(); 677 curFrame = toLocalFrame(curFrame->tree().parent());
663 678
664 return curFrame; 679 return curFrame;
665 } 680 }
666 681
667 } // namespace WebCore 682 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698