Changeset 112177 in webkit


Ignore:
Timestamp:
Mar 26, 2012 4:59:27 PM (12 years ago)
Author:
rniwa@webkit.org
Message:

cssText should use shorthand notations
https://bugs.webkit.org/show_bug.cgi?id=81737

Reviewed by Enrica Casucci.

Source/JavaScriptCore:

Export symbols of BitVector on Windows.

Source/WebCore:

Use shorthand properties to serialize style properties for cssText.

The overall algorithm is to look for any property that has a shorthand, and then check if
the shorthand value could be obtained (the condition is quite complicated for border properties).
If it could, then append that value to the string builder, and set the corresponding entries in
shorthandPropertyAppeared and shorthandPropertyUsed. If not, only turn on the bit in
shorthandPropertyAppeared on to avoid calling getPropertyValue again for longhand properties
that use the same shorthand property when we cannot use the shorthand.

Test: fast/css/cssText-shorthand.html

  • css/StylePropertySet.cpp:

(WebCore::StylePropertySet::asText):

Source/WTF:

  • wtf/BitVector.h:

(BitVector):
(WTF::BitVector::ensureSizeAndSet): Added.

LayoutTests:

Rebaseline existing tests and add a regression test for unprefixed CSS properties with
the exception of -webkit-border-horizontal/vertical-spacing (the shorthand version of
these properties (border-spacing) is unprefixed.

  • editing/pasteboard/paste-and-sanitize-expected.txt: Uses border instead of longhand

properties as desired.

  • editing/pasteboard/paste-and-sanitize.html:
  • editing/style/non-inheritable-styles-expected.txt: Ditto.
  • fast/css/background-position-serialize-expected.txt: No longer emits "background-*:

initial" as desired.

  • fast/css/cssText-shorthand-expected.txt: Added.
  • fast/css/cssText-shorthand.html: Added.
  • fast/css/remove-shorthand-expected.txt:
  • fast/css/remove-shorthand.html: Modified to do elaborative comparison of the lists of

properties before and after removing a shorthand since now removing a shorthand property
may end up adding new longhand property.

  • fast/css/uri-token-parsing-expected.txt:
  • fast/css/uri-token-parsing.html: Uses shorthand properties instead of longhand equivalents.
  • inspector/styles/styles-update-from-js-expected.txt: Ditto.
  • printing/page-rule-css-text-expected.txt: Ditto.
Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112169 r112177  
     12012-03-23  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        cssText should use shorthand notations
     4        https://bugs.webkit.org/show_bug.cgi?id=81737
     5
     6        Reviewed by Enrica Casucci.
     7
     8        Rebaseline existing tests and add a regression test for unprefixed CSS properties with
     9        the exception of -webkit-border-horizontal/vertical-spacing (the shorthand version of
     10        these properties (border-spacing) is unprefixed.
     11
     12        * editing/pasteboard/paste-and-sanitize-expected.txt: Uses border instead of longhand
     13        properties as desired.
     14        * editing/pasteboard/paste-and-sanitize.html:
     15        * editing/style/non-inheritable-styles-expected.txt: Ditto.
     16        * fast/css/background-position-serialize-expected.txt: No longer emits "background-*:
     17        initial" as desired.
     18        * fast/css/cssText-shorthand-expected.txt: Added.
     19        * fast/css/cssText-shorthand.html: Added.
     20        * fast/css/remove-shorthand-expected.txt:
     21        * fast/css/remove-shorthand.html: Modified to do elaborative comparison of the lists of
     22        properties before and after removing a shorthand since now removing a shorthand property
     23        may end up adding new longhand property.
     24        * fast/css/uri-token-parsing-expected.txt:
     25        * fast/css/uri-token-parsing.html: Uses shorthand properties instead of longhand equivalents.
     26        * inspector/styles/styles-update-from-js-expected.txt: Ditto.
     27        * printing/page-rule-css-text-expected.txt: Ditto.
     28
    1292012-03-26  Emil A Eklund  <eae@chromium.org>
    230
  • trunk/LayoutTests/editing/pasteboard/paste-and-sanitize-expected.txt

    r102846 r112177  
    99PASS confirmedMarkup is '<div><b><i>hello</i></b></div><div><b><i>world</i></b></div>'
    1010PASS confirmedMarkup is '<b><i><span style="font-weight: normal; "><b><i>hello1</i></b><b><i>&nbsp;hello2</i></b></span></i></b>'
    11 PASS confirmedMarkup is '<i style="margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; "><b><i style="margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; ">hello</i></b></i>'
     11FAIL confirmedMarkup should be <i style="margin: 10px; ">hello</i></b></i>. Was <i style="margin: 10px; "><b><i style="margin: 10px; ">hello</i></b></i>.
    1212PASS confirmedMarkup is '<b><i>Hello&nbsp;world</i></b>'
    1313PASS confirmedMarkup is '<b><i><span style="font-weight: normal; ">plain text<b><i>bold italic text</i></b></span></i></b>'
  • trunk/LayoutTests/editing/pasteboard/paste-and-sanitize.html

    r102846 r112177  
    4545testPaste("div", "<div><b><i><span style=\"font-weight: normal; \"><b><i>hello1</i></b><b><i> hello2</i></b></span></i></b></div>", "<b><i><span style=\"font-weight: normal; \"><b><i>hello1</i></b><b><i>&nbsp;hello2</i></b></span></i></b>");
    4646testPaste("div", "<i style=\"margin: 10px;\"><b><i style=\"margin: 10px;\">hello</i></b></i>",
    47           "<i style=\"margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; \"><b><i style=\"margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; \">hello</i></b></i>");
     47          "<i style=\"margin: 10px; \">hello</i></b></i>");
    4848testPaste("div", "<div><b><i><span style=\"font-weight: normal\"><b><i>Hello <!-- comment -->world</i></b></span></i></b></div>", "<b><i>Hello&nbsp;world</i></b>");
    4949testPaste("div", "<div><b><i><span style=\"font-weight: normal\">plain text<b><i>bold italic text</i></b></span></i></b></div>", "<b><i><span style=\"font-weight: normal; \">plain text<b><i>bold italic text</i></b></span></i></b>");
  • trunk/LayoutTests/editing/style/non-inheritable-styles-expected.txt

    r95279 r112177  
    44|   class="class"
    55|   id="id"
    6 |   style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: blue; border-right-color: blue; border-bottom-color: blue; border-left-color: blue; border-image: initial; "
     6|   style="border: 1px solid blue; "
    77|   "This should have blue border when its pasted."
    88| "This shouldn't have a border.<#selection-caret>"
  • trunk/LayoutTests/fast/css/background-position-serialize-expected.txt

    r47906 r112177  
    6060t.style.backgroundPositionY = '50px'
    6161style.cssText =
    62 background-image: url(about:blank); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 80% 50px; background-repeat: initial initial;
     62background-image: url(about:blank); background-position: 80% 50px; background-repeat: initial initial;
  • trunk/LayoutTests/fast/css/remove-shorthand-expected.txt

    r68561 r112177  
    33Starting with a declaration containing all properties that are constituents of shortcuts, see what is removed when a shortcut property is removed. The shortcut’s constituents and only them should be removed.
    44
    5 Removing background removes background-image, background-attachment, background-origin, background-clip, background-color, background-position, background-repeat.
    6 Removing background-position removes background-position.
    7 Removing border removes border-top-width, border-right-width, border-bottom-width, border-left-width, border-top-style, border-right-style, border-bottom-style, border-left-style, border-top-color, border-right-color, border-bottom-color, border-left-color.
    8 Removing border-top removes border-top-width, border-top-style, border-top-color.
    9 Removing border-right removes border-right-width, border-right-style, border-right-color.
    10 Removing border-bottom removes border-bottom-width, border-bottom-style, border-bottom-color.
    11 Removing border-left removes border-left-width, border-left-style, border-left-color.
    12 Removing border-color removes border-top-color, border-right-color, border-bottom-color, border-left-color.
    13 Removing border-style removes border-top-style, border-right-style, border-bottom-style, border-left-style.
    14 Removing border-width removes border-top-width, border-right-width, border-bottom-width, border-left-width.
    15 Removing border-radius removes border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius.
    16 Removing -webkit-border-radius removes border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius.
    17 Removing border-spacing removes -webkit-border-horizontal-spacing, -webkit-border-vertical-spacing.
    18 Removing -webkit-columns removes -webkit-column-width, -webkit-column-count.
    19 Removing -webkit-column-rule removes -webkit-column-rule-width, -webkit-column-rule-style, -webkit-column-rule-color.
    20 Removing list-style removes list-style-type, list-style-position, list-style-image.
    21 Removing margin removes margin-top, margin-right, margin-bottom, margin-left.
    22 Removing -webkit-margin-collapse removes -webkit-margin-before-collapse, -webkit-margin-after-collapse.
    23 Removing -webkit-marquee removes -webkit-marquee-direction, -webkit-marquee-increment, -webkit-marquee-repetition, -webkit-marquee-style, -webkit-marquee-speed.
    24 Removing -webkit-mask removes -webkit-mask-image, -webkit-mask-repeat-x, -webkit-mask-repeat-y, -webkit-mask-attachment, -webkit-mask-position-x, -webkit-mask-position-y, -webkit-mask-origin, -webkit-mask-clip.
    25 Removing -webkit-mask-position removes -webkit-mask-position-x, -webkit-mask-position-y.
    26 Removing overflow removes overflow-x, overflow-y.
    27 Removing padding removes padding-top, padding-right, padding-bottom, padding-left.
    28 Removing -webkit-text-stroke removes -webkit-text-stroke-color, -webkit-text-stroke-width.
     5Removing background
     6removes "background-image, background-attachment, background-color, background-position, background-repeat"
     7and adds "".
     8Removing background-position
     9removes "background-position"
     10and adds "".
     11Removing border
     12removes "border"
     13and adds "".
     14Removing border-top
     15removes "border"
     16and adds "border-right-width, border-bottom-width, border-left-width, border-right-style, border-bottom-style, border-left-style, border-right-color, border-bottom-color, border-left-color".
     17Removing border-right
     18removes "border"
     19and adds "border-top-width, border-bottom-width, border-left-width, border-top-style, border-bottom-style, border-left-style, border-top-color, border-bottom-color, border-left-color".
     20Removing border-bottom
     21removes "border"
     22and adds "border-top-width, border-right-width, border-left-width, border-top-style, border-right-style, border-left-style, border-top-color, border-right-color, border-left-color".
     23Removing border-left
     24removes "border"
     25and adds "border-top-width, border-right-width, border-bottom-width, border-top-style, border-right-style, border-bottom-style, border-top-color, border-right-color, border-bottom-color".
     26Removing border-color
     27removes "border"
     28and adds "border".
     29Removing border-style
     30removes "border"
     31and adds "border".
     32Removing border-width
     33removes "border"
     34and adds "border".
     35Removing border-radius
     36removes "border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius"
     37and adds "".
     38Removing -webkit-border-radius
     39removes "border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius"
     40and adds "".
     41Removing border-spacing
     42removes "border-spacing"
     43and adds "".
     44Removing -webkit-columns
     45removes "-webkit-column-width, -webkit-column-count"
     46and adds "".
     47Removing -webkit-column-rule
     48removes "-webkit-column-rule-width, -webkit-column-rule-style, -webkit-column-rule-color"
     49and adds "".
     50Removing list-style
     51removes "list-style-type, list-style-position, list-style-image"
     52and adds "".
     53Removing margin
     54removes "margin"
     55and adds "".
     56Removing -webkit-margin-collapse
     57removes "-webkit-margin-before-collapse, -webkit-margin-after-collapse"
     58and adds "".
     59Removing -webkit-marquee
     60removes "-webkit-marquee-direction, -webkit-marquee-increment, -webkit-marquee-repetition, -webkit-marquee-style, -webkit-marquee-speed"
     61and adds "".
     62Removing -webkit-mask
     63removes "-webkit-mask"
     64and adds "".
     65Removing -webkit-mask-position
     66removes "-webkit-mask"
     67and adds "-webkit-mask".
     68Removing overflow
     69removes "overflow"
     70and adds "".
     71Removing padding
     72removes "padding"
     73and adds "".
     74Removing -webkit-text-stroke
     75removes "-webkit-text-stroke-color, -webkit-text-stroke-width"
     76and adds "".
  • trunk/LayoutTests/fast/css/remove-shorthand.html

    r46508 r112177  
    3131            var remainingProperties = element.style.cssText.split("; ");
    3232            var removedProperties = [];
    33             var p;
    34             while (p = allProperties.shift()) {
    35                 if (remainingProperties[0] == p)
    36                     remainingProperties.shift();
    37                 else
    38                     removedProperties.push("<tt>" + p.replace(/\:.*/,"") + "</tt>");
     33            var addedProperties = [];
     34
     35            for (var i = 0; i < allProperties.length; i++) {
     36                if (remainingProperties.indexOf(allProperties[i]) < 0)
     37                    removedProperties.push("<tt>" + allProperties[i].replace(/\:.*/,"") + "</tt>");
    3938            }
    40             log("Removing <tt>" + shorthand + "</tt> removes " + removedProperties.join(", ") +".");
     39            for (var i = 0; i < remainingProperties.length; i++) {
     40                if (allProperties.indexOf(remainingProperties[i]) < 0)
     41                    addedProperties.push("<tt>" + remainingProperties[i].replace(/\:.*/,"") + "</tt>");
     42            }
     43
     44            log("Removing <tt>" + shorthand + '</tt><br>removes "' + removedProperties.join(", ")
     45                + '"<br>and adds "' + addedProperties.join(", ") + '".');
    4146        }
    4247       
  • trunk/LayoutTests/fast/css/uri-token-parsing-expected.txt

    r98366 r112177  
    2020#p { content: url('url(g)'); }
    2121#q { cursor: url('url(q)'); }
    22 #r { list-style-image: url('url(r)'); }
     22#r { list-style: url('url(r)'); }
    2323#s { background-image: url('url(s)'); }
    24 #t { -webkit-mask-image: url('url(t)'); }
     24#t { -webkit-mask: url('url(t)'); }
    2525#u { -webkit-border-image: url('url(u)') 1 2 3 4 fill stretch round; }
    2626#v { -webkit-mask-box-image: url('url(v)') 1 2 3 4 fill stretch round; }
     
    4545#p { content: url('url(g)'); }
    4646#q { cursor: url('url(q)'); }
    47 #r { list-style-image: url('url(r)'); }
     47#r { list-style: url('url(r)'); }
    4848#s { background-image: url('url(s)'); }
    49 #t { -webkit-mask-image: url('url(t)'); }
     49#t { -webkit-mask: url('url(t)'); }
    5050#u { -webkit-border-image: url('url(u)') 1 2 3 4 fill stretch round; }
    5151#v { -webkit-mask-box-image: url('url(v)') 1 2 3 4 fill stretch round; }
  • trunk/LayoutTests/fast/css/uri-token-parsing.html

    r98366 r112177  
    9494#p { content: url('url(g)'); }
    9595#q { cursor: url('url(q)'); }
    96 #r { list-style-image: url('url(r)'); }
     96#r { list-style: url('url(r)'); }
    9797#s { background-image: url('url(s)'); }
    98 #t { -webkit-mask-image: url('url(t)'); }
     98#t { -webkit-mask: url('url(t)'); }
    9999#u { -webkit-border-image: url('url(u)') 1 2 3 4 fill stretch round; }
    100100#v { -webkit-mask-box-image: url('url(v)') 1 2 3 4 fill stretch round; }
  • trunk/LayoutTests/inspector/styles/styles-update-from-js-expected.txt

    r99713 r112177  
    3434
    3535Running: testSetViaParsedAttributes
    36 <div id="container" style="color: rgb(192, 255, 238); border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: green; border-right-color: green; border-bottom-color: green; border-left-color: green; border-image: initial; border-top-width: 3px; border-right-width: 3px; border-bottom-width: 3px; border-left-width: 3px; "></div>
     36<div id="container" style="color: rgb(192, 255, 238); border: 3px dashed green; "></div>
    3737[expanded]
    3838element.style  { ()
     
    4747    border-bottom-color: green;
    4848    border-left-color: green;
    49 border-image: initial;
    5049border-width: 3px;
    5150    border-top-width: 3px;
  • trunk/LayoutTests/printing/page-rule-css-text-expected.txt

    r59751 r112177  
    22@page :left { margin-right: 3cm; }
    33@page :right { margin-left: 3cm; }
    4 @page :first { border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; }
     4@page :first { border: 1px; }
    55@page hello { color: green; }
    66@page world:right { background-color: green; }
    7 @media print { @page somepage:first { margin-top: 3cm; margin-right: 3cm; margin-bottom: 3cm; margin-left: 3cm; } }
     7@media print { @page somepage:first { margin: 3cm; } }
    88@page auto_page { size: auto; }
    99@page square_page { size: 4in; }
  • trunk/Source/JavaScriptCore/ChangeLog

    r112164 r112177  
     12012-03-26  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        cssText should use shorthand notations
     4        https://bugs.webkit.org/show_bug.cgi?id=81737
     5
     6        Reviewed by Enrica Casucci.
     7
     8        Export symbols of BitVector on Windows.
     9
     10        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     11
    1122012-03-26  Filip Pizlo  <fpizlo@apple.com>
    213
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r111197 r112177  
    158158    ?destroy@JSCell@JSC@@KAXPAV12@@Z
    159159    ?destroy@JSGlobalObject@JSC@@SAXPAVJSCell@2@@Z
     160    ?destroy@OutOfLineBits@BitVector@WTF@@SAXPAV123@@Z
    160161    ?detach@Debugger@JSC@@UAEXPAVJSGlobalObject@2@@Z
    161162    ?detachThread@WTF@@YAXI@Z
     
    296297    ?resetDateCache@JSGlobalData@JSC@@QAEXXZ
    297298    ?resize@StringBuilder@WTF@@QAEXI@Z
     299    ?resizeOutOfLine@BitVector@WTF@@AAEXI@Z
    298300    ?resolveRope@JSString@JSC@@ABEXPAVExecState@2@@Z
    299301    ?restoreAll@Profile@JSC@@QAEXXZ
  • trunk/Source/WTF/ChangeLog

    r112082 r112177  
     12012-03-23  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        cssText should use shorthand notations
     4        https://bugs.webkit.org/show_bug.cgi?id=81737
     5
     6        Reviewed by Enrica Casucci.
     7
     8        * wtf/BitVector.h:
     9        (BitVector):
     10        (WTF::BitVector::ensureSizeAndSet): Added.
     11
    1122012-03-26  Carlos Garcia Campos  <cgarcia@igalia.com>
    213
  • trunk/Source/WTF/wtf/BitVector.h

    r111834 r112177  
    147147        quickSet(bit);
    148148    }
    149    
     149
     150    void ensureSizeAndSet(size_t bit, size_t size)
     151    {
     152        ensureSize(size);
     153        quickSet(bit);
     154    }
     155
    150156    void clear(size_t bit)
    151157    {
  • trunk/Source/WebCore/ChangeLog

    r112174 r112177  
     12012-03-23  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        cssText should use shorthand notations
     4        https://bugs.webkit.org/show_bug.cgi?id=81737
     5
     6        Reviewed by Enrica Casucci.
     7
     8        Use shorthand properties to serialize style properties for cssText.
     9
     10        The overall algorithm is to look for any property that has a shorthand, and then check if
     11        the shorthand value could be obtained (the condition is quite complicated for border properties).
     12        If it could, then append that value to the string builder, and set the corresponding entries in
     13        shorthandPropertyAppeared and shorthandPropertyUsed. If not, only turn on the bit in
     14        shorthandPropertyAppeared on to avoid calling getPropertyValue again for longhand properties
     15        that use the same shorthand property when we cannot use the shorthand.
     16
     17        Test: fast/css/cssText-shorthand.html
     18
     19        * css/StylePropertySet.cpp:
     20        (WebCore::StylePropertySet::asText):
     21
    1222012-03-26  Bolin Hsu  <bhsu@google.com>
    223
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r112078 r112177  
    3131#include "Document.h"
    3232#include "PropertySetCSSStyleDeclaration.h"
     33#include <wtf/BitVector.h>
    3334#include <wtf/text/StringBuilder.h>
    3435
     
    566567    const CSSProperty* repeatYProp = 0;
    567568
     569    // FIXME: Stack-allocate the buffer for these BitVectors.
     570    BitVector shorthandPropertyUsed;
     571    BitVector shorthandPropertyAppeared;
     572
    568573    unsigned size = m_properties.size();
    569574    for (unsigned n = 0; n < size; ++n) {
    570575        const CSSProperty& prop = m_properties[n];
    571         switch (prop.id()) {
     576        int propertyID = prop.id();
     577        int shorthandPropertyID = 0;
     578
     579        switch (propertyID) {
    572580        case CSSPropertyBackgroundPositionX:
    573581            positionXProp = &prop;
    574             break;
     582            continue;
    575583        case CSSPropertyBackgroundPositionY:
    576584            positionYProp = &prop;
    577             break;
     585            continue;
    578586        case CSSPropertyBackgroundRepeatX:
    579587            repeatXProp = &prop;
    580             break;
     588            continue;
    581589        case CSSPropertyBackgroundRepeatY:
    582590            repeatYProp = &prop;
    583             break;
    584         default:
    585             result.append(prop.cssText());
    586         }
     591            continue;
     592        case CSSPropertyBorderWidth:
     593        case CSSPropertyBorderTopWidth:
     594        case CSSPropertyBorderRightWidth:
     595        case CSSPropertyBorderBottomWidth:
     596        case CSSPropertyBorderLeftWidth:
     597        case CSSPropertyBorderStyle:
     598        case CSSPropertyBorderTopStyle:
     599        case CSSPropertyBorderRightStyle:
     600        case CSSPropertyBorderBottomStyle:
     601        case CSSPropertyBorderLeftStyle:
     602        case CSSPropertyBorderColor:
     603        case CSSPropertyBorderTopColor:
     604        case CSSPropertyBorderRightColor:
     605        case CSSPropertyBorderBottomColor:
     606        case CSSPropertyBorderLeftColor:
     607            // FIXME: Deal with cases where only some of border-(top|right|bottom|left) are specified.
     608            shorthandPropertyID = CSSPropertyBorder;
     609            if (shorthandPropertyAppeared.get(CSSPropertyBorder - firstCSSProperty))
     610                break;
     611            for (unsigned i = 0; i < borderAbridgedLonghand().length() && shorthandPropertyID; i++) {
     612                const CSSPropertyLonghand& longhand = *(borderAbridgedLonghand().longhandsForInitialization()[i]);
     613                String commonValue;
     614                bool commonImportance = false;
     615                for (size_t j = 0; j < longhand.length(); ++j) {
     616                    int id = longhand.properties()[j];
     617                    RefPtr<CSSValue> value = getPropertyCSSValue(id);
     618                    String currentValue = value ? value->cssText() : String();
     619                    bool isImportant = propertyIsImportant(id);
     620                    if (j && (currentValue != commonValue || commonImportance != isImportant)) {
     621                        shorthandPropertyID = 0;
     622                        break;
     623                    }
     624                    if (!j) {
     625                        commonValue = currentValue;
     626                        commonImportance = isImportant;
     627                    }
     628                }
     629            }
     630            break;
     631        case CSSPropertyWebkitBorderHorizontalSpacing:
     632        case CSSPropertyWebkitBorderVerticalSpacing:
     633            shorthandPropertyID = CSSPropertyBorderSpacing;
     634            break;
     635        case CSSPropertyFontFamily:
     636        case CSSPropertyLineHeight:
     637        case CSSPropertyFontSize:
     638        case CSSPropertyFontStyle:
     639        case CSSPropertyFontVariant:
     640        case CSSPropertyFontWeight:
     641            // Don't use CSSPropertyFont because old UAs can't recognize them but are important for editing.
     642            break;
     643        case CSSPropertyListStyleType:
     644        case CSSPropertyListStylePosition:
     645        case CSSPropertyListStyleImage:
     646            shorthandPropertyID = CSSPropertyListStyle;
     647            break;
     648        case CSSPropertyMarginTop:
     649        case CSSPropertyMarginRight:
     650        case CSSPropertyMarginBottom:
     651        case CSSPropertyMarginLeft:
     652            shorthandPropertyID = CSSPropertyMargin;
     653            break;
     654        case CSSPropertyOutlineWidth:
     655        case CSSPropertyOutlineStyle:
     656        case CSSPropertyOutlineColor:
     657            shorthandPropertyID = CSSPropertyOutline;
     658            break;
     659        case CSSPropertyOverflowX:
     660        case CSSPropertyOverflowY:
     661            shorthandPropertyID = CSSPropertyOverflow;
     662            break;
     663        case CSSPropertyPaddingTop:
     664        case CSSPropertyPaddingRight:
     665        case CSSPropertyPaddingBottom:
     666        case CSSPropertyPaddingLeft:
     667            shorthandPropertyID = CSSPropertyPadding;
     668            break;
     669        case CSSPropertyWebkitAnimationName:
     670        case CSSPropertyWebkitAnimationDuration:
     671        case CSSPropertyWebkitAnimationTimingFunction:
     672        case CSSPropertyWebkitAnimationDelay:
     673        case CSSPropertyWebkitAnimationIterationCount:
     674        case CSSPropertyWebkitAnimationDirection:
     675        case CSSPropertyWebkitAnimationFillMode:
     676            shorthandPropertyID = CSSPropertyWebkitAnimation;
     677            break;
     678        case CSSPropertyWebkitFlexDirection:
     679        case CSSPropertyWebkitFlexWrap:
     680            shorthandPropertyID = CSSPropertyWebkitFlexFlow;
     681            break;
     682        case CSSPropertyWebkitMaskPositionX:
     683        case CSSPropertyWebkitMaskPositionY:
     684        case CSSPropertyWebkitMaskRepeatX:
     685        case CSSPropertyWebkitMaskRepeatY:
     686        case CSSPropertyWebkitMaskImage:
     687        case CSSPropertyWebkitMaskRepeat:
     688        case CSSPropertyWebkitMaskAttachment:
     689        case CSSPropertyWebkitMaskPosition:
     690        case CSSPropertyWebkitMaskClip:
     691        case CSSPropertyWebkitMaskOrigin:
     692            shorthandPropertyID = CSSPropertyWebkitMask;
     693            break;
     694        case CSSPropertyWebkitTransformOriginX:
     695        case CSSPropertyWebkitTransformOriginY:
     696        case CSSPropertyWebkitTransformOriginZ:
     697            shorthandPropertyID = CSSPropertyWebkitTransformOrigin;
     698            break;
     699        case CSSPropertyWebkitTransitionProperty:
     700        case CSSPropertyWebkitTransitionDuration:
     701        case CSSPropertyWebkitTransitionTimingFunction:
     702        case CSSPropertyWebkitTransitionDelay:
     703            shorthandPropertyID = CSSPropertyWebkitTransition;
     704            break;
     705        case CSSPropertyWebkitWrapFlow:
     706        case CSSPropertyWebkitWrapMargin:
     707        case CSSPropertyWebkitWrapPadding:
     708            shorthandPropertyID = CSSPropertyWebkitWrap;
     709            break;
     710        }
     711
     712        String value;
     713        unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty;
     714        if (shorthandPropertyID) {
     715            if (shorthandPropertyUsed.get(shortPropertyIndex))
     716                continue;
     717            if (!shorthandPropertyAppeared.get(shortPropertyIndex))
     718                value = getPropertyValue(shorthandPropertyID);
     719            shorthandPropertyAppeared.ensureSizeAndSet(shortPropertyIndex, numCSSProperties);
     720        }
     721
     722        if (!value.isNull()) {
     723            propertyID = shorthandPropertyID;
     724            shorthandPropertyUsed.ensureSizeAndSet(shortPropertyIndex, numCSSProperties);
     725        } else
     726            value = prop.value()->cssText();
     727
     728        if (value == "initial" && !CSSProperty::isInheritedProperty(propertyID))
     729            continue;
     730
     731        result.append(getPropertyName(static_cast<CSSPropertyID>(propertyID)));
     732        result.append(": ");
     733        result.append(value);
     734        result.append(prop.isImportant() ? " !important" : "");
     735        result.append("; ");
    587736    }
    588737
Note: See TracChangeset for help on using the changeset viewer.