diff options
| author | Cary Clark <cary@android.com> | 2010-11-08 11:35:24 -0500 |
|---|---|---|
| committer | Cary Clark <cary@android.com> | 2010-11-08 15:33:48 -0500 |
| commit | f1610d01f92cb77827d2de13c0ed38554e4f0790 (patch) | |
| tree | 4d10890cc77381af3dc3a55d98c0bf8a0b0866cd | |
| parent | 9934d5d8bbc7e1f13e620eac325528f9e92d67ee (diff) | |
| download | external_webkit-f1610d01f92cb77827d2de13c0ed38554e4f0790.zip external_webkit-f1610d01f92cb77827d2de13c0ed38554e4f0790.tar.gz external_webkit-f1610d01f92cb77827d2de13c0ed38554e4f0790.tar.bz2 | |
update dom version on style change
The DOM version number is used to know when the
nav cache is out of date. Webkit changes the version
when DOM attributes change, but not when the CSS
style property changes.
Tracking the style version fixes Google properties like
the 'Options' menu that is available on mobile
devices after a search.
Additionally, fix a crash if the root layer doesn't
exist. And, rebuild the nav cache always on touch.
bug:2628448
Change-Id: I50aa258c1b057ac7deed00f6eca37c0ee323efcf
| -rw-r--r-- | WebCore/config.h | 3 | ||||
| -rw-r--r-- | WebCore/dom/Document.cpp | 3 | ||||
| -rw-r--r-- | WebCore/dom/Document.h | 8 | ||||
| -rw-r--r-- | WebCore/dom/Element.cpp | 3 | ||||
| -rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 3 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedFrame.cpp | 25 | ||||
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 2 |
7 files changed, 35 insertions, 12 deletions
diff --git a/WebCore/config.h b/WebCore/config.h index 70f8a20..5c3a48c 100644 --- a/WebCore/config.h +++ b/WebCore/config.h @@ -202,6 +202,9 @@ // apple-touch-icon support in <link> tags #define ANDROID_APPLE_TOUCH_ICON +// track changes to the style that may change what is drawn +#define ANDROID_STYLE_VERSION + // Enable prefetching when specified via the rel element of <link> elements. #define ENABLE_LINK_PREFETCH 1 diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 9dfe6a3..9ad263c 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -371,6 +371,9 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con , m_compatibilityMode(NoQuirksMode) , m_compatibilityModeLocked(false) , m_domTreeVersion(0) +#ifdef ANDROID_STYLE_VERSION + , m_styleVersion(0) +#endif , m_styleSheets(StyleSheetList::create(this)) , m_readyState(Complete) , m_styleRecalcTimer(this, &Document::styleRecalcTimerFired) diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index 1fb7079..25122b5 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -873,6 +873,11 @@ public: void incDOMTreeVersion() { ++m_domTreeVersion; } unsigned domTreeVersion() const { return m_domTreeVersion; } +#ifdef ANDROID_STYLE_VERSION + void incStyleVersion() { ++m_styleVersion; } + unsigned styleVersion() const { return m_styleVersion; } +#endif + void setDocType(PassRefPtr<DocumentType>); #if ENABLE(XPATH) @@ -1164,6 +1169,9 @@ private: mutable RefPtr<Element> m_documentElement; unsigned m_domTreeVersion; +#ifdef ANDROID_STYLE_VERSION + unsigned m_styleVersion; +#endif HashSet<NodeIterator*> m_nodeIterators; HashSet<Range*> m_ranges; diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp index 83e129e..10ba71b 100644 --- a/WebCore/dom/Element.cpp +++ b/WebCore/dom/Element.cpp @@ -930,6 +930,9 @@ void Element::recalcStyle(StyleChange change) #endif if ((change > NoChange || needsStyleRecalc())) { +#ifdef ANDROID_STYLE_VERSION + document()->incStyleVersion(); +#endif if (hasRareData()) rareData()->resetComputedStyle(); } diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index deae37f..64b53c4 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -675,7 +675,8 @@ void WebViewCore::recordPictureSet(PictureSet* content) // as domTreeVersion only increment, we can just check the sum to see // whether we need to update the frame cache for (Frame* frame = m_mainFrame; frame; frame = frame->tree()->traverseNext()) { - latestVersion += frame->document()->domTreeVersion(); + const Document* doc = frame->document(); + latestVersion += doc->domTreeVersion() + doc->styleVersion(); } } DBG_NAV_LOGD("m_lastFocused=%p oldFocusNode=%p" diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp index e331464..8f0df7a 100644 --- a/WebKit/android/nav/CachedFrame.cpp +++ b/WebKit/android/nav/CachedFrame.cpp @@ -52,13 +52,15 @@ WebCore::IntRect CachedFrame::adjustBounds(const CachedNode* node, #if USE(ACCELERATED_COMPOSITING) const CachedLayer* cachedLayer = layer(node); const WebCore::LayerAndroid* rootLayer = mRoot->rootLayer(); - IntRect rrect = cachedLayer->adjustBounds(rootLayer, rect); - if (!cachedLayer->layer(rootLayer)->contentIsScrollable()) - rrect.move(-mViewBounds.x(), -mViewBounds.y()); - return rrect; -#else - return rect; + const LayerAndroid* aLayer = cachedLayer->layer(rootLayer); + if (aLayer) { + IntRect rrect = cachedLayer->adjustBounds(rootLayer, rect); + if (!aLayer->contentIsScrollable()) + rrect.move(-mViewBounds.x(), -mViewBounds.y()); + return rrect; + } #endif + return rect; } // This is for nodes inside a layer. It takes an IntRect that has been @@ -71,10 +73,13 @@ WebCore::IntRect CachedFrame::unadjustBounds(const CachedNode* node, if (node->isInLayer()) { const CachedLayer* cachedLayer = layer(node); const WebCore::LayerAndroid* rootLayer = mRoot->rootLayer(); - IntRect rrect = cachedLayer->unadjustBounds(rootLayer, rect); - if (!cachedLayer->layer(rootLayer)->contentIsScrollable()) - rrect.move(mViewBounds.x(), mViewBounds.y()); - return rrect; + const LayerAndroid* aLayer = cachedLayer->layer(rootLayer); + if (aLayer) { + IntRect rrect = cachedLayer->unadjustBounds(rootLayer, rect); + if (!aLayer->contentIsScrollable()) + rrect.move(mViewBounds.x(), mViewBounds.y()); + return rrect; + } } #endif return rect; diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index d754af5..9579509 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -885,7 +885,7 @@ void selectBestAt(const WebCore::IntRect& rect) { const CachedFrame* frame; int rx, ry; - CachedRoot* root = getFrameCache(DontAllowNewer); + CachedRoot* root = getFrameCache(AllowNewer); const CachedNode* node = findAt(root, rect, &frame, &rx, &ry); if (!node) { |
