Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove HTMLFrameElement.width/height
Remove HTMLFrameElement.width/height
https://bugs.webkit.org/show_bug.cgi?id=249966

Reviewed by Michael Catanzaro and Ryosuke Niwa.

This patch is to align WebKit with Gecko / Firefox and Blink / Chromium by removing non-standard attributes.

Merge - https://src.chromium.org/viewvc/blink?view=rev&revision=179130

This patch removes 'height' and 'width' attributes from the frame element, wihch were non-standard and was supported only in Internet Explorer 11 and WebKit. These were never supported by Gecko and later removed by Blink in 2014.

* Source/WebCore/html/HTMLFrameElement.idl: Remove 'height' and 'width'
* Source/WebCore/html/HTMLFrameElementBase.h: Remove 'height' and 'width' definitions
* Source/WebCore/html/HTMLFrameElementBase.cpp: Remove 'height' and 'width' functions
* Source/WebKitLegacy/mac/DOM/DOMHTMLFrameElement.mm: Ditto
* Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLFrameElement.cpp: Update to return "0" for 'height' and 'width'
* Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLFrameElement.h: Update "return" comment
* LayoutTests/fast/frames/resources/frame-programmatic-resize.js: Rebaselined
* LayoutTests/fast/frames/frames-with-frameborder-zero-can-be-resized.html: Rebaselined
* LayoutTests/fast/frames/frame-deep-nested-resize.html: Rebaselined
* LayoutTests/fast/frames/frame-inherit-noresize-from-frameset-expected.txt: Rebaselined
* LayoutTests/fast/frames/frame-js-url-clientWidth.html: Rebaselined
* LayoutTests/fast/frames/frame-js-url-clientWidth-expected.txt: Rebaselined
* LayoutTests/fast/frames/frame-programmatic-noresize-expected.txt: Rebaselined
* LayoutTests/fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize-expected.txt: Rebaselined
* LayoutTests/fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize-to-false-expected.txt: Rebaselined
* LayoutTests/fast/frames/frameElement-widthheight.html: Deleted
* LayoutTests/fast/frames/frameElement-widthheight-expected.txt: Ditto

Canonical link: https://commits.webkit.org/258573@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Jan 7, 2023
1 parent 981b5db commit 38a2ac2
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 133 deletions.
19 changes: 10 additions & 9 deletions LayoutTests/fast/frames/frame-deep-nested-resize.html
Expand Up @@ -12,9 +12,10 @@
if (success)
frame.document.write('<p>Success!</p>');
else {
var rect = frame.frameElement.getBoundingClientRect();
frame.document.write('<p>Resize until ');
frame.document.write(isWidth ? 'width:' : 'height:');
frame.document.write(isWidth ? frame.frameElement.width : frame.frameElement.height);
frame.document.write(isWidth ? rect.width : rect.height);
frame.document.write(' = ' + size + '</p>');
}
}
Expand Down Expand Up @@ -75,14 +76,14 @@
}
}
function checkSuccess() {
log(One, One.frameElement.width == 100, true, 100)
log(Two, Two.frameElement.height == 80, false, 80)
log(Three, Three.frameElement.height == 50, false, 50)
log(Four, Four.frameElement.height == 143, false, 143)
log(Five, Five.frameElement.height == 111, false, 111)
log(Six, Six.frameElement.height == 192, false, 192)
log(Seven, Seven.frameElement.width == 100, true, 100)
log(Eight, Eight.frameElement.width == 100, true, 100)
log(One, One.frameElement.getBoundingClientRect().width == 100, true, 100)
log(Two, Two.frameElement.getBoundingClientRect().height == 80, false, 80)
log(Three, Three.frameElement.getBoundingClientRect().height == 50, false, 50)
log(Four, Four.frameElement.getBoundingClientRect().height == 143, false, 143)
log(Five, Five.frameElement.getBoundingClientRect().height == 111, false, 111)
log(Six, Six.frameElement.getBoundingClientRect().height == 192, false, 192)
log(Seven, Seven.frameElement.getBoundingClientRect().width == 100, true, 100)
log(Eight, Eight.frameElement.getBoundingClientRect().width == 100, true, 100)
}

window.onload = init;
Expand Down
Expand Up @@ -10,5 +10,5 @@ Frame: 'results'
--------
This tests that a frame inherits the noresize attribute of its parent frameset by default. Note, this behavior doesn't seem to conform to any W3C spec or MSDN documentation. See WebKit Bug 57604.

PASS document.getElementById("testFrame").width is 200
PASS document.getElementById("testFrame").getBoundingClientRect().width is 200

4 changes: 2 additions & 2 deletions LayoutTests/fast/frames/frame-js-url-clientWidth-expected.txt
@@ -1,10 +1,10 @@
ALERT: This page tests whether an iframe correctly reports renderer-dependent values when executing a javascript: load. If the test passes, you'll see a series of 'PASS' messages below.

ALERT: PASS: frame.frameElement.width should be 250 and is.
ALERT: PASS: frame.frameElement.getBoundingClientRect().width should be 250 and is.

ALERT: PASS: frame.frameElement.clientWidth should be 250 and is.

ALERT: PASS: frame.frameElement.height should be 250 and is.
ALERT: PASS: frame.frameElement.getBoundingClientRect().height should be 250 and is.

ALERT: PASS: frame.frameElement.clientHeight should be 250 and is.

Expand Down
4 changes: 2 additions & 2 deletions LayoutTests/fast/frames/frame-js-url-clientWidth.html
Expand Up @@ -35,9 +35,9 @@
'when executing a javascript: load. If the test passes, you\'ll see a series of ' +
'\'PASS\' messages below.\n'
);
top.shouldBe('frame.frameElement.width', 250);
top.shouldBe('frame.frameElement.getBoundingClientRect().width', 250);
top.shouldBe('frame.frameElement.clientWidth', 250);
top.shouldBe('frame.frameElement.height', 250);
top.shouldBe('frame.frameElement.getBoundingClientRect().height', 250);
top.shouldBe('frame.frameElement.clientHeight', 250);
"
>
Expand Down
22 changes: 11 additions & 11 deletions LayoutTests/fast/frames/frame-programmatic-noresize-expected.txt
Expand Up @@ -11,25 +11,25 @@ Frame: 'results'
This tests that frame resizing is allowed and disallowed when programmatically removing and adding the noresize attribute, respectively.

Test disallow frame resize via noResize IDL attribute:
PASS document.getElementById("testFrame").width is 200
PASS document.getElementById("testFrame").getBoundingClientRect().width is 200

Test allow frame resize when noResize IDL attribute has value undefined:
PASS document.getElementById("testFrame").width is 210
PASS document.getElementById("testFrame").getBoundingClientRect().width is 210

Test allow frame resize when noResize IDL attribute has value null:
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").getBoundingClientRect().width is 220

Test disallow frame resize via noresize content attribute:
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").getBoundingClientRect().width is 220
PASS document.getElementById("testFrame").getBoundingClientRect().width is 220
PASS document.getElementById("testFrame").getBoundingClientRect().width is 220
PASS document.getElementById("testFrame").getBoundingClientRect().width is 220

Test disallow then allow frame resize via noResize IDL attribute (i.e. increase frame width by 10 pixels):
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").width is 230
PASS document.getElementById("testFrame").getBoundingClientRect().width is 220
PASS document.getElementById("testFrame").getBoundingClientRect().width is 230

Test disallow then allow frame resize via noresize content attribute (i.e. increase frame width by 10 pixels):
PASS document.getElementById("testFrame").width is 230
PASS document.getElementById("testFrame").width is 240
PASS document.getElementById("testFrame").getBoundingClientRect().width is 230
PASS document.getElementById("testFrame").getBoundingClientRect().width is 240

Expand Up @@ -10,5 +10,5 @@ Frame: 'results'
--------
This tests that a frame with a source code-specified noresize attribute can be resized after programmatically removing its noresize attribute.

PASS document.getElementById("testFrame").width is 210
PASS document.getElementById("testFrame").getBoundingClientRect().width is 210

Expand Up @@ -10,5 +10,5 @@ Frame: 'results'
--------
This tests that a frame with a source code-specified noresize attribute can be resized after setting frame.noResize to false.

PASS document.getElementById("testFrame").width is 210
PASS document.getElementById("testFrame").getBoundingClientRect().width is 210

2 changes: 0 additions & 2 deletions LayoutTests/fast/frames/frameElement-widthheight-expected.txt

This file was deleted.

46 changes: 0 additions & 46 deletions LayoutTests/fast/frames/frameElement-widthheight.html

This file was deleted.

Expand Up @@ -10,9 +10,10 @@
if (success)
frame.document.write('<p>Success!</p>');
else {
var rect = frame.frameElement.getBoundingClientRect();
frame.document.write('<p>Resize until ');
frame.document.write(isWidth ? 'width:' : 'height:');
frame.document.write(isWidth ? frame.frameElement.width : frame.frameElement.height);
frame.document.write(isWidth ? rect.width : rect.height);
frame.document.write(' = ' + size + '</p>');
}
}
Expand Down Expand Up @@ -50,8 +51,8 @@
}

function checkSuccess() {
log(One, One.frameElement.width == 100, true, 100)
log(Two, Two.frameElement.height == 80, false, 80)
log(One, One.frameElement.getBoundingClientRect().width == 100, true, 100)
log(Two, Two.frameElement.getBoundingClientRect().height == 80, false, 80)
}

window.onload = run;
Expand Down
10 changes: 5 additions & 5 deletions LayoutTests/fast/frames/resources/frame-programmatic-resize.js
Expand Up @@ -24,26 +24,26 @@ function shouldDisallowFrameResize()

function shouldDisallowFrameResizeAfterProcessingFrame(processFrameFunction)
{
var expectedWidth = _testFrame.width;
var expectedWidth = _testFrame.getBoundingClientRect().width;
processFrameFunction(_testFrame);
resizeTestFrameBy(deltaWidth());
checkTestFrameWidthEquals(expectedWidth);
}

function shouldAllowFrameResizeAfterProcessingFrame(processFrameFunction)
{
var expectedWidth = _testFrame.width + deltaWidth();
var expectedWidth = _testFrame.getBoundingClientRect().width + deltaWidth();
processFrameFunction(_testFrame);
resizeTestFrameBy(deltaWidth());
checkTestFrameWidthEquals(expectedWidth);
}

function checkTestFrameWidthEquals(expectedWidth)
{
if (_testFrame.width === expectedWidth)
log('PASS document.getElementById("' + _testFrameId + '").width is ' + expectedWidth);
if (_testFrame.getBoundingClientRect().width === expectedWidth)
log('PASS document.getElementById("' + _testFrameId + '").getBoundingClientRect().width is ' + expectedWidth);
else
log('FAIL document.getElementById("' + _testFrameId + '").width should be ' + expectedWidth + '. Was ' + _testFrame.width + '.');
log('FAIL document.getElementById("' + _testFrameId + '").getBoundingClientRect().width should be ' + expectedWidth + '. Was ' + _testFrame.getBoundingClientRect().width + '.');
}

function resizeTestFrameBy(deltaWidthInPixels)
Expand Down
7 changes: 3 additions & 4 deletions Source/WebCore/html/HTMLFrameElement.idl
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2006-2023 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
Expand All @@ -18,6 +18,8 @@
* Boston, MA 02110-1301, USA.
*/

// https://html.spec.whatwg.org/#htmlframeelement

[
Exposed=Window
] interface HTMLFrameElement : HTMLElement {
Expand All @@ -35,9 +37,6 @@

[CheckSecurityForNode] Document getSVGDocument();

[CEReactions=NotNeeded] readonly attribute long width;
[CEReactions=NotNeeded] readonly attribute long height;

// FIXME: No other browser has this attribute.
[SetterCallWith=CurrentGlobalObject] attribute DOMString? location;
};
18 changes: 1 addition & 17 deletions Source/WebCore/html/HTMLFrameElementBase.cpp
Expand Up @@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann (hausmann@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2004-2019 Apple Inc. All rights reserved.
* Copyright (C) 2004-2023 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand Down Expand Up @@ -221,22 +221,6 @@ bool HTMLFrameElementBase::isHTMLContentAttribute(const Attribute& attribute) co
return attribute.name() == srcdocAttr || HTMLFrameOwnerElement::isHTMLContentAttribute(attribute);
}

int HTMLFrameElementBase::width()
{
document().updateLayoutIgnorePendingStylesheets();
if (!renderBox())
return 0;
return renderBox()->width();
}

int HTMLFrameElementBase::height()
{
document().updateLayoutIgnorePendingStylesheets();
if (!renderBox())
return 0;
return renderBox()->height();
}

ScrollbarMode HTMLFrameElementBase::scrollingMode() const
{
auto scrollingAttribute = attributeWithoutSynchronization(scrollingAttr);
Expand Down
5 changes: 1 addition & 4 deletions Source/WebCore/html/HTMLFrameElementBase.h
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann <hausmann@kde.org>
* Copyright (C) 2004-2019 Apple Inc. All rights reserved.
* Copyright (C) 2004-2023 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand Down Expand Up @@ -41,9 +41,6 @@ class HTMLFrameElementBase : public HTMLFrameOwnerElement {

ScrollbarMode scrollingMode() const final;

WEBCORE_EXPORT int width();
WEBCORE_EXPORT int height();

protected:
HTMLFrameElementBase(const QualifiedName&, Document&);

Expand Down
Expand Up @@ -185,10 +185,8 @@ static void webkit_dom_html_frame_element_get_property(GObject* object, guint pr
g_value_set_object(value, webkit_dom_html_frame_element_get_content_window(self));
break;
case DOM_HTML_FRAME_ELEMENT_PROP_WIDTH:
g_value_set_long(value, webkit_dom_html_frame_element_get_width(self));
break;
case DOM_HTML_FRAME_ELEMENT_PROP_HEIGHT:
g_value_set_long(value, webkit_dom_html_frame_element_get_height(self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
Expand Down Expand Up @@ -491,20 +489,14 @@ WebKitDOMDOMWindow* webkit_dom_html_frame_element_get_content_window(WebKitDOMHT

glong webkit_dom_html_frame_element_get_width(WebKitDOMHTMLFrameElement* self)
{
WebCore::JSMainThreadNullState state;
g_return_val_if_fail(WEBKIT_DOM_IS_HTML_FRAME_ELEMENT(self), 0);
WebCore::HTMLFrameElement* item = WebKit::core(self);
glong result = item->width();
return result;
return 0;
}

glong webkit_dom_html_frame_element_get_height(WebKitDOMHTMLFrameElement* self)
{
WebCore::JSMainThreadNullState state;
g_return_val_if_fail(WEBKIT_DOM_IS_HTML_FRAME_ELEMENT(self), 0);
WebCore::HTMLFrameElement* item = WebKit::core(self);
glong result = item->height();
return result;
return 0;
}

G_GNUC_END_IGNORE_DEPRECATIONS;
Expand Up @@ -250,7 +250,7 @@ webkit_dom_html_frame_element_get_content_window(WebKitDOMHTMLFrameElement* self
* webkit_dom_html_frame_element_get_width:
* @self: A #WebKitDOMHTMLFrameElement
*
* Returns: A #glong
* Returns: 0
*
* Deprecated: 2.22: Use JavaScriptCore API instead
**/
Expand All @@ -261,7 +261,7 @@ webkit_dom_html_frame_element_get_width(WebKitDOMHTMLFrameElement* self);
* webkit_dom_html_frame_element_get_height:
* @self: A #WebKitDOMHTMLFrameElement
*
* Returns: A #glong
* Returns: 0
*
* Deprecated: 2.22: Use JavaScriptCore API instead
**/
Expand Down
14 changes: 1 addition & 13 deletions Source/WebKitLegacy/mac/DOM/DOMHTMLFrameElement.mm
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004-2016 Apple Inc. All rights reserved.
* Copyright (C) 2004-2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -163,18 +163,6 @@ - (void)setLocation:(NSString *)newLocation
IMPL->setLocation(newLocation);
}

- (int)width
{
WebCore::JSMainThreadNullState state;
return IMPL->width();
}

- (int)height
{
WebCore::JSMainThreadNullState state;
return IMPL->height();
}

@end

#undef IMPL

0 comments on commit 38a2ac2

Please sign in to comment.