Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (92285 => 92286)
--- trunk/Source/WebCore/CMakeLists.txt 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-08-03 16:27:35 UTC (rev 92286)
@@ -635,6 +635,7 @@
editing/RemoveFormatCommand.cpp
editing/RemoveNodeCommand.cpp
editing/RemoveNodePreservingChildrenCommand.cpp
+ editing/RenderedPosition.cpp
editing/ReplaceNodeWithSpanCommand.cpp
editing/ReplaceSelectionCommand.cpp
editing/SetNodeAttributeCommand.cpp
Modified: trunk/Source/WebCore/ChangeLog (92285 => 92286)
--- trunk/Source/WebCore/ChangeLog 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/ChangeLog 2011-08-03 16:27:35 UTC (rev 92286)
@@ -1,3 +1,31 @@
+2011-08-03 Ryosuke Niwa <[email protected]>
+
+ Add RenderedPosition
+ https://bugs.webkit.org/show_bug.cgi?id=65221
+
+ Reviewed by Hajime Morita.
+
+ Add the skeleton for RenderedPosition and use it in rootBoxForLine.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * editing/EditingAllInOne.cpp:
+ * editing/RenderedPosition.cpp: Added.
+ (WebCore::RenderedPosition::RenderedPosition):
+ * editing/RenderedPosition.h: Added.
+ (WebCore::RenderedPosition::isNull):
+ (WebCore::RenderedPosition::rootBox):
+ (WebCore::RenderedPosition::RenderedPosition):
+ * editing/visible_units.cpp:
+ (WebCore::startPositionForLine):
+ (WebCore::endPositionForLine):
+ (WebCore::logicalStartPositionForLine):
+ (WebCore::logicalEndPositionForLine):
+
2011-08-03 Roland Steiner <[email protected]>
[V8] V8CSSRuleCustom.cpp: not all enum values are listed in switch statement
Modified: trunk/Source/WebCore/GNUmakefile.list.am (92285 => 92286)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-08-03 16:27:35 UTC (rev 92286)
@@ -1398,6 +1398,8 @@
Source/WebCore/editing/RemoveNodeCommand.h \
Source/WebCore/editing/RemoveNodePreservingChildrenCommand.cpp \
Source/WebCore/editing/RemoveNodePreservingChildrenCommand.h \
+ Source/WebCore/editing/RenderedPosition.cpp \
+ Source/WebCore/editing/RenderedPosition.h \
Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp \
Source/WebCore/editing/ReplaceNodeWithSpanCommand.h \
Source/WebCore/editing/ReplaceSelectionCommand.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (92285 => 92286)
--- trunk/Source/WebCore/WebCore.gypi 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/WebCore.gypi 2011-08-03 16:27:35 UTC (rev 92286)
@@ -2476,6 +2476,8 @@
'editing/RemoveNodeCommand.h',
'editing/RemoveNodePreservingChildrenCommand.cpp',
'editing/RemoveNodePreservingChildrenCommand.h',
+ 'editing/RenderedPosition.cpp',
+ 'editing/RenderedPosition.h',
'editing/ReplaceNodeWithSpanCommand.cpp',
'editing/ReplaceNodeWithSpanCommand.h',
'editing/ReplaceSelectionCommand.cpp',
Modified: trunk/Source/WebCore/WebCore.pro (92285 => 92286)
--- trunk/Source/WebCore/WebCore.pro 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/WebCore.pro 2011-08-03 16:27:35 UTC (rev 92286)
@@ -598,6 +598,7 @@
editing/RemoveFormatCommand.cpp \
editing/RemoveNodeCommand.cpp \
editing/RemoveNodePreservingChildrenCommand.cpp \
+ editing/RenderedPosition.cpp \
editing/ReplaceNodeWithSpanCommand.cpp \
editing/ReplaceSelectionCommand.cpp \
editing/SetNodeAttributeCommand.cpp \
@@ -1586,6 +1587,7 @@
editing/RemoveFormatCommand.h \
editing/RemoveNodeCommand.h \
editing/RemoveNodePreservingChildrenCommand.h \
+ editing/RenderedPosition.h \
editing/ReplaceNodeWithSpanCommand.h \
editing/ReplaceSelectionCommand.h \
editing/SetNodeAttributeCommand.h \
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (92285 => 92286)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-08-03 16:27:35 UTC (rev 92286)
@@ -51622,6 +51622,62 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\editing\RenderedPosition.h"
+ >
+ </File>
+ <File
+ RelativePath="..\editing\RenderedPosition.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_All|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
RelativePath="..\editing\RemoveNodePreservingChildrenCommand.h"
>
</File>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (92285 => 92286)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-08-03 16:27:35 UTC (rev 92286)
@@ -3252,6 +3252,8 @@
98CE4326129E00BD005821DC /* LinkLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98CE4325129E00BD005821DC /* LinkLoader.cpp */; };
98CE432A129E00E5005821DC /* LinkLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 98CE4329129E00E5005821DC /* LinkLoader.h */; };
98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = 98EB1F941313FE0500D0E1EA /* NotImplemented.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 9B32CDA913DF7FA900F34D13 /* RenderedPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B32CDA713DF7FA900F34D13 /* RenderedPosition.h */; };
+ 9B32CDAA13DF7FA900F34D13 /* RenderedPosition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B32CDA813DF7FA900F34D13 /* RenderedPosition.cpp */; };
9B417064125662B3006B28FC /* ApplyBlockElementCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B417062125662B3006B28FC /* ApplyBlockElementCommand.h */; settings = {ATTRIBUTES = (Private, ); }; };
9B417065125662B3006B28FC /* ApplyBlockElementCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B417063125662B3006B28FC /* ApplyBlockElementCommand.cpp */; };
9B6C41531344949000085B62 /* StringWithDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6C41521344949000085B62 /* StringWithDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9825,6 +9827,8 @@
98CE4325129E00BD005821DC /* LinkLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LinkLoader.cpp; sourceTree = "<group>"; };
98CE4329129E00E5005821DC /* LinkLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkLoader.h; sourceTree = "<group>"; };
98EB1F941313FE0500D0E1EA /* NotImplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotImplemented.h; sourceTree = "<group>"; };
+ 9B32CDA713DF7FA900F34D13 /* RenderedPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderedPosition.h; sourceTree = "<group>"; };
+ 9B32CDA813DF7FA900F34D13 /* RenderedPosition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderedPosition.cpp; sourceTree = "<group>"; };
9B417062125662B3006B28FC /* ApplyBlockElementCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyBlockElementCommand.h; sourceTree = "<group>"; };
9B417063125662B3006B28FC /* ApplyBlockElementCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyBlockElementCommand.cpp; sourceTree = "<group>"; };
9B6C41521344949000085B62 /* StringWithDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringWithDirection.h; sourceTree = "<group>"; };
@@ -15948,6 +15952,8 @@
93309DB6099E64910056E581 /* RemoveNodeCommand.h */,
93309DB7099E64910056E581 /* RemoveNodePreservingChildrenCommand.cpp */,
93309DB8099E64910056E581 /* RemoveNodePreservingChildrenCommand.h */,
+ 9B32CDA713DF7FA900F34D13 /* RenderedPosition.h */,
+ 9B32CDA813DF7FA900F34D13 /* RenderedPosition.cpp */,
A89CCC500F44E98100B5DA10 /* ReplaceNodeWithSpanCommand.cpp */,
A89CCC510F44E98100B5DA10 /* ReplaceNodeWithSpanCommand.h */,
93309DBA099E64910056E581 /* ReplaceSelectionCommand.cpp */,
@@ -22588,6 +22594,7 @@
BCEA4868097D93020094C9E4 /* RenderView.h in Headers */,
A871DFE40A15376B00B12A68 /* RenderWidget.h in Headers */,
93799EF90BF2743600D0F230 /* RenderWordBreak.h in Headers */,
+ 9B32CDA913DF7FA900F34D13 /* RenderedPosition.h in Headers */,
A89CCC530F44E98100B5DA10 /* ReplaceNodeWithSpanCommand.h in Headers */,
93309E0A099E64920056E581 /* ReplaceSelectionCommand.h in Headers */,
F55B3DD01251F12D003EF269 /* ResetInputType.h in Headers */,
@@ -25510,6 +25517,7 @@
BCEA4867097D93020094C9E4 /* RenderView.cpp in Sources */,
A871DFE50A15376B00B12A68 /* RenderWidget.cpp in Sources */,
93799EF80BF2743600D0F230 /* RenderWordBreak.cpp in Sources */,
+ 9B32CDAA13DF7FA900F34D13 /* RenderedPosition.cpp in Sources */,
A89CCC520F44E98100B5DA10 /* ReplaceNodeWithSpanCommand.cpp in Sources */,
93309E09099E64920056E581 /* ReplaceSelectionCommand.cpp in Sources */,
F55B3DCF1251F12D003EF269 /* ResetInputType.cpp in Sources */,
Modified: trunk/Source/WebCore/editing/EditingAllInOne.cpp (92285 => 92286)
--- trunk/Source/WebCore/editing/EditingAllInOne.cpp 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/editing/EditingAllInOne.cpp 2011-08-03 16:27:35 UTC (rev 92286)
@@ -57,6 +57,7 @@
#include <RemoveFormatCommand.cpp>
#include <RemoveNodeCommand.cpp>
#include <RemoveNodePreservingChildrenCommand.cpp>
+#include <RenderedPosition.cpp>
#include <ReplaceNodeWithSpanCommand.cpp>
#include <ReplaceSelectionCommand.cpp>
#include <SetNodeAttributeCommand.cpp>
Added: trunk/Source/WebCore/editing/RenderedPosition.cpp (0 => 92286)
--- trunk/Source/WebCore/editing/RenderedPosition.cpp (rev 0)
+++ trunk/Source/WebCore/editing/RenderedPosition.cpp 2011-08-03 16:27:35 UTC (rev 92286)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RenderedPosition.h"
+
+#include "InlineBox.h"
+#include "Position.h"
+#include "VisiblePosition.h"
+
+namespace WebCore {
+
+RenderedPosition::RenderedPosition(const VisiblePosition& position)
+ : m_renderer(0)
+ , m_inlineBox(0)
+ , m_offset(0)
+{
+ if (position.isNull())
+ return;
+ position.getInlineBoxAndOffset(m_inlineBox, m_offset);
+ if (m_inlineBox)
+ m_renderer = m_inlineBox->renderer();
+}
+
+};
Added: trunk/Source/WebCore/editing/RenderedPosition.h (0 => 92286)
--- trunk/Source/WebCore/editing/RenderedPosition.h (rev 0)
+++ trunk/Source/WebCore/editing/RenderedPosition.h 2011-08-03 16:27:35 UTC (rev 92286)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RenderedPosition_h
+#define RenderedPosition_h
+
+#include "InlineBox.h"
+#include "TextAffinity.h"
+
+namespace WebCore {
+
+class Position;
+class RenderObject;
+class VisiblePosition;
+
+class RenderedPosition {
+public:
+ RenderedPosition();
+ explicit RenderedPosition(const VisiblePosition&);
+
+ bool isNull() { return !m_renderer; }
+ RootInlineBox* rootBox() { return m_inlineBox ? m_inlineBox->root() : 0; }
+
+private:
+ RenderObject* m_renderer;
+ InlineBox* m_inlineBox;
+ int m_offset;
+};
+
+inline RenderedPosition::RenderedPosition()
+ : m_renderer(0)
+ , m_inlineBox(0)
+ , m_offset(0)
+{
+}
+
+};
+
+#endif // RenderedPosition_h
Modified: trunk/Source/WebCore/editing/visible_units.cpp (92285 => 92286)
--- trunk/Source/WebCore/editing/visible_units.cpp 2011-08-03 16:15:21 UTC (rev 92285)
+++ trunk/Source/WebCore/editing/visible_units.cpp 2011-08-03 16:27:35 UTC (rev 92286)
@@ -34,6 +34,7 @@
#include "RenderBlock.h"
#include "RenderLayer.h"
#include "RenderObject.h"
+#include "RenderedPosition.h"
#include "Text.h"
#include "TextBoundaries.h"
#include "TextBreakIterator.h"
@@ -323,24 +324,6 @@
// ---------
-static RootInlineBox *rootBoxForLine(const VisiblePosition &c)
-{
- Position p = c.deepEquivalent();
- Node* node = p.deprecatedNode();
- if (!node)
- return 0;
-
- RenderObject *renderer = node->renderer();
- if (!renderer)
- return 0;
-
- InlineBox* box;
- int offset;
- c.getInlineBoxAndOffset(box, offset);
-
- return box ? box->root() : 0;
-}
-
static VisiblePosition positionAvoidingFirstPositionInTable(const VisiblePosition& c)
{
// return table offset 0 instead of the first VisiblePosition inside the table
@@ -356,7 +339,7 @@
if (c.isNull())
return VisiblePosition();
- RootInlineBox *rootBox = rootBoxForLine(c);
+ RootInlineBox* rootBox = RenderedPosition(c).rootBox();
if (!rootBox) {
// There are VisiblePositions at offset 0 in blocks without
// RootInlineBoxes, like empty editable blocks and bordered blocks.
@@ -404,7 +387,7 @@
if (c.isNull())
return VisiblePosition();
- RootInlineBox *rootBox = rootBoxForLine(c);
+ RootInlineBox* rootBox = RenderedPosition(c).rootBox();
if (!rootBox) {
// There are VisiblePositions at offset 0 in blocks without
// RootInlineBoxes, like empty editable blocks and bordered blocks.
@@ -1063,7 +1046,7 @@
if (c.isNull())
return VisiblePosition();
- RootInlineBox* rootBox = rootBoxForLine(c);
+ RootInlineBox* rootBox = RenderedPosition(c).rootBox();
if (!rootBox) {
// There are VisiblePositions at offset 0 in blocks without
// RootInlineBoxes, like empty editable blocks and bordered blocks.
@@ -1103,7 +1086,7 @@
if (c.isNull())
return VisiblePosition();
- RootInlineBox* rootBox = rootBoxForLine(c);
+ RootInlineBox* rootBox = RenderedPosition(c).rootBox();
if (!rootBox) {
// There are VisiblePositions at offset 0 in blocks without
// RootInlineBoxes, like empty editable blocks and bordered blocks.