COMMIT_MESSAGE

 1Allow listbox content and scrollbar to intrude padding area.
 2https://bugs.webkit.org/show_bug.cgi?id=128489
 3
 4Source/WebCore:
 5
 6Reviewed by NOBODY (OOPS!).
 7
 8Originally when the RenderListBox::controlClipRect method was implemented (see [1]), it used
 9to allow its content (<option>'s) to intrude padding to get rendered. Overlay scrollbars were also
 10allowed to paint over the padding area, if necessary.
 11
 12[2] changed this behavior to restrict list-box'es content within the content box rect (excluding padding and border).
 13
 14This had two consequences:
 151) it made WebKit disallow list-box' content to intrude the padding area, diverging from other vendors.
 16like Firefox and Chrome.
 172) Since overlay scrollbar might get painted over the padding area, if any, [2] could result
 18in the scrollbar being clipped out if padding-right is set (or padding-left in case of RTL content).
 19
 20Patch changed WebKit back so that it allows list-box' content and overlay scrollbars to intrude the
 21padding area, matching other browsers vendors
 22
 23[1] https://trac.webkit.org/changeset/18819/trunk/WebCore/rendering/RenderListBox.cpp
 24[2] https://trac.webkit.org/changeset/19037/trunk/WebCore/rendering/RenderListBox.cpp
 25
 26Tests: fast/forms/listbox-selection-3.html
 27 fast/forms/listbox-padding-clip-expected-mismatch.html (renamed from listbox-padding-clip-overlay-expected.html)
 28 fast/forms/listbox-padding-clip-overlay-expected-mismatch.html (renamed from listbox-padding-clip-expected.html)
 29
 30* rendering/RenderListBox.cpp:
 31(WebCore::RenderListBox::numVisibleItems): changed to allow list-box items to get rendered on the padding-bottom area.
 32This matches Firefox and Chrome.
 33(WebCore::RenderListBox::listIndexAtOffset): relax the check for a given list-box item at a specific offset in the vertical axis.
 34This means if an list-box item has its content painted into the padding-bottom area, it will be actionable by mouse clicking.
 35This matches Firefox and Chrome.
 36(WebCore::RenderListBox::controlClipRect): clips list-box content against the padding box rect rather than the content box rect,
 37to allow its list-box items' content intrude the padding area.
 38This matches Firefox and Chrome.
 39
 40LayoutTests:
 41
 42* fast/forms/listbox-selection-3-expected.txt: Added.
 43* fast/forms/listbox-selection-3.html: Added.
 44* fast/forms/listbox-padding-clip-expected-mismatch.html: Renamed from listbox-padding-clip-overlay-expected.html.
 45* fast/forms/listbox-padding-clip-overlay-expected-mismatch.html: Renamed from listbox-padding-clip-expected.html.

LayoutTests/ChangeLog

 12016-04-08 Antonio Gomes <tonikitoo@webkit.org>
 2
 3 Allow listbox content and scrollbar to intrude padding area.
 4 https://bugs.webkit.org/show_bug.cgi?id=128489
 5
 6 * fast/forms/listbox-selection-3-expected.txt: Added.
 7 * fast/forms/listbox-selection-3.html: Added.
 8 * fast/forms/listbox-padding-clip-expected-mismatch.html: Renamed from listbox-padding-clip-overlay-expected.html.
 9 * fast/forms/listbox-padding-clip-overlay-expected-mismatch.html: Renamed from listbox-padding-clip-expected.html.
 10
1112016-04-08 Joseph Pecoraro <pecoraro@apple.com>
212
313 Redefining a method of the same name hits an assertion

LayoutTests/fast/forms/listbox-padding-clip-expected-mismatch.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4</head>
 5<body>
 6<p>This test makes sure that the contents of list boxes do not intrude upon their padding. The test passes if you see a tall green box below (and not a single black pixel anywhere inside it)<p>
 7<div style="display: inline-block; width: 100px; height: 400px; background: green;"></div>
 8</body>
 9</html>

LayoutTests/fast/forms/listbox-padding-clip-expected.html

1 <!DOCTYPE html>
2 <html>
3 <head>
4 </head>
5 <body>
6 <p>This test makes sure that the contents of list boxes do not intrude upon their padding. The test passes if you see a tall green box below (and not a single black pixel anywhere inside it)<p>
7 <div style="display: inline-block; width: 100px; height: 400px; background: green;"></div>
8 </body>
9 </html>

LayoutTests/fast/forms/listbox-padding-clip-overlay-expected-mismatch.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4</head>
 5<body>
 6<p>This test makes sure that the contents of list boxes do not intrude upon their padding. The test passes if you see a tall green box below (and not a single black pixel anywhere inside it)<p>
 7<div style="display: inline-block; width: 100px; height: 400px; background: green;"></div>
 8</body>
 9</html>

LayoutTests/fast/forms/listbox-padding-clip-overlay-expected.html

1 <!DOCTYPE html>
2 <html>
3 <head>
4 </head>
5 <body>
6 <p>This test makes sure that the contents of list boxes do not intrude upon their padding. The test passes if you see a tall green box below (and not a single black pixel anywhere inside it)<p>
7 <div style="display: inline-block; width: 100px; height: 400px; background: green;"></div>
8 </body>
9 </html>

LayoutTests/fast/forms/listbox-selection-3-expected.txt

 1Clicking on items of <select> with padding set.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS successfullyParsed is true
 7
 8TEST COMPLETE
 9PASS selectionPattern("sl1") is "00000000000000000"
 10PASS selectionPattern("sl1") is "01000000000000000"
 11PASS selectionPattern("sl1") is "10000000000000000"
 12PASS selectionPattern("sl1") is "10000000000000000"
 13PASS selectionPattern("sl1") is "10000000000000000"
 14PASS selectionPattern("sl1") is "00000000100000000"
 15

LayoutTests/fast/forms/listbox-selection-3.html

 1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 2<html>
 3<head>
 4<script src="../../resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<p id="description"></p>
 8<div id="console"></div>
 9<script>
 10description('Clicking on items of &lt;select> with padding set.');
 11
 12var parent = document.createElement('div');
 13parent.innerHTML = '<select id="sl1" multiple size=5>'
 14 + '<option id="opt1">one</option>'
 15 + '<option id="opt2">two</option>'
 16 + '<option id="opt3">three</option>'
 17 + '<option id="opt4">four</option>'
 18 + '<option id="opt5">five</option>'
 19 + '<option id="opt6">six</option>'
 20 + '<option id="opt7">seven</option>'
 21 + '<option id="opt8">eight</option>'
 22 + '<option id="opt9">nine</option>'
 23 + '<option id="opt10">ten</option>'
 24 + '<option id="opt11">eleven</option>'
 25 + '<option id="opt12">twelve</option>'
 26 + '<option id="opt13">thirteen</option>'
 27 + '<option id="opt14">fourteen</option>'
 28 + '<option id="opt15">fifteen</option>'
 29 + '<option id="opt16">sixteen</option>'
 30 + '<option id="opt17">seventeen</option>'
 31 + '</select>';
 32document.body.appendChild(parent);
 33
 34// Determine the item height.
 35var sl1 = document.getElementById('sl1');
 36var sl2 = document.getElementById('sl2');
 37var itemHeight = Math.floor(sl1.offsetHeight / sl1.size);
 38sl1.removeAttribute('size');
 39var height = itemHeight * 9;
 40sl1.setAttribute('style', 'height: ' + height + 'px; border: 0px; padding-top: 0px; padding-left: 25px; padding-right: 25px; padding-bottom: 20px;');
 41
 42var kClickOnPaddingLeftArea = 1;
 43var kClickOnPaddingRightArea = 2;
 44var kClickOnOptionElement = 3;
 45
 46function mouseDownOnSelect(selId, index, fudge)
 47{
 48 var sl = document.getElementById(selId);
 49 var opt = document.getElementById("opt" + index);
 50 var paddingTop = 0;
 51 var paddingLeft = 25;
 52 var paddingRight = 25;
 53
 54 // default clicking to the middle of the option element.
 55 var x = ((sl.offsetLeft + sl.offsetWidth - paddingRight) - (sl.offsetLeft + paddingLeft)) / 2;
 56 x += sl.offsetLeft + paddingLeft;
 57
 58 var y = (index - 1) * itemHeight + itemHeight / 3 - window.pageYOffset + paddingTop;
 59 y += sl.offsetTop;
 60
 61 if (fudge == kClickOnPaddingLeftArea) {
 62 x = opt.offsetLeft + (paddingLeft / 2); // middle of the padding left area.
 63 } else if (fudge == kClickOnOptionElement) {
 64 // do nothing, already set as default value above.
 65 } else if (fudge == kClickOnPaddingRightArea) {
 66 x = opt.offsetRight + (paddingRight / 2); // middle of the padding right area.
 67 }
 68 var event = document.createEvent("MouseEvent");
 69 event.initMouseEvent("mousedown", true, true, document.defaultView, 1, x, y, x, y, false, false, false, false, 0, document);
 70 sl.dispatchEvent(event);
 71}
 72
 73function selectionPattern(selectId)
 74{
 75 var select = document.getElementById(selectId);
 76 var result = "";
 77 for (var i = 0; i < select.options.length; i++)
 78 result += select.options[i].selected ? '1' : '0';
 79 return result;
 80}
 81
 82window.onload = function () {
 83 mouseDownOnSelect("sl1", 2, kClickOnPaddingRightArea);
 84 shouldBe('selectionPattern("sl1")', '"00000000000000000"');
 85
 86 mouseDownOnSelect("sl1", 2, kClickOnOptionElement);
 87 shouldBe('selectionPattern("sl1")', '"01000000000000000"');
 88
 89 mouseDownOnSelect("sl1", 1, kClickOnOptionElement);
 90 shouldBe('selectionPattern("sl1")', '"10000000000000000"');
 91
 92 mouseDownOnSelect("sl1", 2, kClickOnPaddingRightArea);
 93 shouldBe('selectionPattern("sl1")', '"10000000000000000"');
 94
 95 mouseDownOnSelect("sl1", 2, kClickOnPaddingLeftArea);
 96 shouldBe('selectionPattern("sl1")', '"10000000000000000"');
 97
 98 mouseDownOnSelect("sl1", 9, kClickOnOptionElement);
 99 shouldBe('selectionPattern("sl1")', '"00000000100000000"');
 100};
 101</script>
 102<script src="../../resources/js-test-post.js"></script>
 103</body>
 104</html>

Source/WebCore/ChangeLog

 12016-04-08 Antonio Gomes <tonikitoo@webkit.org>
 2
 3 Allow listbox content and scrollbar to intrude padding area.
 4 https://bugs.webkit.org/show_bug.cgi?id=128489
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Originally when the RenderListBox::controlClipRect method was implemented (see [1]), it used
 9 to allow its content (<option>'s) to intrude padding to get rendered. Overlay scrollbars were also
 10 allowed to paint over the padding area, if necessary.
 11
 12 [2] changed this behavior to restrict list-box'es content within the content box rect (excluding padding and border).
 13
 14 This had two consequences:
 15 1) it made WebKit disallow list-box' content to intrude the padding area, diverging from other vendors.
 16 like Firefox and Chrome.
 17 2) Since overlay scrollbar might get painted over the padding area, if any, [2] could result
 18 in the scrollbar being clipped out if padding-right is set (or padding-left in case of RTL content).
 19
 20 Patch changed WebKit back so that it allows list-box' content and overlay scrollbars to intrude the
 21 padding area, matching other browsers vendors
 22
 23 [1] https://trac.webkit.org/changeset/18819/trunk/WebCore/rendering/RenderListBox.cpp
 24 [2] https://trac.webkit.org/changeset/19037/trunk/WebCore/rendering/RenderListBox.cpp
 25
 26 Tests: fast/forms/listbox-selection-3.html
 27 fast/forms/listbox-padding-clip-expected-mismatch.html (renamed from listbox-padding-clip-overlay-expected.html)
 28 fast/forms/listbox-padding-clip-overlay-expected-mismatch.html (renamed from listbox-padding-clip-expected.html)
 29
 30 * rendering/RenderListBox.cpp:
 31 (WebCore::RenderListBox::numVisibleItems): changed to allow list-box items to get rendered on the padding-bottom area.
 32 This matches Firefox and Chrome.
 33 (WebCore::RenderListBox::listIndexAtOffset): relax the check for a given list-box item at a specific offset in the vertical axis.
 34 This means if an list-box item has its content painted into the padding-bottom area, it will be actionable by mouse clicking.
 35 This matches Firefox and Chrome.
 36 (WebCore::RenderListBox::controlClipRect): clips list-box content against the padding box rect rather than the content box rect,
 37 to allow its list-box items' content intrude the padding area.
 38 This matches Firefox and Chrome.
 39
1402016-04-08 Beth Dakin <bdakin@apple.com>
241
342 Fix leaks in WebAVMediaSelectionOptionMac and WebPlaybackControlsManager

Source/WebCore/rendering/RenderListBox.cpp

@@int RenderListBox::size() const
240240int RenderListBox::numVisibleItems() const
241241{
242242 // Only count fully visible rows. But don't return 0 even if only part of a row shows.
243  return std::max<int>(1, (contentHeight() + rowSpacing) / itemHeight());
 243 return std::max<int>(1, (contentHeight() + paddingBottom() + rowSpacing) / itemHeight());
244244}
245245
246246int RenderListBox::numItems() const

@@int RenderListBox::listIndexAtOffset(const LayoutSize& offset)
471471 if (!numItems())
472472 return -1;
473473
474  if (offset.height() < borderTop() + paddingTop() || offset.height() > height() - paddingBottom() - borderBottom())
 474 if (offset.height() < borderTop() || offset.height() > height() - borderBottom())
475475 return -1;
476476
477477 int scrollbarWidth = m_vBar ? m_vBar->width() : 0;

@@bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
731731
732732LayoutRect RenderListBox::controlClipRect(const LayoutPoint& additionalOffset) const
733733{
734  LayoutRect clipRect = contentBoxRect();
 734 // Clip against the padding box, to give <option>s and overlay scrollbar some extra space
 735 // to get painted.
 736 LayoutRect clipRect = paddingBoxRect();
735737 if (verticalScrollbarIsOnLeft() && (!layer() || !layer()->verticalScrollbarIsOnLeft()))
736738 clipRect.move(m_vBar->occupiedWidth(), 0);
737739 clipRect.moveBy(additionalOffset);