Diff
Modified: trunk/LayoutTests/ChangeLog (166667 => 166668)
--- trunk/LayoutTests/ChangeLog 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/LayoutTests/ChangeLog 2014-04-02 21:40:26 UTC (rev 166668)
@@ -1,5 +1,26 @@
2014-04-02 Daniel Bates <[email protected]>
+ Move focus management API from HTMLDocument to Document
+ https://bugs.webkit.org/show_bug.cgi?id=131079
+ <rdar://problem/16220103>
+
+ Reviewed by Timothy Hatcher.
+
+ Derived from a Blink patch by Christophe Dumez:
+ https://src.chromium.org/viewvc/blink?view=rev&revision=165515
+
+ Made the test in <https://src.chromium.org/viewvc/blink?view=rev&revision=165515> a valid XHTML
+ document. Additionally taught LayoutTests/resources/{js-test, js-test-pre}.js to create actual
+ HTML elements so that these scripts can be used to write DRT tests in XML documents.
+
+ * fast/dom/Document/xml-document-focus-expected.txt: Added.
+ * fast/dom/Document/xml-document-focus.xml: Added.
+ * resources/js-test-pre.js: Added function createHTMLElement() and modified code to use it
+ instead of document.createElement() so as to work around <https://bugs.webkit.org/show_bug.cgi?id=131074>.
+ * resources/js-test.js: Ditto.
+
+2014-04-02 Daniel Bates <[email protected]>
+
Remove Settings::maximumDecodedImageSize()
https://bugs.webkit.org/show_bug.cgi?id=131057
<rdar://problem/15626368>
Added: trunk/LayoutTests/fast/dom/Document/xml-document-focus-expected.txt (0 => 166668)
--- trunk/LayoutTests/fast/dom/Document/xml-document-focus-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/xml-document-focus-expected.txt 2014-04-02 21:40:26 UTC (rev 166668)
@@ -0,0 +1,15 @@
+Make sure the focus management API is available to XML documents.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.__proto__ is not HTMLDocument.prototype
+PASS document.__proto__ is Document.prototype
+PASS document.hasFocus() is true
+PASS document.activeElement is document.body
+PASS document.activeElement is testElement
+PASS document.hasFocus() is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/Document/xml-document-focus.xml (0 => 166668)
--- trunk/LayoutTests/fast/dom/Document/xml-document-focus.xml (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/xml-document-focus.xml 2014-04-02 21:40:26 UTC (rev 166668)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Test document.activeElement and document.hasFocus()</title>
+<script type="text/_javascript_" src=""
+</head>
+<body>
+<input id="testElement"></input>
+<script type="text/_javascript_">
+description("Make sure the focus management API is available to XML documents.");
+
+shouldNotBe("document.__proto__", "HTMLDocument.prototype");
+shouldBe("document.__proto__", "Document.prototype");
+shouldBeTrue("document.hasFocus()");
+shouldBe("document.activeElement", "document.body");
+var testElement = document.getElementById("testElement");
+testElement.focus();
+shouldBe("document.activeElement", "testElement");
+shouldBeTrue("document.hasFocus()");
+</script>
+<script type="text/_javascript_" src=""
+</body>
+</html>
Modified: trunk/LayoutTests/resources/js-test-pre.js (166667 => 166668)
--- trunk/LayoutTests/resources/js-test-pre.js 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/LayoutTests/resources/js-test-pre.js 2014-04-02 21:40:26 UTC (rev 166668)
@@ -10,13 +10,24 @@
(function() {
+ function createHTMLElement(tagName)
+ {
+ // FIXME: In an XML document, document.createElement() creates an element with a null namespace URI.
+ // So, we need use document.createElementNS() to explicitly create an element with the specified
+ // tag name in the HTML namespace. We can remove this function and use document.createElement()
+ // directly once we fix <https://bugs.webkit.org/show_bug.cgi?id=131074>.
+ if (document.createElementNS)
+ return document.createElementNS("http://www.w3.org/1999/xhtml", tagName);
+ return document.createElement(tagName);
+ }
+
function getOrCreate(id, tagName)
{
var element = document.getElementById(id);
if (element)
return element;
- element = document.createElement(tagName);
+ element = createHTMLElement(tagName);
element.id = id;
var refNode;
var parent = document.body || document.documentElement;
@@ -32,7 +43,7 @@
description = function description(msg, quiet)
{
// For MSIE 6 compatibility
- var span = document.createElement("span");
+ var span = createHTMLElement("span");
if (quiet)
span.innerHTML = '<p>' + msg + '</p><p>On success, you will see no "<span class="fail">FAIL</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
else
@@ -47,7 +58,7 @@
debug = function debug(msg)
{
- var span = document.createElement("span");
+ var span = createHTMLElement("span");
getOrCreate("console", "div").appendChild(span); // insert it first so XHTML knows the namespace
span.innerHTML = msg + '<br />';
};
@@ -68,7 +79,7 @@
function insertStyleSheet()
{
- var styleElement = document.createElement("style");
+ var styleElement = createHTMLElement("style");
styleElement.textContent = css;
(document.head || document.documentElement).appendChild(styleElement);
}
Modified: trunk/LayoutTests/resources/js-test.js (166667 => 166668)
--- trunk/LayoutTests/resources/js-test.js 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/LayoutTests/resources/js-test.js 2014-04-02 21:40:26 UTC (rev 166668)
@@ -14,13 +14,24 @@
(function() {
+ function createHTMLElement(tagName)
+ {
+ // FIXME: In an XML document, document.createElement() creates an element with a null namespace URI.
+ // So, we need use document.createElementNS() to explicitly create an element with the specified
+ // tag name in the HTML namespace. We can remove this function and use document.createElement()
+ // directly once we fix <https://bugs.webkit.org/show_bug.cgi?id=131074>.
+ if (document.createElementNS)
+ return document.createElementNS("http://www.w3.org/1999/xhtml", tagName);
+ return document.createElement(tagName);
+ }
+
function getOrCreate(id, tagName)
{
var element = document.getElementById(id);
if (element)
return element;
- element = document.createElement(tagName);
+ element = createHTMLElement(tagName);
element.id = id;
var refNode;
var parent = document.body || document.documentElement;
@@ -36,7 +47,7 @@
description = function description(msg, quiet)
{
// For MSIE 6 compatibility
- var span = document.createElement("span");
+ var span = createHTMLElement("span");
if (quiet)
span.innerHTML = '<p>' + msg + '</p><p>On success, you will see no "<span class="fail">FAIL</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
else
@@ -51,7 +62,7 @@
debug = function debug(msg)
{
- var span = document.createElement("span");
+ var span = createHTMLElement("span");
getOrCreate("console", "div").appendChild(span); // insert it first so XHTML knows the namespace
span.innerHTML = msg + '<br />';
};
@@ -72,7 +83,7 @@
function insertStyleSheet()
{
- var styleElement = document.createElement("style");
+ var styleElement = createHTMLElement("style");
styleElement.textContent = css;
(document.head || document.documentElement).appendChild(styleElement);
}
Modified: trunk/Source/WebCore/ChangeLog (166667 => 166668)
--- trunk/Source/WebCore/ChangeLog 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/Source/WebCore/ChangeLog 2014-04-02 21:40:26 UTC (rev 166668)
@@ -1,3 +1,33 @@
+2014-04-02 Daniel Bates <[email protected]>
+
+ Move focus management API from HTMLDocument to Document
+ https://bugs.webkit.org/show_bug.cgi?id=131079
+ <rdar://problem/16220103>
+
+ Reviewed by Timothy Hatcher.
+
+ Merged from Blink (patch by Christophe Dumez):
+ https://src.chromium.org/viewvc/blink?view=rev&revision=165515
+
+ Move hasFocus() and attribute activeElement from interface HTMLDocument
+ to DOMDocument as per section Focus management APIs of the HTML5 standard:
+ <http://www.whatwg.org/specs/web-apps/current-work/#focus-management-apis> (1 April 2014).
+
+ Test: fast/dom/Document/xml-document-focus.xml
+
+ * bindings/objc/PublicDOMInterfaces.h: Moved hasFocus() and property activeElement from
+ interface DOMHTMLDocument to DOMDocument.
+ * dom/Document.cpp:
+ (WebCore::Document::activeElement): Added.
+ (WebCore::Document::hasFocus): Added.
+ * dom/Document.h:
+ * dom/Document.idl:
+ * html/HTMLDocument.cpp:
+ (WebCore::HTMLDocument::activeElement): Deleted.
+ (WebCore::HTMLDocument::hasFocus): Deleted.
+ * html/HTMLDocument.h:
+ * html/HTMLDocument.idl:
+
2014-04-02 Benjamin Poulain <[email protected]>
Refactor the function call generator to take the arguments by value
Modified: trunk/Source/WebCore/bindings/objc/PublicDOMInterfaces.h (166667 => 166668)
--- trunk/Source/WebCore/bindings/objc/PublicDOMInterfaces.h 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/Source/WebCore/bindings/objc/PublicDOMInterfaces.h 2014-04-02 21:40:26 UTC (rev 166668)
@@ -107,6 +107,7 @@
@property (readonly, copy) NSString *preferredStylesheetSet WEBKIT_AVAILABLE_MAC(10_5);
@property (copy) NSString *selectedStylesheetSet WEBKIT_AVAILABLE_MAC(10_5);
@property (readonly, copy) NSString *lastModified WEBKIT_AVAILABLE_MAC(10_6);
+@property (readonly, strong) DOMElement *activeElement WEBKIT_AVAILABLE_MAC(10_6);
- (DOMElement *)createElement:(NSString *)tagName;
- (DOMDocumentFragment *)createDocumentFragment;
- (DOMText *)createTextNode:(NSString *)data;
@@ -161,6 +162,7 @@
#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
- (void)webkitCancelFullScreen WEBKIT_AVAILABLE_MAC(10_6);
#endif
+- (BOOL)hasFocus WEBKIT_AVAILABLE_MAC(10_6);
@end
@interface DOMDocumentFragment : DOMNode 10_4
@@ -458,12 +460,10 @@
@property (copy) NSString *alinkColor WEBKIT_AVAILABLE_MAC(10_5);
@property (copy) NSString *linkColor WEBKIT_AVAILABLE_MAC(10_5);
@property (copy) NSString *vlinkColor WEBKIT_AVAILABLE_MAC(10_5);
-@property (readonly, strong) DOMElement *activeElement WEBKIT_AVAILABLE_MAC(10_6);
@property (readonly, copy) NSString *compatMode WEBKIT_AVAILABLE_MAC(10_6);
- (void)captureEvents WEBKIT_AVAILABLE_MAC(10_5);
- (void)releaseEvents WEBKIT_AVAILABLE_MAC(10_5);
- (void)clear WEBKIT_AVAILABLE_MAC(10_6);
-- (BOOL)hasFocus WEBKIT_AVAILABLE_MAC(10_6);
- (void)open;
- (void)close;
- (void)write:(NSString *)text;
Modified: trunk/Source/WebCore/dom/Document.cpp (166667 => 166668)
--- trunk/Source/WebCore/dom/Document.cpp 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/Source/WebCore/dom/Document.cpp 2014-04-02 21:40:26 UTC (rev 166668)
@@ -55,6 +55,7 @@
#include "EntityReference.h"
#include "EventFactory.h"
#include "EventHandler.h"
+#include "FocusController.h"
#include "FontLoader.h"
#include "FormController.h"
#include "FrameLoader.h"
@@ -6153,4 +6154,24 @@
return true;
}
+Element* Document::activeElement()
+{
+ updateStyleIfNeeded();
+ if (Element* element = treeScope().focusedElement())
+ return element;
+ return body();
+}
+
+bool Document::hasFocus() const
+{
+ Page* page = this->page();
+ if (!page || !page->focusController().isActive())
+ return false;
+ if (Frame* focusedFrame = page->focusController().focusedFrame()) {
+ if (focusedFrame->tree().isDescendantOf(frame()))
+ return true;
+ }
+ return false;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Document.h (166667 => 166668)
--- trunk/Source/WebCore/dom/Document.h 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/Source/WebCore/dom/Document.h 2014-04-02 21:40:26 UTC (rev 166668)
@@ -405,6 +405,9 @@
return m_documentElement.get();
}
+ Element* activeElement();
+ bool hasFocus() const;
+
bool hasManifest() const;
virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
Modified: trunk/Source/WebCore/dom/Document.idl (166667 => 166668)
--- trunk/Source/WebCore/dom/Document.idl 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/Source/WebCore/dom/Document.idl 2014-04-02 21:40:26 UTC (rev 166668)
@@ -210,6 +210,9 @@
// HTML 5
NodeList getElementsByClassName([Default=Undefined] optional DOMString tagname);
+ readonly attribute Element activeElement;
+ boolean hasFocus();
+
readonly attribute DOMString compatMode;
// NodeSelector - Selector API
Modified: trunk/Source/WebCore/html/HTMLDocument.cpp (166667 => 166668)
--- trunk/Source/WebCore/html/HTMLDocument.cpp 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/Source/WebCore/html/HTMLDocument.cpp 2014-04-02 21:40:26 UTC (rev 166668)
@@ -137,28 +137,6 @@
Document::setDesignMode(mode);
}
-Element* HTMLDocument::activeElement()
-{
- document().updateStyleIfNeeded();
- if (Element* element = treeScope().focusedElement())
- return element;
- return body();
-}
-
-bool HTMLDocument::hasFocus()
-{
- Page* page = this->page();
- if (!page)
- return false;
- if (!page->focusController().isActive())
- return false;
- if (Frame* focusedFrame = page->focusController().focusedFrame()) {
- if (focusedFrame->tree().isDescendantOf(frame()))
- return true;
- }
- return false;
-}
-
const AtomicString& HTMLDocument::bgColor() const
{
HTMLElement* bodyElement = body();
Modified: trunk/Source/WebCore/html/HTMLDocument.h (166667 => 166668)
--- trunk/Source/WebCore/html/HTMLDocument.h 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/Source/WebCore/html/HTMLDocument.h 2014-04-02 21:40:26 UTC (rev 166668)
@@ -52,9 +52,6 @@
String designMode() const;
void setDesignMode(const String&);
- Element* activeElement();
- bool hasFocus();
-
const AtomicString& bgColor() const;
void setBgColor(const String&);
const AtomicString& fgColor() const;
Modified: trunk/Source/WebCore/html/HTMLDocument.idl (166667 => 166668)
--- trunk/Source/WebCore/html/HTMLDocument.idl 2014-04-02 21:38:49 UTC (rev 166667)
+++ trunk/Source/WebCore/html/HTMLDocument.idl 2014-04-02 21:40:26 UTC (rev 166668)
@@ -49,9 +49,6 @@
[TreatNullAs=NullString] attribute DOMString designMode;
readonly attribute DOMString compatMode;
- readonly attribute Element activeElement;
- boolean hasFocus();
-
// Deprecated attributes
[TreatNullAs=NullString] attribute DOMString bgColor;
[TreatNullAs=NullString] attribute DOMString fgColor;