Commit d3da52f8 authored by tony@chromium.org's avatar tony@chromium.org

Remove document as a parameter from a few internals methods

https://bugs.webkit.org/show_bug.cgi?id=107757

Reviewed by Hajime Morita.

Remove document as a parameter since there's already one associated with internals.

Source/WebCore:

No new tests, this refactors some testing code and is covered by
exisiting tests.

* testing/Internals.cpp:
(WebCore::Internals::isPreloaded):
(WebCore::Internals::createContentElement):
(WebCore::Internals::absoluteCaretBounds):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

LayoutTests:

* editing/input/editable-container-with-word-wrap-normal.html:
* editing/selection/caret-alignment-for-vertical-text.html:
* editing/selection/caret-at-end-of-text-line-followed-by-block-in-vertical-mode.html:
* editing/selection/caret-in-div-containing-br-in-vertical-mode.html:
* editing/selection/caret-in-empty-inline-1.html:
* editing/selection/caret-in-empty-inline-2.html:
* editing/selection/internal-caret-rect.html:
* fast/dom/resources/shadow-test-driver.js:
(createContentWithSelect):
(createContentWithText):
(appendShadow):
(appendShadowDeep):
* fast/dom/shadow/content-element-includer.html:
* fast/dom/shadow/content-element-renderers.html:
* fast/dom/shadow/content-selector-query.html:
* fast/dom/shadow/create-content-element.html:
* fast/dom/shadow/shadow-contents-fallback-dynamic.html:
* fast/dom/shadow/shadow-contents-fallback.html:
* fast/dom/shadow/shadow-contents-select.html:
* fast/preloader/scan-body-from-head-import.html:
* http/tests/loading/preload-append-scan.php:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140710 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 819c0246
2013-01-24 Tony Chang <tony@chromium.org>
Remove document as a parameter from a few internals methods
https://bugs.webkit.org/show_bug.cgi?id=107757
Reviewed by Hajime Morita.
Remove document as a parameter since there's already one associated with internals.
* editing/input/editable-container-with-word-wrap-normal.html:
* editing/selection/caret-alignment-for-vertical-text.html:
* editing/selection/caret-at-end-of-text-line-followed-by-block-in-vertical-mode.html:
* editing/selection/caret-in-div-containing-br-in-vertical-mode.html:
* editing/selection/caret-in-empty-inline-1.html:
* editing/selection/caret-in-empty-inline-2.html:
* editing/selection/internal-caret-rect.html:
* fast/dom/resources/shadow-test-driver.js:
(createContentWithSelect):
(createContentWithText):
(appendShadow):
(appendShadowDeep):
* fast/dom/shadow/content-element-includer.html:
* fast/dom/shadow/content-element-renderers.html:
* fast/dom/shadow/content-selector-query.html:
* fast/dom/shadow/create-content-element.html:
* fast/dom/shadow/shadow-contents-fallback-dynamic.html:
* fast/dom/shadow/shadow-contents-fallback.html:
* fast/dom/shadow/shadow-contents-select.html:
* fast/preloader/scan-body-from-head-import.html:
* http/tests/loading/preload-append-scan.php:
2013-01-24 Mike West <mkwst@chromium.org>
Web Inspector: 'console.debug' should generate messages at DebugMessageLevel.
......@@ -24,7 +24,7 @@ The test case checks if caret is drawn properly(especially scrolls properly) ins
editableContainer = document.getElementById('test');
editableContainer.focus();
if (window.internals)
startCaretRect = internals.absoluteCaretBounds(document);
startCaretRect = internals.absoluteCaretBounds();
window.getSelection().setPosition(editableContainer,0);
if (window.testRunner)
......@@ -32,7 +32,7 @@ The test case checks if caret is drawn properly(especially scrolls properly) ins
finalCaretRect = {right:-1,left:-1};
if (window.internals)
finalCaretRect = internals.absoluteCaretBounds(document);
finalCaretRect = internals.absoluteCaretBounds();
caretWidth = finalCaretRect.right - finalCaretRect.left;
......
......@@ -18,17 +18,17 @@ function runTest() {
/* Caret rect for the empty container. */
document.getElementById('emptyDiv').focus();
if (window.internals)
emptyDivCaretRect = internals.absoluteCaretBounds(document);
emptyDivCaretRect = internals.absoluteCaretBounds();
/* Caret rect for am empty line. */
document.getElementById('emptyLineDiv').focus();
if (window.internals)
emptyLineCaretRect = internals.absoluteCaretBounds(document);
emptyLineCaretRect = internals.absoluteCaretBounds();
/* Caret rect for the container with some text. */
document.getElementById('textDiv').focus();
if (window.internals)
textDivCaretRect = internals.absoluteCaretBounds(document);
textDivCaretRect = internals.absoluteCaretBounds();
debug("The carets on the empty editable boxes should have the same orientation as that on the editable box containing some text. We thus compare the width and the height of the caret rects for verification. Width and height for all the three caret rects should be the same for the test to pass.")
......
......@@ -23,12 +23,12 @@ if (window.internals) {
eventSender.mouseMoveTo(testDiv.offsetLeft + testDiv.offsetWidth - 5, testDiv.offsetTop);
eventSender.mouseDown();
eventSender.mouseUp();
caretRectAtStart = internals.absoluteCaretBounds(document);
caretRectAtStart = internals.absoluteCaretBounds();
eventSender.mouseMoveTo(testDiv.offsetLeft + testDiv.offsetWidth - 5, testDiv.offsetTop + testDiv.offsetHeight - 5);
eventSender.mouseDown();
eventSender.mouseUp();
caretRectAtEnd = internals.absoluteCaretBounds(document);
caretRectAtEnd = internals.absoluteCaretBounds();
shouldBe("caretRectAtEnd.left", "caretRectAtStart.left");
shouldBe("caretRectAtEnd.width", "caretRectAtStart.width");
......
......@@ -16,11 +16,11 @@ function runTest() {
document.getElementById('textDiv').focus();
if (window.internals)
withTextCaretRect = internals.absoluteCaretBounds(document);
withTextCaretRect = internals.absoluteCaretBounds();
document.getElementById('noTextDiv').focus();
if (window.internals)
withoutTextCaretRect = internals.absoluteCaretBounds(document);
withoutTextCaretRect = internals.absoluteCaretBounds();
if (window.internals) {
shouldBe("withTextCaretRect.top", "withoutTextCaretRect.top");
......
......@@ -18,7 +18,7 @@
var testInline = document.getElementById("testInline");
getSelection().collapse(testInline, 0);
if (window.internals) {
var caretRect = internals.absoluteCaretBounds(document);
var caretRect = internals.absoluteCaretBounds();
shouldBe("caretRect.left", "8");
shouldBe("caretRect.top", "160");
shouldBe("caretRect.width", "1");
......
......@@ -19,7 +19,7 @@ another inline element, gets a valid caret rect.</p>
var testInline = document.getElementById("testInline");
getSelection().collapse(testInline, 0);
if (window.internals) {
var caretRect = internals.absoluteCaretBounds(document);
var caretRect = internals.absoluteCaretBounds();
shouldBe("caretRect.left", "268");
shouldBe("caretRect.top", "180");
shouldBe("caretRect.width", "1");
......
......@@ -20,7 +20,7 @@
{
if (window.internals) {
var index = caretRects.length;
caretRects.push(internals.absoluteCaretBounds(document));
caretRects.push(internals.absoluteCaretBounds());
shouldBe("caretRects[" + index + "].left", left.toString());
shouldBe("caretRects[" + index + "].top", top.toString());
shouldBe("caretRects[" + index + "].width", width.toString());
......
......@@ -72,7 +72,7 @@ function createSpanWithText(text, className) {
}
function createContentWithSelect(select, fallbackText) {
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', select);
if (fallbackText)
content.appendChild(createSpanWithText(fallbackText));
......@@ -81,7 +81,7 @@ function createContentWithSelect(select, fallbackText) {
}
function createContentWithText(fallbackText) {
var content = internals.createContentElement(document);
var content = internals.createContentElement();
if (fallbackText)
content.innerHTML = fallbackText;
......@@ -91,7 +91,7 @@ function createContentWithText(fallbackText) {
function appendShadow(target, select) {
var root = internals.ensureShadowRoot(target);
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', select);
content.appendChild(createSpanWithText("FALLBACK"));
......@@ -105,7 +105,7 @@ function appendShadowDeep(target, select) {
var child = document.createElement("span");
{
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', select);
content.appendChild(createSpanWithText("FALLBACK"));
......
......@@ -33,7 +33,7 @@ shouldBe("internals.includerFor(childOfElementWithShadow)", "null");
var elementWithShadowContent = document.createElement("div");
container.appendChild(elementWithShadowContent);
var shadowRootOfElementWithShadowContent = internals.ensureShadowRoot(elementWithShadowContent);
var shadowContentOfElementWithShadowContent = internals.createContentElement(document);
var shadowContentOfElementWithShadowContent = internals.createContentElement();
shadowRootOfElementWithShadowContent.appendChild(shadowContentOfElementWithShadowContent);
var childOfElementWithShadowContent = document.createElement("span");
elementWithShadowContent.appendChild(childOfElementWithShadowContent);
......@@ -58,7 +58,7 @@ elementWithShadow.removeChild(movingChild);
var anotherElementWithShadowContent = document.createElement("div");
container.appendChild(anotherElementWithShadowContent);
var anotherShadowRootOfElementWithShadowContent = internals.ensureShadowRoot(anotherElementWithShadowContent);
var anotherShadowContentOfElementWithShadowContent = internals.createContentElement(document);
var anotherShadowContentOfElementWithShadowContent = internals.createContentElement();
anotherShadowRootOfElementWithShadowContent.appendChild(anotherShadowContentOfElementWithShadowContent);
anotherElementWithShadowContent.appendChild(movingChild);
......
......@@ -62,7 +62,7 @@ function createTreeFrom(html)
var contentPlaceholder = root.getElementsByTagName("CONTENT")[0];
if (contentPlaceholder) {
var contentParent = contentPlaceholder.parentNode;
contentParent.replaceChild(window.internals.createContentElement(document), contentPlaceholder);
contentParent.replaceChild(window.internals.createContentElement(), contentPlaceholder);
};
return root;
......
......@@ -13,7 +13,7 @@ var container = document.getElementById("container");
var content;
function test(select, valid) {
content = internals.createContentElement(document);
content = internals.createContentElement();
if (select != null)
content.setAttribute('select', select);
......
......@@ -29,7 +29,7 @@ function setupTargetTree()
var child0 = document.createElement("span");
child0.innerHTML = "Hello,";
root.appendChild(child0);
root.appendChild(window.internals.createContentElement(document));
root.appendChild(window.internals.createContentElement());
var child1 = document.createElement("span");
child1.innerHTML = "World.";
root.appendChild(child1);
......
......@@ -61,7 +61,7 @@ function createSpanWithText(text) {
function appendShadow(target, select) {
var root = internals.ensureShadowRoot(target);
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', select);
content.appendChild(createSpanWithText("FALLBACK"));
......@@ -75,7 +75,7 @@ function appendShadowDeep(target, select) {
var child = document.createElement("span");
{
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', select);
content.appendChild(createSpanWithText("FALLBACK"));
......@@ -349,7 +349,7 @@ function testContentInContent(callIfDone) {
target.appendChild(createSpanWithText('S2'));
var root = internals.ensureShadowRoot(target);
var content1 = internals.createContentElement(document);
var content1 = internals.createContentElement();
content1.setAttribute('select', 'div');
root.appendChild(document.createTextNode("{SHADOW: "));
......@@ -360,7 +360,7 @@ function testContentInContent(callIfDone) {
var f = (function(target, content1, callIfDone) {
return function() {
var content2 = internals.createContentElement(document);
var content2 = internals.createContentElement();
content2.setAttribute('select', 'span');
content2.appendChild(createSpanWithText('CONTENT 2 FALLBACK'));
content1.appendChild(content2);
......@@ -380,7 +380,7 @@ function testContentInContentFallback(callIfDone) {
target.appendChild(createSpanWithText('S2'));
var root = internals.ensureShadowRoot(target);
var content1 = internals.createContentElement(document);
var content1 = internals.createContentElement();
content1.setAttribute('select', 'div');
root.appendChild(document.createTextNode("{SHADOW: "));
......@@ -391,7 +391,7 @@ function testContentInContentFallback(callIfDone) {
var f = (function(target, content1, callIfDone) {
return function() {
var content2 = internals.createContentElement(document);
var content2 = internals.createContentElement();
content2.setAttribute('select', 'div');
content2.appendChild(createSpanWithText('CONTENT 2 FALLBACK'));
content1.appendChild(content2);
......@@ -411,7 +411,7 @@ function testContentInContentFallbackDirect(callIfDone) {
target.appendChild(createSpanWithText('S2'));
var root = internals.ensureShadowRoot(target);
var content1 = internals.createContentElement(document);
var content1 = internals.createContentElement();
content1.setAttribute('select', 'div');
root.appendChild(content1);
......@@ -419,7 +419,7 @@ function testContentInContentFallbackDirect(callIfDone) {
var f = (function(target, content1, callIfDone) {
return function() {
var content2 = internals.createContentElement(document);
var content2 = internals.createContentElement();
content2.setAttribute('select', 'div');
content2.appendChild(createSpanWithText('CONTENT 2 FALLBACK'));
content1.appendChild(content2);
......
......@@ -62,7 +62,7 @@ function createSpanWithText(text) {
function appendShadow(target, select) {
var root = internals.ensureShadowRoot(target);
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', select);
content.appendChild(createSpanWithText("FALLBACK"));
......@@ -76,7 +76,7 @@ function appendShadowDeep(target, select) {
var child = document.createElement("span");
{
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', select);
content.appendChild(createSpanWithText("FALLBACK"));
......@@ -231,7 +231,7 @@ function testContentkWithDisplayNone() {
target.appendChild(span3);
var root = internals.ensureShadowRoot(target);
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', 'span');
content.appendChild(createSpanWithText('FALLBACK'));
......@@ -253,11 +253,11 @@ function testContentInContent() {
target.appendChild(createSpanWithText('S2'));
var root = internals.ensureShadowRoot(target);
var content2 = internals.createContentElement(document);
var content2 = internals.createContentElement();
content2.setAttribute('select', 'span');
content2.appendChild(createSpanWithText('CONTENT 2 FALLBACK'));
var content1 = internals.createContentElement(document);
var content1 = internals.createContentElement();
content1.setAttribute('select', 'div');
content1.appendChild(content2);
......@@ -276,11 +276,11 @@ function testContentInContentFallback() {
target.appendChild(createSpanWithText('S2'));
var root = internals.ensureShadowRoot(target);
var content2 = internals.createContentElement(document);
var content2 = internals.createContentElement();
content2.setAttribute('select', 'div');
content2.appendChild(createSpanWithText('CONTENT 2 FALLBACK'));
var content1 = internals.createContentElement(document);
var content1 = internals.createContentElement();
content1.setAttribute('select', 'div');
content1.appendChild(content2);
......@@ -299,11 +299,11 @@ function testContentInContentFallbackWithDisplayNone() {
target.appendChild(createSpanWithText('S2'));
var root = internals.ensureShadowRoot(target);
var content2 = internals.createContentElement(document);
var content2 = internals.createContentElement();
content2.setAttribute('select', 'div');
content2.appendChild(createSpanWithText('CONTENT 2 FALLBACK'));
var content1 = internals.createContentElement(document);
var content1 = internals.createContentElement();
content1.setAttribute('select', 'div');
content1.appendChild(content2);
......@@ -325,11 +325,11 @@ function testContentInContentFallbackDirect() {
target.appendChild(createSpanWithText('S2'));
var root = internals.ensureShadowRoot(target);
var content2 = internals.createContentElement(document);
var content2 = internals.createContentElement();
content2.setAttribute('select', 'div');
content2.appendChild(createSpanWithText('CONTENT 2 FALLBACK'));
var content1 = internals.createContentElement(document);
var content1 = internals.createContentElement();
content1.setAttribute('select', 'div');
content1.appendChild(content2);
......
......@@ -15,7 +15,7 @@ function appendShadow(target, select) {
child0.innerHTML = "Hello,";
root.appendChild(child0);
var content = internals.createContentElement(document);
var content = internals.createContentElement();
content.setAttribute('select', select);
root.appendChild(content);
......
......@@ -6,7 +6,7 @@ if (window.testRunner)
function checkForPreload() {
var result;
if (internals.isPreloaded(document, "resources/image1.png") && internals.isPreloaded(document, "resources/style1.css"))
if (internals.isPreloaded("resources/image1.png") && internals.isPreloaded("resources/style1.css"))
result = "PASS";
else
result = "FAIL";
......
......@@ -6,7 +6,7 @@ if (window.testRunner)
function checkForPreload() {
var result;
if (internals.isPreloaded(document, "resources/image1.png") && internals.isPreloaded(document, "resources/script1.js"))
if (internals.isPreloaded("resources/image1.png") && internals.isPreloaded("resources/script1.js"))
result = "PASS";
else
result = "FAIL";
......
......@@ -12,7 +12,7 @@ if (window.testRunner)
function checkForPreload() {
var result;
if (internals.isPreloaded(document, "resources/preload-test.jpg"))
if (internals.isPreloaded("resources/preload-test.jpg"))
result = "PASS";
else
result = "FAIL";
......
2013-01-24 Tony Chang <tony@chromium.org>
Remove document as a parameter from a few internals methods
https://bugs.webkit.org/show_bug.cgi?id=107757
Reviewed by Hajime Morita.
Remove document as a parameter since there's already one associated with internals.
No new tests, this refactors some testing code and is covered by
exisiting tests.
* testing/Internals.cpp:
(WebCore::Internals::isPreloaded):
(WebCore::Internals::createContentElement):
(WebCore::Internals::absoluteCaretBounds):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:
2013-01-24 Mike West <mkwst@chromium.org>
Web Inspector: 'console.debug' should generate messages at DebugMessageLevel.
......@@ -285,16 +285,15 @@ String Internals::address(Node* node)
return String(buf);
}
bool Internals::isPreloaded(Document* document, const String& url)
bool Internals::isPreloaded(const String& url)
{
if (!document)
return false;
Document* document = contextDocument();
return document->cachedResourceLoader()->isPreloaded(url);
}
PassRefPtr<Element> Internals::createContentElement(Document* document, ExceptionCode& ec)
PassRefPtr<Element> Internals::createContentElement(ExceptionCode& ec)
{
Document* document = contextDocument();
if (!document) {
ec = INVALID_ACCESS_ERR;
return 0;
......@@ -763,8 +762,9 @@ PassRefPtr<PagePopupController> Internals::pagePopupController()
}
#endif
PassRefPtr<ClientRect> Internals::absoluteCaretBounds(Document* document, ExceptionCode& ec)
PassRefPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionCode& ec)
{
Document* document = contextDocument();
if (!document || !document->frame() || !document->frame()->selection()) {
ec = INVALID_ACCESS_ERR;
return ClientRect::create();
......
......@@ -71,7 +71,7 @@ public:
String address(Node*);
bool isPreloaded(Document*, const String& url);
bool isPreloaded(const String& url);
size_t numberOfScopedHTMLStyleChildren(const Node*, ExceptionCode&) const;
......@@ -98,7 +98,7 @@ public:
bool pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element*, const String& pseudoId, ExceptionCode&);
bool pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element*, const String& pseudoId, ExceptionCode&);
PassRefPtr<Element> createContentElement(Document*, ExceptionCode&);
PassRefPtr<Element> createContentElement(ExceptionCode&);
bool isValidContentSelect(Element* insertionPoint, ExceptionCode&);
Node* treeScopeRootNode(Node*, ExceptionCode&);
Node* parentTreeScope(Node*, ExceptionCode&);
......@@ -127,7 +127,7 @@ public:
PassRefPtr<PagePopupController> pagePopupController();
#endif
PassRefPtr<ClientRect> absoluteCaretBounds(Document*, ExceptionCode&);
PassRefPtr<ClientRect> absoluteCaretBounds(ExceptionCode&);
PassRefPtr<ClientRect> boundingBox(Element*, ExceptionCode&);
......
......@@ -29,7 +29,7 @@
DOMString address(in Node node);
DOMString elementRenderTreeAsText(in Element element) raises(DOMException);
boolean isPreloaded(in Document document, in DOMString url);
boolean isPreloaded(in DOMString url);
unsigned long numberOfScopedHTMLStyleChildren(in Node scope) raises(DOMException);
......@@ -56,7 +56,7 @@
Element includerFor(in Node node) raises (DOMException);
DOMString shadowPseudoId(in Element element) raises (DOMException);
void setShadowPseudoId(in Element element, in DOMString id) raises (DOMException);
Element createContentElement(in Document document) raises(DOMException);
Element createContentElement() raises(DOMException);
boolean isValidContentSelect(in Element contentElement) raises(DOMException);
Node treeScopeRootNode(in Node node) raises (DOMException);
Node parentTreeScope(in Node node) raises (DOMException);
......@@ -87,7 +87,7 @@
readonly attribute PagePopupController pagePopupController;
#endif
ClientRect absoluteCaretBounds(in Document document) raises(DOMException);
ClientRect absoluteCaretBounds() raises(DOMException);
ClientRect boundingBox(in Element element) raises(DOMException);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment