Changeset 49608 in webkit
- Timestamp:
- Oct 14, 2009 10:15:54 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r49607 r49608 1 2009-10-14 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Sam Weinig. 4 5 Move scrolling code from FrameLoader to FrameView 6 https://bugs.webkit.org/show_bug.cgi?id=30370 7 8 This code is about controlling the Frame's view, not about loading 9 stuff into the frame. 10 11 * loader/FrameLoader.cpp: 12 (WebCore::FrameLoader::finishedParsing): 13 (WebCore::FrameLoader::scrollToAnchor): 14 * page/FrameView.cpp: 15 (WebCore::FrameView::scrollToFragment): 16 (WebCore::FrameView::scrollToAnchor): 17 * page/FrameView.h: 18 1 19 2009-10-14 Oliver Hunt <oliver@apple.com> 2 20 -
trunk/WebCore/dom/Document.cpp
r49507 r49608 2355 2355 m_tokenizer->executeScriptsWaitingForStylesheets(); 2356 2356 2357 if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && m_frame)2358 m_frame->loader()->gotoAnchor();2357 if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && view()) 2358 view()->scrollToFragment(m_frame->loader()->url()); 2359 2359 } 2360 2360 -
trunk/WebCore/loader/FrameLoader.cpp
r49507 r49608 1020 1020 } 1021 1021 1022 void FrameLoader::gotoAnchor()1023 {1024 // If our URL has no ref, then we have no place we need to jump to.1025 // OTOH If CSS target was set previously, we want to set it to 0, recalc1026 // and possibly repaint because :target pseudo class may have been1027 // set (see bug 11321).1028 if (!m_URL.hasFragmentIdentifier() && !m_frame->document()->cssTarget())1029 return;1030 1031 String fragmentIdentifier = m_URL.fragmentIdentifier();1032 if (gotoAnchor(fragmentIdentifier))1033 return;1034 1035 // Try again after decoding the ref, based on the document's encoding.1036 if (m_decoder)1037 gotoAnchor(decodeURLEscapeSequences(fragmentIdentifier, m_decoder->encoding()));1038 }1039 1040 1022 void FrameLoader::finishedParsing() 1041 1023 { … … 1060 1042 // If not, remove them, relayout, and repaint. 1061 1043 m_frame->view()->restoreScrollbar(); 1062 1063 gotoAnchor(); 1044 m_frame->view()->scrollToFragment(m_URL); 1064 1045 } 1065 1046 … … 1242 1223 Settings* settings = m_frame->settings(); 1243 1224 return settings ? settings->defaultTextEncodingName() : String(); 1244 }1245 1246 bool FrameLoader::gotoAnchor(const String& name)1247 {1248 ASSERT(m_frame->document());1249 1250 if (!m_frame->document()->haveStylesheetsLoaded()) {1251 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true);1252 return false;1253 }1254 1255 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false);1256 1257 Element* anchorNode = m_frame->document()->findAnchor(name);1258 1259 #if ENABLE(SVG)1260 if (m_frame->document()->isSVGDocument()) {1261 if (name.startsWith("xpointer(")) {1262 // We need to parse the xpointer reference here1263 } else if (name.startsWith("svgView(")) {1264 RefPtr<SVGSVGElement> svg = static_cast<SVGDocument*>(m_frame->document())->rootElement();1265 if (!svg->currentView()->parseViewSpec(name))1266 return false;1267 svg->setUseCurrentView(true);1268 } else {1269 if (anchorNode && anchorNode->hasTagName(SVGNames::viewTag)) {1270 RefPtr<SVGViewElement> viewElement = anchorNode->hasTagName(SVGNames::viewTag) ? static_cast<SVGViewElement*>(anchorNode) : 0;1271 if (viewElement.get()) {1272 RefPtr<SVGSVGElement> svg = static_cast<SVGSVGElement*>(SVGLocatable::nearestViewportElement(viewElement.get()));1273 svg->inheritViewAttributes(viewElement.get());1274 }1275 }1276 }1277 // FIXME: need to decide which <svg> to focus on, and zoom to that one1278 // FIXME: need to actually "highlight" the viewTarget(s)1279 }1280 #endif1281 1282 m_frame->document()->setCSSTarget(anchorNode); // Setting to null will clear the current target.1283 1284 // Implement the rule that "" and "top" both mean top of page as in other browsers.1285 if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top")))1286 return false;1287 1288 if (FrameView* view = m_frame->view())1289 view->maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNode) : m_frame->document());1290 1291 return true;1292 1225 } 1293 1226 … … 1767 1700 m_frame->eventHandler()->stopAutoscrollTimer(); 1768 1701 started(); 1769 gotoAnchor(); 1702 if (FrameView* view = m_frame->view()) 1703 view->scrollToFragment(m_URL); 1770 1704 1771 1705 // It's important to model this as a load that starts and immediately finishes. -
trunk/WebCore/loader/FrameLoader.h
r49415 r49608 247 247 String encoding() const; 248 248 249 void gotoAnchor();250 251 249 void tokenizerProcessedData(); 252 250 … … 429 427 Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer); 430 428 431 bool gotoAnchor(const String& name); // returns true if the anchor was found432 429 void scrollToAnchor(const KURL&); 433 430 -
trunk/WebCore/page/FrameView.cpp
r48533 r49608 53 53 #include "RenderView.h" 54 54 #include "Settings.h" 55 #include "TextResourceDecoder.h" 55 56 #include <wtf/CurrentTime.h> 56 57 … … 58 59 #include "RenderLayerCompositor.h" 59 60 #endif 61 62 #if ENABLE(SVG) 63 #include "SVGDocument.h" 64 #include "SVGLocatable.h" 65 #include "SVGNames.h" 66 #include "SVGPreserveAspectRatio.h" 67 #include "SVGSVGElement.h" 68 #include "SVGViewElement.h" 69 #include "SVGViewSpec.h" 70 #endif 71 60 72 61 73 namespace WebCore { … … 770 782 } 771 783 784 bool FrameView::scrollToFragment(const KURL& url) 785 { 786 // If our URL has no ref, then we have no place we need to jump to. 787 // OTOH If CSS target was set previously, we want to set it to 0, recalc 788 // and possibly repaint because :target pseudo class may have been 789 // set (see bug 11321). 790 if (!url.hasFragmentIdentifier() && !m_frame->document()->cssTarget()) 791 return false; 792 793 String fragmentIdentifier = url.fragmentIdentifier(); 794 if (scrollToAnchor(fragmentIdentifier)) 795 return true; 796 797 // Try again after decoding the ref, based on the document's encoding. 798 if (TextResourceDecoder* decoder = m_frame->document()->decoder()) 799 return scrollToAnchor(decodeURLEscapeSequences(fragmentIdentifier, decoder->encoding())); 800 801 return false; 802 } 803 804 bool FrameView::scrollToAnchor(const String& name) 805 { 806 ASSERT(m_frame->document()); 807 808 if (!m_frame->document()->haveStylesheetsLoaded()) { 809 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true); 810 return false; 811 } 812 813 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false); 814 815 Element* anchorNode = m_frame->document()->findAnchor(name); 816 817 #if ENABLE(SVG) 818 if (m_frame->document()->isSVGDocument()) { 819 if (name.startsWith("xpointer(")) { 820 // We need to parse the xpointer reference here 821 } else if (name.startsWith("svgView(")) { 822 RefPtr<SVGSVGElement> svg = static_cast<SVGDocument*>(m_frame->document())->rootElement(); 823 if (!svg->currentView()->parseViewSpec(name)) 824 return false; 825 svg->setUseCurrentView(true); 826 } else { 827 if (anchorNode && anchorNode->hasTagName(SVGNames::viewTag)) { 828 RefPtr<SVGViewElement> viewElement = anchorNode->hasTagName(SVGNames::viewTag) ? static_cast<SVGViewElement*>(anchorNode) : 0; 829 if (viewElement.get()) { 830 RefPtr<SVGSVGElement> svg = static_cast<SVGSVGElement*>(SVGLocatable::nearestViewportElement(viewElement.get())); 831 svg->inheritViewAttributes(viewElement.get()); 832 } 833 } 834 } 835 // FIXME: need to decide which <svg> to focus on, and zoom to that one 836 // FIXME: need to actually "highlight" the viewTarget(s) 837 } 838 #endif 839 840 m_frame->document()->setCSSTarget(anchorNode); // Setting to null will clear the current target. 841 842 // Implement the rule that "" and "top" both mean top of page as in other browsers. 843 if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top"))) 844 return false; 845 846 maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNode) : m_frame->document()); 847 return true; 848 } 849 772 850 void FrameView::maintainScrollPositionAtAnchor(Node* anchorNode) 773 851 { -
trunk/WebCore/page/FrameView.h
r48526 r49608 184 184 void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit); 185 185 186 bool scrollToFragment(const KURL&); 187 bool scrollToAnchor(const String&); 186 188 void maintainScrollPositionAtAnchor(Node*); 187 189
Note: See TracChangeset
for help on using the changeset viewer.