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

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: improved test 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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // m_fetcher. 543 // m_fetcher.
511 m_styleEngine = StyleEngine::create(*this); 544 m_styleEngine = StyleEngine::create(*this);
512 } 545 }
513 546
514 Document::~Document() 547 Document::~Document()
515 { 548 {
516 ASSERT(!renderView()); 549 ASSERT(!renderView());
517 ASSERT(m_ranges.isEmpty()); 550 ASSERT(m_ranges.isEmpty());
518 ASSERT(!parentTreeScope()); 551 ASSERT(!parentTreeScope());
519 ASSERT(!hasGuardRefCount()); 552 ASSERT(!hasGuardRefCount());
553 ASSERT(m_visibilityObservers.isEmpty());
520 554
521 if (m_templateDocument) 555 if (m_templateDocument)
522 m_templateDocument->setTemplateDocumentHost(0); // balanced in templateD ocument(). 556 m_templateDocument->setTemplateDocumentHost(0); // balanced in templateD ocument().
523 557
524 if (Document* ownerDocument = this->ownerDocument()) 558 if (Document* ownerDocument = this->ownerDocument())
525 ownerDocument->didRemoveEventTargetNode(this); 559 ownerDocument->didRemoveEventTargetNode(this);
526 560
527 m_scriptRunner.clear(); 561 m_scriptRunner.clear();
528 562
529 removeAllEventListeners(); 563 removeAllEventListeners();
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 String Document::visibilityState() const 1433 String Document::visibilityState() const
1400 { 1434 {
1401 return pageVisibilityStateString(pageVisibilityState()); 1435 return pageVisibilityStateString(pageVisibilityState());
1402 } 1436 }
1403 1437
1404 bool Document::hidden() const 1438 bool Document::hidden() const
1405 { 1439 {
1406 return pageVisibilityState() != PageVisibilityStateVisible; 1440 return pageVisibilityState() != PageVisibilityStateVisible;
1407 } 1441 }
1408 1442
1409 void Document::dispatchVisibilityStateChangeEvent() 1443 void Document::didChangeVisibilityState()
1410 { 1444 {
1411 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); 1445 dispatchEvent(Event::create(EventTypeNames::visibilitychange));
1412 // Also send out the deprecated version until it can be removed. 1446 // Also send out the deprecated version until it can be removed.
1413 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange)); 1447 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange));
1448
1449 PageVisibilityState state = pageVisibilityState();
1450 HashSet<DocumentVisibilityObserver*>::const_iterator observerEnd = m_visibil ityObservers.end();
1451 for (HashSet<DocumentVisibilityObserver*>::const_iterator it = m_visibilityO bservers.begin(); it != observerEnd; ++it)
1452 (*it)->didChangeVisibilityState(state);
1453 }
1454
1455 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer)
1456 {
1457 ASSERT(!m_visibilityObservers.contains(observer));
1458 m_visibilityObservers.add(observer);
1459 }
1460
1461 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer )
1462 {
1463 ASSERT(m_visibilityObservers.contains(observer));
1464 m_visibilityObservers.remove(observer);
1414 } 1465 }
1415 1466
1416 String Document::nodeName() const 1467 String Document::nodeName() const
1417 { 1468 {
1418 return "#document"; 1469 return "#document";
1419 } 1470 }
1420 1471
1421 Node::NodeType Document::nodeType() const 1472 Node::NodeType Document::nodeType() const
1422 { 1473 {
1423 return DOCUMENT_NODE; 1474 return DOCUMENT_NODE;
(...skipping 3940 matching lines...) Expand 10 before | Expand all | Expand 10 after
5364 if (!page->focusController().isActive() || !page->focusController().isFocuse d()) 5415 if (!page->focusController().isActive() || !page->focusController().isFocuse d())
5365 return false; 5416 return false;
5366 if (Frame* focusedFrame = page->focusController().focusedFrame()) { 5417 if (Frame* focusedFrame = page->focusController().focusedFrame()) {
5367 if (focusedFrame->tree().isDescendantOf(frame())) 5418 if (focusedFrame->tree().isDescendantOf(frame()))
5368 return true; 5419 return true;
5369 } 5420 }
5370 return false; 5421 return false;
5371 } 5422 }
5372 5423
5373 } // namespace WebCore 5424 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698