[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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155496 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Be explicit about backwards propagation properties that care about escaping to bytecode, as opposed to just escaping within DFG code.

Rubber stamped by Mark Hahnenberg.
        
We need to care about escaping to bytecode if we're doing a lossy optimization,
i.e. the optimization means we produce less information and so we can't rescue
ourselves during OSR exit.
        
We only need to care about escaping within the DFG code (and can ignore what
might happen in bytecode) if we're doing an optimization that is lossless, i.e.
we can always still reconstruct the values that bytecode wants.
        
Example #1:
        
    Large int32 + int32 which overflows. We want to optimize away the overflow
    check and just do a 32-bit add.
            
    This is lossy; the result should have one extra bit but we simply throw
    that bit away by doing a check-less 32-bit add. Hence we need to know that 
    even the bytecode wouldn't have cared about that bit. This is true in cases
    like (a + b) | 0.
        
Example #2:
        
    Larbe int32 + int32 which overflows. We want to optimize away the overflow
    check by doing a 64-bit add.
            
    This is lossless. We can always convert the resulting 64-bit int back to a
    double if that's what bytecode wants. Hence we only need to know that the
    DFG code won't want to do something to this value that would make 64-bit
    ints either unprofitable or unsound.
        
The backwards propagator's notions of flags (NodeUsedAsValue, etc) are for lossy
optimizations and so should be named in a way that reflects this. This patch
calls then NodeBytecodeUsesAsValue, etc.
        
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::::executeEffects):
* dfg/DFGArrayMode.cpp:
(JSC::DFG::ArrayMode::refine):
* dfg/DFGBackwardsPropagationPhase.cpp:
(JSC::DFG::BackwardsPropagationPhase::mergeDefaultFlags):
(JSC::DFG::BackwardsPropagationPhase::propagate):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGGraph.h:
(JSC::DFG::Graph::addImmediateShouldSpeculateInt32):
* dfg/DFGNode.h:
(JSC::DFG::Node::arithNodeFlags):
* dfg/DFGNodeFlags.cpp:
(JSC::DFG::dumpNodeFlags):
* dfg/DFGNodeFlags.h:
(JSC::DFG::bytecodeUsesAsNumber):
(JSC::DFG::bytecodeCanTruncateInteger):
(JSC::DFG::bytecodeCanIgnoreNegativeZero):
(JSC::DFG::nodeMayNegZero):
(JSC::DFG::nodeCanSpeculateInt32):
* dfg/DFGPredictionPropagationPhase.cpp:
(JSC::DFG::PredictionPropagationPhase::propagate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileDoubleAsInt32):
(JSC::DFG::SpeculativeJIT::compileAdd):
(JSC::DFG::SpeculativeJIT::compileArithSub):
(JSC::DFG::SpeculativeJIT::compileArithNegate):
(JSC::DFG::SpeculativeJIT::compileArithMul):
(JSC::DFG::SpeculativeJIT::compileArithDiv):
(JSC::DFG::SpeculativeJIT::compileArithMod):
* dfg/DFGVariableAccessData.h:
(JSC::DFG::VariableAccessData::shouldUseDoubleFormatAccordingToVote):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileAdd):
(JSC::FTL::LowerDFGToLLVM::compileArithSub):
(JSC::FTL::LowerDFGToLLVM::compileArithMul):
(JSC::FTL::LowerDFGToLLVM::compileArithDiv):
(JSC::FTL::LowerDFGToLLVM::compileArithMod):
(JSC::FTL::LowerDFGToLLVM::compileArithNegate):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155497 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, be a bit more clear about what we mean by 'js' tests. I think this
got a bit overlooked from the fast/js->js refactoring.

* Scripts/run-javascriptcore-tests:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155498 268f45cc-cd09-0410-ab3c-d52691b4dbfc