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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 117703004: Free temporary GPU and memory resources held by inactive or hidden 2D canvases (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: typo Created 6 years, 11 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/dom/Document.h ('k') | Source/core/dom/DocumentTest.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 virtual void performTask(ExecutionContext* context) OVERRIDE 387 virtual void performTask(ExecutionContext* context) OVERRIDE
388 { 388 {
389 Document* document = toDocument(context); 389 Document* document = toDocument(context);
390 if (RefPtr<Element> element = document->autofocusElement()) { 390 if (RefPtr<Element> element = document->autofocusElement()) {
391 document->setAutofocusElement(0); 391 document->setAutofocusElement(0);
392 element->focus(); 392 element->focus();
393 } 393 }
394 } 394 }
395 }; 395 };
396 396
397 DocumentVisibilityObserver::DocumentVisibilityObserver(Document& document)
398 : m_document(0)
399 {
400 registerObserver(document);
401 }
402
403 DocumentVisibilityObserver::~DocumentVisibilityObserver()
404 {
405 unregisterObserver();
406 }
407
408 void DocumentVisibilityObserver::unregisterObserver()
409 {
410 if (m_document) {
411 m_document->unregisterVisibilityObserver(this);
412 m_document = 0;
413 }
414 }
415
416 void DocumentVisibilityObserver::registerObserver(Document& document)
417 {
418 ASSERT(!m_document);
419 m_document = &document;
420 if (m_document)
421 m_document->registerVisibilityObserver(this);
422 }
423
424 void DocumentVisibilityObserver::setObservedDocument(Document& document)
425 {
426 unregisterObserver();
427 registerObserver(document);
428 }
429
397 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses) 430 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses)
398 : ContainerNode(0, CreateDocument) 431 : ContainerNode(0, CreateDocument)
399 , TreeScope(*this) 432 , TreeScope(*this)
400 , m_hasNodesWithPlaceholderStyle(false) 433 , m_hasNodesWithPlaceholderStyle(false)
401 , m_needsNotifyRemoveAllPendingStylesheet(false) 434 , m_needsNotifyRemoveAllPendingStylesheet(false)
402 , m_evaluateMediaQueriesOnStyleRecalc(false) 435 , m_evaluateMediaQueriesOnStyleRecalc(false)
403 , m_pendingSheetLayout(NoLayoutWithPendingSheets) 436 , m_pendingSheetLayout(NoLayoutWithPendingSheets)
404 , m_frame(initializer.frame()) 437 , m_frame(initializer.frame())
405 , m_domWindow(m_frame ? m_frame->domWindow() : 0) 438 , m_domWindow(m_frame ? m_frame->domWindow() : 0)
406 , m_import(initializer.import()) 439 , m_import(initializer.import())
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 // m_fetcher. 542 // m_fetcher.
510 m_styleEngine = StyleEngine::create(*this); 543 m_styleEngine = StyleEngine::create(*this);
511 } 544 }
512 545
513 Document::~Document() 546 Document::~Document()
514 { 547 {
515 ASSERT(!renderView()); 548 ASSERT(!renderView());
516 ASSERT(m_ranges.isEmpty()); 549 ASSERT(m_ranges.isEmpty());
517 ASSERT(!parentTreeScope()); 550 ASSERT(!parentTreeScope());
518 ASSERT(!hasGuardRefCount()); 551 ASSERT(!hasGuardRefCount());
552 ASSERT(m_visibilityObservers.isEmpty());
519 553
520 if (m_templateDocument) 554 if (m_templateDocument)
521 m_templateDocument->setTemplateDocumentHost(0); // balanced in templateD ocument(). 555 m_templateDocument->setTemplateDocumentHost(0); // balanced in templateD ocument().
522 556
523 if (Document* ownerDocument = this->ownerDocument()) 557 if (Document* ownerDocument = this->ownerDocument())
524 ownerDocument->didRemoveEventTargetNode(this); 558 ownerDocument->didRemoveEventTargetNode(this);
525 559
526 m_scriptRunner.clear(); 560 m_scriptRunner.clear();
527 561
528 removeAllEventListeners(); 562 removeAllEventListeners();
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 String Document::visibilityState() const 1432 String Document::visibilityState() const
1399 { 1433 {
1400 return pageVisibilityStateString(pageVisibilityState()); 1434 return pageVisibilityStateString(pageVisibilityState());
1401 } 1435 }
1402 1436
1403 bool Document::hidden() const 1437 bool Document::hidden() const
1404 { 1438 {
1405 return pageVisibilityState() != PageVisibilityStateVisible; 1439 return pageVisibilityState() != PageVisibilityStateVisible;
1406 } 1440 }
1407 1441
1408 void Document::dispatchVisibilityStateChangeEvent() 1442 void Document::didChangeVisibilityState()
1409 { 1443 {
1410 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); 1444 dispatchEvent(Event::create(EventTypeNames::visibilitychange));
1411 // Also send out the deprecated version until it can be removed. 1445 // Also send out the deprecated version until it can be removed.
1412 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange)); 1446 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange));
1447
1448 PageVisibilityState state = pageVisibilityState();
1449 HashSet<DocumentVisibilityObserver*>::const_iterator observerEnd = m_visibil ityObservers.end();
1450 for (HashSet<DocumentVisibilityObserver*>::const_iterator it = m_visibilityO bservers.begin(); it != observerEnd; ++it)
1451 (*it)->didChangeVisibilityState(state);
1452 }
1453
1454 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer)
1455 {
1456 ASSERT(!m_visibilityObservers.contains(observer));
1457 m_visibilityObservers.add(observer);
1458 }
1459
1460 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer )
1461 {
1462 ASSERT(m_visibilityObservers.contains(observer));
1463 m_visibilityObservers.remove(observer);
1413 } 1464 }
1414 1465
1415 String Document::nodeName() const 1466 String Document::nodeName() const
1416 { 1467 {
1417 return "#document"; 1468 return "#document";
1418 } 1469 }
1419 1470
1420 Node::NodeType Document::nodeType() const 1471 Node::NodeType Document::nodeType() const
1421 { 1472 {
1422 return DOCUMENT_NODE; 1473 return DOCUMENT_NODE;
(...skipping 3896 matching lines...) Expand 10 before | Expand all | Expand 10 after
5319 if (!page->focusController().isActive() || !page->focusController().isFocuse d()) 5370 if (!page->focusController().isActive() || !page->focusController().isFocuse d())
5320 return false; 5371 return false;
5321 if (Frame* focusedFrame = page->focusController().focusedFrame()) { 5372 if (Frame* focusedFrame = page->focusController().focusedFrame()) {
5322 if (focusedFrame->tree().isDescendantOf(frame())) 5373 if (focusedFrame->tree().isDescendantOf(frame()))
5323 return true; 5374 return true;
5324 } 5375 }
5325 return false; 5376 return false;
5326 } 5377 }
5327 5378
5328 } // namespace WebCore 5379 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698