Ignore:
Timestamp:
Sep 10, 2013, 7:39:05 PM (12 years ago)
Author:
[email protected]
Message:

[iOS] Upstream text autosizing
https://bugs.webkit.org/show_bug.cgi?id=121111

Reviewed by Andy Estes and Sam Weinig.

Source/WebCore:

Tests: platform/iphone-simulator/text-autosizing/anonymous-block.html

platform/iphone-simulator/text-autosizing/contenteditable.html
platform/iphone-simulator/text-autosizing/first-letter.html
platform/iphone-simulator/text-autosizing/font-family-case-insensitive.html
platform/iphone-simulator/text-autosizing/lists.html
platform/iphone-simulator/text-autosizing/overflow.html
platform/iphone-simulator/text-autosizing/percent-adjust-length-line-height.html
platform/iphone-simulator/text-autosizing/percent-adjust-number-line-height.html
platform/iphone-simulator/text-autosizing/percent-adjust-percent-line-height.html

  • WebCore.exp.in:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::propertyValue):

  • css/CSSParser.cpp:

(WebCore::isValidKeywordPropertyAndValue):
(WebCore::CSSParser::parseValue):

  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty):

  • css/CSSPropertyNames.in: Add property -webkit-text-size-adjust.
  • css/DeprecatedStyleBuilder.cpp:

(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): Added.
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyInitialValue): Added.
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyInheritValue): Added.
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::createHandler): Added.
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::updateFont):
(WebCore::StyleResolver::applyProperties): Add COMPILE_ASSERT to ensure that
all properties that affect font size, including -webkit-text-size-adjust, are
resolved before properties that depend on them; see <rdar://problem/13522835>.
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::checkForTextSizeAdjust): Added.

  • css/StyleResolver.h:
  • dom/Document.cpp:

(WebCore::TextAutoSizingTraits::constructDeletedValue): Added.
(WebCore::TextAutoSizingTraits::isDeletedValue): Added.
(WebCore::Document::detach):
(WebCore::Document::addAutoSizingNode): Added.
(WebCore::Document::validateAutoSizingNodes): Added.
(WebCore::Document::resetAutoSizingNodes): Added.

  • dom/Document.h:
  • editing/EditingStyle.cpp:
  • page/Frame.h: Add declarations for setTextAutosizingWidth(), textAutosizingWidth().
  • page/FrameView.cpp:

(WebCore::FrameView::layout):

  • page/Settings.in: Generate setter and getter for setting minimumZoomFontSize.
  • platform/graphics/Font.h:

(WebCore::Font::equalForTextAutoSizing): Added.

  • platform/graphics/FontDescription.cpp:

(WebCore::FontDescription::familiesEqualForTextAutoSizing): Added.

  • platform/graphics/FontDescription.h:

(WebCore::FontDescription::equalForTextAutoSizing): Added.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::RenderBlock):
(WebCore::isVisibleRenderText): Added.
(WebCore::resizeTextPermitted): Added.
(WebCore::RenderBlock::immediateLineCount): Added.
(WebCore::isNonBlocksOrNonFixedHeightListItems): Added.
(WebCore::oneLineTextMultiplier): Added.
(WebCore::textMultiplier): Added.
(WebCore::RenderBlock::adjustComputedFontSizes): Added.

  • rendering/RenderBlock.h:

(WebCore::RenderBlock::resetComputedFontSize): Added.

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::traverseNext): Added.
(WebCore::includeNonFixedHeight): Added.
(WebCore::RenderObject::adjustComputedFontSizesOnBlocks): Added.
(WebCore::RenderObject::resetTextAutosizing): Added.

  • rendering/RenderObject.h:
  • rendering/RenderText.cpp:

(WebCore::RenderText::RenderText):

  • rendering/RenderText.h:

(WebCore::RenderText::candidateComputedTextSize): Added.
(WebCore::RenderText::setCandidateComputedTextSize): Added.

  • rendering/style/RenderStyle.cpp:

(WebCore::computeFontHash):
(WebCore::RenderStyle::hashForTextAutosizing): Added.
(WebCore::RenderStyle::equalForTextAutosizing): Added.
(WebCore::RenderStyle::changeRequiresLayout):
(WebCore::RenderStyle::specifiedLineHeight): Added; iOS-specific variant.
We should reconcile this getter with the getter of the same name that is
compiled when building with IOS_TEXT_AUTOSIZING disabled.
(WebCore::RenderStyle::setSpecifiedLineHeight): Added.

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyle::initialSpecifiedLineHeight): Added.
(WebCore::RenderStyle::initialTextSizeAdjust): Added.
(WebCore::RenderStyle::setTextSizeAdjust): Added.
(WebCore::RenderStyle::textSizeAdjust): Added.

  • rendering/style/StyleInheritedData.cpp:

(WebCore::StyleInheritedData::StyleInheritedData):
(WebCore::StyleInheritedData::operator==):

  • rendering/style/StyleInheritedData.h:
  • rendering/style/StyleRareInheritedData.cpp:

(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):

  • rendering/style/StyleRareInheritedData.h:
  • rendering/style/TextSizeAdjustment.h: Added.

(TextSizeAdjustment::TextSizeAdjustment):
(TextSizeAdjustment::percentage):
(TextSizeAdjustment::multiplier):
(TextSizeAdjustment::isAuto):
(TextSizeAdjustment::isNone):
(TextSizeAdjustment::isPercentage):
(TextSizeAdjustment::operator == ):
(TextSizeAdjustment::operator != ):

Source/WebKit/mac:

  • WebView/WebFrame.mm:

(-[WebFrame resetTextAutosizingBeforeLayout]): Added.
(-[WebFrame _setVisibleSize:]): Added.
(-[WebFrame _setTextAutosizingWidth:]): Added.

  • WebView/WebFramePrivate.h:
  • WebView/WebPreferenceKeysPrivate.h:
  • WebView/WebPreferences.mm:

(+[WebPreferences initialize]):
(-[WebPreferences _setMinimumZoomFontSize:]): Added.
(-[WebPreferences _minimumZoomFontSize]): Added.

Source/WTF:

Define iOS text autosizing to be enabled on iOS unless otherwise defined.

  • wtf/FeatureDefines.h:

Tools:

Implement infrastructure to test the iOS text autosizing code.

  • DumpRenderTree/TestRunner.cpp:

(setTextAutosizingEnabledCallback): Added.
(TestRunner::staticFunctions):

  • DumpRenderTree/TestRunner.h:
  • DumpRenderTree/mac/DumpRenderTree.mm:

(resetDefaultsToConsistentValues):

  • DumpRenderTree/mac/TestRunnerMac.mm:

(TestRunner::setTextAutosizingEnabled): Added.

LayoutTests:

Add tests to ensure we don't regress iOS text autosizing.

  • platform/iphone-simulator/text-autosizing/anonymous-block-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/anonymous-block.html: Added.
  • platform/iphone-simulator/text-autosizing/contenteditable-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/contenteditable.html: Added.
  • platform/iphone-simulator/text-autosizing/first-letter-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/first-letter.html: Added.
  • platform/iphone-simulator/text-autosizing/font-family-case-insensitive-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/font-family-case-insensitive.html: Added.
  • platform/iphone-simulator/text-autosizing/lists-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/lists.html: Added.
  • platform/iphone-simulator/text-autosizing/overflow-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/overflow.html: Added.
  • platform/iphone-simulator/text-autosizing/percent-adjust-length-line-height-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/percent-adjust-length-line-height.html: Added.
  • platform/iphone-simulator/text-autosizing/percent-adjust-number-line-height-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/percent-adjust-number-line-height.html: Added.
  • platform/iphone-simulator/text-autosizing/percent-adjust-percent-line-height-expected.txt: Added.
  • platform/iphone-simulator/text-autosizing/percent-adjust-percent-line-height.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r155344 r155496  
    14531453
    14541454    RenderStyle* style = m_state.style();
     1455#if ENABLE(IOS_TEXT_AUTOSIZING)
     1456    checkForTextSizeAdjust(style);
     1457#endif
    14551458    checkForGenericFamilyChange(style, m_state.parentStyle());
    14561459    checkForZoomChange(style, m_state.parentStyle());
     
    15461549        case HighPriorityProperties:
    15471550            COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_first_property);
     1551#if ENABLE(IOS_TEXT_AUTOSIZING)
     1552            COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 18, CSS_zoom_is_end_of_first_prop_range);
     1553#else
    15481554            COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 17, CSS_zoom_is_end_of_first_prop_range);
     1555#endif
    15491556            COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_line_height_is_after_zoom);
    15501557#if ENABLE(CSS_VARIABLES)
     
    24342441        return;
    24352442    }
     2443#if ENABLE(IOS_TEXT_AUTOSIZING)
     2444    case CSSPropertyWebkitTextSizeAdjust: {
     2445        HANDLE_INHERIT_AND_INITIAL(textSizeAdjust, TextSizeAdjust)
     2446        if (!primitiveValue)
     2447            return;
     2448
     2449        if (primitiveValue->getValueID() == CSSValueAuto)
     2450            state.style()->setTextSizeAdjust(TextSizeAdjustment(AutoTextSizeAdjustment));
     2451        else if (primitiveValue->getValueID() == CSSValueNone)
     2452            state.style()->setTextSizeAdjust(TextSizeAdjustment(NoTextSizeAdjustment));
     2453        else
     2454            state.style()->setTextSizeAdjust(TextSizeAdjustment(primitiveValue->getFloatValue()));
     2455
     2456        state.setFontDirty(true);
     2457        return;
     2458    }
     2459#endif
    24362460#if ENABLE(DASHBOARD_SUPPORT)
    24372461    case CSSPropertyWebkitDashboardRegion:
     
    31073131}
    31083132
     3133#if ENABLE(IOS_TEXT_AUTOSIZING)
     3134void StyleResolver::checkForTextSizeAdjust(RenderStyle* style)
     3135{
     3136    if (style->textSizeAdjust().isAuto())
     3137        return;
     3138
     3139    FontDescription newFontDescription(style->fontDescription());
     3140    if (!style->textSizeAdjust().isNone())
     3141        newFontDescription.setComputedSize(newFontDescription.specifiedSize() * style->textSizeAdjust().multiplier());
     3142    else
     3143        newFontDescription.setComputedSize(newFontDescription.specifiedSize());
     3144    style->setFontDescription(newFontDescription);
     3145}
     3146#endif
     3147
    31093148void StyleResolver::checkForZoomChange(RenderStyle* style, RenderStyle* parentStyle)
    31103149{
Note: See TracChangeset for help on using the changeset viewer.