Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1110)

Unified Diff: Source/core/html/HTMLAnchorElement.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLAnchorElement.h ('k') | Source/core/html/HTMLAppletElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLAnchorElement.cpp
diff --git a/Source/core/html/HTMLAnchorElement.cpp b/Source/core/html/HTMLAnchorElement.cpp
index ca3767edaa4a66dd2f233c8d953583ad382beed7..0c0d201d45a1c213a28c1a30c975dc30dc8dea6f 100644
--- a/Source/core/html/HTMLAnchorElement.cpp
+++ b/Source/core/html/HTMLAnchorElement.cpp
@@ -169,7 +169,7 @@ bool HTMLAnchorElement::isKeyboardFocusable() const
if (!isFocusable())
return false;
- Page* page = document()->page();
+ Page* page = document().page();
if (!page)
return false;
@@ -231,8 +231,8 @@ void HTMLAnchorElement::defaultEventHandler(Event* event)
if (rendererIsEditable()) {
// This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
// for the LiveWhenNotFocused editable link behavior
- if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() != RightButton && document()->frame() && document()->frame()->selection()) {
- setRootEditableElementForSelectionOnMouseDown(document()->frame()->selection()->rootEditableElement());
+ if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && toMouseEvent(event)->button() != RightButton && document().frame() && document().frame()->selection()) {
+ setRootEditableElementForSelectionOnMouseDown(document().frame()->selection()->rootEditableElement());
m_wasShiftKeyDownOnMouseDown = toMouseEvent(event)->shiftKey();
} else if (event->type() == eventNames().mouseoverEvent) {
// These are cleared on mouseover and not mouseout because their values are needed for drag events,
@@ -250,7 +250,7 @@ void HTMLAnchorElement::setActive(bool down, bool pause)
{
if (rendererIsEditable()) {
EditableLinkBehavior editableLinkBehavior = EditableLinkDefaultBehavior;
- if (Settings* settings = document()->settings())
+ if (Settings* settings = document().settings())
editableLinkBehavior = settings->editableLinkBehavior();
switch (editableLinkBehavior) {
@@ -265,7 +265,7 @@ void HTMLAnchorElement::setActive(bool down, bool pause)
// Don't set the link to be active if the current selection is in the same editable block as
// this link
case EditableLinkLiveWhenNotFocused:
- if (down && document()->frame() && document()->frame()->selection()->rootEditableElement() == rootEditableElement())
+ if (down && document().frame() && document().frame()->selection()->rootEditableElement() == rootEditableElement())
return;
break;
@@ -288,14 +288,14 @@ void HTMLAnchorElement::parseAttribute(const QualifiedName& name, const AtomicSt
if (wasLink && treeScope()->adjustedFocusedElement() == this) {
// We might want to call blur(), but it's dangerous to dispatch
// events here.
- document()->setNeedsFocusedElementCheck();
+ document().setNeedsFocusedElementCheck();
}
}
if (isLink()) {
String parsedURL = stripLeadingAndTrailingHTMLSpaces(value);
- if (document()->isDNSPrefetchEnabled()) {
+ if (document().isDNSPrefetchEnabled()) {
if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "https") || parsedURL.startsWith("//"))
- prefetchDNS(document()->completeURL(parsedURL).host());
+ prefetchDNS(document().completeURL(parsedURL).host());
}
if (wasLink)
@@ -341,7 +341,7 @@ bool HTMLAnchorElement::draggable() const
KURL HTMLAnchorElement::href() const
{
- return document()->completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute(hrefAttr)));
+ return document().completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute(hrefAttr)));
}
void HTMLAnchorElement::setHref(const AtomicString& value)
@@ -560,40 +560,40 @@ bool HTMLAnchorElement::isLiveLink() const
void HTMLAnchorElement::sendPings(const KURL& destinationURL)
{
- if (!hasAttribute(pingAttr) || !document()->settings() || !document()->settings()->hyperlinkAuditingEnabled())
+ if (!hasAttribute(pingAttr) || !document().settings() || !document().settings()->hyperlinkAuditingEnabled())
return;
SpaceSplitString pingURLs(getAttribute(pingAttr), false);
for (unsigned i = 0; i < pingURLs.size(); i++)
- PingLoader::sendPing(document()->frame(), document()->completeURL(pingURLs[i]), destinationURL);
+ PingLoader::sendPing(document().frame(), document().completeURL(pingURLs[i]), destinationURL);
}
void HTMLAnchorElement::handleClick(Event* event)
{
event->setDefaultHandled();
- Frame* frame = document()->frame();
+ Frame* frame = document().frame();
if (!frame)
return;
StringBuilder url;
url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr)));
appendServerMapMousePosition(url, event);
- KURL completedURL = document()->completeURL(url.toString());
+ KURL completedURL = document().completeURL(url.toString());
ResourceRequest request(completedURL);
if (prefetchEventHandler()->hasIssuedPreconnect())
frame->loader()->client()->dispatchWillRequestAfterPreconnect(request);
if (hasAttribute(downloadAttr)) {
if (!hasRel(RelationNoReferrer)) {
- String referrer = SecurityPolicy::generateReferrerHeader(document()->referrerPolicy(), completedURL, frame->loader()->outgoingReferrer());
+ String referrer = SecurityPolicy::generateReferrerHeader(document().referrerPolicy(), completedURL, frame->loader()->outgoingReferrer());
if (!referrer.isEmpty())
request.setHTTPReferrer(referrer);
}
frame->loader()->client()->loadURLExternally(request, NavigationPolicyDownload, fastGetAttribute(downloadAttr));
} else {
- FrameLoadRequest frameRequest(document()->securityOrigin(), request, target());
+ FrameLoadRequest frameRequest(document().securityOrigin(), request, target());
frameRequest.setTriggeringEvent(event);
if (hasRel(RelationNoReferrer))
frameRequest.setShouldSendReferrer(NeverSendReferrer);
@@ -615,7 +615,7 @@ bool HTMLAnchorElement::treatLinkAsLiveForEventType(EventType eventType) const
if (!rendererIsEditable())
return true;
- Settings* settings = document()->settings();
+ Settings* settings = document().settings();
if (!settings)
return true;
@@ -822,17 +822,15 @@ bool HTMLAnchorElement::PrefetchEventHandler::shouldPrefetch(const KURL& url)
if (!url.protocolIsInHTTPFamily())
return false;
- Document* document = m_anchorElement->document();
- if (!document)
- return false;
+ Document& document = m_anchorElement->document();
- if (!document->securityOrigin()->canDisplay(url))
+ if (!document.securityOrigin()->canDisplay(url))
return false;
- if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(document->url(), url))
+ if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(document.url(), url))
return false;
- Frame* frame = document->frame();
+ Frame* frame = document.frame();
if (!frame)
return false;
« no previous file with comments | « Source/core/html/HTMLAnchorElement.h ('k') | Source/core/html/HTMLAppletElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698