Avoid multiple copies of inline script & style strings
https://bugs.webkit.org/show_bug.cgi?id=117202

Patch by Arunprasad Rajkumar <arurajku@cisco.com> on 2013-06-05
Reviewed by Darin Adler.

Merge from https://chromiumcodereview.appspot.com/16005007.

No new tests needed.

The HTML parser breaks up large text nodes into small chunks to avoid some
O(n^2) editing algorithms. This fix skips that workaround for <script> and
<style> elements, which aren't likely to need editing. As a result, <script>
ends up with a single text node, containing a contiguous String, which is the
source code of that inline script block.

Prior this fix, we could end up with two copies of large inline scripts: one
monolithic string retained by JSC and a number of shards retained by the DOM.
After this fix, both the DOM and JSC use the same monolithic string, removing a
copy.

* dom/Text.cpp:
(WebCore::Text::createWithLengthLimit):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::shouldUseLengthLimit):
(WebCore::HTMLConstructionSite::insertTextNode):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[css exclusions] Clean up ExclusionShapeInsideInfo dynamic removal code
https://bugs.webkit.org/show_bug.cgi?id=116236

Reviewed by David Hyatt.

Instead of keeping the ExclusionShapeInsideInfo around after it has
become stale, we can immediately remove it and just mark descendants
for relayout. This patch removes most of the code added by
https://bugs.webkit.org/show_bug.cgi?id=111029
in favor of this simpler approach.

This patch does not introduce new functionality.

* rendering/ExclusionShapeInsideInfo.h:
(WebCore::ExclusionShapeInsideInfo::ExclusionShapeInsideInfo):
(ExclusionShapeInsideInfo): Remove needsRemoval code.
* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState): Ditto.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateExclusionShapeInsideInfoAfterStyleChange): Remove
needsRemoval code and mark descendants for layout.
(WebCore):
(WebCore::RenderBlock::markShapeInsideDescendantsForLayout): Method to mark
descendants of a shape inside with inline content for layout.
(WebCore::exclusionInfoRequiresRelayout): Remove needsRemoval code.
(WebCore::RenderBlock::updateRegionsAndExclusionsAfterChildLayout): Ditto.
* rendering/RenderBlock.h:
(WebCore::RenderBlock::exclusionShapeInsideInfo): Ditto.
(RenderBlock):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::layoutExclusionShapeInsideInfo): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151237 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[curl] Restrict allowed protocols
https://bugs.webkit.org/show_bug.cgi?id=117257

Patch by Peter Gal <galpeter@inf.u-szeged.hu> on 2013-06-05
Reviewed by Brent Fulgham.

curl supports various protocols (like: HTTP,...,POP3,IMAP...) and by
default all of the are enabled for a single curl handle. Furthermore
all of the protocols are allowed during Location header follow.
This could pose a security risk for example: a malicious server responds
with a crafted Location header pointing to an imap/../(etc) url and the
curl backend will follow it and will give the result for the WebCore.

This patch will restrict the allowed protocols to: HTTP(S), FTP(S), FILE

* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::ResourceHandleManager::initializeHandle):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[WinCE,WinCairo] RenderThemeWin.cpp needs to include FrameSelection.h.
https://bugs.webkit.org/show_bug.cgi?id=116583

Patch by Mark Salisbury <mark.salisbury@hp.com> on 2013-06-05
Reviewed by Brent Fulgham.

* rendering/RenderThemeWin.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151239 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] Make image clickable when it has anchor as parent node.
https://bugs.webkit.org/show_bug.cgi?id=117271

Patch by Tiancheng Jiang <tijiang@rim.com> on 2013-06-05
Reviewed by Rob Buis.

BlackBerry PR 345995
Internally Reviewed by Genevieve Mak.
* WebKitSupport/FatFingers.cpp:
(BlackBerry::WebKit::FatFingers::isElementClickable):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] Deleting the pendingSelectionCandidate on the wrong thread causes an assert.
https://bugs.webkit.org/show_bug.cgi?id=117276

Patch by Genevieve Mak <gmak@rim.com> on 2013-06-05
Reviewed by Rob Buis.

Reviewed Internally by Nima Ghanavatian.
PR #342399
Store and delete the selectionScrollView in webkit which is what we already do for
scrolling subframes.

* Api/InRegionScroller.cpp:
(BlackBerry::WebKit::InRegionScrollerPrivate::InRegionScrollerPrivate):
(BlackBerry::WebKit::InRegionScrollerPrivate::resetSelectionScrollView):
(WebKit):
(BlackBerry::WebKit::InRegionScrollerPrivate::clearDocumentData):
(BlackBerry::WebKit::InRegionScrollerPrivate::calculateInRegionScrollableAreasForPoint):
(BlackBerry::WebKit::InRegionScrollerPrivate::updateSelectionScrollView):
(BlackBerry::WebKit::InRegionScrollerPrivate::firstScrollableInRegionForNode):
* Api/InRegionScroller_p.h:
(InRegionScrollerPrivate):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151241 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Don't throttle timers if a page is doing something that might be interesting
https://bugs.webkit.org/show_bug.cgi?id=117273

Reviewed by Gavin Barraclough.

Make the decision about whether or not to throttle timers be
determined by the PageThrottler

* page/Page.cpp:
(WebCore::Page::throttleTimers):
(WebCore::Page::unthrottleTimers):
(WebCore::Page::setVisibilityState):
(WebCore::Page::hiddenPageDOMTimerThrottlingStateChanged):
* page/Page.h:
* page/PageThrottler.cpp:
(WebCore::PageThrottler::throttlePage):
(WebCore::PageThrottler::unthrottlePage):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151244 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] AcceleratedCompositingContext: fix layerFlushTimerFiredCallback condition
https://bugs.webkit.org/show_bug.cgi?id=117258

Patch by Alberto Garcia <agarcia@igalia.com> on 2013-06-05
Reviewed by Martin Robinson.

The expressions were incorrectly grouped, a timeout handler can
only be added only if there's none running already.

* WebCoreSupport/AcceleratedCompositingContextGL.cpp:
(WebKit::AcceleratedCompositingContext::renderLayersToWindow):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151245 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Crash if an IPC connection is invalidated before it's completely set up
https://bugs.webkit.org/show_bug.cgi?id=117274
<rdar://problem/13319035>

Reviewed by Andreas Kling.

Resume our dispatch sources on the connection queue so we won't get invalidation callbacks before
all sources have been set up.

* Platform/CoreIPC/mac/ConnectionMac.cpp:
(CoreIPC::Connection::open):
(CoreIPC::Connection::sendOutgoingMessage):
(CoreIPC::Connection::initializeDeadNameSource):
(CoreIPC::Connection::receiveSourceEventHandler):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151246 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Exclusions][CSS Shapes] Split CSS Exclusions & Shapes compile & runtime flags
https://bugs.webkit.org/show_bug.cgi?id=117172

Reviewed by Alexandru Chiculita.

.:

Adding the CSS_SHAPES compile flag.

* Source/autotools/SetupWebKitFeatures.m4:
* Source/autotools/symbols.filter:
* Source/cmake/WebKitFeatures.cmake:
* Source/cmakeconfig.h.cmake:

Source/JavaScriptCore:

Adding the CSS_SHAPES compile flag.

* Configurations/FeatureDefines.xcconfig:

Source/WebCore:

This patch adds a new compile and runtime flag for the CSS Shapes feature, which
has split off from the previous CSS Exclusions and Shapes specification. The
specifications are available here:
http://dev.w3.org/csswg/css-exclusions/
http://dev.w3.org/csswg/css-shapes/

The changes introduce a new CSS_SHAPES compile flag, and a new cssShapesEnabled
runtime flag. In general, the code changes are simple renames.

Refactoring, no new tests.

* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setCSSShapesEnabled):
(WebCore::RuntimeEnabledFeatures::cssShapesEnabled):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSParser.cpp:
(WebCore::isSimpleLengthPropertyID):
(WebCore::CSSParser::parseValue):
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::loadPendingImages):
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimation::ensurePropertyMap):
* rendering/BidiRun.h:
(WebCore::BidiRun::BidiRun):
* rendering/ExclusionShapeInfo.cpp:
* rendering/ExclusionShapeInfo.h:
* rendering/ExclusionShapeInsideInfo.cpp:
* rendering/ExclusionShapeInsideInfo.h:
* rendering/ExclusionShapeOutsideInfo.cpp:
* rendering/ExclusionShapeOutsideInfo.h:
* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
* rendering/LayoutState.h:
(WebCore::LayoutState::LayoutState):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::styleDidChange):
(WebCore::exclusionInfoRequiresRelayout):
(WebCore::RenderBlock::updateRegionsAndExclusionsBeforeChildLayout):
(WebCore::RenderBlock::updateRegionsAndExclusionsAfterChildLayout):
(WebCore::RenderBlock::insertFloatingObject):
(WebCore::RenderBlock::computeLogicalLocationForFloat):
(WebCore::RenderBlock::positionNewFloats):
(WebCore::::collectIfNeeded):
(WebCore::RenderBlock::logicalLeftOffsetForLine):
(WebCore::RenderBlock::logicalRightOffsetForLine):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::xPositionForFloatIncludingMargin):
(WebCore::RenderBlock::yPositionForFloatIncludingMargin):
(WebCore::RenderBlock::FloatIntervalSearchAdapter::FloatIntervalSearchAdapter):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::LineWidth::LineWidth):
(WebCore::LineWidth::updateAvailableWidth):
(WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded):
(WebCore::RenderBlock::constructLine):
(WebCore::computeExpansionForJustifiedText):
(WebCore::RenderBlock::computeInlineDirectionPositionsForLine):
(WebCore::RenderBlock::computeInlineDirectionPositionsForSegment):
(WebCore::constructBidiRunsForLine):
(WebCore::RenderBlock::layoutRunsAndFloatsInRange):
(WebCore::RenderBlock::LineBreaker::nextLineBreak):
(WebCore::RenderBlock::LineBreaker::nextSegmentBreak):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::willBeDestroyed):
(WebCore::RenderBox::styleDidChange):
* rendering/RenderBox.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintOffset):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::shouldBeNormalFlowOnly):
* rendering/RenderObject.h:
(WebCore::RenderObject::hasPaintOffset):
* rendering/RenderView.h:
(WebCore::RenderView::pushLayoutState):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresLayout):
* rendering/style/RenderStyle.h:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setCSSShapesEnabled):

Source/WebKit/blackberry:

Adding the CSS_SHAPES compile flag.

* WebCoreSupport/AboutDataEnableFeatures.in:

Source/WebKit/mac:

Adding the CSS_SHAPES compile flag.

* Configurations/FeatureDefines.xcconfig:

Source/WebKit2:

Adding the CSS_SHAPES compile flag.

* Configurations/FeatureDefines.xcconfig:

Tools:

Adding the CSS_SHAPES compile flag.

* Scripts/webkitperl/FeatureList.pm:
* qmake/mkspecs/features/features.pri:

WebKitLibraries:

Adding the CSS_SHAPES compile flag.

* win/tools32/vsprops/FeatureDefines.vsprops:
* win/tools32/vsprops/FeatureDefinesCairo.vsprops:

LayoutTests:

Adjusting the shape inside tests to use the new setCSSShapesEnabled method, rather
than the older setCSSExclusionsEnabled method.

* fast/exclusions/css-exclusions-disabled.html:
* fast/exclusions/parsing/script-tests/parsing-shape-inside.js:
* fast/exclusions/parsing/script-tests/parsing-shape-lengths.js:
* fast/exclusions/parsing/script-tests/parsing-shape-margin.js:
* fast/exclusions/parsing/script-tests/parsing-shape-outside.js:
* fast/exclusions/parsing/script-tests/parsing-shape-padding.js:
* fast/exclusions/resources/multi-segment-polygon.js:
(generatePolygon):
* fast/exclusions/resources/simple-polygon.js:
* fast/exclusions/resources/simple-rectangle.js:
* fast/exclusions/shape-inside/shape-inside-animation.html:
* fast/exclusions/shape-inside/shape-inside-bottom-edge.html:
* fast/exclusions/shape-inside/shape-inside-box-sizing.html:
* fast/exclusions/shape-inside/shape-inside-circle-padding.html:
* fast/exclusions/shape-inside/shape-inside-circle.html:
* fast/exclusions/shape-inside/shape-inside-coincident-vertices-expected.html:
* fast/exclusions/shape-inside/shape-inside-coincident-vertices.html:
* fast/exclusions/shape-inside/shape-inside-collinear-vertices-expected.html:
* fast/exclusions/shape-inside/shape-inside-collinear-vertices.html:
* fast/exclusions/shape-inside/shape-inside-counterclockwise-polygon-expected.html:
* fast/exclusions/shape-inside/shape-inside-counterclockwise-polygon.html:
* fast/exclusions/shape-inside/shape-inside-dynamic-nested-expected.html:
* fast/exclusions/shape-inside/shape-inside-dynamic-nested.html:
* fast/exclusions/shape-inside/shape-inside-dynamic-shape.html:
* fast/exclusions/shape-inside/shape-inside-dynamic-text.html:
* fast/exclusions/shape-inside/shape-inside-ellipse-padding.html:
* fast/exclusions/shape-inside/shape-inside-ellipse.html:
* fast/exclusions/shape-inside/shape-inside-empty-expected.html:
* fast/exclusions/shape-inside/shape-inside-empty.html:
* fast/exclusions/shape-inside/shape-inside-first-fit-001.html:
* fast/exclusions/shape-inside/shape-inside-first-fit-002.html:
* fast/exclusions/shape-inside/shape-inside-first-fit-003.html:
* fast/exclusions/shape-inside/shape-inside-first-fit-004-expected.html:
* fast/exclusions/shape-inside/shape-inside-first-fit-004.html:
* fast/exclusions/shape-inside/shape-inside-first-fit-reflex.html:
* fast/exclusions/shape-inside/shape-inside-inline-elements.html:
* fast/exclusions/shape-inside/shape-inside-multiple-blocks-vertical.html:
* fast/exclusions/shape-inside/shape-inside-multiple-blocks.html:
* fast/exclusions/shape-inside/shape-inside-on-nested-container-with-unresolved-height.html:
* fast/exclusions/shape-inside/shape-inside-overflow-fixed-dimensions.html:
* fast/exclusions/shape-inside/shape-inside-overflow.html:
* fast/exclusions/shape-inside/shape-inside-partial-fill-001.html:
* fast/exclusions/shape-inside/shape-inside-partial-fill-002.html:
* fast/exclusions/shape-inside/shape-inside-percentage-auto.html:
* fast/exclusions/shape-inside/shape-inside-percentage.html:
* fast/exclusions/shape-inside/shape-inside-polygon-layout.html:
* fast/exclusions/shape-inside/shape-inside-polygon-padding-001.html:
* fast/exclusions/shape-inside/shape-inside-polygon-padding-002.html:
* fast/exclusions/shape-inside/shape-inside-polygon-padding-003.html:
* fast/exclusions/shape-inside/shape-inside-polygon-rectangle.html:
* fast/exclusions/shape-inside/shape-inside-polygon-zoom.html:
* fast/exclusions/shape-inside/shape-inside-rectangle-padding.html:
* fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-001-expected.html:
* fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-001.html:
* fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-002-expected.html:
* fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-002.html:
* fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-003-expected.html:
* fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-003.html:
* fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-004-expected.html:
* fast/exclusions/shape-inside/shape-inside-rectilinear-polygon-004.html:
* fast/exclusions/shape-inside/shape-inside-regular-polygon16-expected.html:
* fast/exclusions/shape-inside/shape-inside-regular-polygon16.html:
* fast/exclusions/shape-inside/shape-inside-regular-polygon8-expected.html:
* fast/exclusions/shape-inside/shape-inside-regular-polygon8.html:
* fast/exclusions/shape-inside/shape-inside-rounded-rectangle-001.html:
* fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-001-expected.html:
* fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-001.html:
* fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002-expected.html:
* fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002.html:
* fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-003-expected.html:
* fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-003.html:
* fast/exclusions/shape-inside/shape-inside-rounded-rectangle-padding.html:
* fast/exclusions/shape-inside/shape-inside-shape-logical-top.html:
* fast/exclusions/shape-inside/shape-inside-sibling-block-dimension-change-needs-relayout-expected.html:
* fast/exclusions/shape-inside/shape-inside-sibling-block-dimension-change-needs-relayout.html:
* fast/exclusions/shape-inside/shape-inside-text.html:
* fast/exclusions/shape-inside/shape-inside-vertical-text.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-bottom.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-left.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-right.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-left-margin-polygon.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-non-zero-y.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-overflow-hidden.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-overhang.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-positioning.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-right-margin-polygon.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-circle.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-ellipse.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-inset-rectangle-percentage.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-inset-rectangle.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-polygon.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rounded-inset-rectangle.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rounded-rectangle-001.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rounded-rectangle-002.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rounded-rectangle-003.html:
* fast/exclusions/shape-outside-floats/shape-outside-floats-stacked.html:
* fast/regions/shape-inside/shape-inside-on-additional-regions.html:
* fast/regions/shape-inside/shape-inside-on-first-region-block-content.html:
* fast/regions/shape-inside/shape-inside-on-first-region-inline-content-expected.html:
* fast/regions/shape-inside/shape-inside-on-first-region-inline-content.html:
* fast/regions/shape-inside/shape-inside-on-regions-block-content-basic-overflow-shape-top-offset.html:
* fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-multiple-shapes.html:
* fast/regions/shape-inside/shape-inside-on-regions-expected.html:
* fast/regions/shape-inside/shape-inside-on-regions-inline-content-basic-overflow-shape-top-offset.html:
* fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-multiple-shapes.html:
* fast/regions/shape-inside/shape-inside-on-regions-inline-content.html:
* fast/regions/shape-inside/shape-inside-on-regions.html:
* fast/regions/shape-inside/shape-inside-on-second-region-block-content.html:
* fast/regions/shape-inside/shape-inside-on-second-region-inline-content.html:
* fast/regions/shape-inside/shape-inside-recursive-layout.html:
* fast/regions/shape-inside/shape-inside-with-region-borders.html:
* fast/regions/shape-inside/shape-inside-with-region-padding.html:


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