Commit 2060803d authored by darin@apple.com's avatar darin@apple.com

WebCore:

        Reviewed by Mitz.

        - fix http://bugs.webkit.org/show_bug.cgi?id=17526
          REGRESSION: iframes are added to Safari's History menu
          by separating the visited link machinery from global history

        This should also make page loading faster due to more efficient visited link coloring.

        * WebCore.base.exp: Updated.
        * WebCore.vcproj/WebCore.vcproj: Added PageGroup.h/cpp, removed GlobalHistory.h/cpp.
        * WebCore.xcodeproj/project.pbxproj: Ditto. Also removed WebCoreHistory.h/m.

        * css/CSSStyleSelector.cpp: Updated includes.
        (WebCore::CSSStyleSelector::initElementAndPseudoState): Eliminated code to set
        currentEncodedURL.
        (WebCore::checkPseudoState): Moved most of the code inside a new
        PageGroup::isLinkVisited function.
        (WebCore::CSSStyleSelector::canShareStyleWithElement): Tightened code a bit by using
        references and only getting colors when needed.
        (WebCore::CSSStyleSelector::getColorFromPrimitiveValue): Ditto.
        * css/CSSStyleSelector.h: Removed EncodedURL, m_encodedURL, and setEncodedURL.

        * dom/Document.cpp:
        (WebCore::Document::attach): Removed call to setEncodedURL.
        (WebCore::Document::setURL): Ditto.
        (WebCore::Document::recalcStyleSelector): Ditto.

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::addBackForwardItemClippedAtTarget): Changed code to use
        early exit idiom to be a little more readable.
        (WebCore::FrameLoader::urlsMatchItem): Change to use a reference for slightly
        better efficiency.
        (WebCore::FrameLoader::goToItem): Use early exit idiom to be a little more
        readable.
        (WebCore::FrameLoader::updateHistoryForStandardLoad): Moved history code back
        in here and got rid of the helper function updateGlobalHistory, restoring the
        logic before r30549. Also added a call to the new addVisitedLink function.
        (WebCore::FrameLoader::updateHistoryForClientRedirect): Added code to call
        addVisitedLink here.
        (WebCore::FrameLoader::updateHistoryForBackForwardNavigation): Removed comment.
        (WebCore::FrameLoader::updateHistoryForReload): Removed call to
        updateGlobalHistory; we can just go without updating global history or
        visited links here, at least for now, since it's not clear that a reload
        is a "history event".
        (WebCore::FrameLoader::updateHistoryForRedirectWithLockedHistory): Moved
        history code back where it was, and added the call to addVisitedLink, just
        as in updateHistoryForStandardLoad above.
        * loader/FrameLoader.h: Removed updateGlobalHistory function.

        * page/Chrome.cpp:
        (WebCore::ChromeClient::populateVisitedLinks): Added. Empty placeholder so we
        don't have to implement this for every port all at once.
        (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): Changed to use the
        new PageGroup class.
        * page/ChromeClient.h: Added populateVisitedLinks function, used to fill the
        visited links set from the global history at application startup time.

        * page/FrameTree.cpp:
        (WebCore::FrameTree::find): Updated to use the new PageGroup class.

        * page/GlobalHistory.h: Removed.
        * page/win/GlobalHistoryWin.cpp: Removed.
        * page/mac/GlobalHistoryMac.mm: Removed.
        * platform/mac/WebCoreHistory.h: Removed.
        * platform/mac/WebCoreHistory.m: Removed.
        * platform/win/WebCoreHistory.cpp: Removed.
        * platform/win/WebCoreHistory.h: Removed.

        * page/Page.cpp:
        (WebCore::Page::Page): Set m_group to 0.
        (WebCore::Page::setGroupName): Set up m_group. If the page is not in any
        group, set it to 0 for now to postpone the cost of creating a group.
        (WebCore::Page::initGroup): Added. Sets m_group to point to a single-page
        group; used when getting a group.
        (WebCore::Page::removeAllVisitedLinks): Added. Calls removeVisitedLinks
        on all page groups.
        * page/Page.h: Moved enums inside the WebCore namespace. Removed the
        frameNamespace function and instead added the group and groupPtr functions.

        * page/PageGroup.cpp: Added. Contains all the visited code from the
        CSSStyleSelector in the isVisitedLink function, but more efficient because
        we don't allocate memory for the buffer.
        * page/PageGroup.h: Added.

        * platform/gtk/TemporaryLinkStubs.cpp: Removed historyContains.
        * platform/qt/TemporaryLinkStubs.cpp: Removed unneeded include.
        * platform/wx/TemporaryLinkStubs.cpp: Removed historyContains.

WebKit:

        * WebKit.xcodeproj/project.pbxproj: Added WebHistoryInternal.h.

WebKit/mac:

        Reviewed by Mitz.

        - fix http://bugs.webkit.org/show_bug.cgi?id=17526
          REGRESSION: iframes are added to Safari's History menu
          by separating the visited link machinery from global history

        * History/WebHistory.mm: Moved WebHistoryPrivate inside this file.
        (-[WebHistoryPrivate removeItemFromDateCaches:]): Removed the underscore from this
        method name, since it's on a private object.
        (-[WebHistoryPrivate removeItemForURLString:]): Added a call to the
        PageGroup::removeAllVisitedLinks function if the last URL was removed.
        (-[WebHistoryPrivate addItemToDateCaches:]): Removed the underscore from this
        method name, since it's on a private object.
        (-[WebHistoryPrivate removeAllItems]): Call PageGroup::removeAllVisitedLinks.
        (-[WebHistoryPrivate ageLimitDate]): Removed the underscore from this
        method name, since it's on a private object.
        (-[WebHistoryPrivate loadHistoryGutsFromURL:savedItemsCount:collectDiscardedItemsInto:error:]):
        Ditto.
        (-[WebHistoryPrivate saveHistoryGuts:URL:error:]): Ditto. Also changed this
        to correctly return the error by using the newer version of writeToURL: and
        removed the FIXME about that.
        (-[WebHistoryPrivate addVisitedLinksToPageGroup:]): Added. Calls addVisitedLink
        for every link in the history.
        (-[WebHistory saveToURL:error:]): Removed the FIXME, since we do get the error now.
        (-[WebHistory addItem:]): Moved into the WebPrivate category.
        (-[WebHistory addItemForURL:]): Ditto.
        (-[WebHistory _addItemForURL:title:]): Added. Used for the normal case where we
        create an item and already know its title.
        (-[WebHistory ageLimitDate]): Moved into the WebPrivate category.
        (-[WebHistory containsItemForURLString:]): Ditto.
        (-[WebHistory removeItem:]): Ditto.
        (-[WebHistory setLastVisitedTimeInterval:forItem:]): Ditto.
        (-[WebHistory _itemForURLString:]): Ditto.
        (-[WebHistory _addVisitedLinksToPageGroup:]): Added. For use only inside WebKit.

        * History/WebHistoryInternal.h: Added.
        * History/WebHistoryItemInternal.h: Tweaked formatting and includes.
        * History/WebHistoryPrivate.h: Moved the WebHistoryPrivate class out of this header.
        Also reorganized what was left behind.

        * WebCoreSupport/WebChromeClient.h: Added populateVisitedLinks.
        * WebCoreSupport/WebChromeClient.mm:
        (WebChromeClient::populateVisitedLinks): Added a call to the new
        -[WebHistory _addVisitedLinksToPageGroup:] method.

        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::updateGlobalHistory): Changed code to use the new
        -[WebHistory _addItemForURL:title:] method.

WebKit/win:

        Reviewed by Mitz.

        - fix http://bugs.webkit.org/show_bug.cgi?id=17526
          REGRESSION: iframes are added to Safari's History menu
          by separating the visited link machinery from global history

        * WebCoreSupport/WebChromeClient.cpp:
        (WebChromeClient::populateVisitedLinks): Added a call to the new
        WebHistory::addVisitedLinksToPageGroup function.
        * WebCoreSupport/WebChromeClient.h: Added populateVisitedLinks.
        Also fixed the webView function to be non-virtual.

        * WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebFrameLoaderClient::updateGlobalHistory): Changed to use the
        new WebHistory::addItem function.
        (WebFrameLoaderClient::webHistory): Changed to return a WebHistory*,
        there's no reason to AddRef the result from this function.
        * WebCoreSupport/WebFrameLoaderClient.h: Ditto.

        * WebHistory.cpp: Removed IWebHistoryPrivate and _WebCoreHistoryProvider.
        (WebHistory::QueryInterface): Removed IWebHistoryPrivate.
        (sharedHistoryStorage): Added.
        (WebHistory::sharedHistory): Added.
        (WebHistory::optionalSharedHistory): Changed to use sharedHistory().
        (WebHistory::setOptionalSharedHistory): Changed to require a WebHistory
        object, not just an IWebHistory.
        (WebHistory::removeAllItems): Call PageGroup::removeAllVisitedLinks.
        (WebHistory::addItem): Changed parameter types since this is called with
        arguments from WebCore -- at some point this could allow better efficiency.
        (WebHistory::removeItemForURLString):  Call PageGroup::removeAllVisitedLinks
        if the last URL is being removed.
        (addVisitedLinkToPageGroup): Added. Helper. Adds a single link to a group's
        visited link set.
        (WebHistory::addVisitedLinksToPageGroup): Added. Adds all links to a group's
        visited link.
        * WebHistory.h: Removed IWebHistoryPrivate. Removed optionalSharedHistoryInternal
        and added sharedHistory. Replaced addItemForURL and containsItemForURLString with
        non-virtual addItem and addVisitedLinksToPageGroup functions.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cc636535
2008-03-06 Darin Adler <darin@apple.com>
Reviewed by Mitz.
- fix http://bugs.webkit.org/show_bug.cgi?id=17526
REGRESSION: iframes are added to Safari's History menu
by separating the visited link machinery from global history
This should also make page loading faster due to more efficient visited link coloring.
* WebCore.base.exp: Updated.
* WebCore.vcproj/WebCore.vcproj: Added PageGroup.h/cpp, removed GlobalHistory.h/cpp.
* WebCore.xcodeproj/project.pbxproj: Ditto. Also removed WebCoreHistory.h/m.
* css/CSSStyleSelector.cpp: Updated includes.
(WebCore::CSSStyleSelector::initElementAndPseudoState): Eliminated code to set
currentEncodedURL.
(WebCore::checkPseudoState): Moved most of the code inside a new
PageGroup::isLinkVisited function.
(WebCore::CSSStyleSelector::canShareStyleWithElement): Tightened code a bit by using
references and only getting colors when needed.
(WebCore::CSSStyleSelector::getColorFromPrimitiveValue): Ditto.
* css/CSSStyleSelector.h: Removed EncodedURL, m_encodedURL, and setEncodedURL.
* dom/Document.cpp:
(WebCore::Document::attach): Removed call to setEncodedURL.
(WebCore::Document::setURL): Ditto.
(WebCore::Document::recalcStyleSelector): Ditto.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::addBackForwardItemClippedAtTarget): Changed code to use
early exit idiom to be a little more readable.
(WebCore::FrameLoader::urlsMatchItem): Change to use a reference for slightly
better efficiency.
(WebCore::FrameLoader::goToItem): Use early exit idiom to be a little more
readable.
(WebCore::FrameLoader::updateHistoryForStandardLoad): Moved history code back
in here and got rid of the helper function updateGlobalHistory, restoring the
logic before r30549. Also added a call to the new addVisitedLink function.
(WebCore::FrameLoader::updateHistoryForClientRedirect): Added code to call
addVisitedLink here.
(WebCore::FrameLoader::updateHistoryForBackForwardNavigation): Removed comment.
(WebCore::FrameLoader::updateHistoryForReload): Removed call to
updateGlobalHistory; we can just go without updating global history or
visited links here, at least for now, since it's not clear that a reload
is a "history event".
(WebCore::FrameLoader::updateHistoryForRedirectWithLockedHistory): Moved
history code back where it was, and added the call to addVisitedLink, just
as in updateHistoryForStandardLoad above.
* loader/FrameLoader.h: Removed updateGlobalHistory function.
* page/Chrome.cpp:
(WebCore::ChromeClient::populateVisitedLinks): Added. Empty placeholder so we
don't have to implement this for every port all at once.
(WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): Changed to use the
new PageGroup class.
* page/ChromeClient.h: Added populateVisitedLinks function, used to fill the
visited links set from the global history at application startup time.
* page/FrameTree.cpp:
(WebCore::FrameTree::find): Updated to use the new PageGroup class.
* page/GlobalHistory.h: Removed.
* page/win/GlobalHistoryWin.cpp: Removed.
* page/mac/GlobalHistoryMac.mm: Removed.
* platform/mac/WebCoreHistory.h: Removed.
* platform/mac/WebCoreHistory.m: Removed.
* platform/win/WebCoreHistory.cpp: Removed.
* platform/win/WebCoreHistory.h: Removed.
* page/Page.cpp:
(WebCore::Page::Page): Set m_group to 0.
(WebCore::Page::setGroupName): Set up m_group. If the page is not in any
group, set it to 0 for now to postpone the cost of creating a group.
(WebCore::Page::initGroup): Added. Sets m_group to point to a single-page
group; used when getting a group.
(WebCore::Page::removeAllVisitedLinks): Added. Calls removeVisitedLinks
on all page groups.
* page/Page.h: Moved enums inside the WebCore namespace. Removed the
frameNamespace function and instead added the group and groupPtr functions.
* page/PageGroup.cpp: Added. Contains all the visited code from the
CSSStyleSelector in the isVisitedLink function, but more efficient because
we don't allocate memory for the buffer.
* page/PageGroup.h: Added.
* platform/gtk/TemporaryLinkStubs.cpp: Removed historyContains.
* platform/qt/TemporaryLinkStubs.cpp: Removed unneeded include.
* platform/wx/TemporaryLinkStubs.cpp: Removed historyContains.
2008-03-06 Mark Rowe <mrowe@apple.com>
Fix 64-bit Mac build.
......@@ -407,6 +407,7 @@ __ZN7WebCore4Page37setInLowQualityImageInterpolationModeEb
__ZN7WebCore4Page6goBackEv
__ZN7WebCore4Page8goToItemEPNS_11HistoryItemENS_13FrameLoadTypeE
__ZN7WebCore4Page9goForwardEv
__ZN7WebCore4Page9initGroupEv
__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientEPNS_15InspectorClientE
__ZN7WebCore4PageD1Ev
__ZN7WebCore5Cache11setDisabledEb
......@@ -563,6 +564,8 @@ __ZN7WebCore9HTMLNames7srcAttrE
__ZN7WebCore9HTMLNames8hrefAttrE
__ZN7WebCore9PageCache11setCapacityEi
__ZN7WebCore9PageCache27releaseAutoreleasedPagesNowEv
__ZN7WebCore9PageGroup14addVisitedLinkEPKtm
__ZN7WebCore9PageGroup21removeAllVisitedLinksEv
__ZN7WebCore9Selection22expandUsingGranularityENS_15TextGranularityE
__ZN7WebCore9TimerBase4stopEv
__ZN7WebCore9TimerBase5startEdd
......
......@@ -2754,10 +2754,6 @@
RelativePath="..\page\FrameView.h"
>
</File>
<File
RelativePath="..\bridge\GlobalHistory.h"
>
</File>
<File
RelativePath="..\page\History.cpp"
>
......@@ -2794,6 +2790,14 @@
RelativePath="..\page\Page.h"
>
</File>
<File
RelativePath="..\page\PageGroup.cpp"
>
</File>
<File
RelativePath="..\page\PageGroup.h"
>
</File>
<File
RelativePath="..\page\Plugin.h"
>
......@@ -2837,10 +2841,6 @@
RelativePath="..\page\win\FrameWin.h"
>
</File>
<File
RelativePath="..\page\win\GlobalHistoryWin.cpp"
>
</File>
<File
RelativePath="..\page\win\PageWin.cpp"
>
......@@ -3568,14 +3568,6 @@
RelativePath="..\platform\win\WCDataObject.h"
>
</File>
<File
RelativePath="..\platform\win\WebCoreHistory.cpp"
>
</File>
<File
RelativePath="..\platform\win\WebCoreHistory.h"
>
</File>
<File
RelativePath="..\platform\win\WebCoreTextRenderer.cpp"
>
......
This diff is collapsed.
......@@ -49,13 +49,14 @@
#include "FontValue.h"
#include "Frame.h"
#include "FrameView.h"
#include "GlobalHistory.h"
#include "HTMLDocument.h"
#include "HTMLElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "Page.h"
#include "PageGroup.h"
#include "Pair.h"
#include "Rect.h"
#include "RenderTheme.h"
......@@ -228,7 +229,6 @@ CSSStyleSheet* CSSStyleSelector::m_viewSourceSheet = 0;
CSSStyleSheet *CSSStyleSelector::m_svgSheet = 0;
#endif
static CSSStyleSelector::EncodedURL* currentEncodedURL = 0;
static PseudoState pseudoState;
static const MediaQueryEvaluator& screenEval()
......@@ -312,28 +312,10 @@ void CSSStyleSelector::init()
m_medium = 0;
}
void CSSStyleSelector::setEncodedURL(const KURL& url)
{
KURL u = url;
u.setQuery(String());
u.setRef(String());
m_encodedURL.file = u.string();
int pos = m_encodedURL.file.reverseFind('/');
m_encodedURL.path = m_encodedURL.file;
if (pos > 0) {
m_encodedURL.path.truncate(pos);
m_encodedURL.path.append('/');
}
u.setPath(String());
m_encodedURL.prefix = u.string();
}
CSSStyleSelector::~CSSStyleSelector()
{
delete m_medium;
::delete m_rootDefaultStyle;
delete m_rootDefaultStyle;
delete m_authorStyle;
delete m_userStyle;
}
......@@ -533,7 +515,6 @@ void CSSStyleSelector::initElementAndPseudoState(Element* e)
m_styledElement = static_cast<StyledElement*>(m_element);
else
m_styledElement = 0;
currentEncodedURL = &m_encodedURL;
pseudoState = PseudoUnknown;
}
......@@ -564,81 +545,7 @@ void CSSStyleSelector::initForStyleResolve(Element* e, RenderStyle* defaultParen
m_fontDirty = false;
}
static inline int findSlashDotDotSlash(const UChar* characters, size_t length)
{
unsigned loopLimit = length < 4 ? 0 : length - 3;
for (unsigned i = 0; i < loopLimit; ++i) {
if (characters[i] == '/' && characters[i + 1] == '.' && characters[i + 2] == '.' && characters[i + 3] == '/')
return i;
}
return -1;
}
static inline int findSlashSlash(const UChar* characters, size_t length, int position)
{
unsigned loopLimit = length < 2 ? 0 : length - 1;
for (unsigned i = position; i < loopLimit; ++i) {
if (characters[i] == '/' && characters[i + 1] == '/')
return i;
}
return -1;
}
static inline int findSlashDotSlash(const UChar* characters, size_t length)
{
unsigned loopLimit = length < 3 ? 0 : length - 2;
for (unsigned i = 0; i < loopLimit; ++i) {
if (characters[i] == '/' && characters[i + 1] == '.' && characters[i + 2] == '/')
return i;
}
return -1;
}
static inline bool containsColonSlashSlash(const UChar* characters, unsigned length)
{
unsigned loopLimit = length < 3 ? 0 : length - 2;
for (unsigned i = 0; i < loopLimit; ++i)
if (characters[i] == ':' && characters[i + 1] == '/' && characters[i + 2] == '/')
return true;
return false;
}
static void cleanPath(Vector<UChar, 512>& path)
{
int pos;
while ((pos = findSlashDotDotSlash(path.data(), path.size())) != -1) {
int prev = reverseFind(path.data(), path.size(), '/', pos - 1);
// don't remove the host, i.e. http://foo.org/../foo.html
if (prev < 0 || (prev > 3 && path[prev - 2] == ':' && path[prev - 1] == '/'))
path.remove(pos, 3);
else
path.remove(prev, pos - prev + 3);
}
// Don't remove "//" from an anchor identifier. -rjw
// Set refPos to -2 to mean "I haven't looked for the anchor yet".
// We don't want to waste a function call on the search for the the anchor
// in the vast majority of cases where there is no "//" in the path.
pos = 0;
int refPos = -2;
while ((pos = findSlashSlash(path.data(), path.size(), pos)) != -1) {
if (refPos == -2)
refPos = find(path.data(), path.size(), '#');
if (refPos > 0 && pos >= refPos)
break;
if (pos == 0 || path[pos - 1] != ':')
path.remove(pos);
else
pos += 2;
}
// FIXME: We don't want to remove "/./" from an anchor identifier either.
while ((pos = findSlashDotSlash(path.data(), path.size())) != -1)
path.remove(pos, 2);
}
static void checkPseudoState(Element *e, bool checkVisited = true)
static void checkPseudoState(Element* e, bool checkVisited = true)
{
if (!e->isLink()) {
pseudoState = PseudoNone;
......@@ -667,26 +574,21 @@ static void checkPseudoState(Element *e, bool checkVisited = true)
return;
}
const UChar* characters = attr->characters();
unsigned length = attr->length();
Document* document = e->document();
if (containsColonSlashSlash(characters, length)) {
// FIXME: Strange to not clean the path just beacause it has "://" in it.
pseudoState = historyContains(characters, length) ? PseudoVisited : PseudoLink;
Frame* frame = document->frame();
if (!frame) {
pseudoState = PseudoLink;
return;
}
Vector<UChar, 512> buffer;
if (length && characters[0] == '/') {
buffer.append(currentEncodedURL->prefix.characters(), currentEncodedURL->prefix.length());
} else if (length && characters[0] == '#') {
buffer.append(currentEncodedURL->file.characters(), currentEncodedURL->file.length());
} else {
buffer.append(currentEncodedURL->path.characters(), currentEncodedURL->path.length());
Page* page = frame->page();
if (!page) {
pseudoState = PseudoLink;
return;
}
buffer.append(characters, length);
cleanPath(buffer);
pseudoState = historyContains(buffer.data(), buffer.size()) ? PseudoVisited : PseudoLink;
pseudoState = page->group().isLinkVisited(document, *attr) ? PseudoVisited : PseudoLink;
}
// a helper function for parsing nth-arguments
......@@ -825,12 +727,14 @@ bool CSSStyleSelector::canShareStyleWithElement(Node* n)
mappedAttrsMatch = s->mappedAttributes()->mapsEquivalent(m_styledElement->mappedAttributes());
if (mappedAttrsMatch) {
bool linksMatch = true;
if (s->isLink()) {
// We need to check to see if the visited state matches.
Color linkColor = m_element->document()->linkColor();
Color visitedColor = m_element->document()->visitedLinkColor();
if (pseudoState == PseudoUnknown)
if (pseudoState == PseudoUnknown) {
const Color& linkColor = m_element->document()->linkColor();
const Color& visitedColor = m_element->document()->visitedLinkColor();
checkPseudoState(m_element, style->pseudoState() != PseudoAnyLink || linkColor != visitedColor);
}
linksMatch = (pseudoState == style->pseudoState());
}
......@@ -5130,8 +5034,8 @@ Color CSSStyleSelector::getColorFromPrimitiveValue(CSSPrimitiveValue* primitiveV
if (ident == CSS_VAL__WEBKIT_TEXT)
col = m_element->document()->textColor();
else if (ident == CSS_VAL__WEBKIT_LINK) {
Color linkColor = m_element->document()->linkColor();
Color visitedColor = m_element->document()->visitedLinkColor();
const Color& linkColor = m_element->document()->linkColor();
const Color& visitedColor = m_element->document()->visitedLinkColor();
if (linkColor == visitedColor)
col = linkColor;
else {
......
......@@ -110,14 +110,6 @@ public:
bool strictParsing;
struct EncodedURL {
String prefix; // protocol, host, etc.
String path;
String file;
} m_encodedURL;
void setEncodedURL(const KURL& url);
// Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this function will return
// the correct font size scaled relative to the user's default (medium).
float fontSizeForKeyword(int keyword, bool quirksMode, bool monospace) const;
......@@ -250,11 +242,8 @@ public:
bool m_matchAuthorAndUserStyles;
RefPtr<CSSFontSelector> m_fontSelector;
HashSet<AtomicStringImpl*> m_selectorAttrs;
Vector<CSSMutableStyleDeclaration*> m_additionalAttributeStyleDecls;
Vector<MediaQueryResult*> m_viewportDependentMediaQueryResults;
void applyProperty(int id, CSSValue*);
......
......@@ -1215,7 +1215,6 @@ void Document::attach()
if (Settings* docSettings = settings())
matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled();
m_styleSelector = new CSSStyleSelector(this, userStyleSheet(), m_styleSheets.get(), m_mappedElementSheet.get(), !inCompatMode(), matchAuthorAndUserStyles);
m_styleSelector->setEncodedURL(m_url);
}
recalcStyle(Force);
......@@ -1636,9 +1635,6 @@ void Document::setURL(const KURL& url)
return;
m_url = url;
if (m_styleSelector)
m_styleSelector->setEncodedURL(url);
m_isAllowedToLoadLocalResources = shouldBeAllowedToLoadLocalResources();
}
......@@ -2208,7 +2204,6 @@ void Document::recalcStyleSelector()
// Create a new style selector
delete m_styleSelector;
m_styleSelector = new CSSStyleSelector(this, userStyleSheet(), m_styleSheets.get(), m_mappedElementSheet.get(), !inCompatMode(), matchAuthorAndUserStyles);
m_styleSelector->setEncodedURL(m_url);
m_didCalculateStyleSelector = true;
}
......
......@@ -66,6 +66,7 @@
#include "MainResourceLoader.h"
#include "Page.h"
#include "PageCache.h"
#include "PageGroup.h"
#include "PluginInfoStore.h"
#include "ProgressTracker.h"
#include "RenderPart.h"
......@@ -3848,21 +3849,25 @@ PassRefPtr<HistoryItem> FrameLoader::createHistoryItem(bool useOriginal)
void FrameLoader::addBackForwardItemClippedAtTarget(bool doClip)
{
if (Page* page = m_frame->page())
if (!documentLoader()->urlForHistory().isEmpty()) {
Frame* mainFrame = page->mainFrame();
ASSERT(mainFrame);
FrameLoader* frameLoader = mainFrame->loader();
if (!frameLoader->m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
frameLoader->m_didPerformFirstNavigation = true;
m_client->didPerformFirstNavigation();
}
Page* page = m_frame->page();
if (!page)
return;
RefPtr<HistoryItem> item = frameLoader->createHistoryItemTree(m_frame, doClip);
LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), documentLoader()->url().string().ascii().data());
page->backForwardList()->addItem(item);
}
if (documentLoader()->urlForHistory().isEmpty())
return;
Frame* mainFrame = page->mainFrame();
ASSERT(mainFrame);
FrameLoader* frameLoader = mainFrame->loader();
if (!frameLoader->m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
frameLoader->m_didPerformFirstNavigation = true;
m_client->didPerformFirstNavigation();
}
RefPtr<HistoryItem> item = frameLoader->createHistoryItemTree(m_frame, doClip);
LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), documentLoader()->url().string().ascii().data());
page->backForwardList()->addItem(item);
}
PassRefPtr<HistoryItem> FrameLoader::createHistoryItemTree(Frame* targetFrame, bool clipAtTarget)
......@@ -4110,13 +4115,12 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
// Walk the frame tree and ensure that the URLs match the URLs in the item.
bool FrameLoader::urlsMatchItem(HistoryItem* item) const
{
KURL currentURL = documentLoader()->url();
const KURL& currentURL = documentLoader()->url();
if (!equalIgnoringRef(currentURL, item->url()))
return false;
const HistoryItemVector& childItems = item->children();
unsigned size = childItems.size();
for (unsigned i = 0; i < size; ++i) {
Frame* childFrame = m_frame->tree()->child(childItems[i]->target());
......@@ -4137,17 +4141,19 @@ void FrameLoader::goToItem(HistoryItem* targetItem, FrameLoadType type)
// <rdar://problem/3951283> can view pages from the back/forward cache that should be disallowed by Parental Controls
// Ultimately, history item navigations should go through the policy delegate. That's covered in:
// <rdar://problem/3979539> back/forward cache navigations should consult policy delegate
if (Page* page = m_frame->page())
if (m_client->shouldGoToHistoryItem(targetItem)) {
BackForwardList* bfList = page->backForwardList();
HistoryItem* currentItem = bfList->currentItem();
// Set the BF cursor before commit, which lets the user quickly click back/forward again.
// - plus, it only makes sense for the top level of the operation through the frametree,
// as opposed to happening for some/one of the page commits that might happen soon
bfList->goToItem(targetItem);
recursiveGoToItem(targetItem, currentItem, type);
}
Page* page = m_frame->page();
if (!page)
return;
if (!m_client->shouldGoToHistoryItem(targetItem))
return;
// Set the BF cursor before commit, which lets the user quickly click back/forward again.
// - plus, it only makes sense for the top level of the operation through the frametree,
// as opposed to happening for some/one of the page commits that might happen soon
BackForwardList* bfList = page->backForwardList();
HistoryItem* currentItem = bfList->currentItem();
bfList->goToItem(targetItem);
recursiveGoToItem(targetItem, currentItem, type);
}
// The general idea here is to traverse the frame tree and the item tree in parallel,
......@@ -4225,25 +4231,23 @@ bool FrameLoader::childFramesMatchItem(HistoryItem* item) const
return true;
}
void FrameLoader::updateGlobalHistory()
{
Settings* settings = m_frame->settings();
if (!settings)
return;
if (settings->privateBrowsingEnabled())
return;
const KURL& url = documentLoader()->urlForHistory();
if (url.isEmpty())
return;
m_client->updateGlobalHistory(url);
}
// There are 3 things you might think of as "history", all of which are handled by these functions.
//
// 1) Back/forward: The m_currentHistoryItem is part of this mechanism.
// 2) Global history: Handled by the client.
// 3) Visited links: Handled by the PageGroup.
void FrameLoader::updateHistoryForStandardLoad()
{
LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", documentLoader()->url().string().ascii().data());
Settings* settings = m_frame->settings();
bool needPrivacy = !settings || settings->privateBrowsingEnabled();
const KURL& historyURL = documentLoader()->urlForHistory();
// If the navigation occured during load and this is a subframe, update the current
// history item rather than adding a new one. <rdar://problem/5333496>
// back/forward item rather than adding a new one and don't add the new URL to global
// history at all. But do add it to visited links. <rdar://problem/5333496>
bool frameNavigationDuringLoad = false;
if (m_navigationDuringLoad) {
HTMLFrameOwnerElement* owner = m_frame->ownerElement();
......@@ -4252,14 +4256,20 @@ void FrameLoader::updateHistoryForStandardLoad()
}
if (!frameNavigationDuringLoad && !documentLoader()->isClientRedirect()) {
if (!documentLoader()->urlForHistory().isEmpty())
if (!historyURL.isEmpty()) {
addBackForwardItemClippedAtTarget(true);
if (!needPrivacy)
m_client->updateGlobalHistory(historyURL);
}
} else if (documentLoader()->unreachableURL().isEmpty() && m_currentHistoryItem) {
m_currentHistoryItem->setURL(documentLoader()->url());
m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
}
updateGlobalHistory();
if (!historyURL.isEmpty() && !needPrivacy) {
if (Page* page = m_frame->page())
page->group().addVisitedLink(historyURL);
}
}
void FrameLoader::updateHistoryForClientRedirect()
......@@ -4276,7 +4286,14 @@ void FrameLoader::updateHistoryForClientRedirect()
m_currentHistoryItem->clearScrollPoint();
}
// FIXME: Should we call updateGlobalHistory here?
Settings* settings = m_frame->settings();
bool needPrivacy = !settings || settings->privateBrowsingEnabled();
const KURL& historyURL = documentLoader()->urlForHistory();
if (!historyURL.isEmpty() && !needPrivacy) {
if (Page* page = m_frame->page())
page->group().addVisitedLink(historyURL);
}
}
void FrameLoader::updateHistoryForBackForwardNavigation()
......@@ -4288,8 +4305,6 @@ void FrameLoader::updateHistoryForBackForwardNavigation()
// Must grab the current scroll position before disturbing it
saveScrollPositionAndViewStateToItem(m_previousHistoryItem.get());
// FIXME: Should we call updateGlobalHistory here?
}
void FrameLoader::updateHistoryForReload()
......@@ -4309,8 +4324,6 @@ void FrameLoader::updateHistoryForReload()
if (documentLoader()->unreachableURL().isEmpty())
m_currentHistoryItem->setURL(documentLoader()->requestURL());
}
updateGlobalHistory();
}
void FrameLoader::updateHistoryForRedirectWithLockedHistory()
......@@ -4320,9 +4333,16 @@ void FrameLoader::updateHistoryForRedirectWithLockedHistory()
LOG(History, "WebCoreHistory: Updating History for internal load in frame %s", documentLoader()->title().utf8().data());
#endif
Settings* settings = m_frame->settings();
bool needPrivacy = !settings || settings->privateBrowsingEnabled();
const KURL& historyURL = documentLoader()->urlForHistory();
if (documentLoader()->isClientRedirect()) {
if (!m_currentHistoryItem && !m_frame->tree()->parent())
if (!m_currentHistoryItem && !m_frame->tree()->parent()) {
addBackForwardItemClippedAtTarget(true);
if (!needPrivacy && !historyURL.isEmpty())
m_client->updateGlobalHistory(historyURL);
}
if (m_currentHistoryItem) {
m_currentHistoryItem->setURL(documentLoader()->url());
m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
......@@ -4333,7 +4353,10 @@ void FrameLoader::updateHistoryForRedirectWithLockedHistory()
parentFrame->loader()->m_currentHistoryItem->addChildItem(createHistoryItem(true));
}
updateGlobalHistory();
if (!historyURL.isEmpty() && !needPrivacy) {
if (Page* page = m_frame->page())
page->group().addVisitedLink(historyURL);
}
}
void FrameLoader::updateHistoryForCommit()
......
......@@ -456,8 +456,6 @@ namespace WebCore {
void updateHistoryForClientRedirect();
void updateHistoryForCommit();
void updateGlobalHistory();
void redirectionTimerFired(Timer<FrameLoader>*);
void checkCompletedTimerFired(Timer<FrameLoader>*);
void checkLoadCompleteTimerFired(Timer<FrameLoader>*);
......
......@@ -33,6 +33,7 @@
#include "InspectorController.h"
#include "JSDOMWindow.h"
#include "Page.h"
#include "PageGroup.h"
#include "PausedTimeouts.h"