summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/Document.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-10-15 16:08:57 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-10-15 16:08:57 +0200
commit5466563f4b5b6b86523e3f89bb7f77e5b5270c78 (patch)
tree8caccf7cd03a15207cde3ba282c88bf132482a91 /Source/WebCore/dom/Document.cpp
parent33b26980cb24288b5a9f2590ccf32a949281bb79 (diff)
downloadqtwebkit-5466563f4b5b6b86523e3f89bb7f77e5b5270c78.tar.gz
Imported WebKit commit 0dc6cd75e1d4836eaffbb520be96fac4847cc9d2 (http://svn.webkit.org/repository/webkit/trunk@131300)
WebKit update which introduces the QtWebKitWidgets module that contains the WK1 widgets based API. (In fact it renames QtWebKit to QtWebKitWidgets while we're working on completing the entire split as part of https://bugs.webkit.org/show_bug.cgi?id=99314
Diffstat (limited to 'Source/WebCore/dom/Document.cpp')
-rw-r--r--Source/WebCore/dom/Document.cpp175
1 files changed, 97 insertions, 78 deletions
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index df2ebeff7..571423581 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -109,6 +109,7 @@
#include "Language.h"
#include "Localizer.h"
#include "Logging.h"
+#include "MediaCanStartListener.h"
#include "MediaQueryList.h"
#include "MediaQueryMatcher.h"
#include "MouseEventWithHitTestResults.h"
@@ -174,6 +175,8 @@
#include <wtf/CurrentTime.h>
#include <wtf/HashFunctions.h>
#include <wtf/MainThread.h>
+#include <wtf/MemoryInstrumentationHashMap.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
#include <wtf/MemoryInstrumentationVector.h>
#include <wtf/PassRefPtr.h>
#include <wtf/StdLibExtras.h>
@@ -459,8 +462,8 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
, m_savedRenderer(0)
, m_designMode(inherit)
#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
- , m_hasDashboardRegions(false)
- , m_dashboardRegionsDirty(false)
+ , m_hasAnnotatedRegions(false)
+ , m_annotatedRegionsDirty(false)
#endif
, m_createRenderers(true)
, m_inPageCache(false)
@@ -526,7 +529,12 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
m_markers = adoptPtr(new DocumentMarkerController);
- m_cachedResourceLoader = adoptPtr(new CachedResourceLoader(this));
+ if (m_frame)
+ m_cachedResourceLoader = m_frame->loader()->activeDocumentLoader()->cachedResourceLoader();
+ if (!m_cachedResourceLoader)
+ m_cachedResourceLoader = CachedResourceLoader::create(0);
+ m_cachedResourceLoader->setDocument(this);
+
#if ENABLE(LINK_PRERENDER)
m_prerenderer = Prerenderer::create(this);
#endif
@@ -642,14 +650,17 @@ Document::~Document()
if (m_elemSheet)
m_elemSheet->clearOwnerNode();
- deleteCustomFonts();
-
m_weakReference->clear();
if (m_mediaQueryMatcher)
m_mediaQueryMatcher->documentDestroyed();
clearStyleResolver(); // We need to destory CSSFontSelector before destroying m_cachedResourceLoader.
+
+ // It's possible for multiple Documents to end up referencing the same CachedResourceLoader (e.g., SVGImages
+ // load the initial empty document and the SVGDocument with the same DocumentLoader).
+ if (m_cachedResourceLoader->document() == this)
+ m_cachedResourceLoader->setDocument(0);
m_cachedResourceLoader.clear();
// We must call clearRareData() here since a Document class inherits TreeScope
@@ -949,9 +960,7 @@ PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCo
ec = NAMESPACE_ERR;
return 0;
}
- RefPtr<Element> newElement = createElement(oldElement->tagQName(), ec);
- if (ec)
- return 0;
+ RefPtr<Element> newElement = createElement(oldElement->tagQName(), false);
newElement->cloneDataFromElement(*oldElement);
@@ -1140,17 +1149,6 @@ bool Document::cssGridLayoutEnabled() const
#if ENABLE(CSS_REGIONS)
-PassRefPtr<WebKitNamedFlow> Document::webkitGetFlowByName(const String& flowName)
-{
- if (!cssRegionsEnabled() || !renderer())
- return 0;
-
- // It's possible to have pending styles not applied that affect the existing flows.
- updateStyleIfNeeded();
-
- return namedFlows()->flowByName(flowName);
-}
-
PassRefPtr<DOMNamedFlowCollection> Document::webkitGetNamedFlows()
{
if (!cssRegionsEnabled() || !renderer())
@@ -1773,11 +1771,16 @@ void Document::unscheduleStyleRecalc()
m_pendingStyleRecalcShouldForce = false;
}
-bool Document::isPendingStyleRecalc() const
+bool Document::hasPendingStyleRecalc() const
{
return m_styleRecalcTimer.isActive() && !m_inStyleRecalc;
}
+bool Document::hasPendingForcedStyleRecalc() const
+{
+ return m_styleRecalcTimer.isActive() && m_pendingStyleRecalcShouldForce;
+}
+
void Document::styleRecalcTimerFired(Timer<Document>*)
{
updateStyleIfNeeded();
@@ -1977,20 +1980,6 @@ PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex)
return style.release();
}
-void Document::registerCustomFont(PassOwnPtr<FontData> fontData)
-{
- m_customFonts.append(fontData);
-}
-
-void Document::deleteCustomFonts()
-{
- size_t size = m_customFonts.size();
- for (size_t i = 0; i < size; ++i)
- GlyphPageTreeNode::pruneTreeCustomFontData(m_customFonts[i].get());
-
- m_customFonts.clear();
-}
-
bool Document::isPageBoxVisible(int pageIndex)
{
RefPtr<RenderStyle> style = styleForPage(pageIndex);
@@ -2684,6 +2673,14 @@ double Document::minimumTimerInterval() const
return p->settings()->minDOMTimerInterval();
}
+double Document::timerAlignmentInterval() const
+{
+ Page* p = page();
+ if (!p)
+ return ScriptExecutionContext::timerAlignmentInterval();
+ return p->settings()->domTimerAlignmentInterval();
+}
+
EventTarget* Document::errorEventTarget()
{
return domWindow();
@@ -3355,15 +3352,15 @@ void Document::activeChainNodeDetached(Node* node)
}
#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
-const Vector<DashboardRegionValue>& Document::dashboardRegions() const
+const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const
{
- return m_dashboardRegions;
+ return m_annotatedRegions;
}
-void Document::setDashboardRegions(const Vector<DashboardRegionValue>& regions)
+void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions)
{
- m_dashboardRegions = regions;
- setDashboardRegionsDirty(false);
+ m_annotatedRegions = regions;
+ setAnnotatedRegionsDirty(false);
}
#endif
@@ -3710,7 +3707,7 @@ EventListener* Document::getWindowAttributeEventListener(const AtomicString& eve
void Document::dispatchWindowEvent(PassRefPtr<Event> event, PassRefPtr<EventTarget> target)
{
- ASSERT(!eventDispatchForbidden());
+ ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
DOMWindow* domWindow = this->domWindow();
if (!domWindow)
return;
@@ -3719,7 +3716,7 @@ void Document::dispatchWindowEvent(PassRefPtr<Event> event, PassRefPtr<EventTar
void Document::dispatchWindowLoadEvent()
{
- ASSERT(!eventDispatchForbidden());
+ ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
DOMWindow* domWindow = this->domWindow();
if (!domWindow)
return;
@@ -4069,14 +4066,25 @@ void Document::setInPageCache(bool flag)
m_inPageCache = flag;
FrameView* v = view();
+ Page* page = this->page();
+
if (flag) {
ASSERT(!m_savedRenderer);
m_savedRenderer = renderer();
if (v) {
+ // FIXME: There is some scrolling related work that needs to happen whenever a page goes into the
+ // page cache and similar work that needs to occur when it comes out. This is where we do the work
+ // that needs to happen when we enter, and the work that needs to happen when we exit is in
+ // HistoryController::restoreScrollPositionAndViewState(). It can't be here because this function is
+ // called too early on in the process of a page exiting the cache for that work to be possible in this
+ // function. It would be nice if there was more symmetry here.
+ // https://bugs.webkit.org/show_bug.cgi?id=98698
v->cacheCurrentScrollPosition();
- if (page() && page()->mainFrame() == m_frame)
+ if (page && page->mainFrame() == m_frame) {
v->resetScrollbarsAndClearContentsSize();
- else
+ if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
+ scrollingCoordinator->clearStateTree();
+ } else
v->resetScrollbars();
}
m_styleRecalcTimer.stop();
@@ -4450,10 +4458,10 @@ PassRefPtr<HTMLCollection> Document::windowNamedItems(const AtomicString& name)
{
NamedCollectionMap::AddResult result = m_windowNamedItemCollections.add(name, 0);
if (!result.isNewEntry)
- return result.iterator->second;
+ return result.iterator->value;
RefPtr<HTMLNameCollection> collection = HTMLNameCollection::create(this, WindowNamedItems, name);
- result.iterator->second = collection.get();
+ result.iterator->value = collection.get();
return collection.release();
}
@@ -4461,10 +4469,10 @@ PassRefPtr<HTMLCollection> Document::documentNamedItems(const AtomicString& name
{
NamedCollectionMap::AddResult result = m_documentNamedItemCollections.add(name, 0);
if (!result.isNewEntry)
- return result.iterator->second;
+ return result.iterator->value;
RefPtr<HTMLNameCollection> collection = HTMLNameCollection::create(this, DocumentNamedItems, name);
- result.iterator->second = collection.get();
+ result.iterator->value = collection.get();
return collection.release();
}
@@ -4802,7 +4810,7 @@ CanvasRenderingContext* Document::getCSSCanvasContext(const String& type, const
HTMLCanvasElement* Document::getCSSCanvasElement(const String& name)
{
- RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, 0).iterator->second;
+ RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, 0).iterator->value;
if (!element)
element = HTMLCanvasElement::create(this);
return element.get();
@@ -5063,9 +5071,17 @@ void Document::requestFullScreenForElement(Element* element, unsigned short flag
// There is a previously-established user preference, security risk, or platform limitation.
if (!page() || !page()->settings()->fullScreenEnabled())
break;
-
- if (!page()->chrome()->client()->supportsFullScreenForElement(element, flags & Element::ALLOW_KEYBOARD_INPUT))
- break;
+
+ if (!page()->chrome()->client()->supportsFullScreenForElement(element, flags & Element::ALLOW_KEYBOARD_INPUT)) {
+ // The new full screen API does not accept a "flags" parameter, so fall back to disallowing
+ // keyboard input if the chrome client refuses to allow keyboard input.
+ if (!inLegacyMozillaMode && flags & Element::ALLOW_KEYBOARD_INPUT) {
+ flags &= ~Element::ALLOW_KEYBOARD_INPUT;
+ if (!page()->chrome()->client()->supportsFullScreenForElement(element, false))
+ break;
+ } else
+ break;
+ }
// 2. Let doc be element's node document. (i.e. "this")
Document* currentDoc = this;
@@ -5525,7 +5541,7 @@ void Document::loadEventDelayTimerFired(Timer<Document>*)
}
#if ENABLE(REQUEST_ANIMATION_FRAME)
-int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback)
+int Document::requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback)
{
if (!m_scriptedAnimationController) {
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
@@ -5543,18 +5559,18 @@ int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallba
return m_scriptedAnimationController->registerCallback(callback);
}
-void Document::webkitCancelAnimationFrame(int id)
+void Document::cancelAnimationFrame(int id)
{
if (!m_scriptedAnimationController)
return;
m_scriptedAnimationController->cancelCallback(id);
}
-void Document::serviceScriptedAnimations(DOMTimeStamp time)
+void Document::serviceScriptedAnimations(double monotonicAnimationStartTime)
{
if (!m_scriptedAnimationController)
return;
- m_scriptedAnimationController->serviceScriptedAnimations(time);
+ m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationStartTime);
}
#endif
@@ -5865,9 +5881,8 @@ void Document::updateHoverActiveState(const HitTestRequest& request, HitTestResu
void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_styleResolver);
ContainerNode::reportMemoryUsage(memoryObjectInfo);
- info.addMember(m_customFonts);
+ info.addMember(m_styleResolver);
info.addMember(m_url);
info.addMember(m_baseURL);
info.addMember(m_baseURLOverride);
@@ -5876,30 +5891,34 @@ void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
info.addMember(m_firstPartyForCookies);
info.addMember(m_documentURI);
info.addMember(m_baseTarget);
+ info.addMember(m_docType);
+ info.addMember(m_implementation);
+ info.addMember(m_elemSheet);
info.addMember(m_frame);
info.addMember(m_cachedResourceLoader);
- info.addMember(m_elemSheet);
info.addMember(m_styleSheetCollection);
- info.addHashSet(m_nodeIterators);
- info.addHashSet(m_ranges);
+ info.addMember(m_styleSheetList);
+ info.addMember(m_formController);
+ info.addMember(m_nodeIterators);
+ info.addMember(m_ranges);
info.addMember(m_title.string());
info.addMember(m_rawTitle.string());
info.addMember(m_xmlEncoding);
info.addMember(m_xmlVersion);
info.addMember(m_contentLanguage);
- info.addHashMap(m_documentNamedItemCollections);
- info.addHashMap(m_windowNamedItemCollections);
-#if ENABLE(DASHBOARD_SUPPORT)
- info.addMember(m_dashboardRegions);
+ info.addMember(m_documentNamedItemCollections);
+ info.addMember(m_windowNamedItemCollections);
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
+ info.addMember(m_annotatedRegions);
#endif
- info.addHashMap(m_cssCanvasElements);
+ info.addMember(m_cssCanvasElements);
info.addMember(m_iconURLs);
- info.addHashSet(m_documentSuspensionCallbackElements);
- info.addHashSet(m_mediaVolumeCallbackElements);
- info.addHashSet(m_privateBrowsingStateChangedElements);
- info.addHashMap(m_elementsByAccessKey);
+ info.addMember(m_documentSuspensionCallbackElements);
+ info.addMember(m_mediaVolumeCallbackElements);
+ info.addMember(m_privateBrowsingStateChangedElements);
+ info.addMember(m_elementsByAccessKey);
info.addMember(m_eventQueue);
- info.addHashSet(m_mediaCanStartListeners);
+ info.addMember(m_mediaCanStartListeners);
info.addMember(m_pendingTasks);
}
@@ -5959,19 +5978,19 @@ PassRefPtr<ElementAttributeData> Document::cachedImmutableAttributeData(const El
unsigned cacheHash = cacheKey.hash();
ImmutableAttributeDataCache::iterator cacheIterator = m_immutableAttributeDataCache.add(cacheHash, nullptr).iterator;
- if (cacheIterator->second && cacheIterator->second->key != cacheKey)
+ if (cacheIterator->value && cacheIterator->value->key != cacheKey)
cacheHash = 0;
RefPtr<ElementAttributeData> attributeData;
- if (cacheHash && cacheIterator->second)
- attributeData = cacheIterator->second->value;
+ if (cacheHash && cacheIterator->value)
+ attributeData = cacheIterator->value->value;
else
attributeData = ElementAttributeData::createImmutable(attributes);
- if (!cacheHash || cacheIterator->second)
+ if (!cacheHash || cacheIterator->value)
return attributeData.release();
- cacheIterator->second = adoptPtr(new ImmutableAttributeDataCacheEntry(ImmutableAttributeDataCacheKey(element->tagQName(), attributeData->immutableAttributeArray(), attributeData->length()), attributeData));
+ cacheIterator->value = adoptPtr(new ImmutableAttributeDataCacheEntry(ImmutableAttributeDataCacheKey(element->tagQName(), attributeData->immutableAttributeArray(), attributeData->length()), attributeData));
return attributeData.release();
}
@@ -5981,15 +6000,15 @@ bool Document::haveStylesheetsLoaded() const
return !m_styleSheetCollection->hasPendingSheets() || m_ignorePendingStylesheets;
}
-Localizer& Document::getLocalizer(const AtomicString& locale)
+Localizer& Document::getCachedLocalizer(const AtomicString& locale)
{
AtomicString localeKey = locale;
if (locale.isEmpty() || !RuntimeEnabledFeatures::langAttributeAwareFormControlUIEnabled())
localeKey = defaultLanguage();
LocaleToLocalizerMap::AddResult result = m_localizerCache.add(localeKey, nullptr);
if (result.isNewEntry)
- result.iterator->second = Localizer::create(localeKey);
- return *(result.iterator->second);
+ result.iterator->value = Localizer::create(localeKey);
+ return *(result.iterator->value);
}
} // namespace WebCore