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

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

Issue 33353003: Have Frame::tree() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 2 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/page/FrameTree.cpp ('k') | Source/core/page/PageGroup.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) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R ights Reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R ights Reserved.
3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
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 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 void Page::networkStateChanged(bool online) 66 void Page::networkStateChanged(bool online)
67 { 67 {
68 if (!allPages) 68 if (!allPages)
69 return; 69 return;
70 70
71 Vector<RefPtr<Frame> > frames; 71 Vector<RefPtr<Frame> > frames;
72 72
73 // Get all the frames of all the pages in all the page groups 73 // Get all the frames of all the pages in all the page groups
74 HashSet<Page*>::iterator end = allPages->end(); 74 HashSet<Page*>::iterator end = allPages->end();
75 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) { 75 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) {
76 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr averseNext()) 76 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree().tra verseNext())
77 frames.append(frame); 77 frames.append(frame);
78 InspectorInstrumentation::networkStateChanged(*it, online); 78 InspectorInstrumentation::networkStateChanged(*it, online);
79 } 79 }
80 80
81 AtomicString eventName = online ? EventTypeNames::online : EventTypeNames::o ffline; 81 AtomicString eventName = online ? EventTypeNames::online : EventTypeNames::o ffline;
82 for (unsigned i = 0; i < frames.size(); i++) 82 for (unsigned i = 0; i < frames.size(); i++)
83 frames[i]->document()->dispatchWindowEvent(Event::create(eventName)); 83 frames[i]->document()->dispatchWindowEvent(Event::create(eventName));
84 } 84 }
85 85
86 float deviceScaleFactor(Frame* frame) 86 float deviceScaleFactor(Frame* frame)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 pageCounter.increment(); 135 pageCounter.increment();
136 #endif 136 #endif
137 } 137 }
138 138
139 Page::~Page() 139 Page::~Page()
140 { 140 {
141 m_mainFrame->setView(0); 141 m_mainFrame->setView(0);
142 clearPageGroup(); 142 clearPageGroup();
143 allPages->remove(this); 143 allPages->remove(this);
144 144
145 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext( )) { 145 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) {
146 frame->willDetachPage(); 146 frame->willDetachPage();
147 frame->detachFromPage(); 147 frame->detachFromPage();
148 } 148 }
149 149
150 m_inspectorController->inspectedPageDestroyed(); 150 m_inspectorController->inspectedPageDestroyed();
151 151
152 if (m_scrollingCoordinator) 152 if (m_scrollingCoordinator)
153 m_scrollingCoordinator->pageDestroyed(); 153 m_scrollingCoordinator->pageDestroyed();
154 154
155 #ifndef NDEBUG 155 #ifndef NDEBUG
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 m_group->addPage(this); 313 m_group->addPage(this);
314 } 314 }
315 315
316 void Page::scheduleForcedStyleRecalcForAllPages() 316 void Page::scheduleForcedStyleRecalcForAllPages()
317 { 317 {
318 if (!allPages) 318 if (!allPages)
319 return; 319 return;
320 HashSet<Page*>::iterator end = allPages->end(); 320 HashSet<Page*>::iterator end = allPages->end();
321 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) 321 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it)
322 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr averseNext()) 322 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree().tra verseNext())
323 frame->document()->setNeedsStyleRecalc(); 323 frame->document()->setNeedsStyleRecalc();
324 } 324 }
325 325
326 void Page::setNeedsRecalcStyleInAllFrames() 326 void Page::setNeedsRecalcStyleInAllFrames()
327 { 327 {
328 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext( )) 328 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() )
329 frame->document()->styleResolverChanged(RecalcStyleDeferred); 329 frame->document()->styleResolverChanged(RecalcStyleDeferred);
330 } 330 }
331 331
332 void Page::refreshPlugins(bool reload) 332 void Page::refreshPlugins(bool reload)
333 { 333 {
334 if (!allPages) 334 if (!allPages)
335 return; 335 return;
336 336
337 PluginData::refresh(); 337 PluginData::refresh();
338 338
339 Vector<RefPtr<Frame> > framesNeedingReload; 339 Vector<RefPtr<Frame> > framesNeedingReload;
340 340
341 HashSet<Page*>::iterator end = allPages->end(); 341 HashSet<Page*>::iterator end = allPages->end();
342 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) { 342 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) {
343 Page* page = *it; 343 Page* page = *it;
344 344
345 // Clear out the page's plug-in data. 345 // Clear out the page's plug-in data.
346 if (page->m_pluginData) 346 if (page->m_pluginData)
347 page->m_pluginData = 0; 347 page->m_pluginData = 0;
348 348
349 if (!reload) 349 if (!reload)
350 continue; 350 continue;
351 351
352 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr averseNext()) { 352 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree().tra verseNext()) {
353 if (frame->loader()->containsPlugins()) 353 if (frame->loader()->containsPlugins())
354 framesNeedingReload.append(frame); 354 framesNeedingReload.append(frame);
355 } 355 }
356 } 356 }
357 357
358 for (size_t i = 0; i < framesNeedingReload.size(); ++i) 358 for (size_t i = 0; i < framesNeedingReload.size(); ++i)
359 framesNeedingReload[i]->loader()->reload(); 359 framesNeedingReload[i]->loader()->reload();
360 } 360 }
361 361
362 PluginData* Page::pluginData() const 362 PluginData* Page::pluginData() const
363 { 363 {
364 if (!mainFrame()->loader()->allowPlugins(NotAboutToInstantiatePlugin)) 364 if (!mainFrame()->loader()->allowPlugins(NotAboutToInstantiatePlugin))
365 return 0; 365 return 0;
366 if (!m_pluginData) 366 if (!m_pluginData)
367 m_pluginData = PluginData::create(this); 367 m_pluginData = PluginData::create(this);
368 return m_pluginData.get(); 368 return m_pluginData.get();
369 } 369 }
370 370
371 static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag) 371 static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag)
372 { 372 {
373 return forward 373 return forward
374 ? curr->tree()->traverseNextWithWrap(wrapFlag) 374 ? curr->tree().traverseNextWithWrap(wrapFlag)
375 : curr->tree()->traversePreviousWithWrap(wrapFlag); 375 : curr->tree().traversePreviousWithWrap(wrapFlag);
376 } 376 }
377 377
378 void Page::unmarkAllTextMatches() 378 void Page::unmarkAllTextMatches()
379 { 379 {
380 if (!mainFrame()) 380 if (!mainFrame())
381 return; 381 return;
382 382
383 Frame* frame = mainFrame(); 383 Frame* frame = mainFrame();
384 do { 384 do {
385 frame->document()->markers()->removeMarkers(DocumentMarker::TextMatch); 385 frame->document()->markers()->removeMarkers(DocumentMarker::TextMatch);
386 frame = incrementFrame(frame, true, false); 386 frame = incrementFrame(frame, true, false);
387 } while (frame); 387 } while (frame);
388 } 388 }
389 389
390 void Page::setDefersLoading(bool defers) 390 void Page::setDefersLoading(bool defers)
391 { 391 {
392 if (defers == m_defersLoading) 392 if (defers == m_defersLoading)
393 return; 393 return;
394 394
395 m_defersLoading = defers; 395 m_defersLoading = defers;
396 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext( )) 396 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() )
397 frame->loader()->setDefersLoading(defers); 397 frame->loader()->setDefersLoading(defers);
398 } 398 }
399 399
400 void Page::setPageScaleFactor(float scale, const IntPoint& origin) 400 void Page::setPageScaleFactor(float scale, const IntPoint& origin)
401 { 401 {
402 FrameView* view = mainFrame()->view(); 402 FrameView* view = mainFrame()->view();
403 403
404 if (scale != m_pageScaleFactor) { 404 if (scale != m_pageScaleFactor) {
405 m_pageScaleFactor = scale; 405 m_pageScaleFactor = scale;
406 406
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // Data URLs with base64-encoded UTF-8 style sheets are common. We can proce ss them 454 // Data URLs with base64-encoded UTF-8 style sheets are common. We can proce ss them
455 // synchronously and avoid using a loader. 455 // synchronously and avoid using a loader.
456 if (url.protocolIsData() && url.string().startsWith("data:text/css;charset=u tf-8;base64,")) { 456 if (url.protocolIsData() && url.string().startsWith("data:text/css;charset=u tf-8;base64,")) {
457 m_didLoadUserStyleSheet = true; 457 m_didLoadUserStyleSheet = true;
458 458
459 Vector<char> styleSheetAsUTF8; 459 Vector<char> styleSheetAsUTF8;
460 if (base64Decode(decodeURLEscapeSequences(url.string().substring(35)), s tyleSheetAsUTF8, Base64IgnoreWhitespace)) 460 if (base64Decode(decodeURLEscapeSequences(url.string().substring(35)), s tyleSheetAsUTF8, Base64IgnoreWhitespace))
461 m_userStyleSheet = String::fromUTF8(styleSheetAsUTF8.data(), styleSh eetAsUTF8.size()); 461 m_userStyleSheet = String::fromUTF8(styleSheetAsUTF8.data(), styleSh eetAsUTF8.size());
462 } 462 }
463 463
464 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext( )) { 464 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) {
465 if (frame->document()) 465 if (frame->document())
466 frame->document()->styleEngine()->updatePageUserSheet(); 466 frame->document()->styleEngine()->updatePageUserSheet();
467 } 467 }
468 } 468 }
469 469
470 const String& Page::userStyleSheet() const 470 const String& Page::userStyleSheet() const
471 { 471 {
472 return m_userStyleSheet; 472 return m_userStyleSheet;
473 } 473 }
474 474
475 void Page::allVisitedStateChanged(PageGroup* group) 475 void Page::allVisitedStateChanged(PageGroup* group)
476 { 476 {
477 ASSERT(group); 477 ASSERT(group);
478 if (!allPages) 478 if (!allPages)
479 return; 479 return;
480 480
481 HashSet<Page*>::iterator pagesEnd = allPages->end(); 481 HashSet<Page*>::iterator pagesEnd = allPages->end();
482 for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) { 482 for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
483 Page* page = *it; 483 Page* page = *it;
484 if (page->m_group != group) 484 if (page->m_group != group)
485 continue; 485 continue;
486 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree( )->traverseNext()) 486 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree( ).traverseNext())
487 frame->document()->visitedLinkState()->invalidateStyleForAllLinks(); 487 frame->document()->visitedLinkState()->invalidateStyleForAllLinks();
488 } 488 }
489 } 489 }
490 490
491 void Page::visitedStateChanged(PageGroup* group, LinkHash linkHash) 491 void Page::visitedStateChanged(PageGroup* group, LinkHash linkHash)
492 { 492 {
493 ASSERT(group); 493 ASSERT(group);
494 if (!allPages) 494 if (!allPages)
495 return; 495 return;
496 496
497 HashSet<Page*>::iterator pagesEnd = allPages->end(); 497 HashSet<Page*>::iterator pagesEnd = allPages->end();
498 for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) { 498 for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
499 Page* page = *it; 499 Page* page = *it;
500 if (page->m_group != group) 500 if (page->m_group != group)
501 continue; 501 continue;
502 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree( )->traverseNext()) 502 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree( ).traverseNext())
503 frame->document()->visitedLinkState()->invalidateStyleForLink(linkHa sh); 503 frame->document()->visitedLinkState()->invalidateStyleForLink(linkHa sh);
504 } 504 }
505 } 505 }
506 506
507 StorageNamespace* Page::sessionStorage(bool optionalCreate) 507 StorageNamespace* Page::sessionStorage(bool optionalCreate)
508 { 508 {
509 if (!m_sessionStorage && optionalCreate) 509 if (!m_sessionStorage && optionalCreate)
510 m_sessionStorage = StorageNamespace::sessionStorageNamespace(this); 510 m_sessionStorage = StorageNamespace::sessionStorageNamespace(this);
511 return m_sessionStorage.get(); 511 return m_sessionStorage.get();
512 } 512 }
513 513
514 void Page::setTimerAlignmentInterval(double interval) 514 void Page::setTimerAlignmentInterval(double interval)
515 { 515 {
516 if (interval == m_timerAlignmentInterval) 516 if (interval == m_timerAlignmentInterval)
517 return; 517 return;
518 518
519 m_timerAlignmentInterval = interval; 519 m_timerAlignmentInterval = interval;
520 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNextW ithWrap(false)) { 520 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNextWi thWrap(false)) {
521 if (frame->document()) 521 if (frame->document())
522 frame->document()->didChangeTimerAlignmentInterval(); 522 frame->document()->didChangeTimerAlignmentInterval();
523 } 523 }
524 } 524 }
525 525
526 double Page::timerAlignmentInterval() const 526 double Page::timerAlignmentInterval() const
527 { 527 {
528 return m_timerAlignmentInterval; 528 return m_timerAlignmentInterval;
529 } 529 }
530 530
531 void Page::dnsPrefetchingStateChanged() 531 void Page::dnsPrefetchingStateChanged()
532 { 532 {
533 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext( )) 533 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() )
534 frame->document()->initDNSPrefetch(); 534 frame->document()->initDNSPrefetch();
535 } 535 }
536 536
537 #if !ASSERT_DISABLED 537 #if !ASSERT_DISABLED
538 void Page::checkSubframeCountConsistency() const 538 void Page::checkSubframeCountConsistency() const
539 { 539 {
540 ASSERT(m_subframeCount >= 0); 540 ASSERT(m_subframeCount >= 0);
541 541
542 int subframeCount = 0; 542 int subframeCount = 0;
543 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext( )) 543 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() )
544 ++subframeCount; 544 ++subframeCount;
545 545
546 ASSERT(m_subframeCount + 1 == subframeCount); 546 ASSERT(m_subframeCount + 1 == subframeCount);
547 } 547 }
548 #endif 548 #endif
549 549
550 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia lState) 550 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia lState)
551 { 551 {
552 if (m_visibilityState == visibilityState) 552 if (m_visibilityState == visibilityState)
553 return; 553 return;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 , inspectorClient(0) 612 , inspectorClient(0)
613 , backForwardClient(0) 613 , backForwardClient(0)
614 { 614 {
615 } 615 }
616 616
617 Page::PageClients::~PageClients() 617 Page::PageClients::~PageClients()
618 { 618 {
619 } 619 }
620 620
621 } // namespace WebCore 621 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/FrameTree.cpp ('k') | Source/core/page/PageGroup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698