Commit Graph

144 Commits

Author SHA1 Message Date
Mirko Brodesser
fc91f37b49 Bug 1433073: part 3) Mimic old behavior of computing mCommonInclusiveAncestors. r=hsivonen
This reverts a previously introduced regression. See the Bugzilla
comments of this bug.

The key consequence of this is change is that copy-pasting multiple
click-selected table rows now works again for some applications (and
shouldn't be broken for others). That's because the clipboard flavor
"text/_moz_htmlcontext" doesn't contain a superfluous "<tr>" anymore.

The fix could presumably be more elegant, but it would be hard to ensure
no other applications relying on the old behavior break.

Differential Revision: https://phabricator.services.mozilla.com/D71982
2020-04-23 10:14:47 +00:00
Mirko Brodesser
edab46f37b Bug 1623858: part 21) Add some const correctness to nsDocumentEncoder::SerializeSelection. r=hsivonen
Depends on D68580

Differential Revision: https://phabricator.services.mozilla.com/D68581

--HG--
extra : moz-landing-system : lando
2020-03-30 08:48:19 +00:00
Mirko Brodesser
d252ed1175 Bug 1623333: part 2) Declare Selection::mSelectionType const. r=smaug
Simplifies reasoning about it.

Differential Revision: https://phabricator.services.mozilla.com/D67328

--HG--
extra : moz-landing-system : lando
2020-03-19 09:25:02 +00:00
Simon Giesecke
d94419173b Bug 1613985 - Use default for equivalent-to-default constructors/destructors in dom/base. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D63102

--HG--
extra : moz-landing-system : lando
2020-02-21 10:41:47 +00:00
Mirko Brodesser
e7ed18f679 Bug 1613378: part 7) Remove Selection's default constructor. r=smaug
Removes duplicated code and reveals the dependency to frame selection.

Differential Revision: https://phabricator.services.mozilla.com/D62040

--HG--
extra : moz-landing-system : lando
2020-02-11 10:50:54 +00:00
Brindusan Cristian
a68356b907 Backed out 5 changesets (bug 1613378) for mochitest failures at test_general.html. CLOSED TREE
Backed out changeset f38b806ee78b (bug 1613378)
Backed out changeset cee4bbabc4b5 (bug 1613378)
Backed out changeset e3a2ab6d7267 (bug 1613378)
Backed out changeset 6fe76439f1d3 (bug 1613378)
Backed out changeset f3baf3407cbe (bug 1613378)
2020-02-11 12:27:49 +02:00
Mirko Brodesser
931ef1e3fa Bug 1613378: part 7) Remove Selection's default constructor. r=smaug
Removes duplicated code and reveals the dependency to frame selection.

Differential Revision: https://phabricator.services.mozilla.com/D62040

--HG--
extra : moz-landing-system : lando
2020-02-11 09:26:07 +00:00
Mirko Brodesser
56780ebd31 Bug 1609662: part 17) Clean up some code around Selection and ranges in nsDocumentEncoder. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D60644

--HG--
extra : moz-landing-system : lando
2020-01-27 09:25:12 +00:00
Mirko Brodesser
efd738af5b Bug 1608071: part 2) Rename nsContentUtils::GetCommonAncestor and related methods. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D59319

--HG--
extra : moz-landing-system : lando
2020-01-13 10:29:44 +00:00
Gabriele Svelto
ace6d1063f Bug 1600545 - Remove useless inclusions of header files generated from IDL files in dom/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.

find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
    interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
    if [ -n "$interfaces" ]; then
        if [[ "$interfaces" == *$'\n'* ]]; then
          regexp="\("
          for i in $interfaces; do regexp="$regexp$i\|"; done
          regexp="${regexp%%\\\|}\)"
        else
          regexp="$interfaces"
        fi
        interface=$(basename "$path")
        rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
            hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
            if [ $hits -eq 0 ]; then
                echo "Removing ${interface} from ${path2}"
                grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
                mv -f "$path2".tmp "$path2"
            fi
        done
    fi
done

Differential Revision: https://phabricator.services.mozilla.com/D55442

--HG--
extra : moz-landing-system : lando
2019-12-06 09:24:56 +00:00
Dorel Luca
a381d5c96d Backed out changeset f6e53d1c6518 (bug 1600545) for Android build bustage. CLOSED TREE 2019-12-04 17:32:27 +02:00
Gabriele Svelto
bc9290f767 Bug 1600545 - Remove useless inclusions of header files generated from IDL files in dom/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.

find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
    interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
    if [ -n "$interfaces" ]; then
        if [[ "$interfaces" == *$'\n'* ]]; then
          regexp="\("
          for i in $interfaces; do regexp="$regexp$i\|"; done
          regexp="${regexp%%\\\|}\)"
        else
          regexp="$interfaces"
        fi
        interface=$(basename "$path")
        rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
            hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
            if [ $hits -eq 0 ]; then
                echo "Removing ${interface} from ${path2}"
                grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
                mv -f "$path2".tmp "$path2"
            fi
        done
    fi
done

Differential Revision: https://phabricator.services.mozilla.com/D55442

--HG--
extra : moz-landing-system : lando
2019-12-04 15:01:19 +00:00
Mirko Brodesser
b2de103bf9 Bug 1593222: part 12) Rename "nsNodeUtils.*" to "MutationObservers.*". r=smaug
Depends on D51827

Differential Revision: https://phabricator.services.mozilla.com/D51828

--HG--
rename : dom/base/nsNodeUtils.cpp => dom/base/MutationObservers.cpp
rename : dom/base/nsNodeUtils.h => dom/base/MutationObservers.h
extra : moz-landing-system : lando
2019-11-06 09:08:06 +00:00
Mirko Brodesser
47bb9d8c1a Bug 1593222: part 3) Move nsNodeUtils::GetFirstChildOfTemplateOrNode to nsINode. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D51608

--HG--
extra : moz-landing-system : lando
2019-11-05 14:06:05 +00:00
Mirko Brodesser
45015bce27 Bug 1576899: change nsIContentSerializer to take output string as argument in nsIContentSerializer::Init. r=hsivonen
Before, all `nsIContentSerializer::Append`* methods took an output
string. The state of `nsPlainTextSerializer` depended on the string
pointing to the same object.

Now, it's ensured that the same output string is used between
`nsIContentSerializer::Init` and `nsIContentSerializer::Finish`.

Moreover, `nsHTMLCopyEncoder::EncodeToStringWithContext` re-used
`mSerializer` without initializing it again. This was error-prone,
because after serializing with `mSerializer`, it's internal state might
have changed to an undesirable one (e.g.
`nsPlainTextSerializer::mWrapColumn` could've been modified).
Hence, it is now initialized again before serializing the common
ancestors.

Differential Revision: https://phabricator.services.mozilla.com/D43613

--HG--
extra : moz-landing-system : lando
2019-08-28 11:54:49 +00:00
longsonr
40d4617494 Bug 1570799 - pass the original element into nsXMLContentSerializer::CheckElementEnd so that we can determine whether it has children properly r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D43450

--HG--
extra : moz-landing-system : lando
2019-08-27 20:33:46 +00:00
Emilio Cobos Álvarez
8a8e0391b0 Bug 1571517 - Don't bail out when serializing a range starting at the end of an element. r=mbrodesser
We have a range that starts at the end of a cell, and ends somewhere else.

We were bailing out recursively from the beginning, causing the serialization to
be the empty string rather than the actually selected text.

Differential Revision: https://phabricator.services.mozilla.com/D42495

--HG--
extra : moz-landing-system : lando
2019-08-20 11:20:16 +00:00
Mirko Brodesser
5e6d66382d Bug 1574463: remove unused nsIDocumentEncoder::OutputNonTextContentAsPlaceholder. r=hsivonen
Doesn't seem to be used by comm-central/Thunderbird.

Differential Revision: https://phabricator.services.mozilla.com/D42302

--HG--
extra : moz-landing-system : lando
2019-08-19 07:56:05 +00:00
Masayuki Nakano
23a22c597a Bug 1569902 - part 2: Stop using attribute to consider whether a <br> element is a special node for empty last line or not r=m_kato,smaug
Editor creates a `<br>` element to end of a block if last line
of the block is empty because caret should be placed as there is an empty
line.  Such special `<br>` element has `type` attribute whose value is "_moz".
However, adding/removing the attribute is expensive and such hacky attribute
shouldn't be referred nor changed by web apps.

Therefore, this patch makes `HTMLBRElement` take another specific flag whether
it's a special node for empty last line.  For making the meaning clearer,
this patch calls the such `<br>` elements as "padding `<br>` element for
empty last line" insead of "moz-br".  So, this patch also includes a lot of
renaming methods and variables, and modifying related comments.

Note that with this change, `IMEContentObserver` counts the padding `<br>`
element in `<textarea>` because it's inserted before setting the new flag
and setting the flag does not cause DOM tree mutation.  This issue will be
fixed by the following patches.

Differential Revision: https://phabricator.services.mozilla.com/D39858

--HG--
extra : moz-landing-system : lando
2019-08-02 05:45:18 +00:00
Mirko Brodesser
1788c9c941 Bug 1562876: rename Selection::AddRangeInternal to Selection::AddRangeAndSelectFramesAndNotifyListeners. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D36601
2019-07-03 13:26:13 +02:00
Sylvestre Ledru
f1fbd2ff00 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D33456

--HG--
extra : moz-landing-system : lando
2019-06-08 08:26:37 +00:00
Ehsan Akhgari
adf073ce68 Bug 836176 - Part 3: Remove nsIHTMLDocument; r=farre
Differential Revision: https://phabricator.services.mozilla.com/D32925

--HG--
extra : moz-landing-system : lando
2019-06-04 17:27:43 +00:00
Mirko Brodesser
899bfb263a Bug 1554222: delegate serializing in nsDocumentEncoder depending on encoding scope to separate methods. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D32486

--HG--
extra : moz-landing-system : lando
2019-05-27 07:50:19 +00:00
Mirko Brodesser
0ad0e91ed8 Bug 1554147: rename mCommonParent and encapsulate mStartDepth and mEndDepth in ContextInfoDepth. r=hsivonen
In order to simplify `nsDocumentEncoder`.

Differential Revision: https://phabricator.services.mozilla.com/D32468

--HG--
extra : moz-landing-system : lando
2019-05-27 07:45:15 +00:00
Sylvestre Ledru
d57d4905f1 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D30883

--HG--
extra : moz-landing-system : lando
2019-05-25 17:46:15 +00:00
arthur.iakab
af8e458c5f Backed out changeset a296439a25ff (bug 1519636) for frequent Windows cppunit failures CLOSED TREE 2019-05-24 14:26:01 +03:00
Sylvestre Ledru
c82ea97226 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D30883

--HG--
extra : moz-landing-system : lando
2019-05-24 09:59:17 +00:00
Mirko Brodesser
7bd552ead5 Bug 1553766: encapsulate range boundary specific members of nsDocumentEncoder and free their memory in nsDocumentEncoder::Initialize. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D32304

--HG--
extra : moz-landing-system : lando
2019-05-23 14:47:10 +00:00
Mirko Brodesser
d68e697c37 Bug 1553480: make resetting members of nsIDocumentEncoder consistent r=hsivonen
Moreover, prepone deleting the cached serializer with LAST_RELEASE
already.

Differential Revision: https://phabricator.services.mozilla.com/D32286

--HG--
extra : moz-landing-system : lando
2019-05-23 10:22:15 +00:00
Mirko Brodesser
31f6daf51c Bug 1553122: split off encoding scope of nsDocumentEncoder to separate class. r=hsivonen
In order to clean up `nsDocumentEncoder`.

Differential Revision: https://phabricator.services.mozilla.com/D32102

--HG--
extra : moz-landing-system : lando
2019-05-22 08:39:02 +00:00
Mirko Brodesser
dff9cbe75c Bug 1552752: Part 2) Rename ConvertAndWrite to EncodeAndWrite and slighlty simplify method. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D31768

--HG--
extra : moz-landing-system : lando
2019-05-21 07:36:49 +00:00
Mirko Brodesser
d762bd2dd7 Bug 1552869: propagate nsresult values of various Append* calls in SerializeNodeStart, SerializeNodeEnd r=hsivonen
Might helpt to discover and prevent bugs.

Differential Revision: https://phabricator.services.mozilla.com/D31798

--HG--
extra : moz-landing-system : lando
2019-05-21 05:38:20 +00:00
Mirko Brodesser
bd167d6f1e Bug 1552752: Part 1) Split off text streaming in nsDocumentEncoder to separate class. r=hsivonen
Abstracts the streaming details away. Reduces complexity of
`nsDocumentEncoder`.

Differential Revision: https://phabricator.services.mozilla.com/D31767

--HG--
extra : moz-landing-system : lando
2019-05-21 05:38:06 +00:00
Mirko Brodesser
0c5556605c Bug 1552490: rename nsCopySupport::HTMLCopy, change nsDocumentEncoder::IsVisible, add unit to buffer size name. r=hsivonen
Because it states more clearly what the functions and the constant are
about.

Differential Revision: https://phabricator.services.mozilla.com/D31615

--HG--
extra : moz-landing-system : lando
2019-05-20 07:43:43 +00:00
Mirko Brodesser
ae0d45070b Bug 1551857: declare static methods of nsHTMLCopyEncoder as such r=hsivonen
Simplifies reasoning about the code.

Differential Revision: https://phabricator.services.mozilla.com/D31240

--HG--
extra : moz-landing-system : lando
2019-05-15 13:22:30 +00:00
Jorg K
eaafaa14f5 Bug 1551707 - Remove conditionally compiled code for Thunderbird from dom/base/nsDocumentEncoder.cpp r=mbrodesser
Differential Revision: https://phabricator.services.mozilla.com/D31137

--HG--
extra : rebase_source : ac0f2da6a2efef8716db9df4ccf021b2b2bd6b8a
2019-05-15 11:07:25 +03:00
Mirko Brodesser
331e0a761b Bug 1174452: Part 2 -- scan nsTextNode's parent element for preformat in nsDocumentEncoder r=masayuki,hsivonen
This takes into account `white-space: pre` style of `nsTextNode`'s
parent element when formatting the selected text of the `nsTextNode`
node.

Differential Revision: https://phabricator.services.mozilla.com/D29159

--HG--
extra : moz-landing-system : lando
2019-05-09 07:40:47 +00:00
Mirko Brodesser
05691b5529 Bug 1549696: factor out functionality to determine fixup node in nsDocumentEncoder. r=hsivonen
In order to reduce code duplication and make the code more legible.

Differential Revision: https://phabricator.services.mozilla.com/D30199

--HG--
extra : moz-landing-system : lando
2019-05-08 11:09:51 +00:00
Mirko Brodesser
537568f496 Bug 1549283: add missing calls to SerializeNodeEnd r=hsivonen
In order to have one call of `SerializeNodeEnd` for every `SerializeNodeStart`
call. In the current state of the code, the absence of these calls doesn't
cause bugs, but this can change anytime `SerializeNodeEnd` is changed. Moreover,
it makes it simpler to reason about the code.

Differential Revision: https://phabricator.services.mozilla.com/D29987

--HG--
extra : moz-landing-system : lando
2019-05-06 13:49:53 +00:00
Andreea Pavel
f955a60145 Backed out changeset 78ed7f9d6566 (bug 1542530) for failing test_text_selection.html on a CLOSED TREE 2019-04-11 19:38:18 +03:00
Andrea Marchesini
07ce3681ac Bug 1542530 - Selection.toString() works correctly when text is selected together with a set of div+svg elements, r=mats
Differential Revision: https://phabricator.services.mozilla.com/D27064

--HG--
extra : moz-landing-system : lando
2019-04-11 14:13:24 +00:00
Boris Zbarsky
5bf2e408e6 Bug 1534608. MOZ_CAN_RUN_SCRIPT should disallow non-stack refptr arguments. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D23217

--HG--
extra : moz-landing-system : lando
2019-03-13 00:30:11 +00:00
Emilio Cobos Álvarez
d2ed260822 Bug 1517241 - Rename nsIDocument to mozilla::dom::Document. r=smaug
Summary: Really sorry for the size of the patch. It's mostly automatic
s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to
add the right namespacing and such.

Overall it's not a very interesting patch I think.

nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and
nsIDocumentInlines.h into DocumentInlines.h.

I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it.

While fixing up some of the bits I also removed some unneeded OwnerDoc() null
checks and such, but I didn't do anything riskier than that.
2019-01-03 17:48:33 +01:00
Olli Pettay
206bc2b3f9 Bug 1513547, ensure selection objects created for autocopy are cleared as soon as possible, r=ehsan
--HG--
extra : rebase_source : 75b4aef031526d6f7c1517305f560bf60ca26b3f
2018-12-13 15:07:19 +02:00
Sylvestre Ledru
265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Ehsan Akhgari
6f7b03e600 Bug 1504574 - Remove the XPCOM registration for nsDocumentEncoder; r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D10856
2018-11-05 23:16:04 -05:00
Ehsan Akhgari
c78ff51afb Bug 1504566 - Remove the XPCOM registration for nsHTMLCopyEncoder; r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D10958
2018-11-05 17:28:54 -05:00
Masayuki Nakano
9c349ade9b Bug 1487591 - Make Selection treat AccessibleCaretEventHub as concrete class rather than nsISelectionListener r=smaug
AccessibleCaretEventHub is an nsISelectionListener of Selection whose type is
"normal".  This is added only when nsFrameSelection::Init() is called and
accessible caret is enabled.  Additionally, nsFrameSelection::Init() is
always called immediately after creating nsFrameSelection.

Therefore, when AccessibleCaretEventHub is installed to Selection, this is
always second selection listener and won't be installed multiple times.  So,
Selection can store pointer of AccessibleCaretEventHub directly only when
it's enabled and the Selection needs to notify it of selection change.

This patch makes Selection stores AccessibleCaretEventHub with RefPtr, then,
makes Selection::NotifySelectionListeners() call its OnSelectionChange()
immediately after AutoCopyListener.

Unfortunately, this patch includes making of MOZ_CAN_RUN_SCRIPT_BOUNDARY and
MOZ_CAN_RUN_SCRIPT a lot since some methods of AccessibleCaretEventHub are
marked as MOZ_CAN_RUN_SCRIPT and including AccessibleCaretEventHub.h into
Selection.h causes compile the compile errors.

Differential Revision: https://phabricator.services.mozilla.com/D4733

--HG--
extra : moz-landing-system : lando
2018-08-31 21:19:44 +00:00
Adrian Wielgosik
be0c1a4f55 Bug 1481645 - Remove some redundant uses of do_QueryInterface. r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D2893

--HG--
extra : moz-landing-system : lando
2018-08-13 09:05:19 +00:00
Andi-Bogdan Postelnicu
88cc63910d Bug 1453795 - DOM - Initialize member fields in classes/ structures. r=peterv
--HG--
extra : rebase_source : 249fc26e50bded4e94f5effa4308af0f1e54b908
2018-06-16 17:21:46 +03:00