WebCore/ChangeLog

 12008-03-05 Darin Adler <darin@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 - fix http://bugs.webkit.org/show_bug.cgi?id=17526
 6 REGRESSION: iframes are added to Safari's History menu
 7 by separating the visited link machinery from global history
 8
 9 This should also make page loading faster due to more efficient visited link coloring.
 10
 11 * WebCore.base.exp: Updated.
 12 * WebCore.vcproj/WebCore.vcproj: Added PageGroup.h/cpp, removed GlobalHistory.h/cpp.
 13 * WebCore.xcodeproj/project.pbxproj: Ditto. Also removed WebCoreHistory.h/m.
 14
 15 * css/CSSStyleSelector.cpp: Updated includes.
 16 (WebCore::CSSStyleSelector::initElementAndPseudoState): Eliminated code to set
 17 currentEncodedURL.
 18 (WebCore::checkPseudoState): Moved most of the code inside a new
 19 PageGroup::isLinkVisited function.
 20 (WebCore::CSSStyleSelector::canShareStyleWithElement): Tightened code a bit by using
 21 references and only getting colors when needed.
 22 (WebCore::CSSStyleSelector::getColorFromPrimitiveValue): Ditto.
 23 * css/CSSStyleSelector.h: Removed EncodedURL, m_encodedURL, and setEncodedURL.
 24
 25 * dom/Document.cpp:
 26 (WebCore::Document::attach): Removed call to setEncodedURL.
 27 (WebCore::Document::setURL): Ditto.
 28 (WebCore::Document::recalcStyleSelector): Ditto.
 29
 30 * loader/FrameLoader.cpp:
 31 (WebCore::FrameLoader::addBackForwardItemClippedAtTarget): Changed code to use
 32 early exit idiom to be a little more readable.
 33 (WebCore::FrameLoader::urlsMatchItem): Change to use a reference for slightly
 34 better efficiency.
 35 (WebCore::FrameLoader::goToItem): Use early exit idiom to be a little more
 36 readable.
 37 (WebCore::FrameLoader::updateHistoryForStandardLoad): Moved history code back
 38 in here and got rid of the helper function updateGlobalHistory, restoring the
 39 logic before r30549. Also added a call to the new addVisitedLink function.
 40 (WebCore::FrameLoader::updateHistoryForClientRedirect): Added code to call
 41 addVisitedLink here.
 42 (WebCore::FrameLoader::updateHistoryForBackForwardNavigation): Removed comment.
 43 (WebCore::FrameLoader::updateHistoryForReload): Removed call to
 44 updateGlobalHistory; we can just go without updating global history or
 45 visited links here, at least for now, since it's not clear that a reload
 46 is a "history event".
 47 (WebCore::FrameLoader::updateHistoryForRedirectWithLockedHistory): Moved
 48 history code back where it was, and added the call to addVisitedLink, just
 49 as in updateHistoryForStandardLoad above.
 50 * loader/FrameLoader.h: Removed updateGlobalHistory function.
 51
 52 * page/Chrome.cpp:
 53 (WebCore::ChromeClient::populateVisitedLinks): Added. Empty placeholder so we
 54 don't have to implement this for every port all at once.
 55 (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): Changed to use the
 56 new PageGroup class.
 57 * page/ChromeClient.h: Added populateVisitedLinks function, used to fill the
 58 visited links set from the global history at application startup time.
 59
 60 * page/FrameTree.cpp:
 61 (WebCore::FrameTree::find): Updated to use the new PageGroup class.
 62
 63 * page/GlobalHistory.h: Removed.
 64 * page/win/GlobalHistoryWin.cpp: Removed.
 65 * page/mac/GlobalHistoryMac.mm: Removed.
 66 * platform/mac/WebCoreHistory.h: Removed.
 67 * platform/mac/WebCoreHistory.m: Removed.
 68 * platform/win/WebCoreHistory.cpp: Removed.
 69 * platform/win/WebCoreHistory.h: Removed.
 70
 71 * page/Page.cpp:
 72 (WebCore::Page::Page): Set m_group to 0.
 73 (WebCore::Page::setGroupName): Set up m_group. If the page is not in any
 74 group, set it to 0 for now to postpone the cost of creating a group.
 75 (WebCore::Page::initGroup): Added. Sets m_group to point to a single-page
 76 group; used when getting a group.
 77 (WebCore::Page::removeAllVisitedLinks): Added. Calls removeVisitedLinks
 78 on all page groups.
 79 * page/Page.h: Moved enums inside the WebCore namespace. Removed the
 80 frameNamespace function and instead added the group and groupPtr functions.
 81
 82 * page/PageGroup.cpp: Added. Contains all the visited code from the
 83 CSSStyleSelector in the isVisitedLink function, but more efficient because
 84 we don't allocate memory for the buffer.
 85 * page/PageGroup.h: Added.
 86
 87 * platform/KURL.cpp:
 88 (WebCore::KURL::KURL): Zero out portEndPos and pathEndPos.
 89 (WebCore::KURL::init): Ditto.
 90 (WebCore::KURL::hasPath): Remove check for m_isValid, which is not needed
 91 any more because both pathEndPos and portEndPos are set to 0.
 92
 93 * platform/KURL.h: Added pathStart, pathEnd, and pathAfterLastSlash, which
 94 allow the visited URL code to work efficiently on a KURL without storing a
 95 copy of the URL as a CSSStyleSelector::EncodedURL.
 96
 97 * platform/gtk/TemporaryLinkStubs.cpp: Removed historyContains.
 98 * platform/qt/TemporaryLinkStubs.cpp: Removed unneeded include.
 99 * platform/wx/TemporaryLinkStubs.cpp: Removed historyContains.
 100
11012008-03-04 Anders Carlsson <andersca@apple.com>
2102
3103 Reviewed by Sam.
30794

WebCore/WebCore.base.exp

@@__ZN7WebCore4Page37setInLowQualityImageI
381381__ZN7WebCore4Page6goBackEv
382382__ZN7WebCore4Page8goToItemEPNS_11HistoryItemENS_13FrameLoadTypeE
383383__ZN7WebCore4Page9goForwardEv
 384__ZN7WebCore4Page9initGroupEv
384385__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientEPNS_15InspectorClientE
385386__ZN7WebCore4PageD1Ev
386387__ZN7WebCore5Cache11setDisabledEb

@@__ZN7WebCore9HTMLNames7srcAttrE
536537__ZN7WebCore9HTMLNames8hrefAttrE
537538__ZN7WebCore9PageCache11setCapacityEi
538539__ZN7WebCore9PageCache27releaseAutoreleasedPagesNowEv
 540__ZN7WebCore9PageGroup14addVisitedLinkEPKtm
 541__ZN7WebCore9PageGroup21removeAllVisitedLinksEv
539542__ZN7WebCore9Selection22expandUsingGranularityENS_15TextGranularityE
540543__ZN7WebCore9TimerBase4stopEv
541544__ZN7WebCore9TimerBase5startEdd
30794

WebCore/WebCore.vcproj/WebCore.vcproj

27552755 >
27562756 </File>
27572757 <File
2758  RelativePath="..\bridge\GlobalHistory.h"
2759  >
2760  </File>
2761  <File
27622758 RelativePath="..\page\History.cpp"
27632759 >
27642760 </File>

27952791 >
27962792 </File>
27972793 <File
 2794 RelativePath="..\page\PageGroup.cpp"
 2795 >
 2796 </File>
 2797 <File
 2798 RelativePath="..\page\PageGroup.h"
 2799 >
 2800 </File>
 2801 <File
27982802 RelativePath="..\page\Plugin.h"
27992803 >
28002804 </File>

28382842 >
28392843 </File>
28402844 <File
2841  RelativePath="..\page\win\GlobalHistoryWin.cpp"
2842  >
2843  </File>
2844  <File
28452845 RelativePath="..\page\win\PageWin.cpp"
28462846 >
28472847 </File>

35693569 >
35703570 </File>
35713571 <File
3572  RelativePath="..\platform\win\WebCoreHistory.cpp"
3573  >
3574  </File>
3575  <File
3576  RelativePath="..\platform\win\WebCoreHistory.h"
3577  >
3578  </File>
3579  <File
35803572 RelativePath="..\platform\win\WebCoreTextRenderer.cpp"
35813573 >
35823574 </File>
30776

WebCore/WebCore.xcodeproj/project.pbxproj

242242 1AE82FED0CAB07EE002237AE /* JSSQLResultSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE82FEB0CAB07EE002237AE /* JSSQLResultSet.h */; };
243243 1AE830440CAB0ED1002237AE /* JSDatabaseCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE830420CAB0ED1002237AE /* JSDatabaseCustom.cpp */; };
244244 1AF326460D78B5530068F0C4 /* AXObjectCacheMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AF326400D78B5530068F0C4 /* AXObjectCacheMac.mm */; };
245  1AF326470D78B5530068F0C4 /* GlobalHistoryMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AF326410D78B5530068F0C4 /* GlobalHistoryMac.mm */; };
246245 1AF326480D78B5530068F0C4 /* WebCoreAXObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF326420D78B5530068F0C4 /* WebCoreAXObject.h */; };
247246 1AF326490D78B5530068F0C4 /* WebCoreAXObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AF326430D78B5530068F0C4 /* WebCoreAXObject.mm */; };
248247 1AF3264A0D78B5530068F0C4 /* WebCoreScriptDebugger.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF326440D78B5530068F0C4 /* WebCoreScriptDebugger.h */; settings = {ATTRIBUTES = (Private, ); }; };
249248 1AF3264B0D78B5530068F0C4 /* WebCoreScriptDebugger.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AF326450D78B5530068F0C4 /* WebCoreScriptDebugger.mm */; };
250249 1AF326780D78B9440068F0C4 /* AXObjectCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF326760D78B9440068F0C4 /* AXObjectCache.h */; };
251250 1AF326790D78B9440068F0C4 /* EditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF326770D78B9440068F0C4 /* EditorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
252  1AF3267B0D78B94E0068F0C4 /* GlobalHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF3267A0D78B94E0068F0C4 /* GlobalHistory.h */; };
253251 1AFE117D0CBFFB36003017FA /* SQLResultSetRowList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFE117B0CBFFB36003017FA /* SQLResultSetRowList.cpp */; };
254252 1AFE117E0CBFFB36003017FA /* SQLResultSetRowList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFE117C0CBFFB36003017FA /* SQLResultSetRowList.h */; };
255253 1AFE11990CBFFCC4003017FA /* JSSQLResultSetRowList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFE11970CBFFCC4003017FA /* JSSQLResultSetRowList.cpp */; };

14391437 85FF315A0AAFBFCB00374F38 /* DOMKeyboardEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */; };
14401438 85FF315B0AAFBFCB00374F38 /* DOMKeyboardEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */; };
14411439 929264770B61FC7200B41D34 /* JSDocumentCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 929264760B61FC7200B41D34 /* JSDocumentCustom.cpp */; };
 1440 9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */; };
 1441 9302B0BF0D79F82C00C7EE83 /* PageGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */; settings = {ATTRIBUTES = (Private, ); }; };
14421442 9305B24D098F1B6B00C28855 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9305B24C098F1B6B00C28855 /* Timer.h */; settings = {ATTRIBUTES = (Private, ); }; };
14431443 930705D809E0C9B700B17FE4 /* JSCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 930705D709E0C9B700B17FE4 /* JSCounter.cpp */; };
14441444 930705DA09E0C9BF00B17FE4 /* JSCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 930705D909E0C9BF00B17FE4 /* JSCounter.h */; };

16451645 93F1999D08245E59001E9ABC /* DeprecatedValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = F58786C202DE3B8601EA4122 /* DeprecatedValueList.h */; settings = {ATTRIBUTES = (Private, ); }; };
16461646 93F1999E08245E59001E9ABC /* DeprecatedValueListImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = F587853B02DE375901EA4122 /* DeprecatedValueListImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
16471647 93F199A808245E59001E9ABC /* WebCoreFrameView.h in Headers */ = {isa = PBXBuildFile; fileRef = F587854C02DE375901EA4122 /* WebCoreFrameView.h */; settings = {ATTRIBUTES = (Private, ); }; };
1648  93F199A908245E59001E9ABC /* WebCoreHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = F5517DC2031AB56301A80180 /* WebCoreHistory.h */; settings = {ATTRIBUTES = (Private, ); }; };
16491648 93F199B308245E59001E9ABC /* WebCoreViewFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F587855402DE375901EA4122 /* WebCoreViewFactory.h */; settings = {ATTRIBUTES = (Private, ); }; };
16501649 93F199B808245E59001E9ABC /* ScrollBar.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7B2AF80450824100A8000F /* ScrollBar.h */; settings = {ATTRIBUTES = (Private, ); }; };
16511650 93F199BB08245E59001E9ABC /* WebCoreKeyboardUIMode.h in Headers */ = {isa = PBXBuildFile; fileRef = BE983D95052A2E0A00892D85 /* WebCoreKeyboardUIMode.h */; settings = {ATTRIBUTES = (Private, ); }; };

16691668 93F19A9D08245E59001E9ABC /* TextResourceDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D27802DE43D7018635CA /* TextResourceDecoder.cpp */; };
16701669 93F19AB908245E59001E9ABC /* Range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D30302DE4476018635CA /* Range.cpp */; };
16711670 93F19ABC08245E59001E9ABC /* XMLTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D30902DE4476018635CA /* XMLTokenizer.cpp */; };
1672  93F19AC808245E59001E9ABC /* WebCoreHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = F5517DC3031AB56301A80180 /* WebCoreHistory.m */; };
16731671 93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93955A4203D72932008635CE /* RenderTreeAsText.cpp */; };
16741672 93F19ADC08245E59001E9ABC /* PlatformScrollBarMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC7B2AF90450824100A8000F /* PlatformScrollBarMac.mm */; };
16751673 93F19AE108245E59001E9ABC /* BlockExceptions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65F80697054D9F86008BF776 /* BlockExceptions.mm */; };

45304528 1AE82FEB0CAB07EE002237AE /* JSSQLResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLResultSet.h; sourceTree = "<group>"; };
45314529 1AE830420CAB0ED1002237AE /* JSDatabaseCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDatabaseCustom.cpp; sourceTree = "<group>"; };
45324530 1AF326400D78B5530068F0C4 /* AXObjectCacheMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AXObjectCacheMac.mm; sourceTree = "<group>"; };
4533  1AF326410D78B5530068F0C4 /* GlobalHistoryMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GlobalHistoryMac.mm; sourceTree = "<group>"; };
45344531 1AF326420D78B5530068F0C4 /* WebCoreAXObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreAXObject.h; sourceTree = "<group>"; };
45354532 1AF326430D78B5530068F0C4 /* WebCoreAXObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreAXObject.mm; sourceTree = "<group>"; };
45364533 1AF326440D78B5530068F0C4 /* WebCoreScriptDebugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreScriptDebugger.h; sourceTree = "<group>"; };
45374534 1AF326450D78B5530068F0C4 /* WebCoreScriptDebugger.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreScriptDebugger.mm; sourceTree = "<group>"; };
45384535 1AF326760D78B9440068F0C4 /* AXObjectCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AXObjectCache.h; sourceTree = "<group>"; };
45394536 1AF326770D78B9440068F0C4 /* EditorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorClient.h; sourceTree = "<group>"; };
4540  1AF3267A0D78B94E0068F0C4 /* GlobalHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalHistory.h; sourceTree = "<group>"; };
45414537 1AFE117B0CBFFB36003017FA /* SQLResultSetRowList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLResultSetRowList.cpp; sourceTree = "<group>"; };
45424538 1AFE117C0CBFFB36003017FA /* SQLResultSetRowList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLResultSetRowList.h; sourceTree = "<group>"; };
45434539 1AFE118C0CBFFC4E003017FA /* SQLResultSetRowList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SQLResultSetRowList.idl; sourceTree = "<group>"; };

56715667 85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMKeyboardEvent.h; sourceTree = "<group>"; };
56725668 85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMKeyboardEvent.mm; sourceTree = "<group>"; };
56735669 929264760B61FC7200B41D34 /* JSDocumentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentCustom.cpp; sourceTree = "<group>"; };
 5670 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageGroup.cpp; sourceTree = "<group>"; };
 5671 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageGroup.h; sourceTree = "<group>"; };
56745672 9305B24C098F1B6B00C28855 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = "<group>"; };
56755673 9307059009E0C75800B17FE4 /* CSSPrimitiveValue.idl */ = {isa = PBXFileReference; explicitFileType = sourcecode; fileEncoding = 4; path = CSSPrimitiveValue.idl; sourceTree = "<group>"; };
56765674 930705C709E0C95F00B17FE4 /* Counter.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Counter.idl; sourceTree = "<group>"; };

79217919 F523D30402DE4476018635CA /* Range.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Range.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
79227920 F523D30902DE4476018635CA /* XMLTokenizer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTokenizer.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
79237921 F523D30A02DE4476018635CA /* XMLTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = XMLTokenizer.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
7924  F5517DC2031AB56301A80180 /* WebCoreHistory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreHistory.h; sourceTree = "<group>"; };
7925  F5517DC3031AB56301A80180 /* WebCoreHistory.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = WebCoreHistory.m; sourceTree = "<group>"; };
79267922 F58784F002DE375901EA4122 /* CursorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CursorMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
79277923 F587851502DE375901EA4122 /* DeprecatedPtrListImpl.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = DeprecatedPtrListImpl.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
79287924 F587851602DE375901EA4122 /* DeprecatedPtrListImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeprecatedPtrListImpl.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };

83668362 84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.mm */,
83678363 6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */,
83688364 51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */,
8369  F5517DC2031AB56301A80180 /* WebCoreHistory.h */,
8370  F5517DC3031AB56301A80180 /* WebCoreHistory.m */,
83718365 84B2B1F7056BEF3A00D2B771 /* WebCoreKeyGenerator.h */,
83728366 84B2B1F8056BEF3A00D2B771 /* WebCoreKeyGenerator.m */,
83738367 934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */,

84338427 65A21483097A3F5300B9050A /* FrameTree.h */,
84348428 65CBFEF70974F607001DAC25 /* FrameView.cpp */,
84358429 65CBFEF80974F607001DAC25 /* FrameView.h */,
8436  1AF3267A0D78B94E0068F0C4 /* GlobalHistory.h */,
84378430 BC94D1500C275C8B006BC617 /* History.cpp */,
84388431 BC94D1510C275C8B006BC617 /* History.h */,
84398432 BC94D1520C275C8B006BC617 /* History.idl */,

84448437 935C476209AC4CE600A6AAB4 /* MouseEventWithHitTestResults.h */,
84458438 65FEA86809833ADE00BED4AB /* Page.cpp */,
84468439 65A21467097A329100B9050A /* Page.h */,
 8440 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */,
 8441 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */,
84478442 65D1C1C909932B22000CB324 /* Plugin.h */,
84488443 BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */,
84498444 BCEC01BB0C274DAC009F4EC9 /* Screen.h */,

97439738 isa = PBXGroup;
97449739 children = (
97459740 1AF326400D78B5530068F0C4 /* AXObjectCacheMac.mm */,
9746  1AF326410D78B5530068F0C4 /* GlobalHistoryMac.mm */,
97479741 1AF326420D78B5530068F0C4 /* WebCoreAXObject.h */,
97489742 1AF326430D78B5530068F0C4 /* WebCoreAXObject.mm */,
97499743 1AF326440D78B5530068F0C4 /* WebCoreScriptDebugger.h */,

1412014114 B255996F0D00D8BA00BB825C /* WKTableTransferFilter.h in Headers */,
1412114115 654EC611097778F500DAB52C /* WebCoreFrameBridge.h in Headers */,
1412214116 93F199A808245E59001E9ABC /* WebCoreFrameView.h in Headers */,
14123  93F199A908245E59001E9ABC /* WebCoreHistory.h in Headers */,
1412414117 93F199C208245E59001E9ABC /* WebCoreKeyGenerator.h in Headers */,
1412514118 93F199BB08245E59001E9ABC /* WebCoreKeyboardUIMode.h in Headers */,
1412614119 934D9BA70B8C1175007B42A9 /* WebCoreNSStringExtras.h in Headers */,

1424014233 1AF326480D78B5530068F0C4 /* WebCoreAXObject.h in Headers */,
1424114234 1AF3264A0D78B5530068F0C4 /* WebCoreScriptDebugger.h in Headers */,
1424214235 1AF326780D78B9440068F0C4 /* AXObjectCache.h in Headers */,
14243  1AF3267B0D78B94E0068F0C4 /* GlobalHistory.h in Headers */,
 14236 9302B0BF0D79F82C00C7EE83 /* PageGroup.h in Headers */,
1424414237 BCA83E500D7CE1E9003421A8 /* JSClipboard.h in Headers */,
1424514238 BC6C49F40D7DBA0500FFA558 /* JSImageConstructor.h in Headers */,
1424614239 BC3452440D7E00EA0016574A /* JSRGBColor.h in Headers */,

1573615729 B255996D0D00D8BA00BB825C /* WKSpotLightFilter.m in Sources */,
1573715730 B25599700D00D8BA00BB825C /* WKTableTransferFilter.m in Sources */,
1573815731 654EC612097778F500DAB52C /* WebCoreFrameBridge.mm in Sources */,
15739  93F19AC808245E59001E9ABC /* WebCoreHistory.m in Sources */,
1574015732 93F19AE508245E59001E9ABC /* WebCoreKeyGenerator.m in Sources */,
1574115733 934D9BA50B8C116B007B42A9 /* WebCoreNSStringExtras.mm in Sources */,
1574215734 DD05FE0E0B8BA3C6009ACDFE /* WebCoreObjCExtras.c in Sources */,

1583715829 A766F3530D6BDE3500ABDDB3 /* JSCanvasPixelArrayCustom.cpp in Sources */,
1583815830 1CEFC9BA0D78DC8C007D2579 /* SchedulePair.cpp in Sources */,
1583915831 1AF326460D78B5530068F0C4 /* AXObjectCacheMac.mm in Sources */,
15840  1AF326470D78B5530068F0C4 /* GlobalHistoryMac.mm in Sources */,
1584115832 1AF326490D78B5530068F0C4 /* WebCoreAXObject.mm in Sources */,
1584215833 1AF3264B0D78B5530068F0C4 /* WebCoreScriptDebugger.mm in Sources */,
 15834 9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */,
1584315835 1CE24F970D7CAF0E007E04C2 /* SchedulePairMac.mm in Sources */,
1584415836 BCA83E4F0D7CE1E9003421A8 /* JSClipboard.cpp in Sources */,
1584515837 BCA83E520D7CE205003421A8 /* JSClipboardCustom.cpp in Sources */,
30794

WebCore/css/CSSStyleSelector.cpp

4949#include "FontValue.h"
5050#include "Frame.h"
5151#include "FrameView.h"
52 #include "GlobalHistory.h"
5352#include "HTMLDocument.h"
5453#include "HTMLElement.h"
5554#include "HTMLInputElement.h"
5655#include "HTMLNames.h"
5756#include "MediaList.h"
5857#include "MediaQueryEvaluator.h"
 58#include "Page.h"
 59#include "PageGroup.h"
5960#include "Pair.h"
6061#include "Rect.h"
6162#include "RenderTheme.h"

@@CSSStyleSheet* CSSStyleSelector::m_viewS
232233CSSStyleSheet *CSSStyleSelector::m_svgSheet = 0;
233234#endif
234235
235 static CSSStyleSelector::EncodedURL* currentEncodedURL = 0;
236236static PseudoState pseudoState;
237237
238238static const MediaQueryEvaluator& screenEval()

@@void CSSStyleSelector::init()
316316 m_medium = 0;
317317}
318318
319 void CSSStyleSelector::setEncodedURL(const KURL& url)
320 {
321  KURL u = url;
322 
323  u.setQuery(String());
324  u.setRef(String());
325  m_encodedURL.file = u.string();
326  int pos = m_encodedURL.file.reverseFind('/');
327  m_encodedURL.path = m_encodedURL.file;
328  if (pos > 0) {
329  m_encodedURL.path.truncate(pos);
330  m_encodedURL.path.append('/');
331  }
332  u.setPath(String());
333  m_encodedURL.prefix = u.string();
334 }
335 
336319CSSStyleSelector::~CSSStyleSelector()
337320{
338321 delete m_medium;
339  ::delete m_rootDefaultStyle;
340 
 322 delete m_rootDefaultStyle;
341323 delete m_authorStyle;
342324 delete m_userStyle;
343325}

@@void CSSStyleSelector::initElementAndPse
537519 m_styledElement = static_cast<StyledElement*>(m_element);
538520 else
539521 m_styledElement = 0;
540  currentEncodedURL = &m_encodedURL;
541522 pseudoState = PseudoUnknown;
542523}
543524

@@void CSSStyleSelector::initForStyleResol
568549 m_fontDirty = false;
569550}
570551
571 static inline int findSlashDotDotSlash(const UChar* characters, size_t length)
572 {
573  unsigned loopLimit = length < 4 ? 0 : length - 3;
574  for (unsigned i = 0; i < loopLimit; ++i) {
575  if (characters[i] == '/' && characters[i + 1] == '.' && characters[i + 2] == '.' && characters[i + 3] == '/')
576  return i;
577  }
578  return -1;
579 }
580 
581 static inline int findSlashSlash(const UChar* characters, size_t length, int position)
582 {
583  unsigned loopLimit = length < 2 ? 0 : length - 1;
584  for (unsigned i = position; i < loopLimit; ++i) {
585  if (characters[i] == '/' && characters[i + 1] == '/')
586  return i;
587  }
588  return -1;
589 }
590 
591 static inline int findSlashDotSlash(const UChar* characters, size_t length)
592 {
593  unsigned loopLimit = length < 3 ? 0 : length - 2;
594  for (unsigned i = 0; i < loopLimit; ++i) {
595  if (characters[i] == '/' && characters[i + 1] == '.' && characters[i + 2] == '/')
596  return i;
597  }
598  return -1;
599 }
600 
601 static inline bool containsColonSlashSlash(const UChar* characters, unsigned length)
602 {
603  unsigned loopLimit = length < 3 ? 0 : length - 2;
604  for (unsigned i = 0; i < loopLimit; ++i)
605  if (characters[i] == ':' && characters[i + 1] == '/' && characters[i + 2] == '/')
606  return true;
607  return false;
608 }
609 
610 static void cleanPath(Vector<UChar, 512>& path)
611 {
612  int pos;
613  while ((pos = findSlashDotDotSlash(path.data(), path.size())) != -1) {
614  int prev = reverseFind(path.data(), path.size(), '/', pos - 1);
615  // don't remove the host, i.e. http://foo.org/../foo.html
616  if (prev < 0 || (prev > 3 && path[prev - 2] == ':' && path[prev - 1] == '/'))
617  path.remove(pos, 3);
618  else
619  path.remove(prev, pos - prev + 3);
620  }
621 
622  // Don't remove "//" from an anchor identifier. -rjw
623  // Set refPos to -2 to mean "I haven't looked for the anchor yet".
624  // We don't want to waste a function call on the search for the the anchor
625  // in the vast majority of cases where there is no "//" in the path.
626  pos = 0;
627  int refPos = -2;
628  while ((pos = findSlashSlash(path.data(), path.size(), pos)) != -1) {
629  if (refPos == -2)
630  refPos = find(path.data(), path.size(), '#');
631  if (refPos > 0 && pos >= refPos)
632  break;
633 
634  if (pos == 0 || path[pos - 1] != ':')
635  path.remove(pos);
636  else
637  pos += 2;
638  }
639 
640  // FIXME: We don't want to remove "/./" from an anchor identifier either.
641  while ((pos = findSlashDotSlash(path.data(), path.size())) != -1)
642  path.remove(pos, 2);
643 }
644 
645 static void checkPseudoState(Element *e, bool checkVisited = true)
 552static void checkPseudoState(Element* e, bool checkVisited = true)
646553{
647554 if (!e->isLink()) {
648555 pseudoState = PseudoNone;

@@static void checkPseudoState(Element *e,
671578 return;
672579 }
673580
674  const UChar* characters = attr->characters();
675  unsigned length = attr->length();
 581 Document* document = e->document();
676582
677  if (containsColonSlashSlash(characters, length)) {
678  // FIXME: Strange to not clean the path just beacause it has "://" in it.
679  pseudoState = historyContains(characters, length) ? PseudoVisited : PseudoLink;
 583 Frame* frame = document->frame();
 584 if (!frame) {
 585 pseudoState = PseudoLink;
680586 return;
681587 }
682588
683  Vector<UChar, 512> buffer;
684  if (length && characters[0] == '/') {
685  buffer.append(currentEncodedURL->prefix.characters(), currentEncodedURL->prefix.length());
686  } else if (length && characters[0] == '#') {
687  buffer.append(currentEncodedURL->file.characters(), currentEncodedURL->file.length());
688  } else {
689  buffer.append(currentEncodedURL->path.characters(), currentEncodedURL->path.length());
 589 Page* page = frame->page();
 590 if (!page) {
 591 pseudoState = PseudoLink;
 592 return;
690593 }
691  buffer.append(characters, length);
692  cleanPath(buffer);
693  pseudoState = historyContains(buffer.data(), buffer.size()) ? PseudoVisited : PseudoLink;
 594
 595 pseudoState = page->group().isLinkVisited(document, *attr) ? PseudoVisited : PseudoLink;
694596}
695597
696598// a helper function for parsing nth-arguments

@@bool CSSStyleSelector::canShareStyleWith
829731 mappedAttrsMatch = s->mappedAttributes()->mapsEquivalent(m_styledElement->mappedAttributes());
830732 if (mappedAttrsMatch) {
831733 bool linksMatch = true;
 734
832735 if (s->isLink()) {
833736 // We need to check to see if the visited state matches.
834  Color linkColor = m_element->document()->linkColor();
835  Color visitedColor = m_element->document()->visitedLinkColor();
836  if (pseudoState == PseudoUnknown)
 737 if (pseudoState == PseudoUnknown) {
 738 const Color& linkColor = m_element->document()->linkColor();
 739 const Color& visitedColor = m_element->document()->visitedLinkColor();
837740 checkPseudoState(m_element, style->pseudoState() != PseudoAnyLink || linkColor != visitedColor);
 741 }
838742 linksMatch = (pseudoState == style->pseudoState());
839743 }
840744

@@Color CSSStyleSelector::getColorFromPrim
51345038 if (ident == CSS_VAL__WEBKIT_TEXT)
51355039 col = m_element->document()->textColor();
51365040 else if (ident == CSS_VAL__WEBKIT_LINK) {
5137  Color linkColor = m_element->document()->linkColor();
5138  Color visitedColor = m_element->document()->visitedLinkColor();
 5041 const Color& linkColor = m_element->document()->linkColor();
 5042 const Color& visitedColor = m_element->document()->visitedLinkColor();
51395043 if (linkColor == visitedColor)
51405044 col = linkColor;
51415045 else {
30794

WebCore/css/CSSStyleSelector.h

@@public:
110110
111111 bool strictParsing;
112112
113  struct EncodedURL {
114  String prefix; // protocol, host, etc.
115  String path;
116  String file;
117  } m_encodedURL;
118 
119  void setEncodedURL(const KURL& url);
120 
121113 // Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this function will return
122114 // the correct font size scaled relative to the user's default (medium).
123115 float fontSizeForKeyword(int keyword, bool quirksMode, bool monospace) const;

@@public:
250242 bool m_matchAuthorAndUserStyles;
251243
252244 RefPtr<CSSFontSelector> m_fontSelector;
253 
254245 HashSet<AtomicStringImpl*> m_selectorAttrs;
255 
256246 Vector<CSSMutableStyleDeclaration*> m_additionalAttributeStyleDecls;
257 
258247 Vector<MediaQueryResult*> m_viewportDependentMediaQueryResults;
259248
260249 void applyProperty(int id, CSSValue*);
30794

WebCore/dom/Document.cpp

@@void Document::attach()
12151215 if (Settings* docSettings = settings())
12161216 matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled();
12171217 m_styleSelector = new CSSStyleSelector(this, userStyleSheet(), m_styleSheets.get(), m_mappedElementSheet.get(), !inCompatMode(), matchAuthorAndUserStyles);
1218  m_styleSelector->setEncodedURL(m_url);
12191218 }
12201219
12211220 recalcStyle(Force);

@@void Document::setURL(const KURL& url)
16361635 return;
16371636
16381637 m_url = url;
1639  if (m_styleSelector)
1640  m_styleSelector->setEncodedURL(url);
1641 
16421638 m_isAllowedToLoadLocalResources = shouldBeAllowedToLoadLocalResources();
16431639 }
16441640

@@void Document::recalcStyleSelector()
22082204 // Create a new style selector
22092205 delete m_styleSelector;
22102206 m_styleSelector = new CSSStyleSelector(this, userStyleSheet(), m_styleSheets.get(), m_mappedElementSheet.get(), !inCompatMode(), matchAuthorAndUserStyles);
2211  m_styleSelector->setEncodedURL(m_url);
22122207 m_didCalculateStyleSelector = true;
22132208}
22142209
30794

WebCore/loader/FrameLoader.cpp

6666#include "MainResourceLoader.h"
6767#include "Page.h"
6868#include "PageCache.h"
 69#include "PageGroup.h"
6970#include "PluginInfoStore.h"
7071#include "ProgressTracker.h"
7172#include "RenderPart.h"

@@PassRefPtr<HistoryItem> FrameLoader::cre
38483849
38493850void FrameLoader::addBackForwardItemClippedAtTarget(bool doClip)
38503851{
3851  if (Page* page = m_frame->page())
3852  if (!documentLoader()->urlForHistory().isEmpty()) {
3853  Frame* mainFrame = page->mainFrame();
3854  ASSERT(mainFrame);
3855  FrameLoader* frameLoader = mainFrame->loader();
3856 
3857  if (!frameLoader->m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
3858  frameLoader->m_didPerformFirstNavigation = true;
3859  m_client->didPerformFirstNavigation();
3860  }
 3852 Page* page = m_frame->page();
 3853 if (!page)
 3854 return;
38613855
3862  RefPtr<HistoryItem> item = frameLoader->createHistoryItemTree(m_frame, doClip);
3863  LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), documentLoader()->url().string().ascii().data());
3864  page->backForwardList()->addItem(item);
3865  }
 3856 if (documentLoader()->urlForHistory().isEmpty())
 3857 return;
 3858
 3859 Frame* mainFrame = page->mainFrame();
 3860 ASSERT(mainFrame);
 3861 FrameLoader* frameLoader = mainFrame->loader();
 3862
 3863 if (!frameLoader->m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
 3864 frameLoader->m_didPerformFirstNavigation = true;
 3865 m_client->didPerformFirstNavigation();
 3866 }
 3867
 3868 RefPtr<HistoryItem> item = frameLoader->createHistoryItemTree(m_frame, doClip);
 3869 LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), documentLoader()->url().string().ascii().data());
 3870 page->backForwardList()->addItem(item);
38663871}
38673872
38683873PassRefPtr<HistoryItem> FrameLoader::createHistoryItemTree(Frame* targetFrame, bool clipAtTarget)

@@void FrameLoader::loadItem(HistoryItem*
41104115// Walk the frame tree and ensure that the URLs match the URLs in the item.
41114116bool FrameLoader::urlsMatchItem(HistoryItem* item) const
41124117{
4113  KURL currentURL = documentLoader()->url();
4114 
 4118 const KURL& currentURL = documentLoader()->url();
41154119 if (!equalIgnoringRef(currentURL, item->url()))
41164120 return false;
4117 
 4121
41184122 const HistoryItemVector& childItems = item->children();
4119 
 4123
41204124 unsigned size = childItems.size();
41214125 for (unsigned i = 0; i < size; ++i) {
41224126 Frame* childFrame = m_frame->tree()->child(childItems[i]->target());

@@void FrameLoader::goToItem(HistoryItem*
41374141 // <rdar://problem/3951283> can view pages from the back/forward cache that should be disallowed by Parental Controls
41384142 // Ultimately, history item navigations should go through the policy delegate. That's covered in:
41394143 // <rdar://problem/3979539> back/forward cache navigations should consult policy delegate
4140  if (Page* page = m_frame->page())
4141  if (m_client->shouldGoToHistoryItem(targetItem)) {
4142  BackForwardList* bfList = page->backForwardList();
4143  HistoryItem* currentItem = bfList->currentItem();
4144 
4145  // Set the BF cursor before commit, which lets the user quickly click back/forward again.
4146  // - plus, it only makes sense for the top level of the operation through the frametree,
4147  // as opposed to happening for some/one of the page commits that might happen soon
4148  bfList->goToItem(targetItem);
4149  recursiveGoToItem(targetItem, currentItem, type);
4150  }
 4144 Page* page = m_frame->page();
 4145 if (!page)
 4146 return;
 4147 if (!m_client->shouldGoToHistoryItem(targetItem))
 4148 return;
 4149
 4150 // Set the BF cursor before commit, which lets the user quickly click back/forward again.
 4151 // - plus, it only makes sense for the top level of the operation through the frametree,
 4152 // as opposed to happening for some/one of the page commits that might happen soon
 4153 BackForwardList* bfList = page->backForwardList();
 4154 HistoryItem* currentItem = bfList->currentItem();
 4155 bfList->goToItem(targetItem);
 4156 recursiveGoToItem(targetItem, currentItem, type);
41514157}
41524158
41534159// The general idea here is to traverse the frame tree and the item tree in parallel,

@@bool FrameLoader::childFramesMatchItem(H
42254231 return true;
42264232}
42274233
4228 void FrameLoader::updateGlobalHistory()
4229 {
4230  Settings* settings = m_frame->settings();
4231  if (!settings)
4232  return;
4233  if (settings->privateBrowsingEnabled())
4234  return;
4235  const KURL& url = documentLoader()->urlForHistory();
4236  if (url.isEmpty())
4237  return;
4238  m_client->updateGlobalHistory(url);
4239 }
 4234// There are 3 things you might think of as "history", all of which are handled by these functions.
 4235//
 4236// 1) Back/forward: The m_currentHistoryItem is part of this mechanism.
 4237// 2) Global history: Handled by the client.
 4238// 3) Visited links: Handled by the PageGroup.
42404239
42414240void FrameLoader::updateHistoryForStandardLoad()
42424241{
42434242 LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", documentLoader()->url().string().ascii().data());
4244 
 4243
 4244 Settings* settings = m_frame->settings();
 4245 bool needPrivacy = !settings || settings->privateBrowsingEnabled();
 4246 const KURL& historyURL = documentLoader()->urlForHistory();
 4247
42454248 // If the navigation occured during load and this is a subframe, update the current
4246  // history item rather than adding a new one. <rdar://problem/5333496>
 4249 // back/forward item rather than adding a new one and don't add the new URL to global
 4250 // history at all. But do add it to visited links. <rdar://problem/5333496>
42474251 bool frameNavigationDuringLoad = false;
42484252 if (m_navigationDuringLoad) {
42494253 HTMLFrameOwnerElement* owner = m_frame->ownerElement();

@@void FrameLoader::updateHistoryForStanda
42524256 }
42534257
42544258 if (!frameNavigationDuringLoad && !documentLoader()->isClientRedirect()) {
4255  if (!documentLoader()->urlForHistory().isEmpty())
 4259 if (!historyURL.isEmpty()) {
42564260 addBackForwardItemClippedAtTarget(true);
 4261 if (!needPrivacy)
 4262 m_client->updateGlobalHistory(historyURL);
 4263 }
42574264 } else if (documentLoader()->unreachableURL().isEmpty() && m_currentHistoryItem) {
42584265 m_currentHistoryItem->setURL(documentLoader()->url());
42594266 m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
42604267 }
42614268
4262  updateGlobalHistory();
 4269 if (!historyURL.isEmpty() && !needPrivacy) {
 4270 if (Page* page = m_frame->page())
 4271 page->group().addVisitedLink(historyURL);
 4272 }
42634273}
42644274
42654275void FrameLoader::updateHistoryForClientRedirect()

@@void FrameLoader::updateHistoryForClient
42764286 m_currentHistoryItem->clearScrollPoint();
42774287 }
42784288
4279  // FIXME: Should we call updateGlobalHistory here?
 4289 Settings* settings = m_frame->settings();
 4290 bool needPrivacy = !settings || settings->privateBrowsingEnabled();
 4291 const KURL& historyURL = documentLoader()->urlForHistory();
 4292
 4293 if (!historyURL.isEmpty() && !needPrivacy) {
 4294 if (Page* page = m_frame->page())
 4295 page->group().addVisitedLink(historyURL);
 4296 }
42804297}
42814298
42824299void FrameLoader::updateHistoryForBackForwardNavigation()

@@void FrameLoader::updateHistoryForBackFo
42884305
42894306 // Must grab the current scroll position before disturbing it
42904307 saveScrollPositionAndViewStateToItem(m_previousHistoryItem.get());
4291 
4292  // FIXME: Should we call updateGlobalHistory here?
42934308}
42944309
42954310void FrameLoader::updateHistoryForReload()

@@void FrameLoader::updateHistoryForReload
43094324 if (documentLoader()->unreachableURL().isEmpty())
43104325 m_currentHistoryItem->setURL(documentLoader()->requestURL());
43114326 }
4312 
4313  updateGlobalHistory();
43144327}
43154328
43164329void FrameLoader::updateHistoryForRedirectWithLockedHistory()

@@void FrameLoader::updateHistoryForRedire
43204333 LOG(History, "WebCoreHistory: Updating History for internal load in frame %s", documentLoader()->title().utf8().data());
43214334#endif
43224335
 4336 Settings* settings = m_frame->settings();
 4337 bool needPrivacy = !settings || settings->privateBrowsingEnabled();
 4338 const KURL& historyURL = documentLoader()->urlForHistory();
 4339
43234340 if (documentLoader()->isClientRedirect()) {
4324  if (!m_currentHistoryItem && !m_frame->tree()->parent())
 4341 if (!m_currentHistoryItem && !m_frame->tree()->parent()) {
43254342 addBackForwardItemClippedAtTarget(true);
 4343 if (!needPrivacy && !historyURL.isEmpty())
 4344 m_client->updateGlobalHistory(historyURL);
 4345 }
43264346 if (m_currentHistoryItem) {
43274347 m_currentHistoryItem->setURL(documentLoader()->url());
43284348 m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());

@@void FrameLoader::updateHistoryForRedire
43334353 parentFrame->loader()->m_currentHistoryItem->addChildItem(createHistoryItem(true));
43344354 }
43354355
4336  updateGlobalHistory();
 4356 if (!historyURL.isEmpty() && !needPrivacy) {
 4357 if (Page* page = m_frame->page())
 4358 page->group().addVisitedLink(historyURL);
 4359 }
43374360}
43384361
43394362void FrameLoader::updateHistoryForCommit()
30794

WebCore/loader/FrameLoader.h

@@namespace WebCore {
456456 void updateHistoryForClientRedirect();
457457 void updateHistoryForCommit();
458458
459  void updateGlobalHistory();
460 
461459 void redirectionTimerFired(Timer<FrameLoader>*);
462460 void checkCompletedTimerFired(Timer<FrameLoader>*);
463461 void checkLoadCompleteTimerFired(Timer<FrameLoader>*);
30794

WebCore/page/Chrome.cpp

3333#include "InspectorController.h"
3434#include "JSDOMWindow.h"
3535#include "Page.h"
 36#include "PageGroup.h"
3637#include "PausedTimeouts.h"
3738#include "ResourceHandle.h"
3839#include "SecurityOrigin.h"

@@void ChromeClient::dashboardRegionsChang
349350{
350351}
351352
 353void ChromeClient::populateVisitedLinks()
 354{
 355}
 356
352357// --------
353358
354359PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
355360{
356  const HashSet<Page*>* group = page->frameNamespace();
357 
358  if (!group)
359  return;
 361 const HashSet<Page*>& pages = page->group().pages();
360362
361  HashSet<Page*>::const_iterator end = group->end();
362  for (HashSet<Page*>::const_iterator it = group->begin(); it != end; ++it) {
 363 HashSet<Page*>::const_iterator end = pages.end();
 364 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
363365 Page* otherPage = *it;
364366 if ((deferSelf || otherPage != page)) {
365367 if (!otherPage->defersLoading())
30794

WebCore/page/ChromeClient.h

@@namespace WebCore {
121121
122122 virtual void dashboardRegionsChanged();
123123
 124 virtual void populateVisitedLinks();
 125
124126 protected:
125127 virtual ~ChromeClient() { }
126128 };
30794

WebCore/page/FrameTree.cpp

2323
2424#include "Frame.h"
2525#include "Page.h"
 26#include "PageGroup.h"
2627#include <stdarg.h>
2728#include <wtf/Platform.h>
2829#include <wtf/StringExtras.h>

@@Frame* FrameTree::find(const AtomicStrin
182183 if (frame->tree()->name() == name)
183184 return frame;
184185
185  // Search the entire tree for all other pages in this namespace.
186  const HashSet<Page*>* pages = page->frameNamespace();
187  if (pages) {
188  HashSet<Page*>::const_iterator end = pages->end();
189  for (HashSet<Page*>::const_iterator it = pages->begin(); it != end; ++it) {
190  Page* otherPage = *it;
191  if (otherPage != page)
192  for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext())
193  if (frame->tree()->name() == name)
194  return frame;
 186 // Search the entire tree of each of the other pages in this namespace.
 187 // FIXME: Is random order OK?
 188 const HashSet<Page*>& pages = page->group().pages();
 189 HashSet<Page*>::const_iterator end = pages.end();
 190 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
 191 Page* otherPage = *it;
 192 if (otherPage != page) {
 193 for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
 194 if (frame->tree()->name() == name)
 195 return frame;
 196 }
195197 }
196198 }
197199
30794

WebCore/page/GlobalHistory.h

1 /*
2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef GlobalHistory_h
27 #define GlobalHistory_h
28 
29 #include <wtf/unicode/Unicode.h>
30 
31 namespace WebCore {
32 
33  bool historyContains(const UChar* characters, unsigned length);
34 
35 } // namespace WebCore
36 
37 #endif // GlobalHistory_h
30794

WebCore/page/Page.cpp

3535#include "HistoryItem.h"
3636#include "InspectorController.h"
3737#include "Logging.h"
 38#include "PageGroup.h"
3839#include "ProgressTracker.h"
3940#include "RenderWidget.h"
4041#include "SelectionController.h"

4950
5051namespace WebCore {
5152
 53typedef HashMap<String, PageGroup*> PageGroupMap;
 54
5255static HashSet<Page*>* allPages;
53 static HashMap<String, HashSet<Page*>*>* frameNamespaces;
 56static PageGroupMap* pageGroups;
5457
5558#ifndef NDEBUG
5659WTFLogChannel LogWebCorePageLeaks = { 0x00000000, "", WTFLogChannelOn };

@@Page::Page(ChromeClient* chromeClient, C
8588 , m_parentInspectorController(0)
8689 , m_didLoadUserStyleSheet(false)
8790 , m_userStyleSheetModificationTime(0)
 91 , m_group(0)
8892 , m_debugger(0)
8993{
9094 if (!allPages) {

@@void Page::goToItem(HistoryItem* item, F
165169
166170void Page::setGroupName(const String& name)
167171{
168  if (frameNamespaces && !m_groupName.isEmpty()) {
169  HashSet<Page*>* oldNamespace = frameNamespaces->get(m_groupName);
170  if (oldNamespace) {
171  oldNamespace->remove(this);
172  if (oldNamespace->isEmpty()) {
173  frameNamespaces->remove(m_groupName);
174  delete oldNamespace;
175  }
176  }
 172 if (!m_groupName.isEmpty()) {
 173 ASSERT(!m_singlePageGroup);
 174 ASSERT(m_group);
 175 ASSERT(pageGroups);
 176 ASSERT(pageGroups->get(m_groupName) == m_group);
 177 m_group->removePage(this);
 178 if (m_group->pages().isEmpty())
 179 pageGroups->remove(m_groupName);
177180 }
178181 m_groupName = name;
179  if (!name.isEmpty()) {
180  if (!frameNamespaces)
181  frameNamespaces = new HashMap<String, HashSet<Page*>*>;
182  HashSet<Page*>* newNamespace = frameNamespaces->get(name);
183  if (!newNamespace) {
184  newNamespace = new HashSet<Page*>;
185  frameNamespaces->add(name, newNamespace);
 182 if (name.isEmpty())
 183 m_group = 0;
 184 else {
 185 m_singlePageGroup.clear();
 186 if (!pageGroups)
 187 pageGroups = new PageGroupMap;
 188 pair<PageGroupMap::iterator, bool> result = pageGroups->add(name, 0);
 189 if (!result.second) {
 190 ASSERT(result.first->second);
 191 m_group = result.first->second;
 192 m_group->addPage(this);
 193 } else {
 194 ASSERT(!result.first->second);
 195 m_group = new PageGroup(this);
 196 result.first->second = m_group;
186197 }
187  newNamespace->add(this);
188198 }
189199}
190200
191 const HashSet<Page*>* Page::frameNamespace() const
192 {
193  return (frameNamespaces && !m_groupName.isEmpty()) ? frameNamespaces->get(m_groupName) : 0;
194 }
195 
196 const HashSet<Page*>* Page::frameNamespace(const String& groupName)
 201void Page::initGroup()
197202{
198  return (frameNamespaces && !groupName.isEmpty()) ? frameNamespaces->get(groupName) : 0;
 203 ASSERT(!m_singlePageGroup);
 204 ASSERT(!m_group);
 205 m_singlePageGroup.set(new PageGroup(this));
 206 m_group = m_singlePageGroup.get();
199207}
200208
201209void Page::setNeedsReapplyStyles()

@@const String& Page::userStyleSheet() con
360368 return m_userStyleSheet;
361369}
362370
 371void Page::removeAllVisitedLinks()
 372{
 373 if (!allPages)
 374 return;
 375 HashSet<PageGroup*> groups;
 376 HashSet<Page*>::iterator pagesEnd = allPages->end();
 377 for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
 378 if (PageGroup* group = (*it)->groupPtr())
 379 groups.add(group);
 380 }
 381 HashSet<PageGroup*>::iterator groupsEnd = groups.end();
 382 for (HashSet<PageGroup*>::iterator it = groups.begin(); it != groupsEnd; ++it)
 383 (*it)->removeVisitedLinks();
 384}
 385
363386void Page::setDebuggerForAllPages(KJS::Debugger* debugger)
364387{
365388 ASSERT(allPages);
30794

WebCore/page/Page.h

11// -*- mode: c++; c-basic-offset: 4 -*-
22/*
3  * Copyright (C) 2006 Apple Computer, Inc.
 3 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
44 *
55 * This library is free software; you can redistribute it and/or
66 * modify it under the terms of the GNU Library General Public

@@namespace KJS {
4040 class Debugger;
4141}
4242
43 typedef enum TextCaseSensitivity {
44  TextCaseSensitive,
45  TextCaseInsensitive
46 };
47 
48 typedef enum FindDirection {
49  FindDirectionForward,
50  FindDirectionBackward
51 };
52 
5343namespace WebCore {
5444
5545 class Chrome;
5646 class ChromeClient;
5747 class ContextMenuClient;
5848 class ContextMenuController;
 49 class Document;
5950 class DragClient;
6051 class DragController;
6152 class EditorClient;

@@namespace WebCore {
6455 class InspectorClient;
6556 class InspectorController;
6657 class Node;
 58 class PageGroup;
6759 class ProgressTracker;
6860 class Selection;
6961 class SelectionController;
7062 class Settings;
 63 class KURL;
 64
 65 enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
 66 enum FindDirection { FindDirectionForward, FindDirectionBackward };
7167
7268 class Page : Noncopyable {
7369 public:
7470 static void setNeedsReapplyStyles();
75  static const HashSet<Page*>* frameNamespace(const String&);
7671
7772 Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*);
7873 ~Page();

@@namespace WebCore {
9388 void goToItem(HistoryItem*, FrameLoadType);
9489
9590 void setGroupName(const String&);
96  String groupName() const { return m_groupName; }
 91 const String& groupName() const { return m_groupName; }
9792
98  const HashSet<Page*>* frameNamespace() const;
 93 PageGroup& group() { if (!m_group) initGroup(); return *m_group; }
 94 PageGroup* groupPtr() { return m_group; } // can return 0
9995
10096 void incrementFrameCount() { ++m_frameCount; }
10197 void decrementFrameCount() { --m_frameCount; }

@@namespace WebCore {
151147 static HINSTANCE instanceHandle() { return s_instanceHandle; }
152148#endif
153149
 150 static void removeAllVisitedLinks();
 151
154152 private:
 153 void initGroup();
 154
155155 OwnPtr<Chrome> m_chrome;
156156 OwnPtr<SelectionController> m_dragCaretController;
157157 OwnPtr<DragController> m_dragController;

@@namespace WebCore {
182182 mutable bool m_didLoadUserStyleSheet;
183183 mutable time_t m_userStyleSheetModificationTime;
184184
 185 OwnPtr<PageGroup> m_singlePageGroup;
 186 PageGroup* m_group;
 187
185188 KJS::Debugger* m_debugger;
186189
187190#if PLATFORM(WIN) || (PLATFORM(WX) && defined(__WXMSW__))
30794

WebCore/page/PageGroup.cpp

 1/*
 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "PageGroup.h"
 28
 29#include "ChromeClient.h"
 30#include "Document.h"
 31#include "Page.h"
 32
 33namespace WebCore {
 34
 35// --------
 36
 37PageGroup::PageGroup(Page* page)
 38 : m_visitedLinksPopulated(false)
 39{
 40 ASSERT(page);
 41 m_pages.add(page);
 42}
 43
 44void PageGroup::addPage(Page* page)
 45{
 46 ASSERT(page);
 47 ASSERT(!m_pages.contains(page));
 48 m_pages.add(page);
 49}
 50
 51void PageGroup::removePage(Page* page)
 52{
 53 ASSERT(page);
 54 ASSERT(m_pages.contains(page));
 55 m_pages.remove(page);
 56}
 57
 58static inline int findSlashDotDotSlash(const UChar* characters, size_t length)
 59{
 60 if (length < 4)
 61 return -1;
 62 unsigned loopLimit = length - 3;
 63 for (unsigned i = 0; i < loopLimit; ++i) {
 64 if (characters[i] == '/' && characters[i + 1] == '.' && characters[i + 2] == '.' && characters[i + 3] == '/')
 65 return i;
 66 }
 67 return -1;
 68}
 69
 70static inline int findSlashSlash(const UChar* characters, size_t length, int position)
 71{
 72 if (length < 2)
 73 return -1;
 74 unsigned loopLimit = length - 1;
 75 for (unsigned i = position; i < loopLimit; ++i) {
 76 if (characters[i] == '/' && characters[i + 1] == '/')
 77 return i;
 78 }
 79 return -1;
 80}
 81
 82static inline int findSlashDotSlash(const UChar* characters, size_t length)
 83{
 84 if (length < 3)
 85 return -1;
 86 unsigned loopLimit = length - 2;
 87 for (unsigned i = 0; i < loopLimit; ++i) {
 88 if (characters[i] == '/' && characters[i + 1] == '.' && characters[i + 2] == '/')
 89 return i;
 90 }
 91 return -1;
 92}
 93
 94static inline bool containsColonSlashSlash(const UChar* characters, unsigned length)
 95{
 96 if (length < 3)
 97 return false;
 98 unsigned loopLimit = length - 2;
 99 for (unsigned i = 0; i < loopLimit; ++i) {
 100 if (characters[i] == ':' && characters[i + 1] == '/' && characters[i + 2] == '/')
 101 return true;
 102 }
 103 return false;
 104}
 105
 106static inline void cleanPath(Vector<UChar, 512>& path)
 107{
 108 // FIXME: Shold not do this in the query or anchor part.
 109 int pos;
 110 while ((pos = findSlashDotDotSlash(path.data(), path.size())) != -1) {
 111 int prev = reverseFind(path.data(), path.size(), '/', pos - 1);
 112 // don't remove the host, i.e. http://foo.org/../foo.html
 113 if (prev < 0 || (prev > 3 && path[prev - 2] == ':' && path[prev - 1] == '/'))
 114 path.remove(pos, 3);
 115 else
 116 path.remove(prev, pos - prev + 3);
 117 }
 118
 119 // FIXME: Shold not do this in the query part.
 120 // Set refPos to -2 to mean "I haven't looked for the anchor yet".
 121 // We don't want to waste a function call on the search for the the anchor
 122 // in the vast majority of cases where there is no "//" in the path.
 123 pos = 0;
 124 int refPos = -2;
 125 while ((pos = findSlashSlash(path.data(), path.size(), pos)) != -1) {
 126 if (refPos == -2)
 127 refPos = find(path.data(), path.size(), '#');
 128 if (refPos > 0 && pos >= refPos)
 129 break;
 130
 131 if (pos == 0 || path[pos - 1] != ':')
 132 path.remove(pos);
 133 else
 134 pos += 2;
 135 }
 136
 137 // FIXME: Shold not do this in the query or anchor part.
 138 while ((pos = findSlashDotSlash(path.data(), path.size())) != -1)
 139 path.remove(pos, 2);
 140}
 141
 142static inline bool matchLetter(UChar c, UChar lowercaseLetter)
 143{
 144 return (c | 0x20) == lowercaseLetter;
 145}
 146
 147static inline bool needsTrailingSlash(const UChar* characters, unsigned length)
 148{
 149 if (length < 6)
 150 return false;
 151 if (!matchLetter(characters[0], 'h')
 152 || !matchLetter(characters[1], 't')
 153 || !matchLetter(characters[2], 't')
 154 || !matchLetter(characters[3], 'p'))
 155 return false;
 156 if (!(characters[4] == ':'
 157 || (matchLetter(characters[4], 's') && characters[5] == ':')))
 158 return false;
 159
 160 unsigned pos = characters[4] == ':' ? 5 : 6;
 161
 162 // Skip initial two slashes if present.
 163 if (pos + 1 < length && characters[pos] == '/' && characters[pos + 1] == '/')
 164 pos += 2;
 165
 166 // Find next slash.
 167 while (pos < length && characters[pos] != '/')
 168 ++pos;
 169
 170 return pos == length;
 171}
 172
 173bool PageGroup::isLinkVisited(Document* document, const AtomicString& attributeURL)
 174{
 175 if (!m_visitedLinksPopulated) {
 176 m_visitedLinksPopulated = true;
 177 ASSERT(!m_pages.isEmpty());
 178 (*m_pages.begin())->chrome()->client()->populateVisitedLinks();
 179 }
 180
 181 const UChar* characters = attributeURL.characters();
 182 unsigned length = attributeURL.length();
 183 if (!length)
 184 return false;
 185
 186 // FIXME: It is strange that we do not do further processing on strings that have "://" in them.
 187 // That's clearly incorrect for at least these reasons:
 188 // 1) The "://" could be in the query or anchor.
 189 // 2) The URL's path could have a "/./" or a "/../" or a "//" sequence in it.
 190
 191 // FIXME: needsTrailingSlash does not properly return true for a URL that has no path, but does
 192 // have a query or anchor.
 193
 194 bool hasColonSlashSlash = containsColonSlashSlash(characters, length);
 195
 196 if (hasColonSlashSlash && !needsTrailingSlash(characters, length))
 197 return m_visitedLinkHashes.contains(StringImpl::computeHash(characters, length));
 198
 199 Vector<UChar, 512> buffer;
 200
 201 // This is a poor man's completeURL. Faster with less memory allocation.
 202 // FIXME: It's missing a lot of what completeURL does and what KURL does.
 203 // FIXME: Move this into KURL? Or Document? Even the fast version should be in the right place,
 204 // rather than here.
 205
 206 if (hasColonSlashSlash) {
 207 // FIXME: This is incorrect for URLs that have a query or anchor; the "/" needs to go at the
 208 // end of the path, *before* the query or anchor.
 209 buffer.append(characters, length);
 210 buffer.append('/');
 211 return m_visitedLinkHashes.contains(StringImpl::computeHash(buffer.data(), buffer.size()));
 212 }
 213
 214 const KURL& baseURL = document->baseURL();
 215 switch (characters[0]) {
 216 case '/':
 217 buffer.append(baseURL.string().characters(), baseURL.pathStart());
 218 break;
 219 case '#':
 220 buffer.append(baseURL.string().characters(), baseURL.pathEnd());
 221 break;
 222 default:
 223 buffer.append(baseURL.string().characters(), baseURL.pathAfterLastSlash());
 224 break;
 225 }
 226 buffer.append(characters, length);
 227 cleanPath(buffer);
 228 if (needsTrailingSlash(buffer.data(), buffer.size())) {
 229 // FIXME: This is incorrect for URLs that have a query or anchor; the "/" needs to go at the
 230 // end of the path, *before* the query or anchor.
 231 buffer.append('/');
 232 }
 233
 234 return m_visitedLinkHashes.contains(StringImpl::computeHash(buffer.data(), buffer.size()));
 235}
 236
 237void PageGroup::addVisitedLink(const KURL& url)
 238{
 239 ASSERT(!url.isEmpty());
 240 m_visitedLinkHashes.add(url.string().impl()->hash());
 241}
 242
 243void PageGroup::addVisitedLink(const UChar* characters, size_t length)
 244{
 245 m_visitedLinkHashes.add(StringImpl::computeHash(characters, length));
 246}
 247
 248void PageGroup::removeVisitedLinks()
 249{
 250 m_visitedLinkHashes.clear();
 251}
 252
 253void PageGroup::removeAllVisitedLinks()
 254{
 255 Page::removeAllVisitedLinks();
 256}
 257
 258} // namespace WebCore
0

WebCore/page/PageGroup.h

 1/*
 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef PageGroup_h
 27#define PageGroup_h
 28
 29#include <wtf/HashSet.h>
 30#include <wtf/Noncopyable.h>
 31#include <wtf/unicode/Unicode.h>
 32
 33namespace WebCore {
 34
 35 class AtomicString;
 36 class Document;
 37 class KURL;
 38 class Page;
 39
 40 class PageGroup : Noncopyable {
 41 public:
 42 PageGroup(Page*);
 43
 44 const HashSet<Page*>& pages() const { return m_pages; }
 45
 46 void addPage(Page*);
 47 void removePage(Page*);
 48
 49 bool isLinkVisited(Document*, const AtomicString& attributeValue);
 50
 51 void addVisitedLink(const KURL&);
 52 void addVisitedLink(const UChar*, size_t);
 53 void removeVisitedLinks();
 54 static void removeAllVisitedLinks();
 55
 56 private:
 57 HashSet<Page*> m_pages;
 58 HashSet<unsigned> m_visitedLinkHashes;
 59 bool m_visitedLinksPopulated;
 60 };
 61
 62} // namespace WebCore
 63
 64#endif // PageGroup_h
0

WebCore/page/mac/GlobalHistoryMac.mm

1 /*
2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "config.h"
27 #import "GlobalHistory.h"
28 
29 #import "WebCoreHistory.h"
30 
31 namespace WebCore {
32 
33 bool historyContains(const UChar* characters, unsigned length)
34 {
35  // the other side of the bridge is careful not to throw exceptions here
36  return [[WebCoreHistory historyProvider] containsURL:characters length:length];
37 }
38 
39 } // namespace WebCore
30794

WebCore/page/win/GlobalHistoryWin.cpp

1 /*
2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "GlobalHistory.h"
28 
29 #include "WebCoreHistory.h"
30 
31 namespace WebCore {
32 
33 bool historyContains(const UChar* characters, unsigned length)
34 {
35  WebCoreHistoryProvider* provider = WebCoreHistory::historyProvider();
36  return provider && provider->containsURL(characters, length);
37 }
38 
39 } // namespace WebCore
30794

WebCore/platform/KURL.cpp

@@inline bool KURL::protocolIs(const Strin
264264
265265KURL::KURL()
266266 : m_isValid(false)
 267 , portEndPos(0)
 268 , pathEndPos(0)
267269{
268270}
269271

@@void KURL::init(const KURL& base, const
320322 if (!base.m_isValid && !base.isEmpty()) {
321323 m_string = relative;
322324 m_isValid = false;
 325 portEndPos = 0;
 326 pathEndPos = 0;
323327 return;
324328 }
325329

@@void KURL::init(const KURL& base, const
393397 else {
394398 m_string = relative;
395399 m_isValid = false;
 400 portEndPos = 0;
 401 pathEndPos = 0;
396402 }
397403 return;
398404 }

@@void KURL::init(const KURL& base, const
505511
506512bool KURL::hasPath() const
507513{
508  return m_isValid && pathEndPos != portEndPos;
 514 return pathEndPos != portEndPos;
509515}
510516
511517String KURL::lastPathComponent() const
30794

WebCore/platform/KURL.h

@@public:
140140 operator const String&() const { return m_string; }
141141 operator KJS::UString() const { return m_string; }
142142
 143 unsigned pathStart() const { return portEndPos; }
 144 unsigned pathEnd() const { return pathEndPos; }
 145 unsigned pathAfterLastSlash() const { return pathEndPos; }
 146
143147#if PLATFORM(CF)
144148 KURL(CFURLRef);
145149 CFURLRef createCFURL() const;
30794

WebCore/platform/gtk/TemporaryLinkStubs.cpp

3131#include "Editor.h"
3232#include "FrameView.h"
3333#include "FTPDirectoryDocument.h"
34 #include "GlobalHistory.h"
3534#include "KURL.h"
3635#include "NotImplemented.h"
3736#include "PluginDatabase.h"

@@Vector<char> loadResourceIntoArray(const
5857/* Completely empty stubs (mostly to allow DRT to run): */
5958/********************************************************/
6059
61 bool WebCore::historyContains(const UChar*, unsigned) { return false; }
62 
6360PluginSet PluginDatabase::getPluginsInPaths() const { notImplemented(); return PluginSet(); }
6461Vector<String> PluginDatabase::defaultPluginPaths() { notImplemented(); return Vector<String>(); }
6562bool PluginDatabase::isPreferredPluginPath(const String&) { notImplemented(); return false; }
30794

WebCore/platform/mac/WebCoreHistory.h

1 /*
2  * Copyright (C) 2003, 2007 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 @protocol WebCoreHistoryProvider <NSObject>
27 - (BOOL)containsURL:(const UniChar*)unicode length:(unsigned)length;
28 @end
29 
30 @interface WebCoreHistory : NSObject
31 
32 + (void)setHistoryProvider:(id<WebCoreHistoryProvider>)h;
33 + (id<WebCoreHistoryProvider>)historyProvider;
34 
35 @end
30794

WebCore/platform/mac/WebCoreHistory.m

1 /*
2  * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "config.h"
27 
28 #import "WebCoreHistory.h"
29 
30 @implementation WebCoreHistory
31 
32 static id<WebCoreHistoryProvider> _historyProvider = nil;
33 
34 + (void)setHistoryProvider: (id<WebCoreHistoryProvider>)h
35 {
36  if (_historyProvider != h){
37  [_historyProvider release];
38  _historyProvider = [h retain];
39  }
40 }
41 
42 + (id<WebCoreHistoryProvider>)historyProvider
43 {
44  return _historyProvider;
45 }
46 
47 @end
30794

WebCore/platform/qt/TemporaryLinkStubs.cpp

4949#include "FileSystem.h"
5050#include "FrameView.h"
5151#include "GraphicsContext.h"
52 #include "GlobalHistory.h"
5352#include "IconLoader.h"
5453#include "IntPoint.h"
5554#include "KURL.h"
30794

WebCore/platform/win/WebCoreHistory.cpp

1 /*
2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "WebCoreHistory.h"
28 
29 namespace WebCore {
30 
31 static WebCoreHistoryProvider* _historyProvider = 0;
32 
33 void WebCoreHistory::setHistoryProvider(WebCoreHistoryProvider* h)
34 {
35  if (_historyProvider == h)
36  return;
37 
38  delete _historyProvider;
39  _historyProvider = h;
40 }
41 
42 WebCoreHistoryProvider* WebCoreHistory::historyProvider()
43 {
44  return _historyProvider;
45 }
46 
47 }
30794

WebCore/platform/win/WebCoreHistory.h

1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25 
26 #ifndef WEBCORE_HISTORY_H_
27 #define WEBCORE_HISTORY_H_
28 
29 #include <unicode/umachine.h>
30 
31 namespace WebCore {
32 
33 class WebCoreHistoryProvider {
34 public:
35  virtual bool containsURL(const UChar* unicode, unsigned length) = 0;
36 };
37 
38 class WebCoreHistory {
39 public:
40  static void setHistoryProvider(WebCoreHistoryProvider*);
41  static WebCoreHistoryProvider* historyProvider();
42 };
43 
44 }
45 
46 #endif
30794

WebCore/platform/wx/TemporaryLinkStubs.cpp

@@bool WebCore::cookiesEnabled(const Docum
113113static WebCore::Cursor localCursor;
114114const WebCore::Cursor& WebCore::moveCursor() { return localCursor; }
115115
116 namespace WebCore {
117  bool historyContains(const UChar*, unsigned) { return false; }
118 }
119 
120116void WebCore::findWordBoundary(UChar const* str,int len,int position,int* start, int* end) { notImplemented(); *start=position; *end=position; }
121117
122118PluginSet PluginDatabase::getPluginsInPaths() const { notImplemented(); return PluginSet(); }
30794

WebKit/ChangeLog

 12008-03-05 Darin Adler <darin@apple.com>
 2
 3 * WebKit.xcodeproj/project.pbxproj: Added WebHistoryInternal.h.
 4
152008-01-26 Greg Bolsinga <bolsinga@apple.com>
26
37 <rdar://problem/5708388> WebDashboardRegion.h duplicated between WebCore / WebKit
30794

WebKit/WebKit.xcodeproj/project.pbxproj

277277 9398112F0824BF01008DF038 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 830E81E005853AC000AD0891 /* Security.framework */; };
278278 93EB178D09F88D460091F8FF /* WebSystemInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 93EB178C09F88D460091F8FF /* WebSystemInterface.m */; };
279279 93EB178F09F88D510091F8FF /* WebSystemInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EB178E09F88D510091F8FF /* WebSystemInterface.h */; };
 280 93FDE9330D79CAF30074F029 /* WebHistoryInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDE9320D79CAF30074F029 /* WebHistoryInternal.h */; };
280281 A70936AF0B5608DC00CDB48E /* WebDragClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A70936AD0B5608DC00CDB48E /* WebDragClient.h */; };
281282 A70936B00B5608DC00CDB48E /* WebDragClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A70936AE0B5608DC00CDB48E /* WebDragClient.mm */; };
282283 A7D3C5BC0B5773C5002CA450 /* WebPasteboardHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D3C5BA0B5773C5002CA450 /* WebPasteboardHelper.h */; };

510511 93D623DD051E791F002F47DD /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = /usr/lib/libicucore.dylib; sourceTree = "<absolute>"; };
511512 93EB178C09F88D460091F8FF /* WebSystemInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebSystemInterface.m; sourceTree = "<group>"; };
512513 93EB178E09F88D510091F8FF /* WebSystemInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSystemInterface.h; sourceTree = "<group>"; };
 514 93FDE9320D79CAF30074F029 /* WebHistoryInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebHistoryInternal.h; sourceTree = "<group>"; };
513515 9CAE9D070252A4130ECA16EA /* WebPreferencesPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPreferencesPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
514516 9CE1F8A302A5C6F30ECA2ACD /* WebImageRendererFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebImageRendererFactory.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
515517 9CF0E249021361B00ECA16EA /* WebFramePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFramePrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };

820822 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */,
821823 65DA2608052CC18700A97B31 /* WebHistory.mm */,
822824 F520FB190221DEFD01C1A525 /* WebHistory.h */,
 825 93FDE9320D79CAF30074F029 /* WebHistoryInternal.h */,
823826 3944607F020F50ED0ECA1767 /* WebHistoryItem.h */,
824827 39446080020F50ED0ECA1767 /* WebHistoryItem.mm */,
825828 516F296F03A6C45A00CA2D3A /* WebHistoryItemInternal.h */,

13171320 9398109B0824BF01008DF038 /* WebViewInternal.h in Headers */,
13181321 939810710824BF01008DF038 /* WebViewPrivate.h in Headers */,
13191322 939810970824BF01008DF038 /* npfunctions.h in Headers */,
 1323 93FDE9330D79CAF30074F029 /* WebHistoryInternal.h in Headers */,
13201324 );
13211325 runOnlyForDeploymentPostprocessing = 0;
13221326 };
30794

WebKit/mac/ChangeLog

 12008-03-05 Darin Adler <darin@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 - fix http://bugs.webkit.org/show_bug.cgi?id=17526
 6 REGRESSION: iframes are added to Safari's History menu
 7 by separating the visited link machinery from global history
 8
 9 * History/WebHistory.mm: Moved WebHistoryPrivate inside this file.
 10 (-[WebHistoryPrivate removeItemFromDateCaches:]): Removed the underscore from this
 11 method name, since it's on a private object.
 12 (-[WebHistoryPrivate removeItemForURLString:]): Added a call to the
 13 PageGroup::removeAllVisitedLinks function if the last URL was removed.
 14 (-[WebHistoryPrivate addItemToDateCaches:]): Removed the underscore from this
 15 method name, since it's on a private object.
 16 (-[WebHistoryPrivate removeAllItems]): Call PageGroup::removeAllVisitedLinks.
 17 (-[WebHistoryPrivate ageLimitDate]): Removed the underscore from this
 18 method name, since it's on a private object.
 19 (-[WebHistoryPrivate loadHistoryGutsFromURL:savedItemsCount:collectDiscardedItemsInto:error:]):
 20 Ditto.
 21 (-[WebHistoryPrivate saveHistoryGuts:URL:error:]): Ditto. Also changed this
 22 to correctly return the error by using the newer version of writeToURL: and
 23 removed the FIXME about that.
 24 (-[WebHistoryPrivate addVisitedLinksToPageGroup:]): Added. Calls addVisitedLink
 25 for every link in the history.
 26 (-[WebHistory saveToURL:error:]): Removed the FIXME, since we do get the error now.
 27 (-[WebHistory addItem:]): Moved into the WebPrivate category.
 28 (-[WebHistory addItemForURL:]): Ditto.
 29 (-[WebHistory _addItemForURL:title:]): Added. Used for the normal case where we
 30 create an item and already know its title.
 31 (-[WebHistory ageLimitDate]): Moved into the WebPrivate category.
 32 (-[WebHistory containsItemForURLString:]): Ditto.
 33 (-[WebHistory removeItem:]): Ditto.
 34 (-[WebHistory setLastVisitedTimeInterval:forItem:]): Ditto.
 35 (-[WebHistory _itemForURLString:]): Ditto.
 36 (-[WebHistory _addVisitedLinksToPageGroup:]): Added. For use only inside WebKit.
 37
 38 * History/WebHistoryInternal.h: Added.
 39 * History/WebHistoryItemInternal.h: Tweaked formatting and includes.
 40 * History/WebHistoryPrivate.h: Moved the WebHistoryPrivate class out of this header.
 41 Also reorganized what was left behind.
 42
 43 * WebCoreSupport/WebChromeClient.h: Added populateVisitedLinks.
 44 * WebCoreSupport/WebChromeClient.mm:
 45 (WebChromeClient::populateVisitedLinks): Added a call to the new
 46 -[WebHistory _addVisitedLinksToPageGroup:] method.
 47
 48 * WebCoreSupport/WebFrameLoaderClient.mm:
 49 (WebFrameLoaderClient::updateGlobalHistory): Changed code to use the new
 50 -[WebHistory _addItemForURL:title:] method.
 51
1522008-03-04 Timothy Hatcher <timothy@apple.com>
253
354 Reviewed by Darin Adler.
30794

WebKit/mac/History/WebHistory.mm

11/*
2  * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
 2 * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727 */
2828
29 #import "WebHistory.h"
30 #import "WebHistoryPrivate.h"
 29#import "WebHistoryInternal.h"
3130
32 #import "WebHistoryItem.h"
3331#import "WebHistoryItemInternal.h"
34 #import "WebHistoryItemPrivate.h"
3532#import "WebKitLogging.h"
3633#import "WebNSURLExtras.h"
 34#import <WebCore/KURL.h>
 35#import <WebCore/Page.h>
 36#import <WebCore/PageGroup.h>
3737#import <Foundation/NSError.h>
3838#import <JavaScriptCore/Assertions.h>
39 #import <WebCore/WebCoreHistory.h>
40 #import <wtf/Vector.h>
 39#import <JavaScriptCore/HashMap.h>
 40#import <JavaScriptCore/RetainPtr.h>
 41#import <JavaScriptCore/Vector.h>
 42
 43using namespace WebCore;
 44
 45typedef int64_t WebHistoryDateKey;
 46typedef HashMap<WebHistoryDateKey, RetainPtr<NSMutableArray> > DateToEntriesMap;
4147
4248NSString *WebHistoryItemsAddedNotification = @"WebHistoryItemsAddedNotification";
4349NSString *WebHistoryItemsRemovedNotification = @"WebHistoryItemsRemovedNotification";

@@NSString *DatesArrayKey = @"WebHistoryDa
5460
5561#define currentFileVersion 1
5662
 63@interface WebHistoryPrivate : NSObject {
 64@private
 65 NSMutableDictionary *_entriesByURL;
 66 DateToEntriesMap* _entriesByDate;
 67 NSMutableArray *_orderedLastVisitedDays;
 68 BOOL itemLimitSet;
 69 int itemLimit;
 70 BOOL ageInDaysLimitSet;
 71 int ageInDaysLimit;
 72}
 73
 74- (void)addItem:(WebHistoryItem *)entry;
 75- (void)addItems:(NSArray *)newEntries;
 76- (BOOL)removeItem:(WebHistoryItem *)entry;
 77- (BOOL)removeItems:(NSArray *)entries;
 78- (BOOL)removeAllItems;
 79- (void)setLastVisitedTimeInterval:(NSTimeInterval)time forItem:(WebHistoryItem *)item;
 80
 81- (NSArray *)orderedLastVisitedDays;
 82- (NSArray *)orderedItemsLastVisitedOnDay:(NSCalendarDate *)calendarDate;
 83- (BOOL)containsURL:(NSURL *)URL;
 84- (BOOL)containsItemForURLString:(NSString *)URLString;
 85- (WebHistoryItem *)itemForURL:(NSURL *)URL;
 86- (WebHistoryItem *)itemForURLString:(NSString *)URLString;
 87
 88- (BOOL)loadFromURL:(NSURL *)URL collectDiscardedItemsInto:(NSMutableArray *)discardedItems error:(NSError **)error;
 89- (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error;
 90
 91- (NSCalendarDate *)ageLimitDate;
 92
 93- (void)setHistoryItemLimit:(int)limit;
 94- (int)historyItemLimit;
 95- (void)setHistoryAgeInDaysLimit:(int)limit;
 96- (int)historyAgeInDaysLimit;
 97
 98- (void)addVisitedLinksToPageGroup:(PageGroup&)group;
 99
 100@end
 101
57102@implementation WebHistoryPrivate
58103
59104#pragma mark OBJECT FRAMEWORK

@@NSString *DatesArrayKey = @"WebHistoryDa
69114
70115- (id)init
71116{
72  if (![super init]) {
 117 if (![super init])
73118 return nil;
74  }
75119
76120 _entriesByURL = [[NSMutableDictionary alloc] init];
77121 _entriesByDate = new DateToEntriesMap;

@@NSString *DatesArrayKey = @"WebHistoryDa
84128 [_entriesByURL release];
85129 [_orderedLastVisitedDays release];
86130 delete _entriesByDate;
87 
88131 [super dealloc];
89132}
90133

@@WebHistoryDateKey timeIntervalForBeginni
156199 [entriesForDate insertObject:entry atIndex:low];
157200}
158201
159 - (BOOL)_removeItemFromDateCaches:(WebHistoryItem *)entry
 202- (BOOL)removeItemFromDateCaches:(WebHistoryItem *)entry
160203{
161204 WebHistoryDateKey dateKey;
162205 BOOL foundDate = [self findKey:&dateKey forDay:[entry lastVisitedTimeInterval]];

@@WebHistoryDateKey timeIntervalForBeginni
179222 return YES;
180223}
181224
182 - (BOOL)removeItemForURLString: (NSString *)URLString
 225- (BOOL)removeItemForURLString:(NSString *)URLString
183226{
184  WebHistoryItem *entry = [_entriesByURL objectForKey: URLString];
185  if (entry == nil) {
 227 WebHistoryItem *entry = [_entriesByURL objectForKey:URLString];
 228 if (!entry)
186229 return NO;
187  }
188230
189  [_entriesByURL removeObjectForKey: URLString];
 231 [_entriesByURL removeObjectForKey:URLString];
190232
191233#if ASSERT_DISABLED
192  [self _removeItemFromDateCaches:entry];
 234 [self removeItemFromDateCaches:entry];
193235#else
194  BOOL itemWasInDateCaches = [self _removeItemFromDateCaches:entry];
 236 BOOL itemWasInDateCaches = [self removeItemFromDateCaches:entry];
195237 ASSERT(itemWasInDateCaches);
196238#endif
197239
 240 if (![_entriesByURL count])
 241 PageGroup::removeAllVisitedLinks();
 242
198243 return YES;
199244}
200245
201 - (void)_addItemToDateCaches:(WebHistoryItem *)entry
 246- (void)addItemToDateCaches:(WebHistoryItem *)entry
202247{
203248 WebHistoryDateKey dateKey;
204249 if ([self findKey:&dateKey forDay:[entry lastVisitedTimeInterval]])

@@WebHistoryDateKey timeIntervalForBeginni
235280 [oldEntry release];
236281 }
237282
238  [self _addItemToDateCaches:entry];
 283 [self addItemToDateCaches:entry];
239284 [_entriesByURL setObject:entry forKey:URLString];
240285}
241286

@@WebHistoryDateKey timeIntervalForBeginni
244289#if ASSERT_DISABLED
245290 [self _removeItemFromDateCaches:entry];
246291#else
247  BOOL entryWasPresent = [self _removeItemFromDateCaches:entry];
 292 BOOL entryWasPresent = [self removeItemFromDateCaches:entry];
248293 ASSERT(entryWasPresent);
249294#endif
250295
251296 [entry _setLastVisitedTimeInterval:time];
252  [self _addItemToDateCaches:entry];
 297 [self addItemToDateCaches:entry];
253298
254299 // Don't send notification until entry is back in the right place in the date caches,
255300 // since observers might fetch history by date when they receive the notification.

@@WebHistoryDateKey timeIntervalForBeginni
257302 postNotificationName:WebHistoryItemChangedNotification object:entry userInfo:nil];
258303}
259304
260 - (BOOL)removeItem: (WebHistoryItem *)entry
 305- (BOOL)removeItem:(WebHistoryItem *)entry
261306{
262  WebHistoryItem *matchingEntry;
263  NSString *URLString;
264 
265  URLString = [entry URLString];
 307 NSString *URLString = [entry URLString];
266308
267309 // If this exact object isn't stored, then make no change.
268310 // FIXME: Is this the right behavior if this entry isn't present, but another entry for the same URL is?
269311 // Maybe need to change the API to make something like removeEntryForURLString public instead.
270  matchingEntry = [_entriesByURL objectForKey: URLString];
271  if (matchingEntry != entry) {
 312 WebHistoryItem *matchingEntry = [_entriesByURL objectForKey:URLString];
 313 if (matchingEntry != entry)
272314 return NO;
273  }
274315
275  [self removeItemForURLString: URLString];
 316 [self removeItemForURLString:URLString];
276317
277318 return YES;
278319}
279320
280 - (BOOL)removeItems: (NSArray *)entries
 321- (BOOL)removeItems:(NSArray *)entries
281322{
282  int index, count;
283 
284  count = [entries count];
285  if (count == 0) {
 323 NSUInteger count = [entries count];
 324 if (!count)
286325 return NO;
287  }
288326
289  for (index = 0; index < count; ++index) {
 327 for (NSUInteger index = 0; index < count; ++index)
290328 [self removeItem:[entries objectAtIndex:index]];
291  }
292329
293330 return YES;
294331}
295332
296333- (BOOL)removeAllItems
297334{
298  if ([_entriesByURL count] == 0) {
 335 if (_entriesByDate->isEmpty())
299336 return NO;
300  }
301337
302338 _entriesByDate->clear();
303339 [_entriesByURL removeAllObjects];

@@WebHistoryDateKey timeIntervalForBeginni
306342 [_orderedLastVisitedDays release];
307343 _orderedLastVisitedDays = nil;
308344
 345 PageGroup::removeAllVisitedLinks();
 346
309347 return YES;
310348}
311349
312350- (void)addItems:(NSArray *)newEntries
313351{
314  NSEnumerator *enumerator;
315  WebHistoryItem *entry;
316 
317352 // There is no guarantee that the incoming entries are in any particular
318353 // order, but if this is called with a set of entries that were created by
319354 // iterating through the results of orderedLastVisitedDays and orderedItemsLastVisitedOnDayy
320355 // then they will be ordered chronologically from newest to oldest. We can make adding them
321356 // faster (fewer compares) by inserting them from oldest to newest.
322  enumerator = [newEntries reverseObjectEnumerator];
323  while ((entry = [enumerator nextObject]) != nil) {
 357 NSEnumerator *enumerator = [newEntries reverseObjectEnumerator];
 358 while (WebHistoryItem *entry = [enumerator nextObject])
324359 [self addItem:entry];
325  }
326360}
327361
328362#pragma mark DATE-BASED RETRIEVAL

@@WebHistoryDateKey timeIntervalForBeginni
349383 return _orderedLastVisitedDays;
350384}
351385
352 - (NSArray *)orderedItemsLastVisitedOnDay: (NSCalendarDate *)date
 386- (NSArray *)orderedItemsLastVisitedOnDay:(NSCalendarDate *)date
353387{
354388 WebHistoryDateKey dateKey;
355  if ([self findKey:&dateKey forDay:[date timeIntervalSinceReferenceDate]])
356  return _entriesByDate->get(dateKey).get();
357 
358  return nil;
 389 if (![self findKey:&dateKey forDay:[date timeIntervalSinceReferenceDate]])
 390 return nil;
 391 return _entriesByDate->get(dateKey).get();
359392}
360393
361394#pragma mark URL MATCHING
362395
363396- (WebHistoryItem *)itemForURLString:(NSString *)URLString
364397{
365  return [_entriesByURL objectForKey: URLString];
 398 return [_entriesByURL objectForKey:URLString];
366399}
367400
368 - (BOOL)containsItemForURLString: (NSString *)URLString
 401- (BOOL)containsItemForURLString:(NSString *)URLString
369402{
370403 return [self itemForURLString:URLString] != nil;
371404}
372405
373 - (BOOL)containsURL: (NSURL *)URL
 406- (BOOL)containsURL:(NSURL *)URL
374407{
375408 return [self itemForURLString:[URL _web_originalDataAsString]] != nil;
376409}

@@WebHistoryDateKey timeIntervalForBeginni
392425{
393426 if (ageInDaysLimitSet)
394427 return ageInDaysLimit;
395  return [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryAgeInDaysLimit"];
 428 return [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitHistoryAgeInDaysLimit"];
396429}
397430
398431- (void)setHistoryItemLimit:(int)limit

@@WebHistoryDateKey timeIntervalForBeginni
405438{
406439 if (itemLimitSet)
407440 return itemLimit;
408  return [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
 441 return [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitHistoryItemLimit"];
409442}
410443
411444// Return a date that marks the age limit for history entries saved to or
412445// loaded from disk. Any entry older than this item should be rejected.
413 - (NSCalendarDate *)_ageLimitDate
 446- (NSCalendarDate *)ageLimitDate
414447{
415448 return [[NSCalendarDate calendarDate] dateByAddingYears:0 months:0 days:-[self historyAgeInDaysLimit]
416449 hours:0 minutes:0 seconds:0];

@@WebHistoryDateKey timeIntervalForBeginni
440473 return arrayRep;
441474}
442475
443 - (BOOL)_loadHistoryGutsFromURL:(NSURL *)URL savedItemsCount:(int *)numberOfItemsLoaded collectDiscardedItemsInto:(NSMutableArray *)discardedItems error:(NSError **)error
 476- (BOOL)loadHistoryGutsFromURL:(NSURL *)URL savedItemsCount:(int *)numberOfItemsLoaded collectDiscardedItemsInto:(NSMutableArray *)discardedItems error:(NSError **)error
444477{
445478 *numberOfItemsLoaded = 0;
446479 NSDictionary *dictionary = nil;

@@WebHistoryDateKey timeIntervalForBeginni
474507 NSNumber *fileVersionObject = [dictionary objectForKey:FileVersionKey];
475508 int fileVersion;
476509 // we don't trust data obtained from elsewhere, so double-check
477  if (fileVersionObject != nil && [fileVersionObject isKindOfClass:[NSNumber class]]) {
478  fileVersion = [fileVersionObject intValue];
479  } else {
 510 if (!fileVersionObject || ![fileVersionObject isKindOfClass:[NSNumber class]]) {
480511 LOG_ERROR("history file version can't be determined, therefore not loading");
481512 return NO;
482513 }
 514 fileVersion = [fileVersionObject intValue];
483515 if (fileVersion > currentFileVersion) {
484516 LOG_ERROR("history file version is %d, newer than newest known version %d, therefore not loading", fileVersion, currentFileVersion);
485517 return NO;

@@WebHistoryDateKey timeIntervalForBeginni
488520 NSArray *array = [dictionary objectForKey:DatesArrayKey];
489521
490522 int itemCountLimit = [self historyItemLimit];
491  NSTimeInterval ageLimitDate = [[self _ageLimitDate] timeIntervalSinceReferenceDate];
 523 NSTimeInterval ageLimitDate = [[self ageLimitDate] timeIntervalSinceReferenceDate];
492524 NSEnumerator *enumerator = [array objectEnumerator];
493525 BOOL ageLimitPassed = NO;
494526 BOOL itemLimitPassed = NO;

@@WebHistoryDateKey timeIntervalForBeginni
530562
531563- (BOOL)loadFromURL:(NSURL *)URL collectDiscardedItemsInto:(NSMutableArray *)discardedItems error:(NSError **)error
532564{
533  int numberOfItems;
534  double start, duration;
535  BOOL result;
 565 double start = CFAbsoluteTimeGetCurrent();
536566
537  start = CFAbsoluteTimeGetCurrent();
538  result = [self _loadHistoryGutsFromURL:URL savedItemsCount:&numberOfItems collectDiscardedItemsInto:discardedItems error:error];
 567 int numberOfItems;
 568 if (![self loadHistoryGutsFromURL:URL savedItemsCount:&numberOfItems collectDiscardedItemsInto:discardedItems error:error])
 569 return NO;
539570
540  if (result) {
541  duration = CFAbsoluteTimeGetCurrent() - start;
542  LOG(Timing, "loading %d history entries from %@ took %f seconds",
543  numberOfItems, URL, duration);
544  }
 571 double duration = CFAbsoluteTimeGetCurrent() - start;
 572 LOG(Timing, "loading %d history entries from %@ took %f seconds", numberOfItems, URL, duration);
545573
546  return result;
 574 return YES;
547575}
548576
549 - (BOOL)_saveHistoryGuts: (int *)numberOfItemsSaved URL:(NSURL *)URL error:(NSError **)error
 577- (BOOL)saveHistoryGuts:(int *)numberOfItemsSaved URL:(NSURL *)URL error:(NSError **)error
550578{
551579 *numberOfItemsSaved = 0;
552580
553  // FIXME: Correctly report error when new API is ready.
554  if (error)
555  *error = nil;
556 
557581 NSArray *array = [self arrayRepresentation];
558582 NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
559583 array, DatesArrayKey,
560584 [NSNumber numberWithInt:currentFileVersion], FileVersionKey,
561585 nil];
562586 NSData *data = [NSPropertyListSerialization dataFromPropertyList:dictionary format:NSPropertyListBinaryFormat_v1_0 errorDescription:nil];
563  if (![data writeToURL:URL atomically:YES]) {
 587 if (![data writeToURL:URL options:0 error:error]) {
564588 LOG_ERROR("attempt to save %@ to %@ failed", dictionary, URL);
565589 return NO;
566590 }
567 
 591
568592 *numberOfItemsSaved = [array count];
569593 return YES;
570594}
571595
572596- (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error
573597{
574  int numberOfItems;
575  double start, duration;
576  BOOL result;
577 
578  start = CFAbsoluteTimeGetCurrent();
579  result = [self _saveHistoryGuts: &numberOfItems URL:URL error:error];
580 
581  if (result) {
582  duration = CFAbsoluteTimeGetCurrent() - start;
583  LOG(Timing, "saving %d history entries to %@ took %f seconds",
584  numberOfItems, URL, duration);
585  }
 598 double start = CFAbsoluteTimeGetCurrent();
586599
587  return result;
588 }
589 
590 @end
591 
592 @interface _WebCoreHistoryProvider : NSObject <WebCoreHistoryProvider>
593 {
594  WebHistory *history;
595 }
596 - initWithHistory: (WebHistory *)h;
597 @end
598 
599 @implementation _WebCoreHistoryProvider
600 - initWithHistory: (WebHistory *)h
601 {
602  history = [h retain];
603  return self;
604 }
 600 int numberOfItems;
 601 if (![self saveHistoryGuts:&numberOfItems URL:URL error:error])
 602 return NO;
605603
606 static inline bool matchLetter(char c, char lowercaseLetter)
607 {
608  return (c | 0x20) == lowercaseLetter;
609 }
 604 double duration = CFAbsoluteTimeGetCurrent() - start;
 605 LOG(Timing, "saving %d history entries to %@ took %f seconds", numberOfItems, URL, duration);
610606
611 static inline bool matchUnicodeLetter(UniChar c, UniChar lowercaseLetter)
612 {
613  return (c | 0x20) == lowercaseLetter;
 607 return YES;
614608}
615609
616 #define UNICODE_BUFFER_SIZE 1024
617 
618 - (BOOL)containsURL:(const UniChar *)unicode length:(unsigned)length
 610- (void)addVisitedLinksToPageGroup:(PageGroup&)group
619611{
620  const UniChar *unicodeStr = unicode;
621  UniChar staticStrBuffer[UNICODE_BUFFER_SIZE];
622  UniChar *strBuffer = NULL;
623  BOOL needToAddSlash = FALSE;
624 
625  if (length >= 6 &&
626  matchUnicodeLetter(unicode[0], 'h') &&
627  matchUnicodeLetter(unicode[1], 't') &&
628  matchUnicodeLetter(unicode[2], 't') &&
629  matchUnicodeLetter(unicode[3], 'p') &&
630  (unicode[4] == ':'
631  || (matchUnicodeLetter(unicode[4], 's') && unicode[5] == ':'))) {
632 
633  unsigned pos = unicode[4] == ':' ? 5 : 6;
634 
635  // skip possible initial two slashes
636  if (pos + 1 < length && unicode[pos] == '/' && unicode[pos + 1] == '/') {
637  pos += 2;
638  }
639 
640  while (pos < length && unicode[pos] != '/') {
641  pos++;
642  }
643 
644  if (pos == length) {
645  needToAddSlash = TRUE;
 612 NSEnumerator *enumerator = [_entriesByURL keyEnumerator];
 613 while (NSString *url = [enumerator nextObject]) {
 614 size_t length = [url length];
 615 const UChar* characters = CFStringGetCharactersPtr(reinterpret_cast<CFStringRef>(url));
 616 if (characters)
 617 group.addVisitedLink(characters, length);
 618 else {
 619 Vector<UChar, 512> buffer(length);
 620 [url getCharacters:buffer.data()];
 621 group.addVisitedLink(buffer.data(), length);
646622 }
647623 }
648 
649  if (needToAddSlash) {
650  if (length + 1 <= UNICODE_BUFFER_SIZE) {
651  strBuffer = staticStrBuffer;
652  } else {
653  strBuffer = (UniChar*)malloc(sizeof(UniChar) * (length + 1));
654  }
655  memcpy(strBuffer, unicode, 2 * length);
656  strBuffer[length] = '/';
657  length++;
658 
659  unicodeStr = strBuffer;
660  }
661 
662  CFStringRef str = CFStringCreateWithCharactersNoCopy(NULL, unicodeStr, length, kCFAllocatorNull);
663  BOOL result = [history containsItemForURLString:(id)str];
664  CFRelease(str);
665 
666  if (strBuffer != staticStrBuffer) {
667  free(strBuffer);
668  }
669 
670  return result;
671 }
672 
673 - (void)dealloc
674 {
675  [history release];
676  [super dealloc];
677624}
678625
679626@end

@@static inline bool matchUnicodeLetter(Un
685632 return _sharedHistory;
686633}
687634
688 
689 + (void)setOptionalSharedHistory: (WebHistory *)history
 635+ (void)setOptionalSharedHistory:(WebHistory *)history
690636{
691  // FIXME. Need to think about multiple instances of WebHistory per application
 637 // FIXME: Need to think about multiple instances of WebHistory per application
692638 // and correct synchronization of history file between applications.
693  [WebCoreHistory setHistoryProvider: [[[_WebCoreHistoryProvider alloc] initWithHistory: history] autorelease]];
694  if (_sharedHistory != history){
 639 if (_sharedHistory != history) {
695640 [_sharedHistory release];
696641 _sharedHistory = [history retain];
697642 }

@@static inline bool matchUnicodeLetter(Un
699644
700645- (id)init
701646{
702  if ((self = [super init]) != nil) {
703  _historyPrivate = [[WebHistoryPrivate alloc] init];
704  }
705 
 647 self = [super init];
 648 if (!self)
 649 return nil;
 650 _historyPrivate = [[WebHistoryPrivate alloc] init];
706651 return self;
707652}
708653

@@static inline bool matchUnicodeLetter(Un
718663{
719664 NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:entries, WebHistoryItemsKey, nil];
720665 [[NSNotificationCenter defaultCenter]
721  postNotificationName: name object: self userInfo: userInfo];
722 }
723 
724 - (WebHistoryItem *)addItemForURL: (NSURL *)URL
725 {
726  WebHistoryItem *entry = [[WebHistoryItem alloc] initWithURL:URL title:nil];
727  [entry _setLastVisitedTimeInterval: [NSDate timeIntervalSinceReferenceDate]];
728  [self addItem: entry];
729  [entry release];
730  return entry;
731 }
732 
733 
734 - (void)addItem: (WebHistoryItem *)entry
735 {
736  LOG (History, "adding %@", entry);
737  [_historyPrivate addItem: entry];
738  [self _sendNotification: WebHistoryItemsAddedNotification
739  entries: [NSArray arrayWithObject:entry]];
740 }
741 
742 - (void)removeItem: (WebHistoryItem *)entry
743 {
744  if ([_historyPrivate removeItem: entry]) {
745  [self _sendNotification: WebHistoryItemsRemovedNotification
746  entries: [NSArray arrayWithObject:entry]];
747  }
 666 postNotificationName:name object:self userInfo:userInfo];
748667}
749668
750 - (void)removeItems: (NSArray *)entries
 669- (void)removeItems:(NSArray *)entries
751670{
752671 if ([_historyPrivate removeItems:entries]) {
753  [self _sendNotification: WebHistoryItemsRemovedNotification
754  entries: entries];
 672 [self _sendNotification:WebHistoryItemsRemovedNotification
 673 entries:entries];
755674 }
756675}
757676

@@static inline bool matchUnicodeLetter(Un
759678{
760679 if ([_historyPrivate removeAllItems]) {
761680 [[NSNotificationCenter defaultCenter]
762  postNotificationName: WebHistoryAllItemsRemovedNotification
763  object: self];
 681 postNotificationName:WebHistoryAllItemsRemovedNotification
 682 object:self];
764683 }
765684}
766685
767686- (void)addItems:(NSArray *)newEntries
768687{
769688 [_historyPrivate addItems:newEntries];
770  [self _sendNotification: WebHistoryItemsAddedNotification
771  entries: newEntries];
772 }
773 
774 - (void)setLastVisitedTimeInterval:(NSTimeInterval)time forItem:(WebHistoryItem *)entry
775 {
776  [_historyPrivate setLastVisitedTimeInterval:time forItem:entry];
 689 [self _sendNotification:WebHistoryItemsAddedNotification
 690 entries:newEntries];
777691}
778692
779693#pragma mark DATE-BASED RETRIEVAL

@@static inline bool matchUnicodeLetter(Un
783697 return [_historyPrivate orderedLastVisitedDays];
784698}
785699
786 - (NSArray *)orderedItemsLastVisitedOnDay: (NSCalendarDate *)date
 700- (NSArray *)orderedItemsLastVisitedOnDay:(NSCalendarDate *)date
787701{
788  return [_historyPrivate orderedItemsLastVisitedOnDay: date];
 702 return [_historyPrivate orderedItemsLastVisitedOnDay:date];
789703}
790704
791705#pragma mark URL MATCHING
792706
793 - (BOOL)containsItemForURLString: (NSString *)URLString
 707- (BOOL)containsURL:(NSURL *)URL
794708{
795  return [_historyPrivate containsItemForURLString: URLString];
796 }
797 
798 - (BOOL)containsURL: (NSURL *)URL
799 {
800  return [_historyPrivate containsURL: URL];
 709 return [_historyPrivate containsURL:URL];
801710}
802711
803712- (WebHistoryItem *)itemForURL:(NSURL *)URL

@@static inline bool matchUnicodeLetter(Un
809718
810719- (BOOL)loadFromURL:(NSURL *)URL error:(NSError **)error
811720{
812  NSMutableArray *discardedItems = [NSMutableArray array];
813 
814  if ([_historyPrivate loadFromURL:URL collectDiscardedItemsInto:discardedItems error:error]) {
815  [[NSNotificationCenter defaultCenter]
816  postNotificationName:WebHistoryLoadedNotification
817  object:self];
818 
819  if ([discardedItems count] > 0)
820  [self _sendNotification:WebHistoryItemsDiscardedWhileLoadingNotification entries:discardedItems];
821 
822  return YES;
 721 NSMutableArray *discardedItems = [[NSMutableArray alloc] init];
 722 if (![_historyPrivate loadFromURL:URL collectDiscardedItemsInto:discardedItems error:error]) {
 723 [discardedItems release];
 724 return NO;
823725 }
824  return NO;
825 }
826726
827 - (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error
828 {
829  // FIXME: Use new foundation API to get error when ready.
830  if([_historyPrivate saveToURL:URL error:error]){
831  [[NSNotificationCenter defaultCenter]
832  postNotificationName: WebHistorySavedNotification
833  object: self];
834  return YES;
835  }
836  return NO;
837 }
 727 [[NSNotificationCenter defaultCenter]
 728 postNotificationName:WebHistoryLoadedNotification
 729 object:self];
838730
839 - (WebHistoryItem *)_itemForURLString:(NSString *)URLString
840 {
841  return [_historyPrivate itemForURLString: URLString];
 731 if ([discardedItems count])
 732 [self _sendNotification:WebHistoryItemsDiscardedWhileLoadingNotification entries:discardedItems];
 733
 734 [discardedItems release];
 735 return YES;
842736}
843737
844 - (NSCalendarDate*)ageLimitDate
 738- (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error
845739{
846  return [_historyPrivate _ageLimitDate];
 740 if (![_historyPrivate saveToURL:URL error:error])
 741 return NO;
 742 [[NSNotificationCenter defaultCenter]
 743 postNotificationName:WebHistorySavedNotification
 744 object:self];
 745 return YES;
847746}
848747
849748- (void)setHistoryItemLimit:(int)limit

@@static inline bool matchUnicodeLetter(Un
867766}
868767
869768@end
 769
 770@implementation WebHistory (WebPrivate)
 771
 772- (void)addItem:(WebHistoryItem *)entry
 773{
 774 LOG(History, "adding %@", entry);
 775 [_historyPrivate addItem:entry];
 776 [self _sendNotification:WebHistoryItemsAddedNotification
 777 entries:[NSArray arrayWithObject:entry]];
 778}
 779
 780- (WebHistoryItem *)addItemForURL:(NSURL *)URL
 781{
 782 WebHistoryItem *entry = [[WebHistoryItem alloc] initWithURL:URL title:nil];
 783 [entry _setLastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate]];
 784 [self addItem:entry];
 785 [entry release];
 786 return entry;
 787}
 788
 789- (NSCalendarDate *)ageLimitDate
 790{
 791 return [_historyPrivate ageLimitDate];
 792}
 793
 794- (BOOL)containsItemForURLString:(NSString *)URLString
 795{
 796 return [_historyPrivate containsItemForURLString:URLString];
 797}
 798
 799- (void)removeItem:(WebHistoryItem *)entry
 800{
 801 if ([_historyPrivate removeItem:entry]) {
 802 [self _sendNotification:WebHistoryItemsRemovedNotification
 803 entries:[NSArray arrayWithObject:entry]];
 804 }
 805}
 806
 807- (void)setLastVisitedTimeInterval:(NSTimeInterval)time forItem:(WebHistoryItem *)entry
 808{
 809 [_historyPrivate setLastVisitedTimeInterval:time forItem:entry];
 810}
 811
 812- (WebHistoryItem *)_itemForURLString:(NSString *)URLString
 813{
 814 return [_historyPrivate itemForURLString:URLString];
 815}
 816
 817@end
 818
 819@implementation WebHistory (WebInternal)
 820
 821- (void)_addItemForURL:(NSURL *)URL title:(NSString *)title
 822{
 823 WebHistoryItem *entry = [[WebHistoryItem alloc] initWithURL:URL title:title];
 824 [entry _setLastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate]];
 825 [self addItem:entry];
 826 [entry release];
 827}
 828
 829- (void)_addVisitedLinksToPageGroup:(WebCore::PageGroup&)group
 830{
 831 [_historyPrivate addVisitedLinksToPageGroup:group];
 832}
 833
 834@end
30794

WebKit/mac/History/WebHistoryInternal.h

 1/*
 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 14 * its contributors may be used to endorse or promote products derived
 15 * from this software without specific prior written permission.
 16 *
 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27 */
 28
 29#import "WebHistoryPrivate.h"
 30
 31namespace WebCore {
 32 class PageGroup;
 33}
 34
 35@interface WebHistory (WebInternal)
 36- (void)_addItemForURL:(NSURL *)URL title:(NSString *)title;
 37- (void)_addVisitedLinksToPageGroup:(WebCore::PageGroup&)group;
 38@end
0

WebKit/mac/History/WebHistoryItemInternal.h

11/*
2  * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727 */
2828
29 #import <Cocoa/Cocoa.h>
 29#import "WebHistoryItemPrivate.h"
3030
31 #import <WebKit/WebBackForwardList.h>
32 #import <WebKit/WebHistoryItem.h>
33 #import <wtf/PassRefPtr.h>
 31#import <JavaScriptCore/PassRefPtr.h>
3432
3533namespace WebCore {
3634 class HistoryItem;

@@extern void WKNotifyHistoryItemChanged()
5654
5755@end
5856
59 @interface WebBackForwardList (WebPrivate)
 57@interface WebBackForwardList (WebInternal)
6058- (void)_close;
6159@end
62 
63 
30794

WebKit/mac/History/WebHistoryPrivate.h

11/*
2  * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
 2 * Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727 */
2828
29 #import <Foundation/Foundation.h>
30 
3129#import <WebKit/WebHistory.h>
3230
33 @class WebHistoryItem;
34 @class NSError;
35 
36 #ifdef __cplusplus
37 #include <wtf/HashMap.h>
38 #include <wtf/RetainPtr.h>
39 
40 typedef int64_t WebHistoryDateKey;
41 typedef HashMap<WebHistoryDateKey, RetainPtr<NSMutableArray> > DateToEntriesMap;
42 #else
43 typedef struct DateToEntriesMap DateToEntriesMap;
44 #endif
45 
4631/*
4732 @constant WebHistoryItemsDiscardedWhileLoadingNotification Posted from loadFromURL:error:.
4833 This notification comes with a userInfo dictionary that contains the array of
49  items discarded due to the date limit or item limit. The key for the array is WebHistoryItemsKey.
 34 items discarded due to the date limit or item limit. The key for the array is WebHistoryItemsKey.
5035*/
51 // FIXME: This notification should become API in WebHistory.h
 36// FIXME: This notification should become public API.
5237extern NSString *WebHistoryItemsDiscardedWhileLoadingNotification;
5338
54 // FIXME: The WebHistoryPrivate interface should be in WebHistoryInternal.h or inside WebHistory.m
55 @interface WebHistoryPrivate : NSObject {
56 @private
57  NSMutableDictionary *_entriesByURL;
58  DateToEntriesMap* _entriesByDate;
59  NSMutableArray *_orderedLastVisitedDays;
60  BOOL itemLimitSet;
61  int itemLimit;
62  BOOL ageInDaysLimitSet;
63  int ageInDaysLimit;
64 }
65 
66 - (void)addItem:(WebHistoryItem *)entry;
67 - (void)addItems:(NSArray *)newEntries;
68 - (BOOL)removeItem:(WebHistoryItem *)entry;
69 - (BOOL)removeItems:(NSArray *)entries;
70 - (BOOL)removeAllItems;
71 - (void)setLastVisitedTimeInterval:(NSTimeInterval)time forItem:(WebHistoryItem *)item;
72 
73 - (NSArray *)orderedLastVisitedDays;
74 - (NSArray *)orderedItemsLastVisitedOnDay:(NSCalendarDate *)calendarDate;
75 - (BOOL)containsItemForURLString:(NSString *)URLString;
76 - (BOOL)containsURL:(NSURL *)URL;
77 - (WebHistoryItem *)itemForURL:(NSURL *)URL;
78 - (WebHistoryItem *)itemForURLString:(NSString *)URLString;
79 
80 - (BOOL)loadFromURL:(NSURL *)URL collectDiscardedItemsInto:(NSMutableArray *)discardedItems error:(NSError **)error;
81 - (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error;
82 
83 - (NSCalendarDate*)_ageLimitDate;
84 
85 - (void)setHistoryItemLimit:(int)limit;
86 - (int)historyItemLimit;
87 - (void)setHistoryAgeInDaysLimit:(int)limit;
88 - (int)historyAgeInDaysLimit;
89 
90 @end
91 
9239@interface WebHistory (WebPrivate)
9340
9441// FIXME: The following SPI is used by Safari. Should it be made into public API?
9542- (WebHistoryItem *)_itemForURLString:(NSString *)URLString;
9643
97 // FIXME: Safari doesn't use the following SPI, and it's used in WebKit only inside WebHistory.m.
98 // Should we move it into a FileInternal category inside WebHistory.m, or do we need it for other
99 // clients?
100 - (void)removeItem:(WebHistoryItem *)entry;
 44// FIXME: neither Safari nor WebKit use the following SPI -- do we still need them?
10145- (void)addItem:(WebHistoryItem *)entry;
102 - (BOOL)containsItemForURLString:(NSString *)URLString;
103 
104 // FIXME: Safari doesn't use the following SPI, but other WebKit classes do. Should we move it into
105 // a WebHistoryInternal.h, or do we need it for other clients?
10646- (WebHistoryItem *)addItemForURL:(NSURL *)URL;
107 // Change date on existing item
 47- (NSCalendarDate *)ageLimitDate;
 48- (BOOL)containsItemForURLString:(NSString *)URLString;
 49- (void)removeItem:(WebHistoryItem *)entry;
10850- (void)setLastVisitedTimeInterval:(NSTimeInterval)time forItem:(WebHistoryItem *)item;
10951
110 // FIXME: neither Safari nor WebKit use the following SPI -- do we still need it?
111 - (NSCalendarDate*)ageLimitDate;
112 
11352@end
30794

WebKit/mac/WebCoreSupport/WebChromeClient.h

@@public:
102102
103103 virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String& databaseName);
104104
 105 virtual void populateVisitedLinks();
 106
105107 virtual void dashboardRegionsChanged();
106108
107109private:
30794

WebKit/mac/WebCoreSupport/WebChromeClient.mm

3535#import "WebFrameView.h"
3636#import "WebHTMLView.h"
3737#import "WebHTMLViewPrivate.h"
 38#import "WebHistoryInternal.h"
3839#import "WebKitSystemInterface.h"
3940#import "WebNSURLRequestExtras.h"
40 #import "WebSecurityOriginPrivate.h"
4141#import "WebSecurityOriginInternal.h"
4242#import "WebUIDelegate.h"
4343#import "WebUIDelegatePrivate.h"

4949#import <WebCore/FrameLoadRequest.h>
5050#import <WebCore/HitTestResult.h>
5151#import <WebCore/IntRect.h>
 52#import <WebCore/Page.h>
5253#import <WebCore/PlatformScreen.h>
5354#import <WebCore/PlatformString.h>
5455#import <WebCore/ResourceRequest.h>

@@void WebChromeClient::exceededDatabaseQu
425426 CallUIDelegate(m_webView, @selector(webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:), kit(frame), webOrigin, (NSString *)databaseName);
426427 [webOrigin release];
427428}
 429
 430void WebChromeClient::populateVisitedLinks()
 431{
 432 [[WebHistory optionalSharedHistory] _addVisitedLinksToPageGroup:[m_webView page]->group()];
 433}
428434
429435void WebChromeClient::dashboardRegionsChanged()
430436{
30794

WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

5151#import "WebHTMLRepresentationPrivate.h"
5252#import "WebHTMLViewInternal.h"
5353#import "WebHistoryItemInternal.h"
54 #import "WebHistoryItemPrivate.h"
55 #import "WebHistoryPrivate.h"
 54#import "WebHistoryInternal.h"
5655#import "WebIconDatabaseInternal.h"
5756#import "WebKitErrorsPrivate.h"
5857#import "WebKitLogging.h"

@@void WebFrameLoaderClient::finalSetupFor
723722void WebFrameLoaderClient::updateGlobalHistory(const KURL& url)
724723{
725724 NSURL *cocoaURL = url;
726  WebHistoryItem *entry = [[WebHistory optionalSharedHistory] addItemForURL:cocoaURL];
727725 const String& pageTitle = core(m_webFrame.get())->loader()->documentLoader()->title();
728  if (!pageTitle.isEmpty())
729  [entry setTitle:pageTitle];
 726 [[WebHistory optionalSharedHistory] _addItemForURL:cocoaURL title:pageTitle];
730727}
731728
732729bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const
30794

WebKit/win/ChangeLog

 12008-03-05 Darin Adler <darin@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 - fix http://bugs.webkit.org/show_bug.cgi?id=17526
 6 REGRESSION: iframes are added to Safari's History menu
 7 by separating the visited link machinery from global history
 8
 9 * WebCoreSupport/WebChromeClient.cpp:
 10 (WebChromeClient::populateVisitedLinks): Added a call to the new
 11 WebHistory::addVisitedLinksToPageGroup function.
 12 * WebCoreSupport/WebChromeClient.h: Added populateVisitedLinks.
 13 Also fixed the webView function to be non-virtual.
 14
 15 * WebCoreSupport/WebFrameLoaderClient.cpp:
 16 (WebFrameLoaderClient::updateGlobalHistory): Changed to use the
 17 new WebHistory::addItem function.
 18 (WebFrameLoaderClient::webHistory): Changed to return a WebHistory*,
 19 there's no reason to AddRef the result from this function.
 20 * WebCoreSupport/WebFrameLoaderClient.h: Ditto.
 21
 22 * WebHistory.cpp: Removed IWebHistoryPrivate and _WebCoreHistoryProvider.
 23 (WebHistory::QueryInterface): Removed IWebHistoryPrivate.
 24 (sharedHistoryStorage): Added.
 25 (WebHistory::sharedHistory): Added.
 26 (WebHistory::optionalSharedHistory): Changed to use sharedHistory().
 27 (WebHistory::setOptionalSharedHistory): Changed to require a WebHistory
 28 object, not just an IWebHistory.
 29 (WebHistory::removeAllItems): Call PageGroup::removeAllVisitedLinks.
 30 (WebHistory::addItem): Changed parameter types since this is called with
 31 arguments from WebCore -- at some point this could allow better efficiency.
 32 (WebHistory::removeItemForURLString): Call PageGroup::removeAllVisitedLinks
 33 if the last URL is being removed.
 34 (addVisitedLinkToPageGroup): Added. Helper. Adds a single link to a group's
 35 visited link set.
 36 (WebHistory::addVisitedLinksToPageGroup): Added. Adds all links to a group's
 37 visited link.
 38 * WebHistory.h: Removed IWebHistoryPrivate. Removed optionalSharedHistoryInternal
 39 and added sharedHistory. Replaced addItemForURL and containsItemForURLString with
 40 non-virtual addItem and addVisitedLinksToPageGroup functions.
 41
1422008-03-04 Sam Weinig <sam@webkit.org>
243
344 Reviewed by Mark Rowe.
30794

WebKit/win/WebHistory.cpp

3535#include "WebNotificationCenter.h"
3636#include "WebPreferences.h"
3737#include <CoreFoundation/CoreFoundation.h>
38 #include <WebCore/WebCoreHistory.h>
3938#pragma warning( push, 0 )
4039#include <wtf/Vector.h>
 40#include <WebCore/KURL.h>
 41#include <WebCore/PageGroup.h>
4142#pragma warning( pop )
4243
 44using namespace WebCore;
 45
4346CFStringRef DatesArrayKey = CFSTR("WebHistoryDates");
4447CFStringRef FileVersionKey = CFSTR("WebHistoryFileVersion");
4548
46 const IID IID_IWebHistoryPrivate = { 0x3de04e59, 0x93f9, 0x4369, { 0x8b, 0x43, 0x97, 0x64, 0x58, 0xd7, 0xe3, 0x19 } };
47 
4849#define currentFileVersion 1
4950
50 class _WebCoreHistoryProvider : public WebCore::WebCoreHistoryProvider {
51 public:
52  _WebCoreHistoryProvider(IWebHistory* history);
53  ~_WebCoreHistoryProvider();
54 
55  virtual bool containsURL(const UChar* unicode, unsigned length);
56 
57 private:
58  IWebHistory* m_history;
59  IWebHistoryPrivate* m_historyPrivate;
60 };
61 
6251static bool areEqualOrClose(double d1, double d2)
6352{
6453 double diff = d1-d2;

@@static void releaseUserInfo(CFDictionary
9786
9887// WebHistory -----------------------------------------------------------------
9988
100 IWebHistory* WebHistory::m_optionalSharedHistory = 0;
101 
10289WebHistory::WebHistory()
10390: m_refCount(0)
10491, m_preferences(0)

@@HRESULT STDMETHODCALLTYPE WebHistory::Qu
159146 *ppvObject = static_cast<IWebHistory*>(this);
160147 else if (IsEqualGUID(riid, IID_IWebHistory))
161148 *ppvObject = static_cast<IWebHistory*>(this);
162  else if (IsEqualGUID(riid, IID_IWebHistoryPrivate))
163  *ppvObject = static_cast<IWebHistoryPrivate*>(this);
164149 else
165150 return E_NOINTERFACE;
166151

@@ULONG STDMETHODCALLTYPE WebHistory::Rele
184169
185170// IWebHistory ----------------------------------------------------------------
186171
 172static inline COMPtr<WebHistory>& sharedHistoryStorage()
 173{
 174 static COMPtr<WebHistory> sharedHistory;
 175 return sharedHistory;
 176}
 177
 178WebHistory* WebHistory::sharedHistory()
 179{
 180 return sharedHistoryStorage().get();
 181}
 182
187183HRESULT STDMETHODCALLTYPE WebHistory::optionalSharedHistory(
188184 /* [retval][out] */ IWebHistory** history)
189185{
190  *history = m_optionalSharedHistory;
191  if (m_optionalSharedHistory)
192  m_optionalSharedHistory->AddRef();
193 
 186 *history = sharedHistory();
 187 if (*history)
 188 (*history)->AddRef();
194189 return S_OK;
195190}
196191
197192HRESULT STDMETHODCALLTYPE WebHistory::setOptionalSharedHistory(
198193 /* [in] */ IWebHistory* history)
199194{
200  if (m_optionalSharedHistory) {
201  m_optionalSharedHistory->Release();
202  m_optionalSharedHistory = 0;
203  }
204 
205  _WebCoreHistoryProvider* coreHistory = 0;
206  m_optionalSharedHistory = history;
207  if (history) {
208  history->AddRef();
209  coreHistory = new _WebCoreHistoryProvider(history);
210  }
211  WebCore::WebCoreHistory::setHistoryProvider(coreHistory);
212 
 195 sharedHistoryStorage().query(history);
213196 return S_OK;
214197}
215198

@@HRESULT STDMETHODCALLTYPE WebHistory::re
467450 CFArrayRemoveAllValues(m_datesWithEntries.get());
468451 CFDictionaryRemoveAllValues(m_entriesByURL.get());
469452
 453 PageGroup::removeAllVisitedLinks();
 454
470455 return postNotification(kWebHistoryAllItemsRemovedNotification);
471456}
472457

@@HRESULT WebHistory::addItem(IWebHistoryI
646631 return hr;
647632}
648633
649 HRESULT WebHistory::addItemForURL(BSTR url, BSTR title)
 634void WebHistory::addItem(const KURL& url, const String& title)
650635{
651636 COMPtr<WebHistoryItem> item(AdoptCOM, WebHistoryItem::createInstance());
652637 if (!item)
653  return E_FAIL;
 638 return;
654639
655640 SYSTEMTIME currentTime;
656641 GetSystemTime(&currentTime);
657642 DATE lastVisited;
658643 if (!SystemTimeToVariantTime(&currentTime, &lastVisited))
659  return E_FAIL;
 644 return;
660645
661  HRESULT hr = item->initWithURLString(url, title, 0);
 646 HRESULT hr = item->initWithURLString(BString(url.string()), BString(title), 0);
662647 if (FAILED(hr))
663  return hr;
 648 return;
664649
665650 hr = item->setLastVisitedTimeInterval(lastVisited); // also increments visitedCount
666651 if (FAILED(hr))
667  return hr;
 652 return;
668653
669  return addItem(item.get());
 654 addItem(item.get());
670655}
671656
672657HRESULT WebHistory::itemForURLString(

@@HRESULT STDMETHODCALLTYPE WebHistory::it
694679 return itemForURLString(urlString.get(), item);
695680}
696681
697 HRESULT WebHistory::containsItemForURLString(
698  /* [in] */ void* urlCFString,
699  /* [retval][out] */ BOOL* contains)
700 {
701  IWebHistoryItem* item = 0;
702  HRESULT hr;
703  if (SUCCEEDED(hr = itemForURLString((CFStringRef)urlCFString, &item))) {
704  *contains = TRUE;
705  // itemForURLString refs the returned item, so we need to balance that
706  item->Release();
707  } else
708  *contains = FALSE;
709 
710  return hr;
711 }
712 
713682HRESULT WebHistory::removeItemForURLString(CFStringRef urlString)
714683{
715684 IWebHistoryItem* entry = (IWebHistoryItem*) CFDictionaryGetValue(m_entriesByURL.get(), urlString);

@@HRESULT WebHistory::removeItemForURLStri
719688 HRESULT hr = removeItemFromDateCaches(entry);
720689 CFDictionaryRemoveValue(m_entriesByURL.get(), urlString);
721690
 691 if (!CFDictionaryGetCount(m_entriesByURL.get()))
 692 PageGroup::removeAllVisitedLinks();
 693
722694 return hr;
723695}
724696

@@HRESULT WebHistory::ageLimitDate(CFAbsol
856828 return S_OK;
857829}
858830
859 IWebHistoryPrivate* WebHistory::optionalSharedHistoryInternal()
860 {
861  if (!m_optionalSharedHistory)
862  return 0;
863 
864  IWebHistoryPrivate* historyPrivate;
865  if (FAILED(m_optionalSharedHistory->QueryInterface(IID_IWebHistoryPrivate, (void**)&historyPrivate)))
866  return 0;
867 
868  historyPrivate->Release(); // don't add an additional ref for this internal call
869  return historyPrivate;
870 }
871 
872 // _WebCoreHistoryProvider ----------------------------------------------------------------
873 
874 _WebCoreHistoryProvider::_WebCoreHistoryProvider(IWebHistory* history)
875  : m_history(history)
876  , m_historyPrivate(0)
 831static void addVisitedLinkToPageGroup(const void* key, const void*, void* context)
877832{
878 }
 833 CFStringRef url = static_cast<CFStringRef>(key);
 834 PageGroup* group = static_cast<PageGroup*>(context);
879835
880 _WebCoreHistoryProvider::~_WebCoreHistoryProvider()
881 {
882 }
883 
884 static inline bool matchLetter(char c, char lowercaseLetter)
885 {
886  return (c | 0x20) == lowercaseLetter;
887 }
888 
889 static inline bool matchUnicodeLetter(UniChar c, UniChar lowercaseLetter)
890 {
891  return (c | 0x20) == lowercaseLetter;
 836 CFIndex length = CFStringGetLength(url);
 837 const UChar* characters = reinterpret_cast<const UChar*>(CFStringGetCharactersPtr(url));
 838 if (characters)
 839 group->addVisitedLink(characters, length);
 840 else {
 841 Vector<UChar, 512> buffer(length);
 842 CFStringGetCharacters(url, CFRangeMake(0, length), reinterpret_cast<UniChar*>(buffer.data()));
 843 group->addVisitedLink(buffer.data(), length);
 844 }
892845}
893846
894 bool _WebCoreHistoryProvider::containsURL(const UChar* unicode, unsigned length)
 847void WebHistory::addVisitedLinksToPageGroup(PageGroup& group)
895848{
896  const int bufferSize = 1024;
897  const UChar *unicodeStr = unicode;
898  UChar staticStrBuffer[bufferSize];
899  UChar *strBuffer = 0;
900  bool needToAddSlash = false;
901 
902  if (length >= 6 &&
903  matchUnicodeLetter(unicode[0], 'h') &&
904  matchUnicodeLetter(unicode[1], 't') &&
905  matchUnicodeLetter(unicode[2], 't') &&
906  matchUnicodeLetter(unicode[3], 'p') &&
907  (unicode[4] == ':'
908  || (matchUnicodeLetter(unicode[4], 's') && unicode[5] == ':'))) {
909 
910  unsigned pos = unicode[4] == ':' ? 5 : 6;
911 
912  // skip possible initial two slashes
913  if (pos + 1 < length && unicode[pos] == '/' && unicode[pos + 1] == '/')
914  pos += 2;
915 
916  while (pos < length && unicode[pos] != '/')
917  pos++;
918 
919  if (pos == length)
920  needToAddSlash = true;
921  }
922 
923  if (needToAddSlash) {
924  if (length + 1 <= bufferSize)
925  strBuffer = staticStrBuffer;
926  else
927  strBuffer = (UChar*)malloc(sizeof(UChar) * (length + 1));
928  memcpy(strBuffer, unicode, 2 * length);
929  strBuffer[length] = '/';
930  length++;
931 
932  unicodeStr = strBuffer;
933  }
934 
935  if (!m_historyPrivate) {
936  if (SUCCEEDED(m_history->QueryInterface(IID_IWebHistoryPrivate, (void**)&m_historyPrivate))) {
937  // don't hold a ref - we're owned by IWebHistory/IWebHistoryPrivate
938  m_historyPrivate->Release();
939  } else {
940  if (strBuffer != staticStrBuffer)
941  free(strBuffer);
942  m_historyPrivate = 0;
943  return false;
944  }
945  }
946 
947  CFStringRef str = CFStringCreateWithCharactersNoCopy(NULL, (const UniChar*)unicodeStr, length, kCFAllocatorNull);
948  BOOL result = FALSE;
949  m_historyPrivate->containsItemForURLString((void*)str, &result);
950  CFRelease(str);
951 
952  if (strBuffer != staticStrBuffer)
953  free(strBuffer);
954 
955  return !!result;
 849 CFDictionaryApplyFunction(m_entriesByURL.get(), addVisitedLinkToPageGroup, &group);
956850}
30794

WebKit/win/WebHistory.h

11/*
2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

3232#include <CoreFoundation/CoreFoundation.h>
3333#include <wtf/RetainPtr.h>
3434
35 //-----------------------------------------------------------------------------
36 
37 // {3DE04E59-93F9-4369-8B43-976458D7E319}
38 DEFINE_GUID(IID_IWebHistoryPrivate, 0x3de04e59, 0x93f9, 0x4369, 0x8b, 0x43, 0x97, 0x64, 0x58, 0xd7, 0xe3, 0x19);
39 
40 interface IWebHistoryPrivate : public IUnknown
41 {
42 public:
43  virtual HRESULT STDMETHODCALLTYPE addItemForURL(
44  /* [in] */ BSTR url,
45  /* [in] */ BSTR title) = 0;
46  virtual HRESULT STDMETHODCALLTYPE containsItemForURLString(
47  /* [in] */ void* urlCFString,
48  /* [retval][out] */ BOOL* contains) = 0;
49 };
 35namespace WebCore {
 36 class KURL;
 37 class PageGroup;
 38 class String;
 39}
5040
5141//-----------------------------------------------------------------------------
5242
5343class WebPreferences;
5444
55 class WebHistory : public IWebHistory, IWebHistoryPrivate
56 {
 45class WebHistory : public IWebHistory {
5746public:
5847 static WebHistory* createInstance();
59 protected:
 48private:
6049 WebHistory();
6150 ~WebHistory();
6251

@@public:
119108 /* [retval][out] */ int* limit);
120109
121110 // WebHistory
122  static IWebHistoryPrivate* optionalSharedHistoryInternal();
123  virtual HRESULT STDMETHODCALLTYPE addItemForURL(BSTR url, BSTR title);
124  virtual HRESULT STDMETHODCALLTYPE containsItemForURLString(void* urlCFString, BOOL* contains);
 111 static WebHistory* sharedHistory();
 112 void addItem(const WebCore::KURL&, const WebCore::String&);
 113 void addVisitedLinksToPageGroup(WebCore::PageGroup&);
125114
126 protected:
 115private:
127116 enum NotificationType
128117 {
129118 kWebHistoryItemsAddedNotification = 0,

@@protected:
150139 BSTR getNotificationString(NotificationType notifyType);
151140 HRESULT itemForURLString(CFStringRef urlString, IWebHistoryItem** item);
152141
153 protected:
154142 ULONG m_refCount;
155143 RetainPtr<CFMutableDictionaryRef> m_entriesByURL;
156144 RetainPtr<CFMutableArrayRef> m_datesWithEntries;
157145 RetainPtr<CFMutableArrayRef> m_entriesByDate;
158146 COMPtr<WebPreferences> m_preferences;
159  static IWebHistory* m_optionalSharedHistory;
160147};
161148
162149#endif
30794

WebKit/win/WebCoreSupport/WebChromeClient.cpp

11/*
2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

2828
2929#include "WebElementPropertyBag.h"
3030#include "WebFrame.h"
 31#include "WebHistory.h"
3132#include "WebMutableURLRequest.h"
3233#include "WebSecurityOrigin.h"
3334#include "WebView.h"

3738#include <WebCore/FloatRect.h>
3839#include <WebCore/FrameLoadRequest.h>
3940#include <WebCore/FrameView.h>
 41#include <WebCore/Page.h>
4042#include <WebCore/WindowFeatures.h>
4143#pragma warning(pop)
4244

@@void WebChromeClient::exceededDatabaseQu
496498 }
497499}
498500
 501void WebChromeClient::populateVisitedLinks()
 502{
 503 WebHistory::sharedHistory()->addVisitedLinksToPageGroup(m_webView->page()->group());
 504}
 505
499506COMPtr<IWebUIDelegate> WebChromeClient::uiDelegate()
500507{
501508 COMPtr<IWebUIDelegate> delegate;
30794

WebKit/win/WebCoreSupport/WebChromeClient.h

@@public:
100100
101101 virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String&);
102102
103  virtual WebView* webView() const { return m_webView; }
 103 virtual void populateVisitedLinks();
 104
 105 WebView* webView() const { return m_webView; }
104106
105107private:
106108 COMPtr<IWebUIDelegate> uiDelegate();
30794

WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp

5656#include <WebCore/PluginPackage.h>
5757#include <WebCore/PluginView.h>
5858#include <WebCore/RenderPart.h>
 59#include <WebCore/ResourceHandle.h>
5960#pragma warning(pop)
6061
6162using namespace WebCore;

@@void WebFrameLoaderClient::finishedLoadi
428429
429430void WebFrameLoaderClient::updateGlobalHistory(const KURL& url)
430431{
431  COMPtr<WebHistory> history = webHistory();
432  if (!history)
433  return;
434  history->addItemForURL(BString(url.string()), 0);
 432 WebHistory::sharedHistory()->addItem(url, core(m_webFrame)->loader()->documentLoader()->title());
435433}
436434
437435bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem*) const

@@void WebFrameLoaderClient::redirectDataT
697695 m_pluginView = static_cast<PluginView*>(pluginWidget);
698696}
699697
700 COMPtr<WebHistory> WebFrameLoaderClient::webHistory() const
 698WebHistory* WebFrameLoaderClient::webHistory() const
701699{
702700 if (m_webFrame != m_webFrame->webView()->topLevelFrame())
703701 return 0;
704702
705  IWebHistoryPrivate* historyInternal = WebHistory::optionalSharedHistoryInternal(); // does not add a ref
706  if (!historyInternal)
707  return 0;
708 
709  return COMPtr<WebHistory>(Query, historyInternal);
 703 return WebHistory::sharedHistory();
710704}
30794

WebKit/win/WebCoreSupport/WebFrameLoaderClient.h

@@private:
108108 PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL&, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*, const WebCore::String& referrer);
109109 void loadURLIntoChild(const WebCore::KURL&, const WebCore::String& referrer, WebFrame* childFrame);
110110 void receivedData(const char*, int, const WebCore::String&);
111  COMPtr<WebHistory> webHistory() const;
 111 WebHistory* webHistory() const;
112112
113113 WebFrame* m_webFrame;
114114
30794