Commit a2df6ed5 authored by kmccullough@apple.com's avatar kmccullough@apple.com

WebCore:

2009-04-23  Kevin McCullough  <kmccullough@apple.com>

        Reviewed by Adam Roben.

        <rdar://problem/6808109> "Deletion UI" is not available for many
        portions of HTML content

        This patch makes the deletion UI show up in some new situations:
        1) If a block's background color is different from its parent's
        2) If a block has a background image.
        3) If a block has a single visible border.
        However the block must now not only be at least a minimum width and
        height, but also exceed a minimum area.  In practice this has led to
        much better element selection. 

        * editing/DeleteButtonController.cpp:
        (WebCore::isDeletableElement):

LayoutTests:

2009-04-23  Kevin McCullough  <kmccullough@apple.com>

        Reviewed by Adam Roben.

        <rdar://problem/6808109> "Deletion UI" is not available for many
        portions of HTML content

        This patch makes the deletion UI show up in some new situations:
        1) If a block's background color is different from its parent's
        2) If a block has a background image.
        3) If a block has a single visible border.
        However the block must now not only be at least a minimum width and
        height, but also exceed a minimum area.  In practice this has led to
        much better element selection.

        * editing/deleting/deletionUI-borders.html: Added.
        * editing/deleting/deletionUI-differing-background.html: Added.
        * editing/deleting/deletionUI-minimum-size.html: Added.
        * editing/deleting/resources: Added.
        * editing/deleting/resources/deletionUI-helpers.js: Added.
        (debug):
        (determineDeletionUIExistence):
        * platform/mac/editing/deleting/deletionUI-borders-expected.txt: Added.
        * platform/mac/editing/deleting/deletionUI-differing-background-expected.txt: Added.
        * platform/mac/editing/deleting/deletionUI-minimum-size-expected.txt: Added.



git-svn-id: svn://svn.chromium.org/blink/trunk@42798 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b912cd3f
2009-04-23 Kevin McCullough <kmccullough@apple.com>
Reviewed by Adam Roben.
<rdar://problem/6808109> "Deletion UI" is not available for many
portions of HTML content
This patch makes the deletion UI show up in some new situations:
1) If a block's background color is different from its parent's
2) If a block has a background image.
3) If a block has a single visible border.
However the block must now not only be at least a minimum width and
height, but also exceed a minimum area. In practice this has led to
much better element selection.
* editing/deleting/deletionUI-borders.html: Added.
* editing/deleting/deletionUI-differing-background.html: Added.
* editing/deleting/deletionUI-minimum-size.html: Added.
* editing/deleting/resources: Added.
* editing/deleting/resources/deletionUI-helpers.js: Added.
(debug):
(determineDeletionUIExistence):
* platform/mac/editing/deleting/deletionUI-borders-expected.txt: Added.
* platform/mac/editing/deleting/deletionUI-differing-background-expected.txt: Added.
* platform/mac/editing/deleting/deletionUI-minimum-size-expected.txt: Added.
2009-04-23 Dimitri Glazkov <dglazkov@chromium.org> 2009-04-23 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Darin Adler. Reviewed by Darin Adler.
......
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<style type="text/css">
div {width:51; height:51}
#oneBorder {border-bottom:1px solid red}
#twoBorder {border-bottom:1px solid red; border-top:1px solid red}
#threeBorder {border-bottom:1px solid red; border-top:1px solid red; border-right:1px solid red}
#fourBorder {border-bottom:1px solid red; border-top:1px solid red; border-right:1px solid red; border-left:1px solid red}
</style>
<script src="resources/deletionUI-helpers.js"></script>
<script>
function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
determineDeletionUIExistence("oneBorder");
determineDeletionUIExistence("twoBorder");
determineDeletionUIExistence("threeBorder");
determineDeletionUIExistence("fourBorder");
}
</script>
</head>
<body onload="test()">
<p>This tests if the deletion UI will show on elements with different numbers of visible borders. This test can be run by DRT but not in the browser.</p>
<div id="console"></div>
<div contenteditable="true" style="padding: 1em;">
<div id="oneBorder" class="needsDeletionUI"><br></div>
<div id="twoBorder" class="needsDeletionUI"><br></div>
<div id="threeBorder" class="needsDeletionUI"><br></div>
<div id="fourBorder" class="needsDeletionUI"><br></div>
<div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<style type="text/css">
div {rgba(255, 255, 255, 0); width:51; height:51;}
#sameBackground {background-color:white}
#differentBackgroundColor {background-color:black}
#differentBackgroundImage {background-image:url("../../fast/images/resources/boston.gif")}
#semiTransparentParent {background-color:rgba(255, 0, 0, .5)}
#fullyTransparentParent {background-color:rgba(255, 0, 0, 0)}
#fullyTransparentChildWithNonTransparentParent {background-color:rgba(255, 255, 255, 0)}
#nonTransparentChildWithSemiTransparentParent {background-color:rgba(255, 0, 0, 1)}
#fullyTransparentChildWithSemiTransparentParent {background-color:rgba(255, 0, 0, 0)}
#nonTransparentChildWithFullyTransparentParent {background-color:rgba(255, 0, 0, 1)}
#fullyTransparentChildWithFullyTransparentParent {background-color:rgba(255, 0, 0, 0)}
</style>
<script src="resources/deletionUI-helpers.js"></script>
<script>
function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
determineDeletionUIExistence("sameBackground");
determineDeletionUIExistence("differentBackgroundColor");
determineDeletionUIExistence("differentBackgroundImage");
determineDeletionUIExistence("fullyTransparentChildWithNonTransparentParent");
determineDeletionUIExistence("nonTransparentChildWithSemiTransparentParent");
determineDeletionUIExistence("fullyTransparentChildWithSemiTransparentParent");
determineDeletionUIExistence("nonTransparentChildWithFullyTransparentParent");
determineDeletionUIExistence("fullyTransparentChildWithFullyTransparentParent");
}
</script>
</head>
<body onload="test()">
<p>This tests if the deletion UI will show on elements with different background colors or images. This test can be run by DRT but not in the browser.</p>
<div id="console"></div>
<div contenteditable="true" style="padding: 1em;">
<div id="sameBackground" class="needsDeletionUI"><br></div>
<div id="differentBackgroundColor" class="needsDeletionUI"><br></div>
<div id="differentBackgroundImage" class="needsDeletionUI"><br></div>
<div id="fullyTransparentChildWithNonTransparentParent" class="needsDeletionUI"><br></div>
<div id="semiTransparentParent">
<div id="nonTransparentChildWithSemiTransparentParent" class="needsDeletionUI"><br></div>
<div id="fullyTransparentChildWithSemiTransparentParent" class="needsDeletionUI"><br></div>
</div>
<div id="fullyTransparentParent">
<div id="nonTransparentChildWithFullyTransparentParent" class="needsDeletionUI"><br></div>
<div id="fullyTransparentChildWithFullyTransparentParent" class="needsDeletionUI"><br></div>
</div>
<div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<style type="text/css">
div {border:1px solid red}
#smallWidth {width:10; height:251}
#smallHeight {width:251; height:10}
#smallWidthSmallHeight {width:10; height:10}
#sufficientWidthAndHeight {width:51; height:51}
</style>
<script src="resources/deletionUI-helpers.js"></script>
<script>
function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
determineDeletionUIExistence("smallWidth");
determineDeletionUIExistence("smallHeight");
determineDeletionUIExistence("smallWidthSmallHeight");
determineDeletionUIExistence("sufficientWidthAndHeight");
}
</script>
</head>
<body onload="test()">
<p>This tests if the deletion UI will show on elements with different sizes. This test can be run by DRT but not in the browser.</p>
<div id="console"></div>
<div contenteditable="true" style="padding: 1em;">
<div id="smallWidth" class="needsDeletionUI"><br></div>
<div id="smallHeight" class="needsDeletionUI"><br></div>
<div id="smallWidthSmallHeight" class="needsDeletionUI"><br></div>
<div id="sufficientWidthAndHeight" class="needsDeletionUI"><br></div>
<div>
</body>
</html>
\ No newline at end of file
if (window.layoutTestController)
layoutTestController.dumpAsText();
function debug(msg)
{
var span = document.createElement("span");
document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
span.innerHTML = msg + '<br />';
}
function determineDeletionUIExistence(id) {
var sel = window.getSelection();
var selElement = document.getElementById(id);
sel.setPosition(selElement, 0);
var deleteButton = document.getElementById("WebKit-Editing-Delete-Button");
debug(id + (deleteButton ? " HAS " : " has NO ") + "deletion UI");
}
This tests if the deletion UI will show on elements with different numbers of visible borders. This test can be run by DRT but not in the browser.
oneBorder HAS deletion UI
twoBorder HAS deletion UI
threeBorder HAS deletion UI
fourBorder HAS deletion UI
This tests if the deletion UI will show on elements with different background colors or images. This test can be run by DRT but not in the browser.
sameBackground HAS deletion UI
differentBackgroundColor HAS deletion UI
differentBackgroundImage HAS deletion UI
fullyTransparentChildWithNonTransparentParent has NO deletion UI
nonTransparentChildWithSemiTransparentParent HAS deletion UI
fullyTransparentChildWithSemiTransparentParent has NO deletion UI
nonTransparentChildWithFullyTransparentParent HAS deletion UI
fullyTransparentChildWithFullyTransparentParent has NO deletion UI
This tests if the deletion UI will show on elements with different sizes. This test can be run by DRT but not in the browser.
smallWidth has NO deletion UI
smallHeight has NO deletion UI
smallWidthSmallHeight has NO deletion UI
sufficientWidthAndHeight HAS deletion UI
2009-04-23 Kevin McCullough <kmccullough@apple.com>
Reviewed by Adam Roben.
<rdar://problem/6808109> "Deletion UI" is not available for many
portions of HTML content
This patch makes the deletion UI show up in some new situations:
1) If a block's background color is different from its parent's
2) If a block has a background image.
3) If a block has a single visible border.
However the block must now not only be at least a minimum width and
height, but also exceed a minimum area. In practice this has led to
much better element selection.
* editing/DeleteButtonController.cpp:
(WebCore::isDeletableElement):
2009-04-23 Kevin Ollivier <kevino@theolliviers.com> 2009-04-23 Kevin Ollivier <kevino@theolliviers.com>
wx build fix. Adding XMLTokenizerScope.cpp to the build. wx build fix. Adding XMLTokenizerScope.cpp to the build.
...@@ -68,7 +68,10 @@ static bool isDeletableElement(const Node* node) ...@@ -68,7 +68,10 @@ static bool isDeletableElement(const Node* node)
const int minimumWidth = 25; const int minimumWidth = 25;
const int minimumHeight = 25; const int minimumHeight = 25;
const unsigned minimumVisibleBorders = 3; // In general we want to only draw the UI arround object of a certain area, but we still keep the min width/height to
// make sure we don't end up with very thin or very short elements getting the UI.
const int minimumArea = 2500;
const unsigned minimumVisibleBorders = 1; // To increase the number of elements which get the UI we keep low the number of visible borders required
RenderObject* renderer = node->renderer(); RenderObject* renderer = node->renderer();
if (!renderer || !renderer->isBox()) if (!renderer || !renderer->isBox())
...@@ -76,7 +79,8 @@ static bool isDeletableElement(const Node* node) ...@@ -76,7 +79,8 @@ static bool isDeletableElement(const Node* node)
RenderBox* box = toRenderBox(renderer); RenderBox* box = toRenderBox(renderer);
IntRect borderBoundingBox = box->borderBoundingBox(); IntRect borderBoundingBox = box->borderBoundingBox();
if (borderBoundingBox.width() < minimumWidth || borderBoundingBox.height() < minimumHeight) if ((borderBoundingBox.width() < minimumWidth || borderBoundingBox.height() < minimumHeight)
|| (borderBoundingBox.width() * borderBoundingBox.height()) < minimumArea)
return false; return false;
if (renderer->isTable()) if (renderer->isTable())
...@@ -91,11 +95,36 @@ static bool isDeletableElement(const Node* node) ...@@ -91,11 +95,36 @@ static bool isDeletableElement(const Node* node)
// allow block elements (excluding table cells) that have some non-transparent borders // allow block elements (excluding table cells) that have some non-transparent borders
if (renderer->isRenderBlock() && !renderer->isTableCell()) { if (renderer->isRenderBlock() && !renderer->isTableCell()) {
RenderStyle* style = renderer->style(); RenderStyle* style = renderer->style();
if (style && style->hasBorder()) { if (!style)
return false;
if (style->hasBackgroundImage() && style->backgroundImage()->canRender(1.0f))
return true;
if (style->hasBorder()) {
unsigned visibleBorders = style->borderTop().isVisible() + style->borderBottom().isVisible() + style->borderLeft().isVisible() + style->borderRight().isVisible(); unsigned visibleBorders = style->borderTop().isVisible() + style->borderBottom().isVisible() + style->borderLeft().isVisible() + style->borderRight().isVisible();
if (visibleBorders >= minimumVisibleBorders) if (visibleBorders >= minimumVisibleBorders)
return true; return true;
} }
// Background comparison to parent
Node* parentNode = node->parentNode();
if (!parentNode)
return false;
RenderObject* parentRenderer = parentNode->renderer();
if (!parentRenderer)
return false;
RenderStyle* parentStyle = parentRenderer->style();
if (!parentStyle)
return false;
if (style->backgroundColor().isValid()
&& style->backgroundColor().alpha() // not fully transparent
&& ((!parentStyle->backgroundColor().isValid() || parentStyle->backgroundColor().alpha() == 0) // if parent if invalid or transparent
|| (style->backgroundColor() != parentStyle->backgroundColor())))
return true;
} }
return false; return false;
......
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