SVGTextRunRenderingContext changes font data in the glyph page, but it shouldn't
https://bugs.webkit.org/show_bug.cgi?id=98755

Reviewed by Eric Seidel.

Source/WebCore:

The code in SVGTextRunRenderingContext::glyphDataForCharacter, when it
encounters an <altglyph> tag, immediately replaces the font data for a
glyph with font data for the primary font, presumably to meet the SVG
spec requirement: "If the references to alternate glyphs do not result
in successful identification of alternate glyphs to use, then the
character(s) that are inside of the ‘altGlyph’ element are rendered as
if the ‘altGlyph’ element were a ‘tspan’ element instead."

If the alt glyph is not then found we are in the case from the spec
and indeed we should use the primary font. However, we end up replacing the GlyphPage
entry for the character with primary font data, which we should not do
because the glyph page might be used in some place that does not have
the alt glyph tag.

Furthermore, this causes object lifetime problems for font data, because
in cases where the font data that is replaced is for the system fallback
font the GlyphPage will live forever with no knowldege that it contains
font data pointers into font data other that the system fallback. The
replaced font data may be deleted while the pointer lives on in the
system fallback page.

The fix is simply not to replace the font data in the page.

Test: svg/text/alt-glpyh-on-fallback-font-crash.html

* rendering/svg/SVGTextRunRenderingContext.cpp:
(WebCore::SVGTextRunRenderingContext::glyphDataForCharacter): Keep track of the original font data and put it back
in the glyph page when the method has finished.

LayoutTests:

New test case that includes an alt-glyph that comes from the system
fallback font (because the alt-glyph doesn't reference anything). This
test crashes on Chromium linux without the patch, and may crash on
other platforms too.

* svg/text/alt-glpyh-on-fallback-font-crash.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130999 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Tests failure on Chromium Mac after r130821
https://bugs.webkit.org/show_bug.cgi?id=98865

Reviewed by Adam Barth.

Source/WebCore:

Updating the check for USE(HARFBUZZ_NG) to check for Mac Chromium, as the HARFBUZZ_NG flag isn't
actually set, despite us using Harfbuzz. This unbreaks Chromium Mac as we diagnose the root
cause of this issue.

* rendering/RenderBlockLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun):

LayoutTests:

Removing failing test entries.

* platform/chromium/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131000 268f45cc-cd09-0410-ab3c-d52691b4dbfc
High res times should start at 0
https://bugs.webkit.org/show_bug.cgi?id=84912

Reviewed by Tony Gentilcore.

Test: Existing Navigation Timing tests.

* inspector/InspectorInstrumentation.cpp: Use legacy document time, pending 98223.
(WebCore):
(WebCore::InspectorInstrumentation::didFinishLoadingImpl):
* inspector/InspectorResourceAgent.cpp:
(WebCore::buildObjectForTiming):
* loader/DocumentLoadTiming.cpp:
(WebCore::DocumentLoadTiming::convertMonotonicTimeToLegacyDocumentTime):
(WebCore):
(WebCore::DocumentLoadTiming::convertMonotonicTimeToZeroBasedDocumentTime):
(WebCore::DocumentLoadTiming::markNavigationStart):
* loader/DocumentLoadTiming.h:
(DocumentLoadTiming):
(WebCore::DocumentLoadTiming::navigationStart): These just report raw monotonic times now.
(WebCore::DocumentLoadTiming::unloadEventStart):
(WebCore::DocumentLoadTiming::unloadEventEnd):
(WebCore::DocumentLoadTiming::redirectStart):
(WebCore::DocumentLoadTiming::redirectEnd):
(WebCore::DocumentLoadTiming::fetchStart):
(WebCore::DocumentLoadTiming::responseEnd):
(WebCore::DocumentLoadTiming::loadEventStart):
(WebCore::DocumentLoadTiming::loadEventEnd):
* page/PerformanceTiming.cpp:
(WebCore::PerformanceTiming::navigationStart): Convert these back to legacy document times.
(WebCore::PerformanceTiming::unloadEventStart):
(WebCore::PerformanceTiming::unloadEventEnd):
(WebCore::PerformanceTiming::redirectStart):
(WebCore::PerformanceTiming::redirectEnd):
(WebCore::PerformanceTiming::fetchStart):
(WebCore::PerformanceTiming::responseEnd):
(WebCore::PerformanceTiming::loadEventStart):
(WebCore::PerformanceTiming::loadEventEnd):
(WebCore::PerformanceTiming::resourceLoadTimeRelativeToAbsolute):
(WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds):
* platform/network/ResourceLoadTiming.cpp:
(WebCore::ResourceLoadTiming::convertResourceLoadTimeToMonotonicTime):
* platform/network/ResourceLoadTiming.h:
(ResourceLoadTiming):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Minimize the recent template explosion in SelectorChecker.
https://bugs.webkit.org/show_bug.cgi?id=98829

Reviewed by Antti Koivisto.

We've recently added the capability to switch sibling traversal strategy to SelectorChecker, at some readability/clarity expense.
This patch tries to minimize the surface of this expense to SelectorChecker::checkOneSelector.

No new tests, no change in behavior.

* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkSelector): Turned back into a function.
(WebCore::SelectorChecker::checkOneSelector): Changed to specialize on traversal strategy, rather than the context, which was less clear.
(WebCore::SelectorChecker::DOMTraversalStrategy::isFirstChild): Turned into a function.
(WebCore::SelectorChecker::DOMTraversalStrategy::isLastChild): Ditto.
(WebCore::SelectorChecker::DOMTraversalStrategy::isFirstOfType): Ditto.
(WebCore::SelectorChecker::DOMTraversalStrategy::isLastOfType): Ditto.
(WebCore::SelectorChecker::DOMTraversalStrategy::countElementsBefore): Ditto.
(WebCore::SelectorChecker::DOMTraversalStrategy::countElementsOfTypeBefore): Ditto.
(WebCore::SelectorChecker::DOMTraversalStrategy::countElementsAfter): Ditto.
(WebCore::SelectorChecker::DOMTraversalStrategy::countElementsOfTypeAfter): Ditto.
* css/SelectorChecker.h:
(DOMTraversalStrategy): Changed into a class, rather than a template.
(SelectorChecker): Turned back into a function.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131002 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add more Objective-C WebKit2 DOM API skeletons.
https://bugs.webkit.org/show_bug.cgi?id=98981

Reviewed by Anders Carlsson.

Source/WebCore:

* WebCore.exp.in:
Add necessary export.

Source/WebKit2:

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/mac/WKDOMDocument.h:
* WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm:
* WebProcess/InjectedBundle/API/mac/WKDOMElement.h:
* WebProcess/InjectedBundle/API/mac/WKDOMElement.mm:
Update guards to actually do something. __CLANG__ is never defined, but __clang__ is.

* WebProcess/InjectedBundle/API/mac/WKDOMInternals.h:
* WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm:
- Abstracts DOM object caching into the DOMCache class which can only be used as a singleton.
- Adds WKDOMRange class extension to allow manipulating its internal pointer for caching purposes.
- Add WKDOMRange conversion functions.

* WebProcess/InjectedBundle/API/mac/WKDOMNode.h:
* WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
Rename _node to _impl for consistency.

* WebProcess/InjectedBundle/API/mac/WKDOMRange.h:
* WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
(-[WKDOMRange _initWithImpl:WebCore::]):
(-[WKDOMRange initWithDocument:]):
(-[WKDOMRange dealloc]):
(-[WKDOMRange startContainer]):
(-[WKDOMRange startOffset]):
(-[WKDOMRange endContainer]):
(-[WKDOMRange endOffset]):
(-[WKDOMRange text]):
Added. Only offers base range functionality.

* WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.h:
* WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm:
(-[WKDOMTextIterator initWithRange:]):
(-[WKDOMTextIterator advance]):
(-[WKDOMTextIterator atEnd]):
(-[WKDOMTextIterator currentRange]):
(-[WKDOMTextIterator currentTextPointer]):
(-[WKDOMTextIterator currentTextLength]):
Added. Almost identical to WebTextIterator API in WebKit.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131003 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Move :before and :after into the DOM
https://bugs.webkit.org/show_bug.cgi?id=95117

Patch by Elliott Sprehn <esprehn@chromium.org> on 2012-10-10
Reviewed by Eric Seidel.

Source/WebCore:

Reimplement generated content :before and :after as DOM Elements. Now ElementRareData has
two RefPtrs to PseudoElements for the generated content and Node has methods for traversing
the tree including generated content.

This allows the generated content to be treated as real nodes instead of anonymous and take
part in the usual recalcStyle and attach flow which fixes many bugs and vastly simplifies the
lifecycle of generated content.

No new tests needed for now.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
* dom/Element.cpp:
(WebCore::Element::attach): Add generated content if needed.
(WebCore::Element::detach): Remove all child generated content.
(WebCore::Element::recalcStyle): Add or remove generated content based on the new style.
(WebCore::Element::updatePseudoElement): Updates pseudo content based on a pseudoId.
(WebCore):
(WebCore::Element::createPseudoElementIfNeeded):
(WebCore::Element::beforePseudoElement):
(WebCore::Element::afterPseudoElement):
* dom/Element.h:
(WebCore):
(Element):
* dom/ElementRareData.h:
(ElementRareData):
(WebCore::ElementRareData::setPseudoElement):
(WebCore):
(WebCore::ElementRareData::pseudoElement):
* dom/Node.cpp:
(WebCore::Node::pseudoAwarePreviousSibling):
(WebCore):
(WebCore::Node::pseudoAwareNextSibling):
(WebCore::checkAcceptChild): Forbid moving PseudoElements for sanity. The code never does this.
* dom/Node.h:
(Node):
(WebCore::Node::isPseudoElement):
(WebCore::Node::pseudoId): Fast path that only calls virtualPseudoId if the node has custom callbacks so isPseudoElement is fast.
(WebCore::Node::virtualPseudoId):
(WebCore::Node::isBeforePseudoElement):
(WebCore::Node::isAfterPseudoElement):
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::nextRenderer): Changed to find the next sibling of pseudos for insertion.
* dom/PseudoElement.cpp: Added.
(WebCore):
(WebCore::pseudoElementName):
(WebCore::PseudoElement::PseudoElement):
(WebCore::PseudoElement::pseudoRendererIsNeeded):
(WebCore::PseudoElement::customStyleForRenderer):
(WebCore::PseudoElement::attach):
(WebCore::PseudoElement::rendererIsNeeded):
(WebCore::PseudoElement::updateChildStyle): Propagates the style downward into the anonymous renderers for the content.
(WebCore::PseudoElement::didRecalcStyle):
(WebCore::PseudoElement::createRendererForContent): Refactored from RenderObjectChildList.
* dom/PseudoElement.h: Added.
(WebCore):
(PseudoElement):
(WebCore::PseudoElement::create):
(WebCore::toPseudoElement):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::setInnerNode): Hit testing a PseudoElement should really hit the parent.
(WebCore::HitTestResult::setInnerNonSharedNode): Same as above.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::styleDidChange): Remove old generated content code, same for below.
(WebCore::RenderBlock::splitBlocks):
(WebCore::RenderBlock::addChildIgnoringAnonymousColumnBlocks):
(WebCore::RenderBlock::createReplacementRunIn):
(WebCore::RenderBlock::renderName):
* rendering/RenderBlock.h:
(RenderBlock):
* rendering/RenderButton.cpp:
* rendering/RenderButton.h:
(RenderButton):
* rendering/RenderCounter.cpp:
(WebCore::RenderCounter::originalText):
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::renderName):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::renderName):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::styleDidChange):
(WebCore::RenderInline::addChildIgnoringContinuation):
(WebCore::RenderInline::splitInlines):
(WebCore::RenderInline::renderName):
* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::updateMarkerLocation):
* rendering/RenderMultiColumnBlock.cpp:
(WebCore::RenderMultiColumnBlock::renderName):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::createObject):
* rendering/RenderObject.h:
(WebCore::RenderObject::isPseudoElement):
(RenderObject):
(WebCore::RenderObject::generatingNode):
* rendering/RenderObjectChildList.cpp:
* rendering/RenderObjectChildList.h:
(RenderObjectChildList):
* rendering/RenderRubyText.cpp:
* rendering/RenderRubyText.h:
(RenderRubyText):
* rendering/RenderTableCell.h:
(WebCore::RenderTableCell::renderName):
* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::styleDidChange):
* rendering/RenderTableRow.h:
(WebCore::RenderTableRow::renderName):
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::addChild):
* rendering/RenderTableSection.h:
(WebCore::RenderTableSection::renderName):
* rendering/RenderTreeAsText.cpp:
(WebCore::RenderTreeAsText::writeRenderObject):

LayoutTests:

Regenerated some baselines for tests given the new generated content architecture and disabled
tests that are testing generated content on inputs which were wrong.

* fast/css-generated-content/before-content-continuation-chain-expected.txt:
* platform/chromium-mac/fast/css-generated-content/table-row-group-to-inline-expected.png:
* platform/chromium/TestExpectations: Disable the tests for generated content on inputs. A follow up CL with remove these tests.
* platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.png:
* platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.txt:
   This test always produced wrong output because we leave an anonymous RenderTable in the tree,
   and now that generated content is handled like DOM nodes this test renders differently since the
   content ends up after the left over RenderTable. Both outputs are wrong until Bug 86261 is fixed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131004 268f45cc-cd09-0410-ab3c-d52691b4dbfc
<rdar://problem/12472460> text-combine doesn’t use third- and quarter-width variants when used with @font-face
https://bugs.webkit.org/show_bug.cgi?id=98961

Reviewed by Tim Horton.

Source/WebCore: 

Test: fast/text/text-combine-with-font-face.html

* css/CSSSegmentedFontFace.cpp:
(WebCore::CSSSegmentedFontFace::getFontData): Added the width variant to the
key used for entries in the font data table, so that we can return different
font data for different width variants.
* platform/graphics/FontWidthVariant.h: Defined FontWidthVariantWidth for
use in the computation of the above key.
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::combineText): Added a local variable to store
the font selector before changing the font description. Previously, by the time
we tried to get the font selector from the font, it had already been cleared,
so we called Font::update() with a 0 font selector, meaning @font-face fonts
could not be selected.

LayoutTests: 

* fast/text/text-combine-with-font-face-expected.html: Added.
* fast/text/text-combine-with-font-face.html: Added.



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