WebCore:

2008-03-19  Justin Garcia  <justin.garcia@apple.com>

        Reviewed by Oliver.
        
        <rdar://problem/5780697> Copying content with CSS property values that are percentages can cause fidelity issues
         
        Elements with height: x%; overflow: visible; overlap what's below them when they are copied from
        a document in quirksmode and pasted into to one in standards mode.  This fix uses the computed 
        the value for a property if its value is a percentage.
        
        * css/CSSMutableStyleDeclaration.cpp:
        (WebCore::CSSMutableStyleDeclaration::addParsedProperty): Added so that we don't have to use
        setProperty from appendStartMarkup.  We already have a parsed property value, so we shouldn't
        use setProperty, since it takes in a String.  If we did, we would have to call CSSValue::cssText()
        for a String only to re-parse it in setProperty.  This wasn't extremely important now, but it will 
        be as we compute more properties to fix the rest of the copy/paste fidelity bugs.
        * css/CSSMutableStyleDeclaration.h:
        * editing/markup.cpp:
        (WebCore::appendStartMarkup): Compute values for properties that have percentage values.  We could
        perhaps narrow this special case to only include properties that are effected by quirksmode.

LayoutTests:

2008-03-19  Justin Garcia  <justin.garcia@apple.com>

        Reviewed by Oliver.
        
        <rdar://problem/5780697> Copying content with CSS property values that are percentages can cause fidelity issues

        * editing/pasteboard/5780697-2-expected.txt: Added.
        * editing/pasteboard/5780697-2.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3005eed5
2008-03-19 Justin Garcia <justin.garcia@apple.com>
Reviewed by Oliver.
<rdar://problem/5780697> Copying content with CSS property values that are percentages can cause fidelity issues
* editing/pasteboard/5780697-2-expected.txt: Added.
* editing/pasteboard/5780697-2.html: Added.
2008-03-19 Oliver Hunt <oliver@apple.com>
Reviewed by Antti.
This tests for a bug where copying content from a document in quirksmode and pasting it would produce overlapping text because of a height: 1%; overflow: visible; rule. To run manually, paste into a document not in quirksmode. The paragraphs should not overlap. When you inspect the source, the paragraphs should have pixel values for the height property.
<p style="overflow-x: visible; overflow-y: visible; height: 54px; ">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam interdum lacus id lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Quisque pulvinar, libero eu tincidunt adipiscing, quam arcu pharetra libero, sed aliquet leo eros vitae sapien.</p><p style="overflow-x: visible; overflow-y: visible; height: 54px; ">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam interdum lacus id lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Quisque pulvinar, libero eu tincidunt adipiscing, quam arcu pharetra libero, sed aliquet leo eros vitae sapien.</p><p style="overflow-x: visible; overflow-y: visible; height: 54px; ">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam interdum lacus id lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Quisque pulvinar, libero eu tincidunt adipiscing, quam arcu pharetra libero, sed aliquet leo eros vitae sapien.</p>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
p {
height: 1%;
overflow: visible;
}
</style>
</head>
<body>
<div id="description">This tests for a bug where copying content from a document in quirksmode and pasting it would produce overlapping text because of a height: 1%; overflow: visible; rule. To run manually, paste into a document not in quirksmode. The paragraphs should not overlap. When you inspect the source, the paragraphs should have pixel values for the height property.</div>
<div id="copy" contenteditable="true">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam interdum lacus id lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Quisque pulvinar, libero eu tincidunt adipiscing, quam arcu pharetra libero, sed aliquet leo eros vitae sapien.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam interdum lacus id lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Quisque pulvinar, libero eu tincidunt adipiscing, quam arcu pharetra libero, sed aliquet leo eros vitae sapien.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam interdum lacus id lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Quisque pulvinar, libero eu tincidunt adipiscing, quam arcu pharetra libero, sed aliquet leo eros vitae sapien.</p>
</div>
<div id="paste" contenteditable="true"></div>
<script>
copy = document.getElementById("copy");
copy.focus();
document.execCommand("selectall");
document.execCommand("copy");
if (window.layoutTestController) {
window.layoutTestController.dumpAsText();
paste = document.getElementById("paste");
description = document.getElementById("description");
document.getElementById("paste").focus();
document.execCommand("paste");
document.body.innerText = description.innerText + "\n\n" + paste.innerHTML;
}
</script>
</body>
</html>
2008-03-19 Justin Garcia <justin.garcia@apple.com>
Reviewed by Oliver.
<rdar://problem/5780697> Copying content with CSS property values that are percentages can cause fidelity issues
Elements with height: x%; overflow: visible; overlap what's below them when they are copied from
a document in quirksmode and pasted into to one in standards mode. This fix uses the computed
the value for a property if its value is a percentage.
* css/CSSMutableStyleDeclaration.cpp:
(WebCore::CSSMutableStyleDeclaration::addParsedProperty): Added so that we don't have to use
setProperty from appendStartMarkup. We already have a parsed property value, so we shouldn't
use setProperty, since it takes in a String. If we did, we would have to call CSSValue::cssText()
for a String only to re-parse it in setProperty. This wasn't extremely important now, but it will
be as we compute more properties to fix the rest of the copy/paste fidelity bugs.
* css/CSSMutableStyleDeclaration.h:
* editing/markup.cpp:
(WebCore::appendStartMarkup): Compute values for properties that have percentage values. We could
perhaps narrow this special case to only include properties that are effected by quirksmode.
2008-03-19 Sam Weinig <sam@webkit.org>
Reviewed by Anders Carlsson.
......@@ -578,6 +578,12 @@ void CSSMutableStyleDeclaration::addParsedProperties(const CSSProperty * const *
// a notifyChanged argument to this function to follow the model of other functions in this class.
}
void CSSMutableStyleDeclaration::addParsedProperty(const CSSProperty& property)
{
removeProperty(property.id(), false);
m_values.append(property);
}
void CSSMutableStyleDeclaration::setLengthProperty(int propertyId, const String& value, bool important, bool /*multiLength*/)
{
bool parseMode = useStrictParsing();
......
......@@ -91,6 +91,8 @@ public:
// Besides adding the properties, this also removes any existing properties with these IDs.
// It does no notification since it's called by the parser.
void addParsedProperties(const CSSProperty* const *, int numProperties);
// This does no change notifications since it's only called by createMarkup.
void addParsedProperty(const CSSProperty&);
PassRefPtr<CSSMutableStyleDeclaration> copyBlockProperties() const;
void removeBlockProperties();
......
......@@ -28,11 +28,14 @@
#include "CDATASection.h"
#include "CSSComputedStyleDeclaration.h"
#include "CSSPrimitiveValue.h"
#include "CSSProperty.h"
#include "CSSPropertyNames.h"
#include "CSSRule.h"
#include "CSSRuleList.h"
#include "CSSStyleRule.h"
#include "CSSStyleSelector.h"
#include "CSSValue.h"
#include "CSSValueKeywords.h"
#include "Comment.h"
#include "DeleteButtonController.h"
......@@ -434,6 +437,24 @@ static void appendStartMarkup(Vector<UChar>& result, const Node *node, const Ran
// over those from matched rules.
styleFromMatchedRules->merge(style.get());
style = styleFromMatchedRules;
RefPtr<CSSComputedStyleDeclaration> computedStyleForElement = computedStyle(element);
RefPtr<CSSMutableStyleDeclaration> fromComputedStyle = new CSSMutableStyleDeclaration();
DeprecatedValueListConstIterator<CSSProperty> end;
for (DeprecatedValueListConstIterator<CSSProperty> it = style->valuesIterator(); it != end; ++it) {
const CSSProperty& property = *it;
CSSValue* value = property.value();
// The property value, if it's a percentage, may not reflect the actual computed value.
// For example: style="height: 1%; overflow: visible;" in quirksmode
// FIXME: There are others like this, see <rdar://problem/5195123> Slashdot copy/paste fidelity problem
if (value->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE)
if (static_cast<CSSPrimitiveValue*>(value)->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
if (RefPtr<CSSValue> computedPropertyValue = computedStyleForElement->getPropertyCSSValue(property.id()))
fromComputedStyle->addParsedProperty(CSSProperty(property.id(), computedPropertyValue));
}
style->merge(fromComputedStyle.get());
}
if (convert)
style->setProperty(CSSPropertyDisplay, CSSValueInline, true);
......
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