summaryrefslogtreecommitdiffstats
path: root/WebCore/html/HTMLAnchorElement.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-10-08 17:19:54 +0100
committerSteve Block <steveblock@google.com>2009-10-20 00:41:58 +0100
commit231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch)
treea6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebCore/html/HTMLAnchorElement.cpp
parente196732677050bd463301566a68a643b6d14b907 (diff)
downloadexternal_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebCore/html/HTMLAnchorElement.cpp')
-rw-r--r--WebCore/html/HTMLAnchorElement.cpp55
1 files changed, 26 insertions, 29 deletions
diff --git a/WebCore/html/HTMLAnchorElement.cpp b/WebCore/html/HTMLAnchorElement.cpp
index 1515460..daa7919 100644
--- a/WebCore/html/HTMLAnchorElement.cpp
+++ b/WebCore/html/HTMLAnchorElement.cpp
@@ -40,51 +40,46 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLAnchorElement::HTMLAnchorElement(Document* document)
- : HTMLElement(aTag, document)
- , m_rootEditableElementForSelectionOnMouseDown(0)
+HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document* document)
+ : HTMLElement(tagName, document, CreateElement)
, m_wasShiftKeyDownOnMouseDown(false)
{
}
-HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document* document)
- : HTMLElement(tagName, document)
- , m_rootEditableElementForSelectionOnMouseDown(0)
- , m_wasShiftKeyDownOnMouseDown(false)
+PassRefPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document* document)
{
+ return adoptRef(new HTMLAnchorElement(aTag, document));
}
-bool HTMLAnchorElement::supportsFocus() const
+PassRefPtr<HTMLAnchorElement> HTMLAnchorElement::create(const QualifiedName& tagName, Document* document)
{
- if (isContentEditable())
- return HTMLElement::supportsFocus();
- return isFocusable() || (isLink() && document() && !document()->haveStylesheetsLoaded());
+ return adoptRef(new HTMLAnchorElement(tagName, document));
}
-bool HTMLAnchorElement::isFocusable() const
+bool HTMLAnchorElement::supportsFocus() const
{
if (isContentEditable())
- return HTMLElement::isFocusable();
-
- // FIXME: Even if we are not visible, we might have a child that is visible.
- // Dave wants to fix that some day with a "has visible content" flag or the like.
- if (!(isLink() && renderer() && renderer()->style()->visibility() == VISIBLE))
- return false;
-
- return true;
+ return HTMLElement::supportsFocus();
+ // If not a link we should still be able to focus the element if it has tabIndex.
+ return isLink() || HTMLElement::supportsFocus();
}
bool HTMLAnchorElement::isMouseFocusable() const
{
-#if PLATFORM(GTK)
- return HTMLElement::isMouseFocusable();
-#else
- return false;
+ // Anchor elements should be mouse focusable, https://bugs.webkit.org/show_bug.cgi?id=26856
+#if !PLATFORM(GTK)
+ if (isLink())
+ return false;
#endif
+ // Allow tab index etc to control focus.
+ return HTMLElement::isMouseFocusable();
}
bool HTMLAnchorElement::isKeyboardFocusable(KeyboardEvent* event) const
{
+ if (!isLink())
+ return HTMLElement::isKeyboardFocusable(event);
+
if (!isFocusable())
return false;
@@ -350,15 +345,17 @@ String HTMLAnchorElement::hash() const
String HTMLAnchorElement::host() const
{
- return href().host();
+ const KURL& url = href();
+ if (url.hostEnd() == url.pathStart())
+ return url.host();
+ if (SecurityOrigin::isDefaultPortForProtocol(url.port(), url.protocol()))
+ return url.host();
+ return url.host() + ":" + String::number(url.port());
}
String HTMLAnchorElement::hostname() const
{
- const KURL& url = href();
- if (url.port() == 0)
- return url.host();
- return url.host() + ":" + String::number(url.port());
+ return href().host();
}
String HTMLAnchorElement::pathname() const