From 596e7654e9403d2b84bcea98854ad849ff8d1deb Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 24 Jul 2007 00:04:32 +0000 Subject: [PATCH] Reviewed by Hyatt. REGRESSION: Clicking on symbol in documentation often doesn't scroll to symbol A renderer for the anchor wasn't always available at the time parsing finished. So we need to bail out of gotoAnchor if stylesheets are pending and remember to call gotoAnchor later once all of the pending stylesheets load. * dom/Document.cpp: (WebCore::Document::Document): Initialize m_gotoAnchorNeededAfterStylesheetsLoad to false. (WebCore::Document::stylesheetLoaded): If we have no more pending stylesheets, call gotoAnchor if needed. * dom/Document.h: (WebCore::Document::gotoAnchorNeededAfterStylesheetsLoad): New method. (WebCore::Document::setGotoAnchorNeededAfterStylesheetsLoad): Ditto. * loader/FrameLoader.cpp: (WebCore::FrameLoader::gotoAnchor): Bail early if the document still has pending stylesheets. * loader/FrameLoader.h: Make gotoAnchor() public. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24550 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 20 ++++++++++++++++++++ WebCore/dom/Document.cpp | 4 ++++ WebCore/dom/Document.h | 4 ++++ WebCore/loader/FrameLoader.cpp | 7 +++++++ WebCore/loader/FrameLoader.h | 3 +-- 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 134ce7bd4158..3e5f21e127a7 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2007-07-23 Timothy Hatcher + + Reviewed by Hyatt. + + REGRESSION: Clicking on symbol in documentation often doesn't scroll to symbol + + A renderer for the anchor wasn't always available at the time parsing finished. So we need + to bail out of gotoAnchor if stylesheets are pending and remember to call gotoAnchor later + once all of the pending stylesheets load. + + * dom/Document.cpp: + (WebCore::Document::Document): Initialize m_gotoAnchorNeededAfterStylesheetsLoad to false. + (WebCore::Document::stylesheetLoaded): If we have no more pending stylesheets, call gotoAnchor if needed. + * dom/Document.h: + (WebCore::Document::gotoAnchorNeededAfterStylesheetsLoad): New method. + (WebCore::Document::setGotoAnchorNeededAfterStylesheetsLoad): Ditto. + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::gotoAnchor): Bail early if the document still has pending stylesheets. + * loader/FrameLoader.h: Make gotoAnchor() public. + 2007-07-23 John Sullivan Reviewed by Darin diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 3bf9dc7ae269..930afb437f1f 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -308,6 +308,7 @@ Document::Document(DOMImplementation* impl, Frame* frame) m_usesSiblingRules = false; m_usesFirstLineRules = false; m_usesFirstLetterRules = false; + m_gotoAnchorNeededAfterStylesheetsLoad = false; m_styleSelector = new CSSStyleSelector(this, m_usersheet, m_styleSheets.get(), !inCompatMode()); m_didCalculateStyleSelector = false; @@ -1924,6 +1925,9 @@ void Document::stylesheetLoaded() #endif updateStyleSelector(); + + if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad) + m_frame->loader()->gotoAnchor(); } void Document::updateStyleSelector() diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index af6690476d16..a7f3c125d594 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -271,6 +271,9 @@ public: */ void addPendingSheet() { m_pendingStylesheets++; } + bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; } + void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; } + /** * Called when one or more stylesheets in the document may have been added, removed or changed. * @@ -730,6 +733,7 @@ protected: bool m_usesSiblingRules; bool m_usesFirstLineRules; bool m_usesFirstLetterRules; + bool m_gotoAnchorNeededAfterStylesheetsLoad; String m_title; bool m_titleSetExplicitly; diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 0c237eb296c5..518f3820ad06 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -1412,6 +1412,13 @@ bool FrameLoader::gotoAnchor(const String& name) { ASSERT(m_frame->document()); + if (!m_frame->document()->haveStylesheetsLoaded()) { + m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true); + return false; + } + + m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false); + Node* anchorNode = m_frame->document()->getElementById(AtomicString(name)); if (!anchorNode) anchorNode = m_frame->document()->anchors()->namedItem(name, !m_frame->document()->inCompatMode()); diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h index b422dac99e29..e19c8d85c527 100644 --- a/WebCore/loader/FrameLoader.h +++ b/WebCore/loader/FrameLoader.h @@ -322,6 +322,7 @@ namespace WebCore { KJS::JSValue* executeScript(const String& URL, int baseLine, const String& script); KJS::JSValue* executeScript(const String& script, bool forceUserGesture = false); + void gotoAnchor(); bool gotoAnchor(const String& name); // returns true if the anchor was found void scrollToAnchor(const KURL&); @@ -472,8 +473,6 @@ namespace WebCore { void receivedFirstData(); - void gotoAnchor(); - void updatePolicyBaseURL(); void setPolicyBaseURL(const String&); -- 2.36.0