ReplaceSelectionCommand should merge text nodes
https://bugs.webkit.org/show_bug.cgi?id=98188

Reviewed by Levi Weintraub.

Source/WebCore: 

Added mergeTextNodesAroundPosition to ReplaceSelectionCommand to merge text nodes after the replace in
completeHTMLReplacement. Also fixed a bunch of bugs in other classes and functions to make this work.

This behavior change is tested by existing tests.

* editing/InsertParagraphSeparatorCommand.cpp:
(WebCore::InsertParagraphSeparatorCommand::doApply): When splitting a text node, place the insertionPosition
at the end of the first half. Leaving it at the beginning of the second half confuses the rest of the code in
the function. However, the logic to handle the "insignificant" white spaces needs the position at the start of
the second half. So keep this position.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply): Update visibleStart after inserting a paragraph separator so that
the logic to cleanup the nested div checks the right condition (right beneath it starting with a long comment).
(WebCore::ReplaceSelectionCommand::addSpacesForSmartReplace): Insert a space for smart paste at the appropriate
offset instead of at the end of endNode. Also update the layout before obtaining startDownstream as we may have 
modified the DOM by inserting a space for endNode. Finally, a non-breaking space should be treated like a space
isCharacterSmartReplaceExempt for the purpose of smart replace. e.g. if we're inserting "world" after
"hello&nbsp;", we shouldn't be inserting another space between "hello" and "world".
(WebCore::ReplaceSelectionCommand::completeHTMLReplacement):
(WebCore::ReplaceSelectionCommand::mergeTextNodesAroundPosition): Added. Merge text nodes around position, and
adjust position and positionOnlyToBeUpdated accordingly. We need to call updatePositionForNodeRemoval when
positions were before or after the text node.
* editing/ReplaceSelectionCommand.h:
(ReplaceSelectionCommand):

LayoutTests: 

Rebaselined tests.

* editing/deleting/merge-paragraphs-with-transparent-background-expected.txt:
* editing/deleting/paste-with-transparent-background-color-expected.txt:
* editing/execCommand/outdent-selection-expected.txt:
* editing/execCommand/remove-list-items-expected.txt:
* editing/inserting/insert-3907422-fix-expected.txt:
* editing/pasteboard/avoid-copying-body-with-background-expected.txt:
* editing/pasteboard/block-wrappers-necessary-expected.txt:
* editing/pasteboard/drag-drop-list-expected.txt:
* editing/pasteboard/merge-end-5-expected.txt:
* editing/pasteboard/paste-before-tab-span-expected.txt:
* editing/pasteboard/paste-into-table-cell-expected.txt:
* editing/pasteboard/paste-text-001-expected.txt:
* editing/pasteboard/paste-text-002-expected.txt:
* editing/pasteboard/paste-text-003-expected.txt:
* editing/pasteboard/paste-text-010-expected.txt:
* editing/pasteboard/paste-text-at-tabspan-001-expected.txt:
* editing/pasteboard/paste-unrendered-select-expected.txt:
* editing/pasteboard/smart-paste-001-expected.txt:
* editing/pasteboard/smart-paste-002-expected.txt:
* editing/pasteboard/smart-paste-003-expected.txt:
* editing/pasteboard/smart-paste-004-expected.txt:
* editing/pasteboard/smart-paste-005-expected.txt:
* editing/pasteboard/smart-paste-006-expected.txt:
* fast/events/ondragenter-expected.txt:
* fast/lists/drag-into-marker.html:
* platform/mac/editing/deleting/delete-block-merge-contents-018-expected.txt:
* platform/mac/editing/deleting/delete-block-merge-contents-019-expected.txt:
* platform/mac/editing/deleting/delete-block-merge-contents-020-expected.txt:
* platform/mac/editing/deleting/delete-block-merge-contents-021-expected.txt:
* platform/mac/editing/deleting/delete-block-merge-contents-022-expected.txt:
* platform/mac/editing/deleting/merge-no-br-expected.txt:
* platform/mac/editing/execCommand/find-after-replace-expected.txt:
* platform/mac/editing/execCommand/paste-1-expected.txt:
* platform/mac/editing/execCommand/paste-2-expected.txt:
* platform/mac/editing/pasteboard/4944770-2-expected.txt:
* platform/mac/editing/pasteboard/5006779-expected.txt:
* platform/mac/editing/pasteboard/5028447-expected.txt:
* platform/mac/editing/pasteboard/8145-3-expected.txt:
* platform/mac/editing/pasteboard/drag-drop-modifies-page-expected.txt:
* platform/mac/editing/pasteboard/emacs-ctrl-k-y-001-expected.txt:
* platform/mac/editing/pasteboard/merge-end-borders-expected.txt:
* platform/mac/editing/pasteboard/paste-line-endings-007-expected.txt:
* platform/mac/editing/pasteboard/paste-line-endings-008-expected.txt:
* platform/mac/editing/pasteboard/paste-line-endings-009-expected.txt:
* platform/mac/editing/pasteboard/paste-line-endings-010-expected.txt:
* platform/mac/editing/pasteboard/paste-match-style-001-expected.txt:
* platform/mac/editing/pasteboard/paste-text-004-expected.txt:
* platform/mac/editing/pasteboard/paste-text-005-expected.txt:
* platform/mac/editing/pasteboard/paste-text-008-expected.txt:
* platform/mac/editing/pasteboard/paste-text-009-expected.txt:
* platform/mac/editing/pasteboard/smart-drag-drop-expected.txt:
* platform/mac/editing/pasteboard/smart-paste-007-expected.txt:
* platform/mac/editing/pasteboard/smart-paste-008-expected.txt:
* platform/mac/editing/pasteboard/subframe-dragndrop-1-expected.txt:
* platform/mac/editing/pasteboard/unrendered-br-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[skia] Drawing a subrect of bitmap image is misaligned
https://bugs.webkit.org/show_bug.cgi?id=95121

Reviewed by Stephen White.

Source/WebCore:

When drawing a subrect of BitmapImage and the subrect is not aligned
to integer boundaries, skia expands it to the closest enclosing integer
rectangle. This creates prominent rendering artifacts when an image
is used as background and its sub-regions are invalidated frequently.

This patch fixes the problem by doing alignment to integer boundaries
and clipping for both cases of RESAMPLE_AWESOME and RESAMPLE_LINEAR.

A clip rect is applied to the canvas using original destination
rectangle, while source and destination rectangles are enlarged
appropriately to ensure source rectangle is aligned.

This patch also fixes a closely related problem. In RESAMPLE_AWESOME
resampling mode the previous algorithm applies different approximated
scale factor for each scaled image fragment. This caused the stitched
image to look ugly.

Scale factor is approximated using entire image size, this gives a
more accurate approximation because of greater denominator and a
consistent scale factor across all fragments.

Changes in Skia enable caching of the scaled image and return the
scaled fragment because scale factor is now consistent for all
fragments.

Tests: fast/images/paint-subrect-grid.html
       fast/images/paint-subrect.html
       fast/images/repaint-subrect-grid.html

* platform/graphics/skia/ImageSkia.cpp:
(WebCore::computeResamplingMode): Use float for width and height.
(WebCore):
(WebCore::areBoundariesIntegerAligned):
(WebCore::computeBitmapDrawRects):
(WebCore::extractScaledImageFragment):
(WebCore::drawResampledBitmap): New algorithm for drawing scaled image fragment.
(WebCore::paintSkBitmap):
(WebCore::Image::drawPattern):
(WebCore::BitmapImage::draw): Use SkRect instead of SkIRect.
(WebCore::BitmapImageSingleFrameSkia::draw):
* platform/graphics/skia/NativeImageSkia.cpp:
Changing the algorithm for extracting a scaled image fragment.
A fragment is now identified by (scaledImageSize, scaledImageSubset).
(WebCore::NativeImageSkia::hasResizedBitmap):
(WebCore::NativeImageSkia::resizedBitmap):
(WebCore::NativeImageSkia::shouldCacheResampling):
(WebCore::NativeImageSkia::CachedImageInfo::CachedImageInfo):
(WebCore):
(WebCore::NativeImageSkia::CachedImageInfo::isEqual):
(WebCore::NativeImageSkia::CachedImageInfo::set):
(WebCore::NativeImageSkia::CachedImageInfo::rectInSubset):
* platform/graphics/skia/NativeImageSkia.h:
(NativeImageSkia):
(CachedImageInfo):

LayoutTests:

3 new tests added.

- fast/images/paint-subrect.html

This test enlarges a 2x1 image in a canvas for easy verification.
2/3 of the image is used as source rectangle to exercise the code path
for partial pixel addressing.

Pixel test result should have 1/3 blue on the left and 2/3 green on the
right with gradient according to interpolation settings.

- fast/images/paint-subrect-grid.html

Draws a 11x11 image into a canvas in 8 fragments with partial pixels.
Canvas should look just like a single image enlarged.

- fast/images/repaint-subrect-grid.html

Scale a 31x31 image to 55x55. A blue square moves across the scaled
image such that the image is partially invalidated. After the animation
the image should look the same.

* fast/images/paint-subrect-expected.txt: Added.
* fast/images/paint-subrect-grid-expected.txt: Added.
* fast/images/paint-subrect-grid.html: Added.
* fast/images/paint-subrect.html: Added.
* fast/images/repaint-subrect-grid-expected.html: Added.
* fast/images/repaint-subrect-grid.html: Added.
* fast/images/resources/grid-large.png: Added.
* fast/images/resources/grid-small.png: Added.
* platform/chromium/TestExpectations: Added image failure expectations.
* platform/chromium/fast/images/paint-subrect-expected.png: Added.
* platform/chromium/fast/images/paint-subrect-grid-expected.png: Added.
* platform/chromium/fast/images/repaint-subrect-grid-expected.png: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
After r130344, OpaqueJSString() creates a empty string which should be a null string
https://bugs.webkit.org/show_bug.cgi?id=98417

Reviewed by Alexey Proskuryakov.

Removed the setting of enclosed string to an empty string from default constructor.
Before changeset r130344, the semantic was the default constructor produced a null
string.

* API/OpaqueJSString.h:
(OpaqueJSString::OpaqueJSString):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130413 268f45cc-cd09-0410-ab3c-d52691b4dbfc
webkitpy: Accept WEBKITOUTPUTDIR in Port._setup_environ_for_server.
https://bugs.webkit.org/show_bug.cgi?id=98436

Reviewed by Dirk Pranke.

The Xvfb driver (ab)uses Port._setup_environ_for_server() to set
the environment for the server process, and the WEBKITOUTPUTDIR
environment variable was not being passed through, causing the
build directory to be wrongfully set to WebKitBuild/ all the time.

* Scripts/webkitpy/layout_tests/port/base.py:
(Port.to.setup_environ_for_server):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make the Xvfb driver recognize `X' as a valid X server binary.
https://bugs.webkit.org/show_bug.cgi?id=98434

Reviewed by Dirk Pranke.

The X server binary can also be called `X', so account for that
possibility in the _next_free_display regexp.

Additionally, make the regular expression require at least one
space character after the `ps comm' part.

* Scripts/webkitpy/layout_tests/port/xvfbdriver.py:
(XvfbDriver._next_free_display):
* Scripts/webkitpy/layout_tests/port/xvfbdriver_unittest.py:
(XvfbDriverTest.test_next_free_display):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130415 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[WK2] Support all attributes of GeolocationPosition
https://bugs.webkit.org/show_bug.cgi?id=98212

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-10-03
Reviewed by Sam Weinig.

Source/WebKit/mac: 

Add an internal constructor for the sake of testing.
A similar API is used on iOS.

* WebView/WebGeolocationPosition.mm:
(-[WebGeolocationPosition initWithGeolocationPosition:]):

Source/WebKit2: 

Add complete support for GeolocationPosition.

* Shared/WebGeolocationPosition.cpp:
(WebKit::WebGeolocationPosition::WebGeolocationPosition):
(WebKit::WebGeolocationPosition::Data::encode):
(WebKit::WebGeolocationPosition::Data::decode):
* Shared/WebGeolocationPosition.h:
(Data):
(WebKit::WebGeolocationPosition::create):
(WebKit::WebGeolocationPosition::canProvideAltitude):
(WebKit::WebGeolocationPosition::altitude):
(WebGeolocationPosition):
(WebKit::WebGeolocationPosition::canProvideAltitudeAccuracy):
(WebKit::WebGeolocationPosition::altitudeAccuracy):
(WebKit::WebGeolocationPosition::canProvideHeading):
(WebKit::WebGeolocationPosition::heading):
(WebKit::WebGeolocationPosition::canProvideSpeed):
(WebKit::WebGeolocationPosition::speed):
WebGeolocationPosition mirror the attributes of WebCore::GeolocationPosition.

* UIProcess/API/C/WKGeolocationPosition.cpp:
(WKGeolocationPositionCreate):
(WKGeolocationPositionCreate_b):
Add a new API exposing all the arguments.

* UIProcess/API/C/WKGeolocationPosition.h:
* WebProcess/Geolocation/WebGeolocationManager.cpp:
(WebKit::WebGeolocationManager::didChangePosition):

Tools: 

Expand WebKitTestRunner and DumpRenderTree to test all the attributes
of GeolocationPosition.

* DumpRenderTree/TestRunner.cpp:
(setMockGeolocationPositionCallback):
* DumpRenderTree/TestRunner.h:
(TestRunner):
* DumpRenderTree/efl/TestRunnerEfl.cpp:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/gtk/TestRunnerGtk.cpp:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/wx/TestRunnerWx.cpp:
(TestRunner::setMockGeolocationPosition):
* WebKitTestRunner/GeolocationProviderMock.cpp:
(WTR::GeolocationProviderMock::setPosition):
* WebKitTestRunner/GeolocationProviderMock.h:
(GeolocationProviderMock):
* WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
(_platformTypeVariableDeclaration):
Use a proper constructor for the JSValueRef, it is an opaque type, we are not supposed
to build the pointer outself.
This is necessary to support optional JSValueRef properly.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(TestRunner):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setMockGeolocationPosition):
* WebKitTestRunner/TestController.h:
(TestController):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests: 

Add a new test for the exposed attributes. It is disabled everywhere else than
Mac because of the missing DRT features.

* fast/dom/Geolocation/coordinates-interface-attributes-expected.txt: Added.
* fast/dom/Geolocation/coordinates-interface-attributes.html: Added.
* platform/chromium/TestExpectations:
* platform/gtk/TestExpectations:
* platform/qt/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Attribute and Uniform variable names need translation in shader
https://bugs.webkit.org/show_bug.cgi?id=70989

Reviewed by Tim Horton (and Darin Adler).

Source/WebCore:

WebGL specifies some maximum lengths for variable names (attributes
and uniforms). Also, some GL drivers have issues with long names. For
that reason, ANGLE has an option to rewrite the shader, translating
long names into short names. Turning this on helps shaders compile,
but we need to keep a mapping between the original names and the
translated names, so that we bind to the right location from user code
(which won't ever see the translated source).

This provided an opportunity to clean up some other bits of code:
CSS Filters examined the uniform names after a compilation; It can
now use the variable name map. I also added a typedef for the
HashMaps that keep the shader, the source code and the variable name
mappings.

I also opened a followup bug to make sure these tables are deleted
when the associated shaders (or linked programs) go away:
https://bugs.webkit.org/show_bug.cgi?id=98204

Covered by existing tests (with some enhancements):
- fast/canvas/webgl/attrib-location-length-limits.html:
- fast/canvas/webgl/uniform-location-length-limits.html:

* platform/graphics/ANGLEWebKitBridge.cpp:
(WebCore::getSymbolInfo): Extracts all the information on symbols (either attributes
or uniforms) from the newly compiled shader.
(WebCore):
(WebCore::ANGLEWebKitBridge::compileShaderSource): New method name.
* platform/graphics/ANGLEWebKitBridge.h:
(WebCore::getUniforms): Deleted this method.
(WebCore::ANGLEShaderSymbol::isSampler): Make sure the symbol is a uniform.
(ANGLEWebKitBridge):
* platform/graphics/GraphicsContext3D.h:
(WebCore::GraphicsContext3D::SymbolInfo::SymbolInfo): A new object that
holds the size, type and translated name of a symbol from a WebGL shader.
(ShaderSourceEntry):
(WebCore::GraphicsContext3D::ShaderSourceEntry::ShaderSourceEntry): Now keeps track
of the translated source code and symbol mappings.
(WebCore::GraphicsContext3D::ShaderSourceEntry::symbolMap): Helper function to
get the member variable corresponding to the type of symbol you're asking fo.
* platform/graphics/filters/CustomFilterValidatedProgram.cpp:
(WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram): Calls new method
name which also produces a set of symbols to examine.
* platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
(WebCore::Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE): We now can pass
in some extra compile options to do translation of long symbol names. Also fill the
map of translated symbol names.
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::compileShader):
(WebCore::GraphicsContext3D::mappedSymbolName): Returns the mapped name for
a shader symbol if it was translated during compilation.
(WebCore):
(WebCore::GraphicsContext3D::getAttribLocation):
(WebCore::GraphicsContext3D::getShaderiv):
(WebCore::GraphicsContext3D::getShaderInfoLog):
(WebCore::GraphicsContext3D::getShaderSource):
(WebCore::GraphicsContext3D::getUniformLocation):

LayoutTests:

Added subtests to exercise variables that are well under the limits but
not long enough to produce an error. This way we now test all three options:
under the limit, at the limit, over the limit.

Also, the tests are unskipped on Mac.

* fast/canvas/webgl/attrib-location-length-limits-expected.txt:
* fast/canvas/webgl/attrib-location-length-limits.html:
* fast/canvas/webgl/uniform-location-length-limits-expected.txt:
* fast/canvas/webgl/uniform-location-length-limits.html:
* platform/mac/TestExpectations:

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