Crash in DumpRenderTree at com.apple.WebCore: WebCore::CaptionUserPreferences::captio...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2013 17:27:20 +0000 (17:27 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2013 17:27:20 +0000 (17:27 +0000)
commit127e6f12da951031c573edd2724743d26db21b74
treec1faadf31281565b5f4a454cd6d56a3e97dddefd
parent98ec5b6b9b66f3347af7c6680d0b9945d34b4a1a
Crash in DumpRenderTree at com.apple.WebCore: WebCore::CaptionUserPreferences::captionPreferencesChanged + 185
https://bugs.webkit.org/show_bug.cgi?id=112051

Reviewed by Eric Carlson.

No new tests; fixes a crash during media/video-controls-captions-trackmenu.html.

Instead of relying on a registration system which can fail when an element's document does not have a page,
Elements will register for captionPreferencesChanged() notifications directly with their owning Document.
CaptionUserPreferences, in turn, will notify all Documents in its PageGroup, rather than only directly
registered listeners.

* dom/Document.cpp:
(WebCore::Document::registerForCaptionPreferencesChangedCallbacks): Added. Notify the CaptionUserPreferences that someone
    is interested in captionPreferencesChanged notfications.
(WebCore::Document::unregisterForCaptionPreferencesChangedCallbacks): Added.
(WebCore::Document::captionPreferencesChanged): Added. Pass to all registered elements.
* dom/Document.h:
* dom/Element.h:
(WebCore::Element::captionPreferencesChanged): Added. Empty; intended
    to be overridden by subclasses.
* history/CachedPage.cpp:
(WebCore::CachedPage::CachedPage): Initialize m_needsCaptionPreferenceChanged member.
(WebCore::CachedPage::restore): Call captionPreferencesChanged() if necessary.
* history/CachedPage.h:
(WebCore::CachedPage::markForCaptionPreferencesChanged): Set the m_needsCaptionPreferenceChanged member.
* history/PageCache.cpp:
(WebCore::PageCache::markPagesForCaptionPreferencesChanged): Pass to every CachedPage.
* history/PageCache.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Register with the Document.
(WebCore::HTMLMediaElement::~HTMLMediaElement): Unregister with same.
(WebCore::HTMLMediaElement::attach): Remove previous registration call.
* html/HTMLMediaElement.h:
* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::captionPreferencesChanged): Pass to the
    PageGroup.
* page/CaptionUserPreferences.h:
(WebCore::CaptionUserPreferences::setInterestedInCaptionPreferenceChanges):
    Empty; intended to be overridden by subclasses.
* page/CaptionUserPreferencesMac.h:
* page/CaptionUserPreferencesMac.mm:
(WebCore::CaptionUserPreferencesMac::setInterestedInCaptionPreferenceChanges):
    Renamed from registerForPreferencesChangedCallbacks().
(WebCore::CaptionUserPreferencesMac::captionPreferencesChanged):
    Replace call to havePreferenceChangeListeners() with m_listeningForPreferenceChanges.
* page/Page.cpp:
(WebCore::Page::captionPreferencesChanged):
    Pass to every contained Document.
* page/Page.h:
* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::captionPreferencesChanged): Pass to the PageGroup.
* page/CaptionUserPreferences.h:
* page/PageGroup.cpp:
(WebCore::PageGroup::captionPreferencesChanged): Pass to every page, as well as pages in the PageCache.
* page/PageGroup.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@145826 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.h
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h
Source/WebCore/history/PageCache.cpp
Source/WebCore/history/PageCache.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/CaptionUserPreferences.cpp
Source/WebCore/page/CaptionUserPreferences.h
Source/WebCore/page/CaptionUserPreferencesMac.h
Source/WebCore/page/CaptionUserPreferencesMac.mm
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PageGroup.cpp
Source/WebCore/page/PageGroup.h